update: change title on aspect form modal
This commit is contained in:
parent
4aa10b3125
commit
8a7022e37e
|
|
@ -29,9 +29,9 @@ export default function AspectFormModal() {
|
||||||
const searchParams = routeApi.useSearch();
|
const searchParams = routeApi.useSearch();
|
||||||
const dataId = searchParams.detail || searchParams.edit;
|
const dataId = searchParams.detail || searchParams.edit;
|
||||||
const isDialogOpen = Boolean(dataId || searchParams.create);
|
const isDialogOpen = Boolean(dataId || searchParams.create);
|
||||||
const formType = searchParams.detail ? "detail" : searchParams.edit ? "edit" : "tambah";
|
const formType = searchParams.detail ? "detail" : searchParams.edit ? "ubah" : "tambah";
|
||||||
|
|
||||||
// Fetch aspect data if editing or viewing details
|
// Fetch aspect data if ubahing or viewing details
|
||||||
const aspectQuery = useQuery(getAspectByIdQueryOptions(dataId));
|
const aspectQuery = useQuery(getAspectByIdQueryOptions(dataId));
|
||||||
|
|
||||||
const modalTitle = `${formType.charAt(0).toUpperCase() + formType.slice(1)} Aspek`;
|
const modalTitle = `${formType.charAt(0).toUpperCase() + formType.slice(1)} Aspek`;
|
||||||
|
|
@ -69,10 +69,10 @@ export default function AspectFormModal() {
|
||||||
mutationKey: ["aspectMutation"],
|
mutationKey: ["aspectMutation"],
|
||||||
mutationFn: async (
|
mutationFn: async (
|
||||||
options:
|
options:
|
||||||
| { action: "edit"; data: Parameters<typeof updateAspect>[0] }
|
| { action: "ubah"; data: Parameters<typeof updateAspect>[0] }
|
||||||
| { action: "create"; data: Parameters<typeof createAspect>[0] }
|
| { action: "tambah"; data: Parameters<typeof createAspect>[0] }
|
||||||
) => {
|
) => {
|
||||||
return options.action === "edit"
|
return options.action === "ubah"
|
||||||
? await updateAspect(options.data)
|
? await updateAspect(options.data)
|
||||||
: await createAspect(options.data);
|
: await createAspect(options.data);
|
||||||
},
|
},
|
||||||
|
|
@ -134,7 +134,7 @@ export default function AspectFormModal() {
|
||||||
: "",
|
: "",
|
||||||
};
|
};
|
||||||
await createAspect(payload);
|
await createAspect(payload);
|
||||||
} else if (formType === "edit") {
|
} else if (formType === "ubah") {
|
||||||
payload = {
|
payload = {
|
||||||
id: values.id,
|
id: values.id,
|
||||||
name: values.name,
|
name: values.name,
|
||||||
|
|
@ -156,7 +156,7 @@ export default function AspectFormModal() {
|
||||||
queryClient.invalidateQueries({ queryKey: ["management-aspect"] });
|
queryClient.invalidateQueries({ queryKey: ["management-aspect"] });
|
||||||
|
|
||||||
notifications.show({
|
notifications.show({
|
||||||
message: `Aspek ${formType === "tambah" ? "berhasil dibuat" : "berhasil diedit"}`,
|
message: `Aspek ${formType === "tambah" ? "berhasil dibuat" : "berhasil diubah"}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
navigate({ search: {} });
|
navigate({ search: {} });
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user