added restore

This commit is contained in:
pramod.mahajan 2025-11-20 22:01:25 +05:30
parent 753d8c4a2c
commit 14c1da7888
3 changed files with 64 additions and 35 deletions

View File

@ -50,7 +50,7 @@ const ServiceBranch = () => {
const handleDelete = (id) => {
setDeletingId(id);
DeleteBranch(
{ id, isActive: false },
{ id, isActive: showInactive },
{
onSettled: () => {
setDeletingId(null);
@ -64,9 +64,13 @@ const ServiceBranch = () => {
{IsDeleteModalOpen && (
<ConfirmModal
isOpen={IsDeleteModalOpen}
type="delete"
header="Delete Expense"
message="Are you sure you want delete?"
type={!showInactive ? "delete" : "undo"}
header={!showInactive ? "Delete Branch" : "Restore Branch"}
message={
!showInactive
? "Are you sure you want delete?"
: "Are you sure you want restore?"
}
onSubmit={handleDelete}
onClose={() => setIsDeleteModalOpen(false)}
loading={isPending}
@ -182,35 +186,47 @@ const ServiceBranch = () => {
>
<i className="bx bx-dots-vertical-rounded text-muted p-0"></i>
</button>
<ul className="dropdown-menu dropdown-menu-end w-auto">
{/* Modify */}
<li
onClick={() =>
setManageState({
IsOpen: true,
branchId: branch.id,
})
}
>
<a className="dropdown-item px-2 cursor-pointer py-1">
<i className="bx bx-edit text-primary bx-xs me-2"></i>
Modify
</a>
</li>
{/* Delete */}
<li
onClick={() => {
setIsDeleteModalOpen(true);
setDeletingId(branch.id);
}}
>
<a className="dropdown-item px-2 cursor-pointer py-1">
<i className="bx bx-trash text-danger bx-xs me-2"></i>
Delete
</a>
</li>
{!showInactive ? (
<>
<li
onClick={() =>
setManageState({
IsOpen: true,
branchId: branch.id,
})
}
>
<a className="dropdown-item px-2 cursor-pointer py-1">
<i className="bx bx-edit text-primary bx-xs me-2"></i>
Modify
</a>
</li>
<li
onClick={() => {
setIsDeleteModalOpen(true);
setDeletingId(branch.id);
}}
>
<a className="dropdown-item px-2 cursor-pointer py-1">
<i className="bx bx-trash text-danger bx-xs me-2"></i>
Delete
</a>
</li>
</>
) : (
<li
onClick={() => {
setIsDeleteModalOpen(true);
setDeletingId(branch.id);
}}
>
<a className="dropdown-item px-2 cursor-pointer py-1">
<i className="bx bx-undo text-danger me-2"></i>
Restore
</a>
</li>
)}
</ul>
</div>
</td>

View File

@ -18,8 +18,10 @@ const ConfirmModal = ({
return <i className="bx bx-x-circle text-danger" style={{ fontSize: "60px" }}></i>;
case "success":
return <i className="bx bx-archive-in text-warning" style={{ fontSize: "60px" }}></i>;
case "warning":
case "archive":
return <i className="bx bx-error-circle text-warning" style={{ fontSize: "60px" }}></i>;
case "undo":
return <i className="bx bx-undo text-info" style={{ fontSize: "50px" }}></i>;
default:
return null;
}

View File

@ -148,6 +148,11 @@ export const useAllocationServiceProjectTeam = (onSuccessCallback) => {
//#endregion
//#region Service Jobs
export const useServiceProjectJobs = (
@ -292,6 +297,12 @@ export const useUpdateServiceProjectJob = (onSuccessCallback) => {
//#endregion
//#region Branch
export const useBranches = (
projectId,
@ -396,9 +407,9 @@ export const useDeleteBranch = () => {
mutationFn: async ({ id, isActive }) =>
await ServiceProjectRepository.DeleteBranch(id, isActive),
onSuccess: () => {
onSuccess: (_,variable) => {
queryClient.invalidateQueries({ queryKey: ["branches"] });
showToast("Branch deleted successfully", "success");
showToast(`Branch ${variable.isActive ? "restored":"deleted"} successfully`, "success");
},
onError: (error) => {