1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

(quality) clean code

This commit is contained in:
Du Peng 2022-10-20 18:30:39 +02:00
parent c43ce2b142
commit 531b8d4947

View File

@ -1,6 +1,5 @@
/* eslint-disable */
import React, { useState, useEffect } from 'react';
import { SubmitHandler, useForm, useWatch } from 'react-hook-form';
import React from 'react';
import { SubmitHandler, useForm } from 'react-hook-form';
import { FormInput } from '../form/form-input';
import { FormSwitch } from '../form/form-switch';
import { useTranslation } from 'react-i18next';
@ -21,11 +20,13 @@ interface CloneProductModalProps {
*/
export const CloneProductModal: React.FC<CloneProductModalProps> = ({ isOpen, toggleModal, onSuccess, onError, product }) => {
const { t } = useTranslation('admin');
const { handleSubmit, register, control, formState, reset } = useForm<Product>({ defaultValues: {
name: product.name,
sku: product.sku,
is_active: false,
} });
const { handleSubmit, register, control, formState, reset } = useForm<Product>({
defaultValues: {
name: product.name,
sku: product.sku,
is_active: false
}
});
/**
* Call product clone api
@ -38,31 +39,31 @@ export const CloneProductModal: React.FC<CloneProductModalProps> = ({ isOpen, to
};
return (
<FabModal title={t('app.admin.store.clone_product_model.clone_product')}
<FabModal title={t('app.admin.store.clone_product_modal.clone_product')}
closeButton
isOpen={isOpen}
toggleModal={toggleModal}
width={ModalSize.medium}
confirmButton={t('app.admin.store.clone_product_model.clone')}
confirmButton={t('app.admin.store.clone_product_modal.clone')}
onConfirm={handleSubmit(handleClone)}>
<form className="clone-product-form" onSubmit={handleSubmit(handleClone)}>
<FormInput id="name"
register={register}
rules={{ required: true }}
formState={formState}
label={t('app.admin.store.product_form.name')}
label={t('app.admin.store.clone_product_modal.name')}
className="span-12" />
<FormInput id="sku"
register={register}
formState={formState}
label={t('app.admin.store.product_form.sku')}
label={t('app.admin.store.clone_product_modal.sku')}
className="span-12" />
{product.is_active &&
<FormSwitch control={control}
id="is_active"
formState={formState}
label={t('app.admin.store.product_form.is_show_in_store')}
tooltip={t('app.admin.store.product_form.active_price_info')}
label={t('app.admin.store.clone_product_modal.is_show_in_store')}
tooltip={t('app.admin.store.clone_product_modal.active_price_info')}
className='span-12' />
}
</form>