diff --git a/components/form/form-master-user.tsx b/components/form/form-master-user.tsx index 4f78b44..bf76031 100644 --- a/components/form/form-master-user.tsx +++ b/components/form/form-master-user.tsx @@ -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"); diff --git a/components/form/login.tsx b/components/form/login.tsx index 12dfd58..9a21df7 100644 --- a/components/form/login.tsx +++ b/components/form/login.tsx @@ -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(); + } } }; diff --git a/components/landing/HeaderNews.tsx b/components/landing/HeaderNews.tsx index f8ce4b1..aad1fb0 100644 --- a/components/landing/HeaderNews.tsx +++ b/components/landing/HeaderNews.tsx @@ -83,7 +83,7 @@ export default function HeaderNews() {
- {banner.length > 0 ? ( + {hotNews?.length > 0 ? ( - {banner?.map((newsItem: any, index: number) => ( + {hotNews?.map((newsItem: any, index: number) => ( - {hotNews.length > 0 ? ( - hotNews.map((data: any, index: number) => ( + {hotNews?.length > 0 ? ( + hotNews?.map((data: any, index: number) => (
- {banner.length > 0 ? ( + {hotNews?.length > 0 ? ( - {banner.map((newsItem: any, index: number) => ( + {hotNews?.map((newsItem: any, index: number) => ( diff --git a/components/table/article-table.tsx b/components/table/article-table.tsx index 62e3c51..6f6864d 100644 --- a/components/table/article-table.tsx +++ b/components/table/article-table.tsx @@ -240,6 +240,7 @@ export default function ArticleTable() { } close(); success("Berhasil Hapus"); + setPage(1); initState(); } diff --git a/components/table/master/master-user-level/master-user-level-table.tsx b/components/table/master/master-user-level/master-user-level-table.tsx index 5ab3d58..6a7743c 100644 --- a/components/table/master/master-user-level/master-user-level-table.tsx +++ b/components/table/master/master-user-level/master-user-level-table.tsx @@ -137,6 +137,8 @@ export default function MasterUserLevelTable() { return value; }); setMasterUserLevel(newData); + } else { + setMasterUserLevel([]); } } @@ -329,63 +331,67 @@ export default function MasterUserLevelTable() { )}
- - - {(column) => ( - - {column.uid === "setup" ? ( - { - doMapping(e); - }} - > - ) : ( - column.name + {masterUserLevelTable && ( + <> +
+ + {(column) => ( + + {column.uid === "setup" ? ( + { + doMapping(e); + }} + > + ) : ( + column.name + )} + )} - - )} - - - {(item) => ( - - {(columnKey) => ( - {renderCell(item, columnKey)} + + + {(item) => ( + + {(columnKey) => ( + {renderCell(item, columnKey)} + )} + )} - - )} - -
-
- setPage(page)} - /> -
+ + +
+ setPage(page)} + /> +
+ + )}
diff --git a/services/advertisement.ts b/services/advertisement.ts index fe5fa69..8679d7d 100644 --- a/services/advertisement.ts +++ b/services/advertisement.ts @@ -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); } diff --git a/services/article.ts b/services/article.ts index 99cb05f..71102cc 100644 --- a/services/article.ts +++ b/services/article.ts @@ -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) { diff --git a/services/master-categories.tsx b/services/master-categories.tsx index 9efd3ec..2d6d073 100644 --- a/services/master-categories.tsx +++ b/services/master-categories.tsx @@ -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) {