put -> patch
This commit is contained in:
1 parent
67da6c61cf
commit
5a12e36c7e
2 files changed
+4
-4
No files matched your search
@@ -24,7 +24,7 @@ import {
|
|||||||
SwitchComponent as Switch,
|
SwitchComponent as Switch,
|
||||||
SliderWithLabel,
|
SliderWithLabel,
|
||||||
} from "@/Components/v2/inputs";
|
} from "@/Components/v2/inputs";
|
||||||
import { useGet, usePost, usePut } from "@/Hooks/UseApi";
|
import { useGet, usePost, usePatch } from "@/Hooks/UseApi";
|
||||||
import { useMonitorForm } from "@/Hooks/useMonitorForm";
|
import { useMonitorForm } from "@/Hooks/useMonitorForm";
|
||||||
import type { Monitor, MonitorType } from "@/Types/Monitor";
|
import type { Monitor, MonitorType } from "@/Types/Monitor";
|
||||||
import type { Notification } from "@/Types/Notification";
|
import type { Notification } from "@/Types/Notification";
|
||||||
@@ -163,13 +163,13 @@ const CreateMonitorPage = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const { post, loading: isCreating } = usePost<MonitorFormData, Monitor>();
|
const { post, loading: isCreating } = usePost<MonitorFormData, Monitor>();
|
||||||
const { put, loading: isUpdating } = usePut<MonitorFormData, Monitor>();
|
const { patch, loading: isUpdating } = usePatch<MonitorFormData, Monitor>();
|
||||||
const isSubmitting = isCreating || isUpdating;
|
const isSubmitting = isCreating || isUpdating;
|
||||||
|
|
||||||
const onSubmit = async (data: MonitorFormData) => {
|
const onSubmit = async (data: MonitorFormData) => {
|
||||||
let result;
|
let result;
|
||||||
if (isEditMode && monitorId) {
|
if (isEditMode && monitorId) {
|
||||||
result = await put(`/monitors/${monitorId}`, data);
|
result = await patch(`/monitors/${monitorId}`, data);
|
||||||
} else {
|
} else {
|
||||||
result = await post("/monitors", data);
|
result = await post("/monitors", data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class MonitorRoutes {
|
|||||||
|
|
||||||
// Individual monitor CRUD routes
|
// Individual monitor CRUD routes
|
||||||
this.router.get("/:monitorId", this.monitorController.getMonitorById);
|
this.router.get("/:monitorId", this.monitorController.getMonitorById);
|
||||||
this.router.put("/:monitorId", isAllowed(["admin", "superadmin"]), this.monitorController.editMonitor);
|
this.router.patch("/:monitorId", isAllowed(["admin", "superadmin"]), this.monitorController.editMonitor);
|
||||||
this.router.delete("/:monitorId", isAllowed(["admin", "superadmin"]), this.monitorController.deleteMonitor);
|
this.router.delete("/:monitorId", isAllowed(["admin", "superadmin"]), this.monitorController.deleteMonitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user