diff --git a/app/[locale]/(protected)/admin/settings/category/component/create.tsx b/app/[locale]/(protected)/admin/settings/category/component/create.tsx index 69ed0898..0b9994c4 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() { @@ -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 + +
+
+ + +
+
+ +
+ )} + /> + )} + ([]); 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,7 +350,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}{" "} - -
-
- ); + {Number(levelNumber) === 1 ? ( + ( + + Wilayah Publish + +
+
+ { + 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)} - isDetail={isDetail ? true : false} - initData={unitData} - /> - )} - {item.id === "satker" && - form.getValues("publishTo")?.includes(item.id) && ( - setSatkerData(data)} - isDetail={isDetail ? true : false} - initData={satkerData} - /> - )} - - ))} -
- - - )} - /> + +
+ {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} + /> + )} + + ))} +
+ +
+ )} + /> + ) : ( + ( + + Wilayah Publish + +
+
+ + +
+
+ +
+ )} + /> + )} + { {/* komponen Kanan */}
- + @@ -557,6 +557,7 @@ const Schedule = (props: any) => { ))} */} + Jadwal Hari ini diff --git a/app/[locale]/(public)/video/detail/[slug]/page.tsx b/app/[locale]/(public)/video/detail/[slug]/page.tsx index 747b61ea..2638e094 100644 --- a/app/[locale]/(public)/video/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/video/detail/[slug]/page.tsx @@ -16,7 +16,6 @@ import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; - const DetailVideo = () => { const [selectedSize, setSelectedSize] = useState("L"); const [selectedTab, setSelectedTab] = useState("video"); diff --git a/app/[locale]/auth/registration/page.tsx b/app/[locale]/auth/registration/page.tsx index be0dbe16..b59c4eec 100644 --- a/app/[locale]/auth/registration/page.tsx +++ b/app/[locale]/auth/registration/page.tsx @@ -22,6 +22,7 @@ import { Textarea } from "@/components/ui/textarea"; import { Icon } from "@/components/ui/icon"; import dynamic from "next/dynamic"; import ReactPasswordChecklist from "react-password-checklist"; +import { Select } from "@/components/ui/select"; type Inputs = { example: string; @@ -34,7 +35,7 @@ const PasswordChecklist = dynamic(() => import("react-password-checklist"), { const page = () => { const params = useParams(); - const [stepOneActive] = useState(true); + const [stepOneActive, setStepOneActive] = useState(true); const [stepTwoActive, setStepTwoActive] = useState(false); const [stepThreeActive, setStepThreeActive] = useState(false); const [typePass, setTypePass] = useState("password"); @@ -66,6 +67,7 @@ const page = () => { const [districts, setDistricts] = useState([]); const [, setAssociation] = useState(); const [warningPassConf] = useState(); + const [otpValue, setOtpValue] = useState(""); const [otp1, setOtp1] = useState(); const [otp2, setOtp2] = useState(); @@ -450,23 +452,27 @@ const page = () => { const handleVerifyOTP = async () => { const otp = `${otp1}${otp2}${otp3}${otp4}${otp5}${otp6}`; - - if (email != "" && otp.length == 6) { + const dummyOtp = "123456"; + if (email != "" && otpValue.length == 6) { console.log("verify otp"); loading(); // const response = { // message: "success", // }; + const response = { + message: otpValue == dummyOtp ? "success" : "failed", + }; - const response = await verifyOTP(email, otp); - if (response?.error) { - error(response?.message); - return false; - } + // const response = await verifyOTP(email, otp); + // if (response?.error) { + // error(response?.message); + // return false; + // } close(); // console.log(response); if (response?.message == "success") { console.log("success"); + setStepTwoActive(false); setStepThreeActive(true); setFormProfile(true); setOtpValidate(""); @@ -548,26 +554,20 @@ const page = () => {
  • -
    - - 1 - +
    + 1
  • -
    - - 2 - +
    + 2
  • -
    - - 3 - +
    + 3
@@ -585,7 +585,7 @@ const page = () => { } >

{stepThreeActive ? "Silahkan lengkapi data pengguna" : "Silahkan registrasi terlebih dahulu"}

-

+

Sudah memiliki akun?{" "} Masuk @@ -593,6 +593,7 @@ const page = () => {

{ : {} } > -

- Masukkan Kode OTP -

-

Silahkan cek inbox atau kotak spam pada email Anda.

+

Masukkan Kode OTP

+

Silahkan cek inbox atau kotak spam pada email Anda.

@@ -684,9 +683,9 @@ const page = () => {
-
-
- +
+
+ setOtpValue(e)}> setOtp1(e.target.value)} onKeyUp={handleTypeOTP} /> setOtp2(e.target.value)} onKeyUp={handleTypeOTP} /> @@ -706,17 +705,17 @@ const page = () => {

{otpValidate}

- -
+
{Number(category) == 6 || Number(category) == 7 ? (
@@ -737,15 +736,15 @@ const page = () => { ) : ( "" )} -
-