refactor: standarisasi antarmuka fungsi login dan pengambilan OTP

Mengubah parameter fungsi auth_funLogin dan auth_getKodeOtpById di backend untuk menggunakan objek, meningkatkan konsistensi dan memudahkan pemahaman tentang data yang diproses. Selain itu, memperbaiki struktur respons fungsi untuk menambahkan  dalam output, memperjelas sumber terjadinya error.
- Di , fungsi auth_funLogin diubah untuk menerima sebuah objek  daripada hanya .
- Di , perubahan variabel  ke  untuk menyelaraskan dengan parameter terbaru dari fungsi yang diinvokasi.
This commit is contained in:
2024-09-18 14:56:31 +08:00
parent 6ee43ed20f
commit 128dc98839
6 changed files with 26 additions and 27 deletions

View File

@@ -34,16 +34,14 @@ export default function Login() {
const [isError, setError] = useState(false);
async function onLogin() {
const nomorHp = phone.substring(1);
const nomor = phone.substring(1);
if (nomor.length <= 4) return setError(true);
if (nomorHp.length <= 4) return setError(true);
const res = await auth_funLogin(nomorHp);
const res = await auth_funLogin({ nomor: nomor });
if (res.status === 200) {
setLoading(true);
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
setKodeId(res.kodeOtpId);
router.push(RouterAuth.validasi + res.kodeOtpId);
router.push(RouterAuth.validasi + res.nomorUser, { scroll: false });
} else {
ComponentGlobal_NotifikasiPeringatan(res.message);
}