Procházet zdrojové kódy

fix(dashboard): Fix positioning of toasts

Michael Bromley před 7 měsíci
rodič
revize
38785e7f4b

+ 1 - 4
packages/dashboard/src/app/routes/_authenticated/_administrators/administrators_.$id.tsx

@@ -70,9 +70,7 @@ function AdministratorDetailPage() {
         },
         params: { id: params.id },
         onSuccess: async data => {
-            toast(i18n.t('Successfully updated administrator'), {
-                position: 'top-right',
-            });
+            toast(i18n.t('Successfully updated administrator'));
             resetForm();
             if (creatingNewEntity) {
                 await navigate({ to: `../$id`, params: { id: data.id } });
@@ -80,7 +78,6 @@ function AdministratorDetailPage() {
         },
         onError: err => {
             toast(i18n.t('Failed to update administrator'), {
-                position: 'top-right',
                 description: err instanceof Error ? err.message : 'Unknown error',
             });
         },

+ 1 - 5
packages/dashboard/src/app/routes/_authenticated/_channels/channels_.$id.tsx

@@ -76,23 +76,19 @@ function ChannelDetailPage() {
         params: { id: params.id },
         onSuccess: async data => {
             if (data.__typename === 'Channel') {
-                toast(i18n.t('Successfully updated channel'), {
-                    position: 'top-right',
-                });
+                toast(i18n.t('Successfully updated channel'));
                 resetForm();
                 if (creatingNewEntity) {
                     await navigate({ to: `../$id`, params: { id: data.id } });
                 }
             } else {
                 toast(i18n.t('Failed to update channel'), {
-                    position: 'top-right',
                     description: data.message,
                 });
             }
         },
         onError: err => {
             toast(i18n.t('Failed to update channel'), {
-                position: 'top-right',
                 description: err instanceof Error ? err.message : 'Unknown error',
             });
         },

+ 1 - 4
packages/dashboard/src/app/routes/_authenticated/_collections/collections_.$id.tsx

@@ -85,9 +85,7 @@ function CollectionDetailPage() {
         },
         params: { id: params.id },
         onSuccess: async data => {
-            toast(i18n.t('Successfully updated collection'), {
-                position: 'top-right',
-            });
+            toast(i18n.t('Successfully updated collection'));
             resetForm();
             if (creatingNewEntity) {
                 await navigate({ to: `../$id`, params: { id: data.id } });
@@ -95,7 +93,6 @@ function CollectionDetailPage() {
         },
         onError: err => {
             toast(i18n.t('Failed to update collection'), {
-                position: 'top-right',
                 description: err instanceof Error ? err.message : 'Unknown error',
             });
         },

+ 1 - 4
packages/dashboard/src/app/routes/_authenticated/_countries/countries_.$id.tsx

@@ -57,9 +57,7 @@ function CountryDetailPage() {
         },
         params: { id: params.id },
         onSuccess: async data => {
-            toast(i18n.t('Successfully updated country'), {
-                position: 'top-right',
-            });
+            toast(i18n.t('Successfully updated country'));
             form.reset(form.getValues());
             if (creatingNewEntity) {
                 await navigate({ to: `../$id`, params: { id: data.id } });
@@ -67,7 +65,6 @@ function CountryDetailPage() {
         },
         onError: err => {
             toast(i18n.t('Failed to update country'), {
-                position: 'top-right',
                 description: err instanceof Error ? err.message : 'Unknown error',
             });
         },

+ 1 - 4
packages/dashboard/src/app/routes/_authenticated/_facets/facets_.$id.tsx

@@ -68,9 +68,7 @@ function FacetDetailPage() {
         },
         params: { id: params.id },
         onSuccess: async data => {
-            toast(i18n.t('Successfully updated facet'), {
-                position: 'top-right',
-            });
+            toast(i18n.t('Successfully updated facet'));
             resetForm();
             if (creatingNewEntity) {
                 await navigate({ to: `../$id`, params: { id: data.id } });
@@ -78,7 +76,6 @@ function FacetDetailPage() {
         },
         onError: err => {
             toast(i18n.t('Failed to update facet'), {
-                position: 'top-right',
                 description: err instanceof Error ? err.message : 'Unknown error',
             });
         },

+ 1 - 5
packages/dashboard/src/app/routes/_authenticated/_global-settings/global-settings.tsx

@@ -59,23 +59,19 @@ function GlobalSettingsPage() {
         params: { id: 'undefined' },
         onSuccess: async data => {
             if (data.__typename === 'GlobalSettings') {
-                toast(i18n.t('Successfully updated global settings'), {
-                    position: 'top-right',
-                });
+                toast(i18n.t('Successfully updated global settings'));
                 form.reset(form.getValues());
                 if (creatingNewEntity) {
                     await navigate({ to: `../$id`, params: { id: data.id } });
                 }
             } else {
                 toast(i18n.t('Failed to update global settings'), {
-                    position: 'top-right',
                     description: data.message,
                 });
             }
         },
         onError: err => {
             toast(i18n.t('Failed to update global settings'), {
-                position: 'top-right',
                 description: err instanceof Error ? err.message : 'Unknown error',
             });
         },

+ 56 - 74
packages/dashboard/src/app/routes/_authenticated/_product-variants/product-variants_.$id.tsx

@@ -7,14 +7,7 @@ import { PermissionGuard } from '@/components/shared/permission-guard.js';
 import { TaxCategorySelector } from '@/components/shared/tax-category-selector.js';
 import { TranslatableFormFieldWrapper } from '@/components/shared/translatable-form-field.js';
 import { Button } from '@/components/ui/button.js';
-import {
-    FormControl,
-    FormDescription,
-    FormField,
-    FormItem,
-    FormLabel,
-    FormMessage,
-} from '@/components/ui/form.js';
+import { FormControl, FormDescription, FormItem, FormLabel, FormMessage } from '@/components/ui/form.js';
 import { Input } from '@/components/ui/input.js';
 import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select.js';
 import { Switch } from '@/components/ui/switch.js';
@@ -194,17 +187,15 @@ function ProductVariantDetailPage() {
                                 <FormFieldWrapper
                                     control={form.control}
                                     name={`stockLevels.${index}.stockOnHand`}
+                                    label={<Trans>Stock level</Trans>}
                                     render={({ field }) => (
-                                        <FormItem>
-                                            <FormLabel>
-                                                <Trans>Stock level</Trans>
-                                            </FormLabel>
-                                            <FormControl>
-                                                <Input type="number" value={field.value} onChange={e => {
-                                                    field.onChange(e.target.valueAsNumber);
-                                                }} />
-                                            </FormControl>
-                                        </FormItem>
+                                        <Input
+                                            type="number"
+                                            value={field.value}
+                                            onChange={e => {
+                                                field.onChange(e.target.valueAsNumber);
+                                            }}
+                                        />
                                     )}
                                 />
                                 <div>
@@ -218,77 +209,68 @@ function ProductVariantDetailPage() {
                             </Fragment>
                         ))}
 
-                        <FormField
+                        <FormFieldWrapper
                             control={form.control}
                             name="trackInventory"
+                            label={<Trans>Stock levels</Trans>}
                             render={({ field }) => (
-                                <FormItem>
-                                    <FormLabel>
-                                        <Trans>Track inventory</Trans>
-                                    </FormLabel>
-                                    <Select onValueChange={val => {
+                                <Select
+                                    onValueChange={val => {
                                         if (val) {
-                                            field.onChange(val)
+                                            field.onChange(val);
                                         }
-                                    }} value={field.value}>
-                                        <FormControl>
-                                            <SelectTrigger className="">
-                                                <SelectValue placeholder="Track inventory" />
-                                            </SelectTrigger>
-                                        </FormControl>
-                                        <SelectContent>
-                                            <SelectItem value="INHERIT">
-                                                <Trans>Inherit from global settings</Trans>
-                                            </SelectItem>
-                                            <SelectItem value="TRUE">
-                                                <Trans>Track</Trans>
-                                            </SelectItem>
-                                            <SelectItem value="FALSE">
-                                                <Trans>Do not track</Trans>
-                                            </SelectItem>
-                                        </SelectContent>
-                                    </Select>
-                                </FormItem>
+                                    }}
+                                    value={field.value}
+                                >
+                                    <FormControl>
+                                        <SelectTrigger className="">
+                                            <SelectValue placeholder="Track inventory" />
+                                        </SelectTrigger>
+                                    </FormControl>
+                                    <SelectContent>
+                                        <SelectItem value="INHERIT">
+                                            <Trans>Inherit from global settings</Trans>
+                                        </SelectItem>
+                                        <SelectItem value="TRUE">
+                                            <Trans>Track</Trans>
+                                        </SelectItem>
+                                        <SelectItem value="FALSE">
+                                            <Trans>Do not track</Trans>
+                                        </SelectItem>
+                                    </SelectContent>
+                                </Select>
                             )}
                         />
-                        <FormField
+                        <FormFieldWrapper
                             control={form.control}
                             name="outOfStockThreshold"
+                            label={<Trans>Out-of-stock threshold</Trans>}
+                            description={
+                                <Trans>
+                                    Sets the stock level at which this variant is considered to be out of
+                                    stock. Using a negative value enables backorder support.
+                                </Trans>
+                            }
                             render={({ field }) => (
-                                <FormItem>
-                                    <FormLabel>
-                                        <Trans>Out-of-stock threshold</Trans>
-                                    </FormLabel>
-                                    <FormControl>
-                                        <Input type="number" {...field} />
-                                    </FormControl>
-                                    <FormDescription>
-                                        <Trans>
-                                            Sets the stock level at which this variant is considered to be out
-                                            of stock. Using a negative value enables backorder support.
-                                        </Trans>
-                                    </FormDescription>
-                                </FormItem>
+                                <Input
+                                    type="number"
+                                    value={field.value}
+                                    onChange={e => field.onChange(e.target.valueAsNumber)}
+                                />
                             )}
                         />
-                        <FormField
+                        <FormFieldWrapper
                             control={form.control}
                             name="useGlobalOutOfStockThreshold"
+                            label={<Trans>Use global out-of-stock threshold</Trans>}
+                            description={
+                                <Trans>
+                                    Sets the stock level at which this variant is considered to be out of
+                                    stock. Using a negative value enables backorder support.
+                                </Trans>
+                            }
                             render={({ field }) => (
-                                <FormItem>
-                                    <FormLabel>
-                                        <Trans>Use global out-of-stock threshold</Trans>
-                                    </FormLabel>
-                                    <FormControl>
-                                        <Switch checked={field.value} onCheckedChange={field.onChange} />
-                                    </FormControl>
-                                    <FormDescription>
-                                        <Trans>
-                                            Sets the stock level at which this variant is considered to be out
-                                            of stock. Using a negative value enables backorder support.
-                                        </Trans>
-                                    </FormDescription>
-                                </FormItem>
+                                <Switch checked={field.value} onCheckedChange={field.onChange} />
                             )}
                         />
                     </DetailFormGrid>

+ 1 - 1
packages/dashboard/src/app/routes/_authenticated/_products/products_.$id.tsx

@@ -68,7 +68,7 @@ function ProductDetailPage() {
                     description: translation.description,
                     customFields: (translation as any).customFields,
                 })),
-                customFields: entity.customFields,
+                customFields: entity.customFields as any,
             };
         },
         params: { id: params.id },

+ 1 - 4
packages/dashboard/src/app/routes/_authenticated/_profile/profile.tsx

@@ -58,14 +58,11 @@ function ProfilePage() {
         },
         params: { id: 'undefined' },
         onSuccess: async data => {
-            toast(i18n.t('Successfully updated profile'), {
-                position: 'top-right',
-            });
+            toast(i18n.t('Successfully updated profile'));
             form.reset(form.getValues());
         },
         onError: err => {
             toast(i18n.t('Failed to update profile'), {
-                position: 'top-right',
                 description: err instanceof Error ? err.message : 'Unknown error',
             });
         },

+ 1 - 4
packages/dashboard/src/app/routes/_authenticated/_sellers/sellers_.$id.tsx

@@ -51,9 +51,7 @@ function SellerDetailPage() {
         },
         params: { id: params.id },
         onSuccess: async data => {
-            toast(i18n.t('Successfully updated seller'), {
-                position: 'top-right',
-            });
+            toast(i18n.t('Successfully updated seller'));
             form.reset(form.getValues());
             if (creatingNewEntity) {
                 await navigate({ to: `../${data?.id}`, from: Route.id });
@@ -61,7 +59,6 @@ function SellerDetailPage() {
         },
         onError: err => {
             toast(i18n.t('Failed to update seller'), {
-                position: 'top-right',
                 description: err instanceof Error ? err.message : 'Unknown error',
             });
         },