mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-01 12:24:28 +01:00
(quality) clean code
This commit is contained in:
parent
c43ce2b142
commit
531b8d4947
@ -1,6 +1,5 @@
|
|||||||
/* eslint-disable */
|
import React from 'react';
|
||||||
import React, { useState, useEffect } from 'react';
|
import { SubmitHandler, useForm } from 'react-hook-form';
|
||||||
import { SubmitHandler, useForm, useWatch } from 'react-hook-form';
|
|
||||||
import { FormInput } from '../form/form-input';
|
import { FormInput } from '../form/form-input';
|
||||||
import { FormSwitch } from '../form/form-switch';
|
import { FormSwitch } from '../form/form-switch';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@ -21,11 +20,13 @@ interface CloneProductModalProps {
|
|||||||
*/
|
*/
|
||||||
export const CloneProductModal: React.FC<CloneProductModalProps> = ({ isOpen, toggleModal, onSuccess, onError, product }) => {
|
export const CloneProductModal: React.FC<CloneProductModalProps> = ({ isOpen, toggleModal, onSuccess, onError, product }) => {
|
||||||
const { t } = useTranslation('admin');
|
const { t } = useTranslation('admin');
|
||||||
const { handleSubmit, register, control, formState, reset } = useForm<Product>({ defaultValues: {
|
const { handleSubmit, register, control, formState, reset } = useForm<Product>({
|
||||||
|
defaultValues: {
|
||||||
name: product.name,
|
name: product.name,
|
||||||
sku: product.sku,
|
sku: product.sku,
|
||||||
is_active: false,
|
is_active: false
|
||||||
} });
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call product clone api
|
* Call product clone api
|
||||||
@ -38,31 +39,31 @@ export const CloneProductModal: React.FC<CloneProductModalProps> = ({ isOpen, to
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FabModal title={t('app.admin.store.clone_product_model.clone_product')}
|
<FabModal title={t('app.admin.store.clone_product_modal.clone_product')}
|
||||||
closeButton
|
closeButton
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
toggleModal={toggleModal}
|
toggleModal={toggleModal}
|
||||||
width={ModalSize.medium}
|
width={ModalSize.medium}
|
||||||
confirmButton={t('app.admin.store.clone_product_model.clone')}
|
confirmButton={t('app.admin.store.clone_product_modal.clone')}
|
||||||
onConfirm={handleSubmit(handleClone)}>
|
onConfirm={handleSubmit(handleClone)}>
|
||||||
<form className="clone-product-form" onSubmit={handleSubmit(handleClone)}>
|
<form className="clone-product-form" onSubmit={handleSubmit(handleClone)}>
|
||||||
<FormInput id="name"
|
<FormInput id="name"
|
||||||
register={register}
|
register={register}
|
||||||
rules={{ required: true }}
|
rules={{ required: true }}
|
||||||
formState={formState}
|
formState={formState}
|
||||||
label={t('app.admin.store.product_form.name')}
|
label={t('app.admin.store.clone_product_modal.name')}
|
||||||
className="span-12" />
|
className="span-12" />
|
||||||
<FormInput id="sku"
|
<FormInput id="sku"
|
||||||
register={register}
|
register={register}
|
||||||
formState={formState}
|
formState={formState}
|
||||||
label={t('app.admin.store.product_form.sku')}
|
label={t('app.admin.store.clone_product_modal.sku')}
|
||||||
className="span-12" />
|
className="span-12" />
|
||||||
{product.is_active &&
|
{product.is_active &&
|
||||||
<FormSwitch control={control}
|
<FormSwitch control={control}
|
||||||
id="is_active"
|
id="is_active"
|
||||||
formState={formState}
|
formState={formState}
|
||||||
label={t('app.admin.store.product_form.is_show_in_store')}
|
label={t('app.admin.store.clone_product_modal.is_show_in_store')}
|
||||||
tooltip={t('app.admin.store.product_form.active_price_info')}
|
tooltip={t('app.admin.store.clone_product_modal.active_price_info')}
|
||||||
className='span-12' />
|
className='span-12' />
|
||||||
}
|
}
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
Reference in New Issue
Block a user