fix
This commit is contained in:
parent
2335da5230
commit
f9d87ebb0f
|
|
@ -1,4 +1,6 @@
|
||||||
|
import React from 'react'
|
||||||
export const translateOptions = (options: any, t: any) => {
|
export const translateOptions = (options: any, t: any) => {
|
||||||
|
if(React.isValidElement(options?.[0].name))return options;
|
||||||
return options?.map((opt: any) => ({
|
return options?.map((opt: any) => ({
|
||||||
...opt,
|
...opt,
|
||||||
label: t(`${opt?.label}`),
|
label: t(`${opt?.label}`),
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ const AddModel: React.FC = () => {
|
||||||
handleSubmit={handleSubmit}
|
handleSubmit={handleSubmit}
|
||||||
getInitialValues={getInitialValues(objectToEdit)}
|
getInitialValues={getInitialValues(objectToEdit)}
|
||||||
getValidationSchema={getValidationSchema}
|
getValidationSchema={getValidationSchema}
|
||||||
|
canClearObjectToEdit = {false}
|
||||||
>
|
>
|
||||||
<ModelBody />
|
<ModelBody />
|
||||||
</LayoutModel>
|
</LayoutModel>
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ interface LayoutModalProps {
|
||||||
ModelClassName?: string;
|
ModelClassName?: string;
|
||||||
width?: string;
|
width?: string;
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
|
canClearObjectToEdit?:boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const LayoutModel = ({
|
const LayoutModel = ({
|
||||||
|
|
@ -34,6 +35,7 @@ const LayoutModel = ({
|
||||||
ModelClassName,
|
ModelClassName,
|
||||||
width = "800px",
|
width = "800px",
|
||||||
isLoading = false,
|
isLoading = false,
|
||||||
|
canClearObjectToEdit =true
|
||||||
}: LayoutModalProps) => {
|
}: LayoutModalProps) => {
|
||||||
const { isOpen, setIsOpen } = useModalState((state) => state);
|
const { isOpen, setIsOpen } = useModalState((state) => state);
|
||||||
const { setObjectToEdit } = useObjectToEdit();
|
const { setObjectToEdit } = useObjectToEdit();
|
||||||
|
|
@ -51,8 +53,9 @@ const LayoutModel = ({
|
||||||
}, [setIsOpen, status]);
|
}, [setIsOpen, status]);
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
|
console.log(true)
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
setObjectToEdit({});
|
canClearObjectToEdit && setObjectToEdit({});
|
||||||
formik.resetForm();
|
formik.resetForm();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,14 @@ const Form = ({ handleCloseModel = () => {} }: ModalBodyProps) => {
|
||||||
|
|
||||||
const student_info = objectToEdit?.data?.data;
|
const student_info = objectToEdit?.data?.data;
|
||||||
const status = objectToEdit?.data?.status;
|
const status = objectToEdit?.data?.status;
|
||||||
const PackagesInfo = student_info?.packages.map((info: any) => ({
|
const PackagesInfo = student_info?.packages?.map((info: any) => ({
|
||||||
id: info?.id,
|
id: info?.id,
|
||||||
name: info.name + " " + `( ${info?.original_price} )`,
|
name:(
|
||||||
|
<div>
|
||||||
|
{info.name } ( <span className={`${info?.coupon_id !== null && 'removed_sales'}`}>{info?.original_price.toLocaleString("en-US")}</span> )
|
||||||
|
{info?.coupon_id !== null && <span className="new_sales"> {info?.final_price.toLocaleString("en-US")}</span>}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ const Form = ({ handleCloseModel = () => {} }: ModalBodyProps) => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
|
||||||
const { mutate, status, error, reset }: any = useAddSales();
|
const { mutate, status, error, reset }: any = useAddSales();
|
||||||
const coupon_id_object = objectToEdit?.data?.data?.packages.find(
|
const coupon_id_object = objectToEdit?.data?.data?.packages.find(
|
||||||
(e: any) => e.id === values?.package_id,
|
(e: any) => e.id === values?.package_id,
|
||||||
|
|
@ -27,7 +28,12 @@ const Form = ({ handleCloseModel = () => {} }: ModalBodyProps) => {
|
||||||
const student_info = objectToEdit?.data?.data;
|
const student_info = objectToEdit?.data?.data;
|
||||||
const PackagesInfo = student_info?.packages.map((info: any) => ({
|
const PackagesInfo = student_info?.packages.map((info: any) => ({
|
||||||
id: info?.id,
|
id: info?.id,
|
||||||
name: info.name + " " + `( ${info?.original_price} )`,
|
name:(
|
||||||
|
<div>
|
||||||
|
{info.name } ( <span className={`${info?.coupon_id !== null && 'removed_sales disapled'}`}>{info?.original_price.toLocaleString("en-US")}</span> )
|
||||||
|
{info?.coupon_id !== null && <span className="new_sales disapled"> {info?.final_price.toLocaleString("en-US")}</span>}
|
||||||
|
</div>
|
||||||
|
),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const handleNext = () => {
|
const handleNext = () => {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ const Form = ({ handleCloseModel = () => {} }: ModalBodyProps) => {
|
||||||
const { values, setFieldValue } = useFormikContext<any>();
|
const { values, setFieldValue } = useFormikContext<any>();
|
||||||
const phoneNumber: number = values?.phone_number;
|
const phoneNumber: number = values?.phone_number;
|
||||||
|
|
||||||
const { data, status, isSuccess } = useGetStudentByPhone(
|
const { data, status, isSuccess,isError } = useGetStudentByPhone(
|
||||||
{
|
{
|
||||||
phone_number: phoneNumber,
|
phone_number: phoneNumber,
|
||||||
},
|
},
|
||||||
|
|
@ -36,12 +36,13 @@ const Form = ({ handleCloseModel = () => {} }: ModalBodyProps) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSuccess) {
|
if (isSuccess && data?.data) {
|
||||||
setTriggerApi(false);
|
setTriggerApi(false);
|
||||||
setObjectToEdit({ data });
|
setObjectToEdit({ data });
|
||||||
|
console.log(isSuccess)
|
||||||
setFieldValue("currentModalIndex", values?.currentModalIndex + 1);
|
setFieldValue("currentModalIndex", values?.currentModalIndex + 1);
|
||||||
}
|
}
|
||||||
}, [isSuccess]);
|
}, [isSuccess,isError,status]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
values?.currentModalIndex == 0 && (
|
values?.currentModalIndex == 0 && (
|
||||||
|
|
|
||||||
|
|
@ -318,3 +318,17 @@ button:disabled {
|
||||||
height: 40px;
|
height: 40px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.removed_sales{
|
||||||
|
color: #dc2626;
|
||||||
|
text-decoration: line-through;
|
||||||
|
&.disapled{
|
||||||
|
color: #dc26268b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.new_sales{
|
||||||
|
color:green;
|
||||||
|
&.disapled{
|
||||||
|
color:rgba(0, 128, 0, 0.499);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user