barsa 1d1602f5e7 feat: Implement unified eligibility check flow with inline OTP verification
- Refactor PublicLandingView to enhance service section animations.
- Update SimPlansContent and PublicEligibilityCheck to streamline service highlights.
- Revise PublicEligibilityCheck to support new flow: "Send Request Only" and "Continue to Create Account".
- Introduce guest eligibility check API with handoff token for account creation.
- Modify success step to provide clear options for account creation and navigation.
- Enhance form handling and error management in PublicEligibilityCheckView.
- Update domain schemas to accommodate guest eligibility requests and responses.
- Document new eligibility check flows and testing procedures.
2026-01-14 17:14:07 +09:00

105 lines
3.4 KiB
TypeScript

/**
* Get Started API Client
*
* API calls for the unified get-started flow
*/
import { apiClient, getDataOrThrow } from "@/core/api";
import {
sendVerificationCodeResponseSchema,
verifyCodeResponseSchema,
quickEligibilityResponseSchema,
guestEligibilityResponseSchema,
maybeLaterResponseSchema,
type SendVerificationCodeRequest,
type SendVerificationCodeResponse,
type VerifyCodeRequest,
type VerifyCodeResponse,
type QuickEligibilityRequest,
type QuickEligibilityResponse,
type GuestEligibilityRequest,
type GuestEligibilityResponse,
type CompleteAccountRequest,
type MaybeLaterRequest,
type MaybeLaterResponse,
} from "@customer-portal/domain/get-started";
import { authResponseSchema, type AuthResponse } from "@customer-portal/domain/auth";
const BASE_PATH = "/api/auth/get-started";
/**
* Send OTP verification code to email
*/
export async function sendVerificationCode(
request: SendVerificationCodeRequest
): Promise<SendVerificationCodeResponse> {
const response = await apiClient.POST<SendVerificationCodeResponse>(`${BASE_PATH}/send-code`, {
body: request,
});
const data = getDataOrThrow(response, "Failed to send verification code");
return sendVerificationCodeResponseSchema.parse(data);
}
/**
* Verify OTP code and get account status
*/
export async function verifyCode(request: VerifyCodeRequest): Promise<VerifyCodeResponse> {
const response = await apiClient.POST<VerifyCodeResponse>(`${BASE_PATH}/verify-code`, {
body: request,
});
const data = getDataOrThrow(response, "Failed to verify code");
return verifyCodeResponseSchema.parse(data);
}
/**
* Quick eligibility check (guest flow) - requires OTP verification
*/
export async function quickEligibilityCheck(
request: QuickEligibilityRequest
): Promise<QuickEligibilityResponse> {
const response = await apiClient.POST<QuickEligibilityResponse>(`${BASE_PATH}/quick-check`, {
body: request,
});
const data = getDataOrThrow(response, "Failed to submit eligibility check");
return quickEligibilityResponseSchema.parse(data);
}
/**
* Guest eligibility check - NO OTP verification required
* Allows users to check availability without verifying email first
* Email verification happens later when user creates an account
*/
export async function guestEligibilityCheck(
request: GuestEligibilityRequest
): Promise<GuestEligibilityResponse> {
const response = await apiClient.POST<GuestEligibilityResponse>(
`${BASE_PATH}/guest-eligibility`,
{ body: request }
);
const data = getDataOrThrow(response, "Failed to submit eligibility check");
return guestEligibilityResponseSchema.parse(data);
}
/**
* Maybe later flow - create SF account and eligibility case
*/
export async function maybeLater(request: MaybeLaterRequest): Promise<MaybeLaterResponse> {
const response = await apiClient.POST<MaybeLaterResponse>(`${BASE_PATH}/maybe-later`, {
body: request,
});
const data = getDataOrThrow(response, "Failed to submit request");
return maybeLaterResponseSchema.parse(data);
}
/**
* Complete account for SF-only users
* Returns auth response with user and session
*/
export async function completeAccount(request: CompleteAccountRequest): Promise<AuthResponse> {
const response = await apiClient.POST<AuthResponse>(`${BASE_PATH}/complete-account`, {
body: request,
});
const data = getDataOrThrow(response, "Failed to complete account");
return authResponseSchema.parse(data);
}