Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
import React, { useState } from 'react';
|
2026-05-20 11:36:51 -04:00
|
|
|
import {
|
|
|
|
|
View,
|
|
|
|
|
StyleSheet,
|
|
|
|
|
KeyboardAvoidingView,
|
|
|
|
|
Platform,
|
|
|
|
|
ScrollView,
|
|
|
|
|
} from 'react-native';
|
|
|
|
|
import {
|
|
|
|
|
Button,
|
|
|
|
|
Text,
|
|
|
|
|
Surface,
|
|
|
|
|
TextInput,
|
|
|
|
|
Divider,
|
|
|
|
|
HelperText,
|
|
|
|
|
} from 'react-native-paper';
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
|
|
|
import { useDispatch } from 'react-redux';
|
|
|
|
|
import { authApi } from '../../lib/api/auth';
|
2026-05-20 11:36:51 -04:00
|
|
|
import { setUser, setError, clearError } from '../../store/slices/authSlice';
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
|
|
|
|
|
export function LoginScreen() {
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
const [loading, setLoading] = useState(false);
|
2026-05-20 11:36:51 -04:00
|
|
|
const [email, setEmail] = useState('');
|
|
|
|
|
const [password, setPassword] = useState('');
|
|
|
|
|
const [showPassword, setShowPassword] = useState(false);
|
|
|
|
|
const [localError, setLocalError] = useState('');
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
|
2026-05-20 11:36:51 -04:00
|
|
|
const handleGoogleLogin = async () => {
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
setLoading(true);
|
2026-05-20 11:36:51 -04:00
|
|
|
setLocalError('');
|
|
|
|
|
dispatch(clearError());
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
try {
|
|
|
|
|
const user = await authApi.login();
|
|
|
|
|
dispatch(setUser(user));
|
|
|
|
|
} catch (err) {
|
|
|
|
|
const message =
|
|
|
|
|
err instanceof Error ? err.message : 'Login failed. Please try again.';
|
2026-05-20 11:36:51 -04:00
|
|
|
setLocalError(message);
|
|
|
|
|
dispatch(setError(message));
|
|
|
|
|
} finally {
|
|
|
|
|
setLoading(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleCredentialLogin = async () => {
|
|
|
|
|
if (!email.trim() || !password) {
|
|
|
|
|
setLocalError('Email and password are required.');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
setLoading(true);
|
|
|
|
|
setLocalError('');
|
|
|
|
|
dispatch(clearError());
|
|
|
|
|
try {
|
|
|
|
|
const user = await authApi.loginWithCredentials(
|
|
|
|
|
email.trim().toLowerCase(),
|
|
|
|
|
password,
|
|
|
|
|
);
|
|
|
|
|
dispatch(setUser(user));
|
|
|
|
|
} catch (err) {
|
|
|
|
|
const message =
|
|
|
|
|
err instanceof Error ? err.message : 'Login failed. Please try again.';
|
|
|
|
|
setLocalError(message);
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
dispatch(setError(message));
|
|
|
|
|
} finally {
|
|
|
|
|
setLoading(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<SafeAreaView style={styles.container}>
|
2026-05-20 11:36:51 -04:00
|
|
|
<KeyboardAvoidingView
|
|
|
|
|
style={styles.flex}
|
|
|
|
|
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
|
|
|
>
|
|
|
|
|
<ScrollView
|
|
|
|
|
contentContainerStyle={styles.content}
|
|
|
|
|
keyboardShouldPersistTaps="handled"
|
|
|
|
|
>
|
|
|
|
|
<Surface style={styles.logoContainer} elevation={0}>
|
|
|
|
|
<Text variant="headlineLarge" style={styles.brand}>
|
|
|
|
|
Sea Haven
|
|
|
|
|
</Text>
|
|
|
|
|
<Text variant="titleMedium" style={styles.brandSub}>
|
|
|
|
|
Industries
|
|
|
|
|
</Text>
|
|
|
|
|
</Surface>
|
|
|
|
|
|
|
|
|
|
<Text variant="headlineSmall" style={styles.title}>
|
|
|
|
|
Proposal System
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
</Text>
|
2026-05-20 11:36:51 -04:00
|
|
|
<Text variant="bodyLarge" style={styles.subtitle}>
|
|
|
|
|
Submit and manage proposals from anywhere
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
</Text>
|
|
|
|
|
|
2026-05-20 11:36:51 -04:00
|
|
|
<View style={styles.form}>
|
|
|
|
|
<TextInput
|
|
|
|
|
label="Email"
|
|
|
|
|
value={email}
|
|
|
|
|
onChangeText={setEmail}
|
|
|
|
|
autoCapitalize="none"
|
|
|
|
|
autoComplete="email"
|
|
|
|
|
keyboardType="email-address"
|
|
|
|
|
textContentType="emailAddress"
|
|
|
|
|
mode="outlined"
|
|
|
|
|
disabled={loading}
|
|
|
|
|
style={styles.input}
|
|
|
|
|
/>
|
|
|
|
|
<TextInput
|
|
|
|
|
label="Password"
|
|
|
|
|
value={password}
|
|
|
|
|
onChangeText={setPassword}
|
|
|
|
|
secureTextEntry={!showPassword}
|
|
|
|
|
autoCapitalize="none"
|
|
|
|
|
autoComplete="password"
|
|
|
|
|
textContentType="password"
|
|
|
|
|
mode="outlined"
|
|
|
|
|
disabled={loading}
|
|
|
|
|
style={styles.input}
|
|
|
|
|
right={
|
|
|
|
|
<TextInput.Icon
|
|
|
|
|
icon={showPassword ? 'eye-off' : 'eye'}
|
|
|
|
|
onPress={() => setShowPassword(!showPassword)}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{localError ? (
|
|
|
|
|
<HelperText type="error" visible>
|
|
|
|
|
{localError}
|
|
|
|
|
</HelperText>
|
|
|
|
|
) : null}
|
|
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
mode="contained"
|
|
|
|
|
onPress={handleCredentialLogin}
|
|
|
|
|
loading={loading}
|
|
|
|
|
disabled={loading}
|
|
|
|
|
contentStyle={styles.buttonContent}
|
|
|
|
|
style={styles.button}
|
|
|
|
|
>
|
|
|
|
|
Sign In
|
|
|
|
|
</Button>
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
<View style={styles.dividerRow}>
|
|
|
|
|
<Divider style={styles.dividerLine} />
|
|
|
|
|
<Text variant="bodySmall" style={styles.dividerText}>
|
|
|
|
|
OR
|
|
|
|
|
</Text>
|
|
|
|
|
<Divider style={styles.dividerLine} />
|
|
|
|
|
</View>
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
|
|
|
|
|
<Button
|
2026-05-20 11:36:51 -04:00
|
|
|
mode="outlined"
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
icon="google"
|
2026-05-20 11:36:51 -04:00
|
|
|
onPress={handleGoogleLogin}
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
loading={loading}
|
|
|
|
|
disabled={loading}
|
|
|
|
|
contentStyle={styles.buttonContent}
|
|
|
|
|
style={styles.button}
|
|
|
|
|
>
|
|
|
|
|
Sign in with Google
|
|
|
|
|
</Button>
|
|
|
|
|
|
2026-05-20 11:36:51 -04:00
|
|
|
<Text variant="bodySmall" style={styles.footer}>
|
|
|
|
|
Use your Sea Haven email to sign in
|
|
|
|
|
</Text>
|
|
|
|
|
</ScrollView>
|
|
|
|
|
</KeyboardAvoidingView>
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
</SafeAreaView>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
|
container: {
|
|
|
|
|
flex: 1,
|
|
|
|
|
backgroundColor: '#FAFAFA',
|
|
|
|
|
},
|
2026-05-20 11:36:51 -04:00
|
|
|
flex: {
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
flex: 1,
|
2026-05-20 11:36:51 -04:00
|
|
|
},
|
|
|
|
|
content: {
|
|
|
|
|
flexGrow: 1,
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
paddingHorizontal: 32,
|
2026-05-20 11:36:51 -04:00
|
|
|
paddingVertical: 24,
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
},
|
|
|
|
|
logoContainer: {
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
marginBottom: 32,
|
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
|
},
|
|
|
|
|
brand: {
|
|
|
|
|
fontWeight: '800',
|
|
|
|
|
color: '#1565C0',
|
|
|
|
|
},
|
|
|
|
|
brandSub: {
|
|
|
|
|
color: '#757575',
|
|
|
|
|
marginTop: -4,
|
|
|
|
|
},
|
|
|
|
|
title: {
|
|
|
|
|
fontWeight: '700',
|
|
|
|
|
color: '#212121',
|
|
|
|
|
marginBottom: 8,
|
|
|
|
|
},
|
|
|
|
|
subtitle: {
|
|
|
|
|
color: '#757575',
|
|
|
|
|
textAlign: 'center',
|
2026-05-20 11:36:51 -04:00
|
|
|
marginBottom: 32,
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
},
|
2026-05-20 11:36:51 -04:00
|
|
|
form: {
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
width: '100%',
|
|
|
|
|
},
|
2026-05-20 11:36:51 -04:00
|
|
|
input: {
|
|
|
|
|
marginBottom: 12,
|
|
|
|
|
},
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
buttonContent: {
|
|
|
|
|
paddingVertical: 8,
|
|
|
|
|
},
|
|
|
|
|
button: {
|
|
|
|
|
borderRadius: 8,
|
2026-05-20 11:36:51 -04:00
|
|
|
width: '100%',
|
|
|
|
|
},
|
|
|
|
|
dividerRow: {
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
width: '100%',
|
|
|
|
|
marginVertical: 20,
|
|
|
|
|
},
|
|
|
|
|
dividerLine: {
|
|
|
|
|
flex: 1,
|
|
|
|
|
},
|
|
|
|
|
dividerText: {
|
|
|
|
|
color: '#9E9E9E',
|
|
|
|
|
marginHorizontal: 16,
|
Add mobile navigation, components, and all screens
Role-based bottom-tab navigation (dispatcher dashboard, admin workspace),
shared components (StatusChip, PriorityChip, ProposalCard, LineItemRow,
FilePickerButton, EmptyState), dispatcher screens (dashboard, new proposal
with camera/document picker and offline drafts, proposal detail), admin
screens (dashboard with stats, proposal queue, workspace with approve/
regenerate/PDF, line item editor), login, and settings.
2026-05-17 15:09:43 -04:00
|
|
|
},
|
|
|
|
|
footer: {
|
|
|
|
|
color: '#9E9E9E',
|
|
|
|
|
marginTop: 24,
|
|
|
|
|
},
|
|
|
|
|
});
|