added restore
This commit is contained in:
parent
753d8c4a2c
commit
14c1da7888
@ -50,7 +50,7 @@ const ServiceBranch = () => {
|
|||||||
const handleDelete = (id) => {
|
const handleDelete = (id) => {
|
||||||
setDeletingId(id);
|
setDeletingId(id);
|
||||||
DeleteBranch(
|
DeleteBranch(
|
||||||
{ id, isActive: false },
|
{ id, isActive: showInactive },
|
||||||
{
|
{
|
||||||
onSettled: () => {
|
onSettled: () => {
|
||||||
setDeletingId(null);
|
setDeletingId(null);
|
||||||
@ -64,9 +64,13 @@ const ServiceBranch = () => {
|
|||||||
{IsDeleteModalOpen && (
|
{IsDeleteModalOpen && (
|
||||||
<ConfirmModal
|
<ConfirmModal
|
||||||
isOpen={IsDeleteModalOpen}
|
isOpen={IsDeleteModalOpen}
|
||||||
type="delete"
|
type={!showInactive ? "delete" : "undo"}
|
||||||
header="Delete Expense"
|
header={!showInactive ? "Delete Branch" : "Restore Branch"}
|
||||||
message="Are you sure you want delete?"
|
message={
|
||||||
|
!showInactive
|
||||||
|
? "Are you sure you want delete?"
|
||||||
|
: "Are you sure you want restore?"
|
||||||
|
}
|
||||||
onSubmit={handleDelete}
|
onSubmit={handleDelete}
|
||||||
onClose={() => setIsDeleteModalOpen(false)}
|
onClose={() => setIsDeleteModalOpen(false)}
|
||||||
loading={isPending}
|
loading={isPending}
|
||||||
@ -182,35 +186,47 @@ const ServiceBranch = () => {
|
|||||||
>
|
>
|
||||||
<i className="bx bx-dots-vertical-rounded text-muted p-0"></i>
|
<i className="bx bx-dots-vertical-rounded text-muted p-0"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<ul className="dropdown-menu dropdown-menu-end w-auto">
|
<ul className="dropdown-menu dropdown-menu-end w-auto">
|
||||||
{/* Modify */}
|
{!showInactive ? (
|
||||||
<li
|
<>
|
||||||
onClick={() =>
|
<li
|
||||||
setManageState({
|
onClick={() =>
|
||||||
IsOpen: true,
|
setManageState({
|
||||||
branchId: branch.id,
|
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>
|
<a className="dropdown-item px-2 cursor-pointer py-1">
|
||||||
Modify
|
<i className="bx bx-edit text-primary bx-xs me-2"></i>
|
||||||
</a>
|
Modify
|
||||||
</li>
|
</a>
|
||||||
|
</li>
|
||||||
{/* Delete */}
|
<li
|
||||||
<li
|
onClick={() => {
|
||||||
onClick={() => {
|
setIsDeleteModalOpen(true);
|
||||||
setIsDeleteModalOpen(true);
|
setDeletingId(branch.id);
|
||||||
setDeletingId(branch.id);
|
}}
|
||||||
}}
|
>
|
||||||
>
|
<a className="dropdown-item px-2 cursor-pointer py-1">
|
||||||
<a className="dropdown-item px-2 cursor-pointer py-1">
|
<i className="bx bx-trash text-danger bx-xs me-2"></i>
|
||||||
<i className="bx bx-trash text-danger bx-xs me-2"></i>
|
Delete
|
||||||
Delete
|
</a>
|
||||||
</a>
|
</li>
|
||||||
</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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@ -18,8 +18,10 @@ const ConfirmModal = ({
|
|||||||
return <i className="bx bx-x-circle text-danger" style={{ fontSize: "60px" }}></i>;
|
return <i className="bx bx-x-circle text-danger" style={{ fontSize: "60px" }}></i>;
|
||||||
case "success":
|
case "success":
|
||||||
return <i className="bx bx-archive-in text-warning" style={{ fontSize: "60px" }}></i>;
|
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>;
|
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:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -148,6 +148,11 @@ export const useAllocationServiceProjectTeam = (onSuccessCallback) => {
|
|||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#region Service Jobs
|
//#region Service Jobs
|
||||||
|
|
||||||
export const useServiceProjectJobs = (
|
export const useServiceProjectJobs = (
|
||||||
@ -292,6 +297,12 @@ export const useUpdateServiceProjectJob = (onSuccessCallback) => {
|
|||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#region Branch
|
//#region Branch
|
||||||
export const useBranches = (
|
export const useBranches = (
|
||||||
projectId,
|
projectId,
|
||||||
@ -396,9 +407,9 @@ export const useDeleteBranch = () => {
|
|||||||
mutationFn: async ({ id, isActive }) =>
|
mutationFn: async ({ id, isActive }) =>
|
||||||
await ServiceProjectRepository.DeleteBranch(id, isActive),
|
await ServiceProjectRepository.DeleteBranch(id, isActive),
|
||||||
|
|
||||||
onSuccess: () => {
|
onSuccess: (_,variable) => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["branches"] });
|
queryClient.invalidateQueries({ queryKey: ["branches"] });
|
||||||
showToast("Branch deleted successfully", "success");
|
showToast(`Branch ${variable.isActive ? "restored":"deleted"} successfully`, "success");
|
||||||
},
|
},
|
||||||
|
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user