feat: architecture refactor — core layer, spreadsheet engine, envelope bidding, tests
CI / quality (push) Waiting to run
CI / quality (push) Waiting to run
- Add src/core/ (config, errors, events, http, observability, storage, query) - Add src/Spreadsheet/ engine with native POI backend and Excel bridge - Add Envelope C spreadsheet flow and tender bidding envelope modules - Consolidate components into src/components/, remove legacy Component/ and Hooks/ - Add registration state/validation, auth session guard, profile edit modules - Add unit tests across axios, redux, bidding, registration, encryption, core - Add CI workflow, docs (architecture, audit, DSC API spec), keystore example - Remove tracked keystore binary; ignore scripts.zip Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
9acec328a7
commit
1d7646d938
@@ -1,9 +1,11 @@
|
||||
import React, { useCallback, useEffect, useRef } from 'react';
|
||||
import { Animated, StyleSheet, View } from 'react-native';
|
||||
import { useNavigation, useIsFocused } from '@react-navigation/native';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import { useSelector } from 'react-redux';
|
||||
|
||||
import { performLogout } from '../../Services/Auth/session';
|
||||
import { applyRouteDecision, decideRegistrationRoute } from '../../Services/Auth/registrationRouting';
|
||||
import { logger } from '../../core/observability/logger';
|
||||
import { showErrorAlert, showToast } from '../../Constant/ShowDailog';
|
||||
import { useRagistrationState } from '../../Services/ApiCall/Hooks';
|
||||
import NavigationString from '../../Constant/NavigationString';
|
||||
@@ -27,84 +29,37 @@ const Splash: React.FC = () => {
|
||||
const { mutateAsync: registrationStateMutate } = useRagistrationState();
|
||||
const hasSessionToken = Boolean(reduxToken && typeof reduxToken === 'object' && reduxToken.token);
|
||||
|
||||
const routeByOrgType = useCallback((params: { otherId: any; orgType: any }) => {
|
||||
const orgType = String(params.orgType ?? '');
|
||||
if (orgType === '4' || orgType === '5' || orgType === '6') {
|
||||
navigation.replace(NavigationString.StageThreeScreen, params);
|
||||
return;
|
||||
}
|
||||
|
||||
if (orgType === '7') {
|
||||
navigation.replace(NavigationString.Partnership, params);
|
||||
return;
|
||||
}
|
||||
|
||||
navigation.replace('Dashboard');
|
||||
}, [navigation]);
|
||||
|
||||
const handleGetData = useCallback(async () => {
|
||||
try {
|
||||
const res = await registrationStateMutate();
|
||||
console.log("splash", res);
|
||||
if (res?.status === false) {
|
||||
navigation.reset({
|
||||
index: 0,
|
||||
routes: [{ name: NavigationString.Login }],
|
||||
});
|
||||
const decision = decideRegistrationRoute(res);
|
||||
if (decision) {
|
||||
applyRouteDecision(navigation, decision);
|
||||
return;
|
||||
}
|
||||
|
||||
if (res?.data?.message === 'No Response From Server' && res?.data?.success === false) {
|
||||
navigation.reset({
|
||||
index: 0,
|
||||
routes: [{ name: NavigationString.Login }],
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (res?.statusCode === 404 || res?.statusCode === 401) {
|
||||
navigation.replace('Registration');
|
||||
return;
|
||||
}
|
||||
|
||||
if (res?.statusCode === 200 && res?.data) {
|
||||
const { registrationStatus, contOtherId, contOrganization } = res.data;
|
||||
const params = { otherId: contOtherId, orgType: contOrganization };
|
||||
switch (registrationStatus) {
|
||||
case null:
|
||||
case undefined:
|
||||
navigation.replace(NavigationString.Registration);
|
||||
break;
|
||||
case 'Pending':
|
||||
routeByOrgType(params);
|
||||
break;
|
||||
case 'Complete':
|
||||
case 'Completed':
|
||||
navigation.replace(NavigationString.Home);
|
||||
break;
|
||||
default:
|
||||
navigation.replace(NavigationString.Login);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
console.error('API error:', res);
|
||||
logger.warn('auth', 'unclassifiable registration-state response on splash', {
|
||||
statusCode: res?.statusCode,
|
||||
});
|
||||
showErrorAlert(res?.error || 'Something went wrong. Please try re-logging in.');
|
||||
navigation.reset({
|
||||
index: 0,
|
||||
routes: [{ name: NavigationString.Login }],
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error('Registration status error:', error);
|
||||
logger.error('auth', 'registration status resolution failed on splash', {
|
||||
error: String(error),
|
||||
});
|
||||
showToast(error?.message || 'Something went wrong');
|
||||
|
||||
if (error?.response?.status === 404) {
|
||||
navigation.replace('Registration');
|
||||
} else {
|
||||
await AsyncStorage.removeItem('persist:root');
|
||||
performLogout();
|
||||
navigation.replace(NavigationString.Login);
|
||||
}
|
||||
}
|
||||
}, [navigation, registrationStateMutate, routeByOrgType]);
|
||||
}, [navigation, registrationStateMutate]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isFocused || !isPersistRehydrated) {
|
||||
|
||||
Reference in New Issue
Block a user