mirror of
https://github.com/Sea-Haven-Industries/proposal-system.git
synced 2026-09-30 08:53:15 +00:00
* Fix NuGet versions and add InitialCreate EF Core migration - Update AWSSDK.SQS and AWSSDK.SecretsManager to 3.7.500.0 (actual available versions) - Update AWSSDK.Extensions.NETCore.Setup to 3.7.400 - Generate InitialCreate migration for PostgreSQL (all 8 entities) - Build verified: 0 errors, 0 warnings * Implement Dispatcher Frontend (Phase 2) React 19 + MUI v7 + TypeScript + Vite SPA matching SHOC patterns: Redux Toolkit (auth/ui slices), TanStack React Query, axios interceptors, react-toastify, Cognito OAuth PKCE login flow, paginated proposal list, new proposal form with customer autocomplete and vendor PDF upload, read-only proposal detail with status stepper timeline. * Add AuthController for Cognito code exchange and .env.example Backend endpoint POST /api/auth/callback exchanges the OAuth authorization code with Cognito's token endpoint, auto-provisions the user in the DB, and returns the access token to the frontend. * Implement Admin Frontend Experience (Phase 3) Three-panel admin workspace: left reference panel (submission details, vendor data), center editor (refined scope, inline line item table with reorder/add/remove/pricing), right similar proposals panel (KB results with pull-to-editor). Admin dashboard with stats cards and proposal queue table. Approval flow with confirmation dialog, mark-as-sent, and create-revision actions. Role-based sidebar navigation. * Implement backend dev mode, internal API auth, and service layer enhancements - Add dev-login endpoint with local JWT signing for local development - Add InternalApiKeyMiddleware with timing-safe comparison for Lambda-to-API auth - Add DevS3Service and NoOpJobPublisher for running without AWS services - Implement CurrentUserService cascading user resolution (ID → sub → email → create) - Add async ResolveAsync() to avoid synchronous DB calls in request pipeline - Add /proposals/stats endpoint for efficient server-side status counts - Guard status transitions: only allow Draft → InReview via update endpoint - Add vendor proposals, generated PDFs, and similar proposals controllers - Add ISimilarProposalService and SimilarProposalService - Add [Authorize] to AddSimilarReference endpoint * Implement Lambda functions for PDF processing, suggestions, and library ingest - pdf-extract: Parse vendor PDFs with pdfplumber, fallback to Claude multimodal - pdf-generate: Generate branded proposal PDFs with reportlab Platypus - library-ingest: Format approved proposals as markdown and sync to Bedrock KB - suggestions: Query KB for similar proposals, generate line items via Claude - All Lambdas use internal API key auth and cold-start secret caching - Fix pdf_path unbound variable in pdf-extract error handling * Add Bedrock Knowledge Base, OpenSearch Serverless, and SQS message filtering - Provision OpenSearch Serverless collection for vector search - Create Bedrock Knowledge Base with Titan embedding model - Configure S3 data source with fixed-size chunking (512 tokens, 20% overlap) - Add suggestions Lambda with SQS event source filtering - Scope bedrock:InvokeModel IAM to specific model ARN patterns - Add internal API key secret in Secrets Manager - Add log retention (2 months) to all Lambda functions - Add docker-compose.yml for local PostgreSQL * Apply SHOC design system styling across frontend - Rewrite theme with SHOC palette (#0c4f6f primary, Nunito font, 4px radius) - Add global CSS with Google Fonts import for Nunito - Redesign Topbar with avatar initials, role subtitle, gradient header - Redesign Sidebar with 220px width, section headers, active state border - Restyle LoginPage with SHOC branded card and dev-mode role selector - Update AdminDashboard KPI cards to centered SHOC style - Add devLogin API method for local development auth flow * Fix frontend navigation bugs, differentiate Dashboard from Proposals list - Fix double nav selection by adding isNavActive() with ALL_NAV_PATHS set - Fix /admin/users routing to placeholder instead of redirect to / - Fix ProposalDetailPage Back button navigating to / instead of /proposals - Differentiate Dashboard (KPI cards + recent 5) from ProposalListPage (full paginated table) - Dashboard now uses dedicated /proposals/stats endpoint for accurate counts - Fix adminApi.getPdf dead code (axios rejects before status check) - Wire up PDF generation button in AdminWorkspace - Adjust layout: 220px drawer, 10px content padding, 64px toolbar height * Add appsettings.Development.json to gitignore Prevent dev-only signing keys and connection strings from being committed. * Fix CI failures: unused Python imports and CDK synth asset path CDK synth job needs the .NET API published first so the Lambda asset path exists. Python lint had 3 unused imports in pdf-generate. * Apply ruff formatting to all Lambda Python files
169 lines
5.9 KiB
TypeScript
169 lines
5.9 KiB
TypeScript
import { useEffect, useState } from 'react';
|
|
import { useNavigate } from 'react-router-dom';
|
|
import { useDispatch } from 'react-redux';
|
|
import { Box, Button, Card, CardContent, Typography, Divider, Stack } from '@mui/material';
|
|
import GoogleIcon from '@mui/icons-material/Google';
|
|
import AdminPanelSettingsIcon from '@mui/icons-material/AdminPanelSettings';
|
|
import EngineeringIcon from '@mui/icons-material/Engineering';
|
|
import PersonIcon from '@mui/icons-material/Person';
|
|
import { useAuth } from '../../hooks/useAuth';
|
|
import { authApi } from '../../lib/api/auth';
|
|
import { setUser, setError } from '../../app/slices/authSlice';
|
|
|
|
const COGNITO_DOMAIN = import.meta.env.VITE_COGNITO_DOMAIN || '';
|
|
const CLIENT_ID = import.meta.env.VITE_COGNITO_CLIENT_ID || '';
|
|
const REDIRECT_URI = `${window.location.origin}/callback`;
|
|
|
|
function buildLoginUrl(): string {
|
|
const params = new URLSearchParams({
|
|
client_id: CLIENT_ID,
|
|
response_type: 'code',
|
|
scope: 'openid email profile',
|
|
redirect_uri: REDIRECT_URI,
|
|
identity_provider: 'Google',
|
|
});
|
|
return `https://${COGNITO_DOMAIN}/oauth2/authorize?${params.toString()}`;
|
|
}
|
|
|
|
export default function LoginPage() {
|
|
const navigate = useNavigate();
|
|
const dispatch = useDispatch();
|
|
const { isAuthenticated } = useAuth();
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const isDevMode = !CLIENT_ID;
|
|
|
|
useEffect(() => {
|
|
if (isAuthenticated) {
|
|
navigate('/', { replace: true });
|
|
}
|
|
}, [isAuthenticated, navigate]);
|
|
|
|
const handleDevLogin = async (role: string) => {
|
|
setLoading(true);
|
|
try {
|
|
const user = await authApi.devLogin('adam@seahavenind.com', 'Adam Moussa', role);
|
|
dispatch(setUser(user));
|
|
navigate('/', { replace: true });
|
|
} catch (err) {
|
|
dispatch(setError(err instanceof Error ? err.message : 'Dev login failed'));
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Box
|
|
sx={{
|
|
minHeight: '100vh',
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
alignItems: 'center',
|
|
justifyContent: 'flex-start',
|
|
pt: '7%',
|
|
bgcolor: '#333',
|
|
}}
|
|
>
|
|
<Box sx={{ width: '100%', maxWidth: 400, mx: 2 }}>
|
|
<Card sx={{ borderRadius: 0, boxShadow: '0 0 10px rgba(0,0,0,0.3)', border: 'none' }}>
|
|
<Box
|
|
sx={{
|
|
height: 100,
|
|
display: 'flex',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
bgcolor: '#fff',
|
|
borderBottom: '1px solid #b8b5b5',
|
|
px: 3,
|
|
}}
|
|
>
|
|
<Typography sx={{ fontSize: '24px', fontWeight: 600, color: '#003A5D' }}>
|
|
Sea Haven Industries
|
|
</Typography>
|
|
</Box>
|
|
<Box
|
|
sx={{
|
|
bgcolor: '#003A5D',
|
|
height: 40,
|
|
display: 'flex',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
borderBottom: '1px solid #b8b5b5',
|
|
}}
|
|
>
|
|
<Typography sx={{ fontSize: '14px', fontWeight: 700, color: '#fff' }}>
|
|
Proposal System
|
|
</Typography>
|
|
</Box>
|
|
<CardContent sx={{ p: '30px', textAlign: 'center' }}>
|
|
{isDevMode ? (
|
|
<>
|
|
<Typography variant="body2" color="text.secondary" sx={{ mb: 3 }}>
|
|
Development Mode — Select a role to sign in as:
|
|
</Typography>
|
|
<Stack spacing={2}>
|
|
<Button
|
|
variant="contained"
|
|
size="large"
|
|
fullWidth
|
|
startIcon={<AdminPanelSettingsIcon />}
|
|
onClick={() => handleDevLogin('SysAdmin')}
|
|
disabled={loading}
|
|
sx={{ py: 1.5, bgcolor: '#003A5D', '&:hover': { bgcolor: '#00527d' } }}
|
|
>
|
|
Sign in as SysAdmin
|
|
</Button>
|
|
<Button
|
|
variant="contained"
|
|
size="large"
|
|
fullWidth
|
|
startIcon={<EngineeringIcon />}
|
|
onClick={() => handleDevLogin('Admin')}
|
|
disabled={loading}
|
|
sx={{ py: 1.5, bgcolor: '#0c4f6f', '&:hover': { bgcolor: '#083a52' } }}
|
|
>
|
|
Sign in as Admin
|
|
</Button>
|
|
<Button
|
|
variant="outlined"
|
|
size="large"
|
|
fullWidth
|
|
startIcon={<PersonIcon />}
|
|
onClick={() => handleDevLogin('Dispatcher')}
|
|
disabled={loading}
|
|
sx={{ py: 1.5 }}
|
|
>
|
|
Sign in as Dispatcher
|
|
</Button>
|
|
</Stack>
|
|
<Divider sx={{ my: 2 }} />
|
|
<Typography variant="caption" color="text.secondary">
|
|
Dev login is only available when VITE_COGNITO_CLIENT_ID is not set
|
|
</Typography>
|
|
</>
|
|
) : (
|
|
<>
|
|
<Typography variant="body2" color="text.secondary" sx={{ mb: 4 }}>
|
|
Sign in with your Sea Haven Google account to continue.
|
|
</Typography>
|
|
<Button
|
|
variant="contained"
|
|
size="large"
|
|
fullWidth
|
|
startIcon={<GoogleIcon />}
|
|
href={buildLoginUrl()}
|
|
sx={{ py: 1.5, bgcolor: '#003A5D', '&:hover': { bgcolor: '#00527d' } }}
|
|
>
|
|
Sign in with Google
|
|
</Button>
|
|
</>
|
|
)}
|
|
</CardContent>
|
|
</Card>
|
|
<Typography sx={{ textAlign: 'center', color: '#fff', fontSize: '12px', mt: 2, opacity: 0.7 }}>
|
|
Sea Haven Industries © {new Date().getFullYear()}
|
|
</Typography>
|
|
</Box>
|
|
</Box>
|
|
);
|
|
}
|