Fix AI chatbot role mapping, add markdown formatting, update system prompts, and handle OpenRouter API errors

This commit is contained in:
Atharv1705
2026-07-20 12:14:58 +05:30
parent 756547a22c
commit c2e22902c8
168 changed files with 11556 additions and 2 deletions
+184
View File
@@ -0,0 +1,184 @@
.counter {
font-size: 16px;
padding: 5px 10px;
border-radius: 5px;
color: var(--accent);
background: var(--accent-bg);
border: 2px solid transparent;
transition: border-color 0.3s;
margin-bottom: 24px;
&:hover {
border-color: var(--accent-border);
}
&:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
}
.hero {
position: relative;
.base,
.framework,
.vite {
inset-inline: 0;
margin: 0 auto;
}
.base {
width: 170px;
position: relative;
z-index: 0;
}
.framework,
.vite {
position: absolute;
}
.framework {
z-index: 1;
top: 34px;
height: 28px;
transform: perspective(2000px) rotateZ(300deg) rotateX(44deg) rotateY(39deg)
scale(1.4);
}
.vite {
z-index: 0;
top: 107px;
height: 26px;
width: auto;
transform: perspective(2000px) rotateZ(300deg) rotateX(40deg) rotateY(39deg)
scale(0.8);
}
}
#center {
display: flex;
flex-direction: column;
gap: 25px;
place-content: center;
place-items: center;
flex-grow: 1;
@media (max-width: 1024px) {
padding: 32px 20px 24px;
gap: 18px;
}
}
#next-steps {
display: flex;
border-top: 1px solid var(--border);
text-align: left;
& > div {
flex: 1 1 0;
padding: 32px;
@media (max-width: 1024px) {
padding: 24px 20px;
}
}
.icon {
margin-bottom: 16px;
width: 22px;
height: 22px;
}
@media (max-width: 1024px) {
flex-direction: column;
text-align: center;
}
}
#docs {
border-right: 1px solid var(--border);
@media (max-width: 1024px) {
border-right: none;
border-bottom: 1px solid var(--border);
}
}
#next-steps ul {
list-style: none;
padding: 0;
display: flex;
gap: 8px;
margin: 32px 0 0;
.logo {
height: 18px;
}
a {
color: var(--text-h);
font-size: 16px;
border-radius: 6px;
background: var(--social-bg);
display: flex;
padding: 6px 12px;
align-items: center;
gap: 8px;
text-decoration: none;
transition: box-shadow 0.3s;
&:hover {
box-shadow: var(--shadow);
}
.button-icon {
height: 18px;
width: 18px;
}
}
@media (max-width: 1024px) {
margin-top: 20px;
flex-wrap: wrap;
justify-content: center;
li {
flex: 1 1 calc(50% - 8px);
}
a {
width: 100%;
justify-content: center;
box-sizing: border-box;
}
}
}
#spacer {
height: 88px;
border-top: 1px solid var(--border);
@media (max-width: 1024px) {
height: 48px;
}
}
.ticks {
position: relative;
width: 100%;
&::before,
&::after {
content: '';
position: absolute;
top: -4.5px;
border: 5px solid transparent;
}
&::before {
left: 0;
border-left-color: var(--border);
}
&::after {
right: 0;
border-right-color: var(--border);
}
}
+147
View File
@@ -0,0 +1,147 @@
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import { AuthProvider, useAuth } from './context/AuthContext';
import { ThemeProvider } from './context/ThemeContext';
import { ToastProvider } from './context/ToastContext';
// Layouts
import PublicLayout from './layouts/PublicLayout';
import DashboardLayout from './layouts/DashboardLayout';
import MarketingLayout from './layouts/MarketingLayout';
// Pages
import Login from './pages/Login';
import Signup from './pages/Signup';
import ForgotPassword from './pages/ForgotPassword';
import ResetPassword from './pages/ResetPassword';
import VerifyEmail from './pages/VerifyEmail';
import ResendVerification from './pages/ResendVerification';
import UserDashboard from './pages/UserDashboard';
import AdminDashboard from './pages/AdminDashboard';
import AdminUserDetail from './pages/AdminUserDetail';
import Profile from './pages/Profile';
import UploadPersonal from './pages/UploadPersonal';
import UploadBusiness from './pages/UploadBusiness';
import Home from './pages/Home';
import AboutUs from './pages/AboutUs';
import Services from './pages/Services';
import Contact from './pages/Contact';
import Chatbot from './components/Chatbot';
import AdminChatbot from './components/AdminChatbot';
const ProtectedRoute = ({ children, adminOnly = false }) => {
const { user, loading } = useAuth();
if (loading) {
return <div style={{display:'flex', alignItems:'center', justifyContent:'center', height:'100vh'}}>Loading...</div>;
}
if (!user) {
return <Navigate to="/login" />;
}
if (adminOnly && user.role !== 'admin' && user.role !== 'super_admin') {
return <Navigate to="/dashboard" />;
}
return children;
};
function AppRoutes() {
return (
<>
<Chatbot />
<AdminChatbot />
<Routes>
{/* Marketing / Static Pages */}
<Route element={<MarketingLayout />}>
<Route path="/" element={<Home />} />
<Route path="/home" element={<Home />} />
<Route path="/about-us" element={<AboutUs />} />
<Route path="/services" element={<Services />} />
<Route path="/contact" element={<Contact />} />
</Route>
{/* Auth Routes */}
<Route element={<PublicLayout />}>
<Route path="/login" element={<Login />} />
<Route path="/signup" element={<Signup />} />
<Route path="/forgot-password" element={<ForgotPassword />} />
<Route path="/reset-password" element={<ResetPassword />} />
<Route path="/verify-email" element={<VerifyEmail />} />
<Route path="/resend-verification" element={<ResendVerification />} />
</Route>
{/* Protected Routes */}
<Route element={<DashboardLayout />}>
<Route
path="/dashboard"
element={
<ProtectedRoute>
<UserDashboard />
</ProtectedRoute>
}
/>
<Route
path="/profile"
element={
<ProtectedRoute>
<Profile />
</ProtectedRoute>
}
/>
<Route
path="/upload-personal"
element={
<ProtectedRoute>
<UploadPersonal />
</ProtectedRoute>
}
/>
<Route
path="/upload-business"
element={
<ProtectedRoute>
<UploadBusiness />
</ProtectedRoute>
}
/>
{/* Admin Routes */}
<Route
path="/admin-dashboard"
element={
<ProtectedRoute adminOnly={true}>
<AdminDashboard />
</ProtectedRoute>
}
/>
<Route
path="/admin-user-detail"
element={
<ProtectedRoute adminOnly={true}>
<AdminUserDetail />
</ProtectedRoute>
}
/>
</Route>
</Routes>
</>
);
}
function App() {
return (
<BrowserRouter>
<ThemeProvider>
<ToastProvider>
<AuthProvider>
<AppRoutes />
</AuthProvider>
</ToastProvider>
</ThemeProvider>
</BrowserRouter>
);
}
export default App;
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.5 KiB

