Compare commits
No commits in common. "7480f9c1d89c31c9718b40144f942daa248aa5db" and "ede1b85c1ce095327d80ac7d2a0b08f46f5c5c35" have entirely different histories.
7480f9c1d8
...
ede1b85c1c
@ -1,80 +0,0 @@
|
|||||||
import React, { useEffect } from "react";
|
|
||||||
import { useForm } from "react-hook-form";
|
|
||||||
import { z } from "zod";
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import { useCreatePaymentMode } from "../../hooks/masterHook/useMaster";
|
|
||||||
|
|
||||||
const ExpnseSchema = z.object({
|
|
||||||
name: z.string().min(1, { message: "Name is required" }),
|
|
||||||
description: z.string().min(1, { message: "Description is required" }),
|
|
||||||
});
|
|
||||||
|
|
||||||
const ManagePaymentMode = ({ data = null, onClose }) => {
|
|
||||||
const {
|
|
||||||
register,
|
|
||||||
handleSubmit,
|
|
||||||
reset,
|
|
||||||
formState: { errors },
|
|
||||||
} = useForm({
|
|
||||||
resolver: zodResolver(ExpnseSchema),
|
|
||||||
defaultValues: { name: "", noOfPersonsRequired: false, description: "" },
|
|
||||||
});
|
|
||||||
|
|
||||||
const { mutate: CreatePaymentMode, isPending } = useCreatePaymentMode(() =>
|
|
||||||
onClose?.()
|
|
||||||
);
|
|
||||||
|
|
||||||
const onSubmit = (payload) => {
|
|
||||||
CreatePaymentMode(payload);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
|
||||||
<form className="row g-2" onSubmit={handleSubmit(onSubmit)}>
|
|
||||||
<div className="col-12 col-md-12">
|
|
||||||
<label className="form-label">Payment Mode Name</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
{...register("name")}
|
|
||||||
className={`form-control ${errors.name ? "is-invalids" : ""}`}
|
|
||||||
/>
|
|
||||||
{errors.name && <p className="danger-text">{errors.name.message}</p>}
|
|
||||||
</div>
|
|
||||||
<div className="col-12 col-md-12">
|
|
||||||
<label className="form-label" htmlFor="description">
|
|
||||||
Description
|
|
||||||
</label>
|
|
||||||
<textarea
|
|
||||||
rows="3"
|
|
||||||
{...register("description")}
|
|
||||||
className={`form-control ${errors.description ? "is-invalids" : ""}`}
|
|
||||||
></textarea>
|
|
||||||
|
|
||||||
{errors.description && (
|
|
||||||
<p className="danger-text">{errors.description.message}</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="col-12 text-center">
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
className="btn btn-sm btn-primary me-3"
|
|
||||||
disabled={isPending }
|
|
||||||
>
|
|
||||||
{isPending ? "Please Wait..." : "Submit"}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="reset"
|
|
||||||
className="btn btn-sm btn-label-secondary "
|
|
||||||
data-bs-dismiss="modal"
|
|
||||||
aria-label="Close"
|
|
||||||
disabled={isPending}
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ManagePaymentMode;
|
|
||||||
@ -18,7 +18,6 @@ import EditContactCategory from "./EditContactCategory";
|
|||||||
import EditContactTag from "./EditContactTag";
|
import EditContactTag from "./EditContactTag";
|
||||||
import { useDeleteMasterItem } from "../../hooks/masterHook/useMaster";
|
import { useDeleteMasterItem } from "../../hooks/masterHook/useMaster";
|
||||||
import ManageExpenseType from "./ManageExpenseType";
|
import ManageExpenseType from "./ManageExpenseType";
|
||||||
import ManagePaymentMode from "./ManagePaymentMode";
|
|
||||||
|
|
||||||
|
|
||||||
const MasterModal = ({ modaldata, closeModal }) => {
|
const MasterModal = ({ modaldata, closeModal }) => {
|
||||||
@ -91,8 +90,7 @@ const MasterModal = ({ modaldata, closeModal }) => {
|
|||||||
"Contact Tag": <CreateContactTag data={item} onClose={closeModal} />,
|
"Contact Tag": <CreateContactTag data={item} onClose={closeModal} />,
|
||||||
"Edit-Contact Tag": <EditContactTag data={item} onClose={closeModal} />,
|
"Edit-Contact Tag": <EditContactTag data={item} onClose={closeModal} />,
|
||||||
"Expense Type":<ManageExpenseType onClose={closeModal} />,
|
"Expense Type":<ManageExpenseType onClose={closeModal} />,
|
||||||
"Edit-Expense Type":<ManageExpenseType data={item} onClose={closeModal} />,
|
"Edit-Expense Type":<ManageExpenseType data={item} onClose={closeModal} />
|
||||||
"Payment Mode":<ManagePaymentMode onClose={closeModal}/>
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return modalComponents[modalType] || null;
|
return modalComponents[modalType] || null;
|
||||||
|
|||||||
@ -582,30 +582,6 @@ export const useUpdateExpenseType = (onSuccessCallback) =>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------Payment Mode -------------
|
|
||||||
|
|
||||||
export const useCreatePaymentMode = (onSuccessCallback)=>{
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
|
|
||||||
return useMutation( {
|
|
||||||
mutationFn: async ( payload ) =>
|
|
||||||
{
|
|
||||||
const resp = await MasterRespository.createPaymentMode(payload);
|
|
||||||
return resp.data;
|
|
||||||
},
|
|
||||||
onSuccess: ( data ) =>
|
|
||||||
{
|
|
||||||
queryClient.invalidateQueries( {queryKey:[ "masterData", "Payment Mode" ]} )
|
|
||||||
showToast( "Payment Mode added successfully", "success" );
|
|
||||||
if(onSuccessCallback) onSuccessCallback(data)
|
|
||||||
},
|
|
||||||
onError: ( error ) =>
|
|
||||||
{
|
|
||||||
showToast(error.message || "Something went wrong", "error");
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// -Delete Master --------
|
// -Delete Master --------
|
||||||
export const useDeleteMasterItem = () => {
|
export const useDeleteMasterItem = () => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|||||||
@ -65,7 +65,6 @@ export const MasterRespository = {
|
|||||||
|
|
||||||
|
|
||||||
getPaymentMode:()=>api.get('/api/Master/payment-modes'),
|
getPaymentMode:()=>api.get('/api/Master/payment-modes'),
|
||||||
createPaymentMode:(data)=>api.post(`/api/Master/payment-mode`,data),
|
|
||||||
|
|
||||||
|
|
||||||
getExpenseStatus:()=>api.get('/api/Master/expenses-status')
|
getExpenseStatus:()=>api.get('/api/Master/expenses-status')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user