Fix address form not loading

This commit is contained in:
Lukasz Ostrowski 2023-05-11 12:15:01 +02:00
parent 8b22b1c1f8
commit ee1a4afd25
3 changed files with 17 additions and 10 deletions

View file

@ -0,0 +1,5 @@
---
"saleor-app-invoices": patch
---
Fixed address form not loading if not data was set before

View file

@ -4,14 +4,14 @@ export const AddressV2Schema = z.object({
/** /**
* min() to allow empty strings * min() to allow empty strings
*/ */
companyName: z.string().min(0), companyName: z.string().optional(),
cityArea: z.string().min(0), cityArea: z.string().optional(),
countryArea: z.string().min(0), countryArea: z.string().optional(),
streetAddress1: z.string().min(0), streetAddress1: z.string().optional(),
streetAddress2: z.string().min(0), streetAddress2: z.string().optional(),
postalCode: z.string().min(0), postalCode: z.string().optional(),
city: z.string().min(0), city: z.string().optional(),
country: z.string().min(0), country: z.string().optional(),
}); });
export const AppConfigV2Schema = z.object({ export const AppConfigV2Schema = z.object({
channelsOverrides: z.record(AddressV2Schema), channelsOverrides: z.record(AddressV2Schema),

View file

@ -181,7 +181,9 @@ export const ConnectedAddressForm = (props: Props) => {
push("/configuration"); push("/configuration");
}, [push]); }, [push]);
if (channelOverrideConfigQuery.isLoading || !addressData) { console.log(addressData);
if (channelOverrideConfigQuery.isLoading) {
return <Text color={"textNeutralSubdued"}>Loading</Text>; return <Text color={"textNeutralSubdued"}>Loading</Text>;
} }
@ -189,7 +191,7 @@ export const ConnectedAddressForm = (props: Props) => {
<AddressForm <AddressForm
onCancel={onCancelHandler} onCancel={onCancelHandler}
onSubmit={submitHandler} onSubmit={submitHandler}
address={channelOverrideConfigQuery.data[props.channelSlug]} address={channelOverrideConfigQuery.data![props.channelSlug]}
channelSlug={props.channelSlug} channelSlug={props.channelSlug}
/> />
); );