Compare commits
3 Commits
main
...
Inventary_
| Author | SHA1 | Date | |
|---|---|---|---|
| 69a854174f | |||
| 76abfb5fd3 | |||
| 20b8d9ae01 |
@ -0,0 +1,97 @@
|
|||||||
|
import React, { useEffect } from "react";
|
||||||
|
import { useForm } from "react-hook-form";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import Label from "../../common/Label";
|
||||||
|
import { useCreateProductCategory, useUpdateProductCategory } from "../../../hooks/masterHook/useMaster";
|
||||||
|
|
||||||
|
const ProductCategorySchema = z.object({
|
||||||
|
name: z.string().min(1, { message: "Name is required" }),
|
||||||
|
description: z.string().min(1, { message: "Description is required" }),
|
||||||
|
});
|
||||||
|
|
||||||
|
const ProductCategory = ({ data = null, onClose }) => {
|
||||||
|
const {
|
||||||
|
register,
|
||||||
|
handleSubmit,
|
||||||
|
reset,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm({
|
||||||
|
resolver: zodResolver(ProductCategorySchema),
|
||||||
|
defaultValues: { name: "", description: "" },
|
||||||
|
});
|
||||||
|
|
||||||
|
const { mutate: CreateProductCategory, isPending } = useCreateProductCategory(() =>
|
||||||
|
onClose?.()
|
||||||
|
);
|
||||||
|
const { mutate: UpdateProductCategory, isPending: Updating } = useUpdateProductCategory(() => onClose?.())
|
||||||
|
|
||||||
|
const onSubmit = (payload) => {
|
||||||
|
if (data) {
|
||||||
|
UpdateProductCategory({ id: data.id, payload: { ...payload, id: data.id } })
|
||||||
|
} else (
|
||||||
|
CreateProductCategory(payload)
|
||||||
|
)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (data) {
|
||||||
|
reset({
|
||||||
|
name: data.name ?? "",
|
||||||
|
description: data.description ?? ""
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, [data])
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<form className="row g-2" onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
<div className="col-12 col-md-12 text-start">
|
||||||
|
<Label className="form-label" required>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 text-start">
|
||||||
|
<Label className="form-label" htmlFor="description" required>
|
||||||
|
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-end">
|
||||||
|
<button
|
||||||
|
type="reset"
|
||||||
|
className="btn btn-sm btn-label-secondary me-3"
|
||||||
|
data-bs-dismiss="modal"
|
||||||
|
aria-label="Close"
|
||||||
|
disabled={isPending || Updating}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="btn btn-sm btn-primary"
|
||||||
|
disabled={isPending || Updating}
|
||||||
|
>
|
||||||
|
{isPending || Updating ? "Please Wait..." : Updating ? "Update" : "Submit"}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ProductCategory;
|
||||||
@ -0,0 +1,97 @@
|
|||||||
|
import React, { useEffect } from "react";
|
||||||
|
import { useForm } from "react-hook-form";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import Label from "../../common/Label";
|
||||||
|
import { useCreatePurhaseOrderStatus, useUpdatePurchaseOrderStatus } from "../../../hooks/masterHook/useMaster";
|
||||||
|
|
||||||
|
const PurchaseOrderStatusSchema = z.object({
|
||||||
|
name: z.string().min(1, { message: "Name is required" }),
|
||||||
|
description: z.string().min(1, { message: "Description is required" }),
|
||||||
|
});
|
||||||
|
|
||||||
|
const PurchaseOrderStatus = ({ data = null, onClose }) => {
|
||||||
|
const {
|
||||||
|
register,
|
||||||
|
handleSubmit,
|
||||||
|
reset,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm({
|
||||||
|
resolver: zodResolver(PurchaseOrderStatusSchema),
|
||||||
|
defaultValues: { name: "", description: "" },
|
||||||
|
});
|
||||||
|
|
||||||
|
const { mutate: CreatePurchaseOrderStatus, isPending } = useCreatePurhaseOrderStatus(() =>
|
||||||
|
onClose?.()
|
||||||
|
);
|
||||||
|
const { mutate: UpdatePurchaseOrderStatus, isPending: Updating } = useUpdatePurchaseOrderStatus(() => onClose?.())
|
||||||
|
|
||||||
|
const onSubmit = (payload) => {
|
||||||
|
if (data) {
|
||||||
|
UpdatePurchaseOrderStatus({ id: data.id, payload: { ...payload, id: data.id } })
|
||||||
|
} else (
|
||||||
|
CreatePurchaseOrderStatus(payload)
|
||||||
|
)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (data) {
|
||||||
|
reset({
|
||||||
|
name: data.name ?? "",
|
||||||
|
description: data.description ?? ""
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, [data])
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<form className="row g-2" onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
<div className="col-12 col-md-12 text-start">
|
||||||
|
<Label className="form-label" required>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 text-start">
|
||||||
|
<Label className="form-label" htmlFor="description" required>
|
||||||
|
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-end">
|
||||||
|
<button
|
||||||
|
type="reset"
|
||||||
|
className="btn btn-sm btn-label-secondary me-3"
|
||||||
|
data-bs-dismiss="modal"
|
||||||
|
aria-label="Close"
|
||||||
|
disabled={isPending || Updating}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="btn btn-sm btn-primary"
|
||||||
|
disabled={isPending || Updating}
|
||||||
|
>
|
||||||
|
{isPending || Updating ? "Please Wait..." : Updating ? "Update" : "Submit"}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PurchaseOrderStatus;
|
||||||
@ -0,0 +1,99 @@
|
|||||||
|
import React, { useEffect } from "react";
|
||||||
|
import { useForm } from "react-hook-form";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
// import { useCreatePaymentMode, useUpdatePaymentMode } from "../../hooks/masterHook/useMaster";
|
||||||
|
// import Label from "../common/Label";
|
||||||
|
import Label from "../../common/Label";
|
||||||
|
import { useCreateRequisitionStatus, useUpdateRequisitionStatus } from "../../../hooks/masterHook/useMaster";
|
||||||
|
|
||||||
|
const RequisitionStatusSchema = z.object({
|
||||||
|
name: z.string().min(1, { message: "Name is required" }),
|
||||||
|
description: z.string().min(1, { message: "Description is required" }),
|
||||||
|
});
|
||||||
|
|
||||||
|
const RequisitionStatus = ({ data = null, onClose }) => {
|
||||||
|
const {
|
||||||
|
register,
|
||||||
|
handleSubmit,
|
||||||
|
reset,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm({
|
||||||
|
resolver: zodResolver(RequisitionStatusSchema),
|
||||||
|
defaultValues: { name: "", description: "" },
|
||||||
|
});
|
||||||
|
|
||||||
|
const { mutate: CreateRequisitionStatus, isPending } = useCreateRequisitionStatus(() =>
|
||||||
|
onClose?.()
|
||||||
|
);
|
||||||
|
const { mutate: UpdateRequisitionStatus, isPending: Updating } = useUpdateRequisitionStatus(() => onClose?.())
|
||||||
|
|
||||||
|
const onSubmit = (payload) => {
|
||||||
|
if (data) {
|
||||||
|
UpdateRequisitionStatus({ id: data.id, payload: { ...payload, id: data.id } })
|
||||||
|
} else (
|
||||||
|
CreateRequisitionStatus(payload)
|
||||||
|
)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (data) {
|
||||||
|
reset({
|
||||||
|
name: data.name ?? "",
|
||||||
|
description: data.description ?? ""
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, [data])
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<form className="row g-2" onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
<div className="col-12 col-md-12 text-start">
|
||||||
|
<Label className="form-label" required>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 text-start">
|
||||||
|
<Label className="form-label" htmlFor="description" required>
|
||||||
|
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-end">
|
||||||
|
<button
|
||||||
|
type="reset"
|
||||||
|
className="btn btn-sm btn-label-secondary me-3"
|
||||||
|
data-bs-dismiss="modal"
|
||||||
|
aria-label="Close"
|
||||||
|
disabled={isPending || Updating}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="btn btn-sm btn-primary"
|
||||||
|
disabled={isPending || Updating}
|
||||||
|
>
|
||||||
|
{isPending || Updating ? "Please Wait..." : Updating ? "Update" : "Submit"}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default RequisitionStatus;
|
||||||
@ -17,6 +17,9 @@ import ManageDocumentType from "./ManageDocumentType";
|
|||||||
import ManageServices from "./Services/ManageServices";
|
import ManageServices from "./Services/ManageServices";
|
||||||
import ServiceGroups from "./Services/ServicesGroups";
|
import ServiceGroups from "./Services/ServicesGroups";
|
||||||
import ManagePaymentHead from "./paymentAdjustmentHead/ManagePaymentHead";
|
import ManagePaymentHead from "./paymentAdjustmentHead/ManagePaymentHead";
|
||||||
|
import RequisitionStatus from "./InventoryManagement/RequisitionStatus";
|
||||||
|
import PurchaseOrderStatus from "./InventoryManagement/PurchaseOrderStatus";
|
||||||
|
import ProductCategory from "./InventoryManagement/ProductCategory";
|
||||||
|
|
||||||
const MasterModal = ({ modaldata, closeModal }) => {
|
const MasterModal = ({ modaldata, closeModal }) => {
|
||||||
if (!modaldata?.modalType || modaldata.modalType === "delete") {
|
if (!modaldata?.modalType || modaldata.modalType === "delete") {
|
||||||
@ -62,7 +65,20 @@ const MasterModal = ({ modaldata, closeModal }) => {
|
|||||||
"Edit-Services": <ManageServices data={item} onClose={closeModal} />,
|
"Edit-Services": <ManageServices data={item} onClose={closeModal} />,
|
||||||
"Manage-Services": <ServiceGroups service={item} onClose={closeModal} />,
|
"Manage-Services": <ServiceGroups service={item} onClose={closeModal} />,
|
||||||
"Payment Adjustment Head": <ManagePaymentHead onClose={closeModal} />,
|
"Payment Adjustment Head": <ManagePaymentHead onClose={closeModal} />,
|
||||||
"Edit-Payment Adjustment Head": <ManagePaymentHead data={item} onClose={closeModal} />
|
"Edit-Payment Adjustment Head": <ManagePaymentHead data={item} onClose={closeModal} />,
|
||||||
|
|
||||||
|
"Requisition Status": <RequisitionStatus onClose={closeModal} />,
|
||||||
|
"Edit-Requisition Status": (
|
||||||
|
<RequisitionStatus data={item} onClose={closeModal} />
|
||||||
|
),
|
||||||
|
"Purchase Order Status": <PurchaseOrderStatus onClose={closeModal} />,
|
||||||
|
"Edit-Purchase Order Status": (
|
||||||
|
<PurchaseOrderStatus data={item} onClose={closeModal} />
|
||||||
|
),
|
||||||
|
"Product Category": <ProductCategory onClose={closeModal} />,
|
||||||
|
"Edit-Product Category": (
|
||||||
|
<ProductCategory data={item} onClose={closeModal} />
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -277,7 +277,7 @@ export const useOrganizationType = () => {
|
|||||||
};
|
};
|
||||||
// ===Application Masters Query=================================================
|
// ===Application Masters Query=================================================
|
||||||
|
|
||||||
const fetchMasterData = async (masterType) => {
|
const fetchMasterData = async (masterType,isActiveMaster) => {
|
||||||
switch (masterType) {
|
switch (masterType) {
|
||||||
case "Application Role":
|
case "Application Role":
|
||||||
return (await MasterRespository.getRoles()).data;
|
return (await MasterRespository.getRoles()).data;
|
||||||
@ -305,6 +305,12 @@ const fetchMasterData = async (masterType) => {
|
|||||||
return (await MasterRespository.getDocumentCategories()).data;
|
return (await MasterRespository.getDocumentCategories()).data;
|
||||||
case "Payment Adjustment Head":
|
case "Payment Adjustment Head":
|
||||||
return (await MasterRespository.getPaymentAdjustmentHead(true)).data;
|
return (await MasterRespository.getPaymentAdjustmentHead(true)).data;
|
||||||
|
case "Requisition Status":
|
||||||
|
return (await MasterRespository.getRequisitionStatus(isActiveMaster)).data;
|
||||||
|
case "Purchase Order Status":
|
||||||
|
return (await MasterRespository.getPurchaseOrderStatus(isActiveMaster)).data;
|
||||||
|
case "Product Category":
|
||||||
|
return (await MasterRespository.getProductCategory(isActiveMaster)).data;
|
||||||
case "Status":
|
case "Status":
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -331,20 +337,20 @@ const fetchMasterData = async (masterType) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const useMaster = () => {
|
const useMaster = (isActiveMaster) => {
|
||||||
const selectedMaster = useSelector(
|
const selectedMaster = useSelector(
|
||||||
(store) => store.localVariables.selectedMaster
|
(store) => store.localVariables.selectedMaster
|
||||||
);
|
);
|
||||||
const queryFn = useCallback(
|
const queryFn = useCallback(
|
||||||
() => fetchMasterData(selectedMaster),
|
() => fetchMasterData(selectedMaster, isActiveMaster),
|
||||||
[selectedMaster]
|
[selectedMaster, isActiveMaster]
|
||||||
);
|
);
|
||||||
const {
|
const {
|
||||||
data = [],
|
data = [],
|
||||||
isLoading,
|
isLoading,
|
||||||
error,
|
error,
|
||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ["masterData", selectedMaster],
|
queryKey: ["masterData", selectedMaster,isActiveMaster],
|
||||||
queryFn,
|
queryFn,
|
||||||
enabled: !!selectedMaster,
|
enabled: !!selectedMaster,
|
||||||
staleTime: 1000 * 60 * 10,
|
staleTime: 1000 * 60 * 10,
|
||||||
@ -361,7 +367,6 @@ const useMaster = () => {
|
|||||||
|
|
||||||
return { data, loading: isLoading, error };
|
return { data, loading: isLoading, error };
|
||||||
};
|
};
|
||||||
|
|
||||||
export default useMaster;
|
export default useMaster;
|
||||||
|
|
||||||
// ================================Mutation====================================
|
// ================================Mutation====================================
|
||||||
@ -1043,8 +1048,139 @@ export const useUpdatePaymentAjustmentHead = (onSuccessCallback) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ============================== Requisition-Status =============================
|
||||||
|
|
||||||
|
export const useCreateRequisitionStatus = (onSuccessCallback) => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async (payload) => {
|
||||||
|
const resp = await MasterRespository.createRequisitionStatus(payload);
|
||||||
|
return resp.data;
|
||||||
|
},
|
||||||
|
onSuccess: (data) => {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["masterData", "Requisition Status"],
|
||||||
|
});
|
||||||
|
showToast("Requisition Status successfully", "success");
|
||||||
|
if (onSuccessCallback) onSuccessCallback(data);
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
showToast(error.message || "Something went wrong", "error");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export const useUpdateRequisitionStatus = (onSuccessCallback) => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async ({ id, payload }) => {
|
||||||
|
const resp = await MasterRespository.updateRequisitionStatus(id, payload);
|
||||||
|
return resp.data;
|
||||||
|
},
|
||||||
|
onSuccess: (data) => {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["masterData", "Requisition Status"],
|
||||||
|
});
|
||||||
|
showToast("Requisition Status Updated successfully", "success");
|
||||||
|
if (onSuccessCallback) onSuccessCallback(data);
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
showToast(error.message || "Something went wrong", "error");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// ============================== Product Category =============================
|
||||||
|
|
||||||
|
export const useCreateProductCategory = (onSuccessCallback) => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async (payload) => {
|
||||||
|
const resp = await MasterRespository.createProductCategory(payload);
|
||||||
|
return resp.data;
|
||||||
|
},
|
||||||
|
onSuccess: (data) => {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["masterData", "Product Category"],
|
||||||
|
});
|
||||||
|
showToast("Product Category successfully", "success");
|
||||||
|
if (onSuccessCallback) onSuccessCallback(data);
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
showToast(error.message || "Something went wrong", "error");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export const useUpdateProductCategory = (onSuccessCallback) => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async ({ id, payload }) => {
|
||||||
|
const resp = await MasterRespository.updateProductCategory(id, payload);
|
||||||
|
return resp.data;
|
||||||
|
},
|
||||||
|
onSuccess: (data) => {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["masterData", "Product Category"],
|
||||||
|
});
|
||||||
|
showToast("Product Category Updated successfully", "success");
|
||||||
|
if (onSuccessCallback) onSuccessCallback(data);
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
showToast(error.message || "Something went wrong", "error");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// ============================== Purchase Order Status =============================
|
||||||
|
|
||||||
|
export const useCreatePurhaseOrderStatus = (onSuccessCallback) => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async (payload) => {
|
||||||
|
const resp = await MasterRespository.createPurchaseOrderStatus(payload);
|
||||||
|
return resp.data;
|
||||||
|
},
|
||||||
|
onSuccess: (data) => {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["masterData", "Purchase Order Status"],
|
||||||
|
});
|
||||||
|
showToast("Purchase Order Status successfully", "success");
|
||||||
|
if (onSuccessCallback) onSuccessCallback(data);
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
showToast(error.message || "Something went wrong", "error");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export const useUpdatePurchaseOrderStatus = (onSuccessCallback) => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async ({ id, payload }) => {
|
||||||
|
const resp = await MasterRespository.updatePurchaseOrderStatus(id, payload);
|
||||||
|
return resp.data;
|
||||||
|
},
|
||||||
|
onSuccess: (data) => {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["masterData", "Purchase Order Status"],
|
||||||
|
});
|
||||||
|
showToast("Purchase Order Status Updated successfully", "success");
|
||||||
|
if (onSuccessCallback) onSuccessCallback(data);
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
showToast(error.message || "Something went wrong", "error");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// ====================x=x====================x=x==================================
|
// ====================x=x====================x=x==================================
|
||||||
|
|
||||||
|
|
||||||
// --------Delete Master --------
|
// --------Delete Master --------
|
||||||
export const useDeleteMasterItem = () => {
|
export const useDeleteMasterItem = () => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|||||||
@ -33,6 +33,7 @@ const MasterPage = () => {
|
|||||||
(store) => store.localVariables.selectedMaster
|
(store) => store.localVariables.selectedMaster
|
||||||
);
|
);
|
||||||
const hasMasterPermission = useHasUserPermission(MANAGE_MASTER);
|
const hasMasterPermission = useHasUserPermission(MANAGE_MASTER);
|
||||||
|
const [isActiveMaster, setIsActiveMaster] = useState(true);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: menuData,
|
data: menuData,
|
||||||
@ -44,11 +45,11 @@ const MasterPage = () => {
|
|||||||
data: masterData = [],
|
data: masterData = [],
|
||||||
loading,
|
loading,
|
||||||
isError: isMasterError,
|
isError: isMasterError,
|
||||||
} = useMaster();
|
} = useMaster(isActiveMaster);
|
||||||
const { mutate: DeleteMaster, isPending: isDeleting } = useDeleteMasterItem();
|
const { mutate: DeleteMaster, isPending: isDeleting } = useDeleteMasterItem();
|
||||||
const [isDeleletingServiceItem,setDeleletingServiceItem] = useState({isOpen:false,ItemId:null,whichItem:null})
|
const [isDeleletingServiceItem, setDeleletingServiceItem] = useState({ isOpen: false, ItemId: null, whichItem: null })
|
||||||
const {mutate:DeleteSericeGroup,isPending:deletingGroup} =useDeleteServiceGroup()
|
const { mutate: DeleteSericeGroup, isPending: deletingGroup } = useDeleteServiceGroup()
|
||||||
const {mutate:DeleteAcivity,isPending:deletingActivity} = useDeleteActivity()
|
const { mutate: DeleteAcivity, isPending: deletingActivity } = useDeleteActivity()
|
||||||
|
|
||||||
const [modalConfig, setModalConfig] = useState(null);
|
const [modalConfig, setModalConfig] = useState(null);
|
||||||
const [deleteData, setDeleteData] = useState(null);
|
const [deleteData, setDeleteData] = useState(null);
|
||||||
@ -89,13 +90,13 @@ const MasterPage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const handleDeleteServiceItem =()=>{
|
const handleDeleteServiceItem = () => {
|
||||||
if(!isDeleletingServiceItem.ItemId) return
|
if (!isDeleletingServiceItem.ItemId) return
|
||||||
debugger
|
debugger
|
||||||
if(isDeleletingServiceItem.whichItem === "activity"){
|
if (isDeleletingServiceItem.whichItem === "activity") {
|
||||||
DeleteAcivity(isDeleletingServiceItem.ItemId,{onSuccess:()=>setDeleletingServiceItem({isOpen:false,ItemId:null,whichItem:null})})
|
DeleteAcivity(isDeleletingServiceItem.ItemId, { onSuccess: () => setDeleletingServiceItem({ isOpen: false, ItemId: null, whichItem: null }) })
|
||||||
}else{
|
} else {
|
||||||
DeleteSericeGroup(isDeleletingServiceItem.ItemId,{onSuccess:()=>setDeleletingServiceItem({isOpen:false,ItemId:null,whichItem:null})})
|
DeleteSericeGroup(isDeleletingServiceItem.ItemId, { onSuccess: () => setDeleletingServiceItem({ isOpen: false, ItemId: null, whichItem: null }) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -115,7 +116,7 @@ const MasterPage = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MasterContext.Provider value={{setDeleletingServiceItem}}>
|
<MasterContext.Provider value={{ setDeleletingServiceItem }}>
|
||||||
{modalConfig && (
|
{modalConfig && (
|
||||||
<GlobalModel
|
<GlobalModel
|
||||||
size={
|
size={
|
||||||
@ -153,7 +154,7 @@ const MasterPage = () => {
|
|||||||
isOpen={!!isDeleletingServiceItem?.isOpen}
|
isOpen={!!isDeleletingServiceItem?.isOpen}
|
||||||
loading={deletingActivity}
|
loading={deletingActivity}
|
||||||
onSubmit={handleDeleteServiceItem}
|
onSubmit={handleDeleteServiceItem}
|
||||||
onClose={() => setDeleletingServiceItem({isOpen:false,ItemId:null,whichItem:null})}
|
onClose={() => setDeleletingServiceItem({ isOpen: false, ItemId: null, whichItem: null })}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="container-fluid">
|
<div className="container-fluid">
|
||||||
@ -196,6 +197,27 @@ const MasterPage = () => {
|
|||||||
onChange={(e) => setSearchTerm(e.target.value)}
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{(selectedMaster === "Purchase Order Status" ||
|
||||||
|
selectedMaster === "Requisition Status" || selectedMaster === "Product Category") && (
|
||||||
|
<div className="form-check form-switch d-flex align-items-center">
|
||||||
|
<input
|
||||||
|
className="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
role="switch"
|
||||||
|
id="flexSwitchCheckActive"
|
||||||
|
checked={isActiveMaster}
|
||||||
|
onChange={() => setIsActiveMaster((prev) => !prev)}
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
className="form-check-label ms-2"
|
||||||
|
htmlFor="flexSwitchCheckActive"
|
||||||
|
>
|
||||||
|
{isActiveMaster ? "Active" : "In-active"}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{hasMasterPermission && (
|
{hasMasterPermission && (
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-primary"
|
className="btn btn-sm btn-primary"
|
||||||
@ -215,6 +237,7 @@ const MasterPage = () => {
|
|||||||
columns={columns}
|
columns={columns}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
handleModalData={handleModalData}
|
handleModalData={handleModalData}
|
||||||
|
isActiveMaster={isActiveMaster}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
|||||||
import { ITEMS_PER_PAGE, MANAGE_MASTER } from "../../utils/constants";
|
import { ITEMS_PER_PAGE, MANAGE_MASTER } from "../../utils/constants";
|
||||||
import showToast from "../../services/toastService";
|
import showToast from "../../services/toastService";
|
||||||
|
|
||||||
const MasterTable = ({ data, columns, loading, handleModalData }) => {
|
const MasterTable = ({ data, columns, loading, handleModalData,isActiveMaster }) => {
|
||||||
const hasMasterPermission = useHasUserPermission(MANAGE_MASTER);
|
const hasMasterPermission = useHasUserPermission(MANAGE_MASTER);
|
||||||
const selectedMaster = useSelector(
|
const selectedMaster = useSelector(
|
||||||
(store) => store.localVariables.selectedMaster
|
(store) => store.localVariables.selectedMaster
|
||||||
@ -230,8 +230,7 @@ const MasterTable = ({ data, columns, loading, handleModalData }) => {
|
|||||||
{[...Array(totalPages)].map((_, index) => (
|
{[...Array(totalPages)].map((_, index) => (
|
||||||
<li
|
<li
|
||||||
key={index}
|
key={index}
|
||||||
className={`page-item ${
|
className={`page-item ${currentPage === index + 1 ? "active" : ""
|
||||||
currentPage === index + 1 ? "active" : ""
|
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
@ -243,8 +242,7 @@ const MasterTable = ({ data, columns, loading, handleModalData }) => {
|
|||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
<li
|
<li
|
||||||
className={`page-item ${
|
className={`page-item ${currentPage === totalPages ? "disabled" : ""
|
||||||
currentPage === totalPages ? "disabled" : ""
|
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@ -58,7 +58,15 @@ export const MasterRespository = {
|
|||||||
"Document Type": (id) => api.delete(`/api/Master/document-type/delete/${id}`),
|
"Document Type": (id) => api.delete(`/api/Master/document-type/delete/${id}`),
|
||||||
"Document Category": (id) =>
|
"Document Category": (id) =>
|
||||||
api.delete(`/api/Master/document-category/delete/${id}`),
|
api.delete(`/api/Master/document-category/delete/${id}`),
|
||||||
"Payment Adjustment Head":(id,isActive)=>api.delete(`/api/Master/payment-adjustment-head/delete/${id}`,(isActive=false)),
|
"Payment Adjustment Head": (id, isActive) => api.delete(`/api/Master/payment-adjustment-head/delete/${id}`, (isActive = false)),
|
||||||
|
|
||||||
|
"Requisition Status": (id, isActive = false) =>
|
||||||
|
api.delete(`/api/master/requisition-status/delete/${id}?isActive=${isActive}`),
|
||||||
|
"Purchase Order Status": (id, isActive = false) =>
|
||||||
|
api.delete(`/api/master/purchase-order-status/delete/${id}?isActive=${isActive}`),
|
||||||
|
"Product Category": (id, isActive = false) =>
|
||||||
|
api.delete(`/api/master/product-category/delete/${id}?isActive=${isActive}`),
|
||||||
|
|
||||||
|
|
||||||
getWorkCategory: () => api.get(`/api/master/work-categories`),
|
getWorkCategory: () => api.get(`/api/master/work-categories`),
|
||||||
createWorkCategory: (data) => api.post(`/api/master/work-category`, data),
|
createWorkCategory: (data) => api.post(`/api/master/work-category`, data),
|
||||||
@ -95,8 +103,7 @@ export const MasterRespository = {
|
|||||||
|
|
||||||
getDocumentCategories: (entityType) =>
|
getDocumentCategories: (entityType) =>
|
||||||
api.get(
|
api.get(
|
||||||
`/api/Master/document-category/list${
|
`/api/Master/document-category/list${entityType ? `?entityTypeId=${entityType}` : ""
|
||||||
entityType ? `?entityTypeId=${entityType}` : ""
|
|
||||||
}`
|
}`
|
||||||
),
|
),
|
||||||
createDocumenyCategory: (data) =>
|
createDocumenyCategory: (data) =>
|
||||||
@ -106,8 +113,7 @@ export const MasterRespository = {
|
|||||||
|
|
||||||
getDocumentTypes: (category) =>
|
getDocumentTypes: (category) =>
|
||||||
api.get(
|
api.get(
|
||||||
`/api/Master/document-type/list${
|
`/api/Master/document-type/list${category ? `?documentCategoryId=${category}` : ""
|
||||||
category ? `?documentCategoryId=${category}` : ""
|
|
||||||
}`
|
}`
|
||||||
),
|
),
|
||||||
|
|
||||||
@ -134,6 +140,25 @@ export const MasterRespository = {
|
|||||||
|
|
||||||
getPaymentAdjustmentHead: (isActive) =>
|
getPaymentAdjustmentHead: (isActive) =>
|
||||||
api.get(`/api/Master/payment-adjustment-head/list?isActive=${isActive}`),
|
api.get(`/api/Master/payment-adjustment-head/list?isActive=${isActive}`),
|
||||||
createPaymentAjustmentHead:(data)=>api.post(`/api/Master/payment-adjustment-head`, data),
|
createPaymentAjustmentHead: (data) => api.post(`/api/Master/payment-adjustment-head`, data),
|
||||||
updatePaymentAjustmentHead:(id,data)=>api.put(`/api/Master/payment-adjustment-head/edit/${id}`, data)
|
updatePaymentAjustmentHead: (id, data) => api.put(`/api/Master/payment-adjustment-head/edit/${id}`, data),
|
||||||
|
|
||||||
|
getRequisitionStatus: (isActive = true) =>
|
||||||
|
api.get(`/api/master/requisition-status/list?isActive=${isActive}`),
|
||||||
|
createRequisitionStatus: (data) => api.post(`/api/master/requisition-status/create`, data),
|
||||||
|
updateRequisitionStatus: (id, data) => api.put(`/api/master/requisition-status/edit/${id}`, data),
|
||||||
|
|
||||||
|
|
||||||
|
getPurchaseOrderStatus: (isActive = true) =>
|
||||||
|
api.get(`/api/master/purchase-order-status/list?isActive=${isActive}`),
|
||||||
|
createPurchaseOrderStatus: (data) => api.post(`/api/master/purchase-order-status/create`, data),
|
||||||
|
updatePurchaseOrderStatus: (id, data) => api.put(`/api/master/purchase-order-status/edit/${id}`, data),
|
||||||
|
|
||||||
|
getProductCategory: (isActive = true) =>
|
||||||
|
api.get(`/api/master/product-category/list?isActive=${isActive}`),
|
||||||
|
createProductCategory: (data) => api.post(`/api/master/product-category/create`, data),
|
||||||
|
updateProductCategory: (id, data) => api.put(`/api/master/product-category/edit/${id}`, data),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user