feat:delete change (httpdelete to put)
This commit is contained in:
parent
ca0b40663a
commit
a1baedde47
|
|
@ -195,7 +195,12 @@ export default function FormMasterUser() {
|
|||
|
||||
const fetchUserLevel = async () => {
|
||||
loading();
|
||||
const res = await getAllUserLevels();
|
||||
const request = {
|
||||
limit: 1000,
|
||||
page: 1,
|
||||
};
|
||||
|
||||
const res = await getAllUserLevels(request);
|
||||
close();
|
||||
if (res?.data?.data) {
|
||||
setupParent(res?.data?.data, "level");
|
||||
|
|
|
|||
|
|
@ -69,101 +69,101 @@ export default function Login() {
|
|||
error("Username & Password Wajib Diisi !");
|
||||
} else {
|
||||
// login dengan otp
|
||||
loading();
|
||||
const response: any = await emailValidation(data);
|
||||
if (response?.error) {
|
||||
console.log("error", response);
|
||||
if (response?.message?.messages[0]?.includes("failed to send mail")) {
|
||||
error("Gagal Mengirim OTP");
|
||||
return false;
|
||||
}
|
||||
// loading();
|
||||
// const response: any = await emailValidation(data);
|
||||
// if (response?.error) {
|
||||
// console.log("error", response);
|
||||
// if (response?.message?.messages[0]?.includes("failed to send mail")) {
|
||||
// error("Gagal Mengirim OTP");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
if (response?.message?.messages[0]?.includes("username")) {
|
||||
error("Username / Password Tidak Sesuai");
|
||||
return false;
|
||||
}
|
||||
error("Unknown Error");
|
||||
return false;
|
||||
}
|
||||
close();
|
||||
if (response?.data?.messages[0] === "Continue to setup email") {
|
||||
setFirstLogin(true);
|
||||
} else {
|
||||
setNeedOtp(true);
|
||||
}
|
||||
// if (response?.message?.messages[0]?.includes("username")) {
|
||||
// error("Username / Password Tidak Sesuai");
|
||||
// return false;
|
||||
// }
|
||||
// error("Unknown Error");
|
||||
// return false;
|
||||
// }
|
||||
// close();
|
||||
// if (response?.data?.messages[0] === "Continue to setup email") {
|
||||
// setFirstLogin(true);
|
||||
// } else {
|
||||
// setNeedOtp(true);
|
||||
// }
|
||||
|
||||
// login tanpa otp
|
||||
// loading();
|
||||
// const response = await postSignIn(data);
|
||||
// if (response?.error) {
|
||||
// error("Username / Password Tidak Sesuai");
|
||||
// } else {
|
||||
// const profile = await getProfile(response?.data?.data?.access_token);
|
||||
// const dateTime: any = new Date();
|
||||
loading();
|
||||
const response = await postSignIn(data);
|
||||
if (response?.error) {
|
||||
error("Username / Password Tidak Sesuai");
|
||||
} else {
|
||||
const profile = await getProfile(response?.data?.data?.access_token);
|
||||
const dateTime: any = new Date();
|
||||
|
||||
// const newTime: any = dateTime.getTime() + 10 * 60 * 1000;
|
||||
const newTime: any = dateTime.getTime() + 10 * 60 * 1000;
|
||||
|
||||
// Cookies.set("access_token", response?.data?.data?.access_token, {
|
||||
// expires: 1,
|
||||
// });
|
||||
// Cookies.set("refresh_token", response?.data?.data?.refresh_token, {
|
||||
// expires: 1,
|
||||
// });
|
||||
// Cookies.set("time_refresh", newTime, {
|
||||
// expires: 1,
|
||||
// });
|
||||
// Cookies.set("is_first_login", "true", {
|
||||
// secure: true,
|
||||
// sameSite: "strict",
|
||||
// });
|
||||
// const resActivity = await saveActivity(
|
||||
// {
|
||||
// activityTypeId: 1,
|
||||
// url: "https://kontenhumas.com/auth",
|
||||
// userId: profile?.data?.data?.id,
|
||||
// },
|
||||
// accessData?.id_token
|
||||
// );
|
||||
// Cookies.set("profile_picture", profile?.data?.data?.profilePictureUrl, {
|
||||
// expires: 1,
|
||||
// });
|
||||
// Cookies.set("uie", profile?.data?.data?.id, {
|
||||
// expires: 1,
|
||||
// });
|
||||
// Cookies.set("ufne", profile?.data?.data?.fullname, {
|
||||
// expires: 1,
|
||||
// });
|
||||
// Cookies.set("ulie", profile?.data?.data?.userLevelGroup, {
|
||||
// expires: 1,
|
||||
// });
|
||||
// Cookies.set("username", profile?.data?.data?.username, {
|
||||
// expires: 1,
|
||||
// });
|
||||
// Cookies.set("urie", profile?.data?.data?.roleId, {
|
||||
// expires: 1,
|
||||
// });
|
||||
// Cookies.set("roleName", profile?.data?.data?.roleName, {
|
||||
// expires: 1,
|
||||
// });
|
||||
// Cookies.set("masterPoldaId", profile?.data?.data?.masterPoldaId, {
|
||||
// expires: 1,
|
||||
// });
|
||||
// Cookies.set("ulne", profile?.data?.data?.userLevelId, {
|
||||
// expires: 1,
|
||||
// });
|
||||
// Cookies.set("urce", profile?.data?.data?.roleCode, {
|
||||
// expires: 1,
|
||||
// });
|
||||
// Cookies.set("email", profile?.data?.data?.email, {
|
||||
// expires: 1,
|
||||
// });
|
||||
// router.push("/admin/dashboard");
|
||||
// Cookies.set("status", "login", {
|
||||
// expires: 1,
|
||||
// });
|
||||
Cookies.set("access_token", response?.data?.data?.access_token, {
|
||||
expires: 1,
|
||||
});
|
||||
Cookies.set("refresh_token", response?.data?.data?.refresh_token, {
|
||||
expires: 1,
|
||||
});
|
||||
Cookies.set("time_refresh", newTime, {
|
||||
expires: 1,
|
||||
});
|
||||
Cookies.set("is_first_login", "true", {
|
||||
secure: true,
|
||||
sameSite: "strict",
|
||||
});
|
||||
const resActivity = await saveActivity(
|
||||
{
|
||||
activityTypeId: 1,
|
||||
url: "https://kontenhumas.com/auth",
|
||||
userId: profile?.data?.data?.id,
|
||||
},
|
||||
accessData?.id_token
|
||||
);
|
||||
Cookies.set("profile_picture", profile?.data?.data?.profilePictureUrl, {
|
||||
expires: 1,
|
||||
});
|
||||
Cookies.set("uie", profile?.data?.data?.id, {
|
||||
expires: 1,
|
||||
});
|
||||
Cookies.set("ufne", profile?.data?.data?.fullname, {
|
||||
expires: 1,
|
||||
});
|
||||
Cookies.set("ulie", profile?.data?.data?.userLevelGroup, {
|
||||
expires: 1,
|
||||
});
|
||||
Cookies.set("username", profile?.data?.data?.username, {
|
||||
expires: 1,
|
||||
});
|
||||
Cookies.set("urie", profile?.data?.data?.roleId, {
|
||||
expires: 1,
|
||||
});
|
||||
Cookies.set("roleName", profile?.data?.data?.roleName, {
|
||||
expires: 1,
|
||||
});
|
||||
Cookies.set("masterPoldaId", profile?.data?.data?.masterPoldaId, {
|
||||
expires: 1,
|
||||
});
|
||||
Cookies.set("ulne", profile?.data?.data?.userLevelId, {
|
||||
expires: 1,
|
||||
});
|
||||
Cookies.set("urce", profile?.data?.data?.roleCode, {
|
||||
expires: 1,
|
||||
});
|
||||
Cookies.set("email", profile?.data?.data?.email, {
|
||||
expires: 1,
|
||||
});
|
||||
router.push("/admin/dashboard");
|
||||
Cookies.set("status", "login", {
|
||||
expires: 1,
|
||||
});
|
||||
|
||||
// close();
|
||||
// }
|
||||
close();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ export default function HeaderNews() {
|
|||
<div className="w-full">
|
||||
<div className="flex flex-col lg:flex-row gap-3 lg:gap-8 bg-white dark:bg-black p-1 lg:p-8 lg:h-[540px] w-full lg:w-[75%] lg:mx-auto">
|
||||
<div className="lg:hidden w-[90%] h-[300px] md:h-[500px] mx-auto">
|
||||
{banner.length > 0 ? (
|
||||
{hotNews?.length > 0 ? (
|
||||
<Swiper
|
||||
centeredSlides={true}
|
||||
autoplay={{
|
||||
|
|
@ -110,7 +110,7 @@ export default function HeaderNews() {
|
|||
);
|
||||
}}
|
||||
>
|
||||
{banner?.map((newsItem: any, index: number) => (
|
||||
{hotNews?.map((newsItem: any, index: number) => (
|
||||
<SwiperSlide key={newsItem?.id}>
|
||||
<Card
|
||||
radius="lg"
|
||||
|
|
@ -162,8 +162,8 @@ export default function HeaderNews() {
|
|||
Hot Topik
|
||||
</p>
|
||||
<ScrollShadow hideScrollBar className="h-[29vh] lg:h-[400px] ">
|
||||
{hotNews.length > 0 ? (
|
||||
hotNews.map((data: any, index: number) => (
|
||||
{hotNews?.length > 0 ? (
|
||||
hotNews?.map((data: any, index: number) => (
|
||||
<div
|
||||
className="text-xs text-left m-2 p-2 dark:bg-[#1E1616] bg-white rounded-md flex flex-row gap-2"
|
||||
key={data?.id}
|
||||
|
|
@ -225,7 +225,7 @@ export default function HeaderNews() {
|
|||
</div>
|
||||
|
||||
<div className="hidden lg:block w-full lg:w-[50%] h-[500px]">
|
||||
{banner.length > 0 ? (
|
||||
{hotNews?.length > 0 ? (
|
||||
<Swiper
|
||||
centeredSlides={true}
|
||||
autoplay={{
|
||||
|
|
@ -252,7 +252,7 @@ export default function HeaderNews() {
|
|||
);
|
||||
}}
|
||||
>
|
||||
{banner.map((newsItem: any, index: number) => (
|
||||
{hotNews?.map((newsItem: any, index: number) => (
|
||||
<SwiperSlide key={newsItem?.id} className="!w-full h-[50vh]">
|
||||
<Card
|
||||
isFooterBlurred
|
||||
|
|
@ -268,7 +268,7 @@ export default function HeaderNews() {
|
|||
? "/no-image.jpg"
|
||||
: newsItem?.thumbnailUrl
|
||||
}
|
||||
className="!w-full !h-[500px] !object-cover !rounded-none"
|
||||
className="!w-[90vw] !h-[500px] !object-cover !rounded-none"
|
||||
/>
|
||||
|
||||
<CardFooter className="mb-1 max-h-[20vh] before:bg-white/10 border-white/20 border-1 overflow-hidden py-1 md:absolute before:rounded-xl rounded-large bottom-1 w-[calc(100%_-_8px)] shadow-small ml-1 z-10">
|
||||
|
|
|
|||
|
|
@ -240,6 +240,7 @@ export default function ArticleTable() {
|
|||
}
|
||||
close();
|
||||
success("Berhasil Hapus");
|
||||
setPage(1);
|
||||
initState();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,6 +137,8 @@ export default function MasterUserLevelTable() {
|
|||
return value;
|
||||
});
|
||||
setMasterUserLevel(newData);
|
||||
} else {
|
||||
setMasterUserLevel([]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -329,63 +331,67 @@ export default function MasterUserLevelTable() {
|
|||
)}
|
||||
</div>
|
||||
|
||||
<Table
|
||||
// selectionMode="multiple"
|
||||
aria-label="micro issue table"
|
||||
className="rounded-xl"
|
||||
classNames={{
|
||||
th: "bg-white dark:bg-black text-black dark:text-white border-b-1 text-md",
|
||||
base: "bg-white dark:bg-black border",
|
||||
wrapper:
|
||||
"min-h-[50px] bg-transpararent text-black dark:text-white ",
|
||||
}}
|
||||
>
|
||||
<TableHeader columns={doSetup ? columns2 : columns}>
|
||||
{(column) => (
|
||||
<TableColumn key={column.uid}>
|
||||
{column.uid === "setup" ? (
|
||||
<Checkbox
|
||||
isSelected={selectAllLevel}
|
||||
onValueChange={(e) => {
|
||||
doMapping(e);
|
||||
}}
|
||||
></Checkbox>
|
||||
) : (
|
||||
column.name
|
||||
{masterUserLevelTable && (
|
||||
<>
|
||||
<Table
|
||||
// selectionMode="multiple"
|
||||
aria-label="micro issue table"
|
||||
className="rounded-xl"
|
||||
classNames={{
|
||||
th: "bg-white dark:bg-black text-black dark:text-white border-b-1 text-md",
|
||||
base: "bg-white dark:bg-black border",
|
||||
wrapper:
|
||||
"min-h-[50px] bg-transpararent text-black dark:text-white ",
|
||||
}}
|
||||
>
|
||||
<TableHeader columns={doSetup ? columns2 : columns}>
|
||||
{(column) => (
|
||||
<TableColumn key={column.uid}>
|
||||
{column.uid === "setup" ? (
|
||||
<Checkbox
|
||||
isSelected={selectAllLevel}
|
||||
onValueChange={(e) => {
|
||||
doMapping(e);
|
||||
}}
|
||||
></Checkbox>
|
||||
) : (
|
||||
column.name
|
||||
)}
|
||||
</TableColumn>
|
||||
)}
|
||||
</TableColumn>
|
||||
)}
|
||||
</TableHeader>
|
||||
<TableBody
|
||||
items={masterUserLevelTable}
|
||||
emptyContent={"No data to display."}
|
||||
>
|
||||
{(item) => (
|
||||
<TableRow key={item.id}>
|
||||
{(columnKey) => (
|
||||
<TableCell>{renderCell(item, columnKey)}</TableCell>
|
||||
</TableHeader>
|
||||
<TableBody
|
||||
items={masterUserLevelTable}
|
||||
emptyContent={"No data to display."}
|
||||
>
|
||||
{(item) => (
|
||||
<TableRow key={item.id}>
|
||||
{(columnKey) => (
|
||||
<TableCell>{renderCell(item, columnKey)}</TableCell>
|
||||
)}
|
||||
</TableRow>
|
||||
)}
|
||||
</TableRow>
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<div className="mt-2 justify-center flex w-full">
|
||||
<Pagination
|
||||
isCompact
|
||||
showControls
|
||||
showShadow
|
||||
color="primary"
|
||||
classNames={{
|
||||
base: "bg-transparent",
|
||||
wrapper: "bg-transparent",
|
||||
item: "w-fit px-3",
|
||||
cursor: "w-fit px-3",
|
||||
}}
|
||||
page={page}
|
||||
total={totalPage}
|
||||
onChange={(page) => setPage(page)}
|
||||
/>
|
||||
</div>
|
||||
</TableBody>
|
||||
</Table>
|
||||
<div className="mt-2 justify-center flex w-full">
|
||||
<Pagination
|
||||
isCompact
|
||||
showControls
|
||||
showShadow
|
||||
color="primary"
|
||||
classNames={{
|
||||
base: "bg-transparent",
|
||||
wrapper: "bg-transparent",
|
||||
item: "w-fit px-3",
|
||||
cursor: "w-fit px-3",
|
||||
}}
|
||||
page={page}
|
||||
total={totalPage}
|
||||
onChange={(page) => setPage(page)}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -59,10 +59,17 @@ export async function editAdvertiseIsActive(data: any) {
|
|||
return await httpPut(pathUrl, headers);
|
||||
}
|
||||
|
||||
// export async function deleteAdvertise(id: number) {
|
||||
// const headers = {
|
||||
// "content-type": "application/json",
|
||||
// };
|
||||
// const pathUrl = `/advertisement/${id}`;
|
||||
// return await httpDeleteInterceptor(pathUrl, headers);
|
||||
// }
|
||||
export async function deleteAdvertise(id: number) {
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
};
|
||||
const pathUrl = `/advertisement/${id}`;
|
||||
return await httpDeleteInterceptor(pathUrl, headers);
|
||||
const pathUrl = `/advertisement/delete/${id}`;
|
||||
return await httpPut(pathUrl, headers);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,11 +126,17 @@ export async function getArticleById(id: any) {
|
|||
return await httpGet(`/articles/${id}`, headers);
|
||||
}
|
||||
|
||||
// export async function deleteArticle(id: string) {
|
||||
// const headers = {
|
||||
// "content-type": "application/json",
|
||||
// };
|
||||
// return await httpDeleteInterceptor(`articles/${id}`, headers);
|
||||
// }
|
||||
export async function deleteArticle(id: string) {
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
};
|
||||
return await httpDeleteInterceptor(`articles/${id}`, headers);
|
||||
return await httpPut(`articles/delete/${id}`, headers);
|
||||
}
|
||||
|
||||
export async function getArticleByCategory() {
|
||||
|
|
@ -165,11 +171,17 @@ export async function uploadArticleThumbnail(id: string, data: any) {
|
|||
return await httpPost(`/articles/thumbnail/${id}`, headers, data);
|
||||
}
|
||||
|
||||
// export async function deleteArticleFiles(id: number) {
|
||||
// const headers = {
|
||||
// "content-type": "multipart/form-data",
|
||||
// };
|
||||
// return await httpDeleteInterceptor(`article-files/${id}`, headers);
|
||||
// }
|
||||
export async function deleteArticleFiles(id: number) {
|
||||
const headers = {
|
||||
"content-type": "multipart/form-data",
|
||||
};
|
||||
return await httpDeleteInterceptor(`article-files/${id}`, headers);
|
||||
return await httpPut(`article-files/delete/${id}`, headers);
|
||||
}
|
||||
|
||||
export async function getUserLevelDataStat(startDate: string, endDate: string) {
|
||||
|
|
|
|||
|
|
@ -32,11 +32,17 @@ export async function getCategoryById(id: number) {
|
|||
return await httpGet(`/article-categories/${id}`, headers);
|
||||
}
|
||||
|
||||
// export async function deleteCategory(id: number) {
|
||||
// const headers = {
|
||||
// "content-type": "application/json",
|
||||
// };
|
||||
// return await httpDeleteInterceptor(`article-categories/${id}`, headers);
|
||||
// }
|
||||
export async function deleteCategory(id: number) {
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
};
|
||||
return await httpDeleteInterceptor(`article-categories/${id}`, headers);
|
||||
return await httpPut(`article-categories/delete/${id}`, headers);
|
||||
}
|
||||
|
||||
export async function uploadCategoryThumbnail(id: string, data: any) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue