diff --git a/components/landing/CategorySatker.tsx b/components/landing/CategorySatker.tsx index 2dcc375..e41760e 100644 --- a/components/landing/CategorySatker.tsx +++ b/components/landing/CategorySatker.tsx @@ -303,7 +303,7 @@ export default function CategorySatker(props: { }} size="5xl" scrollBehavior={scrollBehavior} - placement={modalPlacement} + placement="center" className="bg-white" > diff --git a/components/landing/PolriApps.tsx b/components/landing/PolriApps.tsx index 9a0ce19..a882ff3 100644 --- a/components/landing/PolriApps.tsx +++ b/components/landing/PolriApps.tsx @@ -182,7 +182,7 @@ export default function PolriApps(props: { }} size="5xl" scrollBehavior={scrollBehavior} - placement={modalPlacement} + placement={"center"} className="bg-white" > diff --git a/components/landing/RegionalNews.tsx b/components/landing/RegionalNews.tsx index 05ebd6b..0dc4270 100644 --- a/components/landing/RegionalNews.tsx +++ b/components/landing/RegionalNews.tsx @@ -310,7 +310,7 @@ export default function RegionalNews(props: { }} size="5xl" scrollBehavior={scrollBehavior} - placement={modalPlacement} + placement="center" className="bg-white" > diff --git a/components/landing/banner-new.tsx b/components/landing/banner-new.tsx index 1b8a66d..d31f6e9 100644 --- a/components/landing/banner-new.tsx +++ b/components/landing/banner-new.tsx @@ -94,7 +94,7 @@ export default function BannerHumasNew() {
diff --git a/components/landing/digital-services.tsx b/components/landing/digital-services.tsx index 1410477..b98cbb5 100644 --- a/components/landing/digital-services.tsx +++ b/components/landing/digital-services.tsx @@ -4,11 +4,14 @@ import RegionalNews from "./RegionalNews"; import { useEffect, useState } from "react"; import CategorySatker from "./CategorySatker"; import PolriApps from "./PolriApps"; +import Link from "next/link"; +import SuggestionsModal from "./suggestions"; export default function DigitalServices() { const [isPoldaOpen, setIsPoldaOpen] = useState(false); const [isSatkerOpen, setIsSatkerOpen] = useState(false); const [isAppsOpen, setIsAppsOpen] = useState(false); + const [isSuggestionOpen, setIsSuggestionOpen] = useState(false); return ( setIsAppsOpen(status)} /> + setIsSuggestionOpen(status)} + />
); } diff --git a/components/landing/suggestions.tsx b/components/landing/suggestions.tsx new file mode 100644 index 0000000..ccf191c --- /dev/null +++ b/components/landing/suggestions.tsx @@ -0,0 +1,293 @@ +"use client"; +import { Button } from "@heroui/button"; +import { + Image, + Input, + InputOtp, + Modal, + ModalBody, + ModalContent, + ModalFooter, + ModalHeader, + ModalProps, + Textarea, + useDisclosure, +} from "@heroui/react"; +import { ChevronLeftWhite, ChevronRightWhite } from "../icons"; +import React, { useEffect, useState } from "react"; +import Link from "next/link"; +import { useTranslations } from "next-intl"; +import * as z from "zod"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { Controller, useForm } from "react-hook-form"; +import { close, error, loading } from "@/config/swal"; +import OTPInput from "react-otp-input"; +import { otpRequest, otpValidation } from "@/service/master-user"; +import Swal from "sweetalert2"; +import withReactContent from "sweetalert2-react-content"; + +const createArticleSchema = z.object({ + email: z.string().min(2, { + message: "Email harus diisi", + }), + name: z.string().min(2, { + message: "Nama harus diisi", + }), + description: z.string().min(2, { + message: "Deskripsi harus diisi", + }), +}); + +export default function SuggestionsModal(props: { + opened: boolean; + modalStatus: (status: boolean) => void; +}) { + const { isOpen, onOpen, onOpenChange } = useDisclosure(); + const [needOtp, setNeedOtp] = useState(false); + const [otpValue, setOtpValue] = useState(""); + const MySwal = withReactContent(Swal); + + const t = useTranslations("Landing"); + + useEffect(() => { + if (props.opened) { + onOpen(); + } + }, [props.opened]); + + const formOptions = { + resolver: zodResolver(createArticleSchema), + defaultValues: { name: "", description: "", email: "" }, + }; + + type UserSettingSchema = z.infer; + const { + control, + handleSubmit, + reset, + formState: { errors }, + } = useForm(formOptions); + + const onSubmit = async (values: z.infer) => { + if (!needOtp) { + loading(); + // const res = await otpRequest(values.email, values?.name); + // if (res?.error) { + // error(res.message); + // return false; + // } + close(); + setNeedOtp(true); + } else { + // const validation = await otpValidation(values.email, otpValue); + // if (validation?.error) { + // error("OTP Tidak Sesuai"); + // return false; + // } + + const req = { + name: values.name, + description: values.description, + email: values.email, + }; + + MySwal.fire({ + title: "Berhasil Kirim", + text: "", + icon: "success", + showCancelButton: false, + confirmButtonColor: "#3085d6", + confirmButtonText: "Oke", + }).then((result) => { + if (result.isConfirmed) { + } + }); + reset(); + setNeedOtp(false); + setOtpValue(""); + props.modalStatus(!props.opened); + onOpenChange(); + } + + // setRefresh(!refresh); + // MySwal.fire({ + // title: "Sukses", + // icon: "success", + // confirmButtonColor: "#3085d6", + // confirmButtonText: "OK", + // }).then((result) => { + // if (result.isConfirmed) { + // } + // }); + }; + + return ( + <> + { + props.modalStatus(!props.opened); + onOpenChange(); + }} + size="3xl" + className="bg-white" + placement="top-center" + > + + {(onClose) => ( + <> + +
+

+ Kritik & Saran +

+
+
+ +
+ {needOtp ? ( +
+

+ Kode verifikasi sudah dikirmkan. Silahkan cek Email + Anda! +

+

OTP

+ + {/* -} + renderInput={(props) => ( + + )} + /> */} + +
+ ) : ( + <> +
+

Nama

+ ( + + )} + /> + {errors?.name && ( +

+ {errors.name?.message} +

+ )} +
+
+

Email

+ ( + + )} + /> + {errors?.email && ( +

+ {errors.email?.message} +

+ )} +
+
+

Kritik & Saran

+ ( +