@@ -21,6 +21,7 @@ import {
2121 createProductVariantsDocument ,
2222} from '../products.graphql.js' ;
2323import { CreateProductVariants , VariantConfiguration } from './create-product-variants.js' ;
24+ import { toast } from 'sonner' ;
2425
2526export function CreateProductVariantsDialog ( {
2627 productId,
@@ -128,7 +129,13 @@ export function CreateProductVariantsDialog({
128129 onSuccess ?.( ) ;
129130 } catch ( error ) {
130131 console . error ( 'Error creating variants:' , error ) ;
131- // Handle error (show toast notification, etc.)
132+
133+ const fieldErrors = ( error as any ) ?. fieldErrors ;
134+ const errorMessage =
135+ fieldErrors ?. [ 0 ] ?. message ??
136+ 'An unexpected error occurred while creating variants.' ;
137+
138+ toast . error ( errorMessage ) ;
132139 }
133140 }
134141
@@ -175,8 +182,8 @@ export function CreateProductVariantsDialog({
175182 }
176183 >
177184 { createOptionGroupMutation . isPending ||
178- addOptionGroupToProductMutation . isPending ||
179- createProductVariantsMutation . isPending ? (
185+ addOptionGroupToProductMutation . isPending ||
186+ createProductVariantsMutation . isPending ? (
180187 < Trans > Creating...</ Trans >
181188 ) : (
182189 < Trans > Create { createCount } variants</ Trans >
0 commit comments