+226
View File
@@ -0,0 +1,226 @@
import { useState, useRef, useEffect } from 'react';
import { useAuth } from '../context/AuthContext';
import { useLocation } from 'react-router-dom';
const FAQ_DATA = {
"Document Review": [
{ q: "How do I review a document?", a: "From the Admin Dashboard, click on any user. You'll see their uploaded documents. Click Approve or Reject and leave a note if needed." },
{ q: "What happens when I reject a document?", a: "The document's status changes to Rejected and the user is notified. They will see your review note and can upload a corrected version to replace it." },
{ q: "How do I upload admin documents for a user?", a: "Go to the user's detail page and scroll down to Admin Documents. You can upload tax returns, reports, and other finalized forms there. These will be visible to the user." }
],
"User Management": [
{ q: "How do I see user details?", a: "Simply click on any user in the Admin Dashboard table. This will take you to their detailed view where you can see their info and all their documents." },
{ q: "Can I add another admin?", a: "Currently, Super Admins can only be created via the backend script `create_super_admin.py` for security reasons." }
],
"Notifications": [
{ q: "How are users notified?", a: "Users receive automated emails when they sign up, when their documents are ready for review, and when you approve or reject their documents." }
]
};
const CATEGORY_ICONS = {
"Document Review": "📑",
"User Management": "👥",
"Notifications": "🔔"
};
const formatMessage = (text) => {
if (!text) return '';
let html = text;
html = html.replace(/\*\*(.*?)\*\*/g, '<b>$1</b>');
html = html.replace(/\*(.*?)\*/g, '<i>$1</i>');
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" target="_blank" rel="noopener noreferrer" style="color: var(--blue); text-decoration: underline;">$1</a>');
html = html.replace(/\n/g, '<br/>');
return html;
};
export default function AdminChatbot() {
const { user, authFetch } = useAuth();
const location = useLocation();
const [isOpen, setIsOpen] = useState(false);
const [messages, setMessages] = useState([]);
const [view, setView] = useState('menu');
const [activeCategory, setActiveCategory] = useState(null);
const [inputText, setInputText] = useState("");
const [isTyping, setIsTyping] = useState(false);
const chatEndRef = useRef(null);
// Close chatbot when navigating
useEffect(() => {
setIsOpen(false);
}, [location.pathname]);
useEffect(() => {
if (chatEndRef.current) {
chatEndRef.current.scrollIntoView({ behavior: 'smooth' });
}
}, [messages, view]);
const toggleChat = () => setIsOpen(!isOpen);
const handleAdminStatusCheck = async () => {
setMessages([...messages, { type: 'user', text: 'Give me a system overview.' }]);
setView('chat');
try {
const res = await authFetch('/api/chatbot/admin-status');
if (res.ok) {
const data = await res.json();
setMessages(prev => [...prev, { type: 'bot', text: data.message }]);
} else {
setMessages(prev => [...prev, { type: 'bot', text: 'Sorry, I could not fetch the system status right now.' }]);
}
} catch (err) {
setMessages(prev => [...prev, { type: 'bot', text: 'Network error occurred.' }]);
}
};
const selectCategory = (cat) => {
setActiveCategory(cat);
setView('category');
};
const askFaq = (faq) => {
setMessages(prev => [...prev, { type: 'user', text: faq.q }, { type: 'bot', text: faq.a }]);
setView('chat');
};
const resetToMenu = () => {
setView('menu');
};
const handleSendMessage = async (e) => {
e.preventDefault();
if (!inputText.trim()) return;
const userMessage = { type: 'user', role: 'user', text: inputText.trim() };
const currentMessages = [...messages, userMessage];
setMessages(currentMessages);
setInputText("");
setView('chat');
setIsTyping(true);
try {
// Convert messages to format expected by backend
const backendMessages = currentMessages.map(m => ({
role: m.role || (m.type === 'bot' ? 'assistant' : 'user'),
content: m.text,
reasoning_details: m.reasoning_details || null
}));
const res = await authFetch('/api/chatbot/ask', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ messages: backendMessages })
});
if (res.ok) {
const data = await res.json();
const contentText = data.content || "Sorry, I couldn't understand that.";
const reasoning = data.reasoning_details;
setMessages(prev => [...prev, { type: 'bot', role: 'assistant', text: contentText, reasoning_details: reasoning }]);
} else {
setMessages(prev => [...prev, { type: 'bot', role: 'assistant', text: 'Sorry, I am having trouble connecting to the server.' }]);
}
} catch (err) {
setMessages(prev => [...prev, { type: 'bot', role: 'assistant', text: 'Network error occurred. Please try again.' }]);
} finally {
setIsTyping(false);
}
};
if (!user || (user.role !== 'admin' && user.role !== 'super_admin') || !location.pathname.startsWith('/admin')) {
return null;
}
return (
<>
<button className={`chatbot-fab ${isOpen ? 'open' : ''}`} onClick={toggleChat} aria-label="Open admin assistant" style={{background: 'linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%)'}}>
<span className="fab-icon">🤖</span>
<span className="notif-dot"></span>
</button>
{isOpen && (
<div className="chatbot-window visible">
<div className="chatbot-header" style={{background: 'linear-gradient(135deg, var(--navy) 0%, #005fa3 100%)'}}>
<div className="bot-avatar">🤖</div>
<div className="bot-info">
<h4>Admin Assistant</h4>
<span>System Insights & Help</span>
</div>
<button className="close-chat" onClick={toggleChat}>✕</button>
</div>
<div className="chatbot-messages">
{view === 'menu' && (
<>
<div className="chatbot-welcome-text">
<span className="material-symbols-outlined sparkle">auto_awesome</span>
<p>How can we help you today?</p>
</div>
<button className="quick-reply-btn" style={{display: 'flex', width: '100%', marginBottom: '8px'}} onClick={handleAdminStatusCheck}>
<span className="qr-icon">📊</span>
Check System Status
</button>
{Object.keys(FAQ_DATA).map(cat => (
<button key={cat} className="quick-reply-btn" style={{display: 'flex', width: '100%', marginBottom: '8px'}} onClick={() => selectCategory(cat)}>
<span className="qr-icon">{CATEGORY_ICONS[cat]}</span> {cat} FAQ
</button>
))}
</>
)}
{view === 'category' && (
<>
<button className="quick-reply-btn" style={{display: 'flex', width: '100%', marginBottom: '16px', background: 'transparent', border: 'none'}} onClick={resetToMenu}>← Back to menu</button>
<h4 style={{margin:'0 0 12px', fontSize:'14px', color:'var(--navy)'}}>{activeCategory} Questions</h4>
{FAQ_DATA[activeCategory].map((faq, i) => (
<button key={i} className="quick-reply-btn" style={{display: 'flex', width: '100%', marginBottom: '8px'}} onClick={() => askFaq(faq)}>
{faq.q}
</button>
))}
</>
)}
{view === 'chat' && (
<>
<button className="quick-reply-btn" onClick={resetToMenu} style={{display: 'flex', width: '100%', marginBottom: '16px', background: 'transparent', border: 'none'}}>
← Back to menu
</button>
{messages.map((msg, i) => (
<div key={i} className={`chat-msg ${msg.type === 'bot' ? 'bot' : 'user'}`}
{...(msg.type === 'bot' ? { dangerouslySetInnerHTML: { __html: formatMessage(msg.text) } } : { children: msg.text })}
/>
))}
{isTyping && (
<div className="chat-msg bot" style={{ fontStyle: 'italic', opacity: 0.7 }}>
Admin Assistant is typing...
</div>
)}
<div ref={chatEndRef} />
</>
)}
</div>
<div className="chatbot-footer" style={{ padding: '12px', borderTop: '1px solid var(--border)', background: 'var(--bg)' }}>
{view === 'chat' ? (
<form onSubmit={handleSendMessage} style={{ display: 'flex', gap: '8px' }}>
<input
type="text"
value={inputText}
onChange={(e) => setInputText(e.target.value)}
placeholder="Ask a question..."
style={{ flex: 1, padding: '8px 12px', borderRadius: 'var(--radius-pill)', border: '1px solid var(--border)', background: 'var(--card)', color: 'var(--navy)' }}
/>
<button type="submit" style={{ background: 'var(--blue)', color: '#fff', border: 'none', borderRadius: 'var(--radius-pill)', padding: '8px 16px', cursor: 'pointer' }}>
Send
</button>
</form>
) : (
<p style={{ margin: 0 }}>Admin tools & shortcuts</p>
)}
</div>
</div>
)}
</>
);
}
+242
View File
@@ -0,0 +1,242 @@
import { useState, useRef, useEffect } from 'react';
import { useAuth } from '../context/AuthContext';
import { useLocation } from 'react-router-dom';
const FAQ_DATA = {
// ... (keep the same FAQ_DATA below this)
"Account": [
{ q: "How do I reset my password?", a: 'Go to the login page and click "Forgot Password". Enter your email and we\'ll send a reset link to your inbox.' },
{ q: "How do I verify my email?", a: 'Check your inbox for a verification email from BookKeepPro. Click the link inside to verify.' },
{ q: "How do I update my profile?", a: 'Go to your Profile page to update your name, phone number, or change your password.' },
],
"Documents": [
{ q: "What file types are accepted?", a: "We accept PDF, JPG, PNG, WEBP, DOC, and DOCX files. The maximum file size is 10 MB." },
{ q: 'What does "Pending" status mean?', a: 'Your document has been uploaded successfully and is waiting for an admin to review it.' },
{ q: 'What does "Rejected" mean?', a: "The admin found an issue with your document. Check the review note for details." },
],
"Tax Filing": [
{ q: "What tax years are supported?", a: "We currently support tax years 2023, 2024, 2025, and 2026." },
{ q: "What personal documents do I need?", a: 'An Individual Taxpayer Organizer for your tax year.' },
],
"Security": [
{ q: "Is my data secure?", a: "Absolutely. All files are stored securely on our servers with encrypted access tokens." },
]
};
const CATEGORY_ICONS = {
"Account": "👤",
"Documents": "📄",
"Tax Filing": "📋",
"Security": "🔒"
};
const formatMessage = (text) => {
if (!text) return '';
let html = text;
html = html.replace(/\*\*(.*?)\*\*/g, '<b>$1</b>');
html = html.replace(/\*(.*?)\*/g, '<i>$1</i>');
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" target="_blank" rel="noopener noreferrer" style="color: var(--blue); text-decoration: underline;">$1</a>');
html = html.replace(/\n/g, '<br/>');
return html;
};
export default function Chatbot() {
const { user, authFetch } = useAuth();
const location = useLocation();
const [isOpen, setIsOpen] = useState(false);
const [messages, setMessages] = useState([]);
const [view, setView] = useState('menu'); // menu, category, chat
const [activeCategory, setActiveCategory] = useState(null);
const [inputText, setInputText] = useState("");
const [isTyping, setIsTyping] = useState(false);
const chatEndRef = useRef(null);
// Close chatbot when navigating
useEffect(() => {
setIsOpen(false);
}, [location.pathname]);
useEffect(() => {
if (chatEndRef.current) {
chatEndRef.current.scrollIntoView({ behavior: 'smooth' });
}
}, [messages, view]);
const toggleChat = () => setIsOpen(!isOpen);
const handleDocStatusCheck = async () => {
if (!user) {
setMessages([...messages, { type: 'bot', text: 'You need to log in to check your document status.' }]);
setView('chat');
return;
}
setMessages([...messages, { type: 'user', text: 'Check my document status' }]);
setView('chat');
try {
const res = await authFetch('/api/chatbot/doc-status');
if (res.ok) {
const data = await res.json();
setMessages(prev => [...prev, { type: 'bot', text: data.message }]);
} else {
setMessages(prev => [...prev, { type: 'bot', text: 'Sorry, I could not fetch your document status right now.' }]);
}
} catch (err) {
setMessages(prev => [...prev, { type: 'bot', text: 'Network error occurred.' }]);
}
};
const selectCategory = (cat) => {
setActiveCategory(cat);
setView('category');
};
const askFaq = (faq) => {
setMessages(prev => [...prev, { type: 'user', text: faq.q }, { type: 'bot', text: faq.a }]);
setView('chat');
};
const resetToMenu = () => {
setView('menu');
};
const handleSendMessage = async (e) => {
e.preventDefault();
if (!inputText.trim()) return;
const userMessage = { type: 'user', role: 'user', text: inputText.trim() };
const currentMessages = [...messages, userMessage];
setMessages(currentMessages);
setInputText("");
setView('chat');
setIsTyping(true);
try {
// Convert messages to format expected by backend
const backendMessages = currentMessages.map(m => ({
role: m.role || (m.type === 'bot' ? 'assistant' : 'user'),
content: m.text,
reasoning_details: m.reasoning_details || null
}));
const res = await authFetch('/api/chatbot/ask', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ messages: backendMessages })
});
if (res.ok) {
const data = await res.json();
// Extract content and optional reasoning details
const contentText = data.content || "Sorry, I couldn't understand that.";
const reasoning = data.reasoning_details;
setMessages(prev => [...prev, { type: 'bot', role: 'assistant', text: contentText, reasoning_details: reasoning }]);
} else {
setMessages(prev => [...prev, { type: 'bot', role: 'assistant', text: 'Sorry, I am having trouble connecting to the server.' }]);
}
} catch (err) {
setMessages(prev => [...prev, { type: 'bot', role: 'assistant', text: 'Network error occurred. Please try again.' }]);
} finally {
setIsTyping(false);
}
};
if (!user || user.role === 'admin' || user.role === 'super_admin' || location.pathname.startsWith('/admin')) {
return null; // Admin has a different dashboard, and logged out users shouldn't see it
}
return (
<>
<button className={`chatbot-fab ${isOpen ? 'open' : ''}`} onClick={toggleChat} aria-label="Open chat assistant">
<span className="fab-icon">💬</span>
<span className="notif-dot"></span>
</button>
{isOpen && (
<div className="chatbot-window visible">
<div className="chatbot-header">
<div className="bot-avatar">🤖</div>
<div className="bot-info">
<h4>BookKeep Assistant</h4>
<span>Online and ready to help</span>
</div>
<button className="close-chat" onClick={toggleChat}>✕</button>
</div>
<div className="chatbot-messages">
{view === 'menu' && (
<>
<div className="chatbot-welcome-text">
<span className="material-symbols-outlined sparkle">auto_awesome</span>
<p>How can we help you today?</p>
</div>
{user && (
<button className="quick-reply-btn" style={{display: 'flex', width: '100%', marginBottom: '8px'}} onClick={handleDocStatusCheck}>
<span className="qr-icon">📋</span>
Check Document Status
</button>
)}
{Object.keys(FAQ_DATA).map(cat => (
<button key={cat} className="quick-reply-btn" style={{display: 'flex', width: '100%', marginBottom: '8px'}} onClick={() => selectCategory(cat)}>
<span className="qr-icon">{CATEGORY_ICONS[cat]}</span> {cat} FAQ
</button>
))}
</>
)}
{view === 'category' && (
<>
<button className="quick-reply-btn" style={{display: 'flex', width: '100%', marginBottom: '16px', background: 'transparent', border: 'none'}} onClick={resetToMenu}>← Back to menu</button>
<h4 style={{margin:'0 0 12px', fontSize:'14px', color:'var(--navy)'}}>{activeCategory} Questions</h4>
{FAQ_DATA[activeCategory].map((faq, i) => (
<button key={i} className="quick-reply-btn" style={{display: 'flex', width: '100%', marginBottom: '8px'}} onClick={() => askFaq(faq)}>
{faq.q}
</button>
))}
</>
)}
{view === 'chat' && (
<>
<button className="quick-reply-btn" onClick={resetToMenu} style={{display: 'flex', width: '100%', marginBottom: '16px', background: 'transparent', border: 'none'}}>
← Back to menu
</button>
{messages.map((msg, i) => (
<div key={i} className={`chat-msg ${msg.type === 'bot' ? 'bot' : 'user'}`}
{...(msg.type === 'bot' ? { dangerouslySetInnerHTML: { __html: formatMessage(msg.text) } } : { children: msg.text })}
/>
))}
{isTyping && (
<div className="chat-msg bot" style={{ fontStyle: 'italic', opacity: 0.7 }}>
BookKeep Assistant is typing...
</div>
)}
<div ref={chatEndRef} />
</>
)}
</div>
<div className="chatbot-footer" style={{ padding: '12px', borderTop: '1px solid var(--border)', background: 'var(--bg)' }}>
{view === 'chat' ? (
<form onSubmit={handleSendMessage} style={{ display: 'flex', gap: '8px' }}>
<input
type="text"
value={inputText}
onChange={(e) => setInputText(e.target.value)}
placeholder="Ask a question..."
style={{ flex: 1, padding: '8px 12px', borderRadius: 'var(--radius-pill)', border: '1px solid var(--border)', background: 'var(--card)', color: 'var(--navy)' }}
/>
<button type="submit" style={{ background: 'var(--navy)', color: '#fff', border: 'none', borderRadius: 'var(--radius-pill)', padding: '8px 16px', cursor: 'pointer' }}>
Send
</button>
</form>
) : (
<p style={{ margin: 0 }}>Need more help? <a href="/contact">Contact Support</a></p>
)}
</div>
</div>
)}
</>
);
}
+34
View File
@@ -0,0 +1,34 @@
import { Link } from 'react-router-dom';
export default function Footer() {
return (
<footer className="footer">
<div className="footer-top">
<div className="footer-left">
<img src="/images/bookkeeppro-logo.webp" className="footer-logo" alt="Bookkeepro" />
<p>Your Globally Trusted Bookkeeping Partner.</p>
</div>
<div className="footer-links">
<h4>Quick Links</h4>
<Link to="/">Home</Link>
<Link to="/about-us">About Us</Link>
<Link to="/services">Services</Link>
<Link to="/contact">Contact Us</Link>
</div>
<div className="footer-contact">
<h4>Contact</h4>
<p>📍 USA: McKinney, TX</p>
<p>📍 India: Pune, Maharashtra</p>
<p>📧 vedant.aiindia@gmail.com</p>
<p>📞 +918275367267</p>
</div>
</div>
<div className="footer-bottom">
<p>© 2026 Bookkeeping Business Solutions. All rights reserved.</p>
</div>
</footer>
);
}
+49
View File
@@ -0,0 +1,49 @@
import { Link, useNavigate } from 'react-router-dom';
import { useState, useEffect } from 'react';
import { useTheme } from '../context/ThemeContext';
export default function Navbar({ transparent = false }) {
const [isOpen, setIsOpen] = useState(false);
const navigate = useNavigate();
const { theme, toggleTheme } = useTheme();
return (
<div className={`navbar ${transparent ? 'navbar-transparent' : ''}`}>
<div className="nav-container">
<Link to="/">
<img id="logos" src="/images/bookkeeppro-logo.webp" alt="Bookkeeping Logo" />
</Link>
<nav id="navMenu" className={`nav-menu ${isOpen ? 'active' : ''}`}>
<Link to="/">Home</Link>
<Link to="/about-us">About Us</Link>
<Link to="/services">Services</Link>
<Link to="/contact">Contact Us</Link>
<button
className="theme-toggle"
onClick={toggleTheme}
style={{background:'none', border:'none', color:'inherit', cursor:'pointer', display:'flex', alignItems:'center', justifyContent:'center', padding:'8px'}}
aria-label="Toggle Theme"
>
<span className="material-symbols-outlined theme-toggle-icon" style={{fontSize: '24px'}}>
{theme === 'dark' ? 'light_mode' : 'dark_mode'}
</span>
</button>
<button className="login-btn desktop-login" onClick={() => navigate('/login')}>
Sign in
</button>
<button className="login-btn mobile-login" onClick={() => navigate('/login')}>
Sign in
</button>
</nav>
<div className="hamburger" onClick={() => setIsOpen(!isOpen)}>
<span></span><span></span><span></span>
</div>
</div>
</div>
);
}
+73
View File
@@ -0,0 +1,73 @@
import { createContext, useContext, useState, useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
const AuthContext = createContext();
export function AuthProvider({ children }) {
const [token, setToken] = useState(localStorage.getItem('token'));
const [user, setUser] = useState(null);
const [loading, setLoading] = useState(true);
const navigate = useNavigate();
useEffect(() => {
if (token) {
localStorage.setItem('token', token);
fetchUser();
} else {
localStorage.removeItem('token');
setUser(null);
setLoading(false);
}
}, [token]);
const fetchUser = async () => {
try {
const res = await fetch('/api/auth/me', {
headers: {
'Authorization': `Bearer ${token}`
}
});
if (res.ok) {
const data = await res.json();
setUser(data);
} else {
setToken(null);
}
} catch (err) {
console.error("Auth error:", err);
setToken(null);
} finally {
setLoading(false);
}
};
const login = (newToken) => {
setLoading(true);
setToken(newToken);
};
const logout = () => {
setToken(null);
navigate('/login');
};
const authFetch = async (url, options = {}) => {
if (!options.headers) options.headers = {};
if (token) {
options.headers['Authorization'] = `Bearer ${token}`;
}
const res = await fetch(url, options);
if (res.status === 401) {
logout();
}
return res;
};
return (
<AuthContext.Provider value={{ token, user, login, logout, authFetch, loading }}>
{children}
</AuthContext.Provider>
);
}
export const useAuth = () => useContext(AuthContext);
+33
View File
@@ -0,0 +1,33 @@
import { createContext, useContext, useState, useEffect } from 'react';
const ThemeContext = createContext();
export function ThemeProvider({ children }) {
const [theme, setTheme] = useState(() => {
return localStorage.getItem('theme') || 'light';
});
useEffect(() => {
if (theme === 'dark') {
document.documentElement.classList.add('dark-theme');
document.body.classList.add('dark-theme');
localStorage.setItem('theme', 'dark');
} else {
document.documentElement.classList.remove('dark-theme');
document.body.classList.remove('dark-theme');
localStorage.setItem('theme', 'light');
}
}, [theme]);
const toggleTheme = () => {
setTheme(prev => prev === 'dark' ? 'light' : 'dark');
};
return (
<ThemeContext.Provider value={{ theme, toggleTheme }}>
{children}
</ThemeContext.Provider>
);
}
export const useTheme = () => useContext(ThemeContext);
+40
View File
@@ -0,0 +1,40 @@
import { createContext, useContext, useState, useCallback } from 'react';
const ToastContext = createContext();
export function ToastProvider({ children }) {
const [toasts, setToasts] = useState([]);
const addToast = useCallback((message, type = 'info', duration = 3000) => {
const id = Date.now();
setToasts(prev => [...prev, { id, message, type }]);
if (duration > 0) {
setTimeout(() => {
setToasts(prev => prev.filter(t => t.id !== id));
}, duration);
}
}, []);
const removeToast = useCallback((id) => {
setToasts(prev => prev.filter(t => t.id !== id));
}, []);
return (
<ToastContext.Provider value={{ addToast }}>
{children}
<div className="toast-container">
{toasts.map(toast => (
<div key={toast.id} className={`toast toast-${toast.type} slide-up`}>
<div className="toast-message">{toast.message}</div>
<button className="toast-close" onClick={() => removeToast(toast.id)}>
<span className="material-symbols-outlined">close</span>
</button>
</div>
))}
</div>
</ToastContext.Provider>
);
}
export const useToast = () => useContext(ToastContext);
File diff suppressed because it is too large Load Diff
+42
View File
@@ -0,0 +1,42 @@
import { Outlet, Link, useNavigate } from 'react-router-dom';
import { useAuth } from '../context/AuthContext';
import { useTheme } from '../context/ThemeContext';
export default function DashboardLayout() {
const { user, logout } = useAuth();
const navigate = useNavigate();
const { theme, toggleTheme } = useTheme();
return (
<div className="app-body">
<header className="app-header">
<Link to="/dashboard">
<img className="logo" src="/images/bookkeeppro-logo.webp" alt="BookKeepPro" />
</Link>
<div className="header-actions">
<button
className="theme-toggle"
onClick={toggleTheme}
style={{background:'none', border:'none', color:'inherit', cursor:'pointer', display:'flex', alignItems:'center', justifyContent:'center', padding:'8px'}}
aria-label="Toggle Theme"
>
<span className="material-symbols-outlined theme-toggle-icon" style={{fontSize: '24px'}}>
{theme === 'dark' ? 'light_mode' : 'dark_mode'}
</span>
</button>
<button className="btn btn-secondary btn-sm" onClick={() => navigate('/profile')}>
My Profile
</button>
<button className="btn btn-primary btn-sm" onClick={logout}>
Logout
</button>
</div>
</header>
<main className="page-main page-enter">
<Outlet />
</main>
</div>
);
}
+13
View File
@@ -0,0 +1,13 @@
import { Outlet } from 'react-router-dom';
import Navbar from '../components/Navbar';
import Footer from '../components/Footer';
export default function MarketingLayout() {
return (
<>
<Navbar />
<Outlet />
<Footer />
</>
);
}
+2
View File
@@ -0,0 +1,2 @@
import { Outlet } from 'react-router-dom';
export default function PublicLayout() { return <Outlet />; }
+10
View File
@@ -0,0 +1,10 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.jsx'
createRoot(document.getElementById('root')).render(
<StrictMode>
<App />
</StrictMode>,
)
+78
View File
@@ -0,0 +1,78 @@
export default function AboutUs() {
return (
<>
{/* HERO */}
<div className="page-hero" style={{
backgroundImage: 'linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.6)), url("/images/About-us-background-image.webp")',
backgroundSize: 'cover',
backgroundPosition: 'center',
minHeight: '400px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
textAlign: 'center',
color: '#fff'
}}>
<div>
<h1>About Us</h1>
<p>Our People Are Passionate About What We Do</p>
</div>
</div>
{/* CONTENT */}
<div className="about-wrapper">
<div className="about-block">
<div className="about-text">
<h2>Who We Are</h2>
<p>
Our journey began in 1998 as a Chartered Accountant firm in India,
built on strong fundamentals of accounting, compliance, integrity,
and long-term client relationships.
</p>
<br />
<p>
In 2018, we strengthened our presence in Pune & Mumbai — transitioning
from a traditional CA practice into a scalable financial services
organization.
</p>
</div>
<img className="about-img" src="/images/about-us-block-1.webp" alt="Bookkeepro Team" style={{ objectFit: 'cover' }} />
</div>
<div className="about-block reverse">
<div className="about-text">
<h2>About Bookkeepro</h2>
<p>
As our client base expanded globally — especially across the US — we aligned
our operating model to support international growth.
</p>
<br />
<p>
In 2023, we launched:<br /><br />
<b>• Bookkeeping Business Solutions Pvt Ltd (India)</b><br />
<b>• Bookkeeping Business Solutions LLC (USA)</b>
</p>
<br />
<p>
Today, Bookkeepro serves global businesses, startups & enterprises with
scalable, compliant bookkeeping and financial operations support.
</p>
</div>
<img className="about-img" src="/images/young-business-people-using-computer-in-office.jpg" alt="About Bookkeepro" style={{ objectFit: 'cover' }} />
</div>
</div>
<div className="about-block" style={{ width: 'min(1200px, 92%)', margin: 'auto', marginBottom: '80px', padding: '40px', justifyContent: 'center', textAlign: 'center', flexWrap: 'wrap' }}>
<div className="about-text" style={{ flex: '1 1 100%' }}>
<h2 style={{ marginBottom: '24px' }}>Who We Are Today</h2>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '20px', justifyContent: 'center' }}>
<p style={{ background: 'var(--blue-light)', color: 'var(--navy)', padding: '12px 24px', borderRadius: '30px', fontWeight: '500' }}>✔️ 25+ years of accounting & compliance expertise</p>
<p style={{ background: 'var(--blue-light)', color: 'var(--navy)', padding: '12px 24px', borderRadius: '30px', fontWeight: '500' }}>✔️ Operations across India & USA</p>
<p style={{ background: 'var(--blue-light)', color: 'var(--navy)', padding: '12px 24px', borderRadius: '30px', fontWeight: '500' }}>✔️ Secure, process-driven financial workflows</p>
<p style={{ background: 'var(--blue-light)', color: 'var(--navy)', padding: '12px 24px', borderRadius: '30px', fontWeight: '500' }}>✔️ Strong confidentiality & data protection practices</p>
</div>
</div>
</div>
</>
);
}
+277
View File
@@ -0,0 +1,277 @@
import { useState, useEffect } from 'react';
import { useAuth } from '../context/AuthContext';
import { useNavigate } from 'react-router-dom';
export default function AdminDashboard() {
const { user, authFetch } = useAuth();
const [stats, setStats] = useState({ total_users: 0, pending_docs: 0, admins: 0 });
const [users, setUsers] = useState([]);
const [search, setSearch] = useState("");
const [tab, setTab] = useState("users");
const [loading, setLoading] = useState(true);
const navigate = useNavigate();
// --- Template Management State ---
const [tplCategory, setTplCategory] = useState("personal");
const [tplYear, setTplYear] = useState(new Date().getFullYear().toString());
const [templates, setTemplates] = useState([]);
const [tplName, setTplName] = useState("");
const [tplFile, setTplFile] = useState(null);
const [tplLoading, setTplLoading] = useState(false);
useEffect(() => {
fetchAdminData();
}, [authFetch]);
useEffect(() => {
if (tab === "templates") {
loadTemplates();
}
}, [tab, tplCategory, tplYear]);
const fetchAdminData = async () => {
setLoading(true);
try {
const res = await authFetch("/api/auth/admin/users");
if (res.ok) {
const payload = await res.json();
const usersArray = Array.isArray(payload) ? payload : (payload.users || []);
setUsers(usersArray);
// Compute stats locally like legacy frontend
const total = usersArray.length;
const pending = usersArray.reduce((s, u) => s + (u.pending_docs || 0), 0);
const admins = usersArray.filter(u => u.role === "admin" || u.role === "super_admin").length;
setStats({ total_users: total, pending_docs: pending, admins: admins });
}
} catch (err) {
console.error(err);
} finally {
setLoading(false);
}
};
const loadTemplates = async () => {
setTplLoading(true);
try {
const res = await authFetch(`/api/upload/templates?category=${tplCategory}&tax_year=${tplYear}`);
if (res.ok) {
setTemplates(await res.json());
} else {
setTemplates([]);
}
} catch (err) {
console.error("Failed to load templates", err);
setTemplates([]);
} finally {
setTplLoading(false);
}
};
const handleTplUpload = async (e) => {
e.preventDefault();
if (!tplFile || !tplName) return;
const fd = new FormData();
fd.append("category", tplCategory);
fd.append("tax_year", tplYear);
fd.append("name", tplName);
fd.append("file", tplFile);
try {
const res = await authFetch("/api/upload/admin/templates", {
method: "POST",
body: fd
});
if (res.ok) {
setTplName("");
setTplFile(null);
document.getElementById("tplFile").value = "";
loadTemplates();
} else {
const err = await res.json();
alert(err.detail || "Upload failed");
}
} catch (err) {
console.error("Upload error", err);
}
};
const deleteTemplate = async (id) => {
if (!window.confirm("Are you sure you want to delete this template?")) return;
try {
const res = await authFetch(`/api/upload/admin/templates/${id}`, { method: "DELETE" });
if (res.ok) {
loadTemplates();
} else {
alert("Failed to delete template");
}
} catch (err) {
console.error("Delete error", err);
}
};
const currentYear = new Date().getFullYear();
const yearOptions = [currentYear - 1, currentYear, currentYear + 1];
const filteredUsers = users.filter(u => {
if (!search) return true;
const q = search.toLowerCase();
return (u.name?.toLowerCase().includes(q) || u.email?.toLowerCase().includes(q));
});
return (
<div className="page-main-wide page-enter">
<div className="flex-between align-center" style={{ marginBottom: '24px', flexWrap: 'wrap', gap: '16px' }}>
<h1 style={{ margin: 0, fontSize: '28px', color: 'var(--navy)' }}>
Users <span style={{ color: 'var(--muted)', fontWeight: 400 }}>{tab === 'templates' ? 'Templates' : ''}</span>
</h1>
{tab === 'users' && (
<div className="search-wrap" style={{ width: '100%', maxWidth: '300px' }}>
<span className="material-symbols-outlined search-icon" style={{position: 'absolute', left: '12px', top: '50%', transform: 'translateY(-50%)', color: 'var(--muted)', fontSize: '20px'}}>search</span>
<input
type="text"
className="search-input"
style={{ width: '100%', padding: '10px 12px 10px 40px', border: '1px solid var(--border)', borderRadius: 'var(--radius-full)', outline: 'none' }}
placeholder="Search by name or email"
value={search}
onChange={(e) => setSearch(e.target.value)}
/>
</div>
)}
</div>
<div className="tab-bar">
<button className={`tab-btn ${tab === 'users' ? 'active' : ''}`} onClick={() => setTab('users')}>
<span className="material-symbols-outlined">group</span> Users Overview
</button>
<button className={`tab-btn ${tab === 'templates' ? 'active' : ''}`} onClick={() => setTab('templates')}>
<span className="material-symbols-outlined">description</span> Templates
</button>
</div>
{/* Users Tab */}
{tab === 'users' && (
<>
{/* Stats Bar */}
<div className="admin-stats">
<div className="stat-card accent-blue">
<div className="stat-icon"><span className="material-symbols-outlined">group</span></div>
<div className="stat-value">{stats.total_users}</div>
<div className="stat-label">Total Users</div>
</div>
<div className="stat-card">
<div className="stat-icon"><span className="material-symbols-outlined">security</span></div>
<div className="stat-value">{stats.admins}</div>
<div className="stat-label">Admin Accounts</div>
</div>
<div className="stat-card accent-orange">
<div className="stat-icon"><span className="material-symbols-outlined">pending</span></div>
<div className="stat-value">{stats.pending_docs}</div>
<div className="stat-label">Pending Docs</div>
</div>
</div>
{/* User Grid */}
<div className="users-grid">
{loading ? (
<div className="empty-state" style={{ gridColumn: '1/-1' }}>
<div className="empty-icon"><span className="material-symbols-outlined">pending</span></div>
<div className="empty-title">Loading users...</div>
</div>
) : filteredUsers.length === 0 ? (
<div className="empty-state" style={{ gridColumn: '1/-1' }}>
<div className="empty-title">No users found</div>
</div>
) : (
filteredUsers.map(u => (
<div key={u.id} className="user-card stagger fade-up" onClick={() => navigate(`/admin-user-detail?user_id=${u.id}`)}>
<div className="user-top">
<div className="user-avatar">{(u.name || "U").charAt(0).toUpperCase()}</div>
<div className="user-info">
<div className="u-name">{u.name || "—"}</div>
<div className="u-email">{u.email || "—"}</div>
</div>
</div>
<div className="user-bottom">
<span className={`badge role-badge ${u.role === 'super_admin' ? 'badge-red' : u.role === 'admin' ? 'badge-orange' : 'badge-blue'}`}>
{u.role}
</span>
{u.pending_docs > 0 && (
<span className="badge badge-orange pulse" style={{ cursor: 'default' }}>{u.pending_docs} pending</span>
)}
</div>
<div className="click-layer"></div>
</div>
))
)}
</div>
</>
)}
{/* Templates Tab */}
{tab === 'templates' && (
<div className="card" style={{ marginTop: '20px' }}>
<h3>Manage Required Templates</h3>
<p className="text-sm" style={{ color: 'var(--muted)', marginBottom: '20px' }}>Upload new templates for users to download.</p>
<div style={{ display: 'flex', gap: '12px', flexWrap: 'wrap', marginBottom: '20px' }}>
<select className="select-input" style={{ width: 'auto' }} value={tplCategory} onChange={(e) => setTplCategory(e.target.value)}>
<option value="personal">Personal</option>
<option value="business">Business</option>
</select>
<select className="select-input" style={{ width: 'auto' }} value={tplYear} onChange={(e) => setTplYear(e.target.value)}>
{yearOptions.map(y => <option key={y} value={y}>{y}</option>)}
</select>
</div>
<div style={{ marginTop: '20px', minHeight: '150px' }}>
{tplLoading ? (
<div className="text-muted">Loading templates...</div>
) : templates.length === 0 ? (
<p className="text-muted">No templates found for {tplCategory} {tplYear}.</p>
) : (
templates.map(t => (
<div key={t.id} className="card-flat" style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '8px' }}>
<div>
<h5 style={{ marginBottom: '4px' }}>{t.name}</h5>
{t.download ? (
<a href={t.download} target="_blank" rel="noreferrer" className="text-sm" style={{ color: 'var(--blue)' }}>View File</a>
) : (
<span className="text-sm text-muted">No file</span>
)}
</div>
<button className="btn btn-danger btn-sm" onClick={() => deleteTemplate(t.id)}>Delete</button>
</div>
))
)}
</div>
<hr style={{ margin: '24px 0', borderTop: '1px solid var(--border)' }} />
<h4 style={{ marginBottom: '12px' }}>Upload New Template</h4>
<form onSubmit={handleTplUpload} style={{ display: 'flex', flexDirection: 'column', gap: '12px', maxWidth: '400px' }}>
<input
type="text"
className="input"
placeholder="Template Name (e.g. Individual Tax Organizer)"
value={tplName}
onChange={(e) => setTplName(e.target.value)}
required
/>
<input
type="file"
id="tplFile"
className="input"
accept=".pdf,.doc,.docx"
onChange={(e) => setTplFile(e.target.files[0])}
/>
<button type="submit" className="btn btn-primary" style={{borderRadius: 'var(--radius-sm)'}}>Upload Template</button>
</form>
</div>
)}
</div>
);
}
+484
View File
@@ -0,0 +1,484 @@
import { useState, useEffect, useRef } from 'react';
import { useSearchParams, useNavigate } from 'react-router-dom';
import { useAuth } from '../context/AuthContext';
import { useToast } from '../context/ToastContext';
export default function AdminUserDetail() {
const [searchParams] = useSearchParams();
const userId = searchParams.get('user_id');
const navigate = useNavigate();
const { authFetch, user: currentUser } = useAuth();
const { showToast } = useToast();
const [userDetail, setUserDetail] = useState(null);
const [documents, setDocuments] = useState([]);
const [activeTab, setActiveTab] = useState('personal');
const [taxYear, setTaxYear] = useState(new Date().getFullYear().toString());
const [loading, setLoading] = useState(true);
// States for Review Emails
const [personalTimeline, setPersonalTimeline] = useState(0);
const [businessTimeline, setBusinessTimeline] = useState(0);
// States for Audit Log
const [auditLog, setAuditLog] = useState([]);
const [auditLoaded, setAuditLoaded] = useState(false);
const adminDocInputRef = useRef(null);
useEffect(() => {
if (!userId) {
navigate('/admin-dashboard');
return;
}
fetchUserDetails();
}, [userId, taxYear]);
const fetchUserDetails = async () => {
setLoading(true);
try {
const url = taxYear ? `/api/upload/admin/users/${userId}/documents?tax_year=${taxYear}` : `/api/upload/admin/users/${userId}/documents`;
const res = await authFetch(url);
if (!res.ok) {
if (res.status === 403) navigate('/admin-dashboard');
return;
}
const payload = await res.json();
setUserDetail(payload.user);
setDocuments(payload.documents || []);
} catch (err) {
console.error(err);
} finally {
setLoading(false);
}
};
const loadAuditLog = async () => {
try {
const res = await authFetch(`/api/auth/admin/audit-logs?user_id=${userId}&limit=30`);
if (res.ok) {
setAuditLog(await res.json());
setAuditLoaded(true);
}
} catch (err) {
console.error(err);
}
};
useEffect(() => {
if (activeTab === 'audit' && !auditLoaded) {
loadAuditLog();
}
}, [activeTab]);
const deleteUser = async () => {
if (!window.confirm("WARNING: This will permanently delete this user, all their documents, and their audit history. Are you sure?")) return;
try {
const res = await authFetch(`/api/upload/admin/users/${userId}`, { method: "DELETE" });
if (res.ok) {
navigate('/admin-dashboard');
} else {
alert("Failed to delete user");
}
} catch (err) {
console.error("Error deleting user", err);
}
};
const handleChangeRole = async (newRole) => {
if (!window.confirm(`Change user role to ${newRole}?`)) return;
try {
const res = await authFetch(`/api/auth/admin/users/${userId}/role`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ role: newRole })
});
if (res.ok) {
showToast("Role updated successfully", "success");
fetchUserDetails();
} else {
const data = await res.json();
showToast(data.detail || "Failed to change role", "error");
}
} catch (err) {
showToast("Network error", "error");
}
};
const handleDocApprove = async (docId, type, isApproved) => {
try {
const status = isApproved ? 'approved' : 'rejected';
const ep = type === "personal" ? `/api/upload/personal-documents/${docId}/review-status` : `/api/upload/business-documents/${docId}/review-status`;
const res = await authFetch(ep, {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ status, note: "" })
});
if (res.ok) {
fetchUserDetails(); // reload docs
} else {
showToast("Failed to save review status", "error");
}
} catch (err) {
console.error("Approval error", err);
showToast("Approval error", "error");
}
};
const deleteAdminDoc = async (docId) => {
if (!window.confirm("Delete this admin document?")) return;
try {
const res = await authFetch(`/api/upload/admin-documents/${docId}`, { method: "DELETE" });
if (res.ok) {
showToast("Document deleted", "success");
fetchUserDetails();
}
} catch(err) {
console.error(err);
}
};
const uploadAdminDoc = async (file) => {
const fd = new FormData();
fd.append("file", file);
fd.append("user_id", userId);
try {
const res = await authFetch("/api/upload/admin-documents", {
method: "POST",
body: fd
});
if (res.ok) {
showToast("Admin document uploaded", "success");
fetchUserDetails();
} else {
showToast("Failed to upload admin document", "error");
}
} catch(err) {
showToast("Upload failed", "error");
}
};
const viewDoc = async (storageKey) => {
try {
const res = await authFetch(`/api/upload/view-url?key=${encodeURIComponent(storageKey)}`);
if (res.ok) {
const data = await res.json();
window.open(data.url, "_blank");
} else {
showToast("Could not generate view link", "error");
}
} catch (err) {
showToast("Could not generate view link", "error");
}
};
const sendEmail = async (type) => {
const docsToReview = documents.filter(d => d.type === type);
const approved = docsToReview.filter(d => d.review_status === "approved").map(d => d.doc_type);
const rejected = docsToReview.filter(d => d.review_status === "rejected").map(d => d.doc_type);
if (approved.length === 0 && rejected.length === 0) {
showToast(`No ${type} documents selected.`, "warning");
return;
}
try {
const res = await authFetch("/api/review/notify-user", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
user_id: userId,
type: type,
approved: approved,
rejected: rejected,
personal_timeline: type === "personal" ? personalTimeline : 0,
business_timeline: type === "business" ? businessTimeline : 0
})
});
if (res.ok) {
showToast(`${type.charAt(0).toUpperCase() + type.slice(1)} approval email sent`, "success");
} else {
showToast("Failed to send email", "error");
}
} catch(err) {
showToast("Error sending email", "error");
}
};
const submitAllDocs = async () => {
if (!window.confirm("Submit all documents for review?\nAn email will be sent to the user.")) return;
try {
const res = await authFetch("/api/review/submit", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ user_id: userId })
});
if (res.ok) {
showToast("Documents submitted — email sent to user.", "success");
} else {
showToast("Failed to submit", "error");
}
} catch (err) {
showToast("Error submitting documents", "error");
}
};
if (loading && !userDetail) {
return <div className="page-main-wide page-enter"><div className="empty-state"><div className="empty-title">Loading user details...</div></div></div>;
}
if (!userDetail) {
return <div className="page-main-wide page-enter"><div className="empty-state"><div className="empty-title">User not found</div></div></div>;
}
const currentYear = new Date().getFullYear();
const yearOptions = [currentYear - 1, currentYear, currentYear + 1];
const personalDocs = documents.filter(d => d.type === "personal");
const businessDocs = documents.filter(d => d.type === "business");
const returnDocs = documents.filter(d => d.type === "admin");
return (
<div className="page-main-wide page-enter">
{/* User Info Bar */}
<div className="card" style={{marginBottom: '20px'}}>
<div style={{display:'flex', alignItems:'center', justifyContent:'space-between', flexWrap:'wrap', gap:'16px'}}>
<div style={{display:'flex', alignItems:'center', gap:'16px'}}>
<div style={{width:'52px', height:'52px', borderRadius:'50%', background:'linear-gradient(135deg,var(--header-bg),var(--blue-light))', display:'flex', alignItems:'center', justifyContent:'center', fontWeight:700, fontSize:'20px', color:'var(--navy)', flexShrink:0}}>
{(userDetail.name || "U").charAt(0).toUpperCase()}
</div>
<div>
<div style={{fontWeight:700, fontSize:'18px', color:'var(--navy)'}}>{userDetail.name || "—"}</div>
<div style={{fontSize:'13px', color:'var(--muted)', marginTop:'2px'}}>{userDetail.email}</div>
<div style={{display:'flex', gap:'8px', marginTop:'6px', flexWrap:'wrap'}}>
{currentUser?.role === 'super_admin' && currentUser.id !== userDetail.id ? (
<select
className="select-input"
style={{padding: '2px 8px', fontSize: '12px', height: 'auto', borderRadius: 'var(--radius-pill)', background: 'var(--card)', border: '1px solid var(--border)'}}
value={userDetail.role}
onChange={(e) => handleChangeRole(e.target.value)}
>
<option value="user">user</option>
<option value="admin">admin</option>
{userDetail.role === 'super_admin' && <option value="super_admin" disabled>super_admin</option>}
</select>
) : (
<span className={`badge ${userDetail.role === 'super_admin' ? 'badge-red' : userDetail.role === 'admin' ? 'badge-orange' : 'badge-blue'}`}>{userDetail.role}</span>
)}
{!userDetail.engagement_acknowledged_at && (
<span className="badge badge-yellow"><span className="material-symbols-outlined" style={{fontSize: '14px'}}>pending</span> Engagement not acknowledged</span>
)}
</div>
</div>
</div>
<div style={{display:'flex', gap:'10px', alignItems:'center', flexWrap:'wrap'}}>
<button className="btn btn-primary btn-sm" onClick={submitAllDocs} style={{borderRadius:'var(--radius-sm)'}}>Trigger Submit Review</button>
<div style={{display: 'flex', flexDirection: 'column', alignItems: 'flex-end', gap: '4px', marginLeft: '12px', paddingLeft: '16px', borderLeft: '1px solid var(--border)'}}>
<label className="form-label" style={{margin:0, fontSize: '11px'}}>Tax Year</label>
<select className="select-input" style={{width: 'auto', padding: '6px 12px', fontSize: '13px'}} value={taxYear} onChange={(e) => setTaxYear(e.target.value)}>
{yearOptions.map(y => <option key={y} value={y}>{y}</option>)}
</select>
</div>
<button className="btn btn-danger btn-sm" onClick={deleteUser} style={{borderRadius:'var(--radius-sm)'}}>Delete User</button>
</div>
</div>
</div>
{/* Tabs */}
<div className="tab-bar">
<button className={`tab-btn ${activeTab === 'personal' ? 'active' : ''}`} onClick={() => setActiveTab('personal')}><span className="material-symbols-outlined">description</span> Personal Docs</button>
<button className={`tab-btn ${activeTab === 'business' ? 'active' : ''}`} onClick={() => setActiveTab('business')}><span className="material-symbols-outlined">business</span> Business Docs</button>
<button className={`tab-btn ${activeTab === 'returns' ? 'active' : ''}`} onClick={() => setActiveTab('returns')}>📤 Returns for Review</button>
<button className={`tab-btn ${activeTab === 'audit' ? 'active' : ''}`} onClick={() => setActiveTab('audit')}><span className="material-symbols-outlined">history</span> Audit Trail</button>
</div>
{/* Tab: Personal */}
{activeTab === 'personal' && (
<div className="tab-panel active">
<div style={{display:'flex', gap:'20px', flexWrap:'wrap'}}>
<div style={{flex:2, minWidth:0}}>
<div className="card-flat">
{personalDocs.length === 0 ? (
<p className="text-muted">No personal documents uploaded for {taxYear}.</p>
) : (
personalDocs.map(doc => (
<div key={doc.id} style={{ display:'flex', alignItems:'flex-start', gap:'16px', padding:'14px 0', borderBottom:'1px solid var(--border)'}}>
<div style={{ flex:1, minWidth:0 }}>
<div style={{ fontWeight:600, fontSize:'13px', color:'var(--navy)' }}>{doc.doc_type}</div>
<div style={{ fontSize:'12px', color:'var(--muted)', marginTop:'2px' }}>Uploaded {new Date(doc.uploaded_at).toLocaleDateString()}</div>
{doc.notes && <div style={{ fontSize:'12px', color:'var(--warn)', marginTop:'3px' }}>Notes: {doc.notes}</div>}
{doc.review_status && (
<div style={{ fontSize:'12px', color: doc.review_status === "approved" ? "var(--success)" : doc.review_status === "rejected" ? "var(--error)" : "var(--yellow)", marginTop:'3px', fontWeight:600, textTransform:'uppercase' }}>
{doc.review_status}
</div>
)}
</div>
<div style={{ display:'flex', alignItems:'center', gap:'8px', flexShrink:0, flexWrap:'wrap' }}>
<button onClick={() => viewDoc(doc.storage_key)} className="btn btn-secondary btn-sm" style={{borderRadius:'var(--radius-sm)'}}>View</button>
<button className="btn btn-secondary btn-sm" style={{borderRadius:'var(--radius-sm)'}} onClick={() => handleDocApprove(doc.id, doc.type, true)}>Approve</button>
<button className="btn btn-danger btn-sm" style={{borderRadius:'var(--radius-sm)'}} onClick={() => handleDocApprove(doc.id, doc.type, false)}>Reject</button>
</div>
</div>
))
)}
</div>
</div>
<div style={{flex:1, minWidth:'240px'}}>
<div className="card-flat" style={{display:'flex', flexDirection:'column', gap:'16px'}}>
<h3>Filing Timeline</h3>
<div className="timeline-control">
<button className="tl-btn" onClick={() => setPersonalTimeline(Math.max(0, personalTimeline - 1))}>−</button>
<div>
<div className="tl-value">{personalTimeline}</div>
<div className="tl-label">days</div>
</div>
<button className="tl-btn" onClick={() => setPersonalTimeline(personalTimeline + 1)}>+</button>
</div>
<button className="btn btn-secondary w-full" style={{borderRadius:'var(--radius-sm)'}} onClick={() => sendEmail("personal")}>
Send Personal Approval Email
</button>
</div>
</div>
</div>
</div>
)}
{/* Tab: Business */}
{activeTab === 'business' && (
<div className="tab-panel active">
<div style={{display:'flex', gap:'20px', flexWrap:'wrap'}}>
<div style={{flex:2, minWidth:0}}>
<div className="card-flat">
{businessDocs.length === 0 ? (
<p className="text-muted">No business documents uploaded for {taxYear}.</p>
) : (
businessDocs.map(doc => (
<div key={doc.id} style={{ display:'flex', alignItems:'flex-start', gap:'16px', padding:'14px 0', borderBottom:'1px solid var(--border)'}}>
<div style={{ flex:1, minWidth:0 }}>
<div style={{ fontWeight:600, fontSize:'13px', color:'var(--navy)' }}>{doc.doc_type}</div>
<div style={{ fontSize:'12px', color:'var(--muted)', marginTop:'2px' }}>Uploaded {new Date(doc.uploaded_at).toLocaleDateString()}</div>
{doc.notes && <div style={{ fontSize:'12px', color:'var(--warn)', marginTop:'3px' }}>Notes: {doc.notes}</div>}
{doc.review_status && (
<div style={{ fontSize:'12px', color: doc.review_status === "approved" ? "var(--success)" : doc.review_status === "rejected" ? "var(--error)" : "var(--yellow)", marginTop:'3px', fontWeight:600, textTransform:'uppercase' }}>
{doc.review_status}
</div>
)}
</div>
<div style={{ display:'flex', alignItems:'center', gap:'8px', flexShrink:0, flexWrap:'wrap' }}>
<button onClick={() => viewDoc(doc.storage_key)} className="btn btn-secondary btn-sm" style={{borderRadius:'var(--radius-sm)'}}>View</button>
<button className="btn btn-secondary btn-sm" style={{borderRadius:'var(--radius-sm)'}} onClick={() => handleDocApprove(doc.id, doc.type, true)}>Approve</button>
<button className="btn btn-danger btn-sm" style={{borderRadius:'var(--radius-sm)'}} onClick={() => handleDocApprove(doc.id, doc.type, false)}>Reject</button>
</div>
</div>
))
)}
</div>
</div>
<div style={{flex:1, minWidth:'240px'}}>
<div className="card-flat" style={{display:'flex', flexDirection:'column', gap:'16px'}}>
<h3>Filing Timeline</h3>
<div className="timeline-control">
<button className="tl-btn" onClick={() => setBusinessTimeline(Math.max(0, businessTimeline - 1))}>−</button>
<div>
<div className="tl-value">{businessTimeline}</div>
<div className="tl-label">days</div>
</div>
<button className="tl-btn" onClick={() => setBusinessTimeline(businessTimeline + 1)}>+</button>
</div>
<button className="btn btn-secondary w-full" style={{borderRadius:'var(--radius-sm)'}} onClick={() => sendEmail("business")}>
Send Business Approval Email
</button>
</div>
</div>
</div>
</div>
)}
{/* Tab: Returns */}
{activeTab === 'returns' && (
<div className="tab-panel active">
<div className="card-flat">
<div style={{display:'flex', justifyContent:'space-between', alignItems:'center', marginBottom:'16px'}}>
<h3 style={{margin:0}}>Admin Documents</h3>
<div>
<input type="file" hidden ref={adminDocInputRef} accept=".pdf,.doc,.docx,.xls,.xlsx" onChange={e => {if(e.target.files[0]) uploadAdminDoc(e.target.files[0])}} />
<button className="btn btn-primary btn-sm" style={{borderRadius:'var(--radius-sm)'}} onClick={() => adminDocInputRef.current?.click()}>+ Upload Document</button>
</div>
</div>
{returnDocs.length === 0 ? (
<p className="text-muted">No returns or final documents uploaded yet.</p>
) : (
<div className="table-responsive">
<table className="admin-table">
<thead>
<tr>
<th>Filename</th>
<th>Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{returnDocs.map(doc => (
<tr key={doc.id}>
<td>
<div style={{fontWeight:500, color:'var(--navy)'}}>{doc.filename}</div>
</td>
<td>{new Date(doc.uploaded_at).toLocaleDateString()}</td>
<td>
<div style={{display:'flex', gap:'8px'}}>
<button className="btn btn-secondary btn-sm" onClick={() => viewDoc(doc.storage_key)}>View</button>
<button className="btn btn-danger btn-sm" onClick={() => deleteAdminDoc(doc.id)}>Delete</button>
</div>
</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</div>
</div>
)}
{/* Tab: Audit */}
{activeTab === 'audit' && (
<div className="tab-panel active">
<div className="card-flat">
<h3 style={{marginBottom:'16px'}}>Recent Activity</h3>
{auditLog.length === 0 ? (
<p className="text-muted">No audit logs found.</p>
) : (
<div className="table-responsive">
<table className="admin-table">
<thead>
<tr>
<th>Date</th>
<th>Action</th>
<th>Details</th>
<th>IP / Agent</th>
</tr>
</thead>
<tbody>
{auditLog.map(log => (
<tr key={log.id}>
<td style={{whiteSpace:'nowrap', color:'var(--muted)'}}>{new Date(log.created_at).toLocaleString()}</td>
<td><span className="badge badge-blue">{log.action}</span></td>
<td>{log.details}</td>
<td className="text-sm text-muted">
{log.ip_address}<br/>
<span style={{fontSize:'10px'}}>{log.user_agent?.substring(0, 30)}...</span>
</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</div>
</div>
)}
</div>
);
}
+153
View File
@@ -0,0 +1,153 @@
import { useState } from 'react';
export default function Contact() {
const [formData, setFormData] = useState({
first_name: '',
last_name: '',
email: '',
phone: '',
message: ''
});
const [loading, setLoading] = useState(false);
const handleSubmit = async (e) => {
e.preventDefault();
setLoading(true);
try {
const res = await fetch("/api/contact", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(formData)
});
if (!res.ok) throw new Error("Failed to send");
alert("Message Sent! Thank you for contacting us.");
setFormData({
first_name: '',
last_name: '',
email: '',
phone: '',
message: ''
});
} catch (err) {
alert("Failed to send message");
} finally {
setLoading(false);
}
};
const handleChange = (e) => {
setFormData({ ...formData, [e.target.name]: e.target.value });
};
return (
<>
{/* HERO */}
<div className="page-hero" style={{
backgroundImage: 'linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url("/images/home-background.jpg")',
backgroundSize: 'cover',
backgroundPosition: 'center',
minHeight: '350px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
textAlign: 'center',
color: '#fff'
}}>
<div>
<h1>Get In Touch</h1>
<p>We'd love to hear from you. Reach out to our global teams.</p>
</div>
</div>
<section className="contact-section" style={{ border: 'none', marginTop: '60px', marginBottom: '80px' }}>
<h2 className="contact-title" style={{ color: 'var(--navy)', marginBottom: '50px' }}>
CONTACT <span style={{ color: 'var(--blue)' }}>BOOK</span><span style={{ color: 'var(--orange)' }}>KEEPRO</span>
</h2>
<div className="contact-container" style={{ width: '100%', maxWidth: '1000px', display: 'flex', flexWrap: 'wrap', gap: '40px', justifyContent: 'center' }}>
<div className="contact-info" style={{ flex: '1 1 300px', display: 'flex', flexDirection: 'column', gap: '30px' }}>
<div className="info-box usa" style={{ padding: '30px', borderRadius: '20px', boxShadow: 'var(--shadow-md)' }}>
<h3 style={{ fontSize: '24px', marginBottom: '12px' }}>USA</h3>
<p style={{ lineHeight: '1.6', marginBottom: '16px', opacity: 0.9 }}>2520 Indigo Dr<br />McKinney, TX<br />75072, United States</p>
<p className="phone" style={{ display: 'flex', alignItems: 'center', gap: '10px', fontWeight: '500' }}>
<span className="material-symbols-outlined" style={{ fontSize: '20px' }}>call</span> +1469-796-6151
</p>
</div>
<div className="info-box ind" style={{ padding: '30px', borderRadius: '20px', boxShadow: 'var(--shadow-md)' }}>
<h3 style={{ fontSize: '24px', marginBottom: '12px' }}>IND</h3>
<p style={{ lineHeight: '1.6', marginBottom: '16px', opacity: 0.9 }}>508, White Square,<br />Hinjewadi Road, Pune<br />411057, India</p>
<p className="phone" style={{ display: 'flex', alignItems: 'center', gap: '10px', fontWeight: '500' }}>
<span className="material-symbols-outlined" style={{ fontSize: '20px' }}>call</span> +91 738 793 6020
</p>
</div>
</div>
<div style={{ flex: '1.5 1 400px' }}>
<form className="contact-form" onSubmit={handleSubmit} style={{ padding: '40px', borderRadius: '20px', boxShadow: 'var(--shadow-lg)' }}>
<h3 style={{ fontSize: '22px', marginBottom: '24px', color: 'var(--navy)' }}>Send us a message</h3>
<div className="form-row" style={{ display: 'flex', gap: '20px', marginBottom: '20px' }}>
<input
type="text"
name="first_name"
placeholder="First Name"
required
value={formData.first_name}
onChange={handleChange}
style={{ flex: 1, padding: '14px', borderRadius: '8px', border: '1px solid var(--border)', outline: 'none' }}
/>
<input
type="text"
name="last_name"
placeholder="Last Name"
required
value={formData.last_name}
onChange={handleChange}
style={{ flex: 1, padding: '14px', borderRadius: '8px', border: '1px solid var(--border)', outline: 'none' }}
/>
</div>
<input
type="email"
name="email"
placeholder="Email Address"
required
value={formData.email}
onChange={handleChange}
style={{ width: '100%', padding: '14px', borderRadius: '8px', border: '1px solid var(--border)', outline: 'none', marginBottom: '20px' }}
/>
<div className="phone-row" style={{ marginBottom: '20px', border: 'none', padding: 0 }}>
<input
type="text"
name="phone"
placeholder="Mobile Number"
required
value={formData.phone}
onChange={handleChange}
style={{ width: '100%', padding: '14px', borderRadius: '8px', border: '1px solid var(--border)', outline: 'none' }}
/>
</div>
<div className="message-row">
<textarea
name="message"
placeholder="How can we help you?"
required
style={{ width: '100%', padding: '14px', border: '1px solid var(--border)', borderRadius: '8px', fontFamily: 'inherit', fontSize: '15px', outline: 'none', marginBottom: '24px', resize: 'vertical', minHeight: '120px' }}
value={formData.message}
onChange={handleChange}
></textarea>
</div>
<button type="submit" disabled={loading} className="btn btn-primary" style={{ width: '100%', padding: '14px', fontSize: '16px', borderRadius: '30px' }}>
{loading ? 'SENDING...' : 'SEND MESSAGE'}
</button>
</form>
</div>
</div>
</section>
</>
);
}
+71
View File
@@ -0,0 +1,71 @@
import { useState } from 'react';
import { Link } from 'react-router-dom';
export default function ForgotPassword() {
const [email, setEmail] = useState('');
const [loading, setLoading] = useState(false);
const [message, setMessage] = useState(null);
const handleReset = async (e) => {
e.preventDefault();
if (!email) return;
setLoading(true);
try {
await fetch("/api/auth/forgot-password", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email })
});
setMessage("If that email exists, a reset link has been sent.");
setEmail("");
} catch (err) {
console.error(err);
setMessage("Network error. Please try again.");
} finally {
setLoading(false);
}
};
return (
<div className="auth-shell page-enter">
<div className="auth-brand">
<img className="brand-logo" src="/images/bookkeeppro-logo.webp" alt="BookKeepPro"/>
<div className="brand-divider"></div>
<h2>Reset Your Password</h2>
<p>We'll send a secure link to your registered email address.</p>
</div>
<div className="auth-form-side">
<div className="auth-box">
<div style={{fontSize:'40px', marginBottom:'12px'}}>🔑</div>
<h1>Forgot Password?</h1>
<p className="auth-subtitle">Enter your email and we'll send a reset link</p>
{message && <div style={{padding: '10px', background: 'var(--blue-light)', color: 'var(--blue)', borderRadius: 'var(--radius-sm)', marginBottom: '16px', fontSize: '14px'}}>{message}</div>}
<form onSubmit={handleReset}>
<div className="form-group" style={{marginTop:'24px'}}>
<label className="form-label" htmlFor="email">Email Address</label>
<input
id="email"
type="email"
className="input"
placeholder="you@example.com"
value={email}
onChange={e => setEmail(e.target.value)}
required
/>
</div>
<button type="submit" className="btn btn-primary w-full" disabled={loading} style={{borderRadius:'var(--radius-sm)'}}>
{loading ? "Sending..." : "Send Reset Link"}
</button>
</form>
<div className="auth-links"><Link to="/login" className="fancy-link">← Back to Sign In</Link></div>
</div>
</div>
</div>
);
}
+76
View File
@@ -0,0 +1,76 @@
import { Link } from 'react-router-dom';
export default function Home() {
return (
<>
{/* ================= HERO ================= */}
<div className="home-hero" style={{
backgroundImage: 'linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.6)), url("/images/home-background.jpg")',
backgroundSize: 'cover',
backgroundPosition: 'center',
minHeight: '600px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
textAlign: 'center',
color: '#fff',
padding: '20px'
}}>
<div style={{ maxWidth: '800px' }}>
<h1 style={{ fontSize: 'clamp(32px, 5vw, 56px)', fontWeight: '700', marginBottom: '20px', color: '#fff' }}>PRECISION | COMPLIANCE | FINANCIAL GROWTH</h1>
<p style={{ fontSize: 'clamp(18px, 2vw, 24px)', marginBottom: '30px', color: '#e2eaf2' }}>Your Trusted Bookkeeping & Financial Operations Partner for Growing Businesses</p>
<Link to="/contact">
<button className="btn btn-primary" style={{ padding: '12px 32px', fontSize: '18px', borderRadius: '30px' }}>Get Started</button>
</Link>
</div>
</div>
{/* ================= ABOUT ================= */}
<section className="about-section" style={{ display: 'flex', gap: '40px', padding: '80px 20px', maxWidth: '1200px', margin: '0 auto', alignItems: 'center', flexWrap: 'wrap' }}>
<div className="text" style={{ flex: '1 1 500px' }}>
<h2 style={{ fontSize: '36px', marginBottom: '24px' }}>
We are <span style={{ color: '#0077C8' }}>BOOK</span><span style={{ color: '#FF7F11' }}>KEEPRO</span>
</h2>
<p style={{ fontSize: '16px', lineHeight: '1.8', marginBottom: '16px' }}>
Our journey began in 1998 as a Chartered Accountant firm in India, built on strong fundamentals of accounting, compliance, integrity, and long-term client relationships. Over the years, we earned the trust of businesses by delivering accurate, compliant, and dependable financial services.
</p>
<p style={{ fontSize: '16px', lineHeight: '1.8', marginBottom: '24px' }}>
In 2018, responding to growing demand and an expanding client base, we strengthened our presence by establishing operations in Pune and Mumbai, two of India’s major business hubs. This phase marked our evolution from a traditional CA practice into a more structured, process-driven financial services organization.
</p>
<p className="note" style={{ fontStyle: 'italic', color: 'var(--muted)', fontWeight: '500' }}>-- Our People Are Passionate About What We Do</p>
</div>
<div style={{ flex: '1 1 400px' }}>
<img src="/images/home-about.jpg" alt="About BookKeepPro" style={{ width: '100%', borderRadius: '20px', boxShadow: 'var(--shadow-lg)', objectFit: 'cover' }} />
</div>
</section>
{/* ================= SERVICES ================= */}
<section className="services-section">
<h2>OUR SERVICES</h2>
<div className="services-grid">
<div className="service-card" style={{ flex: '1 1 300px' }}>
<img src="/images/services-1.jpg" alt="Bookkeeping" style={{ width: '100%', height: '220px', objectFit: 'cover', borderTopLeftRadius: '15px', borderTopRightRadius: '15px' }} />
<div style={{ padding: '24px' }}>
<h3 style={{ fontSize: '20px', marginBottom: '16px' }}>Professional Bookkeeping for Firms & Businesses</h3>
<Link to="/contact"><button className="btn btn-outline" style={{ width: '100%' }}>Get Consultation</button></Link>
</div>
</div>
<div className="service-card" style={{ flex: '1 1 300px' }}>
<img src="/images/services-2.jpg" alt="Payroll" style={{ width: '100%', height: '220px', objectFit: 'cover', borderTopLeftRadius: '15px', borderTopRightRadius: '15px' }} />
<div style={{ padding: '24px' }}>
<h3 style={{ fontSize: '20px', marginBottom: '16px' }}>Professional & Globally Trusted Payroll Solutions</h3>
<Link to="/contact"><button className="btn btn-outline" style={{ width: '100%' }}>Get Consultation</button></Link>
</div>
</div>
<div className="service-card" style={{ flex: '1 1 300px' }}>
<img src="/images/services-3.jpg" alt="Tax Planning" style={{ width: '100%', height: '220px', objectFit: 'cover', borderTopLeftRadius: '15px', borderTopRightRadius: '15px' }} />
<div style={{ padding: '24px' }}>
<h3 style={{ fontSize: '20px', marginBottom: '16px' }}>Professional Tax Planning & Preparation</h3>
<Link to="/contact"><button className="btn btn-outline" style={{ width: '100%' }}>Get Consultation</button></Link>
</div>
</div>
</div>
</section>
</>
);
}
+119
View File
@@ -0,0 +1,119 @@
import { useState } from 'react';
import { useNavigate, Link } from 'react-router-dom';
import { useAuth } from '../context/AuthContext';
export default function Login() {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [showPassword, setShowPassword] = useState(false);
const [error, setError] = useState(null);
const [loading, setLoading] = useState(false);
const { login } = useAuth();
const navigate = useNavigate();
const handleLogin = async (e) => {
e.preventDefault();
setError(null);
setLoading(true);
try {
const res = await fetch("/api/auth/login", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email, password })
});
if (!res.ok) {
throw new Error("Invalid credentials");
}
const data = await res.json();
login(data.access_token);
// Navigate to correct dashboard based on role
if (data.role === 'admin' || data.role === 'super_admin') {
navigate('/admin-dashboard');
} else {
navigate('/dashboard');
}
} catch (err) {
setError(err.message);
} finally {
setLoading(false);
}
};
return (
<div className="auth-shell page-enter">
<div className="auth-brand">
<img className="brand-logo" src="/images/bookkeeppro-logo.webp" alt="BookKeepPro" />
<div className="brand-divider"></div>
<h2>Welcome Back</h2>
<p>Secure access to your bookkeeping portal. Upload documents, track filings, and stay organised.</p>
</div>
<div className="auth-form-side">
<div className="auth-box">
<Link to="/" className="fancy-link" style={{display: 'inline-block', marginBottom: '1.5rem', fontSize: '0.95rem', fontWeight: '500'}}>
&larr; Back to Home
</Link>
<h1>Sign In</h1>
<p className="auth-subtitle">Enter your credentials to continue</p>
{error && <div style={{color: 'var(--error)', marginBottom: '1rem', fontSize: '14px'}}>{error}</div>}
<form onSubmit={handleLogin}>
<div className="form-group">
<label className="form-label" htmlFor="email">Email Address</label>
<input
id="email"
type="email"
className="input"
placeholder="you@example.com"
required
value={email}
onChange={e => setEmail(e.target.value)}
/>
</div>
<div className="form-group">
<label className="form-label" htmlFor="password">Password</label>
<div className="password-wrap">
<input
id="password"
type={showPassword ? 'text' : 'password'}
className="input"
placeholder="Your password"
required
value={password}
onChange={e => setPassword(e.target.value)}
/>
<button
type="button"
className="password-toggle"
onClick={() => setShowPassword(!showPassword)}
>
{showPassword ? 'Hide' : 'Show'}
</button>
</div>
</div>
<button
type="submit"
className="btn btn-primary w-full"
style={{borderRadius: 'var(--radius-sm)', marginTop: '4px'}}
disabled={loading}
>
{loading ? 'Signing in...' : 'Sign In'}
</button>
</form>
<div className="auth-links">
<Link to="/forgot-password" className="fancy-link">Forgot password?</Link><br/>
Don't have an account? <Link to="/signup" className="fancy-link">Sign Up</Link>
</div>
</div>
</div>
</div>
);
}
+116
View File
@@ -0,0 +1,116 @@
import { useState, useEffect } from 'react';
import { useAuth } from '../context/AuthContext';
export default function Profile() {
const { user, authFetch } = useAuth();
const [formData, setFormData] = useState({ name: '', phone: '' });
const [pwData, setPwData] = useState({ currentPw: '', newPw: '', confirmPw: '' });
const [showPwSection, setShowPwSection] = useState(false);
const [showNewPw, setShowNewPw] = useState(false);
const [loading, setLoading] = useState(false);
useEffect(() => {
if (user) {
setFormData({ name: user.name || '', phone: user.phone || '' });
}
}, [user]);
const handleSave = async () => {
setLoading(true);
try {
const payload = { ...formData };
if (showPwSection && pwData.newPw) {
if (pwData.newPw !== pwData.confirmPw) {
alert("New passwords do not match");
setLoading(false);
return;
}
payload.current_password = pwData.currentPw;
payload.new_password = pwData.newPw;
}
const res = await authFetch("/api/auth/me", {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload)
});
if (!res.ok) {
const data = await res.json();
throw new Error(data.detail || "Failed to update profile");
}
alert("Profile updated successfully. Please log in again if you changed your password.");
if (payload.new_password) {
window.location.href = '/login';
}
} catch (err) {
alert(err.message);
} finally {
setLoading(false);
}
};
return (
<div style={{ maxWidth: '680px', margin: '0 auto' }}>
<div className="page-heading">
<div>
<h1>My Profile</h1>
<p className="page-meta">Update your name, phone number, or password</p>
</div>
</div>
<div className="card" style={{ marginBottom: '20px' }}>
<h3 style={{ marginBottom: '20px', paddingBottom: '12px', borderBottom: '1px solid var(--border)' }}>Account Info</h3>
<div className="form-group">
<label className="form-label">Email Address <span style={{ color: 'var(--muted)', fontWeight: 400 }}>(cannot be changed)</span></label>
<input type="email" className="input" readOnly value={user?.email || ''} />
</div>
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '16px' }}>
<div className="form-group">
<label className="form-label">Full Name</label>
<input type="text" className="input" placeholder="Your full name" value={formData.name} onChange={e => setFormData({ ...formData, name: e.target.value })} />
</div>
<div className="form-group">
<label className="form-label">Phone Number</label>
<input type="tel" className="input" placeholder="+1 (555) 000-0000" value={formData.phone} onChange={e => setFormData({ ...formData, phone: e.target.value })} />
</div>
</div>
</div>
<div className="card" style={{ marginBottom: '24px' }}>
<div className="flex-between" style={{ marginBottom: '4px', cursor: 'pointer' }} onClick={() => setShowPwSection(!showPwSection)}>
<h3>Change Password</h3>
<span style={{ color: 'var(--muted)', fontSize: '18px' }}>{showPwSection ? '▼' : '▶'}</span>
</div>
<p className="text-sm" style={{ marginBottom: 0 }}>Click to expand and update your password</p>
{showPwSection && (
<div style={{ marginTop: '20px', paddingTop: '20px', borderTop: '1px solid var(--border)' }}>
<div className="form-group">
<label className="form-label">Current Password</label>
<input type="password" className="input" placeholder="Enter current password" value={pwData.currentPw} onChange={e => setPwData({ ...pwData, currentPw: e.target.value })} />
</div>
<div className="form-group">
<label className="form-label">New Password</label>
<div className="password-wrap">
<input type={showNewPw ? 'text' : 'password'} className="input" placeholder="At least 8 characters" style={{ paddingRight: '56px' }} value={pwData.newPw} onChange={e => setPwData({ ...pwData, newPw: e.target.value })} />
<button type="button" className="password-toggle" onClick={() => setShowNewPw(!showNewPw)}>
{showNewPw ? 'Hide' : 'Show'}
</button>
</div>
</div>
<div className="form-group">
<label className="form-label">Confirm New Password</label>
<input type="password" className="input" placeholder="Repeat new password" value={pwData.confirmPw} onChange={e => setPwData({ ...pwData, confirmPw: e.target.value })} />
</div>
</div>
)}
</div>
<button className="btn btn-primary w-full" style={{ borderRadius: 'var(--radius-sm)' }} onClick={handleSave} disabled={loading}>
{loading ? 'Saving...' : 'Save Changes'}
</button>
</div>
);
}
+71
View File
@@ -0,0 +1,71 @@
import { useState } from 'react';
import { Link } from 'react-router-dom';
export default function ResendVerification() {
const [email, setEmail] = useState('');
const [loading, setLoading] = useState(false);
const [message, setMessage] = useState(null);
const handleResend = async (e) => {
e.preventDefault();
if (!email) return;
setLoading(true);
try {
await fetch("/api/auth/resend-verification", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email })
});
setMessage("If that email is registered and unverified, a new link has been sent. Check your inbox.");
setEmail("");
} catch (err) {
console.error(err);
setMessage("Network error. Please try again.");
} finally {
setLoading(false);
}
};
return (
<div className="auth-shell page-enter">
<div className="auth-brand">
<img className="brand-logo" src="/images/bookkeeppro-logo.webp" alt="BookKeepPro"/>
<div className="brand-divider"></div>
<h2>Verify Your Email</h2>
<p>Check your inbox for the verification link. It expires in 24 hours.</p>
</div>
<div className="auth-form-side">
<div className="auth-box">
<div style={{fontSize:'40px', marginBottom:'12px'}}>📧</div>
<h1>Resend Verification</h1>
<p className="auth-subtitle">We'll send a new link to your registered email</p>
{message && <div style={{padding: '10px', background: 'var(--blue-light)', color: 'var(--blue)', borderRadius: 'var(--radius-sm)', marginBottom: '16px', fontSize: '14px'}}>{message}</div>}
<form onSubmit={handleResend}>
<div className="form-group" style={{marginTop:'24px'}}>
<label className="form-label" htmlFor="email">Email Address</label>
<input
id="email"
type="email"
className="input"
placeholder="you@example.com"
value={email}
onChange={e => setEmail(e.target.value)}
required
/>
</div>
<button type="submit" className="btn btn-primary w-full" disabled={loading} style={{borderRadius:'var(--radius-sm)'}}>
{loading ? "Sending..." : "Send Verification Link"}
</button>
</form>
<div className="auth-links"><Link to="/login" className="fancy-link">Back to Sign In</Link></div>
</div>
</div>
</div>
);
}
+95
View File
@@ -0,0 +1,95 @@
import { useState, useEffect } from 'react';
import { useSearchParams, useNavigate, Link } from 'react-router-dom';
export default function ResetPassword() {
const [searchParams] = useSearchParams();
const token = searchParams.get('token');
const navigate = useNavigate();
const [password, setPassword] = useState('');
const [showPassword, setShowPassword] = useState(false);
const [loading, setLoading] = useState(false);
const [message, setMessage] = useState(null);
const [error, setError] = useState(null);
useEffect(() => {
if (!token) {
setError("Invalid or missing reset link. Request a new one.");
}
}, [token]);
const handleReset = async (e) => {
e.preventDefault();
if (!password || !token) return;
setLoading(true);
setError(null);
try {
const res = await fetch("/api/auth/reset-password", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ token, new_password: password })
});
const data = await res.json();
if (!res.ok) {
throw new Error(data.detail || "Password reset failed");
}
setMessage("Password reset! Redirecting to sign in...");
setTimeout(() => navigate('/login'), 2000);
} catch (err) {
setError(err.message);
} finally {
setLoading(false);
}
};
return (
<div className="auth-shell page-enter">
<div className="auth-brand">
<img className="brand-logo" src="/images/bookkeeppro-logo.webp" alt="BookKeepPro"/>
<div className="brand-divider"></div>
<h2>Choose a New Password</h2>
<p>Pick something strong — at least 8 characters with a mix of letters, numbers, and symbols.</p>
</div>
<div className="auth-form-side">
<div className="auth-box">
<div style={{fontSize:'40px', marginBottom:'12px'}}>🔒</div>
<h1>Reset Password</h1>
<p className="auth-subtitle">Enter your new password below</p>
{error && <div style={{color: 'var(--error)', marginBottom: '1rem', fontSize: '14px'}}>{error}</div>}
{message && <div style={{color: 'var(--green)', marginBottom: '1rem', fontSize: '14px'}}>{message}</div>}
<form onSubmit={handleReset}>
<div className="form-group" style={{marginTop:'24px'}}>
<label className="form-label" htmlFor="password">New Password</label>
<div className="password-wrap">
<input
id="password"
type={showPassword ? "text" : "password"}
className="input"
placeholder="At least 8 characters"
value={password}
onChange={e => setPassword(e.target.value)}
required
/>
<button type="button" className="password-toggle" onClick={() => setShowPassword(!showPassword)}>
{showPassword ? "Hide" : "Show"}
</button>
</div>
</div>
<button type="submit" className="btn btn-primary w-full" disabled={loading || !token} style={{borderRadius:'var(--radius-sm)'}}>
{loading ? "Resetting..." : "Reset Password"}
</button>
</form>
<div className="auth-links"><Link to="/login" className="fancy-link">Back to Sign In</Link></div>
</div>
</div>
</div>
);
}
+85
View File
@@ -0,0 +1,85 @@
export default function Services() {
return (
<>
{/* HERO */}
<div className="page-hero" style={{
backgroundImage: 'linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.6)), url("/images/Services-background-image.webp")',
backgroundSize: 'cover',
backgroundPosition: 'center',
minHeight: '400px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
textAlign: 'center',
color: '#fff'
}}>
<h1>Professional Services for Firms & Businesses</h1>
</div>
{/* SERVICE CONTENT */}
<div className="services-wrapper">
{/* Block 1 */}
<div className="service-block">
<div className="service-text">
<h2>For Accounting Firms and Businesses</h2>
<p>
Bookkeepro India specialises in its offshore delivery model and consists of a strong team of qualified
accountants, cost accountants, tax consultants and payroll experts to ease the bookkeeping for Accounting
Firms and Businesses, globally.
</p>
<br />
<p>
Bookkeepro’s India based offshore bookkeeping services offer several benefits
to global accounting firms and businesses.
</p>
</div>
<img className="service-img" src="/images/services-3.jpg" alt="Accounting Outsourcing" style={{ borderRadius: '14px', objectFit: 'cover' }} />
</div>
{/* Block 2 */}
<div className="service-block reverse">
<div className="service-text">
<h2>Scale Your Business with Accounting Outsourcing</h2>
<p>
Are you ready to supercharge your business and take it to new heights?
We understand that managing finances and accounting can be a complex and
time-consuming task, often diverting your focus away from what truly matters —
growing your business.
</p>
<br />
<p>
That’s where we come in. Allow us to present the game-changing solution:
Accounting Outsourcing.
</p>
</div>
<img className="service-img-bl-3" src="/images/services-2.jpg" alt="Outsourced Accounting Team" style={{ borderRadius: '14px', objectFit: 'cover' }} />
</div>
{/* Block 3 */}
<div className="service-block">
<div className="service-text">
<h2>Tax Planning And Preparation</h2>
<p>
We help individuals and businesses optimize tax strategy and get returns prepared right and on time.
Whether your business is an LLC, S-Corp, or C-Corp, we’ll help you:
</p>
<ol className="list-items">
<li>Comply with and leverage changing federal tax law</li>
<li>Minimize overall tax liability through strategic planning</li>
<li>Determine taxation of owner-provided benefits</li>
<li>Leverage year-end tax opportunities</li>
<li>Manage multi-state tax exposure based on nexus</li>
</ol>
<br />
<p>
By minimizing your tax liability, you maximize your after-tax cash flow,
which helps create financial security. We want you confident in knowing you
have the right proactive tax plan in place.
</p>
</div>
<img className="service-img" src="/images/services-1.jpg" alt="Tax Services" style={{ borderRadius: '14px', objectFit: 'cover' }} />
</div>
</div>
</>
);
}
+131
View File
@@ -0,0 +1,131 @@
import { useState } from 'react';
import { useNavigate, Link } from 'react-router-dom';
export default function Signup() {
const [formData, setFormData] = useState({ name: '', email: '', phone: '', password: '' });
const [showPassword, setShowPassword] = useState(false);
const [error, setError] = useState(null);
const [loading, setLoading] = useState(false);
const navigate = useNavigate();
const handleSignup = async (e) => {
e.preventDefault();
setError(null);
setLoading(true);
try {
const res = await fetch("/api/auth/signup", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(formData)
});
if (!res.ok) {
const data = await res.json();
throw new Error(data.detail || "Signup failed");
}
// Success, route to login with message
navigate('/login', { state: { message: "Account created successfully. Please log in." }});
} catch (err) {
setError(err.message);
} finally {
setLoading(false);
}
};
return (
<div className="auth-shell page-enter">
<div className="auth-brand">
<img className="brand-logo" src="/images/bookkeeppro-logo.webp" alt="BookKeepPro" />
<div className="brand-divider"></div>
<h2>Join BookKeepPro</h2>
<p>Create your account to securely upload documents, track reviews, and stay on top of your filings.</p>
</div>
<div className="auth-form-side">
<div className="auth-box">
<Link to="/" className="fancy-link" style={{display: 'inline-block', marginBottom: '1.5rem', fontSize: '0.95rem', fontWeight: '500'}}>
&larr; Back to Home
</Link>
<h1>Create Account</h1>
<p className="auth-subtitle">It only takes a minute</p>
{error && <div style={{color: 'var(--error)', marginBottom: '1rem', fontSize: '14px'}}>{error}</div>}
<form onSubmit={handleSignup} autoComplete="off">
<div className="form-group">
<label className="form-label" htmlFor="name">Full Name</label>
<input
id="name"
type="text"
className="input"
placeholder="Jane Smith"
required
value={formData.name}
onChange={e => setFormData({...formData, name: e.target.value})}
/>
</div>
<div className="form-group">
<label className="form-label" htmlFor="email">Email Address</label>
<input
id="email"
type="email"
className="input"
placeholder="you@example.com"
required
value={formData.email}
onChange={e => setFormData({...formData, email: e.target.value})}
/>
</div>
<div className="form-group">
<label className="form-label" htmlFor="phone">Phone Number <span style={{color:'var(--muted)', fontWeight:400}}>(optional)</span></label>
<input
id="phone"
type="tel"
className="input"
placeholder="+1 (555) 000-0000"
value={formData.phone}
onChange={e => setFormData({...formData, phone: e.target.value})}
/>
</div>
<div className="form-group">
<label className="form-label" htmlFor="password">Password</label>
<div className="password-wrap">
<input
id="password"
type={showPassword ? 'text' : 'password'}
className="input"
placeholder="At least 8 characters"
required
style={{paddingRight:'56px'}}
value={formData.password}
onChange={e => setFormData({...formData, password: e.target.value})}
/>
<button
type="button"
className="password-toggle"
onClick={() => setShowPassword(!showPassword)}
>
{showPassword ? 'Hide' : 'Show'}
</button>
</div>
</div>
<button
type="submit"
className="btn btn-primary w-full"
style={{borderRadius: 'var(--radius-sm)'}}
disabled={loading}
>
{loading ? 'Creating account...' : 'Create Account'}
</button>
<div className="auth-links">
Already have an account? <Link to="/login" className="fancy-link">Sign In</Link>
</div>
</form>
</div>
</div>
</div>
);
}
+249
View File
@@ -0,0 +1,249 @@
import { useEffect, useState, useRef } from 'react';
import { Link } from 'react-router-dom';
import { useAuth } from '../context/AuthContext';
import { useToast } from '../context/ToastContext';
export default function UploadBusiness() {
const { authFetch } = useAuth();
const { showToast } = useToast();
const [taxYear, setTaxYear] = useState(new Date().getFullYear());
const [docs, setDocs] = useState([]);
const [templates, setTemplates] = useState([]);
const [loading, setLoading] = useState(false);
const fileInputRefs = useRef({});
const extraFileRef = useRef(null);
useEffect(() => {
fetchTemplatesAndDocs();
}, [taxYear]);
const fetchTemplatesAndDocs = async () => {
setLoading(true);
try {
const tplRes = await authFetch(`/api/upload/templates?category=business&tax_year=${taxYear}`);
if (tplRes.ok) {
setTemplates(await tplRes.json());
}
const docRes = await authFetch(`/api/upload/business-documents?tax_year=${taxYear}`);
if (docRes.ok) {
setDocs(await docRes.json());
}
} catch (err) {
console.error(err);
} finally {
setLoading(false);
}
};
const uploadFile = async (file, docType) => {
if (file.size > 10 * 1024 * 1024) {
showToast("File size exceeds 10MB limit", "error");
return;
}
const fd = new FormData();
fd.append("file", file);
fd.append("tax_year", taxYear);
fd.append("doc_type", docType);
try {
const res = await authFetch("/api/upload/business-documents", {
method: "POST",
body: fd
});
if (res.ok) {
showToast("Document uploaded successfully", "success");
fetchTemplatesAndDocs();
} else {
const data = await res.json().catch(() => ({}));
showToast(data.detail || "Upload failed", "error");
}
} catch (err) {
showToast("Upload failed due to network error", "error");
}
};
const deleteDoc = async (id) => {
if (!window.confirm("Delete this document?\nThis action cannot be undone.")) return;
try {
const res = await authFetch(`/api/upload/business-documents/${id}`, { method: "DELETE" });
if (res.ok) {
showToast("Document deleted", "success");
fetchTemplatesAndDocs();
} else {
showToast("Delete failed", "error");
}
} catch (err) {
showToast("Delete failed", "error");
}
};
const viewDoc = async (storageKey) => {
try {
const res = await authFetch(`/api/upload/view-url?key=${encodeURIComponent(storageKey)}`);
if (res.ok) {
const data = await res.json();
window.open(data.url, "_blank");
} else {
showToast("Could not generate view link", "error");
}
} catch (err) {
showToast("Could not generate view link", "error");
}
};
const handleExtraUpload = async (e) => {
const files = Array.from(e.target.files);
for (let file of files) {
if (file.size > 10 * 1024 * 1024) {
showToast(`File ${file.name} exceeds 10MB limit`, "error");
continue;
}
await uploadFile(file, "other");
}
e.target.value = "";
};
const notifyComplete = async () => {
try {
const res = await authFetch("/api/upload/notify-upload-complete", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ file_count: docs.length, doc_category: "Business" })
});
if (res.ok) {
showToast("Admin notified successfully", "success");
} else {
showToast("Failed to notify admin", "error");
}
} catch (err) {
showToast("Error notifying admin", "error");
}
};
const years = [new Date().getFullYear(), new Date().getFullYear() - 1, new Date().getFullYear() - 2];
return (
<div>
<div style={{marginBottom: '16px'}}>
<Link to="/dashboard" className="fancy-link" style={{fontSize: '14px', fontWeight: 500}}>← Back to Dashboard</Link>
</div>
<div className="page-heading">
<div>
<h1>Business Documents</h1>
<p className="page-meta">Upload your business tax documents securely</p>
</div>
<div style={{display:'flex', flexDirection:'column', alignItems:'flex-end', gap:'4px'}}>
<label className="form-label" style={{margin:0}}>Tax Year</label>
<select
className="select-input"
style={{width:'auto', padding:'8px 14px'}}
value={taxYear}
onChange={(e) => setTaxYear(e.target.value)}
>
{years.map(y => <option key={y} value={y}>{y}</option>)}
</select>
</div>
</div>
<div className="card" style={{marginBottom: '20px'}}>
<h3 style={{marginBottom: '16px'}}>Required Documents</h3>
<div id="docWrapper">
{loading ? (
<div className="empty-state">Loading templates...</div>
) : templates.length === 0 ? (
<div className="empty-state">No required documents for this tax year.</div>
) : templates.map((dt, i) => {
const uploaded = docs.filter(d => d.doc_type === dt.name);
return (
<div className="doc-slot fade-up" key={i} style={{ animationDelay: `${i * 0.04}s` }}>
<div className="doc-slot-info">
<div className="doc-slot-name">{i+1}. {dt.name}</div>
<div className="doc-slot-status">
{uploaded.length ? (
<span className="pill-pending"><span className="material-symbols-outlined">pending</span> Pending Review</span>
) : (
"Missing"
)}
</div>
</div>
<div className="doc-slot-actions">
<input
type="file"
hidden
accept=".pdf,.jpg,.jpeg,.png,.webp,.doc,.docx,.xls,.xlsx"
ref={el => fileInputRefs.current[dt.name] = el}
onChange={(e) => e.target.files[0] && uploadFile(e.target.files[0], dt.name)}
/>
<div style={{display: 'flex', gap: '8px', alignItems: 'center'}}>
{dt.download && (
<a href={dt.download} target="_blank" rel="noreferrer" className="btn btn-secondary btn-sm" style={{borderRadius: 'var(--radius-pill)', padding: '4px 12px', display: 'flex', alignItems: 'center', gap: '4px'}}>
<span className="material-symbols-outlined" style={{fontSize: '16px'}}>download</span> Template
</a>
)}
{!uploaded.length && (
<button className="btn btn-sm btn-upload-pill" onClick={() => fileInputRefs.current[dt.name].click()}>Upload</button>
)}
</div>
{uploaded.map(doc => (
<div key={doc.id} style={{display:'flex', gap:'8px'}}>
<button className="btn btn-secondary btn-xs" style={{borderRadius:'var(--radius-sm)'}} onClick={() => viewDoc(doc.storage_key)}>View</button>
<button className="btn btn-danger btn-xs" style={{borderRadius:'var(--radius-sm)'}} onClick={() => deleteDoc(doc.id)}>Delete</button>
</div>
))}
</div>
</div>
);
})}
</div>
</div>
<div className="card">
<div className="flex-between" style={{marginBottom: '16px'}}>
<div>
<h3>Additional Documents</h3>
<p className="text-sm" style={{marginTop:'2px'}}>Upload any supplementary business documents</p>
</div>
<label className="btn btn-secondary btn-sm" style={{borderRadius:'var(--radius-sm)', cursor:'pointer'}}>
+ Choose Files
<input type="file" multiple hidden accept=".pdf,.jpg,.jpeg,.png,.webp,.doc,.docx,.xls,.xlsx" onChange={handleExtraUpload} />
</label>
</div>
<div className="drop-area" style={{ border:'2px dashed #b8cfdf', borderRadius:'var(--radius-md)', padding:'28px 20px', textAlign:'center', cursor:'pointer', background:'var(--card)' }} onClick={() => extraFileRef.current?.click()}>
<div className="da-icon"><span className="material-symbols-outlined" style={{color: '#ffca28', fontSize: '32px'}}>folder</span></div>
<div className="da-title" style={{fontWeight: 600, color: 'var(--navy)', fontSize: '14px'}}>Drag & drop files here</div>
<div className="da-hint" style={{fontSize: '12px', color: 'var(--muted)'}}>or click to browse · PDF, JPG, PNG, WEBP, DOC, EXCEL · Max 10MB</div>
</div>
<input type="file" multiple hidden ref={extraFileRef} onChange={handleExtraUpload} />
<div className="upload-track mt-12">
{docs.filter(d => d.doc_type === "other").map(doc => (
<div key={doc.id} className="upload-track-item" style={{display:'flex', alignItems:'center', gap:'10px', padding:'8px 12px', borderRadius:'var(--radius-sm)', background:'#f5f8fb', fontSize:'13px', marginBottom:'6px'}}>
<span className="material-symbols-outlined" style={{color:'var(--green)', fontSize:'18px'}}>check_circle</span>
<div className="uti-name" style={{flex:1}}>{doc.filename}</div>
<button className="btn btn-secondary btn-sm" style={{padding:'4px'}} onClick={() => viewDoc(doc.storage_key)}>
<span className="material-symbols-outlined" style={{fontSize:'16px'}}>visibility</span>
</button>
<button className="btn btn-danger btn-sm" style={{padding:'4px'}} onClick={() => deleteDoc(doc.id)}>
<span className="material-symbols-outlined" style={{fontSize:'16px'}}>delete</span>
</button>
</div>
))}
</div>
</div>
<div className="card mt-20" style={{marginTop: '20px'}}>
<div style={{display:'flex', alignItems:'center', justifyContent:'space-between', flexWrap:'wrap', gap:'16px'}}>
<div>
<h3 style={{marginBottom:'4px'}}>Finished Uploading?</h3>
<p className="text-sm" style={{margin:0}}>Notify your accountant that your business documents are ready for review.</p>
</div>
<button className="btn btn-primary" onClick={notifyComplete}>
<span className="material-symbols-outlined">send</span>
Notify Admin: Uploads Complete
</button>
</div>
</div>
</div>
);
}
+251
View File
@@ -0,0 +1,251 @@
import { useEffect, useState, useRef } from 'react';
import { Link } from 'react-router-dom';
import { useAuth } from '../context/AuthContext';
import { useToast } from '../context/ToastContext';
export default function UploadPersonal() {
const { authFetch } = useAuth();
const { showToast } = useToast();
const [taxYear, setTaxYear] = useState(new Date().getFullYear());
const [docs, setDocs] = useState([]);
const [templates, setTemplates] = useState([]);
const [loading, setLoading] = useState(false);
const fileInputRefs = useRef({});
const extraFileRef = useRef(null);
useEffect(() => {
fetchTemplatesAndDocs();
}, [taxYear]);
const fetchTemplatesAndDocs = async () => {
setLoading(true);
try {
// Fetch required templates
const tplRes = await authFetch(`/api/upload/templates?category=personal&tax_year=${taxYear}`);
if (tplRes.ok) {
setTemplates(await tplRes.json());
}
// Fetch user's uploaded documents
const docRes = await authFetch(`/api/upload/personal-documents?tax_year=${taxYear}`);
if (docRes.ok) {
setDocs(await docRes.json());
}
} catch (err) {
console.error(err);
} finally {
setLoading(false);
}
};
const uploadFile = async (file, docType) => {
if (file.size > 10 * 1024 * 1024) {
showToast("File size exceeds 10MB limit", "error");
return;
}
const fd = new FormData();
fd.append("file", file);
fd.append("tax_year", taxYear);
fd.append("doc_type", docType);
try {
const res = await authFetch("/api/upload/personal-documents", {
method: "POST",
body: fd
});
if (res.ok) {
showToast("Document uploaded successfully", "success");
fetchTemplatesAndDocs();
} else {
const data = await res.json().catch(() => ({}));
showToast(data.detail || "Upload failed", "error");
}
} catch (err) {
showToast("Upload failed due to network error", "error");
}
};
const deleteDoc = async (id) => {
if (!window.confirm("Delete this document?\nThis action cannot be undone.")) return;
try {
const res = await authFetch(`/api/upload/personal-documents/${id}`, { method: "DELETE" });
if (res.ok) {
showToast("Document deleted", "success");
fetchTemplatesAndDocs();
} else {
showToast("Delete failed", "error");
}
} catch (err) {
showToast("Delete failed", "error");
}
};
const viewDoc = async (storageKey) => {
try {
const res = await authFetch(`/api/upload/view-url?key=${encodeURIComponent(storageKey)}`);
if (res.ok) {
const data = await res.json();
window.open(data.url, "_blank");
} else {
showToast("Could not generate view link", "error");
}
} catch (err) {
showToast("Could not generate view link", "error");
}
};
const handleExtraUpload = async (e) => {
const files = Array.from(e.target.files);
for (let file of files) {
if (file.size > 10 * 1024 * 1024) {
showToast(`File ${file.name} exceeds 10MB limit`, "error");
continue;
}
await uploadFile(file, "other");
}
e.target.value = "";
};
const notifyComplete = async () => {
try {
const res = await authFetch("/api/upload/notify-upload-complete", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ file_count: docs.length, doc_category: "Personal" })
});
if (res.ok) {
showToast("Admin notified successfully", "success");
} else {
showToast("Failed to notify admin", "error");
}
} catch (err) {
showToast("Error notifying admin", "error");
}
};
const years = [new Date().getFullYear(), new Date().getFullYear() - 1, new Date().getFullYear() - 2];
return (
<div>
<div style={{marginBottom: '16px'}}>
<Link to="/dashboard" className="fancy-link" style={{fontSize: '14px', fontWeight: 500}}>← Back to Dashboard</Link>
</div>
<div className="page-heading">
<div>
<h1>Personal Documents</h1>
<p className="page-meta">Upload your personal tax documents securely</p>
</div>
<div style={{display:'flex', flexDirection:'column', alignItems:'flex-end', gap:'4px'}}>
<label className="form-label" style={{margin:0}}>Tax Year</label>
<select
className="select-input"
style={{width:'auto', padding:'8px 14px'}}
value={taxYear}
onChange={(e) => setTaxYear(e.target.value)}
>
{years.map(y => <option key={y} value={y}>{y}</option>)}
</select>
</div>
</div>
<div className="card" style={{marginBottom: '20px'}}>
<h3 style={{marginBottom: '16px'}}>Required Documents</h3>
<div id="docWrapper">
{loading ? (
<div className="empty-state">Loading templates...</div>
) : templates.length === 0 ? (
<div className="empty-state">No required documents for this tax year.</div>
) : templates.map((dt, i) => {
const uploaded = docs.filter(d => d.doc_type === dt.name);
return (
<div className="doc-slot fade-up" key={i} style={{ animationDelay: `${i * 0.04}s` }}>
<div className="doc-slot-info">
<div className="doc-slot-name">{i+1}. {dt.name}</div>
<div className="doc-slot-status">
{uploaded.length ? (
<span className="pill-pending"><span className="material-symbols-outlined">pending</span> Pending Review</span>
) : (
"Missing"
)}
</div>
</div>
<div className="doc-slot-actions">
<input
type="file"
hidden
accept=".pdf,.jpg,.jpeg,.png,.webp,.doc,.docx"
ref={el => fileInputRefs.current[dt.name] = el}
onChange={(e) => e.target.files[0] && uploadFile(e.target.files[0], dt.name)}
/>
<div style={{display: 'flex', gap: '8px', alignItems: 'center'}}>
{dt.download && (
<a href={dt.download} target="_blank" rel="noreferrer" className="btn btn-secondary btn-sm" style={{borderRadius: 'var(--radius-pill)', padding: '4px 12px', display: 'flex', alignItems: 'center', gap: '4px'}}>
<span className="material-symbols-outlined" style={{fontSize: '16px'}}>download</span> Template
</a>
)}
{!uploaded.length && (
<button className="btn btn-sm btn-upload-pill" onClick={() => fileInputRefs.current[dt.name].click()}>Upload</button>
)}
</div>
{uploaded.map(doc => (
<div key={doc.id} style={{display:'flex', gap:'8px'}}>
<button className="btn btn-secondary btn-xs" style={{borderRadius:'var(--radius-sm)'}} onClick={() => viewDoc(doc.storage_key)}>View</button>
<button className="btn btn-danger btn-xs" style={{borderRadius:'var(--radius-sm)'}} onClick={() => deleteDoc(doc.id)}>Delete</button>
</div>
))}
</div>
</div>
);
})}
</div>
</div>
<div className="card">
<div className="flex-between" style={{marginBottom: '16px'}}>
<div>
<h3>Additional Documents</h3>
<p className="text-sm" style={{marginTop:'2px'}}>Upload any supplementary personal documents</p>
</div>
<label className="btn btn-secondary btn-sm" style={{borderRadius:'var(--radius-sm)', cursor:'pointer'}}>
+ Choose Files
<input type="file" multiple hidden accept=".pdf,.jpg,.jpeg,.png,.webp,.doc,.docx" onChange={handleExtraUpload} />
</label>
</div>
<div className="drop-area" style={{ border:'2px dashed #b8cfdf', borderRadius:'var(--radius-md)', padding:'28px 20px', textAlign:'center', cursor:'pointer', background:'var(--card)' }} onClick={() => extraFileRef.current?.click()}>
<div className="da-icon"><span className="material-symbols-outlined" style={{color: '#ffca28', fontSize: '32px'}}>folder</span></div>
<div className="da-title" style={{fontWeight: 600, color: 'var(--navy)', fontSize: '14px'}}>Drag & drop files here</div>
<div className="da-hint" style={{fontSize: '12px', color: 'var(--muted)'}}>or click to browse · PDF, JPG, PNG, WEBP, DOC, DOCX · Max 10MB</div>
</div>
<input type="file" multiple hidden ref={extraFileRef} onChange={handleExtraUpload} />
<div className="upload-track mt-12">
{docs.filter(d => d.doc_type === "other").map(doc => (
<div key={doc.id} className="upload-track-item" style={{display:'flex', alignItems:'center', gap:'10px', padding:'8px 12px', borderRadius:'var(--radius-sm)', background:'#f5f8fb', fontSize:'13px', marginBottom:'6px'}}>
<span className="material-symbols-outlined" style={{color:'var(--green)', fontSize:'18px'}}>check_circle</span>
<div className="uti-name" style={{flex:1}}>{doc.filename}</div>
<button className="btn btn-secondary btn-sm" style={{padding:'4px'}} onClick={() => viewDoc(doc.storage_key)}>
<span className="material-symbols-outlined" style={{fontSize:'16px'}}>visibility</span>
</button>
<button className="btn btn-danger btn-sm" style={{padding:'4px'}} onClick={() => deleteDoc(doc.id)}>
<span className="material-symbols-outlined" style={{fontSize:'16px'}}>delete</span>
</button>
</div>
))}
</div>
</div>
<div className="card mt-20" style={{marginTop: '20px'}}>
<div style={{display:'flex', alignItems:'center', justifyContent:'space-between', flexWrap:'wrap', gap:'16px'}}>
<div>
<h3 style={{marginBottom:'4px'}}>Finished Uploading?</h3>
<p className="text-sm" style={{margin:0}}>Notify your accountant that your personal documents are ready for review.</p>
</div>
<button className="btn btn-primary" onClick={notifyComplete}>
<span className="material-symbols-outlined">send</span>
Notify Admin: Uploads Complete
</button>
</div>
</div>
</div>
);
}
+218
View File
@@ -0,0 +1,218 @@
import { useState, useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { useAuth } from '../context/AuthContext';
import { useToast } from '../context/ToastContext';
export default function UserDashboard() {
const { user, authFetch } = useAuth();
const { showToast } = useToast();
const navigate = useNavigate();
const [engagementChecked, setEngagementChecked] = useState(false);
const [engagementDisabled, setEngagementDisabled] = useState(false);
const [adminDocs, setAdminDocs] = useState([]);
const [loadingDocs, setLoadingDocs] = useState(false);
const [docLoading, setDocLoading] = useState(false);
useEffect(() => {
checkEngagement();
loadAdminDocs();
}, []);
const checkEngagement = async () => {
try {
const res = await authFetch("/api/auth/me");
if (res.ok) {
const data = await res.json();
if (data.engagement_acknowledged_at) {
setEngagementChecked(true);
setEngagementDisabled(true);
}
}
} catch (err) {
console.error(err);
}
};
const handleEngagementChange = async (e) => {
const isChecked = e.target.checked;
if (!isChecked) {
// Don't allow unchecking
setEngagementChecked(true);
return;
}
try {
setEngagementChecked(true);
const res = await authFetch("/api/auth/acknowledge-engagement", { method: "POST" });
if (res.ok) {
showToast("Engagement Letter acknowledged successfully", "success");
setEngagementDisabled(true);
} else {
setEngagementChecked(false);
}
} catch (err) {
setEngagementChecked(false);
}
};
const loadAdminDocs = async () => {
setLoadingDocs(true);
try {
const res = await authFetch("/api/upload/admin-documents");
if (res.ok) {
setAdminDocs(await res.json());
}
} catch (err) {
console.error(err);
} finally {
setLoadingDocs(false);
}
};
const viewDoc = async (storageKey) => {
try {
const res = await authFetch(`/api/upload/view-url?key=${encodeURIComponent(storageKey)}`);
if (res.ok) {
const data = await res.json();
window.open(data.url, "_blank");
} else {
showToast("Could not generate view link", "error");
}
} catch (err) {
showToast("Could not generate view link", "error");
}
};
const respondDoc = async (docId, approved) => {
if (docLoading) return;
let reason = "";
if (!approved) {
reason = window.prompt("Reason for rejection:");
if (reason === null) return;
}
setDocLoading(true);
try {
const res = await authFetch("/api/review/admin-doc-response", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ doc_id: docId, status: approved ? "approved" : "rejected", reason })
});
if (res.ok) {
showToast(`Document ${approved ? 'approved' : 'rejected'} successfully`, "success");
} else {
showToast("Failed to submit response", "error");
}
} catch (err) {
showToast("Network error", "error");
} finally {
setDocLoading(false);
}
};
return (
<div>
<div className="page-heading">
<div>
<h1>Welcome, {user?.name || user?.email?.split('@')[0]}</h1>
<p className="page-meta">Here is your dashboard overview</p>
</div>
</div>
<div className="card fade-up">
<h3 style={{marginBottom: '16px'}}>Engagement Letter</h3>
<p className="text-sm" style={{marginBottom: '16px'}}>Please acknowledge the engagement letter before uploading documents.</p>
<div style={{
display: 'flex', alignItems: 'center', gap: '12px', padding: '16px',
background: 'var(--bg)', borderRadius: 'var(--radius-sm)', border: '1px solid var(--border)'
}}>
<input
type="checkbox"
checked={engagementChecked}
disabled={engagementDisabled}
onChange={handleEngagementChange}
style={{width:'20px', height:'20px', cursor: engagementDisabled ? 'not-allowed' : 'pointer'}}
/>
<div>
<div style={{fontWeight: 600, color: 'var(--navy)'}}>I acknowledge the Engagement Letter</div>
<div style={{fontSize: '13px', color: 'var(--muted)', marginTop: '2px'}}>By checking this, you agree to our terms of service for the current tax year.</div>
</div>
</div>
</div>
<div style={{display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(280px, 1fr))', gap: '20px', marginTop: '20px'}}>
<div className="card fade-up" style={{animationDelay: '0.1s'}}>
<div style={{display:'flex', alignItems:'center', gap:'12px', marginBottom: '12px'}}>
<span className="material-symbols-outlined" style={{color:'var(--accent)', fontSize:'28px'}}>description</span>
<h3 style={{margin:0}}>Personal Documents</h3>
</div>
<p className="text-sm text-muted" style={{marginBottom: '20px', minHeight: '40px'}}>Upload your W-2s, 1099s, IDs, and other individual tax forms.</p>
<button
className="btn btn-primary w-full"
disabled={!engagementChecked}
onClick={() => navigate('/upload-personal')}
>
Go to Personal Upload
</button>
</div>
<div className="card fade-up" style={{animationDelay: '0.2s'}}>
<div style={{display:'flex', alignItems:'center', gap:'12px', marginBottom: '12px'}}>
<span className="material-symbols-outlined" style={{color:'var(--orange)', fontSize:'28px'}}>business</span>
<h3 style={{margin:0}}>Business Documents</h3>
</div>
<p className="text-sm text-muted" style={{marginBottom: '20px', minHeight: '40px'}}>Upload corporate documents, bookkeeping ledgers, and business receipts.</p>
<button
className="btn btn-primary w-full"
disabled={!engagementChecked}
onClick={() => navigate('/upload-business')}
>
Go to Business Upload
</button>
</div>
</div>
<div className="card fade-up" style={{animationDelay: '0.3s', marginTop: '20px'}}>
<h3 style={{marginBottom: '16px'}}>Admin Returns / Documents</h3>
<p className="text-sm" style={{marginBottom: '16px'}}>Documents and tax returns finalized by the admin.</p>
{loadingDocs ? (
<div className="empty-state">Loading documents...</div>
) : adminDocs.length === 0 ? (
<div className="empty-state">No documents have been provided by the admin yet.</div>
) : (
<div className="table-responsive">
<table className="admin-table">
<thead>
<tr>
<th>Document Name</th>
<th>Date Provided</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{adminDocs.map(doc => (
<tr key={doc.id}>
<td>
<div style={{fontWeight: 500, color: 'var(--navy)'}}>{doc.doc_label}</div>
<div className="text-sm text-muted">{doc.filename}</div>
</td>
<td>{new Date(doc.created_at).toLocaleDateString()}</td>
<td>
<div style={{display:'flex', gap:'8px'}}>
<button className="btn btn-secondary btn-sm" onClick={() => viewDoc(doc.storage_key)}>View</button>
<button className="btn btn-primary btn-sm" onClick={() => respondDoc(doc.id, true)} disabled={docLoading}>Approve</button>
<button className="btn btn-danger btn-sm" onClick={() => respondDoc(doc.id, false)} disabled={docLoading}>Reject</button>
</div>
</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</div>
</div>
);
}
+107
View File
@@ -0,0 +1,107 @@
import { useState, useEffect } from 'react';
import { useSearchParams, Link } from 'react-router-dom';
export default function VerifyEmail() {
const [searchParams] = useSearchParams();
const token = searchParams.get('token');
const [status, setStatus] = useState('verifying'); // verifying, success, failed, invalid
const [message, setMessage] = useState('');
useEffect(() => {
if (!token) {
setStatus('invalid');
return;
}
const verify = async () => {
try {
const res = await fetch(`/api/auth/verify-email?token=${encodeURIComponent(token)}`);
const data = await res.json();
if (res.ok && (data.message === "verified" || data.message === "already_verified")) {
setStatus('success');
setMessage(data.message === "already_verified" ? "Already Verified" : "Email Verified!");
} else {
setStatus('failed');
setMessage(data.detail || "This link is invalid or has expired.");
}
} catch (err) {
setStatus('failed');
setMessage("Could not connect to the server. Please try again later.");
}
};
verify();
}, [token]);
return (
<div className="auth-shell page-enter">
<div className="auth-brand">
<img className="brand-logo" src="/images/bookkeeppro-logo.webp" alt="BookKeepPro"/>
<div className="brand-divider"></div>
<h2>Almost There</h2>
<p>We're verifying your email address right now.</p>
</div>
<div className="auth-form-side">
<div className="auth-box text-center">
{status === 'verifying' && (
<>
<div style={{fontSize:'48px', marginBottom:'16px'}}>
<span className="material-symbols-outlined">pending</span>
</div>
<h2>Verifying your email...</h2>
<p className="auth-subtitle">Please wait a moment.</p>
</>
)}
{status === 'invalid' && (
<>
<div style={{fontSize:'48px', marginBottom:'16px'}}>
<span className="material-symbols-outlined">cancel</span>
</div>
<h2>Invalid Link</h2>
<p className="auth-subtitle">This verification link is missing a token.<br/>Please use the link from your email.</p>
<Link to="/login" className="btn btn-primary" style={{borderRadius:'var(--radius-sm)', marginTop:'24px', display:'inline-flex'}}>
Go to Sign In
</Link>
</>
)}
{status === 'success' && (
<>
<div style={{fontSize:'48px', marginBottom:'16px', color:'var(--green)'}}>
<span className="material-symbols-outlined">check_circle</span>
</div>
<h2>{message}</h2>
<p className="auth-subtitle">
{message === "Already Verified"
? "Your email is already verified. You can sign in below."
: "Your email has been verified. You can now sign in to your account."}
</p>
<Link to="/login" className="btn btn-primary" style={{borderRadius:'var(--radius-sm)', marginTop:'24px', display:'inline-flex'}}>
Sign In
</Link>
</>
)}
{status === 'failed' && (
<>
<div style={{fontSize:'48px', marginBottom:'16px', color:'var(--error)'}}>
<span className="material-symbols-outlined">cancel</span>
</div>
<h2>Verification Failed</h2>
<p className="auth-subtitle">{message}</p>
<Link to="/resend-verification" className="btn btn-primary" style={{borderRadius:'var(--radius-sm)', marginTop:'24px', display:'inline-flex'}}>
Request New Link
</Link>
</>
)}
</div>
</div>
</div>
);
}