diff --git a/app/[locale]/(protected)/admin/management-user/internal/create/page.tsx b/app/[locale]/(protected)/admin/management-user/internal/create/page.tsx index bcd99c67..37bd3425 100644 --- a/app/[locale]/(protected)/admin/management-user/internal/create/page.tsx +++ b/app/[locale]/(protected)/admin/management-user/internal/create/page.tsx @@ -2,7 +2,7 @@ import SiteBreadcrumb from "@/components/site-breadcrumb"; import { zodResolver } from "@hookform/resolvers/zod"; -import { Check, ChevronsUpDown } from "lucide-react"; +import { Check, ChevronsUpDown, Eye, EyeOff } from "lucide-react"; import { useForm } from "react-hook-form"; import { z } from "zod"; @@ -174,7 +174,8 @@ export default function CreateUserForm() { const MySwal = withReactContent(Swal); const levelName = getCookiesDecrypt("ulnae"); const [roleList, setRoleList] = useState([]); - + const [showPassword, setShowPassword] = useState(false); + const [showConfirmPassword, setShowConfirmPassword] = useState(false); const [userEducations, setUserEducations] = useState(); const [userSchools, setUserSchools] = useState(); const [userCompetencies, setUserCompetencies] = useState(); @@ -694,18 +695,26 @@ export default function CreateUserForm() { Password - +
+ + +
-
)} /> + Konfirmasi Kata Sandi - +
+ + +
- )} /> + { const [page, setPage] = React.useState(1); const [totalPage, setTotalPage] = React.useState(1); const [searchQuery, setSearchQuery] = React.useState(""); + const [bannerCount, setBannerCount] = React.useState(0); + + React.useEffect(() => { + fetchBannerCount(); + }, []); + + async function fetchBannerCount() { + try { + const res = await listDataMedia(0, "100", "", "", ""); + const banners = res?.data?.data?.content?.filter( + (item: any) => item.isBanner + ); + setBannerCount(banners?.length || 0); + + setBannerCount(data?.length || 0); + } catch (error) { + console.error("Error fetching banner count:", error); + } + } const handleKeyUp = () => { clearTimeout(typingTimer); @@ -218,11 +237,26 @@ const ContentListBanner = () => { const handleBanner = async (ids: number[]) => { try { - await Promise.all(ids.map((id) => setBanner(id, true))); - toast({ - title: "Sukses", - description: `${ids.length} item berhasil dijadikan banner.`, - }); + // const res = await Promise.all(ids.map((id) => setBanner(id, true))); + + for (const element of ids) { + loading(); + const res = await setBanner(element, true); + close(); + if (res?.error) { + toast({ + title: "Gagal", + description: + "Banner sudah melebihi batas maksimum (4 konten). Silahkan di disable banner Lainnya.", + variant: "destructive", + }); + } else { + toast({ + title: "Sukses", + description: `item berhasil dijadikan banner.`, + }); + } + } } catch (err) { toast({ title: "Gagal", diff --git a/app/[locale]/(protected)/admin/settings/popup/component/table.tsx b/app/[locale]/(protected)/admin/settings/popup/component/table.tsx index b797a310..a370e12d 100644 --- a/app/[locale]/(protected)/admin/settings/popup/component/table.tsx +++ b/app/[locale]/(protected)/admin/settings/popup/component/table.tsx @@ -237,13 +237,44 @@ const ContentListPopUp = () => { const { toast } = useToast(); + // const handlePopUp = async (ids: number[]) => { + // try { + // await Promise.all(ids.map((id) => setPopUp(id, true))); + // toast({ + // title: "Sukses", + // description: `${ids.length} item berhasil dijadikan Popup.`, + // }); + // } catch (err) { + // toast({ + // title: "Gagal", + // description: "Terjadi kesalahan saat menjadikan Popup.", + // variant: "destructive", + // }); + // } + // }; + const handlePopUp = async (ids: number[]) => { try { - await Promise.all(ids.map((id) => setPopUp(id, true))); - toast({ - title: "Sukses", - description: `${ids.length} item berhasil dijadikan banner.`, - }); + // const res = await Promise.all(ids.map((id) => setBanner(id, true))); + + for (const element of ids) { + loading(); + const res = await setPopUp(element, true); + close(); + if (res?.error) { + toast({ + title: "Gagal", + description: + "Banner sudah melebihi batas maksimum (4 konten). Silahkan di disable popup Lainnya.", + variant: "destructive", + }); + } else { + toast({ + title: "Sukses", + description: `item berhasil dijadikan banner.`, + }); + } + } } catch (err) { toast({ title: "Gagal", diff --git a/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx b/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx index dfb84851..36e2feea 100644 --- a/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx +++ b/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx @@ -115,6 +115,7 @@ const CalendarView = ({ categories }: CalendarViewProps) => { const [selectedCategory, setSelectedCategory] = useState([]); const [selectedEventDate, setSelectedEventDate] = useState(null); const roleId = Number(getCookiesDecrypt("urie")) || 0; + console.log("DUARR", roleId) const userLevelId = Number(getCookiesDecrypt("ulie")) || 0; const [calendarEvents, setCalendarEvents] = useState([]); const [isLoading, setIsLoading] = useState(false); @@ -526,7 +527,7 @@ const CalendarView = ({ categories }: CalendarViewProps) => { - {[3, 11, 2, 12].includes(roleId) && ( + {[3, 11, 2].includes(roleId) && (