From b02622ff5026cafc29821dd20768c56b9875931f Mon Sep 17 00:00:00 2001 From: Rama Priyanto Date: Mon, 13 Jan 2025 11:50:39 +0700 Subject: [PATCH 1/5] fix:menu satker, create category --- .../settings/category/component/create.tsx | 213 +++++++++++------- lib/menus.ts | 149 +++++++----- messages/en.json | 1 + messages/in.json | 1 + 4 files changed, 227 insertions(+), 137 deletions(-) diff --git a/app/[locale]/(protected)/admin/settings/category/component/create.tsx b/app/[locale]/(protected)/admin/settings/category/component/create.tsx index 69ed0898..4db8b7e2 100644 --- a/app/[locale]/(protected)/admin/settings/category/component/create.tsx +++ b/app/[locale]/(protected)/admin/settings/category/component/create.tsx @@ -37,6 +37,8 @@ import { useDropzone } from "react-dropzone"; import { CloudUpload } from "lucide-react"; import Image from "next/image"; import { Upload } from "tus-js-client"; +import { getCookiesDecrypt } from "@/lib/utils"; +import Cookies from "js-cookie"; const FormSchema = z.object({ title: z.string({ @@ -103,6 +105,10 @@ const publishToList = [ export default function CreateCategoryModal() { const router = useRouter(); const { toast } = useToast(); + const roleId = getCookiesDecrypt("urie"); + const levelNumber = getCookiesDecrypt("ulne"); + const userLevelId = getCookiesDecrypt("ulie"); + const poldaState = Cookies.get("state"); const [files, setFiles] = useState([]); const [isOpen, setIsOpen] = useState(false); @@ -139,6 +145,14 @@ export default function CreateCategoryModal() { useEffect(() => { getRoles(); + if (Number(levelNumber) === 2) { + form.setValue("publishTo", ["polda"]); + setUnitData([String(userLevelId)]); + } + if (Number(levelNumber) === 3) { + form.setValue("publishTo", ["satker"]); + setSatkerData([String(userLevelId)]); + } }, []); async function getRoles() { @@ -176,7 +190,7 @@ export default function CreateCategoryModal() { const save = async (data: z.infer) => { const formMedia = new FormData(); - loading(); + // loading(); const unit = unitData?.join(","); const satker = satkerData?.join(","); @@ -196,6 +210,10 @@ export default function CreateCategoryModal() { formMedia.append("file", files[0]); formMedia.append("publishedLocation", data.publishTo.sort().join(",")); formMedia.append("publishedLocationLevel", join); + formMedia.append( + "isInt", + data.publishTo.includes("internasional") ? "true" : "false" + ); const response = await postCategory(formMedia); close(); @@ -374,94 +392,117 @@ export default function CreateCategoryModal() { )} /> - ( - - Wilayah Publish + {Number(levelNumber) === 1 ? ( + ( + + Wilayah Publish -
-
- { - if (checked) { - form.setValue( - "publishTo", - publishToList.map((item) => item.id) - ); - } else { - form.setValue("publishTo", []); - } - }} - /> - -
- {publishToList.map((item) => ( - <> - { - return ( - -
- - { - return checked - ? field.onChange([ - ...field.value, - item.id, - ]) - : field.onChange( - field.value?.filter( - (value) => value !== item.id - ) - ); - }} - /> - - - {item.name}{" "} - -
-
- ); +
+
+ { + if (checked) { + form.setValue( + "publishTo", + publishToList.map((item) => item.id) + ); + } else { + form.setValue("publishTo", []); + } }} /> - {item.id === "polda" && - form.getValues("publishTo")?.includes(item.id) && ( - setUnitData(data)} - /> - )} - {item.id === "satker" && - form.getValues("publishTo")?.includes(item.id) && ( - setSatkerData(data)} - /> - )} - - ))} -
- - - )} - /> + +
+ {publishToList.map((item) => ( + <> + { + return ( + +
+ + { + return checked + ? field.onChange([ + ...field.value, + item.id, + ]) + : field.onChange( + field.value?.filter( + (value) => value !== item.id + ) + ); + }} + /> + + + {item.name}{" "} + +
+
+ ); + }} + /> + {item.id === "polda" && + form.getValues("publishTo")?.includes(item.id) && ( + setUnitData(data)} + /> + )} + {item.id === "satker" && + form.getValues("publishTo")?.includes(item.id) && ( + setSatkerData(data)} + /> + )} + + ))} +
+ +
+ )} + /> + ) : ( + ( + + Wilayah Publish + +
+
+ + +
+
+ +
+ )} + /> + )} + Date: Mon, 13 Jan 2025 11:51:56 +0700 Subject: [PATCH 2/5] little update --- .../(protected)/admin/settings/category/component/create.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/[locale]/(protected)/admin/settings/category/component/create.tsx b/app/[locale]/(protected)/admin/settings/category/component/create.tsx index 4db8b7e2..0b9994c4 100644 --- a/app/[locale]/(protected)/admin/settings/category/component/create.tsx +++ b/app/[locale]/(protected)/admin/settings/category/component/create.tsx @@ -190,7 +190,7 @@ export default function CreateCategoryModal() { const save = async (data: z.infer) => { const formMedia = new FormData(); - // loading(); + loading(); const unit = unitData?.join(","); const satker = satkerData?.join(","); From 9046df54061ca4e6a52ff9a7fe00df4b02931c4e Mon Sep 17 00:00:00 2001 From: sabdayagra Date: Mon, 13 Jan 2025 12:29:14 +0700 Subject: [PATCH 3/5] fix: fix content in content-management and filter --- .../content-management/download/page.tsx | 43 +++++++++++-------- .../content-management/galery/page.tsx | 41 ++++++++++-------- .../content-management/rewrite/page.tsx | 6 ++- app/[locale]/(public)/image/filter/page.tsx | 14 ++---- app/[locale]/(public)/schedule/page.tsx | 8 ++-- app/[locale]/(public)/video/filter/page.tsx | 6 ++- messages/en.json | 3 +- 7 files changed, 69 insertions(+), 52 deletions(-) diff --git a/app/[locale]/(public)/content-management/download/page.tsx b/app/[locale]/(public)/content-management/download/page.tsx index f1ffbf31..ce95e055 100644 --- a/app/[locale]/(public)/content-management/download/page.tsx +++ b/app/[locale]/(public)/content-management/download/page.tsx @@ -17,6 +17,7 @@ import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { sendMediaUploadToEmail } from "@/service/media-tracking/media-tracking"; +import ImageBlurry from "@/components/ui/image-blurry"; const Galery = (props: any) => { const [profile, setProfile] = useState(); @@ -284,20 +285,6 @@ const Galery = (props: any) => {
- - Audio Visual - -
|
- - Audio - -
|
{ Foto
|
+ + Audio Visual + +
|
Teks +
|
+ + Audio +
@@ -323,9 +324,12 @@ const Galery = (props: any) => {
- -
{video?.mediaUpload?.title}
+ {/* */} +
+ +
+
{video?.mediaUpload?.title}
@@ -454,9 +458,12 @@ const Galery = (props: any) => { - -
{image?.mediaUpload?.title}
+ {/* */} +
+ +
+
{image?.mediaUpload?.title}
diff --git a/app/[locale]/(public)/content-management/galery/page.tsx b/app/[locale]/(public)/content-management/galery/page.tsx index 6bdaf09a..87da08f1 100644 --- a/app/[locale]/(public)/content-management/galery/page.tsx +++ b/app/[locale]/(public)/content-management/galery/page.tsx @@ -19,6 +19,7 @@ import { Icon } from "@iconify/react/dist/iconify.js"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { sendMediaUploadToEmail } from "@/service/media-tracking/media-tracking"; +import ImageBlurry from "@/components/ui/image-blurry"; const Galery = (props: any) => { const [profile, setProfile] = useState(); @@ -290,20 +291,6 @@ const Galery = (props: any) => {
- - Audio Visual - -
|
- - Audio - -
|
{ Foto
|
+ + Audio Visual + +
|
Teks +
|
+ + Audio +
@@ -329,7 +330,10 @@ const Galery = (props: any) => {
- + {/* */} +
+ +
{video?.mediaUpload?.title}
@@ -458,9 +462,12 @@ const Galery = (props: any) => { - -
{image?.mediaUpload?.title}
+ {/* */} +
+ +
+
{image?.mediaUpload?.title}
diff --git a/app/[locale]/(public)/content-management/rewrite/page.tsx b/app/[locale]/(public)/content-management/rewrite/page.tsx index f9d1cf4a..8f05243e 100644 --- a/app/[locale]/(public)/content-management/rewrite/page.tsx +++ b/app/[locale]/(public)/content-management/rewrite/page.tsx @@ -16,6 +16,7 @@ import { Icon } from "@iconify/react/dist/iconify.js"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { sendMediaUploadToEmail } from "@/service/media-tracking/media-tracking"; +import ImageBlurry from "@/components/ui/image-blurry"; const page = () => { const [, setProfile] = useState(); @@ -210,7 +211,10 @@ const page = () => {
- + {/* */} +
+ +
{image?.title}
diff --git a/app/[locale]/(public)/image/filter/page.tsx b/app/[locale]/(public)/image/filter/page.tsx index bf4ee07e..8ef407d3 100644 --- a/app/[locale]/(public)/image/filter/page.tsx +++ b/app/[locale]/(public)/image/filter/page.tsx @@ -156,7 +156,7 @@ const FilterPage = () => { endDateString, monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("", "") : "", monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] : "", - locale == "en" ? true : false, + locale == "en" ? true : false ); close(); // setGetTotalPage(response?.data?.data?.totalPages); @@ -189,7 +189,7 @@ const FilterPage = () => { endDateString, monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("", "") : "", monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] : "", - locale == "en" ? true : false, + locale == "en" ? true : false ); close(); // setGetTotalPage(response?.data?.data?.totalPages); @@ -491,14 +491,8 @@ const FilterPage = () => { {/* */} -
- +
+
{formatDateToIndonesian(new Date(image?.createdAt))} {image?.timezone ? image?.timezone : "WIB"}| diff --git a/app/[locale]/(public)/schedule/page.tsx b/app/[locale]/(public)/schedule/page.tsx index 578b19b3..5a5f5743 100644 --- a/app/[locale]/(public)/schedule/page.tsx +++ b/app/[locale]/(public)/schedule/page.tsx @@ -14,6 +14,7 @@ import { useRouter } from "@/i18n/routing"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@/components/ui/alert-dialog"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"; import { close, loading } from "@/config/swal"; +import { useTranslations } from "next-intl"; const timeList = [ { @@ -118,16 +119,15 @@ const Schedule = (props: any) => { const router = useRouter(); const [startDate, setStartDate] = useState(new Date()); const [dateAWeek, setDateAWeek] = useState([]); - const [scheduleSearch, setScheduleSearch] = useState(); const [todayList, setTodayList] = useState([]); const [prevdayList, setPrevdayList] = useState([]); const [nextdayList, setNextdayList] = useState([]); - const [isOpen, setIsOpen] = React.useState(false); const [schedules, setSchedules] = useState([]); const [openDialog, setOpenDialog] = useState(false); const [detail, setDetail] = useState(); const [content, setContent] = useState(); const { id } = props; + const t = useTranslations("LandingPage"); useEffect(() => { async function getDataSchedule() { @@ -511,10 +511,10 @@ const Schedule = (props: any) => {
- {/* Component Kanan */} + {/* komponen Kanan */}
- + diff --git a/app/[locale]/(public)/video/filter/page.tsx b/app/[locale]/(public)/video/filter/page.tsx index 915d1c46..e0e1514b 100644 --- a/app/[locale]/(public)/video/filter/page.tsx +++ b/app/[locale]/(public)/video/filter/page.tsx @@ -15,6 +15,7 @@ import ReactDatePicker from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css"; import { close, loading } from "@/config/swal"; import { useTranslations } from "next-intl"; +import ImageBlurry from "@/components/ui/image-blurry"; const columns: ColumnDef[] = [ { @@ -518,7 +519,10 @@ const FilterPage = () => { - + {/* */} +
+ +
{formatDateToIndonesian(new Date(video?.createdAt))} {video?.timezone ? video?.timezone : "WIB"}| {video?.clickCount}{" "} diff --git a/messages/en.json b/messages/en.json index bd982b40..a9539a6b 100644 --- a/messages/en.json +++ b/messages/en.json @@ -343,7 +343,8 @@ "profile": "Profile", "contentManagement": "Content Management", "live": "Live", - "notFound": "Not Found" + "notFound": "Not Found", + "titleSchedule": "Enter schedule title" }, "FilterPage": { "image": "Image", From 350c061263b49da2ddb9d70085996d2cb957f795 Mon Sep 17 00:00:00 2001 From: Rama Priyanto Date: Mon, 13 Jan 2025 12:33:42 +0700 Subject: [PATCH 4/5] fix:edit category polda satker --- .../settings/category/component/edit.tsx | 170 ++++++++++-------- 1 file changed, 99 insertions(+), 71 deletions(-) diff --git a/app/[locale]/(protected)/admin/settings/category/component/edit.tsx b/app/[locale]/(protected)/admin/settings/category/component/edit.tsx index 316e6a74..dae2cd75 100644 --- a/app/[locale]/(protected)/admin/settings/category/component/edit.tsx +++ b/app/[locale]/(protected)/admin/settings/category/component/edit.tsx @@ -38,6 +38,9 @@ import { UnitMapping } from "./unit-mapping"; import { useDropzone } from "react-dropzone"; import { CloudUpload } from "lucide-react"; import { useToast } from "@/components/ui/use-toast"; +import Cookies from "js-cookie"; +import { getCookiesDecrypt } from "@/lib/utils"; + const FormSchema = z.object({ title: z.string({ required_error: "Required", @@ -112,7 +115,10 @@ export default function EditCategoryModal(props: { const [files, setFiles] = useState([]); const [isOpen, setIsOpen] = useState(false); const { toast } = useToast(); - + const roleId = getCookiesDecrypt("urie"); + const levelNumber = getCookiesDecrypt("ulne"); + const userLevelId = getCookiesDecrypt("ulie"); + const poldaState = Cookies.get("state"); const router = useRouter(); const [satkerData, setSatkerData] = useState([]); const [unitData, setUnitData] = useState([]); @@ -344,79 +350,101 @@ export default function EditCategoryModal(props: { )} /> + {Number(levelNumber) === 1 ? ( + ( + + Target Publish - ( - - Target Publish - -
-
- { - if (checked) { - form.setValue( - "selectedUser", - userList.map((item) => item.id) +
+
+ { + if (checked) { + form.setValue( + "selectedUser", + userList.map((item) => item.id) + ); + } else { + form.setValue("selectedUser", []); + } + }} + /> + +
+ {userList.map((item) => ( + { + return ( + +
+ + { + return checked + ? field.onChange([ + ...field.value, + item.id, + ]) + : field.onChange( + field.value?.filter( + (value) => value !== item.id + ) + ); + }} + /> + + + {item.name} + +
+
); - } else { - form.setValue("selectedUser", []); - } - }} - /> - + }} + /> + ))}
- {userList.map((item) => ( - { - return ( - -
- - { - return checked - ? field.onChange([ - ...field.value, - item.id, - ]) - : field.onChange( - field.value?.filter( - (value) => value !== item.id - ) - ); - }} - /> - - - {item.name} - -
-
- ); - }} - /> - ))} -
- - - )} - /> + + + )} + /> + ) : ( + ( + + Wilayah Publish + +
+
+ + +
+
+ +
+ )} + /> + )} + Date: Mon, 13 Jan 2025 12:48:58 +0700 Subject: [PATCH 5/5] fix create new categ satker polda --- .../settings/category/component/edit.tsx | 273 +++++++++--------- 1 file changed, 137 insertions(+), 136 deletions(-) diff --git a/app/[locale]/(protected)/admin/settings/category/component/edit.tsx b/app/[locale]/(protected)/admin/settings/category/component/edit.tsx index dae2cd75..aebf2356 100644 --- a/app/[locale]/(protected)/admin/settings/category/component/edit.tsx +++ b/app/[locale]/(protected)/admin/settings/category/component/edit.tsx @@ -350,28 +350,101 @@ export default function EditCategoryModal(props: { )} /> + ( + + Target Publish + +
+
+ { + if (checked) { + form.setValue( + "selectedUser", + userList.map((item) => item.id) + ); + } else { + form.setValue("selectedUser", []); + } + }} + /> + +
+ {userList.map((item) => ( + { + return ( + +
+ + { + return checked + ? field.onChange([ + ...field.value, + item.id, + ]) + : field.onChange( + field.value?.filter( + (value) => value !== item.id + ) + ); + }} + /> + + + {item.name} + +
+
+ ); + }} + /> + ))} +
+ +
+ )} + /> + {Number(levelNumber) === 1 ? ( ( - Target Publish + Wilayah Publish
{ if (checked) { form.setValue( - "selectedUser", - userList.map((item) => item.id) + "publishTo", + publishToList.map((item) => item.id) ); } else { - form.setValue("selectedUser", []); + form.setValue("publishTo", []); } }} /> @@ -379,44 +452,64 @@ export default function EditCategoryModal(props: { Semua
- {userList.map((item) => ( - { - return ( - -
- - { - return checked - ? field.onChange([ - ...field.value, - item.id, - ]) - : field.onChange( - field.value?.filter( - (value) => value !== item.id - ) - ); - }} - /> - - - {item.name} - -
-
- ); - }} - /> + {publishToList.map((item) => ( + <> + { + return ( + +
+ + { + return checked + ? field.onChange([ + ...field.value, + item.id, + ]) + : field.onChange( + field.value?.filter( + (value) => value !== item.id + ) + ); + }} + /> + + + {item.name}{" "} + +
+
+ ); + }} + /> + {item.id === "polda" && + form.getValues("publishTo")?.includes(item.id) && ( + setUnitData(data)} + isDetail={isDetail ? true : false} + initData={unitData} + /> + )} + {item.id === "satker" && + form.getValues("publishTo")?.includes(item.id) && ( + setSatkerData(data)} + isDetail={isDetail ? true : false} + initData={satkerData} + /> + )} + ))}
@@ -445,98 +538,6 @@ export default function EditCategoryModal(props: { /> )} - ( - - Wilayah Publish - -
-
- { - if (checked) { - form.setValue( - "publishTo", - publishToList.map((item) => item.id) - ); - } else { - form.setValue("publishTo", []); - } - }} - /> - -
- {publishToList.map((item) => ( - <> - { - return ( - -
- - { - return checked - ? field.onChange([ - ...field.value, - item.id, - ]) - : field.onChange( - field.value?.filter( - (value) => value !== item.id - ) - ); - }} - /> - - - {item.name}{" "} - -
-
- ); - }} - /> - {item.id === "polda" && - form.getValues("publishTo")?.includes(item.id) && ( - setUnitData(data)} - isDetail={isDetail ? true : false} - initData={unitData} - /> - )} - {item.id === "satker" && - form.getValues("publishTo")?.includes(item.id) && ( - setSatkerData(data)} - isDetail={isDetail ? true : false} - initData={satkerData} - /> - )} - - ))} -
- -
- )} - />