refactor: modularize profile setup components and update profile completion logic commit

This commit is contained in:
mengstabketemaw
2026-06-26 16:12:25 +03:00
parent 08ade42157
commit ac8df4cdff
6 changed files with 624 additions and 310 deletions

View File

@@ -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) {