diff --git a/app/[locale]/(protected)/shared/contest/components/columns.tsx b/app/[locale]/(protected)/shared/contest/components/columns.tsx index 58967acb..b62e3a07 100644 --- a/app/[locale]/(protected)/shared/contest/components/columns.tsx +++ b/app/[locale]/(protected)/shared/contest/components/columns.tsx @@ -17,7 +17,7 @@ import withReactContent from "sweetalert2-react-content"; import Swal from "sweetalert2"; import { error } from "@/lib/swal"; import { deleteMedia } from "@/service/content/content"; -import { publishContest } from "@/service/contest/contest"; +import { deleteContest, publishContest } from "@/service/contest/contest"; import { useTranslations } from "next-intl"; const useTableColumns = () => { @@ -109,23 +109,22 @@ const useTableColumns = () => { row.original.isPublishForMabes ); + const isPublish: boolean = isPublishForMabes === true; const isPending: boolean = (userRoleId === 3 && userLevelNumber === 1 && !isPublishForAll) || ((userRoleId === 11 || userRoleId === 12) && !isPublishForMabes); - const isTerkirim: boolean = isPublishForMabes && !isPublishForAll; - return ( - {isPending ? "Pending" : isTerkirim ? "Terkirim" : "Publish"} + {isPending ? "Pending" : isPublish ? "Publish" : "Terkirim"} ); }, @@ -184,6 +183,37 @@ const useTableColumns = () => { } }); }; + + async function doDelete(id: any) { + // loading(); + const data = { + id, + }; + + const response = await deleteContest(id); + + if (response?.error) { + error(response.message); + return false; + } + success(); + } + + const handleDeleteContest = (id: any) => { + MySwal.fire({ + title: "Hapus Data", + text: "", + icon: "warning", + showCancelButton: true, + cancelButtonColor: "#3085d6", + confirmButtonColor: "#d33", + confirmButtonText: "Hapus", + }).then((result) => { + if (result.isConfirmed) { + doDelete(id); + } + }); + }; return ( @@ -217,14 +247,19 @@ const useTableColumns = () => { View - {/* - - Edit - - - - Delete - */} + + + + Edit + + + handleDeleteContest(row.original.id)} + className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" + > + + Delete + ); diff --git a/app/[locale]/(protected)/shared/contest/update/[id]/page.tsx b/app/[locale]/(protected)/shared/contest/update/[id]/page.tsx new file mode 100644 index 00000000..467ec28c --- /dev/null +++ b/app/[locale]/(protected)/shared/contest/update/[id]/page.tsx @@ -0,0 +1,15 @@ +import SiteBreadcrumb from "@/components/site-breadcrumb"; +import FormContestUpdate from "@/components/form/contest/contest-update-form"; + +const ContestUpdatePage = async () => { + return ( +
+ +
+ +
+
+ ); +}; + +export default ContestUpdatePage; diff --git a/components/form/contest/contest-detail-form.tsx b/components/form/contest/contest-detail-form.tsx index 3800ed80..9ddb9d42 100644 --- a/components/form/contest/contest-detail-form.tsx +++ b/components/form/contest/contest-detail-form.tsx @@ -710,7 +710,7 @@ export default function FormContestDetail() {
- {listDest.map((polda: any) => ( + {listDest?.map((polda: any) => (
@@ -775,7 +775,7 @@ export default function FormTaskTa() {
))} - {isRecording &&

Recording... {timer} seconds remaining

}{" "} + {/* {isRecording &&

Recording... {timer} seconds remaining

}{" "}
{links.map((link, index) => ( @@ -808,7 +808,7 @@ export default function FormTaskTa() { > {t("add-links")} -
+ */} diff --git a/components/partials/auth/login-form.tsx b/components/partials/auth/login-form.tsx index 212af74c..d02e8556 100644 --- a/components/partials/auth/login-form.tsx +++ b/components/partials/auth/login-form.tsx @@ -535,10 +535,10 @@ const LoginForm = () => { diff --git a/service/contest/contest.ts b/service/contest/contest.ts index 9c9c2aeb..51fdef30 100644 --- a/service/contest/contest.ts +++ b/service/contest/contest.ts @@ -1,4 +1,5 @@ import { + httpDeleteInterceptor, httpGetInterceptor, httpPostInterceptor, } from "../http-config/http-interceptor-service"; @@ -28,3 +29,8 @@ export async function publishContest(id: any) { const url = `contest/publish?id=${id}`; return httpPostInterceptor(url); } + +export async function deleteContest(id: any) { + const url = `contest?id=${id}`; + return httpDeleteInterceptor(url); +}