+
+
+ ),
+ },
+ } ) }
+ />
+
+ ),
+ },
+ } ) }
+ help={
+ inputDescriptionProps?.help ??
+ __(
+ 'Describe how you and other store administrators can use this shipping class.',
+ 'woocommerce'
+ )
+ }
+ />
+
+
+
+
+
+ );
+}
+
+function validateForm(
+ values: Partial< ProductShippingClass >
+): FormErrors< ProductShippingClass > {
+ const errors: FormErrors< ProductShippingClass > = {};
+
+ if ( ! values.name?.length ) {
+ errors.name = __(
+ 'The shipping class name is required.',
+ 'woocommerce'
+ );
+ }
+
+ return errors;
+}
+
+export type AddNewShippingClassModalProps = {
+ shippingClass?: Partial< ProductShippingClass >;
+ onAdd: (
+ shippingClass: Partial< ProductShippingClass >
+ ) => Promise< ProductShippingClass >;
+ onCancel: () => void;
+};
+
+const INITIAL_VALUES = {
+ name: __( 'New shipping class', 'woocommerce' ),
+ slug: __( 'new-shipping-class', 'woocommerce' ),
+};
+
+export function AddNewShippingClassModal( {
+ shippingClass,
+ onAdd,
+ onCancel,
+}: AddNewShippingClassModalProps ) {
+ return (
+