mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
refactor: modularize profile setup components and update profile completion logic commit
This commit is contained in:
@@ -46,7 +46,7 @@ export function LoginPage() {
|
||||
const [rememberMe, setRememberMe] = useState(true);
|
||||
const [loginTrigger] = useApiMutation<LoginPayload>();
|
||||
const [meTrigger] = useApiMutation<AuthUser>();
|
||||
const [profileCheckTrigger] = useApiMutation<{ count: number; items: Array<{ userId: string }> }>();
|
||||
const [profileCheckTrigger] = useApiMutation<{ total: number; items: Array<{ id: string; user: { id: string }; isComplete: boolean }> }>();
|
||||
|
||||
const {
|
||||
register,
|
||||
@@ -74,19 +74,20 @@ export function LoginPage() {
|
||||
|
||||
try {
|
||||
const profiles = await profileCheckTrigger({
|
||||
url: '/profiles?take=10000&skip=0',
|
||||
url: `/profiles?q=${encodeURIComponent('i=user')}`,
|
||||
method: 'GET',
|
||||
}).unwrap();
|
||||
const userProfile = profiles.items?.find((p) => p.userId === me.id);
|
||||
const userProfile = profiles.items?.find((p) => p.user?.id === me.id);
|
||||
|
||||
if (!userProfile) {
|
||||
if (userProfile?.isComplete) {
|
||||
authStorage.setProfileId(userProfile.id);
|
||||
} else {
|
||||
navigate('/profile-setup');
|
||||
return;
|
||||
}
|
||||
|
||||
authStorage.setProfileId(userProfile.id);
|
||||
} catch {
|
||||
// profile check failed — proceed to dashboard anyway
|
||||
navigate('/profile-setup');
|
||||
return;
|
||||
}
|
||||
|
||||
if (me.isPhoneNumberVerified) {
|
||||
|
||||
Reference in New Issue
Block a user