"use client"; import { AccentColor, MainColor, } from "@/app_modules/_global/color/color_pallet"; import ComponentGlobal_ErrorInput from "@/app_modules/_global/component/error_input"; import { ComponentGlobal_NotifikasiBerhasil, ComponentGlobal_NotifikasiGagal, ComponentGlobal_NotifikasiPeringatan, } from "@/app_modules/_global/notif_global"; import { UIGlobal_LayoutDefault } from "@/app_modules/_global/ui"; import { clientLogger } from "@/util/clientLogger"; import { Box, Button, Center, Group, Stack, Text, Title } from "@mantine/core"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { PhoneInput } from "react-international-phone"; import "react-international-phone/style.css"; export default function Login({ version }: { version: string }) { const router = useRouter(); const [phone, setPhone] = useState(""); const [loading, setLoading] = useState(false); const [isError, setError] = useState(false); async function onLogin() { const nomor = phone.substring(1); if (nomor.length <= 4) return setError(true); try { setLoading(true); const res = await fetch("/api/auth/login", { method: "POST", body: JSON.stringify({ nomor: nomor }), headers: { "Content-Type": "application/json", }, }); const result = await res.json(); if (res.status == 500) { ComponentGlobal_NotifikasiGagal("Server Error"); return; } if (res.status === 200) { localStorage.setItem("hipmi_auth_code_id", result.kodeId); ComponentGlobal_NotifikasiBerhasil(result.message, 2000); router.push("/validasi", { scroll: false }); } else { ComponentGlobal_NotifikasiPeringatan(result.message); } } catch (error) { clientLogger.error("Error login:", error); ComponentGlobal_NotifikasiGagal("Terjadi Kesalahan"); } finally { setLoading(false); } } return ( <> WELCOME TO HIPMI BADUNG APPS powered by muku.id
Nomor telepon
{ setPhone(val); }} /> {isError ? ( ) : ( "" )}
v {version}
); }