fix: category in admin
This commit is contained in:
parent
4a5bce9c24
commit
ff44a3b837
|
|
@ -10,15 +10,34 @@ export default function StatusToogle(props: {
|
||||||
}) {
|
}) {
|
||||||
const { id, initValue } = props;
|
const { id, initValue } = props;
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
// const publishCategory = async (id: number, status: string) => {
|
||||||
|
// const response = await publishUnpublishCategory(id, status);
|
||||||
|
// console.log(response);
|
||||||
|
// if (response?.error) {
|
||||||
|
// error(response.message);
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// router.push("/admin/settings/category?dataChange=true");
|
||||||
|
// };
|
||||||
const publishCategory = async (id: number, status: string) => {
|
const publishCategory = async (id: number, status: string) => {
|
||||||
const response = await publishUnpublishCategory(id, status);
|
const response = await publishUnpublishCategory(id, status);
|
||||||
console.log(response);
|
console.log("API Response:", response);
|
||||||
|
|
||||||
|
// cek error interceptor
|
||||||
if (response?.error) {
|
if (response?.error) {
|
||||||
error(response.message);
|
error(response.message || "Terjadi kesalahan");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cek flag success asli dari backend
|
||||||
|
if (response?.data?.success === false) {
|
||||||
|
error(response?.data?.message || "Terjadi kesalahan");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
router.push("/admin/settings/category?dataChange=true");
|
router.push("/admin/settings/category?dataChange=true");
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Switch
|
<Switch
|
||||||
id={String(id)}
|
id={String(id)}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue