chore: add change password
This commit is contained in:
+27
-2
@@ -11,10 +11,12 @@ import { ThemeProvider, useTheme } from "./src/context/ThemeContext";
|
||||
|
||||
import HomeScreen from "./src/screens/HomeScreen";
|
||||
import ClientLoginScreen from "./src/screens/auth/ClientLoginScreen";
|
||||
import ChangePasswordScreen from "./src/screens/auth/ChangePasswordScreen";
|
||||
import ClientNavigator from "./src/navigation/ClientNavigator";
|
||||
import type { RootStackParamList } from "./src/navigation/types";
|
||||
import type { RootStackParamList, ChangePasswordStackParamList } from "./src/navigation/types";
|
||||
|
||||
const Stack = createNativeStackNavigator<RootStackParamList>();
|
||||
const CPStack = createNativeStackNavigator<ChangePasswordStackParamList>();
|
||||
|
||||
function AuthStack() {
|
||||
const { colors } = useTheme();
|
||||
@@ -40,8 +42,27 @@ function AuthStack() {
|
||||
);
|
||||
}
|
||||
|
||||
function ForceChangePasswordStack() {
|
||||
const { colors } = useTheme();
|
||||
return (
|
||||
<CPStack.Navigator
|
||||
screenOptions={{
|
||||
headerStyle: { backgroundColor: colors.bgSecondary },
|
||||
headerTintColor: colors.textWhite,
|
||||
gestureEnabled: false,
|
||||
}}
|
||||
>
|
||||
<CPStack.Screen
|
||||
name="ChangePassword"
|
||||
component={ChangePasswordScreen}
|
||||
options={{ title: "Changer le mot de passe", headerLeft: () => null }}
|
||||
/>
|
||||
</CPStack.Navigator>
|
||||
);
|
||||
}
|
||||
|
||||
function RootNavigator() {
|
||||
const { isAuthenticated, isLoading, role } = useAuth();
|
||||
const { isAuthenticated, isLoading, role, mustChangePassword } = useAuth();
|
||||
const { colors, isDark } = useTheme();
|
||||
|
||||
if (isLoading) {
|
||||
@@ -59,6 +80,10 @@ function RootNavigator() {
|
||||
);
|
||||
}
|
||||
|
||||
if (isAuthenticated && role === "client" && mustChangePassword) {
|
||||
return <ForceChangePasswordStack />;
|
||||
}
|
||||
|
||||
if (isAuthenticated && role === "client") {
|
||||
return (
|
||||
<CartProvider>
|
||||
|
||||
Reference in New Issue
Block a user