import type { IProfileInformationResponse } from "@/services/eva-display/profile/profile-information.services"; function IsNullOrEmpty(value: string | null | undefined | number): boolean { return value === null || value === undefined || value === ""; } const PROFILE_PATH = "/profile/personal-information"; export function checkProfileInformation( data: IProfileInformationResponse, ): boolean { const { userDetail: { firstName, lastName, gender, birthDate }, phoneNumber, passaportDetail: { nationality: { name: nationalityName }, citizenNo, }, } = data.result; if ( IsNullOrEmpty(firstName) || IsNullOrEmpty(lastName) || IsNullOrEmpty(gender) || IsNullOrEmpty(birthDate) || IsNullOrEmpty(phoneNumber) || IsNullOrEmpty(nationalityName) || IsNullOrEmpty(citizenNo) ) { return false; } return true; } export function CheckProfileAndRedirect( data: IProfileInformationResponse, ): boolean { const { userDetail: { firstName, lastName, gender, birthDate }, phoneNumber, passaportDetail: { nationality: { name: nationalityName }, citizenNo, }, } = data.result; if ( IsNullOrEmpty(firstName) || IsNullOrEmpty(lastName) || IsNullOrEmpty(gender) || IsNullOrEmpty(birthDate) || IsNullOrEmpty(phoneNumber) || IsNullOrEmpty(nationalityName) || IsNullOrEmpty(citizenNo) ) { if (window.location.pathname === PROFILE_PATH) return false; window.location.href = `${PROFILE_PATH}?mode=edit`; return false; } return true; }