33 useActionData ,
44 useLoaderData ,
55 useSubmit ,
6- useNavigation ,
7- useNavigate ,
86 useParams ,
97} from "react-router" ;
108import { authenticate } from "../shopify.server" ;
@@ -39,12 +37,9 @@ export async function loader({ request, params }) {
3937
4038// [START action]
4139export async function action ( { request, params } ) {
42- const { session , admin, redirect } = await authenticate . admin ( request ) ;
40+ const { admin, redirect } = await authenticate . admin ( request ) ;
4341
44- /** @type {any } */
45- const data = {
46- ...Object . fromEntries ( await request . formData ( ) ) ,
47- } ;
42+ const data = Object . fromEntries ( await request . formData ( ) ) ;
4843
4944 if ( data . action === "delete" ) {
5045 await deleteQRCode ( data . metaobjectId , admin . graphql ) ;
@@ -72,7 +67,6 @@ export async function action({ request, params }) {
7267// [END action]
7368
7469export default function QRCodeForm ( ) {
75- const navigate = useNavigate ( ) ;
7670 const { id } = useParams ( ) ;
7771
7872 // [START state]
@@ -81,7 +75,6 @@ export default function QRCodeForm() {
8175 const [ initialFormState , setInitialFormState ] = useState ( qrCode ) ;
8276 const [ formState , setFormState ] = useState ( qrCode ) ;
8377 const errors = useActionData ( ) ?. errors || { } ;
84- const isSaving = useNavigation ( ) . state === "submitting" ;
8578 const isDirty =
8679 JSON . stringify ( formState ) !== JSON . stringify ( initialFormState ) ;
8780 // [END state]
@@ -185,6 +178,7 @@ export default function QRCodeForm() {
185178 < button variant = "primary" onClick = { handleSave } > </ button >
186179 < button onClick = { handleReset } > </ button >
187180 </ ui-save-bar >
181+ { /* [END save-bar] */ }
188182 < form onSubmit = { handleSave } onReset = { handleReset } >
189183 { /* [START polaris] */ }
190184 < s-page heading = { initialFormState . title || "Create QR code" } >
@@ -316,7 +310,10 @@ export default function QRCodeForm() {
316310 </ s-button >
317311 ) }
318312 { errors . productId ? (
319- < s-text tone = "critical" > { errors . productId } </ s-text >
313+ < div style = { { display : "flex" , alignItems : "center" , gap : "4px" } } >
314+ < s-icon type = "alert-circle" tone = "critical" size = "small" />
315+ < s-text tone = "critical" variant = "bodySm" > { errors . productId } </ s-text >
316+ </ div >
320317 ) : null }
321318 </ s-stack >
322319 </ s-stack >
0 commit comments