Skip to content

QNH-309 and QNH-311. Create Register Page and Login Page - #15

Merged
spectraVal merged 1 commit into
developmentfrom
FE
Jun 22, 2026
Merged

QNH-309 and QNH-311. Create Register Page and Login Page#15
spectraVal merged 1 commit into
developmentfrom
FE

Conversation

@spectraVal

Copy link
Copy Markdown
Owner

Summary

Implementasi infrastruktur autentikasi frontend dan dua halaman pertama
Sprint 9: Register dan Login. PR ini mencakup fondasi yang dibutuhkan oleh
semua task auth selanjutnya (AUTH-03, AUTH-04) — Axios instance, Auth Context,
route guards, service layer — sekaligus dua page pertama yang menggunakannya.

Jira Ticket

Ticket: AUTH-01, AUTH-02

Type of Change

  • New feature

Changes Made

  • src/api/axiosInstance.ts — Axios instance terpusat dengan baseURL dari
    VITE_API_URL, default headers, withCredentials: true, dan interceptor
    untuk attach Bearer token dari sessionStorage
  • src/types/auth.ts — Shared TypeScript interfaces untuk auth domain
    (AuthUser, RegisterPayload, LoginPayload, dll)
  • src/services/authService.ts — Abstraksi HTTP call untuk register, login,
    dan logout; komponen tidak memanggil Axios secara langsung
  • src/contexts/AuthContext.tsx — React Context untuk auth state (user, token,
    isAuthenticated) dengan sessionStorage sebagai bridge survive-refresh
  • src/hooks/useAuth.ts — Custom hook untuk consume AuthContext
  • src/routes/PublicRoute.tsx — Route guard: redirect ke /dashboard jika sudah
    authenticated
  • src/routes/ProtectedRoute.tsx — Route guard: redirect ke /login jika belum
    authenticated
  • src/pages/RegisterPage.tsx — Form register (name, email, phone, password,
    password_confirmation) dengan per-field error handling untuk 422 dan generic
    error untuk 500
  • src/pages/LoginPage.tsx — Form login (email, password) dengan role-based
    redirect ke /dashboard, error handling 401 dan 422
  • src/App.tsx — Updated dengan BrowserRouter, AuthProvider, dan route
    structure (public + protected)
  • src/tests/pages/RegisterPage.test.tsx — 6 unit tests
  • src/tests/pages/LoginPage.test.tsx — 7 unit tests
  • .env.example — Dokumentasi environment variable VITE_API_URL

How to Test

  1. Copy .env.example ke .env.local dan set VITE_API_URL ke URL backend
  2. Jalankan npm run dev dan buka /register
  3. Isi form register dan submit — verifikasi redirect ke /login dengan
    success message
  4. Di /login, login dengan credentials yang baru didaftarkan — verifikasi
    redirect ke /dashboard
  5. Coba akses /login saat sudah authenticated — verifikasi redirect ke
    /dashboard
  6. Coba akses /dashboard saat belum authenticated — verifikasi redirect ke
    /login
  7. Jalankan unit test: npm run test

Screenshots (if applicable)

Checklist

  • Kode sudah di-test secara lokal
  • Tidak ada console.log yang tertinggal
  • Tidak ada conflict dengan branch target
  • Nama branch mengikuti konvensi (feature/AUTH-01-AUTH-02-register-login-page)
  • PR title mengikuti konvensi (AUTH-01 & AUTH-02 | Register Page + Login Page + Auth Infrastructure)

Notes for Reviewer

Auth mode saat ini masih menggunakan Bearer Token (sessionStorage bridge)
karena implementasi dikerjakan sebelum keputusan migrasi ke Sanctum
Cookie-based Session (ADR-006). Revisi ke cookie-based akan dilakukan di
sprint ticket terpisah setelah OpenAPI contract diupdate oleh BE.

@spectraVal
spectraVal merged commit 963ecf3 into development Jun 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant