This commit is contained in:
Shubhankar45
2026-11-13 12:14:55 +00:00
commit 53dbfa976b
191 changed files with 12074 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
# Backend that the Vite dev server proxies /api and /media to
VITE_BACKEND_URL=http://127.0.0.1:8020
# API base path used by the browser (leave as /api when using the dev proxy)
VITE_API_BASE_URL=/api
+24
View File
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
+8
View File
@@ -0,0 +1,8 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["react", "oxc"],
"rules": {
"react/rules-of-hooks": "error",
"react/only-export-components": ["warn", { "allowConstantExport": true }]
}
}
+16
View File
@@ -0,0 +1,16 @@
# React + Vite
This template provides a minimal setup to get React working in Vite with HMR and some Oxlint rules.
Currently, two official plugins are available:
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
## React Compiler
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
## Expanding the Oxlint configuration
If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and Oxlint's TypeScript related rules in your project.
+15
View File
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Saura Shakti — rooftop and on-grid solar for homes, businesses and farms, supported by the PM Surya Ghar subsidy." />
<meta name="theme-color" content="#010F1C" />
<title>Saura Shakti — Rooftop Solar</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
+2286
View File
File diff suppressed because it is too large Load Diff
+32
View File
@@ -0,0 +1,32 @@
{
"name": "frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "oxlint",
"preview": "vite preview"
},
"dependencies": {
"@fontsource/inter": "^5.3.0",
"@fontsource/manrope": "^5.3.0",
"@fontsource/poppins": "^5.3.0",
"axios": "^1.21.1",
"framer-motion": "^14.13.0",
"lucide-react": "^1.72.0",
"react": "^19.3.1",
"react-dom": "^19.3.1",
"react-router-dom": "^7.18.5"
},
"devDependencies": {
"@tailwindcss/vite": "^4.3.5",
"@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0",
"@vitejs/plugin-react": "^6.1.2",
"oxlint": "^1.90.0",
"tailwindcss": "^4.3.5",
"vite": "^8.3.6"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.3 KiB

+24
View File
@@ -0,0 +1,24 @@
<svg xmlns="http://www.w3.org/2000/svg">
<symbol id="bluesky-icon" viewBox="0 0 16 17">
<g clip-path="url(#bluesky-clip)"><path fill="#08060d" d="M7.75 7.735c-.693-1.348-2.58-3.86-4.334-5.097-1.68-1.187-2.32-.981-2.74-.79C.188 2.065.1 2.812.1 3.251s.241 3.602.398 4.13c.52 1.744 2.367 2.333 4.07 2.145-2.495.37-4.71 1.278-1.805 4.512 3.196 3.309 4.38-.71 4.987-2.746.608 2.036 1.307 5.91 4.93 2.746 2.72-2.746.747-4.143-1.747-4.512 1.702.189 3.55-.4 4.07-2.145.156-.528.397-3.691.397-4.13s-.088-1.186-.575-1.406c-.42-.19-1.06-.395-2.741.79-1.755 1.24-3.64 3.752-4.334 5.099"/></g>
<defs><clipPath id="bluesky-clip"><path fill="#fff" d="M.1.85h15.3v15.3H.1z"/></clipPath></defs>
</symbol>
<symbol id="discord-icon" viewBox="0 0 20 19">
<path fill="#08060d" d="M16.224 3.768a14.5 14.5 0 0 0-3.67-1.153c-.158.286-.343.67-.47.976a13.5 13.5 0 0 0-4.067 0c-.128-.306-.317-.69-.476-.976A14.4 14.4 0 0 0 3.868 3.77C1.546 7.28.916 10.703 1.231 14.077a14.7 14.7 0 0 0 4.5 2.306q.545-.748.965-1.587a9.5 9.5 0 0 1-1.518-.74q.191-.14.372-.293c2.927 1.369 6.107 1.369 8.999 0q.183.152.372.294-.723.437-1.52.74.418.838.963 1.588a14.6 14.6 0 0 0 4.504-2.308c.37-3.911-.63-7.302-2.644-10.309m-9.13 8.234c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.894 0 1.614.82 1.599 1.82.001 1-.705 1.82-1.6 1.82m5.91 0c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.893 0 1.614.82 1.599 1.82 0 1-.706 1.82-1.6 1.82"/>
</symbol>
<symbol id="documentation-icon" viewBox="0 0 21 20">
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="m15.5 13.333 1.533 1.322c.645.555.967.833.967 1.178s-.322.623-.967 1.179L15.5 18.333m-3.333-5-1.534 1.322c-.644.555-.966.833-.966 1.178s.322.623.966 1.179l1.534 1.321"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M17.167 10.836v-4.32c0-1.41 0-2.117-.224-2.68-.359-.906-1.118-1.621-2.08-1.96-.599-.21-1.349-.21-2.848-.21-2.623 0-3.935 0-4.983.369-1.684.591-3.013 1.842-3.641 3.428C3 6.449 3 7.684 3 10.154v2.122c0 2.558 0 3.838.706 4.726q.306.383.713.671c.76.536 1.79.64 3.581.66"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M3 10a2.78 2.78 0 0 1 2.778-2.778c.555 0 1.209.097 1.748-.047.48-.129.854-.503.982-.982.145-.54.048-1.194.048-1.749a2.78 2.78 0 0 1 2.777-2.777"/>
</symbol>
<symbol id="github-icon" viewBox="0 0 19 19">
<path fill="#08060d" fill-rule="evenodd" d="M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844" clip-rule="evenodd"/>
</symbol>
<symbol id="social-icon" viewBox="0 0 20 20">
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M12.5 6.667a4.167 4.167 0 1 0-8.334 0 4.167 4.167 0 0 0 8.334 0"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M2.5 16.667a5.833 5.833 0 0 1 8.75-5.053m3.837.474.513 1.035c.07.144.257.282.414.309l.93.155c.596.1.736.536.307.965l-.723.73a.64.64 0 0 0-.152.531l.207.903c.164.715-.213.991-.84.618l-.872-.52a.63.63 0 0 0-.577 0l-.872.52c-.624.373-1.003.094-.84-.618l.207-.903a.64.64 0 0 0-.152-.532l-.723-.729c-.426-.43-.289-.864.306-.964l.93-.156a.64.64 0 0 0 .412-.31l.513-1.034c.28-.562.735-.562 1.012 0"/>
</symbol>
<symbol id="x-icon" viewBox="0 0 19 19">
<path fill="#08060d" fill-rule="evenodd" d="M1.893 1.98c.052.072 1.245 1.769 2.653 3.77l2.892 4.114c.183.261.333.48.333.486s-.068.089-.152.183l-.522.593-.765.867-3.597 4.087c-.375.426-.734.834-.798.905a1 1 0 0 0-.118.148c0 .01.236.017.664.017h.663l.729-.83c.4-.457.796-.906.879-.999a692 692 0 0 0 1.794-2.038c.034-.037.301-.34.594-.675l.551-.624.345-.392a7 7 0 0 1 .34-.374c.006 0 .93 1.306 2.052 2.903l2.084 2.965.045.063h2.275c1.87 0 2.273-.003 2.266-.021-.008-.02-1.098-1.572-3.894-5.547-2.013-2.862-2.28-3.246-2.273-3.266.008-.019.282-.332 2.085-2.38l2-2.274 1.567-1.782c.022-.028-.016-.03-.65-.03h-.674l-.3.342a871 871 0 0 1-1.782 2.025c-.067.075-.405.458-.75.852a100 100 0 0 1-.803.91c-.148.172-.299.344-.99 1.127-.304.343-.32.358-.345.327-.015-.019-.904-1.282-1.976-2.808L6.365 1.85H1.8zm1.782.91 8.078 11.294c.772 1.08 1.413 1.973 1.425 1.984.016.017.241.02 1.05.017l1.03-.004-2.694-3.766L7.796 5.75 5.722 2.852l-1.039-.004-1.039-.004z" clip-rule="evenodd"/>
</symbol>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

+57
View File
@@ -0,0 +1,57 @@
import { lazy, Suspense } from 'react'
import { Route, Routes } from 'react-router-dom'
import { ContentProvider } from './context/ContentContext'
import { LeadModalProvider } from './context/LeadModalContext'
import { Spinner } from './components/ui'
import HomePage from './pages/HomePage'
import PublicLayout from './layouts/PublicLayout'
import ProjectsPage from './pages/ProjectsPage'
import ProjectDetailPage from './pages/ProjectDetailPage'
import LegalPage, { NotFoundPage } from './pages/LegalPage'
// Admin dashboard is code-split so public visitors never download it.
const AdminApp = lazy(() => import('./admin/AdminApp'))
function PublicSite({ children }) {
return (
<ContentProvider>
<LeadModalProvider>{children}</LeadModalProvider>
</ContentProvider>
)
}
export default function App() {
return (
<Routes>
<Route
path="/admin/*"
element={
<Suspense fallback={<div className="grid min-h-dvh place-items-center text-brand"><Spinner className="size-8" /></div>}>
<AdminApp />
</Suspense>
}
/>
<Route
path="/"
element={
<PublicSite>
<HomePage />
</PublicSite>
}
/>
<Route
element={
<PublicSite>
<PublicLayout />
</PublicSite>
}
>
<Route path="/projects" element={<ProjectsPage />} />
<Route path="/projects/:slug" element={<ProjectDetailPage />} />
<Route path="/terms" element={<LegalPage kind="terms" />} />
<Route path="/privacy" element={<LegalPage kind="privacy" />} />
<Route path="*" element={<NotFoundPage />} />
</Route>
</Routes>
)
}
+57
View File
@@ -0,0 +1,57 @@
import { Navigate, Route, Routes, useLocation } from 'react-router-dom'
import { AuthProvider, useAuth } from '../context/AuthContext'
import { FeedbackProvider, LoadingBlock } from './components/feedback'
import AdminLayout from './layouts/AdminLayout'
import LoginPage from './pages/LoginPage'
import DashboardPage from './pages/DashboardPage'
import EnquiriesPage from './pages/EnquiriesPage'
import EnquiryDetailPage from './pages/EnquiryDetailPage'
import ProjectsPage from './pages/ProjectsPage'
import ProjectEditorPage from './pages/ProjectEditorPage'
import ServicesPage from './pages/ServicesPage'
import TestimonialsPage from './pages/TestimonialsPage'
import MessagesPage from './pages/MessagesPage'
import SubscribersPage from './pages/SubscribersPage'
import ContentPage from './pages/ContentPage'
import UsersPage from './pages/UsersPage'
function RequireAuth({ children }) {
const { admin, loading } = useAuth()
const location = useLocation()
if (loading) return <div className="grid min-h-dvh place-items-center bg-surface"><LoadingBlock /></div>
if (!admin) return <Navigate to="/admin/login" replace state={{ from: location.pathname }} />
return children
}
export default function AdminApp() {
return (
<AuthProvider>
<FeedbackProvider>
<Routes>
<Route path="login" element={<LoginPage />} />
<Route
element={
<RequireAuth>
<AdminLayout />
</RequireAuth>
}
>
<Route index element={<DashboardPage />} />
<Route path="enquiries" element={<EnquiriesPage />} />
<Route path="enquiries/:id" element={<EnquiryDetailPage />} />
<Route path="projects" element={<ProjectsPage />} />
<Route path="projects/new" element={<ProjectEditorPage />} />
<Route path="projects/:id" element={<ProjectEditorPage />} />
<Route path="services" element={<ServicesPage />} />
<Route path="testimonials" element={<TestimonialsPage />} />
<Route path="messages" element={<MessagesPage />} />
<Route path="subscribers" element={<SubscribersPage />} />
<Route path="content" element={<ContentPage />} />
<Route path="users" element={<UsersPage />} />
<Route path="*" element={<Navigate to="/admin" replace />} />
</Route>
</Routes>
</FeedbackProvider>
</AuthProvider>
)
}
@@ -0,0 +1,100 @@
import { useRef, useState } from 'react'
import { ImagePlus, Stamp } from 'lucide-react'
import api, { errorMessage } from '../../services/api'
const ACCEPT = ['image/jpeg', 'image/png', 'image/webp']
const EXT = /\.(jpe?g|png|webp)$/i
const MAX_MB = 10
/**
* Drag & drop / click uploader. Validates type and size client-side (the server
* re-validates everything), shows upload progress, and reports the response.
*/
export default function ImageUploader({ url, field = 'files', multiple = true, onUploaded, onError, compact = false }) {
const inputRef = useRef(null)
const [drag, setDrag] = useState(false)
const [progress, setProgress] = useState(null)
const [problems, setProblems] = useState([])
const upload = async (fileList) => {
const files = Array.from(fileList || [])
if (!files.length) return
const bad = []
const good = files.filter((f) => {
if (!ACCEPT.includes(f.type) && !EXT.test(f.name)) return bad.push(`${f.name}: only JPG, PNG or WEBP`) && false
if (f.size > MAX_MB * 1024 * 1024) return bad.push(`${f.name}: larger than ${MAX_MB} MB`) && false
return true
})
setProblems(bad)
if (!good.length) return
const form = new FormData()
;(multiple ? good : good.slice(0, 1)).forEach((f) => form.append(field, f))
setProgress(0)
try {
const res = await api.post(url, form, {
onUploadProgress: (e) => e.total && setProgress(Math.round((e.loaded / e.total) * 100)),
timeout: 180000,
})
onUploaded?.(res.data)
} catch (e) {
const msg = errorMessage(e, 'Upload failed.')
setProblems((p) => [...p, msg])
onError?.(msg)
} finally {
setProgress(null)
if (inputRef.current) inputRef.current.value = ''
}
}
const busy = progress !== null
return (
<div>
<div
role="button"
tabIndex={0}
onClick={() => !busy && inputRef.current?.click()}
onKeyDown={(e) => (e.key === 'Enter' || e.key === ' ') && !busy && inputRef.current?.click()}
onDragOver={(e) => {
e.preventDefault()
setDrag(true)
}}
onDragLeave={() => setDrag(false)}
onDrop={(e) => {
e.preventDefault()
setDrag(false)
if (!busy) upload(e.dataTransfer.files)
}}
className={`flex cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed text-center transition ${compact ? 'px-4 py-6' : 'px-6 py-10'} ${
drag ? 'border-brand bg-brand/5' : 'border-[#D0D5DD] bg-surface hover:border-brand/60'
} ${busy ? 'cursor-wait' : ''}`}
aria-label="Upload images"
>
<ImagePlus className="size-8 text-brand" strokeWidth={1.5} />
{busy ? (
<div className="mt-3 w-full max-w-xs">
<p className="text-[14px] font-semibold text-navy">{progress < 100 ? `Uploading… ${progress}%` : 'Adding watermark & thumbnails…'}</p>
<div className="mt-2 h-2 overflow-hidden rounded-full bg-[#E4E7EC]">
<div className="h-full bg-brand transition-all" style={{ width: `${progress}%` }} />
</div>
</div>
) : (
<>
<p className="mt-3 text-[14px] font-semibold text-navy">
{multiple ? 'Drop photos here or click to choose' : 'Drop a photo here or click to choose'}
</p>
<p className="mt-1 text-[12px] text-slate">JPG, PNG or WEBP · up to {MAX_MB} MB{multiple ? ' each · up to 20 at once' : ''}</p>
<p className="mt-2 inline-flex items-center gap-1.5 text-[12px] font-medium text-[#067647]">
<Stamp className="size-3.5" /> Saura Shakti watermark is added automatically
</p>
</>
)}
<input ref={inputRef} type="file" accept=".jpg,.jpeg,.png,.webp,image/jpeg,image/png,image/webp" multiple={multiple} className="hidden" onChange={(e) => upload(e.target.files)} />
</div>
{problems.length > 0 && (
<ul className="mt-3 space-y-1 rounded-xl bg-[#FEF3F2] px-4 py-3 text-[13px] text-[#912018]" role="alert">
{problems.map((p) => <li key={p}>{p}</li>)}
</ul>
)}
</div>
)
}
+111
View File
@@ -0,0 +1,111 @@
import { createContext, useCallback, useContext, useMemo, useRef, useState } from 'react'
import { AnimatePresence, motion } from 'framer-motion'
import { AlertTriangle, CheckCircle2, X, XCircle } from 'lucide-react'
import Modal from '../../components/Modal'
import { Spinner } from '../../components/ui'
const FeedbackContext = createContext(null)
export function FeedbackProvider({ children }) {
const [toasts, setToasts] = useState([])
const [confirmState, setConfirmState] = useState(null)
const idRef = useRef(0)
const toast = useCallback((message, type = 'success') => {
const id = ++idRef.current
setToasts((t) => [...t, { id, message, type }])
setTimeout(() => setToasts((t) => t.filter((x) => x.id !== id)), type === 'error' ? 6000 : 3500)
}, [])
/** confirm({title, message, confirmLabel, danger}) → Promise<boolean> */
const confirm = useCallback(
(opts) => new Promise((resolve) => setConfirmState({ ...opts, resolve })),
[],
)
const value = useMemo(() => ({ toast, confirm }), [toast, confirm])
const closeConfirm = (result) => {
confirmState?.resolve(result)
setConfirmState(null)
}
return (
<FeedbackContext.Provider value={value}>
{children}
<div className="pointer-events-none fixed right-4 bottom-4 z-[200] flex w-[min(380px,calc(100vw-2rem))] flex-col gap-2" aria-live="polite">
<AnimatePresence>
{toasts.map((t) => (
<motion.div
key={t.id}
initial={{ opacity: 0, y: 12, scale: 0.98 }}
animate={{ opacity: 1, y: 0, scale: 1 }}
exit={{ opacity: 0, x: 40 }}
className={`pointer-events-auto flex items-start gap-3 rounded-xl px-4 py-3 text-[14px] font-medium shadow-lg ring-1 ${
t.type === 'error' ? 'bg-[#FEF3F2] text-[#912018] ring-[#FECDCA]' : 'bg-white text-navy ring-line'
}`}
role={t.type === 'error' ? 'alert' : 'status'}
>
{t.type === 'error' ? <XCircle className="mt-0.5 size-5 shrink-0" /> : <CheckCircle2 className="mt-0.5 size-5 shrink-0 text-green" />}
<span className="flex-1">{t.message}</span>
<button type="button" onClick={() => setToasts((x) => x.filter((y) => y.id !== t.id))} aria-label="Dismiss" className="text-slate hover:text-navy">
<X className="size-4" />
</button>
</motion.div>
))}
</AnimatePresence>
</div>
<Modal open={!!confirmState} onClose={() => closeConfirm(false)} title={confirmState?.title || 'Are you sure?'} width="max-w-[440px]">
<div className="flex gap-3">
{confirmState?.danger && <AlertTriangle className="size-6 shrink-0 text-[#D92D20]" />}
<p className="text-[15px] leading-6 text-slate">{confirmState?.message}</p>
</div>
<div className="mt-8 flex justify-end gap-3">
<button type="button" onClick={() => closeConfirm(false)} className="h-11 rounded-full px-5 font-semibold text-navy ring-1 ring-line hover:bg-surface">
Cancel
</button>
<button
type="button"
onClick={() => closeConfirm(true)}
className={`h-11 rounded-full px-5 font-semibold text-white ${confirmState?.danger ? 'bg-[#D92D20] hover:bg-[#B42318]' : 'bg-brand hover:bg-[#023a5a]'}`}
>
{confirmState?.confirmLabel || 'Confirm'}
</button>
</div>
</Modal>
</FeedbackContext.Provider>
)
}
// eslint-disable-next-line react-refresh/only-export-components
export const useFeedback = () => useContext(FeedbackContext)
export function LoadingBlock({ label = 'Loading…' }) {
return (
<div className="flex items-center justify-center gap-3 py-16 text-slate">
<Spinner className="size-5 text-brand" /> {label}
</div>
)
}
export function ErrorBlock({ message, onRetry }) {
return (
<div className="rounded-2xl bg-[#FEF3F2] p-6 text-[#912018]">
<p className="font-medium">{message}</p>
{onRetry && (
<button type="button" onClick={onRetry} className="mt-3 rounded-full bg-white px-4 py-2 text-[14px] font-semibold ring-1 ring-[#FECDCA]">
Try again
</button>
)}
</div>
)
}
export function EmptyBlock({ title, text, action }) {
return (
<div className="flex flex-col items-center rounded-2xl border border-dashed border-[#CBD5E1] bg-white px-6 py-14 text-center">
<p className="text-[17px] font-bold text-navy">{title}</p>
{text && <p className="mt-1 max-w-md text-[14px] text-slate">{text}</p>}
{action && <div className="mt-5">{action}</div>}
</div>
)
}
+114
View File
@@ -0,0 +1,114 @@
import { ChevronLeft, ChevronRight } from 'lucide-react'
import { Spinner } from '../../components/ui'
export const STATUS = {
new: { label: 'New', cls: 'bg-[#EFF8FF] text-[#175CD3] ring-[#B2DDFF]' },
contacted: { label: 'Contacted', cls: 'bg-[#F4F3FF] text-[#5925DC] ring-[#D9D6FE]' },
site_visit_scheduled: { label: 'Site Visit Scheduled', cls: 'bg-[#FFFAEB] text-[#B54708] ring-[#FEDF89]' },
quotation_sent: { label: 'Quotation Sent', cls: 'bg-[#F0F9FF] text-[#026AA2] ring-[#B9E6FE]' },
converted: { label: 'Converted', cls: 'bg-[#ECFDF3] text-[#067647] ring-[#ABEFC6]' },
rejected: { label: 'Rejected', cls: 'bg-[#F2F4F7] text-[#475467] ring-[#D0D5DD]' },
}
export function StatusBadge({ status }) {
const s = STATUS[status] || { label: status, cls: 'bg-surface text-slate ring-line' }
return <span className={`inline-flex items-center rounded-full px-2.5 py-0.5 text-[12px] font-semibold whitespace-nowrap ring-1 ${s.cls}`}>{s.label}</span>
}
export function Pill({ on, children }) {
return (
<span className={`inline-flex rounded-full px-2.5 py-0.5 text-[12px] font-semibold ring-1 ${on ? 'bg-[#ECFDF3] text-[#067647] ring-[#ABEFC6]' : 'bg-[#F2F4F7] text-[#475467] ring-[#D0D5DD]'}`}>
{children}
</span>
)
}
export function PageHeader({ title, subtitle, actions }) {
return (
<div className="mb-6 flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between">
<div>
<h1 className="text-[26px] leading-9 font-extrabold tracking-[-0.6px] text-navy">{title}</h1>
{subtitle && <p className="mt-1 text-[14px] text-slate">{subtitle}</p>}
</div>
{actions && <div className="flex flex-wrap gap-2">{actions}</div>}
</div>
)
}
export function Btn({ variant = 'primary', busy, children, className = '', as: Comp = 'button', disabled, ...props }) {
const v = {
primary: 'bg-brand text-white hover:bg-[#023a5a]',
accent: 'bg-yellow-cta text-black hover:brightness-105',
ghost: 'bg-white text-navy ring-1 ring-line hover:bg-surface',
danger: 'bg-white text-[#B42318] ring-1 ring-[#FECDCA] hover:bg-[#FEF3F2]',
}[variant]
const buttonProps = Comp === 'button' ? { type: 'button', disabled: busy || disabled } : {}
return (
<Comp
{...buttonProps}
className={`inline-flex h-10 items-center justify-center gap-2 rounded-full px-4 text-[14px] font-semibold whitespace-nowrap transition disabled:opacity-50 ${v} ${className}`}
{...props}
>
{busy && <Spinner className="size-4" />}
{children}
</Comp>
)
}
export function Card({ children, className = '' }) {
return <div className={`rounded-2xl bg-white p-5 ring-1 ring-line sm:p-6 ${className}`}>{children}</div>
}
export const aInput =
'w-full rounded-xl border border-[#D0D5DD] bg-white px-3.5 py-2.5 text-[14px] text-navy outline-none transition placeholder:text-[#98A2B3] focus:border-brand focus:ring-4 focus:ring-brand/10 disabled:bg-surface aria-[invalid=true]:border-[#F04438]'
export function AField({ label, error, hint, children, className = '' }) {
return (
<label className={`block ${className}`}>
<span className="mb-1.5 block text-[13px] font-semibold text-[#344054]">{label}</span>
{children}
{error ? <span className="mt-1 block text-[12px] font-medium text-[#D92D20]">{error}</span> : hint ? <span className="mt-1 block text-[12px] text-slate">{hint}</span> : null}
</label>
)
}
export function Toggle({ checked, onChange, label }) {
return (
<label className="inline-flex cursor-pointer items-center gap-3 select-none">
<button
type="button"
role="switch"
aria-checked={checked}
onClick={() => onChange(!checked)}
className={`relative h-6 w-11 rounded-full transition ${checked ? 'bg-green' : 'bg-[#D0D5DD]'}`}
>
<span className={`absolute top-0.5 left-0.5 size-5 rounded-full bg-white shadow transition-transform ${checked ? 'translate-x-5' : ''}`} />
</button>
<span className="text-[14px] font-medium text-navy">{label}</span>
</label>
)
}
export function Pagination({ page, pageSize, total, onPage }) {
const pages = Math.max(1, Math.ceil(total / pageSize))
if (total <= pageSize) return null
return (
<div className="mt-4 flex items-center justify-between text-[14px] text-slate">
<span>
{(page - 1) * pageSize + 1}–{Math.min(page * pageSize, total)} of {total}
</span>
<div className="flex gap-2">
<button type="button" disabled={page <= 1} onClick={() => onPage(page - 1)} className="grid size-9 place-items-center rounded-full ring-1 ring-line hover:bg-surface disabled:opacity-40" aria-label="Previous page">
<ChevronLeft className="size-4" />
</button>
<button type="button" disabled={page >= pages} onClick={() => onPage(page + 1)} className="grid size-9 place-items-center rounded-full ring-1 ring-line hover:bg-surface disabled:opacity-40" aria-label="Next page">
<ChevronRight className="size-4" />
</button>
</div>
</div>
)
}
export const fmtDate = (d) =>
d ? new Date(d).toLocaleString('en-IN', { day: '2-digit', month: 'short', year: 'numeric', hour: '2-digit', minute: '2-digit' }) : '—'
export const fmtDay = (d) => (d ? new Date(d).toLocaleDateString('en-IN', { day: '2-digit', month: 'short', year: 'numeric' }) : '—')
+111
View File
@@ -0,0 +1,111 @@
import { useEffect, useState } from 'react'
import { NavLink, Outlet, useLocation } from 'react-router-dom'
import {
ExternalLink,
FileText,
FolderKanban,
Inbox,
LayoutDashboard,
LogOut,
Mail,
Menu,
MessageSquareQuote,
Newspaper,
Shield,
Sun,
X,
} from 'lucide-react'
import logo from '../../assets/images/logo.webp'
import { can, useAuth } from '../../context/AuthContext'
const NAV = [
{ to: '/admin', label: 'Dashboard', icon: LayoutDashboard, end: true },
{ to: '/admin/enquiries', label: 'Enquiries', icon: Inbox },
{ to: '/admin/projects', label: 'Projects', icon: FolderKanban },
{ to: '/admin/services', label: 'Services', icon: Sun },
{ to: '/admin/testimonials', label: 'Testimonials', icon: MessageSquareQuote },
{ to: '/admin/messages', label: 'Contact messages', icon: Mail },
{ to: '/admin/subscribers', label: 'Subscribers', icon: Newspaper },
{ to: '/admin/content', label: 'Website content', icon: FileText },
{ to: '/admin/users', label: 'Admin users', icon: Shield, perm: 'users' },
]
const ROLE_LABEL = { super_admin: 'Super admin', admin: 'Admin', editor: 'Editor' }
export default function AdminLayout() {
const { admin, logout } = useAuth()
const [open, setOpen] = useState(false)
const { pathname } = useLocation()
useEffect(() => setOpen(false), [pathname])
useEffect(() => {
document.title = 'Admin — Saura Shakti'
}, [])
const sidebar = (
<div className="flex h-full flex-col bg-footer text-white">
<div className="flex h-20 items-center justify-between px-5">
<img src={logo} alt="Saura Shakti" className="h-14 w-auto" />
<button type="button" className="grid size-10 place-items-center rounded-full hover:bg-white/10 lg:hidden" onClick={() => setOpen(false)} aria-label="Close menu">
<X className="size-5" />
</button>
</div>
<nav className="flex-1 overflow-y-auto px-3 py-2" aria-label="Admin">
<ul className="space-y-1">
{NAV.filter((n) => !n.perm || can(admin, n.perm)).map(({ to, label, icon: Icon, end }) => (
<li key={to}>
<NavLink
to={to}
end={end}
className={({ isActive }) =>
`flex items-center gap-3 rounded-xl px-3 py-2.5 text-[14px] font-semibold transition ${
isActive ? 'bg-white/10 text-pale-lime' : 'text-white/75 hover:bg-white/5 hover:text-white'
}`
}
>
<Icon className="size-[18px]" strokeWidth={2} />
{label}
</NavLink>
</li>
))}
</ul>
</nav>
<div className="border-t border-white/10 p-3">
<a href="/" target="_blank" rel="noopener" className="flex items-center gap-3 rounded-xl px-3 py-2.5 text-[14px] font-semibold text-white/75 hover:bg-white/5 hover:text-white">
<ExternalLink className="size-[18px]" /> View website
</a>
</div>
</div>
)
return (
<div className="min-h-dvh bg-surface lg:pl-64">
<aside className="fixed inset-y-0 left-0 z-40 hidden w-64 lg:block">{sidebar}</aside>
{open && (
<div className="fixed inset-0 z-50 lg:hidden">
<div className="absolute inset-0 bg-black/50" onClick={() => setOpen(false)} aria-hidden />
<aside className="absolute inset-y-0 left-0 w-72 shadow-2xl">{sidebar}</aside>
</div>
)}
<header className="sticky top-0 z-30 flex h-16 items-center justify-between border-b border-line bg-white/90 px-4 backdrop-blur sm:px-6">
<button type="button" className="grid size-10 place-items-center rounded-full hover:bg-surface lg:hidden" onClick={() => setOpen(true)} aria-label="Open menu">
<Menu className="size-5" />
</button>
<div className="hidden lg:block" />
<div className="flex items-center gap-3">
<div className="text-right leading-tight">
<p className="text-[14px] font-bold text-navy">{admin?.full_name}</p>
<p className="text-[12px] text-slate">{ROLE_LABEL[admin?.role] || admin?.role}</p>
</div>
<button type="button" onClick={logout} className="inline-flex h-10 items-center gap-2 rounded-full px-3 text-[14px] font-semibold text-slate ring-1 ring-line hover:bg-surface hover:text-navy">
<LogOut className="size-4" /> <span className="hidden sm:inline">Log out</span>
</button>
</div>
</header>
<main className="mx-auto max-w-[1280px] px-4 py-6 sm:px-6 lg:py-8">
<Outlet />
</main>
</div>
)
}
+167
View File
@@ -0,0 +1,167 @@
import { useEffect, useMemo, useState } from 'react'
import { RotateCcw } from 'lucide-react'
import { CONTENT_DEFAULTS } from '../../content/defaults'
import { can, useAuth } from '../../context/AuthContext'
import { useApi } from '../../hooks/useApi'
import api, { errorMessage } from '../../services/api'
import { DEFAULT_QUOTE_SETTINGS } from '../../utils/quote'
import { ErrorBlock, LoadingBlock, useFeedback } from '../components/feedback'
import { aInput, AField, Btn, Card, PageHeader } from '../components/kit'
// Section blocks the admin can edit. Lists keep the design's item count so the layout never breaks.
const BLOCKS = [
{ key: 'hero', label: 'Hero (top of page)' },
{ key: 'solutions', label: 'Solutions slider (used when no services are published)' },
{ key: 'awareness', label: 'Solar awareness' },
{ key: 'myths', label: 'Solar myths (FAQ)' },
{ key: 'quotation', label: 'Quote calculator text' },
{ key: 'quote_settings', label: 'Quote calculator rates', defaults: DEFAULT_QUOTE_SETTINGS },
{ key: 'process', label: 'Installation process' },
{ key: 'testimonials', label: 'Testimonials heading' },
{ key: 'footer', label: 'Footer' },
{ key: 'contact', label: 'Contact details & social links' },
{ key: 'legal', label: 'Terms & privacy pages' },
]
const LABELS = {
sqft_per_kw: 'Roof area needed per kW (sq ft)',
panel_cost_per_kw: 'Panel & equipment cost per kW (₹)',
installation_cost_per_kw: 'Installation cost per kW (₹)',
min_area_sqft: 'Minimum roof area (sq ft)',
max_area_sqft: 'Maximum roof area (sq ft)',
subsidy_first_2kw_per_kw: 'Subsidy per kW for first 2 kW (₹)',
subsidy_third_kw: 'Subsidy for 3rd kW (₹)',
subsidy_cap: 'Maximum subsidy (₹)',
commercial_subsidy: 'Commercial subsidy (₹)',
}
const human = (k) => LABELS[k] || k.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase())
const isLong = (k, v) => ['terms', 'privacy'].includes(k) || (typeof v === 'string' && v.length > 70)
function FieldFor({ name, value, def, onChange }) {
if (Array.isArray(def)) {
return (
<fieldset className="space-y-3">
<legend className="mb-2 text-[13px] font-semibold text-[#344054]">{human(name)}</legend>
{def.map((itemDef, i) => (
<div key={i} className="rounded-xl bg-surface p-3">
<p className="mb-2 text-[12px] font-bold text-slate">#{i + 1}</p>
<div className="grid gap-2">
{Object.keys(itemDef).map((k) => (
<FieldFor
key={k}
name={k}
def={itemDef[k]}
value={value?.[i]?.[k] ?? ''}
onChange={(v) => {
const next = def.map((d, j) => ({ ...d, ...(value?.[j] || {}) }))
next[i] = { ...next[i], [k]: v }
onChange(next)
}}
/>
))}
</div>
</div>
))}
</fieldset>
)
}
const numeric = typeof def === 'number'
const props = {
className: `${aInput} ${isLong(name, def) ? 'min-h-24' : ''}`,
value: value ?? '',
placeholder: typeof def === 'string' ? def : String(def ?? ''),
onChange: (e) => onChange(numeric ? (e.target.value === '' ? '' : Number(e.target.value)) : e.target.value),
}
return (
<AField label={human(name)}>
{isLong(name, def) ? <textarea {...props} rows={name === 'terms' || name === 'privacy' ? 10 : 3} /> : <input {...props} type={numeric ? 'number' : 'text'} min={numeric ? 0 : undefined} />}
</AField>
)
}
function BlockEditor({ block, saved, onSaved }) {
const { admin } = useAuth()
const { toast, confirm } = useFeedback()
const defaults = block.defaults || CONTENT_DEFAULTS[block.key]
const initial = useMemo(() => ({ ...defaults, ...(saved || {}) }), [defaults, saved])
const [value, setValue] = useState(initial)
const [busy, setBusy] = useState(false)
useEffect(() => setValue(initial), [initial])
const save = async () => {
setBusy(true)
try {
await api.put(`/admin/content/${block.key}`, { value })
toast(`${block.label.split(' (')[0]} saved — live on the website`)
onSaved()
} catch (err) {
toast(errorMessage(err), 'error')
} finally {
setBusy(false)
}
}
const reset = async () => {
if (!(await confirm({ title: 'Reset to design text?', message: 'Your edits to this section will be removed and the original design text restored.', confirmLabel: 'Reset' }))) return
try {
await api.delete(`/admin/content/${block.key}`)
toast('Restored the design text')
onSaved()
} catch (err) {
toast(errorMessage(err), 'error')
}
}
return (
<Card>
<div className="grid gap-4">
{Object.keys(defaults).map((k) => (
<FieldFor key={k} name={k} def={defaults[k]} value={value[k]} onChange={(v) => setValue((s) => ({ ...s, [k]: v }))} />
))}
</div>
<div className="mt-5 flex flex-wrap justify-end gap-2 border-t border-line pt-4">
{saved && can(admin, 'delete') && <Btn variant="ghost" onClick={reset}><RotateCcw className="size-4" /> Reset to design</Btn>}
<Btn busy={busy} onClick={save}>Save section</Btn>
</div>
</Card>
)
}
export default function ContentPage() {
const { data, loading, error, reload } = useApi('/content')
const [active, setActive] = useState(BLOCKS[0].key)
const block = BLOCKS.find((b) => b.key === active)
return (
<>
<PageHeader title="Website content" subtitle="Edit the text on the public website. The layout and design stay exactly as in Figma; empty fields fall back to the design text." />
{loading && !data ? (
<LoadingBlock />
) : error ? (
<ErrorBlock message={error} onRetry={reload} />
) : (
<div className="grid gap-6 lg:grid-cols-[260px_1fr]">
<nav aria-label="Sections">
<select className={`${aInput} lg:hidden`} value={active} onChange={(e) => setActive(e.target.value)}>
{BLOCKS.map((b) => <option key={b.key} value={b.key}>{b.label}</option>)}
</select>
<ul className="hidden space-y-1 lg:block">
{BLOCKS.map((b) => (
<li key={b.key}>
<button
type="button"
onClick={() => setActive(b.key)}
className={`w-full rounded-xl px-3 py-2.5 text-left text-[14px] font-semibold ${active === b.key ? 'bg-white text-brand ring-1 ring-line' : 'text-slate hover:bg-white/60'}`}
>
{b.label.split(' (')[0]}
{data[b.key] && <span className="ml-2 text-[11px] font-medium text-green-text">edited</span>}
</button>
</li>
))}
</ul>
</nav>
<BlockEditor key={block.key} block={block} saved={data[block.key]} onSaved={reload} />
</div>
)}
</>
)
}
@@ -0,0 +1,78 @@
import { Link } from 'react-router-dom'
import { ArrowRight, CalendarCheck, CheckCircle2, FolderCheck, Inbox, Mail, PhoneCall, Sparkles } from 'lucide-react'
import { useApi } from '../../hooks/useApi'
import { ErrorBlock, LoadingBlock } from '../components/feedback'
import { Card, fmtDate, PageHeader, StatusBadge } from '../components/kit'
function Stat({ label, value, icon: Icon, tone, to }) {
const body = (
<Card className="h-full transition hover:ring-brand/40">
<div className="flex items-start justify-between">
<p className="text-[13px] font-semibold text-slate">{label}</p>
<span className={`grid size-9 place-items-center rounded-xl ${tone}`}><Icon className="size-[18px]" /></span>
</div>
<p className="mt-3 font-inter text-[30px] leading-9 font-black text-navy">{value}</p>
</Card>
)
return to ? <Link to={to} className="block">{body}</Link> : body
}
export default function DashboardPage() {
const { data: s, loading, error, reload } = useApi('/admin/dashboard/stats')
return (
<>
<PageHeader title="Dashboard" subtitle="Overview of enquiries and website activity." />
{loading && !s ? (
<LoadingBlock />
) : error ? (
<ErrorBlock message={error} onRetry={reload} />
) : (
<>
<div className="grid grid-cols-2 gap-3 sm:gap-4 lg:grid-cols-4">
<Stat label="Total enquiries" value={s.total_enquiries} icon={Inbox} tone="bg-[#EFF8FF] text-[#175CD3]" to="/admin/enquiries" />
<Stat label="New enquiries" value={s.new_enquiries} icon={Sparkles} tone="bg-[#FFFAEB] text-[#B54708]" to="/admin/enquiries?status=new" />
<Stat label="Contacted" value={s.contacted} icon={PhoneCall} tone="bg-[#F4F3FF] text-[#5925DC]" to="/admin/enquiries?status=contacted" />
<Stat label="Site visits scheduled" value={s.site_visits_scheduled} icon={CalendarCheck} tone="bg-[#FEF6EE] text-[#B93815]" to="/admin/enquiries?status=site_visit_scheduled" />
<Stat label="Converted" value={s.converted} icon={CheckCircle2} tone="bg-[#ECFDF3] text-[#067647]" to="/admin/enquiries?status=converted" />
<Stat label="Completed projects" value={s.completed_projects} icon={FolderCheck} tone="bg-[#F0F9FF] text-[#026AA2]" to="/admin/projects" />
<Stat label="Enquiries (30 days)" value={s.enquiries_last_30_days} icon={Inbox} tone="bg-surface text-slate" />
<Stat label="Unread messages" value={s.unread_contact_messages} icon={Mail} tone="bg-surface text-slate" to="/admin/messages" />
</div>
<Card className="mt-6 p-0 sm:p-0">
<div className="flex items-center justify-between px-5 py-4 sm:px-6">
<h2 className="text-[17px] font-bold text-navy">Recent enquiries</h2>
<Link to="/admin/enquiries" className="inline-flex items-center gap-1 text-[14px] font-semibold text-brand hover:underline">
View all <ArrowRight className="size-4" />
</Link>
</div>
{s.recent_enquiries.length === 0 ? (
<p className="border-t border-line px-6 py-10 text-center text-[14px] text-slate">No enquiries yet. They will appear here when visitors submit the website forms.</p>
) : (
<ul className="divide-y divide-line border-t border-line">
{s.recent_enquiries.map((e) => (
<li key={e.id}>
<Link to={`/admin/enquiries/${e.id}`} className="flex flex-col gap-1 px-5 py-3.5 hover:bg-surface sm:flex-row sm:items-center sm:justify-between sm:px-6">
<span>
<span className="font-semibold text-navy">{e.name}</span>
<span className="ml-2 text-[13px] text-slate">{e.phone || e.email}{e.city ? ` · ${e.city}` : ''}</span>
</span>
<span className="flex items-center gap-3">
<span className="text-[12px] text-slate">{fmtDate(e.created_at)}</span>
<StatusBadge status={e.status} />
</span>
</Link>
</li>
))}
</ul>
)}
</Card>
<p className="mt-4 text-[13px] text-slate">
{s.published_projects} of {s.total_projects} projects published · {s.published_services} services published · {s.quotations_sent} quotations sent · {s.rejected} rejected
</p>
</>
)}
</>
)
}
+103
View File
@@ -0,0 +1,103 @@
import { useEffect, useState } from 'react'
import { Link, useNavigate, useSearchParams } from 'react-router-dom'
import { Search } from 'lucide-react'
import { useApi } from '../../hooks/useApi'
import { EmptyBlock, ErrorBlock, LoadingBlock } from '../components/feedback'
import { aInput, Card, fmtDate, PageHeader, Pagination, STATUS, StatusBadge } from '../components/kit'
const PAGE_SIZE = 20
export default function EnquiriesPage() {
const [params, setParams] = useSearchParams()
const navigate = useNavigate()
const status = params.get('status') || ''
const page = Number(params.get('page')) || 1
const [search, setSearch] = useState(params.get('search') || '')
const searchParam = params.get('search') || ''
// debounce search → URL
useEffect(() => {
const t = setTimeout(() => {
if (search === searchParam) return
const next = new URLSearchParams(params)
search ? next.set('search', search) : next.delete('search')
next.delete('page')
setParams(next, { replace: true })
}, 350)
return () => clearTimeout(t)
}, [search, searchParam, params, setParams])
const { data, loading, error, reload } = useApi('/admin/enquiries', {
params: { page, page_size: PAGE_SIZE, ...(status && { status }), ...(searchParam && { search: searchParam }) },
})
const setParam = (k, v) => {
const next = new URLSearchParams(params)
v ? next.set(k, v) : next.delete(k)
if (k !== 'page') next.delete('page')
setParams(next)
}
return (
<>
<PageHeader title="Enquiries" subtitle="Consultation requests and quotation leads from the website." />
<div className="mb-4 flex flex-col gap-3 sm:flex-row">
<label className="relative flex-1">
<Search className="pointer-events-none absolute top-1/2 left-3.5 size-4 -translate-y-1/2 text-slate" />
<input className={`${aInput} pl-10`} placeholder="Search name, phone, email or city" value={search} onChange={(e) => setSearch(e.target.value)} aria-label="Search enquiries" />
</label>
<select className={`${aInput} sm:w-60`} value={status} onChange={(e) => setParam('status', e.target.value)} aria-label="Filter by status">
<option value="">All statuses</option>
{Object.entries(STATUS).map(([v, s]) => <option key={v} value={v}>{s.label}</option>)}
</select>
</div>
{loading && !data ? (
<LoadingBlock />
) : error ? (
<ErrorBlock message={error} onRetry={reload} />
) : data.items.length === 0 ? (
<EmptyBlock title={status || searchParam ? 'No matching enquiries' : 'No enquiries yet'} text={status || searchParam ? 'Try a different search or status.' : 'New website enquiries will appear here.'} />
) : (
<Card className={`overflow-hidden p-0 sm:p-0 ${loading ? 'opacity-60' : ''}`}>
<div className="overflow-x-auto">
<table className="w-full min-w-[760px] text-left text-[14px]">
<thead className="bg-surface text-[12px] font-semibold tracking-wide text-slate uppercase">
<tr>
<th className="px-5 py-3">Customer</th>
<th className="px-5 py-3">Contact</th>
<th className="px-5 py-3">Property</th>
<th className="px-5 py-3">Source</th>
<th className="px-5 py-3">Received</th>
<th className="px-5 py-3">Status</th>
</tr>
</thead>
<tbody className="divide-y divide-line">
{data.items.map((e) => (
<tr key={e.id} className="cursor-pointer hover:bg-surface" onClick={() => navigate(`/admin/enquiries/${e.id}`)}>
<td className="px-5 py-3.5">
<Link to={`/admin/enquiries/${e.id}`} className="font-semibold text-navy hover:text-brand" onClick={(ev) => ev.stopPropagation()}>{e.name}</Link>
{e.city && <p className="text-[12px] text-slate">{e.city}</p>}
</td>
<td className="px-5 py-3.5 text-navy">
{e.phone && <p>{e.phone}</p>}
{e.email && <p className="text-[12px] text-slate">{e.email}</p>}
</td>
<td className="px-5 py-3.5 text-navy capitalize">
{e.property_type || '—'}
{e.required_capacity_kw && <p className="text-[12px] text-slate">{e.required_capacity_kw} kW</p>}
</td>
<td className="px-5 py-3.5 text-slate">{e.source === 'quote_calculator' ? 'Quote calculator' : 'Website form'}</td>
<td className="px-5 py-3.5 whitespace-nowrap text-slate">{fmtDate(e.created_at)}</td>
<td className="px-5 py-3.5"><StatusBadge status={e.status} /></td>
</tr>
))}
</tbody>
</table>
</div>
</Card>
)}
{data && <Pagination page={page} pageSize={PAGE_SIZE} total={data.total} onPage={(p) => setParam('page', String(p))} />}
</>
)
}
@@ -0,0 +1,130 @@
import { useState } from 'react'
import { Link, useNavigate, useParams } from 'react-router-dom'
import { ArrowLeft, Mail, Phone, Trash2 } from 'lucide-react'
import { can, useAuth } from '../../context/AuthContext'
import { useApi } from '../../hooks/useApi'
import api, { errorMessage } from '../../services/api'
import { ErrorBlock, LoadingBlock, useFeedback } from '../components/feedback'
import { aInput, Btn, Card, fmtDate, PageHeader, STATUS, StatusBadge } from '../components/kit'
function Row({ label, children }) {
return (
<div className="grid grid-cols-[140px_1fr] gap-3 py-2.5 text-[14px]">
<dt className="text-slate">{label}</dt>
<dd className="text-navy">{children || '—'}</dd>
</div>
)
}
export default function EnquiryDetailPage() {
const { id } = useParams()
const navigate = useNavigate()
const { admin } = useAuth()
const { toast, confirm } = useFeedback()
const { data: e, loading, error, reload, setData } = useApi(`/admin/enquiries/${id}`)
const [note, setNote] = useState('')
const [busy, setBusy] = useState('')
const patch = async (body, what) => {
setBusy(what)
try {
const r = await api.patch(`/admin/enquiries/${id}`, body)
setData(r.data)
toast(what === 'note' ? 'Note added' : 'Status updated')
if (what === 'note') setNote('')
} catch (err) {
toast(errorMessage(err), 'error')
} finally {
setBusy('')
}
}
const remove = async () => {
const ok = await confirm({ title: 'Delete enquiry?', message: `This permanently deletes the enquiry from ${e.name} and its notes.`, confirmLabel: 'Delete', danger: true })
if (!ok) return
try {
await api.delete(`/admin/enquiries/${id}`)
toast('Enquiry deleted')
navigate('/admin/enquiries', { replace: true })
} catch (err) {
toast(errorMessage(err), 'error')
}
}
if (loading && !e) return <LoadingBlock />
if (error) return <ErrorBlock message={error} onRetry={reload} />
return (
<>
<Link to="/admin/enquiries" className="mb-4 inline-flex items-center gap-1.5 text-[14px] font-semibold text-brand hover:underline"><ArrowLeft className="size-4" /> Enquiries</Link>
<PageHeader
title={e.name}
subtitle={`Received ${fmtDate(e.created_at)} · ${e.source === 'quote_calculator' ? 'Quote calculator' : 'Website form'}`}
actions={can(admin, 'delete') && <Btn variant="danger" onClick={remove}><Trash2 className="size-4" /> Delete</Btn>}
/>
<div className="grid gap-6 lg:grid-cols-[1fr_380px]">
<div className="space-y-6">
<Card>
<h2 className="mb-2 text-[16px] font-bold text-navy">Customer details</h2>
<dl className="divide-y divide-line">
<Row label="Phone">{e.phone && <a href={`tel:${e.phone}`} className="inline-flex items-center gap-1.5 font-semibold text-brand"><Phone className="size-3.5" />{e.phone}</a>}</Row>
<Row label="Email">{e.email && <a href={`mailto:${e.email}`} className="inline-flex items-center gap-1.5 font-semibold text-brand"><Mail className="size-3.5" />{e.email}</a>}</Row>
<Row label="City">{e.city}</Row>
<Row label="Address">{e.address}</Row>
<Row label="Property type"><span className="capitalize">{e.property_type}</span></Row>
<Row label="Monthly bill">{e.monthly_bill != null && `₹${e.monthly_bill.toLocaleString('en-IN')}`}</Row>
<Row label="Capacity">{e.required_capacity_kw && `${e.required_capacity_kw} kW`}</Row>
<Row label="Message"><span className="whitespace-pre-line">{e.message}</span></Row>
</dl>
</Card>
<Card>
<h2 className="mb-3 text-[16px] font-bold text-navy">Internal notes</h2>
<form
onSubmit={(ev) => {
ev.preventDefault()
if (note.trim()) patch({ note: note.trim() }, 'note')
}}
>
<textarea className={`${aInput} min-h-24`} placeholder="Add a note (only visible to admins)…" value={note} onChange={(ev) => setNote(ev.target.value)} maxLength={5000} aria-label="New note" />
<div className="mt-2 flex justify-end">
<Btn type="submit" busy={busy === 'note'} disabled={!note.trim()}>Add note</Btn>
</div>
</form>
{e.notes.length > 0 && (
<ul className="mt-4 space-y-3">
{e.notes.map((n) => (
<li key={n.id} className="rounded-xl bg-surface p-4">
<p className="text-[14px] whitespace-pre-line text-navy">{n.content}</p>
<p className="mt-2 text-[12px] text-slate">{n.author_name || 'Deleted user'} · {fmtDate(n.created_at)}</p>
</li>
))}
</ul>
)}
</Card>
</div>
<Card className="h-fit">
<h2 className="text-[16px] font-bold text-navy">Status</h2>
<div className="mt-2"><StatusBadge status={e.status} /></div>
<div className="mt-4 grid gap-2">
{Object.entries(STATUS).map(([value, s]) => (
<button
key={value}
type="button"
disabled={!!busy || value === e.status}
onClick={() => patch({ status: value }, 'status')}
className={`flex h-10 items-center justify-between rounded-xl px-3.5 text-[14px] font-semibold ring-1 transition ${value === e.status ? 'bg-brand text-white ring-brand' : 'bg-white text-navy ring-line hover:bg-surface'} disabled:cursor-default`}
>
{s.label}
{value === e.status && <span className="text-[12px] font-medium opacity-80">Current</span>}
</button>
))}
</div>
<p className="mt-4 text-[12px] text-slate">Last updated {fmtDate(e.updated_at)}</p>
</Card>
</div>
</>
)
}
+80
View File
@@ -0,0 +1,80 @@
import { useEffect, useState } from 'react'
import { Navigate, useLocation, useNavigate } from 'react-router-dom'
import { Eye, EyeOff, Lock } from 'lucide-react'
import logo from '../../assets/images/logo.webp'
import heroBg from '../../assets/images/hero-bg.webp'
import { useAuth } from '../../context/AuthContext'
import { errorMessage } from '../../services/api'
import { Spinner } from '../../components/ui'
import { aInput, AField } from '../components/kit'
export default function LoginPage() {
const { admin, login, sessionMessage } = useAuth()
const navigate = useNavigate()
const location = useLocation()
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const [show, setShow] = useState(false)
const [busy, setBusy] = useState(false)
const [error, setError] = useState('')
useEffect(() => {
document.title = 'Admin login — Saura Shakti'
}, [])
if (admin) return <Navigate to={location.state?.from || '/admin'} replace />
const submit = async (e) => {
e.preventDefault()
setError('')
if (!email.trim() || !password) {
setError('Enter your email and password.')
return
}
setBusy(true)
try {
await login(email.trim(), password)
navigate(location.state?.from || '/admin', { replace: true })
} catch (err) {
setError(errorMessage(err, 'Login failed.'))
} finally {
setBusy(false)
}
}
return (
<div className="relative isolate grid min-h-dvh place-items-center p-4">
<img src={heroBg} alt="" className="absolute inset-0 -z-20 size-full object-cover" />
<div className="absolute inset-0 -z-10 bg-gradient-to-b from-[#0E5177]/60 via-[#082D42]/80 to-[#00070B]" />
<div className="w-full max-w-[420px] rounded-[24px] bg-white p-8 shadow-2xl sm:p-10">
<div className="-mx-2 -mt-2 mb-6 flex justify-center rounded-2xl bg-footer py-3">
<img src={logo} alt="Saura Shakti" className="h-16 w-auto" />
</div>
<h1 className="text-[24px] font-extrabold tracking-[-0.5px] text-navy">Admin dashboard</h1>
<p className="mt-1 text-[14px] text-slate">Sign in to manage enquiries, projects and website content.</p>
{sessionMessage && !error && (
<p className="mt-5 rounded-xl bg-[#FFFAEB] px-4 py-3 text-[13px] font-medium text-[#B54708]" role="status">{sessionMessage}</p>
)}
<form onSubmit={submit} noValidate className="mt-6 space-y-4">
<AField label="Email">
<input className={aInput} type="email" value={email} onChange={(e) => setEmail(e.target.value)} autoComplete="username" autoFocus />
</AField>
<AField label="Password">
<span className="relative block">
<input className={`${aInput} pr-11`} type={show ? 'text' : 'password'} value={password} onChange={(e) => setPassword(e.target.value)} autoComplete="current-password" />
<button type="button" onClick={() => setShow((s) => !s)} className="absolute top-1/2 right-2 grid size-8 -translate-y-1/2 place-items-center rounded-lg text-slate hover:bg-surface" aria-label={show ? 'Hide password' : 'Show password'}>
{show ? <EyeOff className="size-4" /> : <Eye className="size-4" />}
</button>
</span>
</AField>
{error && <p className="rounded-xl bg-[#FEF3F2] px-4 py-3 text-[13px] font-medium text-[#B42318]" role="alert">{error}</p>}
<button type="submit" disabled={busy} className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-brand font-semibold text-white transition hover:bg-[#023a5a] disabled:opacity-60">
{busy ? <Spinner className="size-4" /> : <Lock className="size-4" />}
{busy ? 'Signing in…' : 'Sign in'}
</button>
</form>
</div>
</div>
)
}
+87
View File
@@ -0,0 +1,87 @@
import { useState } from 'react'
import { Mail, MailOpen, Phone, Trash2 } from 'lucide-react'
import { can, useAuth } from '../../context/AuthContext'
import { useApi } from '../../hooks/useApi'
import api, { errorMessage } from '../../services/api'
import { EmptyBlock, ErrorBlock, LoadingBlock, useFeedback } from '../components/feedback'
import { aInput, Btn, Card, fmtDate, PageHeader, Pagination } from '../components/kit'
const PAGE_SIZE = 20
export default function MessagesPage() {
const { admin } = useAuth()
const { toast, confirm } = useFeedback()
const [filter, setFilter] = useState('')
const [page, setPage] = useState(1)
const [open, setOpen] = useState(null)
const { data, loading, error, reload } = useApi('/admin/contact-messages', {
params: { page, page_size: PAGE_SIZE, ...(filter !== '' && { is_read: filter }) },
})
const markRead = async (m, is_read) => {
try {
await api.patch(`/admin/contact-messages/${m.id}`, { is_read })
reload()
} catch (err) {
toast(errorMessage(err), 'error')
}
}
const toggleOpen = (m) => {
setOpen(open === m.id ? null : m.id)
if (!m.is_read) markRead(m, true)
}
const remove = async (m) => {
if (!(await confirm({ title: 'Delete message?', message: `Delete the message from ${m.name}?`, confirmLabel: 'Delete', danger: true }))) return
try {
await api.delete(`/admin/contact-messages/${m.id}`)
toast('Message deleted')
reload()
} catch (err) {
toast(errorMessage(err), 'error')
}
}
return (
<>
<PageHeader title="Contact messages" subtitle="Messages sent from the Support form." />
<select className={`${aInput} mb-4 sm:w-56`} value={filter} onChange={(e) => { setFilter(e.target.value); setPage(1) }} aria-label="Filter">
<option value="">All messages</option>
<option value="false">Unread</option>
<option value="true">Read</option>
</select>
{loading && !data ? (
<LoadingBlock />
) : error ? (
<ErrorBlock message={error} onRetry={reload} />
) : data.items.length === 0 ? (
<EmptyBlock title="No messages" />
) : (
<div className="space-y-2">
{data.items.map((m) => (
<Card key={m.id} className={`p-0 sm:p-0 ${!m.is_read ? 'ring-brand/30' : ''}`}>
<button type="button" onClick={() => toggleOpen(m)} className="flex w-full items-center gap-3 px-5 py-4 text-left" aria-expanded={open === m.id}>
{m.is_read ? <MailOpen className="size-5 shrink-0 text-slate" /> : <Mail className="size-5 shrink-0 text-brand" />}
<span className="min-w-0 flex-1">
<span className={`block truncate text-navy ${m.is_read ? 'font-medium' : 'font-bold'}`}>{m.name} — {m.subject || m.message.slice(0, 60)}</span>
<span className="block text-[12px] text-slate">{m.email} · {fmtDate(m.created_at)}</span>
</span>
</button>
{open === m.id && (
<div className="border-t border-line px-5 py-4">
<p className="text-[14px] whitespace-pre-line text-navy">{m.message}</p>
<div className="mt-4 flex flex-wrap gap-2">
<a href={`mailto:${m.email}?subject=${encodeURIComponent('Re: ' + (m.subject || 'Your message to Saura Shakti'))}`}><Btn as="span" variant="ghost"><Mail className="size-4" /> Reply</Btn></a>
{m.phone && <a href={`tel:${m.phone}`}><Btn as="span" variant="ghost"><Phone className="size-4" /> {m.phone}</Btn></a>}
<Btn variant="ghost" onClick={() => markRead(m, !m.is_read)}>Mark as {m.is_read ? 'unread' : 'read'}</Btn>
{can(admin, 'delete') && <Btn variant="danger" onClick={() => remove(m)}><Trash2 className="size-4" /> Delete</Btn>}
</div>
</div>
)}
</Card>
))}
</div>
)}
{data && <Pagination page={page} pageSize={PAGE_SIZE} total={data.total} onPage={setPage} />}
</>
)
}
@@ -0,0 +1,267 @@
import { useEffect, useState } from 'react'
import { Link, useNavigate, useParams } from 'react-router-dom'
import { ArrowLeft, Download, ExternalLink, Star, Trash2 } from 'lucide-react'
import { useApi } from '../../hooks/useApi'
import api, { errorMessage, fieldErrors } from '../../services/api'
import { ErrorBlock, LoadingBlock, useFeedback } from '../components/feedback'
import ImageUploader from '../components/ImageUploader'
import { aInput, AField, Btn, Card, PageHeader, Pill, Toggle } from '../components/kit'
const EMPTY = { title: '', category: 'residential', location: '', capacity_kw: '', installation_date: '', description: '', status: 'completed', is_published: false }
function toForm(p) {
return {
title: p.title,
category: p.category,
location: p.location || '',
capacity_kw: p.capacity_kw ?? '',
installation_date: p.installation_date || '',
description: p.description || '',
status: p.status,
is_published: p.is_published,
}
}
function toPayload(f) {
return {
...f,
location: f.location.trim() || null,
description: f.description.trim() || null,
capacity_kw: f.capacity_kw === '' ? null : Number(f.capacity_kw),
installation_date: f.installation_date || null,
}
}
async function downloadOriginal(img) {
const res = await api.get(img.original_download_path.replace(/^\/api/, ''), { responseType: 'blob' })
const url = URL.createObjectURL(res.data)
const a = document.createElement('a')
a.href = url
a.download = img.original_filename
a.click()
setTimeout(() => URL.revokeObjectURL(url), 2000)
}
function Gallery({ project, onChange }) {
const { toast, confirm } = useFeedback()
const [busyId, setBusyId] = useState(null)
const [captions, setCaptions] = useState({})
const act = async (id, fn, okMsg) => {
setBusyId(id)
try {
const r = await fn()
if (r?.data?.images) onChange(r.data)
if (okMsg) toast(okMsg)
return true
} catch (e) {
toast(errorMessage(e), 'error')
return false
} finally {
setBusyId(null)
}
}
const remove = async (img) => {
const ok = await confirm({ title: 'Delete photo?', message: `"${img.original_filename}" and its watermarked copy will be permanently deleted.`, confirmLabel: 'Delete photo', danger: true })
if (!ok) return
const done = await act(img.id, () => api.delete(`/admin/project-images/${img.id}`), 'Photo deleted')
if (done) {
const r = await api.get(`/admin/projects/${project.id}`)
onChange(r.data)
}
}
return (
<Card>
<div className="mb-4 flex items-center justify-between">
<h2 className="text-[16px] font-bold text-navy">Photos ({project.images.length})</h2>
<span className="text-[12px] text-slate">The public gallery shows watermarked copies only.</span>
</div>
<ImageUploader
url={`/admin/projects/${project.id}/images`}
onUploaded={(res) => {
onChange(res.project)
toast(`${res.uploaded.length} photo${res.uploaded.length === 1 ? '' : 's'} uploaded and watermarked`)
}}
/>
{project.images.length > 0 && (
<ul className="mt-5 grid gap-4 sm:grid-cols-2 xl:grid-cols-3">
{project.images.map((img) => (
<li key={img.id} className={`overflow-hidden rounded-2xl ring-1 ${img.is_featured ? 'ring-2 ring-yellow-badge' : 'ring-line'} ${busyId === img.id ? 'opacity-50' : ''}`}>
<a href={img.url} target="_blank" rel="noopener" className="relative block aspect-[4/3] bg-surface" title="Open watermarked image">
<img src={img.thumbnail_url} alt={img.caption || img.original_filename} className="size-full object-cover" loading="lazy" />
{img.is_featured && <span className="absolute top-2 left-2 inline-flex items-center gap-1 rounded-full bg-yellow-badge px-2 py-0.5 text-[11px] font-bold text-black"><Star className="size-3" fill="currentColor" /> Featured</span>}
</a>
<div className="space-y-2 p-3">
<p className="truncate text-[12px] text-slate" title={img.original_filename}>
{img.original_filename} · {img.width}×{img.height} · {(img.file_size / 1024 / 1024).toFixed(1)} MB
</p>
<input
className={`${aInput} py-1.5 text-[13px]`}
placeholder="Caption (optional)"
value={captions[img.id] ?? img.caption ?? ''}
onChange={(e) => setCaptions((c) => ({ ...c, [img.id]: e.target.value }))}
onBlur={() => {
const v = captions[img.id]
if (v !== undefined && v !== (img.caption ?? '')) act(img.id, () => api.patch(`/admin/project-images/${img.id}`, { caption: v.trim() || null }), 'Caption saved')
}}
maxLength={300}
aria-label="Caption"
/>
<div className="flex flex-wrap gap-1.5">
{!img.is_featured && (
<Btn variant="ghost" className="h-8 px-3 text-[12px]" onClick={() => act(img.id, () => api.patch(`/admin/project-images/${img.id}`, { is_featured: true }), 'Featured image set')}>
<Star className="size-3.5" /> Set featured
</Btn>
)}
<Btn variant="ghost" className="h-8 px-3 text-[12px]" onClick={() => downloadOriginal(img).catch((e) => toast(errorMessage(e), 'error'))} title="Download original (no watermark)">
<Download className="size-3.5" /> Original
</Btn>
<Btn variant="danger" className="h-8 px-3 text-[12px]" onClick={() => remove(img)}>
<Trash2 className="size-3.5" /> Delete
</Btn>
</div>
</div>
</li>
))}
</ul>
)}
</Card>
)
}
export default function ProjectEditorPage() {
const { id } = useParams()
const isNew = !id
const navigate = useNavigate()
const { toast, confirm } = useFeedback()
const { data, loading, error, reload, setData } = useApi(`/admin/projects/${id}`, { enabled: !isNew })
const [form, setForm] = useState(EMPTY)
const [errors, setErrors] = useState({})
const [saving, setSaving] = useState(false)
// Fill the form once per loaded project (photo changes must not wipe unsaved edits).
const loadedId = data?.id
useEffect(() => {
if (data) setForm(toForm(data))
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [loadedId])
const set = (k) => (e) => {
setForm((f) => ({ ...f, [k]: e?.target ? e.target.value : e }))
setErrors((er) => ({ ...er, [k]: undefined }))
}
const save = async (ev) => {
ev?.preventDefault()
const e = {}
if (form.title.trim().length < 2) e.title = 'Enter a project title'
if (form.capacity_kw !== '' && !(Number(form.capacity_kw) > 0)) e.capacity_kw = 'Capacity must be a positive number'
setErrors(e)
if (Object.keys(e).length) return
setSaving(true)
try {
if (isNew) {
const r = await api.post('/admin/projects', toPayload(form))
toast('Project created — now add photos')
navigate(`/admin/projects/${r.data.id}`, { replace: true })
} else {
const r = await api.put(`/admin/projects/${id}`, toPayload(form))
setData(r.data)
setForm(toForm(r.data))
toast('Project saved')
}
} catch (err) {
setErrors(fieldErrors(err))
toast(errorMessage(err), 'error')
} finally {
setSaving(false)
}
}
const remove = async () => {
const ok = await confirm({ title: 'Delete project?', message: `"${data.title}" and all ${data.images.length} photos will be permanently deleted.`, confirmLabel: 'Delete project', danger: true })
if (!ok) return
try {
await api.delete(`/admin/projects/${id}`)
toast('Project deleted')
navigate('/admin/projects', { replace: true })
} catch (err) {
toast(errorMessage(err), 'error')
}
}
if (!isNew && error) return <ErrorBlock message={error} onRetry={reload} />
if (!isNew && (!data || String(data.id) !== String(id))) return <LoadingBlock />
return (
<>
<Link to="/admin/projects" className="mb-4 inline-flex items-center gap-1.5 text-[14px] font-semibold text-brand hover:underline"><ArrowLeft className="size-4" /> Projects</Link>
<PageHeader
title={isNew ? 'New project' : data.title}
subtitle={isNew ? 'Save the details first, then upload photos.' : <span className="inline-flex items-center gap-2"><Pill on={data.is_published}>{data.is_published ? 'Published' : 'Draft'}</Pill> /{data.slug}</span>}
actions={
!isNew && (
<>
{data.is_published && (
<a href={`/projects/${data.slug}`} target="_blank" rel="noopener"><Btn variant="ghost" as="span"><ExternalLink className="size-4" /> View on site</Btn></a>
)}
<Btn variant="danger" onClick={remove}><Trash2 className="size-4" /> Delete</Btn>
</>
)
}
/>
<div className="grid gap-6 xl:grid-cols-[420px_1fr]">
<Card className="h-fit">
<form onSubmit={save} noValidate className="space-y-4">
<AField label="Title *" error={errors.title}>
<input className={aInput} value={form.title} onChange={set('title')} maxLength={200} aria-invalid={!!errors.title} />
</AField>
<div className="grid grid-cols-2 gap-3">
<AField label="Category" error={errors.category}>
<select className={aInput} value={form.category} onChange={set('category')}>
<option value="residential">Residential</option>
<option value="commercial">Commercial</option>
</select>
</AField>
<AField label="Status">
<select className={aInput} value={form.status} onChange={set('status')}>
<option value="completed">Completed</option>
<option value="ongoing">Ongoing</option>
</select>
</AField>
</div>
<AField label="Location" error={errors.location}>
<input className={aInput} value={form.location} onChange={set('location')} placeholder="e.g. Patia, Bhubaneswar" maxLength={200} />
</AField>
<div className="grid grid-cols-2 gap-3">
<AField label="Capacity (kW)" error={errors.capacity_kw}>
<input className={aInput} type="number" min="0" step="0.1" value={form.capacity_kw} onChange={set('capacity_kw')} aria-invalid={!!errors.capacity_kw} />
</AField>
<AField label="Installation date" error={errors.installation_date}>
<input className={aInput} type="date" value={form.installation_date} onChange={set('installation_date')} />
</AField>
</div>
<AField label="Description" error={errors.description}>
<textarea className={`${aInput} min-h-32`} value={form.description} onChange={set('description')} maxLength={10000} />
</AField>
<Toggle checked={form.is_published} onChange={set('is_published')} label="Published on website" />
<div className="flex justify-end gap-2 pt-2">
<Btn type="submit" busy={saving}>{isNew ? 'Create project' : 'Save changes'}</Btn>
</div>
</form>
</Card>
{isNew ? (
<Card className="grid place-items-center text-center text-[14px] text-slate">
<p className="max-w-sm py-10">Create the project first — the photo uploader will appear here.</p>
</Card>
) : (
<Gallery project={data} onChange={setData} />
)}
</div>
</>
)
}
+76
View File
@@ -0,0 +1,76 @@
import { useState } from 'react'
import { Link } from 'react-router-dom'
import { ImageOff, Plus } from 'lucide-react'
import { useApi } from '../../hooks/useApi'
import { EmptyBlock, ErrorBlock, LoadingBlock } from '../components/feedback'
import { aInput, Btn, fmtDay, PageHeader, Pagination, Pill } from '../components/kit'
const PAGE_SIZE = 20
export default function ProjectsPage() {
const [filters, setFilters] = useState({ search: '', category: '', is_published: '' })
const [page, setPage] = useState(1)
const params = Object.fromEntries(Object.entries({ ...filters, page, page_size: PAGE_SIZE }).filter(([, v]) => v !== ''))
const { data, loading, error, reload } = useApi('/admin/projects', { params })
const set = (k) => (e) => {
setFilters((f) => ({ ...f, [k]: e.target.value }))
setPage(1)
}
return (
<>
<PageHeader
title="Projects"
subtitle="Completed installations shown in the public project gallery."
actions={<Link to="/admin/projects/new"><Btn as="span"><Plus className="size-4" /> Add project</Btn></Link>}
/>
<div className="mb-4 grid gap-3 sm:grid-cols-[1fr_180px_180px]">
<input className={aInput} placeholder="Search title or location" value={filters.search} onChange={set('search')} aria-label="Search projects" />
<select className={aInput} value={filters.category} onChange={set('category')} aria-label="Category">
<option value="">All categories</option>
<option value="residential">Residential</option>
<option value="commercial">Commercial</option>
</select>
<select className={aInput} value={filters.is_published} onChange={set('is_published')} aria-label="Visibility">
<option value="">Published & drafts</option>
<option value="true">Published</option>
<option value="false">Drafts</option>
</select>
</div>
{loading && !data ? (
<LoadingBlock />
) : error ? (
<ErrorBlock message={error} onRetry={reload} />
) : data.items.length === 0 ? (
<EmptyBlock title="No projects found" text="Add a project, upload its photos and publish it to show it on the website." action={<Link to="/admin/projects/new"><Btn as="span"><Plus className="size-4" /> Add project</Btn></Link>} />
) : (
<ul className={`grid gap-4 sm:grid-cols-2 xl:grid-cols-3 ${loading ? 'opacity-60' : ''}`}>
{data.items.map((p) => (
<li key={p.id}>
<Link to={`/admin/projects/${p.id}`} className="group block overflow-hidden rounded-2xl bg-white ring-1 ring-line transition hover:ring-brand/40">
<div className="relative aspect-[16/10] bg-surface">
{p.featured_image ? (
<img src={p.featured_image.thumbnail_url} alt="" className="size-full object-cover" loading="lazy" />
) : (
<div className="grid size-full place-items-center text-[#98A2B3]"><ImageOff className="size-7" /></div>
)}
<span className="absolute top-3 left-3"><Pill on={p.is_published}>{p.is_published ? 'Published' : 'Draft'}</Pill></span>
<span className="absolute right-3 bottom-3 rounded-full bg-black/60 px-2.5 py-0.5 text-[12px] font-semibold text-white">{p.images.length} photo{p.images.length === 1 ? '' : 's'}</span>
</div>
<div className="p-4">
<p className="font-bold text-navy group-hover:text-brand">{p.title}</p>
<p className="mt-1 text-[13px] text-slate capitalize">
{p.category}{p.capacity_kw ? ` · ${p.capacity_kw} kW` : ''}{p.location ? ` · ${p.location}` : ''}
</p>
<p className="mt-1 text-[12px] text-[#98A2B3]">Installed {fmtDay(p.installation_date)}</p>
</div>
</Link>
</li>
))}
</ul>
)}
{data && <Pagination page={page} pageSize={PAGE_SIZE} total={data.total} onPage={setPage} />}
</>
)
}
+166
View File
@@ -0,0 +1,166 @@
import { useState } from 'react'
import { ImageOff, Pencil, Plus, Trash2 } from 'lucide-react'
import Modal from '../../components/Modal'
import { useApi } from '../../hooks/useApi'
import api, { errorMessage, fieldErrors } from '../../services/api'
import { EmptyBlock, ErrorBlock, LoadingBlock, useFeedback } from '../components/feedback'
import ImageUploader from '../components/ImageUploader'
import { aInput, AField, Btn, Card, PageHeader, Pill, Toggle } from '../components/kit'
const EMPTY = { title: '', short_description: '', description: '', icon: '', sort_order: 0, is_published: false }
function ServiceEditor({ service, onSaved, onClose }) {
const { toast } = useFeedback()
const [current, setCurrent] = useState(service)
const [form, setForm] = useState(
service
? { title: service.title, short_description: service.short_description || '', description: service.description || '', icon: service.icon || '', sort_order: service.sort_order, is_published: service.is_published }
: EMPTY,
)
const [errors, setErrors] = useState({})
const [busy, setBusy] = useState(false)
const set = (k) => (e) => setForm((f) => ({ ...f, [k]: e?.target ? e.target.value : e }))
const save = async (ev) => {
ev.preventDefault()
if (form.title.trim().length < 2) return setErrors({ title: 'Enter a title' })
setBusy(true)
const payload = {
...form,
short_description: form.short_description.trim() || null,
description: form.description.trim() || null,
icon: form.icon.trim() || null,
sort_order: Number(form.sort_order) || 0,
}
try {
const r = current ? await api.put(`/admin/services/${current.id}`, payload) : await api.post('/admin/services', payload)
setCurrent(r.data)
onSaved()
toast(current ? 'Service saved' : 'Service created — you can now add an image')
} catch (err) {
setErrors(fieldErrors(err))
toast(errorMessage(err), 'error')
} finally {
setBusy(false)
}
}
const removeImage = async () => {
try {
const r = await api.delete(`/admin/services/${current.id}/image`)
setCurrent(r.data)
onSaved()
toast('Image removed')
} catch (err) {
toast(errorMessage(err), 'error')
}
}
return (
<div className="space-y-5">
<form onSubmit={save} noValidate className="space-y-4">
<AField label="Title *" error={errors.title} hint='Tip: "Solar for Your Home" shows "Your Home" in green on the website.'>
<input className={aInput} value={form.title} onChange={set('title')} maxLength={150} />
</AField>
<AField label="Short description" error={errors.short_description}>
<input className={aInput} value={form.short_description} onChange={set('short_description')} maxLength={300} />
</AField>
<AField label="Description" error={errors.description}>
<textarea className={`${aInput} min-h-28`} value={form.description} onChange={set('description')} maxLength={10000} />
</AField>
<div className="grid grid-cols-2 gap-3">
<AField label="Display order" hint="Lower numbers appear first">
<input className={aInput} type="number" min="0" value={form.sort_order} onChange={set('sort_order')} />
</AField>
<AField label="Icon name (optional)">
<input className={aInput} value={form.icon} onChange={set('icon')} maxLength={60} />
</AField>
</div>
<Toggle checked={form.is_published} onChange={set('is_published')} label="Published on website" />
<div className="flex justify-end gap-2">
<Btn variant="ghost" onClick={onClose}>Close</Btn>
<Btn type="submit" busy={busy}>{current ? 'Save' : 'Create service'}</Btn>
</div>
</form>
{current && (
<div className="border-t border-line pt-5">
<p className="mb-3 text-[14px] font-bold text-navy">Image</p>
{current.image_url && (
<div className="mb-3 flex items-center gap-3">
<img src={current.thumbnail_url} alt="" className="h-20 w-28 rounded-xl object-cover" />
<Btn variant="danger" className="h-8 text-[12px]" onClick={removeImage}><Trash2 className="size-3.5" /> Remove</Btn>
</div>
)}
<ImageUploader
compact
multiple={false}
field="file"
url={`/admin/services/${current.id}/image`}
onUploaded={(data) => {
setCurrent(data)
onSaved()
toast('Image uploaded and watermarked')
}}
/>
</div>
)}
</div>
)
}
export default function ServicesPage() {
const { data, loading, error, reload } = useApi('/admin/services')
const { toast, confirm } = useFeedback()
const [editing, setEditing] = useState(undefined) // undefined=closed, null=new, obj=edit
const remove = async (s) => {
if (!(await confirm({ title: 'Delete service?', message: `"${s.title}" and its image will be permanently deleted.`, confirmLabel: 'Delete', danger: true }))) return
try {
await api.delete(`/admin/services/${s.id}`)
toast('Service deleted')
reload()
} catch (err) {
toast(errorMessage(err), 'error')
}
}
return (
<>
<PageHeader
title="Services"
subtitle='Published services replace the design slides in the "Powering Homes, Businesses & Beyond" section.'
actions={<Btn onClick={() => setEditing(null)}><Plus className="size-4" /> Add service</Btn>}
/>
{loading && !data ? (
<LoadingBlock />
) : error ? (
<ErrorBlock message={error} onRetry={reload} />
) : data.length === 0 ? (
<EmptyBlock title="No services yet" text="Until you publish services, the website shows the three solutions from the design (Home, Business, Agriculture)." action={<Btn onClick={() => setEditing(null)}><Plus className="size-4" /> Add service</Btn>} />
) : (
<div className="space-y-3">
{data.map((s) => (
<Card key={s.id} className="flex items-center gap-4 p-4 sm:p-4">
<div className="h-16 w-24 shrink-0 overflow-hidden rounded-xl bg-surface">
{s.thumbnail_url ? <img src={s.thumbnail_url} alt="" className="size-full object-cover" /> : <div className="grid size-full place-items-center text-[#98A2B3]"><ImageOff className="size-5" /></div>}
</div>
<div className="min-w-0 flex-1">
<p className="truncate font-bold text-navy">{s.title}</p>
<p className="truncate text-[13px] text-slate">{s.short_description || s.description || 'No description'}</p>
</div>
<Pill on={s.is_published}>{s.is_published ? 'Published' : 'Draft'}</Pill>
<div className="flex gap-1.5">
<Btn variant="ghost" className="size-9 px-0" onClick={() => setEditing(s)} aria-label={`Edit ${s.title}`}><Pencil className="size-4" /></Btn>
<Btn variant="danger" className="size-9 px-0" onClick={() => remove(s)} aria-label={`Delete ${s.title}`}><Trash2 className="size-4" /></Btn>
</div>
</Card>
))}
</div>
)}
<Modal open={editing !== undefined} onClose={() => setEditing(undefined)} title={editing ? 'Edit service' : 'New service'} width="max-w-[620px]">
{editing !== undefined && <ServiceEditor key={editing?.id || 'new'} service={editing} onSaved={reload} onClose={() => setEditing(undefined)} />}
</Modal>
</>
)
}
@@ -0,0 +1,63 @@
import { useState } from 'react'
import { Copy, Trash2 } from 'lucide-react'
import { can, useAuth } from '../../context/AuthContext'
import { useApi } from '../../hooks/useApi'
import api, { errorMessage } from '../../services/api'
import { EmptyBlock, ErrorBlock, LoadingBlock, useFeedback } from '../components/feedback'
import { Btn, Card, fmtDate, PageHeader, Pagination } from '../components/kit'
const PAGE_SIZE = 50
export default function SubscribersPage() {
const { admin } = useAuth()
const { toast, confirm } = useFeedback()
const [page, setPage] = useState(1)
const { data, loading, error, reload } = useApi('/admin/subscribers', { params: { page, page_size: PAGE_SIZE } })
const copyAll = async () => {
try {
await navigator.clipboard.writeText(data.items.map((s) => s.email).join(', '))
toast('Emails on this page copied')
} catch {
toast('Could not access the clipboard', 'error')
}
}
const remove = async (s) => {
if (!(await confirm({ title: 'Remove subscriber?', message: s.email, confirmLabel: 'Remove', danger: true }))) return
try {
await api.delete(`/admin/subscribers/${s.id}`)
toast('Subscriber removed')
reload()
} catch (err) {
toast(errorMessage(err), 'error')
}
}
return (
<>
<PageHeader title="Subscribers" subtitle="Email sign-ups from the website footer." actions={data?.items.length > 0 && <Btn variant="ghost" onClick={copyAll}><Copy className="size-4" /> Copy emails</Btn>} />
{loading && !data ? (
<LoadingBlock />
) : error ? (
<ErrorBlock message={error} onRetry={reload} />
) : data.items.length === 0 ? (
<EmptyBlock title="No subscribers yet" />
) : (
<Card className="p-0 sm:p-0">
<ul className="divide-y divide-line">
{data.items.map((s) => (
<li key={s.id} className="flex items-center justify-between gap-3 px-5 py-3">
<span>
<span className="font-medium text-navy">{s.email}</span>
<span className="ml-2 text-[12px] text-slate">{fmtDate(s.created_at)}</span>
</span>
{can(admin, 'delete') && <Btn variant="danger" className="size-8 px-0" onClick={() => remove(s)} aria-label={`Remove ${s.email}`}><Trash2 className="size-3.5" /></Btn>}
</li>
))}
</ul>
</Card>
)}
{data && <Pagination page={page} pageSize={PAGE_SIZE} total={data.total} onPage={setPage} />}
</>
)
}
@@ -0,0 +1,166 @@
import { useState } from 'react'
import { Pencil, Plus, Star, Trash2, UserRound, Video } from 'lucide-react'
import Modal from '../../components/Modal'
import { useApi } from '../../hooks/useApi'
import api, { errorMessage, fieldErrors } from '../../services/api'
import { EmptyBlock, ErrorBlock, LoadingBlock, useFeedback } from '../components/feedback'
import ImageUploader from '../components/ImageUploader'
import { aInput, AField, Btn, Card, PageHeader, Pill, Toggle } from '../components/kit'
const EMPTY = { customer_name: '', designation: '', location: '', content: '', video_url: '', rating: 5, sort_order: 0, is_published: true }
function Editor({ item, onSaved, onClose }) {
const { toast } = useFeedback()
const [current, setCurrent] = useState(item)
const [form, setForm] = useState(
item
? Object.fromEntries(Object.keys(EMPTY).map((k) => [k, item[k] ?? EMPTY[k]]))
: EMPTY,
)
const [errors, setErrors] = useState({})
const [busy, setBusy] = useState(false)
const set = (k) => (e) => setForm((f) => ({ ...f, [k]: e?.target ? e.target.value : e }))
const save = async (ev) => {
ev.preventDefault()
const e = {}
if (form.customer_name.trim().length < 2) e.customer_name = 'Enter the customer name'
if (form.video_url && !/^https?:\/\//i.test(form.video_url.trim())) e.video_url = 'Paste a full link starting with https://'
setErrors(e)
if (Object.keys(e).length) return
setBusy(true)
const payload = {
...form,
designation: form.designation.trim() || null,
location: form.location.trim() || null,
content: form.content.trim() || null,
video_url: form.video_url.trim() || null,
rating: Number(form.rating),
sort_order: Number(form.sort_order) || 0,
}
try {
const r = current ? await api.put(`/admin/testimonials/${current.id}`, payload) : await api.post('/admin/testimonials', payload)
setCurrent(r.data)
onSaved()
toast(current ? 'Testimonial saved' : 'Testimonial created — you can now add a photo')
} catch (err) {
setErrors(fieldErrors(err))
toast(errorMessage(err), 'error')
} finally {
setBusy(false)
}
}
return (
<div className="space-y-5">
<form onSubmit={save} noValidate className="space-y-4">
<div className="grid gap-3 sm:grid-cols-2">
<AField label="Customer name *" error={errors.customer_name}>
<input className={aInput} value={form.customer_name} onChange={set('customer_name')} maxLength={150} />
</AField>
<AField label="Role" hint="e.g. Homeowner, Business Owner">
<input className={aInput} value={form.designation} onChange={set('designation')} maxLength={150} />
</AField>
</div>
<AField label="Quote" hint="Shown over the video still. Optional for video-only reviews.">
<textarea className={`${aInput} min-h-24`} value={form.content} onChange={set('content')} maxLength={3000} />
</AField>
<AField label="Video link" error={errors.video_url} hint="YouTube link or a direct .mp4 URL">
<input className={aInput} value={form.video_url} onChange={set('video_url')} placeholder="https://www.youtube.com/watch?v=…" maxLength={500} />
</AField>
<div className="grid grid-cols-3 gap-3">
<AField label="Location">
<input className={aInput} value={form.location} onChange={set('location')} maxLength={150} />
</AField>
<AField label="Rating">
<select className={aInput} value={form.rating} onChange={set('rating')}>
{[5, 4, 3, 2, 1].map((n) => <option key={n} value={n}>{n} ★</option>)}
</select>
</AField>
<AField label="Order">
<input className={aInput} type="number" min="0" value={form.sort_order} onChange={set('sort_order')} />
</AField>
</div>
<Toggle checked={form.is_published} onChange={set('is_published')} label="Published on website" />
<div className="flex justify-end gap-2">
<Btn variant="ghost" onClick={onClose}>Close</Btn>
<Btn type="submit" busy={busy}>{current ? 'Save' : 'Create'}</Btn>
</div>
</form>
{current && (
<div className="border-t border-line pt-5">
<p className="mb-3 text-[14px] font-bold text-navy">Video still / customer photo</p>
{current.thumbnail_url && <img src={current.thumbnail_url} alt="" className="mb-3 h-24 w-40 rounded-xl object-cover" />}
<ImageUploader
compact
multiple={false}
field="file"
url={`/admin/testimonials/${current.id}/image`}
onUploaded={(data) => {
setCurrent(data)
onSaved()
toast('Photo uploaded and watermarked')
}}
/>
</div>
)}
</div>
)
}
export default function TestimonialsPage() {
const { data, loading, error, reload } = useApi('/admin/testimonials')
const { toast, confirm } = useFeedback()
const [editing, setEditing] = useState(undefined)
const remove = async (t) => {
if (!(await confirm({ title: 'Delete testimonial?', message: `The testimonial from ${t.customer_name} will be permanently deleted.`, confirmLabel: 'Delete', danger: true }))) return
try {
await api.delete(`/admin/testimonials/${t.id}`)
toast('Testimonial deleted')
reload()
} catch (err) {
toast(errorMessage(err), 'error')
}
}
return (
<>
<PageHeader title="Testimonials" subtitle="Customer reviews shown in the “What Our Customers Say” section." actions={<Btn onClick={() => setEditing(null)}><Plus className="size-4" /> Add testimonial</Btn>} />
{loading && !data ? (
<LoadingBlock />
) : error ? (
<ErrorBlock message={error} onRetry={reload} />
) : data.length === 0 ? (
<EmptyBlock title="No testimonials yet" text="Until you add real testimonials, the website shows the sample cards from the design." action={<Btn onClick={() => setEditing(null)}><Plus className="size-4" /> Add testimonial</Btn>} />
) : (
<div className="grid gap-3 md:grid-cols-2">
{data.map((t) => (
<Card key={t.id} className="flex gap-4 p-4 sm:p-4">
<div className="size-16 shrink-0 overflow-hidden rounded-xl bg-surface">
{t.thumbnail_url ? <img src={t.thumbnail_url} alt="" className="size-full object-cover" /> : <div className="grid size-full place-items-center text-[#98A2B3]"><UserRound className="size-6" /></div>}
</div>
<div className="min-w-0 flex-1">
<div className="flex items-center gap-2">
<p className="truncate font-bold text-navy">{t.customer_name}</p>
{t.video_url && <Video className="size-4 shrink-0 text-brand" aria-label="Has video" />}
</div>
<p className="text-[12px] text-slate">{t.designation} · {Array.from({ length: t.rating }).map((_, i) => <Star key={i} className="inline size-3 fill-yellow text-yellow" />)}</p>
<p className="mt-1 line-clamp-2 text-[13px] text-slate">{t.content || 'No quote'}</p>
<div className="mt-2 flex items-center gap-2">
<Pill on={t.is_published}>{t.is_published ? 'Published' : 'Hidden'}</Pill>
<span className="flex-1" />
<Btn variant="ghost" className="size-8 px-0" onClick={() => setEditing(t)} aria-label="Edit"><Pencil className="size-3.5" /></Btn>
<Btn variant="danger" className="size-8 px-0" onClick={() => remove(t)} aria-label="Delete"><Trash2 className="size-3.5" /></Btn>
</div>
</div>
</Card>
))}
</div>
)}
<Modal open={editing !== undefined} onClose={() => setEditing(undefined)} title={editing ? 'Edit testimonial' : 'New testimonial'} width="max-w-[620px]">
{editing !== undefined && <Editor key={editing?.id || 'new'} item={editing} onSaved={reload} onClose={() => setEditing(undefined)} />}
</Modal>
</>
)
}
+122
View File
@@ -0,0 +1,122 @@
import { useState } from 'react'
import { Navigate } from 'react-router-dom'
import { Plus } from 'lucide-react'
import Modal from '../../components/Modal'
import { can, useAuth } from '../../context/AuthContext'
import { useApi } from '../../hooks/useApi'
import api, { errorMessage, fieldErrors } from '../../services/api'
import { ErrorBlock, LoadingBlock, useFeedback } from '../components/feedback'
import { aInput, AField, Btn, Card, fmtDate, PageHeader, Pill } from '../components/kit'
const ROLES = { super_admin: 'Super admin', admin: 'Admin', editor: 'Editor' }
function UserForm({ user, onDone }) {
const { toast } = useFeedback()
const [form, setForm] = useState({ email: user?.email || '', full_name: user?.full_name || '', role: user?.role || 'editor', password: '', is_active: user?.is_active ?? true })
const [errors, setErrors] = useState({})
const [busy, setBusy] = useState(false)
const set = (k) => (e) => setForm((f) => ({ ...f, [k]: e.target.value }))
const submit = async (ev) => {
ev.preventDefault()
setBusy(true)
try {
if (user) {
const body = { full_name: form.full_name, role: form.role }
if (form.password) body.password = form.password
await api.patch(`/admin/users/${user.id}`, body)
} else {
await api.post('/admin/users', { email: form.email, full_name: form.full_name, role: form.role, password: form.password })
}
toast(user ? 'Account updated' : 'Account created')
onDone()
} catch (err) {
setErrors(fieldErrors(err))
toast(errorMessage(err), 'error')
} finally {
setBusy(false)
}
}
return (
<form onSubmit={submit} noValidate className="space-y-4">
{!user && (
<AField label="Email" error={errors.email}>
<input className={aInput} type="email" value={form.email} onChange={set('email')} autoComplete="off" />
</AField>
)}
<AField label="Full name" error={errors.full_name}>
<input className={aInput} value={form.full_name} onChange={set('full_name')} />
</AField>
<AField label="Role" hint="Editors manage content but cannot delete enquiries or manage accounts.">
<select className={aInput} value={form.role} onChange={set('role')}>
{Object.entries(ROLES).map(([v, l]) => <option key={v} value={v}>{l}</option>)}
</select>
</AField>
<AField label={user ? 'New password (leave empty to keep)' : 'Password'} error={errors.password} hint="At least 10 characters with letters and numbers">
<input className={aInput} type="password" value={form.password} onChange={set('password')} autoComplete="new-password" />
</AField>
<div className="flex justify-end gap-2">
<Btn variant="ghost" onClick={onDone}>Cancel</Btn>
<Btn type="submit" busy={busy}>{user ? 'Save' : 'Create account'}</Btn>
</div>
</form>
)
}
export default function UsersPage() {
const { admin } = useAuth()
const { toast } = useFeedback()
const { data, loading, error, reload } = useApi('/admin/users', { enabled: can(admin, 'users') })
const [editing, setEditing] = useState(undefined)
if (!can(admin, 'users')) return <Navigate to="/admin" replace />
const toggleActive = async (u) => {
try {
await api.patch(`/admin/users/${u.id}`, { is_active: !u.is_active })
toast(u.is_active ? 'Account disabled' : 'Account enabled')
reload()
} catch (err) {
toast(errorMessage(err), 'error')
}
}
return (
<>
<PageHeader title="Admin users" subtitle="People who can sign in to this dashboard." actions={<Btn onClick={() => setEditing(null)}><Plus className="size-4" /> Add user</Btn>} />
{loading && !data ? (
<LoadingBlock />
) : error ? (
<ErrorBlock message={error} onRetry={reload} />
) : (
<Card className="overflow-x-auto p-0 sm:p-0">
<table className="w-full min-w-[640px] text-left text-[14px]">
<thead className="bg-surface text-[12px] font-semibold tracking-wide text-slate uppercase">
<tr><th className="px-5 py-3">Name</th><th className="px-5 py-3">Role</th><th className="px-5 py-3">Last login</th><th className="px-5 py-3">Status</th><th className="px-5 py-3" /></tr>
</thead>
<tbody className="divide-y divide-line">
{data.map((u) => (
<tr key={u.id}>
<td className="px-5 py-3"><p className="font-semibold text-navy">{u.full_name}{u.id === admin.id && <span className="ml-2 text-[12px] font-medium text-slate">(you)</span>}</p><p className="text-[12px] text-slate">{u.email}</p></td>
<td className="px-5 py-3 text-navy">{ROLES[u.role]}</td>
<td className="px-5 py-3 text-slate">{fmtDate(u.last_login_at)}</td>
<td className="px-5 py-3"><Pill on={u.is_active}>{u.is_active ? 'Active' : 'Disabled'}</Pill></td>
<td className="px-5 py-3 text-right">
<div className="flex justify-end gap-2">
<Btn variant="ghost" className="h-8 text-[12px]" onClick={() => setEditing(u)}>Edit</Btn>
{u.id !== admin.id && <Btn variant={u.is_active ? 'danger' : 'ghost'} className="h-8 text-[12px]" onClick={() => toggleActive(u)}>{u.is_active ? 'Disable' : 'Enable'}</Btn>}
</div>
</td>
</tr>
))}
</tbody>
</table>
</Card>
)}
<Modal open={editing !== undefined} onClose={() => setEditing(undefined)} title={editing ? 'Edit account' : 'New admin account'} width="max-w-[480px]">
{editing !== undefined && <UserForm key={editing?.id || 'new'} user={editing} onDone={() => { setEditing(undefined); reload() }} />}
</Modal>
</>
)
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

@@ -0,0 +1,10 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_0_71)">
<path d="M5.54998 14.0125L-0.150024 8.31255L1.27498 6.88755L5.54998 11.1625L14.725 1.98755L16.15 3.41255L5.54998 14.0125Z" fill="black"/>
</g>
<defs>
<clipPath id="clip0_0_71">
<rect width="16" height="16" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 377 B

@@ -0,0 +1,10 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_0_52)">
<path d="M5.54998 14.0008L-0.150024 8.30083L1.27498 6.87583L5.54998 11.1508L14.725 1.97583L16.15 3.40083L5.54998 14.0008Z" fill="black"/>
</g>
<defs>
<clipPath id="clip0_0_52">
<rect width="16" height="16" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 377 B

@@ -0,0 +1,10 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_0_62)">
<path d="M5.5501 14.0133L-0.149902 8.31328L1.2751 6.88828L5.5501 11.1633L14.7251 1.98828L16.1501 3.41328L5.5501 14.0133Z" fill="black"/>
</g>
<defs>
<clipPath id="clip0_0_62">
<rect width="16" height="16" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 376 B

@@ -0,0 +1,10 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_0_80)">
<path d="M5.54998 14.0125L-0.150024 8.31255L1.27498 6.88755L5.54998 11.1625L14.725 1.98755L16.15 3.41255L5.54998 14.0125Z" fill="black"/>
</g>
<defs>
<clipPath id="clip0_0_80">
<rect width="16" height="16" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 377 B

@@ -0,0 +1,3 @@
<svg width="31" height="31" viewBox="0 0 31 31" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M28.4176 18.0831V12.9165M5.16579 7.74982H20.667C22.0939 7.74982 23.2506 8.90641 23.2506 10.3331V20.6665C23.2506 22.0932 22.0939 23.2498 20.667 23.2498H5.16579C3.73894 23.2498 2.58225 22.0932 2.58225 20.6665V10.3331C2.58225 8.90641 3.73894 7.74982 5.16579 7.74982Z" stroke-width="2.81818" stroke-linecap="round" stroke="white"/>
</svg>

After

Width:  |  Height:  |  Size: 440 B

@@ -0,0 +1,3 @@
<svg width="31" height="31" viewBox="0 0 31 31" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M15.4997 25.834V28.4175M15.4997 25.834H21.9585M15.4997 25.834H9.04085M15.4997 2.58213V5.16566M15.4997 5.16566H9.04085M15.4997 5.16566H21.9585M21.9585 25.834V28.4175M21.9585 25.834H23.2503C24.6772 25.834 25.8339 24.6773 25.8339 23.2504V21.9587M21.9585 2.58213V5.16566M21.9585 5.16566H23.2503C24.6772 5.16566 25.8339 6.32235 25.8339 7.7492V9.04097M2.582 15.4998H5.16554M5.16554 15.4998V21.9587M5.16554 15.4998V9.04097M2.582 21.9587H5.16554M5.16554 21.9587V23.2504C5.16554 24.6773 6.32223 25.834 7.74908 25.834H9.04085M2.582 9.04097H5.16554M5.16554 9.04097V7.7492C5.16554 6.32235 6.32223 5.16566 7.74908 5.16566H9.04085M25.8339 15.4998H28.4174M25.8339 15.4998V9.04097M25.8339 15.4998V21.9587M25.8339 21.9587H28.4174M25.8339 9.04097H28.4174M9.04085 25.834V28.4175M9.04085 2.58213V5.16566M11.6244 10.3327H19.375C20.0884 10.3327 20.6668 10.9111 20.6668 11.6245V19.3751C20.6668 20.0886 20.0884 20.6669 19.375 20.6669H11.6244C10.911 20.6669 10.3326 20.0886 10.3326 19.3751V11.6245C10.3326 10.9111 10.911 10.3327 11.6244 10.3327Z" stroke-width="2.81818" stroke-linecap="round" stroke="white"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

@@ -0,0 +1,10 @@
<svg width="31" height="31" viewBox="0 0 31 31" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_5_41)">
<path d="M2.58225 27.1248C2.58225 24.3703 3.78969 22.0334 5.98653 20.6153M5.98653 20.6153C6.88026 20.0384 7.93773 19.6136 9.14428 19.3745C12.2703 18.7545 15.4996 16.791 16.7914 15.4993M5.98653 20.6153C6.48525 21.6838 7.19243 22.6537 8.07763 23.4633C9.75138 24.9941 11.9393 25.84 14.2076 25.8331C20.9504 25.8331 27.1249 20.0203 27.1249 12.9159C27.1249 7.98152 25.8332 5.16557 24.5415 2.58213C21.958 5.78559 20.0204 6.45729 12.6575 7.87818C10.4216 8.26014 8.41102 9.46844 7.02439 11.2634C5.63776 13.0584 4.97641 15.309 5.1715 17.5688C5.26341 18.6335 5.54226 19.6635 5.98653 20.6153Z" stroke-width="2.81818" stroke-linecap="round" stroke="white"/>
</g>
<defs>
<clipPath id="clip0_5_41">
<rect width="30.8171" height="30.8171" fill="white" transform="scale(1.00593)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 921 B

@@ -0,0 +1,3 @@
<svg width="31" height="31" viewBox="0 0 31 31" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14.209 2.58213H16.7924M18.4455 18.0834L15.5004 23.2504M18.4455 18.0834H10.3343C9.87069 18.0833 9.41555 18.2079 9.01668 18.4443C8.6178 18.6807 8.28989 19.02 8.06733 19.4268L5.88845 23.2504M18.4455 18.0834H25.8352C26.0627 18.0832 26.2862 18.143 26.4831 18.2569C26.68 18.3708 26.8434 18.5347 26.9566 18.732C27.0699 18.9293 27.129 19.153 27.1281 19.3804C27.1272 19.6079 27.0662 19.8311 26.9513 20.0275L25.1138 23.2517M15.5004 23.2504L12.5552 28.4175M15.5004 23.2504H25.1133L25.1138 23.2517M15.5004 23.2504H5.88845M12.5552 28.4175H20.6683C21.1314 28.4176 21.5861 28.2932 21.9847 28.0574C22.3833 27.8215 22.7112 27.4827 22.934 27.0767L25.1138 23.2517M12.5552 28.4175H5.16737C4.93982 28.4176 4.71627 28.3576 4.51935 28.2436C4.32244 28.1295 4.15915 27.9654 4.04601 27.768C3.93286 27.5706 3.87389 27.3467 3.87505 27.1192C3.87621 26.8916 3.93746 26.6684 4.0526 26.4721L5.88845 23.2504M27.1259 28.4175L25.1138 23.2517M5.88845 23.2504H5.88707M3.87503 12.9163V15.4998M9.042 2.58213C9.042 3.95252 8.49762 5.26679 7.52863 6.2358C6.55963 7.20482 5.2454 7.7492 3.87503 7.7492M11.1865 9.89374L13.0078 11.7151" stroke-width="2.81818" stroke-linecap="round" stroke="white"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3.33282 3.33364C3.33276 3.09905 3.3946 2.8686 3.5121 2.66554C3.62961 2.46249 3.79862 2.29404 4.00207 2.17718C4.20553 2.06033 4.43622 1.99921 4.67085 2.00001C4.90548 2.0008 5.13575 2.06348 5.3384 2.18172L13.3374 6.84674C13.5393 6.96385 13.7068 7.13189 13.8234 7.33405C13.94 7.53621 14.0014 7.76541 14.0016 7.99876C14.0018 8.2321 13.9408 8.46142 13.8246 8.66378C13.7083 8.86614 13.541 9.03446 13.3394 9.15192L5.3384 13.8183C5.13575 13.9365 4.90548 13.9992 4.67085 14C4.43622 14.0008 4.20553 13.9397 4.00207 13.8228C3.79862 13.706 3.62961 13.5375 3.5121 13.3345C3.3946 13.1314 3.33276 12.9009 3.33282 12.6664V3.33364Z" stroke-width="2" stroke-linecap="round" stroke="#111111"/>
</svg>

After

Width:  |  Height:  |  Size: 788 B

@@ -0,0 +1,10 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_9_228)">
<path d="M1.66602 17.5C1.66602 15.7229 2.44501 14.2152 3.86233 13.3003M3.86233 13.3003C4.43893 12.9281 5.12117 12.654 5.89959 12.4998C7.91637 12.0998 9.99982 10.8331 10.8332 9.9997M3.86233 13.3003C4.18408 13.9897 4.64033 14.6154 5.21142 15.1378C6.29127 16.1254 7.70285 16.6711 9.16621 16.6666C13.5165 16.6666 17.5 12.9165 17.5 8.33296C17.5 5.1495 16.6666 3.33275 15.8333 1.66602C14.1665 3.73277 12.9164 4.16612 8.16616 5.08283C6.72369 5.32925 5.42651 6.10881 4.53191 7.26687C3.63731 8.42493 3.21064 9.87692 3.3365 11.3348C3.3958 12.0217 3.5757 12.6863 3.86233 13.3003Z" stroke-width="2" stroke-linecap="round" stroke="#D2E59E"/>
</g>
<defs>
<clipPath id="clip0_9_228">
<rect width="20" height="20" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 870 B

@@ -0,0 +1,10 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_9_221)">
<path d="M-1 18V8L6 3L13 8L12.2875 8.7125L11.575 9.425L6 5.45L1 9V16H3V11H9V18H7V13H5V18H-1ZM21 0V10.125C20.7167 9.825 20.4083 9.55417 20.075 9.3125C19.7417 9.07083 19.3833 8.85833 19 8.675V2H10V3.4L8 1.95V0H21ZM15 6H17V4H15V6ZM16 20C14.6167 20 13.4375 19.5125 12.4625 18.5375C11.4875 17.5625 11 16.3833 11 15C11 13.6167 11.4875 12.4375 12.4625 11.4625C13.4375 10.4875 14.6167 10 16 10C17.3833 10 18.5625 10.4875 19.5375 11.4625C20.5125 12.4375 21 13.6167 21 15C21 16.3833 20.5125 17.5625 19.5375 18.5375C18.5625 19.5125 17.3833 20 16 20ZM15.5 18H16.5V15.5H19V14.5H16.5V12H15.5V14.5H13V15.5H15.5V18Z" fill="#D2E59E"/>
</g>
<defs>
<clipPath id="clip0_9_221">
<rect width="20" height="20" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 859 B

@@ -0,0 +1,10 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_9_214)">
<path d="M1.98617 17.4995V8.12451L0.18617 9.49951L-0.988831 7.92451L9.98617 -0.500488L20.9862 7.89951L19.7862 9.49951L9.98617 1.99951L3.98617 6.59951V15.4995H7.98617V17.4995H1.98617ZM15.4862 19.8745C14.7862 20.3578 14.0153 20.562 13.1737 20.487C12.332 20.412 11.6112 20.0745 11.0112 19.4745C10.4112 18.8745 10.0737 18.1537 9.99867 17.312C9.92367 16.4703 10.1278 15.6995 10.6112 14.9995C10.1278 14.2995 9.92367 13.5287 9.99867 12.687C10.0737 11.8453 10.4112 11.1245 11.0112 10.5245C11.6112 9.92451 12.332 9.58701 13.1737 9.51201C14.0153 9.43701 14.7862 9.64118 15.4862 10.1245C16.1862 9.64118 16.957 9.43701 17.7987 9.51201C18.6403 9.58701 19.3612 9.92451 19.9612 10.5245C20.5612 11.1245 20.8987 11.8453 20.9737 12.687C21.0487 13.5287 20.8445 14.2995 20.3612 14.9995C20.8445 15.6995 21.0487 16.4703 20.9737 17.312C20.8987 18.1537 20.5612 18.8745 19.9612 19.4745C19.3612 20.0745 18.6403 20.412 17.7987 20.487C16.957 20.562 16.1862 20.3578 15.4862 19.8745ZM15.4862 17.4245L16.6362 18.2245C16.9362 18.4412 17.2612 18.5328 17.6112 18.4995C17.9612 18.4662 18.2695 18.3162 18.5362 18.0495C18.8028 17.7828 18.9528 17.4745 18.9862 17.1245C19.0195 16.7745 18.9278 16.4495 18.7112 16.1495L17.9112 14.9995L18.7112 13.8495C18.9278 13.5495 19.0195 13.2245 18.9862 12.8745C18.9528 12.5245 18.8028 12.2162 18.5362 11.9495C18.2695 11.6828 17.9612 11.5328 17.6112 11.4995C17.2612 11.4662 16.9362 11.5578 16.6362 11.7745L15.4862 12.5745L14.3362 11.7745C14.0362 11.5578 13.7112 11.4662 13.3612 11.4995C13.0112 11.5328 12.7028 11.6828 12.4362 11.9495C12.1695 12.2162 12.0195 12.5245 11.9862 12.8745C11.9528 13.2245 12.0445 13.5495 12.2612 13.8495L13.0612 14.9995L12.2612 16.1495C12.0445 16.4495 11.9528 16.7745 11.9862 17.1245C12.0195 17.4745 12.1695 17.7828 12.4362 18.0495C12.7028 18.3162 13.0112 18.4662 13.3612 18.4995C13.7112 18.5328 14.0362 18.4412 14.3362 18.2245L15.4862 17.4245ZM16.3737 15.887C16.6153 15.6453 16.7362 15.3495 16.7362 14.9995C16.7362 14.6495 16.6153 14.3537 16.3737 14.112C16.132 13.8703 15.8362 13.7495 15.4862 13.7495C15.1362 13.7495 14.8403 13.8703 14.5987 14.112C14.357 14.3537 14.2362 14.6495 14.2362 14.9995C14.2362 15.3495 14.357 15.6453 14.5987 15.887C14.8403 16.1287 15.1362 16.2495 15.4862 16.2495C15.8362 16.2495 16.132 16.1287 16.3737 15.887Z" fill="#D2E59E"/>
</g>
<defs>
<clipPath id="clip0_9_214">
<rect width="20" height="20" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

@@ -0,0 +1,10 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_9_235)">
<path d="M7.25007 20L6.85007 16.8C6.63341 16.7167 6.42924 16.6167 6.23757 16.5C6.04591 16.3833 5.85841 16.2583 5.67507 16.125L2.70007 17.375L-0.0499268 12.625L2.52507 10.675C2.50841 10.5583 2.50007 10.4458 2.50007 10.3375V9.6625C2.50007 9.55417 2.50841 9.44167 2.52507 9.325L-0.0499268 7.375L2.70007 2.625L5.67507 3.875C5.85841 3.74167 6.05007 3.61667 6.25007 3.5C6.45007 3.38333 6.65007 3.28333 6.85007 3.2L7.25007 0H12.7501L13.1501 3.2C13.3667 3.28333 13.5709 3.38333 13.7626 3.5C13.9542 3.61667 14.1417 3.74167 14.3251 3.875L17.3001 2.625L20.0501 7.375L17.4751 9.325C17.4917 9.44167 17.5001 9.55417 17.5001 9.6625V10.3375C17.5001 10.4458 17.4834 10.5583 17.4501 10.675L20.0251 12.625L17.2751 17.375L14.3251 16.125C14.1417 16.2583 13.9501 16.3833 13.7501 16.5C13.5501 16.6167 13.3501 16.7167 13.1501 16.8L12.7501 20H7.25007ZM9.00007 18H10.9751L11.3251 15.35C11.8417 15.2167 12.3209 15.0208 12.7626 14.7625C13.2042 14.5042 13.6084 14.1917 13.9751 13.825L16.4501 14.85L17.4251 13.15L15.2751 11.525C15.3584 11.2917 15.4167 11.0458 15.4501 10.7875C15.4834 10.5292 15.5001 10.2667 15.5001 10C15.5001 9.73333 15.4834 9.47083 15.4501 9.2125C15.4167 8.95417 15.3584 8.70833 15.2751 8.475L17.4251 6.85L16.4501 5.15L13.9751 6.2C13.6084 5.81667 13.2042 5.49583 12.7626 5.2375C12.3209 4.97917 11.8417 4.78333 11.3251 4.65L11.0001 2H9.02507L8.67507 4.65C8.15841 4.78333 7.67924 4.97917 7.23757 5.2375C6.79591 5.49583 6.39174 5.80833 6.02507 6.175L3.55007 5.15L2.57507 6.85L4.72507 8.45C4.64174 8.7 4.58341 8.95 4.55007 9.2C4.51674 9.45 4.50007 9.71667 4.50007 10C4.50007 10.2667 4.51674 10.525 4.55007 10.775C4.58341 11.025 4.64174 11.275 4.72507 11.525L2.57507 13.15L3.55007 14.85L6.02507 13.8C6.39174 14.1833 6.79591 14.5042 7.23757 14.7625C7.67924 15.0208 8.15841 15.2167 8.67507 15.35L9.00007 18ZM10.0501 13.5C11.0167 13.5 11.8417 13.1583 12.5251 12.475C13.2084 11.7917 13.5501 10.9667 13.5501 10C13.5501 9.03333 13.2084 8.20833 12.5251 7.525C11.8417 6.84167 11.0167 6.5 10.0501 6.5C9.06674 6.5 8.23757 6.84167 7.56257 7.525C6.88757 8.20833 6.55007 9.03333 6.55007 10C6.55007 10.9667 6.88757 11.7917 7.56257 12.475C8.23757 13.1583 9.06674 13.5 10.0501 13.5Z" fill="#D2E59E"/>
</g>
<defs>
<clipPath id="clip0_9_235">
<rect width="20" height="20" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

@@ -0,0 +1,3 @@
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.375 11.25L5.625 7.5L9.375 3.75" stroke-width="2.5" stroke-linecap="square" stroke="#666666"/>
</svg>

After

Width:  |  Height:  |  Size: 209 B

@@ -0,0 +1,3 @@
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.625 11.25L9.375 7.5L5.625 3.75" stroke-width="2.5" stroke-linecap="square" stroke="#666666"/>
</svg>

After

Width:  |  Height:  |  Size: 209 B

@@ -0,0 +1,3 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8.7502 1.75H10.5004C10.8226 1.75 11.0838 2.01117 11.0838 2.33333V11.6667C11.0838 11.9888 10.8226 12.25 10.5004 12.25H8.7502C8.428 12.25 8.1668 11.9888 8.1668 11.6667V2.33333C8.1668 2.01117 8.428 1.75 8.7502 1.75ZM3.4996 1.75H5.2498C5.572 1.75 5.8332 2.01117 5.8332 2.33333V11.6667C5.8332 11.9888 5.572 12.25 5.2498 12.25H3.4996C3.1774 12.25 2.9162 11.9888 2.9162 11.6667V2.33333C2.9162 2.01117 3.1774 1.75 3.4996 1.75Z" stroke-width="2" stroke-linecap="round" stroke="white"/>
</svg>

After

Width:  |  Height:  |  Size: 590 B

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8 10V2M11.3333 6.66667L8 10L4.66667 6.66667M14 10V12.6667C14 13.0203 13.8595 13.3594 13.6095 13.6095C13.3594 13.8595 13.0203 14 12.6667 14H3.33333C2.97971 14 2.64057 13.8595 2.39052 13.6095C2.14048 13.3594 2 13.0203 2 12.6667V10" stroke-width="2" stroke-linecap="round" stroke="#224233"/>
</svg>

After

Width:  |  Height:  |  Size: 402 B

@@ -0,0 +1,10 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_0_107)">
<path d="M14.6672 4.66704L8.67268 8.48465C8.46926 8.60278 8.23821 8.66501 8.00296 8.66501C7.76772 8.66501 7.53666 8.60278 7.33324 8.48465L1.33276 4.66704M14.6672 4.66704V4.00044C14.6672 3.26413 14.0702 2.66724 13.3337 2.66724H2.6662C1.92977 2.66724 1.33276 3.26413 1.33276 4.00044V4.66704M14.6672 4.66704V11.9996C14.6672 12.7359 14.0702 13.3328 13.3337 13.3328H2.6662C1.92977 13.3328 1.33276 12.7359 1.33276 11.9996V4.66704" stroke-width="2" stroke-linecap="round" stroke="#224233"/>
</g>
<defs>
<clipPath id="clip0_0_107">
<rect width="16" height="16" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 725 B

@@ -0,0 +1,3 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13.4125 11.4125C13.8042 11.0208 14 10.55 14 10C14 9.45 13.8042 8.97917 13.4125 8.5875C13.0208 8.19583 12.55 8 12 8C11.45 8 10.9792 8.19583 10.5875 8.5875C10.1958 8.97917 10 9.45 10 10C10 10.55 10.1958 11.0208 10.5875 11.4125C10.9792 11.8042 11.45 12 12 12C12.55 12 13.0208 11.8042 13.4125 11.4125ZM12 22C9.31667 19.7167 7.3125 17.5958 5.9875 15.6375C4.6625 13.6792 4 11.8667 4 10.2C4 7.7 4.80417 5.70833 6.4125 4.225C8.02083 2.74167 9.88333 2 12 2C14.1167 2 15.9792 2.74167 17.5875 4.225C19.1958 5.70833 20 7.7 20 10.2C20 11.8667 19.3375 13.6792 18.0125 15.6375C16.6875 17.5958 14.6833 19.7167 12 22Z" fill="#7A8F9F"/>
</svg>

After

Width:  |  Height:  |  Size: 732 B

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10.0002 1.33282H12V3.9997H10.0002C9.82338 3.9997 9.65383 4.06995 9.52881 4.19498C9.4038 4.32002 9.33356 4.4896 9.33356 4.66642V6.66658H12L11.3334 9.33347H9.33356V14.6672H6.66709V9.33347H4.66724V6.66658H6.66709V4.66642C6.66709 3.7823 7.01825 2.93438 7.64333 2.30921C8.26841 1.68404 9.11619 1.33282 10.0002 1.33282Z" fill="#F2BD1F" stroke-linecap="round" stroke="#F2BD1F"/>
</svg>

After

Width:  |  Height:  |  Size: 485 B

@@ -0,0 +1,11 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_43_288)">
<path d="M11.3336 1.33282H4.66636C2.82527 1.33282 1.33276 2.82533 1.33276 4.66642V11.3336C1.33276 13.1747 2.82527 14.6672 4.66636 14.6672H11.3336C13.1747 14.6672 14.6672 13.1747 14.6672 11.3336V4.66642C14.6672 2.82533 13.1747 1.33282 11.3336 1.33282Z" fill="#F2BD1F"/>
<path d="M11.6669 4.33306H11.6736M4.66636 1.33282H11.3336C13.1747 1.33282 14.6672 2.82533 14.6672 4.66642V11.3336C14.6672 13.1747 13.1747 14.6672 11.3336 14.6672H4.66636C2.82527 14.6672 1.33276 13.1747 1.33276 11.3336V4.66642C1.33276 2.82533 2.82527 1.33282 4.66636 1.33282ZM10.6666 7.58019C10.7489 8.13507 10.6542 8.70176 10.3958 9.19967C10.1374 9.69757 9.72867 10.1013 9.22762 10.3535C8.72656 10.6057 8.15875 10.6935 7.60493 10.6044C7.05111 10.5153 6.53949 10.2538 6.14285 9.85715C5.7462 9.4605 5.48472 8.94888 5.39561 8.39507C5.30649 7.84125 5.39427 7.27343 5.64646 6.77238C5.89866 6.27132 6.30242 5.86255 6.80033 5.6042C7.29823 5.34584 7.86493 5.25106 8.4198 5.33335C8.9858 5.41728 9.50979 5.68102 9.91438 6.08561C10.319 6.4902 10.5827 7.0142 10.6666 7.58019Z" stroke-width="1.2" stroke-linecap="round" stroke="#16171D"/>
</g>
<defs>
<clipPath id="clip0_43_288">
<rect width="16" height="16" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

@@ -0,0 +1,6 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13.4955 6.50462C12.7453 5.75444 11.7278 5.33299 10.6668 5.33299C9.60589 5.33299 8.5884 5.75444 7.83819 6.50462C7.08799 7.25479 6.66652 8.27225 6.66652 9.33316V14H9.3334V9.33316C9.3334 8.97952 9.47389 8.64037 9.72396 8.39031C9.97403 8.14025 10.3132 7.99977 10.6668 7.99977C11.0205 7.99977 11.3597 8.14025 11.6097 8.39031C11.8598 8.64037 12.0003 8.97952 12.0003 9.33316V14H14.6672V9.33316C14.6672 8.27225 14.2457 7.25479 13.4955 6.50462Z" fill="#F2BD1F"/>
<path d="M3.99964 5.99969H1.33276V14H3.99964V5.99969Z" fill="#F2BD1F"/>
<path d="M2.6662 3.9996C3.40264 3.9996 3.99964 3.40262 3.99964 2.66621C3.99964 1.9298 3.40264 1.33282 2.6662 1.33282C1.92977 1.33282 1.33276 1.9298 1.33276 2.66621C1.33276 3.40262 1.92977 3.9996 2.6662 3.9996Z" fill="#F2BD1F"/>
<path d="M10.6668 5.33299C11.7278 5.33299 12.7453 5.75444 13.4955 6.50462C14.2457 7.25479 14.6672 8.27225 14.6672 9.33316V14H12.0003V9.33316C12.0003 8.97952 11.8598 8.64037 11.6097 8.39031C11.3597 8.14025 11.0205 7.99977 10.6668 7.99977C10.3132 7.99977 9.97403 8.14025 9.72396 8.39031C9.47389 8.64037 9.3334 8.97952 9.3334 9.33316V14H6.66652V9.33316C6.66652 8.27225 7.08799 7.25479 7.83819 6.50462C8.5884 5.75444 9.60589 5.33299 10.6668 5.33299ZM1.33276 5.99969H3.99964V14H1.33276V5.99969ZM3.99964 2.66621C3.99964 3.40262 3.40264 3.9996 2.6662 3.9996C1.92977 3.9996 1.33276 3.40262 1.33276 2.66621C1.33276 1.9298 1.92977 1.33282 2.6662 1.33282C3.40264 1.33282 3.99964 1.9298 3.99964 2.66621Z" stroke-linecap="round" stroke="#F2BD1F"/>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 4L8 8M8 8L4 12M8 8L4 4M8 8L12 12" stroke-width="3" stroke-linecap="square" stroke="#F2BD1F"/>
</svg>

After

Width:  |  Height:  |  Size: 210 B

@@ -0,0 +1,3 @@
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.7494 12.7493V5.25052H5.25059M12.7494 5.25052L5.25059 12.7493" stroke-width="2.57143" stroke-linecap="square" stroke="#0D0E12"/>
</svg>

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.5 KiB

+187
View File
@@ -0,0 +1,187 @@
import { useState } from 'react'
import { CheckCircle2 } from 'lucide-react'
import api, { errorMessage, fieldErrors } from '../services/api'
import { Field, inputCls, Spinner } from './ui'
const PHONE_RE = /^\+?[0-9\s\-()]{7,20}$/
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/
function useForm(initial) {
const [values, setValues] = useState(initial)
const [errors, setErrors] = useState({})
const set = (k) => (e) => {
setValues((v) => ({ ...v, [k]: e.target.value }))
if (errors[k]) setErrors((er) => ({ ...er, [k]: undefined }))
}
return { values, setValues, errors, setErrors, set }
}
function Success({ title, text, onClose }) {
return (
<div className="flex flex-col items-center py-6 text-center animate-fade-in" role="status">
<CheckCircle2 className="size-14 text-green" strokeWidth={1.75} />
<h3 className="mt-4 text-[24px] font-extrabold text-navy">{title}</h3>
<p className="mt-2 max-w-sm text-[16px] leading-[24px] text-slate">{text}</p>
<button type="button" onClick={onClose} className="mt-8 rounded-full bg-brand px-8 py-3 font-semibold text-white transition hover:bg-[#023a5a]">
Close
</button>
</div>
)
}
function SubmitButton({ busy, children }) {
return (
<button
type="submit"
disabled={busy}
className="inline-flex h-[54px] w-full items-center justify-center gap-2 rounded-full bg-yellow-cta px-8 text-[16px] font-semibold text-black transition hover:brightness-105 disabled:opacity-60"
>
{busy && <Spinner className="size-4" />}
{busy ? 'Sending…' : children}
</button>
)
}
/** "Get a consultation" — saves an enquiry (POST /api/enquiries). */
export function EnquiryForm({ onDone, defaults = {} }) {
const f = useForm({ name: '', phone: '', email: '', city: '', property_type: 'residential', monthly_bill: '', message: '', website: '', ...defaults })
const [busy, setBusy] = useState(false)
const [serverError, setServerError] = useState('')
const [done, setDone] = useState(false)
const validate = () => {
const v = f.values
const e = {}
if (v.name.trim().length < 2) e.name = 'Please enter your name'
if (!PHONE_RE.test(v.phone.trim()) || v.phone.replace(/\D/g, '').length < 7) e.phone = 'Enter a valid phone number'
if (v.email && !EMAIL_RE.test(v.email.trim())) e.email = 'Enter a valid email address'
if (v.monthly_bill && (Number.isNaN(Number(v.monthly_bill)) || Number(v.monthly_bill) < 0)) e.monthly_bill = 'Enter an amount in ₹'
f.setErrors(e)
return Object.keys(e).length === 0
}
const submit = async (ev) => {
ev.preventDefault()
setServerError('')
if (!validate()) return
setBusy(true)
try {
const v = f.values
await api.post('/enquiries', {
...v,
monthly_bill: v.monthly_bill === '' ? null : Number(v.monthly_bill),
})
setDone(true)
} catch (err) {
f.setErrors(fieldErrors(err))
setServerError(errorMessage(err))
} finally {
setBusy(false)
}
}
if (done) return <Success title="Thank you!" text="Our team will contact you shortly to discuss your solar requirements." onClose={onDone} />
return (
<form onSubmit={submit} noValidate className="grid gap-4 sm:grid-cols-2">
<div className="sm:col-span-2">
<Field label="Full name" required error={f.errors.name}>
<input className={inputCls} value={f.values.name} onChange={f.set('name')} autoComplete="name" aria-invalid={!!f.errors.name} />
</Field>
</div>
<Field label="Phone" required error={f.errors.phone}>
<input className={inputCls} type="tel" value={f.values.phone} onChange={f.set('phone')} autoComplete="tel" placeholder="+91 98765 43210" aria-invalid={!!f.errors.phone} />
</Field>
<Field label="Email" error={f.errors.email}>
<input className={inputCls} type="email" value={f.values.email} onChange={f.set('email')} autoComplete="email" aria-invalid={!!f.errors.email} />
</Field>
<Field label="City" error={f.errors.city}>
<input className={inputCls} value={f.values.city} onChange={f.set('city')} autoComplete="address-level2" placeholder="Bhubaneswar" />
</Field>
<Field label="Property type">
<select className={inputCls} value={f.values.property_type} onChange={f.set('property_type')}>
<option value="residential">Residential</option>
<option value="commercial">Commercial</option>
<option value="industrial">Industrial</option>
<option value="other">Agriculture / Other</option>
</select>
</Field>
<div className="sm:col-span-2">
<Field label="Average monthly electricity bill (₹)" error={f.errors.monthly_bill}>
<input className={inputCls} inputMode="numeric" value={f.values.monthly_bill} onChange={f.set('monthly_bill')} placeholder="e.g. 3500" aria-invalid={!!f.errors.monthly_bill} />
</Field>
</div>
<div className="sm:col-span-2">
<Field label="Message" error={f.errors.message}>
<textarea className={`${inputCls} min-h-24`} value={f.values.message} onChange={f.set('message')} maxLength={2000} placeholder="Tell us about your requirement" />
</Field>
</div>
{/* honeypot */}
<input type="text" name="website" value={f.values.website} onChange={f.set('website')} tabIndex={-1} autoComplete="off" className="hidden" aria-hidden />
{serverError && <p className="rounded-lg bg-[#FEF3F2] px-4 py-3 text-[14px] text-[#B42318] sm:col-span-2" role="alert">{serverError}</p>}
<div className="sm:col-span-2">
<SubmitButton busy={busy}>Request consultation</SubmitButton>
</div>
</form>
)
}
/** "Support" — contact message (POST /api/contact). */
export function ContactForm({ onDone }) {
const f = useForm({ name: '', email: '', phone: '', subject: '', message: '', website: '' })
const [busy, setBusy] = useState(false)
const [serverError, setServerError] = useState('')
const [done, setDone] = useState(false)
const submit = async (ev) => {
ev.preventDefault()
setServerError('')
const v = f.values
const e = {}
if (v.name.trim().length < 2) e.name = 'Please enter your name'
if (!EMAIL_RE.test(v.email.trim())) e.email = 'Enter a valid email address'
if (v.phone && !PHONE_RE.test(v.phone.trim())) e.phone = 'Enter a valid phone number'
if (v.message.trim().length < 5) e.message = 'Please write a short message'
f.setErrors(e)
if (Object.keys(e).length) return
setBusy(true)
try {
await api.post('/contact', v)
setDone(true)
} catch (err) {
f.setErrors(fieldErrors(err))
setServerError(errorMessage(err))
} finally {
setBusy(false)
}
}
if (done) return <Success title="Message sent" text="Thank you for reaching out. We'll get back to you soon." onClose={onDone} />
return (
<form onSubmit={submit} noValidate className="grid gap-4 sm:grid-cols-2">
<Field label="Name" required error={f.errors.name}>
<input className={inputCls} value={f.values.name} onChange={f.set('name')} autoComplete="name" aria-invalid={!!f.errors.name} />
</Field>
<Field label="Email" required error={f.errors.email}>
<input className={inputCls} type="email" value={f.values.email} onChange={f.set('email')} autoComplete="email" aria-invalid={!!f.errors.email} />
</Field>
<Field label="Phone" error={f.errors.phone}>
<input className={inputCls} type="tel" value={f.values.phone} onChange={f.set('phone')} autoComplete="tel" aria-invalid={!!f.errors.phone} />
</Field>
<Field label="Subject">
<input className={inputCls} value={f.values.subject} onChange={f.set('subject')} maxLength={200} />
</Field>
<div className="sm:col-span-2">
<Field label="Message" required error={f.errors.message}>
<textarea className={`${inputCls} min-h-28`} value={f.values.message} onChange={f.set('message')} maxLength={5000} aria-invalid={!!f.errors.message} />
</Field>
</div>
<input type="text" name="website" value={f.values.website} onChange={f.set('website')} tabIndex={-1} autoComplete="off" className="hidden" aria-hidden />
{serverError && <p className="rounded-lg bg-[#FEF3F2] px-4 py-3 text-[14px] text-[#B42318] sm:col-span-2" role="alert">{serverError}</p>}
<div className="sm:col-span-2">
<SubmitButton busy={busy}>Send message</SubmitButton>
</div>
</form>
)
}
+61
View File
@@ -0,0 +1,61 @@
import { useEffect, useRef } from 'react'
import { createPortal } from 'react-dom'
import { AnimatePresence, motion } from 'framer-motion'
import { X } from 'lucide-react'
export default function Modal({ open, onClose, title, subtitle, children, width = 'max-w-[560px]' }) {
const panelRef = useRef(null)
useEffect(() => {
if (!open) return
const prev = document.activeElement
const onKey = (e) => e.key === 'Escape' && onClose()
document.addEventListener('keydown', onKey)
document.body.style.overflow = 'hidden'
setTimeout(() => panelRef.current?.querySelector('input,select,textarea,button')?.focus(), 50)
return () => {
document.removeEventListener('keydown', onKey)
document.body.style.overflow = ''
prev?.focus?.()
}
}, [open, onClose])
return createPortal(
<AnimatePresence>
{open && (
<motion.div
className="fixed inset-0 z-[100] flex items-end justify-center bg-[#00070B]/70 p-0 backdrop-blur-sm sm:items-center sm:p-6"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
onMouseDown={(e) => e.target === e.currentTarget && onClose()}
>
<motion.div
ref={panelRef}
role="dialog"
aria-modal="true"
aria-label={title}
className={`relative max-h-[92dvh] w-full ${width} overflow-y-auto rounded-t-[24px] bg-white p-6 shadow-2xl sm:rounded-[24px] sm:p-10`}
initial={{ y: 40, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
exit={{ y: 40, opacity: 0 }}
transition={{ type: 'spring', damping: 28, stiffness: 320 }}
>
<button
type="button"
onClick={onClose}
className="absolute top-4 right-4 grid size-10 place-items-center rounded-full text-slate transition hover:bg-surface hover:text-navy"
aria-label="Close"
>
<X className="size-5" />
</button>
{title && <h2 className="pr-10 text-[28px] leading-[36px] font-extrabold tracking-[-0.8px] text-navy">{title}</h2>}
{subtitle && <p className="mt-2 text-[15px] leading-[24px] text-slate">{subtitle}</p>}
<div className="mt-6">{children}</div>
</motion.div>
</motion.div>
)}
</AnimatePresence>,
document.body,
)
}
+70
View File
@@ -0,0 +1,70 @@
import { ArrowRight } from 'lucide-react'
/** Pill tag with green dot (Figma "meet-experts-tag"). tone: light | dark */
export function Tag({ children, tone = 'light', dot = 'bg-green', className = '' }) {
const toneCls =
tone === 'dark'
? 'border-tag-border bg-[#E4E4E4]/10 text-white'
: 'border-tag-border bg-[#E4E4E4]/10 text-ink-dark'
return (
<span
className={`inline-flex h-[35px] items-center gap-2 rounded-full border px-4 text-[12px] leading-[19px] font-extrabold tracking-[1px] uppercase sm:text-[14px] ${toneCls} ${className}`}
>
<span className={`size-2 shrink-0 rounded-full ${dot}`} aria-hidden />
{children}
</span>
)
}
/** Yellow primary CTA (hero "Get a Custom Quote"). */
export function PrimaryButton({ children, as: Comp = 'button', className = '', ...props }) {
return (
<Comp
className={`group inline-flex h-[54px] items-center gap-2.5 rounded-full border border-white/15 bg-yellow-cta px-8 text-[16px] leading-[22px] font-semibold text-black transition hover:brightness-105 active:scale-[0.98] ${className}`}
{...props}
>
{children}
<ArrowRight className="size-4 transition-transform group-hover:translate-x-0.5" strokeWidth={2.5} aria-hidden />
</Comp>
)
}
/** 64px round arrow (Figma "Arrows": slate, hover lime). */
export function ArrowButton({ direction = 'right', className = '', ...props }) {
return (
<button
type="button"
className={`grid size-12 place-items-center rounded-full bg-slate text-white transition-colors hover:bg-lime hover:text-black disabled:opacity-40 sm:size-16 ${className}`}
{...props}
>
<ArrowRight className={`size-5 sm:size-6 ${direction === 'left' ? 'rotate-180' : ''}`} strokeWidth={3} aria-hidden />
</button>
)
}
export function Spinner({ className = 'size-5' }) {
return (
<span
className={`inline-block animate-spin rounded-full border-2 border-current border-r-transparent ${className}`}
role="status"
aria-label="Loading"
/>
)
}
export function Field({ label, error, required, children, hint }) {
return (
<label className="block">
<span className="mb-1.5 block text-[14px] font-bold text-navy">
{label}
{required && <span className="text-[#B42318]"> *</span>}
</span>
{children}
{hint && !error && <span className="mt-1 block text-[12px] text-slate">{hint}</span>}
{error && <span className="mt-1 block text-[13px] font-medium text-[#B42318]">{error}</span>}
</label>
)
}
export const inputCls =
'w-full rounded-[4px] border border-forest bg-white px-3 py-2.5 font-inter text-[14px] text-forest placeholder:text-[#9AA4AE] outline-none transition focus:border-brand focus:ring-2 focus:ring-brand/20 aria-[invalid=true]:border-[#B42318]'
+123
View File
@@ -0,0 +1,123 @@
// All website copy, taken verbatim from the Figma design.
// Admins can override any block from the dashboard (Website Content); empty fields keep these defaults.
export const CONTENT_DEFAULTS = {
hero: {
tag: 'Rooftop Solar • On-Grid Systems',
title_line1: 'Make Your Own Power With Solar',
title_line2: 'Supported by PM Surya Ghar Subsidy',
subtitle:
'Generate your own electricity with a rooftop solar system designed around your home, energy needs, and budget.',
primary_cta: 'Get a Custom Quote',
secondary_cta: 'Watch Reviews',
nav_cta: 'Get a consultation',
features: [
{ title: 'For Homes', text: 'Rooftop solar for everyday power needs' },
{ title: 'For Businesses', text: 'Solar systems built around your energy use' },
{ title: 'For Farms', text: 'Solar-powered water pumping solutions' },
{ title: 'Complete Installation', text: 'From site assessment to commissioning' },
],
},
solutions: {
tag: 'Solar for every need',
title: 'Powering Homes, Businesses & Beyond',
slides: [
{
prefix: 'Solar for ',
highlight: 'Your Home',
text: 'Generate your own electricity from your rooftop and reduce your dependence on the grid. A well-designed solar system can help lower your monthly power bills while turning unused rooftop space into a source of clean energy.',
category: 'residential',
},
{
prefix: 'Solar for ',
highlight: 'Your Business',
text: 'Use your rooftop to generate electricity for your shop, office, factory, or commercial property. Solar can help reduce a recurring operating expense and give your business greater control over its energy costs.',
category: 'commercial',
},
{
prefix: 'Solar for ',
highlight: 'Agriculture',
text: 'Use solar power for irrigation, water pumping, and other farm operations without relying entirely on conventional electricity or diesel. Solar pumping can provide a dependable energy source while helping reduce ongoing fuel and electricity expenses.',
category: '',
},
],
},
awareness: {
tag: 'Solar Awareness',
title_line1: 'Know Your Solar.',
title_line2: 'Make a Smarter Choice.',
text: 'Solar panels are more than just what you see on a rooftop. From the cells that generate electricity to the inverter that converts it, every part plays a role in how well your system performs.',
button: 'Learn More',
cards: [
{ title: 'High-Efficiency Solar Cells', text: 'Convert sunlight into electricity and generate more power from limited rooftop space.' },
{ title: 'The Right Inverter', text: 'Converts solar energy into usable electricity for your home or business.' },
{ title: 'Built for Indian Conditions', text: 'Designed to perform reliably through heat, dust, rain, and changing weather.' },
{ title: 'More Than Just Panels', text: 'Panels, inverter, wiring, mounting, and safety systems all work together as one system.' },
],
},
myths: {
tag: 'Clarifying solar myths',
title_line1: 'Heard Something About Solar?',
title_line2: 'Let’s Clear It Up.',
text: 'There’s plenty of confusing information around solar panels. Here are straightforward answers to some of the questions and misconceptions.',
items: [
{ question: 'Do solar panels work on cloudy or rainy days?', answer: 'Yes. Panels can still generate electricity from diffused daylight, although output is lower than on a bright, sunny day.' },
{ question: 'Do solar panels work at night?', answer: 'No. Solar panels need light to generate electricity. At night, homes can use grid power or stored energy from a battery system.' },
{ question: 'Do solar panels need a lot of maintenance?', answer: "Not usually. Routine cleaning and occasional system checks help keep panels performing well, but solar systems don't require constant maintenance." },
{ question: 'Will solar completely eliminate my electricity bill?', answer: 'Not necessarily. Solar can significantly reduce energy charges, but fixed or other applicable grid-related charges may still remain.' },
{ question: 'Do solar panels stop being useful after a few years?', answer: 'No. Solar panels are designed for long-term operation and typically continue producing electricity for decades, although their output gradually declines over time.' },
],
},
quotation: {
title: 'Get Your Custom Solar Quote',
text: 'Tell us about your home or business and get an estimated solar system size, installation cost, and potential savings based on your requirements.',
default_location: 'Bhubaneswar, India',
},
process: {
// NOTE: the Figma file uses this tag here too (copied from the myths section) — editable in admin.
tag: 'Clarifying solar myths',
title_line1: 'From First Consultation to Solar',
title_prefix: 'in ',
title_highlight: '4 Simple Steps',
text: 'Our team takes care of the key stages of your solar installation, from assessing your requirements and designing the system to installation and final commissioning.',
steps: [
{ title: 'Consultation & Site Assessment', text: 'We assess your energy needs, roof space, and site conditions.' },
{ title: 'System Design & Quotation', text: 'We design the right system and provide a clear quotation.' },
{ title: 'Professional Installation', text: 'Our team installs the panels & all essential system components.' },
{ title: 'Testing & Commissioning', text: 'We test, connect, and commission your system, ready to generate power.' },
],
},
testimonials: {
tag: 'Trusted voices',
title: 'What Our Customers Say',
text: 'Hear directly from customers about their experience with Saura Shakti, from installation to the difference solar has made for their homes and businesses.',
},
footer: {
// The Figma footer contains template text ("Evora…"); replaced with Saura Shakti wording.
description: 'Saura Shakti Enterprise Private Limited — rooftop and on-grid solar for homes, businesses and farms.',
copyright: '© 2026 Saura Shakti Enterprise Private Limited. All rights reserved.',
},
contact: {
phone: '',
email: '',
address: '',
twitter_url: '',
facebook_url: '',
linkedin_url: '',
instagram_url: '',
},
legal: {
terms: '',
privacy: '',
},
}
// Design sample testimonials (names/roles/stills from Figma). Shown only until real
// testimonials are added in the admin dashboard. Only one quote exists in the design.
export const DESIGN_TESTIMONIALS = [
{ customer_name: 'Priya Nair', designation: 'Homeowner', still: 'thumb-1' },
{ customer_name: 'Amit Mishra', designation: 'Business Owner', still: 'thumb-2' },
{ customer_name: 'Sanjay Behera', designation: 'Homeowner', still: 'thumb-3' },
{ customer_name: 'Ananya Das', designation: 'Property Owner', still: 'thumb-4' },
{ customer_name: 'Rajesh Kumar', designation: 'Homeowner', content: 'The team explained everything clearly, handled the installation professionally, and made the whole process much easier than I expected.', still: 'featured' },
]
+61
View File
@@ -0,0 +1,61 @@
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'
import api, { onUnauthorized, tokenStore } from '../services/api'
const AuthContext = createContext(null)
export function AuthProvider({ children }) {
const [admin, setAdmin] = useState(null)
const [loading, setLoading] = useState(Boolean(tokenStore.get()))
const [sessionMessage, setSessionMessage] = useState('')
useEffect(() => {
if (!tokenStore.get()) return
api
.get('/auth/me')
.then((r) => setAdmin(r.data))
.catch(() => setAdmin(null))
.finally(() => setLoading(false))
}, [])
useEffect(
() =>
onUnauthorized((detail) => {
setAdmin(null)
setSessionMessage(detail || 'Your session has ended. Please log in again.')
}),
[],
)
const login = useCallback(async (email, password) => {
const { data } = await api.post('/auth/login', { email, password })
tokenStore.set(data.access_token)
setSessionMessage('')
setAdmin(data.admin)
return data.admin
}, [])
const logout = useCallback(() => {
tokenStore.clear()
setAdmin(null)
}, [])
const value = useMemo(
() => ({ admin, loading, login, logout, sessionMessage, setAdmin }),
[admin, loading, login, logout, sessionMessage],
)
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>
}
// eslint-disable-next-line react-refresh/only-export-components
export function useAuth() {
const ctx = useContext(AuthContext)
if (!ctx) throw new Error('useAuth must be used inside AuthProvider')
return ctx
}
export const can = (admin, action) => {
if (!admin) return false
if (action === 'delete') return admin.role !== 'editor'
if (action === 'users') return admin.role === 'super_admin'
return true
}
+37
View File
@@ -0,0 +1,37 @@
import { createContext, useContext, useEffect, useState } from 'react'
import api from '../services/api'
import { CONTENT_DEFAULTS } from '../content/defaults'
const ContentContext = createContext({ blocks: {}, loaded: false })
/** Loads admin-editable content blocks once; sections fall back to the Figma copy. */
export function ContentProvider({ children }) {
const [state, setState] = useState({ blocks: {}, loaded: false })
useEffect(() => {
let alive = true
api
.get('/content')
.then((r) => alive && setState({ blocks: r.data || {}, loaded: true }))
.catch(() => alive && setState({ blocks: {}, loaded: true }))
return () => {
alive = false
}
}, [])
return <ContentContext.Provider value={state}>{children}</ContentContext.Provider>
}
// eslint-disable-next-line react-refresh/only-export-components
export function useContent(key) {
const { blocks } = useContext(ContentContext)
const defaults = CONTENT_DEFAULTS[key] || {}
const override = blocks[key]
if (!override || typeof override !== 'object') return defaults
// Shallow merge: any field the admin left empty keeps the design default.
const merged = { ...defaults }
for (const [k, v] of Object.entries(override)) {
if (v === null || v === undefined || v === '') continue
if (Array.isArray(v) && v.length === 0) continue
merged[k] = v
}
return merged
}
+33
View File
@@ -0,0 +1,33 @@
import { createContext, useCallback, useContext, useMemo, useState } from 'react'
import Modal from '../components/Modal'
import { ContactForm, EnquiryForm } from '../components/LeadForms'
const LeadModalContext = createContext({ openConsultation: () => {}, openSupport: () => {} })
export function LeadModalProvider({ children }) {
const [which, setWhich] = useState(null)
const close = useCallback(() => setWhich(null), [])
const value = useMemo(
() => ({ openConsultation: () => setWhich('consultation'), openSupport: () => setWhich('support') }),
[],
)
return (
<LeadModalContext.Provider value={value}>
{children}
<Modal
open={which === 'consultation'}
onClose={close}
title="Get a consultation"
subtitle="Share a few details and our solar experts will call you back."
>
<EnquiryForm onDone={close} />
</Modal>
<Modal open={which === 'support'} onClose={close} title="Support" subtitle="Questions about your system or our services? Send us a message.">
<ContactForm onDone={close} />
</Modal>
</LeadModalContext.Provider>
)
}
// eslint-disable-next-line react-refresh/only-export-components
export const useLeadModal = () => useContext(LeadModalContext)
+32
View File
@@ -0,0 +1,32 @@
import { useCallback, useEffect, useRef, useState } from 'react'
import api, { errorMessage } from '../services/api'
/** GET a resource with loading/error state. `reload()` refetches. */
export function useApi(url, { params, enabled = true } = {}) {
const [data, setData] = useState(null)
const [loading, setLoading] = useState(enabled)
const [error, setError] = useState('')
const paramsKey = JSON.stringify(params || {})
const reqId = useRef(0)
const load = useCallback(async () => {
if (!enabled || !url) return
const id = ++reqId.current
setLoading(true)
setError('')
try {
const res = await api.get(url, { params: JSON.parse(paramsKey) })
if (id === reqId.current) setData(res.data)
} catch (e) {
if (id === reqId.current) setError(errorMessage(e))
} finally {
if (id === reqId.current) setLoading(false)
}
}, [url, paramsKey, enabled])
useEffect(() => {
load()
}, [load])
return { data, loading, error, reload: load, setData }
}
+77
View File
@@ -0,0 +1,77 @@
@import 'tailwindcss';
/* Design tokens taken from the Figma file (see design/DESIGN_ANALYSIS.md) */
@theme {
--font-sans: 'Manrope', ui-sans-serif, system-ui, sans-serif;
--font-inter: 'Inter', ui-sans-serif, system-ui, sans-serif;
--color-navy: #0f172a;
--color-brand: #034c75;
--color-green: #66bb22;
--color-green-text: #1fad20;
--color-green-bright: #4ade80;
--color-lime: #acd860;
--color-pale-lime: #d2e59e;
--color-yellow: #f2bd1f;
--color-yellow-cta: #edbd20;
--color-yellow-sub: #f0bc25;
--color-yellow-badge: #f2bc20;
--color-slate: #4d5660;
--color-muted: #7a8f9f;
--color-forest: #224233;
--color-ink: #1c2421;
--color-ink-dark: #0b0b0f;
--color-ink-blue: #0b1528;
--color-tag-border: #c4c4c4;
--color-line: #e2e8f0;
--color-surface: #f4f6f8;
--color-surface-2: #f7f7f7;
--color-footer: #010f1c;
--color-social: #16171d;
--color-social-border: #1e2028;
--text-h1: 48px;
--text-h1--line-height: 64px;
--text-h1--letter-spacing: -1.5px;
--text-h2: 48px;
--text-h2--line-height: 56px;
--text-h2--letter-spacing: -1.5px;
--text-lead: 20px;
--text-lead--line-height: 32px;
--text-card: 24px;
--text-card--line-height: 32px;
--animate-fade-in: fade-in 0.4s ease-out both;
}
@keyframes fade-in {
from { opacity: 0; transform: translateY(6px); }
to { opacity: 1; transform: none; }
}
@layer base {
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
@apply bg-white font-sans text-navy antialiased;
overflow-x: hidden;
}
/* anchor targets clear the sticky navbar */
section[id] { scroll-margin-top: 96px; }
:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
}
@layer components {
/* 1280px content column with 80px gutters at 1440 (Figma), smaller gutters below */
.container-site { @apply mx-auto w-full max-w-[1440px] px-4 sm:px-8 lg:px-12 xl:px-20; }
.h2 {
@apply text-[32px] leading-[40px] font-extrabold tracking-[-1px] sm:text-[40px] sm:leading-[48px] lg:text-h2 lg:leading-[56px] lg:tracking-[-1.5px];
}
.lead { @apply text-[17px] leading-[28px] lg:text-lead lg:leading-[32px]; }
}
@media (prefers-reduced-motion: reduce) {
html { scroll-behavior: auto; }
*, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
+16
View File
@@ -0,0 +1,16 @@
import { Outlet } from 'react-router-dom'
import Navbar from '../sections/Navbar'
import Footer from '../sections/Footer'
/** Inner pages: dark band behind the navbar, then content, then the footer. */
export default function PublicLayout() {
return (
<>
<Navbar overlay={false} />
<main className="min-h-[60vh]">
<Outlet />
</main>
<Footer />
</>
)
}
+25
View File
@@ -0,0 +1,25 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { BrowserRouter } from 'react-router-dom'
import '@fontsource/manrope/400.css'
import '@fontsource/manrope/500.css'
import '@fontsource/manrope/600.css'
import '@fontsource/manrope/700.css'
import '@fontsource/manrope/800.css'
import '@fontsource/inter/400.css'
import '@fontsource/inter/500.css'
import '@fontsource/inter/600.css'
import '@fontsource/inter/700.css'
import '@fontsource/inter/900.css'
import './index.css'
import App from './App.jsx'
createRoot(document.getElementById('root')).render(
<StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</StrictMode>,
)
+42
View File
@@ -0,0 +1,42 @@
import { useEffect } from 'react'
import { useLocation } from 'react-router-dom'
import Navbar from '../sections/Navbar'
import Hero from '../sections/Hero'
import Solutions from '../sections/Solutions'
import Awareness from '../sections/Awareness'
import Myths from '../sections/Myths'
import Quotation from '../sections/Quotation'
import Process from '../sections/Process'
import Testimonials from '../sections/Testimonials'
import Footer from '../sections/Footer'
export default function HomePage() {
const { hash } = useLocation()
// Arriving from another page with /#section → scroll once the section exists.
useEffect(() => {
if (!hash) return
const t = setTimeout(() => document.getElementById(hash.slice(1))?.scrollIntoView({ behavior: 'smooth' }), 80)
return () => clearTimeout(t)
}, [hash])
useEffect(() => {
document.title = 'Saura Shakti — Rooftop Solar with PM Surya Ghar Subsidy'
}, [])
return (
<>
<Navbar />
<main>
<Hero />
<Solutions />
<Awareness />
<Myths />
<Quotation />
<Process />
<Testimonials />
</main>
<Footer />
</>
)
}
+37
View File
@@ -0,0 +1,37 @@
import { useEffect } from 'react'
import { Link } from 'react-router-dom'
import { useContent } from '../context/ContentContext'
const TITLES = { terms: 'Terms of Use', privacy: 'Privacy Policy' }
export default function LegalPage({ kind }) {
const legal = useContent('legal')
const text = legal[kind]
useEffect(() => {
document.title = `${TITLES[kind]} — Saura Shakti`
}, [kind])
return (
<div className="container-site py-14 lg:py-20">
<article className="mx-auto max-w-[760px]">
<h1 className="h2 text-navy">{TITLES[kind]}</h1>
{text ? (
<div className="mt-8 text-[16px] leading-7 whitespace-pre-line text-navy">{text}</div>
) : (
<p className="mt-8 rounded-[12px] bg-surface p-6 text-[16px] leading-7 text-slate">
This page is being prepared. For any questions please <Link to="/" className="font-semibold text-brand underline">contact our team</Link>.
</p>
)}
</article>
</div>
)
}
export function NotFoundPage() {
return (
<div className="container-site py-24 text-center">
<p className="font-inter text-[64px] font-black text-brand">404</p>
<h1 className="mt-2 text-[28px] font-extrabold text-navy">Page not found</h1>
<Link to="/" className="mt-6 inline-flex rounded-full bg-yellow-cta px-8 py-3.5 font-semibold text-black">Back to home</Link>
</div>
)
}
+104
View File
@@ -0,0 +1,104 @@
import { useCallback, useEffect, useState } from 'react'
import { Link, useParams } from 'react-router-dom'
import { AnimatePresence, motion } from 'framer-motion'
import { ArrowLeft, CalendarDays, ChevronLeft, ChevronRight, MapPin, X, Zap } from 'lucide-react'
import { Spinner, Tag } from '../components/ui'
import { useApi } from '../hooks/useApi'
import { useLeadModal } from '../context/LeadModalContext'
function Lightbox({ images, index, onClose, onMove }) {
useEffect(() => {
const onKey = (e) => {
if (e.key === 'Escape') onClose()
if (e.key === 'ArrowRight') onMove(1)
if (e.key === 'ArrowLeft') onMove(-1)
}
document.addEventListener('keydown', onKey)
document.body.style.overflow = 'hidden'
return () => {
document.removeEventListener('keydown', onKey)
document.body.style.overflow = ''
}
}, [onClose, onMove])
const img = images[index]
return (
<motion.div className="fixed inset-0 z-[100] flex items-center justify-center bg-black/90 p-4" initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} role="dialog" aria-modal="true" aria-label="Photo viewer">
<button type="button" onClick={onClose} className="absolute top-4 right-4 grid size-11 place-items-center rounded-full bg-white/10 text-white hover:bg-white/20" aria-label="Close"><X /></button>
{images.length > 1 && (
<>
<button type="button" onClick={() => onMove(-1)} className="absolute left-3 grid size-11 place-items-center rounded-full bg-white/10 text-white hover:bg-white/20" aria-label="Previous photo"><ChevronLeft /></button>
<button type="button" onClick={() => onMove(1)} className="absolute right-3 grid size-11 place-items-center rounded-full bg-white/10 text-white hover:bg-white/20" aria-label="Next photo"><ChevronRight /></button>
</>
)}
<figure className="flex max-h-full max-w-6xl flex-col items-center gap-3">
<img src={img.url} alt={img.caption || ''} className="max-h-[85vh] w-auto rounded-lg object-contain" />
<figcaption className="text-center text-[14px] text-white/80">
{img.caption} <span className="text-white/50">{index + 1} / {images.length}</span>
</figcaption>
</figure>
</motion.div>
)
}
export default function ProjectDetailPage() {
const { slug } = useParams()
const { data: p, loading, error } = useApi(`/projects/${encodeURIComponent(slug)}`)
const [lightbox, setLightbox] = useState(-1)
const { openConsultation } = useLeadModal()
const move = useCallback((d) => setLightbox((i) => (i + d + (p?.images.length || 1)) % (p?.images.length || 1)), [p])
const close = useCallback(() => setLightbox(-1), [])
useEffect(() => {
if (p) document.title = `${p.title} — Saura Shakti`
}, [p])
if (loading) return <div className="grid place-items-center py-32 text-brand"><Spinner className="size-8" /></div>
if (error || !p)
return (
<div className="container-site py-24 text-center">
<h1 className="text-[28px] font-extrabold text-navy">Project not found</h1>
<Link to="/projects" className="mt-6 inline-flex items-center gap-2 font-semibold text-brand"><ArrowLeft className="size-4" /> All projects</Link>
</div>
)
const date = p.installation_date ? new Date(p.installation_date).toLocaleDateString('en-IN', { month: 'long', year: 'numeric' }) : null
return (
<article className="bg-surface-2 py-12 lg:py-16">
<div className="container-site flex flex-col gap-10">
<Link to="/projects" className="inline-flex items-center gap-2 self-start text-[15px] font-semibold text-brand hover:underline"><ArrowLeft className="size-4" /> All projects</Link>
<header className="flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between">
<div className="flex flex-col gap-4">
<Tag className="self-start">{p.category} · {p.status}</Tag>
<h1 className="h2 max-w-[860px] text-navy">{p.title}</h1>
<ul className="flex flex-wrap gap-x-6 gap-y-2 text-[16px] font-semibold text-slate">
{p.capacity_kw && <li className="flex items-center gap-2"><Zap className="size-5 text-yellow-badge" />{p.capacity_kw} kW system</li>}
{p.location && <li className="flex items-center gap-2"><MapPin className="size-5 text-muted" />{p.location}</li>}
{date && <li className="flex items-center gap-2"><CalendarDays className="size-5 text-muted" />Installed {date}</li>}
</ul>
</div>
<button type="button" onClick={openConsultation} className="inline-flex h-[54px] shrink-0 items-center justify-center rounded-full bg-yellow-cta px-8 font-semibold text-black hover:brightness-105">
Get a similar system
</button>
</header>
{p.description && <p className="lead max-w-[860px] whitespace-pre-line text-navy">{p.description}</p>}
{p.images.length > 0 ? (
<ul className="grid grid-cols-2 gap-3 sm:gap-4 lg:grid-cols-3">
{p.images.map((img, i) => (
<li key={img.id} className={i === 0 && p.images.length >= 3 ? 'col-span-2 row-span-2' : ''}>
<button type="button" onClick={() => setLightbox(i)} className="group block size-full overflow-hidden rounded-[16px] bg-surface" aria-label={`Open photo ${i + 1}`}>
<img src={i === 0 && p.images.length >= 3 ? img.url : img.thumbnail_url} alt={img.caption || `${p.title} photo ${i + 1}`} className="aspect-[4/3] size-full object-cover transition duration-700 group-hover:scale-105" loading={i < 3 ? 'eager' : 'lazy'} />
</button>
</li>
))}
</ul>
) : (
<p className="rounded-[24px] bg-white p-10 text-center text-slate">Photos for this project will be added soon.</p>
)}
</div>
<AnimatePresence>{lightbox >= 0 && <Lightbox images={p.images} index={lightbox} onClose={close} onMove={move} />}</AnimatePresence>
</article>
)
}
+117
View File
@@ -0,0 +1,117 @@
import { useEffect } from 'react'
import { Link, useSearchParams } from 'react-router-dom'
import { motion } from 'framer-motion'
import { ImageOff, MapPin, Zap } from 'lucide-react'
import { Spinner, Tag } from '../components/ui'
import { useApi } from '../hooks/useApi'
const FILTERS = [
{ value: '', label: 'All projects' },
{ value: 'residential', label: 'Residential' },
{ value: 'commercial', label: 'Commercial' },
]
const PAGE_SIZE = 12
export function ProjectCard({ p, i = 0 }) {
return (
<motion.li initial={{ opacity: 0, y: 16 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.4, delay: (i % 6) * 0.05 }}>
<Link to={`/projects/${p.slug}`} className="group flex h-full flex-col overflow-hidden rounded-[24px] bg-white ring-1 ring-line transition hover:-translate-y-1 hover:shadow-[0_16px_40px_rgba(15,23,42,0.10)]">
<div className="relative aspect-[4/3] overflow-hidden bg-surface">
{p.featured_image ? (
<img src={p.featured_image.thumbnail_url} alt={p.title} className="size-full object-cover transition duration-700 group-hover:scale-105" loading="lazy" />
) : (
<div className="grid size-full place-items-center text-muted"><ImageOff className="size-8" /></div>
)}
<span className="absolute top-4 left-4 rounded-full bg-footer/80 px-3 py-1 text-[12px] font-extrabold tracking-[1px] text-white uppercase backdrop-blur">
{p.category}
</span>
</div>
<div className="flex flex-1 flex-col gap-3 p-6">
<h3 className="text-[20px] leading-7 font-bold text-navy">{p.title}</h3>
<div className="mt-auto flex flex-wrap gap-x-5 gap-y-1 text-[14px] font-semibold text-slate">
{p.capacity_kw && <span className="flex items-center gap-1.5"><Zap className="size-4 text-yellow-badge" />{p.capacity_kw} kW</span>}
{p.location && <span className="flex items-center gap-1.5"><MapPin className="size-4 text-muted" />{p.location}</span>}
</div>
</div>
</Link>
</motion.li>
)
}
export default function ProjectsPage() {
const [params, setParams] = useSearchParams()
const category = params.get('category') || ''
const page = Math.max(1, Number(params.get('page')) || 1)
const { data, loading, error, reload } = useApi('/projects', {
params: { page, page_size: PAGE_SIZE, ...(category ? { category } : {}) },
})
const pages = data ? Math.max(1, Math.ceil(data.total / PAGE_SIZE)) : 1
useEffect(() => {
document.title = 'Our Projects — Saura Shakti'
}, [])
const setFilter = (value) => setParams(value ? { category: value } : {})
return (
<div className="bg-surface-2 py-14 lg:py-20">
<div className="container-site flex flex-col gap-10">
<header className="flex flex-col gap-4">
<Tag className="self-start">Completed installations</Tag>
<h1 className="h2 text-navy">Our Solar Projects</h1>
<p className="lead max-w-[720px] text-navy">Rooftop and on-grid systems installed by the Saura Shakti team for homes and businesses.</p>
</header>
<div className="flex flex-wrap gap-2" role="tablist" aria-label="Filter projects">
{FILTERS.map((f) => (
<button
key={f.value}
type="button"
role="tab"
aria-selected={category === f.value}
onClick={() => setFilter(f.value)}
className={`h-[37px] rounded-full px-6 font-inter text-[14px] transition ${category === f.value ? 'bg-lime text-black' : 'border border-forest bg-white text-navy hover:bg-lime/30'}`}
>
{f.label}
</button>
))}
</div>
{loading && !data ? (
<div className="grid place-items-center py-24 text-brand"><Spinner className="size-8" /></div>
) : error ? (
<div className="rounded-[24px] bg-white p-10 text-center">
<p className="text-[16px] text-[#B42318]">{error}</p>
<button type="button" onClick={reload} className="mt-4 rounded-full bg-brand px-6 py-2.5 font-semibold text-white">Try again</button>
</div>
) : data.items.length === 0 ? (
<div className="rounded-[24px] bg-white p-12 text-center">
<p className="text-[18px] font-semibold text-navy">No projects published yet.</p>
<p className="mt-2 text-slate">Check back soon — new installations are added regularly.</p>
</div>
) : (
<>
<ul className={`grid gap-6 sm:grid-cols-2 lg:grid-cols-3 ${loading ? 'opacity-60' : ''}`}>
{data.items.map((p, i) => <ProjectCard key={p.id} p={p} i={i} />)}
</ul>
{pages > 1 && (
<nav className="flex items-center justify-center gap-2" aria-label="Pagination">
{Array.from({ length: pages }, (_, i) => i + 1).map((n) => (
<button
key={n}
type="button"
onClick={() => setParams({ ...(category ? { category } : {}), page: String(n) })}
aria-current={n === page ? 'page' : undefined}
className={`size-10 rounded-full font-inter text-[14px] font-semibold ${n === page ? 'bg-brand text-white' : 'bg-white text-navy ring-1 ring-line hover:bg-surface'}`}
>
{n}
</button>
))}
</nav>
)}
</>
)}
</div>
</div>
)
}
+72
View File
@@ -0,0 +1,72 @@
import { motion } from 'framer-motion'
import bg from '../assets/images/awareness-bg.webp'
import iconPanel from '../assets/icons/cards-container__solar-panel.svg'
import iconBattery from '../assets/icons/cards-container__battery.svg'
import iconCpu from '../assets/icons/cards-container__cpu.svg'
import iconLeaf from '../assets/icons/cards-container__leaf.svg'
import { Tag } from '../components/ui'
import { useContent } from '../context/ContentContext'
const ICONS = [iconPanel, iconBattery, iconCpu, iconLeaf]
export default function Awareness() {
const c = useContent('awareness')
return (
<section id="awareness" className="relative isolate overflow-hidden py-16 text-white lg:py-20" aria-label="Solar awareness">
<img src={bg} alt="" className="absolute inset-0 -z-20 size-full object-cover" loading="lazy" />
<div className="absolute inset-0 -z-10 bg-ink-blue/65" aria-hidden />
<div className="container-site flex flex-col gap-14 lg:gap-[120px]">
<div className="flex flex-col gap-8 lg:flex-row lg:justify-between">
<div className="flex max-w-[630px] flex-col gap-[22px]">
<Tag tone="dark" dot="bg-green-bright" className="self-start border-white/15 bg-white/10">
{c.tag}
</Tag>
<h2 className="h2">
{c.title_line1}
<br />
{c.title_line2}
</h2>
</div>
<div className="flex max-w-[593px] flex-col items-start gap-[25px]">
<p className="lead">{c.text}</p>
<a
href="#myths"
className="inline-flex h-14 items-center rounded-[140px] bg-white px-[34px] font-inter text-[18px] leading-[22px] font-semibold text-ink-blue transition hover:bg-pale-lime"
>
{c.button}
</a>
</div>
</div>
<ul className="grid grid-cols-1 gap-[22px] sm:grid-cols-2 lg:grid-cols-4">
{c.cards.slice(0, 4).map((card, i) => {
const iconFirst = i % 2 === 0 // Figma: cards 1 & 3 icon on top, 2 & 4 icon at bottom
const icon = (
<span className="grid size-14 place-items-center rounded-[12px] border-[1.4px] border-white/17 bg-white/7">
<img src={ICONS[i]} alt="" className="size-[31px]" aria-hidden />
</span>
)
return (
<motion.li
key={card.title}
className="flex min-h-[280px] flex-col justify-between gap-10 rounded-[34px] border-[1.4px] border-white/60 bg-white/7 p-[34px] backdrop-blur-[22px] lg:min-h-[320px]"
initial={{ opacity: 0, y: 24 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true, margin: '-60px' }}
transition={{ duration: 0.5, delay: i * 0.08 }}
>
{iconFirst && icon}
<div className="flex flex-col gap-[11px]">
<h3 className="text-card leading-8 font-semibold">{card.title}</h3>
<p className="text-[16px] leading-6">{card.text}</p>
</div>
{!iconFirst && icon}
</motion.li>
)
})}
</ul>
</div>
</section>
)
}
+151
View File
@@ -0,0 +1,151 @@
import { useState } from 'react'
import { Link, useLocation } from 'react-router-dom'
import { ArrowUpRight } from 'lucide-react'
import logo from '../assets/images/logo.webp'
import panel from '../assets/images/footer-panel.webp'
import iconX from '../assets/icons/social-icons__x.svg'
import iconFb from '../assets/icons/social-icons__facebook.svg'
import iconIn from '../assets/icons/social-icons__linkedin.svg'
import iconIg from '../assets/icons/social-icons__instagram.svg'
import { Spinner } from '../components/ui'
import { useContent } from '../context/ContentContext'
import { useLeadModal } from '../context/LeadModalContext'
import api, { errorMessage } from '../services/api'
const FOOTER_LINKS = [
{ label: 'Solution', id: 'solutions' },
{ label: 'Awareness', id: 'awareness' },
{ label: 'Myths', id: 'myths' },
{ label: 'Quotation', id: 'quotation' },
{ label: 'Installation', id: 'process' },
{ label: 'Review', id: 'reviews' },
]
function Subscribe() {
const [email, setEmail] = useState('')
const [state, setState] = useState({ status: 'idle', message: '' })
const submit = async (e) => {
e.preventDefault()
if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(email.trim())) {
setState({ status: 'error', message: 'Please enter a valid email address.' })
return
}
setState({ status: 'busy', message: '' })
try {
const r = await api.post('/subscribe', { email: email.trim() })
setState({ status: 'done', message: r.data.message })
setEmail('')
} catch (err) {
setState({ status: 'error', message: errorMessage(err) })
}
}
return (
<form onSubmit={submit} noValidate className="flex flex-col gap-2">
<div className="flex flex-col gap-3 sm:flex-row sm:items-center">
<input
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="Email address"
aria-label="Email address"
autoComplete="email"
className="h-12 w-full rounded-[8px] bg-white px-5 text-[15px] leading-5 text-navy outline-none placeholder:text-[#6B7280] focus:ring-2 focus:ring-yellow sm:w-[376px]"
/>
<button
type="submit"
disabled={state.status === 'busy'}
className="inline-flex h-[50px] shrink-0 items-center justify-center gap-2 rounded-[8px] bg-yellow-sub px-6 text-[16px] leading-[22px] font-semibold text-[#0D0E12] transition hover:brightness-105 disabled:opacity-60"
>
{state.status === 'busy' ? <Spinner className="size-4" /> : null}
Subscribe
<ArrowUpRight className="size-[18px]" strokeWidth={2.25} aria-hidden />
</button>
</div>
{state.message && (
<p className={`text-[14px] ${state.status === 'error' ? 'text-[#FDA29B]' : 'text-pale-lime'}`} role="status">
{state.message}
</p>
)}
</form>
)
}
export default function Footer() {
const f = useContent('footer')
const contact = useContent('contact')
const { openSupport } = useLeadModal()
const onHome = useLocation().pathname === '/'
const socials = [
{ icon: iconX, label: 'X (Twitter)', url: contact.twitter_url },
{ icon: iconFb, label: 'Facebook', url: contact.facebook_url },
{ icon: iconIn, label: 'LinkedIn', url: contact.linkedin_url },
{ icon: iconIg, label: 'Instagram', url: contact.instagram_url },
]
return (
<footer className="relative isolate overflow-hidden bg-footer pt-16 pb-12 text-white lg:pt-20 lg:pb-16">
<img src={panel} alt="" className="pointer-events-none absolute top-[105px] left-[42%] -z-10 hidden w-[1038px] max-w-none opacity-20 md:block" loading="lazy" aria-hidden />
<div className="container-site flex flex-col gap-12">
<div className="flex flex-col gap-10 lg:flex-row lg:justify-between">
<div className="flex max-w-[540px] flex-col gap-6">
<Link to="/" aria-label="Saura Shakti home">
<img src={logo} alt="Saura Shakti Enterprise Private Limited" className="h-[113px] w-auto" width={200} height={113} loading="lazy" />
</Link>
<p className="text-[16px] leading-6">{f.description}</p>
{(contact.phone || contact.email || contact.address) && (
<p className="text-[15px] leading-6 text-line">
{[contact.phone, contact.email, contact.address].filter(Boolean).join(' · ')}
</p>
)}
<Subscribe />
</div>
<div className="flex flex-col gap-8 lg:items-end">
<nav aria-label="Footer">
<ul className="flex flex-wrap gap-x-7 gap-y-3">
{FOOTER_LINKS.map((l) => (
<li key={l.id}>
<a href={onHome ? `#${l.id}` : `/#${l.id}`} className="text-[15px] leading-5 font-semibold text-line transition hover:text-white">
{l.label}
</a>
</li>
))}
<li>
<Link to="/projects" className="text-[15px] leading-5 font-semibold text-line transition hover:text-white">Projects</Link>
</li>
</ul>
</nav>
<ul className="flex gap-3">
{socials.map((s) => (
<li key={s.label}>
{s.url ? (
<a href={s.url} target="_blank" rel="noopener noreferrer" aria-label={s.label} className="grid size-10 place-items-center rounded-[20px] border border-social-border bg-social transition hover:border-yellow">
<img src={s.icon} alt="" className="size-4" />
</a>
) : (
<span aria-label={`${s.label} (link not set)`} className="grid size-10 place-items-center rounded-[20px] border border-social-border bg-social opacity-90">
<img src={s.icon} alt="" className="size-4" />
</span>
)}
</li>
))}
</ul>
</div>
</div>
<div className="flex flex-col gap-5">
<div className="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
<p className="text-[15px] leading-[22px] sm:text-[16px]">{f.copyright}</p>
<ul className="flex gap-6">
<li><Link to="/terms" className="text-[16px] leading-[22px] font-semibold hover:text-pale-lime">Terms</Link></li>
<li><Link to="/privacy" className="text-[16px] leading-[22px] font-semibold hover:text-pale-lime">Privacy</Link></li>
<li><button type="button" onClick={openSupport} className="text-[16px] leading-[22px] font-semibold hover:text-pale-lime">Support</button></li>
</ul>
</div>
<hr className="border-t-2 border-[#8E939E]/40" />
</div>
</div>
</footer>
)
}
+70
View File
@@ -0,0 +1,70 @@
import { motion } from 'framer-motion'
import { Play } from 'lucide-react'
import heroBg from '../assets/images/hero-bg.webp'
import iconHome from '../assets/icons/features-bar__shield-check.svg'
import iconBusiness from '../assets/icons/features-bar__lock.svg'
import iconFarm from '../assets/icons/features-bar__leaf.svg'
import iconInstall from '../assets/icons/features-bar__sun.svg'
import { PrimaryButton, Tag } from '../components/ui'
import { useContent } from '../context/ContentContext'
const FEATURE_ICONS = [iconHome, iconBusiness, iconFarm, iconInstall]
export default function Hero() {
const c = useContent('hero')
return (
<section className="relative isolate overflow-hidden text-white lg:min-h-[785px]" aria-label="Introduction">
<img src={heroBg} alt="" className="absolute inset-0 -z-20 size-full object-cover" fetchPriority="high" />
{/* Figma overlay: linear #0E5177/32% → #082D42/60% → #00070B at 80% */}
<div
className="absolute inset-0 -z-10 opacity-80"
style={{ background: 'linear-gradient(180deg, rgba(14,81,119,0.32) 0%, rgba(8,45,66,0.6) 60%, #00070B 100%)' }}
aria-hidden
/>
<div className="container-site pt-[120px] pb-12 lg:pt-[176px] lg:pb-12">
<motion.div
className="max-w-[861px] lg:px-4"
initial={{ opacity: 0, y: 16 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.6, ease: 'easeOut' }}
>
<Tag tone="dark">{c.tag}</Tag>
<h1 className="mt-4 text-[34px] leading-[44px] font-extrabold tracking-[-1px] sm:text-[42px] sm:leading-[54px] lg:text-h1 lg:leading-[64px] lg:tracking-[-1.5px]">
{c.title_line1}
<br className="hidden md:block" /> {c.title_line2}
</h1>
<p className="mt-6 max-w-[640px] text-[17px] leading-[28px] font-medium lg:text-[20px] lg:leading-[32px]">{c.subtitle}</p>
<div className="mt-6 flex flex-wrap items-center gap-6">
<PrimaryButton as="a" href="#quotation">
{c.primary_cta}
</PrimaryButton>
<a href="#reviews" className="group inline-flex items-center gap-3 text-[15px] leading-5 font-semibold">
<span className="grid size-11 place-items-center rounded-full border-[1.5px] border-white bg-white/8 transition group-hover:bg-white/20">
<Play className="ml-0.5 size-4" strokeWidth={2} aria-hidden />
</span>
{c.secondary_cta}
</a>
</div>
</motion.div>
{/* features bar */}
<ul className="mt-12 grid grid-cols-1 border-t border-white/15 pt-4 sm:grid-cols-2 lg:mt-20 lg:grid-cols-4 lg:pt-6 lg:pb-3">
{c.features.slice(0, 4).map((f, i) => (
<li
key={f.title}
className={`flex gap-4 py-3 pr-8 pl-0 sm:pl-4 ${i < 3 ? 'lg:border-r lg:border-white/15' : ''} ${i % 2 === 0 ? 'sm:border-r sm:border-white/15 lg:border-r' : ''}`}
>
<span className="grid size-10 shrink-0 place-items-center rounded-full border border-white/15 bg-white/8">
<img src={FEATURE_ICONS[i]} alt="" className="size-5" aria-hidden />
</span>
<span>
<span className="block text-[16px] leading-6 font-semibold">{f.title}</span>
<span className="mt-1 block text-[14px] leading-6 font-medium text-line">{f.text}</span>
</span>
</li>
))}
</ul>
</div>
</section>
)
}
+105
View File
@@ -0,0 +1,105 @@
import { useId, useState } from 'react'
import { AnimatePresence, motion } from 'framer-motion'
import { Minus, Plus } from 'lucide-react'
import myth1 from '../assets/images/myth-1.webp'
import myth2 from '../assets/images/myth-2.webp'
import myth3 from '../assets/images/myth-3.webp'
import myth4 from '../assets/images/myth-4.webp'
import myth5 from '../assets/images/myth-5.webp'
import { Tag } from '../components/ui'
import { useContent } from '../context/ContentContext'
const IMAGES = [myth1, myth2, myth3, myth4, myth5]
export default function Myths() {
const c = useContent('myths')
const [open, setOpen] = useState(0)
const baseId = useId()
const image = IMAGES[(open < 0 ? 0 : open) % IMAGES.length]
return (
<section id="myths" className="bg-white py-16 lg:py-20" aria-label="Solar myths">
<div className="container-site flex flex-col gap-12 lg:gap-20">
<div className="flex flex-col gap-3">
<Tag className="self-start">{c.tag}</Tag>
<div className="flex flex-col gap-6 lg:flex-row lg:gap-16">
<h2 className="h2 text-navy lg:w-[688px] lg:shrink-0">
{c.title_line1}
<br />
<span className="text-muted">{c.title_line2}</span>
</h2>
<p className="lead text-navy lg:max-w-[528px]">{c.text}</p>
</div>
</div>
<div className="flex flex-col gap-10 lg:flex-row lg:gap-20">
<div className="w-full lg:w-[720px] lg:shrink-0">
{c.items.map((item, i) => {
const isOpen = open === i
const num = String(i + 1).padStart(2, '0')
return (
<div
key={item.question}
className={`px-4 py-5 transition-colors sm:px-5 sm:py-6 ${isOpen ? 'rounded-[12px] bg-surface' : 'border-b border-line'}`}
>
<h3>
<button
type="button"
className="flex w-full items-center justify-between gap-2 text-left lg:gap-0"
aria-expanded={isOpen}
aria-controls={`${baseId}-${i}`}
onClick={() => setOpen(isOpen ? -1 : i)}
>
<span className={`flex items-center ${isOpen ? 'gap-5 sm:gap-7' : 'gap-5 sm:gap-8'}`}>
<span className={`w-[22px] shrink-0 font-inter text-[16px] leading-[19px] font-bold ${isOpen ? 'text-brand' : 'text-slate'}`}>{num}</span>
<span
className={`text-[18px] leading-[26px] sm:text-[24px] sm:leading-8 ${isOpen ? 'font-bold text-brand' : 'font-semibold text-navy'}`}
>
{item.question}
</span>
</span>
<span className="grid size-6 shrink-0 place-items-center text-navy">
{isOpen ? <Minus className="size-4" strokeWidth={2} /> : <Plus className="size-4" strokeWidth={2} />}
</span>
</button>
</h3>
<AnimatePresence initial={false}>
{isOpen && (
<motion.div
id={`${baseId}-${i}`}
role="region"
initial={{ height: 0, opacity: 0 }}
animate={{ height: 'auto', opacity: 1 }}
exit={{ height: 0, opacity: 0 }}
transition={{ duration: 0.3, ease: [0.4, 0, 0.2, 1] }}
className="overflow-hidden"
>
<p className="pt-4 pl-11 text-[16px] leading-6 text-ink sm:pl-12">{item.answer}</p>
</motion.div>
)}
</AnimatePresence>
</div>
)
})}
</div>
<div className="relative hidden h-[464px] w-full overflow-hidden rounded-[24px] bg-surface md:block lg:w-[480px]">
<AnimatePresence initial={false}>
<motion.img
key={image}
src={image}
alt=""
className="absolute inset-0 size-full object-cover"
initial={{ opacity: 0, scale: 1.03 }}
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.5 }}
loading="lazy"
/>
</AnimatePresence>
</div>
</div>
</div>
</section>
)
}
+129
View File
@@ -0,0 +1,129 @@
import { useEffect, useState } from 'react'
import { Link, useLocation } from 'react-router-dom'
import { AnimatePresence, motion } from 'framer-motion'
import { ArrowRight, Menu, X } from 'lucide-react'
import logo from '../assets/images/logo.webp'
import { useLeadModal } from '../context/LeadModalContext'
import { useContent } from '../context/ContentContext'
export const NAV_LINKS = [
{ label: 'Solutions', href: 'solutions' },
{ label: 'Awareness', href: 'awareness' },
{ label: 'Myths', href: 'myths' },
{ label: 'Quotation', href: 'quotation' },
{ label: 'Process', href: 'process' },
{ label: 'Reviews', href: 'reviews' },
]
/** Pill navbar (Figma: 1280×72, #010F1C, radius 94). Becomes sticky after scrolling. */
export default function Navbar({ overlay = true }) {
const { openConsultation } = useLeadModal()
const hero = useContent('hero')
const { pathname } = useLocation()
const onHome = pathname === '/'
const [open, setOpen] = useState(false)
const [stuck, setStuck] = useState(false)
useEffect(() => {
const onScroll = () => setStuck(window.scrollY > 8)
onScroll()
window.addEventListener('scroll', onScroll, { passive: true })
return () => window.removeEventListener('scroll', onScroll)
}, [])
useEffect(() => setOpen(false), [pathname])
const linkHref = (id) => (onHome ? `#${id}` : `/#${id}`)
// The Figma pill navbar, always pinned to the top of the viewport and drawn above every
// section. The transparent area around the pill lets clicks pass through to the page.
return (
<header
className={`pointer-events-none ${overlay ? 'fixed' : 'sticky'} inset-x-0 top-0 z-[60] w-full pt-4 lg:pt-6`}
>
<div className="container-site">
<nav
className={`pointer-events-auto relative flex h-[60px] items-center justify-between rounded-[94px] bg-footer px-3 transition-shadow duration-300 lg:h-[72px] lg:px-4 ${
stuck ? 'shadow-[0_10px_30px_rgba(0,7,11,0.35)]' : ''
}`}
aria-label="Main"
>
<Link to="/" className="shrink-0" aria-label="Saura Shakti home">
<img src={logo} alt="Saura Shakti Enterprise Private Limited" className="h-[52px] w-auto lg:h-[72px]" width={128} height={72} />
</Link>
<ul className="hidden items-center gap-6 lg:flex xl:gap-8">
{NAV_LINKS.map((l) => (
<li key={l.href}>
<a href={linkHref(l.href)} className="text-[16px] leading-[22px] font-semibold text-white/90 transition hover:text-pale-lime">
{l.label}
</a>
</li>
))}
</ul>
<div className="flex items-center gap-2">
<button
type="button"
onClick={openConsultation}
className="group hidden h-[43px] items-center gap-2 rounded-full border border-brand bg-white px-6 text-[14px] leading-[19px] font-semibold text-brand transition hover:bg-pale-lime sm:inline-flex"
>
{hero.nav_cta}
<ArrowRight className="size-3.5 transition-transform group-hover:translate-x-0.5" strokeWidth={2.5} aria-hidden />
</button>
<button
type="button"
className="grid size-11 place-items-center rounded-full text-white hover:bg-white/10 lg:hidden"
onClick={() => setOpen((o) => !o)}
aria-expanded={open}
aria-label={open ? 'Close menu' : 'Open menu'}
>
{open ? <X className="size-6" /> : <Menu className="size-6" />}
</button>
</div>
<AnimatePresence>
{open && (
<motion.div
initial={{ opacity: 0, y: -8 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -8 }}
transition={{ duration: 0.18 }}
className="absolute top-[calc(100%+8px)] right-0 left-0 rounded-[24px] bg-footer p-3 shadow-2xl lg:hidden"
>
<ul className="flex flex-col">
{NAV_LINKS.map((l) => (
<li key={l.href}>
<a
href={linkHref(l.href)}
onClick={() => setOpen(false)}
className="block rounded-2xl px-4 py-3 text-[16px] font-semibold text-white/90 hover:bg-white/5"
>
{l.label}
</a>
</li>
))}
<li>
<Link to="/projects" className="block rounded-2xl px-4 py-3 text-[16px] font-semibold text-white/90 hover:bg-white/5">
Projects
</Link>
</li>
</ul>
<button
type="button"
onClick={() => {
setOpen(false)
openConsultation()
}}
className="mt-2 flex h-12 w-full items-center justify-center gap-2 rounded-full bg-white text-[15px] font-semibold text-brand sm:hidden"
>
{hero.nav_cta} <ArrowRight className="size-4" />
</button>
</motion.div>
)}
</AnimatePresence>
</nav>
</div>
</header>
)
}
+84
View File
@@ -0,0 +1,84 @@
import { useState } from 'react'
import { AnimatePresence, motion } from 'framer-motion'
import step1 from '../assets/images/step-1.webp'
import step2 from '../assets/images/step-2.webp'
import step3 from '../assets/images/step-3.webp'
import step4 from '../assets/images/step-4.webp'
import { Tag } from '../components/ui'
import { useContent } from '../context/ContentContext'
const IMAGES = [step1, step2, step3, step4]
export default function Process() {
const c = useContent('process')
const [active, setActive] = useState(0)
return (
<section id="process" className="bg-brand py-16 text-white lg:py-24" aria-label="Installation process">
<div className="container-site flex flex-col gap-12 lg:gap-20">
<div className="flex flex-col gap-3">
<Tag tone="dark" className="self-start">{c.tag}</Tag>
<div className="flex flex-col gap-6 lg:flex-row lg:justify-between lg:gap-16">
<h2 className="h2 lg:w-[704px]">
{c.title_line1}
<br />
{c.title_prefix}
<span className="text-yellow">{c.title_highlight}</span>
</h2>
<p className="lead lg:max-w-[470px]">{c.text}</p>
</div>
</div>
<ol className="-mx-4 flex snap-x snap-mandatory gap-[18px] overflow-x-auto px-4 pb-2 sm:mx-0 sm:grid sm:grid-cols-2 sm:overflow-visible sm:px-0 lg:grid-cols-4">
{c.steps.slice(0, 4).map((step, i) => {
const isActive = active === i
return (
<li key={step.title} className="w-[78%] shrink-0 snap-start sm:w-auto">
<button
type="button"
onClick={() => setActive(i)}
onMouseEnter={() => setActive(i)}
onFocus={() => setActive(i)}
aria-expanded={isActive}
className="relative isolate flex h-[420px] w-full flex-col justify-between overflow-hidden rounded-[32px] p-8 text-left lg:h-[480px]"
>
<img src={IMAGES[i]} alt="" className="absolute inset-0 -z-20 size-full object-cover" loading="lazy" />
<span
className="absolute inset-0 -z-10 transition-opacity duration-500"
style={{ background: 'linear-gradient(180deg, rgba(39,75,142,0) 0%, rgba(11,21,40,0.8) 100%)', opacity: isActive ? 1 : 0 }}
aria-hidden
/>
<span className="absolute inset-0 -z-10 bg-ink-blue/64 transition-opacity duration-500" style={{ opacity: isActive ? 0 : 1 }} aria-hidden />
<span
className={`grid size-16 place-items-center rounded-[93px] text-[24px] leading-8 backdrop-blur-[8px] transition-colors duration-300 ${
isActive ? 'border-2 border-navy bg-yellow font-extrabold text-black' : 'border border-white/20 bg-white/25 font-bold text-white'
}`}
>
{String(i + 1).padStart(2, '0')}
</span>
<span className="flex flex-col gap-2">
<span className="text-card leading-8 font-semibold">{step.title}</span>
<AnimatePresence initial={false}>
{isActive && (
<motion.span
className="block overflow-hidden text-[16px] leading-6 font-medium"
initial={{ height: 0, opacity: 0 }}
animate={{ height: 'auto', opacity: 1 }}
exit={{ height: 0, opacity: 0 }}
transition={{ duration: 0.3 }}
>
{step.text}
</motion.span>
)}
</AnimatePresence>
</span>
</button>
</li>
)
})}
</ol>
</div>
</section>
)
}
+267
View File
@@ -0,0 +1,267 @@
import { useEffect, useMemo, useState } from 'react'
import { AnimatePresence, motion } from 'framer-motion'
import { ArrowUpRight } from 'lucide-react'
import iconCheck from '../assets/icons/breakdown-list__shield-check.svg'
import iconPin from '../assets/icons/slider-feed-in-tariff__location_on.svg'
import iconDownload from '../assets/icons/secondary-actions-row__download.svg'
import iconMail from '../assets/icons/secondary-actions-row__mail.svg'
import { Spinner } from '../components/ui'
import { useContent } from '../context/ContentContext'
import api, { errorMessage } from '../services/api'
import { areaToPosition, calculateQuote, DEFAULT_QUOTE_SETTINGS, formatINR, formatKW, positionToArea } from '../utils/quote'
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/
function RoofSlider({ value, onChange, min }) {
const pos = areaToPosition(value)
const pct = pos * 100
return (
<div className="flex flex-col gap-1">
<div className="relative h-[17px]">
<span
className="absolute top-0 font-inter text-[14px] leading-[17px] font-bold whitespace-nowrap text-brand"
style={{ left: `clamp(0px, calc(${pct}% - 34px), calc(100% - 80px))` }}
aria-hidden
>
{value} sq. ft.
</span>
</div>
<div className="relative h-5">
<div className="absolute top-[7px] right-0 left-0 h-1.5 rounded-[3px] bg-[#D5D5D5]" />
<div className="absolute top-[7px] left-0 h-1.5 rounded-[3px] bg-green" style={{ width: `${pct}%` }} />
<div
className="pointer-events-none absolute top-0 size-5 rounded-full border-2 border-white bg-forest shadow-sm"
style={{ left: `calc(${pct}% - ${pos * 20}px)` }}
/>
<input
type="range"
min={0}
max={1000}
step={1}
value={Math.round(pos * 1000)}
onChange={(e) => onChange(positionToArea(Number(e.target.value) / 1000, 50, min))}
className="absolute inset-0 h-5 w-full cursor-pointer opacity-0"
aria-label="Available roof area in square feet"
aria-valuetext={`${value} square feet`}
/>
</div>
</div>
)
}
function Pill({ active, children, ...props }) {
return (
<button
type="button"
aria-pressed={active}
className={`h-[37px] flex-1 rounded-full px-6 font-inter text-[14px] leading-[17px] transition ${
active ? 'bg-lime text-black' : 'border border-forest bg-white text-navy hover:bg-lime/30'
}`}
{...props}
>
{children}
</button>
)
}
const outlineBtn =
'inline-flex h-[47px] w-full sm:flex-1 items-center justify-center gap-2 rounded-full border border-forest bg-white px-6 font-inter text-[16px] leading-[19px] font-medium text-forest transition hover:bg-lime disabled:opacity-60'
export default function Quotation() {
const c = useContent('quotation')
const [cfg, setCfg] = useState(DEFAULT_QUOTE_SETTINGS)
const [propertyType, setPropertyType] = useState('residential')
const [area, setArea] = useState(250)
const [location, setLocation] = useState(c.default_location)
// idle | email | downloaded | emailed
const [mode, setMode] = useState('idle')
const [email, setEmail] = useState('')
const [busy, setBusy] = useState('')
const [error, setError] = useState('')
useEffect(() => {
api.get('/quotations/settings').then((r) => setCfg({ ...DEFAULT_QUOTE_SETTINGS, ...r.data })).catch(() => {})
}, [])
useEffect(() => setLocation(c.default_location), [c.default_location])
const q = useMemo(() => calculateQuote(cfg, propertyType, area), [cfg, propertyType, area])
const payload = { property_type: propertyType, roof_area_sqft: q.area, location: location.trim() }
// inputs changed after a success banner → bring the buttons back
useEffect(() => {
setMode((m) => (m === 'downloaded' || m === 'emailed' ? 'idle' : m))
}, [propertyType, area, location])
const download = async () => {
setError('')
setBusy('pdf')
try {
const res = await api.post('/quotations/pdf', payload, { responseType: 'blob' })
const url = URL.createObjectURL(res.data)
const a = document.createElement('a')
a.href = url
a.download = 'saura-shakti-quotation.pdf'
document.body.appendChild(a)
a.click()
a.remove()
setTimeout(() => URL.revokeObjectURL(url), 2000)
setMode('downloaded')
} catch (e) {
setError(errorMessage(e, 'Could not generate the quotation. Please try again.'))
} finally {
setBusy('')
}
}
const sendEmail = async (ev) => {
ev.preventDefault()
setError('')
if (!EMAIL_RE.test(email.trim())) {
setError('Please enter a valid email address.')
return
}
setBusy('email')
try {
await api.post('/quotations/email', { ...payload, email: email.trim() })
setMode('emailed')
} catch (e) {
setError(errorMessage(e, 'Could not send the email. Please try again.'))
} finally {
setBusy('')
}
}
const rows = [
['Solar Panel & Equipment', q.panel],
['Installation & Setup', q.install],
['Estimated Subsidy / Incentive', q.subsidy],
['Estimated Cost After Subsidy', q.total],
]
return (
<section id="quotation" className="bg-surface py-16 lg:py-20" aria-label="Solar quotation calculator">
<div className="container-site flex flex-col gap-10 lg:gap-12">
<h2 className="h2 text-center text-navy">{c.title}</h2>
<div className="flex flex-col gap-6 lg:flex-row lg:gap-8">
{/* controls (400px) */}
<div className="flex flex-col gap-10 rounded-[12px] bg-white px-6 py-6 sm:px-10 sm:py-5 lg:w-[400px] lg:shrink-0">
<p className="text-[16px] leading-6 text-navy">{c.text}</p>
<div className="flex flex-col gap-8 pb-4">
<fieldset className="flex flex-col gap-2">
<legend className="mb-2 text-[16px] leading-6 font-bold text-navy">Property Type</legend>
<div className="flex gap-2">
<Pill active={propertyType === 'residential'} onClick={() => setPropertyType('residential')}>Residential</Pill>
<Pill active={propertyType === 'commercial'} onClick={() => setPropertyType('commercial')}>Commercial</Pill>
</div>
</fieldset>
<div className="flex flex-col gap-2">
<span className="text-[16px] leading-6 font-bold text-navy">Available Roof Area</span>
<RoofSlider value={q.area} onChange={setArea} min={cfg.min_area_sqft} />
</div>
<label className="flex flex-col gap-2">
<span className="text-[16px] leading-6 font-bold text-navy">Location</span>
<span className="flex h-11 items-center justify-between gap-2 rounded-[4px] border border-forest bg-white px-3 focus-within:ring-2 focus-within:ring-brand/25">
<input
value={location}
onChange={(e) => setLocation(e.target.value)}
maxLength={120}
className="w-full bg-transparent font-inter text-[14px] text-forest outline-none"
autoComplete="address-level2"
/>
<img src={iconPin} alt="" className="size-6" aria-hidden />
</span>
</label>
</div>
</div>
{/* results (752px) */}
<div className="flex flex-col gap-8 rounded-[12px] bg-white p-6 sm:p-10 lg:w-[752px]">
<div className="flex items-center border-b border-[#EBF0ED] pb-1">
<div className="flex flex-1 flex-col items-center gap-2 text-center">
<span className="text-[12px] leading-[19px] font-extrabold tracking-[1px] text-slate uppercase sm:text-[14px]">Recommended System</span>
<span className="font-inter text-[28px] leading-[48px] font-black text-brand sm:text-[40px]" aria-live="polite">{formatKW(q.capacity)}</span>
</div>
<span className="hidden h-px w-[60px] bg-[#EBF0ED] sm:block" aria-hidden />
<div className="flex flex-1 flex-col items-center gap-2 text-center">
<span className="text-[12px] leading-[19px] font-extrabold tracking-[1px] text-slate uppercase sm:text-[14px]">Estimated Cost</span>
<span className="font-inter text-[28px] leading-[48px] font-black text-brand sm:text-[40px]" aria-live="polite">{formatINR(q.total)}</span>
</div>
</div>
<ul className="flex flex-col gap-4">
{rows.map(([label, value]) => (
<li key={label} className="flex items-center justify-between gap-3 border-b border-[#E2E2E2] pb-4">
<span className="flex items-center gap-3">
<span className="grid size-8 shrink-0 place-items-center rounded-full bg-yellow-badge">
<img src={iconCheck} alt="" className="size-4" aria-hidden />
</span>
<span className="text-[15px] leading-6 font-semibold text-navy sm:text-[16px]">{label}</span>
</span>
<span className="font-inter text-[16px] leading-[19px] font-bold whitespace-nowrap text-ink">{formatINR(value)}</span>
</li>
))}
</ul>
<div className="min-h-[47px]">
<AnimatePresence mode="wait" initial={false}>
{mode === 'idle' && (
<motion.div key="idle" className="flex flex-col gap-4 sm:flex-row" initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }}>
<button type="button" className={outlineBtn} onClick={download} disabled={!!busy}>
{busy === 'pdf' ? <Spinner className="size-4" /> : <img src={iconDownload} alt="" className="size-4" aria-hidden />}
Download Quotation
</button>
<button type="button" className={outlineBtn} onClick={() => { setError(''); setMode('email') }} disabled={!!busy}>
<img src={iconMail} alt="" className="size-4" aria-hidden />
Email Quotation
</button>
</motion.div>
)}
{mode === 'email' && (
<motion.form key="email" onSubmit={sendEmail} noValidate className="flex flex-col gap-1.5 sm:flex-row" initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }}>
<label className="flex h-[47px] w-full items-center gap-2 rounded-full sm:flex-1 border border-forest bg-white px-6">
<img src={iconMail} alt="" className="size-4 opacity-60" aria-hidden />
<input
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="Email Id"
className="w-full bg-transparent font-inter text-[16px] text-forest outline-none placeholder:text-forest/60"
autoComplete="email"
autoFocus
aria-label="Email address"
/>
</label>
<button
type="submit"
disabled={busy === 'email'}
className="inline-flex h-[50px] items-center justify-center gap-2 rounded-full border border-forest bg-lime px-6 text-[16px] leading-[22px] font-semibold text-[#0D0E12] transition hover:brightness-95 disabled:opacity-60"
>
{busy === 'email' ? <Spinner className="size-4" /> : null}
Email Quotation
{busy !== 'email' && <ArrowUpRight className="size-[18px]" strokeWidth={2.25} aria-hidden />}
</button>
</motion.form>
)}
{(mode === 'downloaded' || mode === 'emailed') && (
<motion.div
key={mode}
role="status"
className="flex min-h-[47px] items-center justify-center rounded-[8px] border border-forest bg-lime/20 px-6 py-3 text-center font-inter text-[16px] leading-[19px] text-black"
initial={{ opacity: 0, y: 6 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0 }}
>
{mode === 'downloaded' ? 'Quotation downloaded successfully.' : 'Your quotation has also been sent to your email.'}
</motion.div>
)}
</AnimatePresence>
{error && <p className="mt-3 text-[14px] text-[#B42318]" role="alert">{error}</p>}
</div>
{cfg.disclaimer && <p className="-mt-4 text-[12px] leading-5 text-slate">{cfg.disclaimer}</p>}
</div>
</div>
</div>
</section>
)
}
+131
View File
@@ -0,0 +1,131 @@
import { useEffect, useMemo, useState } from 'react'
import { Link } from 'react-router-dom'
import { AnimatePresence, motion } from 'framer-motion'
import homeImg from '../assets/images/usecase-home.webp'
import businessImg from '../assets/images/usecase-business.webp'
import farmImg from '../assets/images/usecase-farm.webp'
import { ArrowButton, Tag } from '../components/ui'
import { useContent } from '../context/ContentContext'
import api from '../services/api'
const DESIGN_IMAGES = [homeImg, businessImg, farmImg]
/**
* "Powering Homes, Businesses & Beyond" — 3-page slider from the Figma "Use case section".
* Published services from the admin dashboard replace the design slides when they exist.
*/
export default function Solutions() {
const c = useContent('solutions')
const [services, setServices] = useState(null)
const [index, setIndex] = useState(0)
useEffect(() => {
api.get('/services').then((r) => setServices(r.data)).catch(() => setServices([]))
}, [])
const slides = useMemo(() => {
if (services?.length) {
return services.map((s, i) => {
const m = /^solar for (.+)$/i.exec(s.title)
return {
key: `svc-${s.id}`,
prefix: m ? s.title.slice(0, s.title.length - m[1].length) : '',
highlight: m ? m[1] : s.title,
text: s.description || s.short_description || '',
image: s.image_url || DESIGN_IMAGES[i % DESIGN_IMAGES.length],
thumb: s.thumbnail_url || s.image_url || DESIGN_IMAGES[i % DESIGN_IMAGES.length],
link: '/projects',
}
})
}
return c.slides.map((s, i) => ({
key: `design-${i}`,
...s,
image: DESIGN_IMAGES[i % DESIGN_IMAGES.length],
thumb: DESIGN_IMAGES[i % DESIGN_IMAGES.length],
link: s.category ? `/projects?category=${s.category}` : '/projects',
}))
}, [services, c.slides])
const count = slides.length
const current = slides[Math.min(index, count - 1)] || slides[0]
const go = (d) => setIndex((i) => (i + d + count) % count)
return (
<section id="solutions" className="bg-white py-16 lg:py-20" aria-roledescription="carousel" aria-label="Solar solutions">
<div className="container-site flex flex-col gap-10 lg:flex-row lg:items-center">
{/* gallery: thumbnails + main image (640 wide in Figma) */}
<div className="flex w-full gap-4 sm:gap-6 lg:w-[640px] lg:shrink-0">
<div className="hidden w-[160px] shrink-0 flex-col gap-4 sm:flex">
{slides.slice(0, 3).map((s, i) => (
<button
key={s.key}
type="button"
onClick={() => setIndex(i)}
className="relative h-[142px] overflow-hidden rounded-[12px] bg-slate"
aria-label={`Show ${s.highlight}`}
aria-current={i === index}
>
<img src={s.thumb} alt="" className="size-full object-cover transition duration-500 hover:scale-105" loading="lazy" />
</button>
))}
</div>
<Link
to={current.link}
className="group relative aspect-[456/458] w-full overflow-hidden rounded-[14px] bg-surface sm:h-[458px] sm:aspect-auto lg:w-[456px]"
aria-label={`View ${current.highlight} projects`}
>
<AnimatePresence mode="popLayout" initial={false}>
<motion.img
key={current.key}
src={current.image}
alt={`${current.prefix}${current.highlight}`}
className="absolute inset-0 size-full object-cover transition-transform duration-700 group-hover:scale-[1.03]"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.45 }}
/>
</AnimatePresence>
<span className="absolute bottom-4 left-4 rounded-full bg-footer/80 px-4 py-2 text-[13px] font-semibold text-white opacity-0 backdrop-blur transition group-hover:opacity-100 group-focus-visible:opacity-100">
View projects →
</span>
</Link>
</div>
{/* copy */}
<div className="flex w-full flex-col justify-between gap-8 lg:min-h-[458px] lg:max-w-[600px]">
<div className="flex flex-col gap-3">
<Tag className="self-start">{c.tag}</Tag>
<div className="flex flex-col gap-6">
<h2 className="h2 text-navy">{c.title}</h2>
<AnimatePresence mode="wait" initial={false}>
<motion.div
key={current.key}
className="flex flex-col gap-4"
initial={{ opacity: 0, y: 8 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -8 }}
transition={{ duration: 0.3 }}
aria-live="polite"
>
<h3 className="text-[22px] leading-8 font-semibold text-navy lg:text-card">
{current.prefix}
<span className="text-green-text">{current.highlight}</span>
</h3>
<p className="text-[16px] leading-6 text-navy">{current.text}</p>
</motion.div>
</AnimatePresence>
</div>
</div>
{count > 1 && (
<div className="flex gap-3">
<ArrowButton direction="left" onClick={() => go(-1)} aria-label="Previous solution" />
<ArrowButton onClick={() => go(1)} aria-label="Next solution" />
</div>
)}
</div>
</div>
</section>
)
}
+236
View File
@@ -0,0 +1,236 @@
import { useEffect, useMemo, useRef, useState } from 'react'
import { AnimatePresence, motion } from 'framer-motion'
import { ChevronLeft, ChevronRight, Pause, Play } from 'lucide-react'
import featured from '../assets/images/testimonial-featured.webp'
import thumb1 from '../assets/images/testimonial-thumb-1.webp'
import thumb2 from '../assets/images/testimonial-thumb-2.webp'
import thumb3 from '../assets/images/testimonial-thumb-3.webp'
import thumb4 from '../assets/images/testimonial-thumb-4.webp'
import { Tag } from '../components/ui'
import { DESIGN_TESTIMONIALS } from '../content/defaults'
import { useContent } from '../context/ContentContext'
import api from '../services/api'
const STILLS = { featured, 'thumb-1': thumb1, 'thumb-2': thumb2, 'thumb-3': thumb3, 'thumb-4': thumb4 }
function youtubeId(url) {
const m = /(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([\w-]{6,})/.exec(url || '')
return m ? m[1] : null
}
const fmtTime = (s) => (Number.isFinite(s) ? `${Math.floor(s / 60)}:${String(Math.floor(s % 60)).padStart(2, '0')}` : '0:00')
function FeaturedCard({ t }) {
const videoRef = useRef(null)
const [playing, setPlaying] = useState(false)
const [time, setTime] = useState({ cur: 0, dur: 0 })
const yt = youtubeId(t.video_url)
const isFile = t.video_url && !yt
useEffect(() => {
setPlaying(false)
setTime({ cur: 0, dur: 0 })
}, [t.key])
const toggle = () => {
if (yt) return setPlaying(true)
const v = videoRef.current
if (!v) return
if (v.paused) v.play().catch(() => {})
else v.pause()
}
const seek = (e) => {
const v = videoRef.current
if (!v || !time.dur) return
const rect = e.currentTarget.getBoundingClientRect()
v.currentTime = ((e.clientX - rect.left) / rect.width) * time.dur
}
return (
<div className="relative isolate flex h-[420px] flex-col justify-between overflow-hidden rounded-[24px] bg-ink-blue p-6 text-white sm:h-[500px] sm:p-10 lg:h-[560px]">
{yt && playing ? (
<iframe
className="absolute inset-0 -z-10 size-full"
src={`https://www.youtube-nocookie.com/embed/${yt}?autoplay=1&rel=0`}
title={`${t.customer_name} testimonial`}
allow="autoplay; encrypted-media; picture-in-picture"
allowFullScreen
/>
) : (
<>
{isFile ? (
<video
ref={videoRef}
className="absolute inset-0 -z-20 size-full object-cover"
src={t.video_url}
poster={t.image}
preload="metadata"
playsInline
onPlay={() => setPlaying(true)}
onPause={() => setPlaying(false)}
onTimeUpdate={(e) => setTime({ cur: e.target.currentTime, dur: e.target.duration })}
onLoadedMetadata={(e) => setTime({ cur: 0, dur: e.target.duration })}
/>
) : (
<img src={t.image} alt="" className="absolute inset-0 -z-20 size-full object-cover" loading="lazy" />
)}
<div className={`absolute inset-0 -z-10 bg-black/24 transition ${playing ? 'opacity-0' : ''}`} aria-hidden />
</>
)}
{!(yt && playing) && (
<>
<div className={`transition-opacity ${playing ? 'opacity-0' : ''}`}>
<p className="text-[20px] leading-8 font-semibold sm:text-card">{t.customer_name}</p>
{t.designation && <p className="text-[16px] leading-7 font-medium text-white/80 sm:text-[20px] sm:leading-8">{t.designation}</p>}
</div>
{t.video_url && !playing && (
<button
type="button"
onClick={toggle}
className="absolute top-1/2 left-1/2 grid size-16 -translate-1/2 place-items-center rounded-full bg-white/80 text-black shadow-[0_4px_12px_rgba(0,0,0,0.1)] transition hover:scale-105"
aria-label={`Play ${t.customer_name}'s video`}
>
<Play className="ml-1 size-6" fill="currentColor" />
</button>
)}
<div className="flex flex-col gap-10">
{t.content && (
<blockquote className={`mx-auto max-w-[1040px] text-center text-[18px] leading-7 font-medium transition-opacity sm:text-[22px] sm:leading-9 lg:text-[28px] lg:leading-10 ${playing ? 'opacity-0' : ''}`}>
“{t.content}”
</blockquote>
)}
{isFile && (
<div className="flex flex-col gap-4">
<div className="h-1.5 cursor-pointer overflow-hidden rounded-[42px] bg-white/30" onClick={seek} role="presentation">
<div className="h-full bg-white" style={{ width: time.dur ? `${(time.cur / time.dur) * 100}%` : '0%' }} />
</div>
<div className="flex items-center justify-between font-inter text-[16px] leading-[19px] text-white/80">
<span className="flex items-center gap-3">
<button type="button" onClick={toggle} aria-label={playing ? 'Pause' : 'Play'} className="text-white">
{playing ? <Pause className="size-3.5" fill="currentColor" /> : <Play className="size-3.5" fill="currentColor" />}
</button>
{fmtTime(time.cur)}
</span>
<span className="font-medium">-{fmtTime(Math.max(0, time.dur - time.cur))}</span>
</div>
</div>
)}
</div>
</>
)}
</div>
)
}
export default function Testimonials() {
const c = useContent('testimonials')
const [items, setItems] = useState(null)
const [index, setIndex] = useState(0)
const railRef = useRef(null)
const userMoved = useRef(false)
useEffect(() => {
api.get('/testimonials').then((r) => setItems(r.data)).catch(() => setItems([]))
}, [])
const list = useMemo(() => {
if (items?.length) {
return items.map((t, i) => ({
...t,
key: `t-${t.id}`,
image: t.image_url || Object.values(STILLS)[i % 5],
thumb: t.thumbnail_url || t.image_url || Object.values(STILLS)[i % 5],
}))
}
return DESIGN_TESTIMONIALS.map((t, i) => ({ ...t, key: `d-${i}`, image: STILLS[t.still], thumb: STILLS[t.still] }))
}, [items])
const usingDesign = !items?.length
// Figma features the last card (Rajesh Kumar) while the rail starts with Priya Nair.
useEffect(() => {
setIndex(usingDesign ? list.length - 1 : 0)
}, [usingDesign, list.length])
const total = list.length
const current = list[Math.min(index, total - 1)]
const go = (d) => {
userMoved.current = true
setIndex((i) => (i + d + total) % total)
}
// Keep the selected thumbnail visible by scrolling the rail only (never the page).
useEffect(() => {
if (!userMoved.current) return
const rail = railRef.current
const el = rail?.querySelector(`[data-idx="${index}"]`)
if (!rail || !el) return
const left = el.offsetLeft - rail.offsetLeft
if (left < rail.scrollLeft || left + el.offsetWidth > rail.scrollLeft + rail.clientWidth) {
rail.scrollTo({ left: Math.max(0, left - 16), behavior: 'smooth' })
}
}, [index])
const select = (i) => {
userMoved.current = true
setIndex(i)
}
if (!current) return null
return (
<section id="reviews" className="overflow-hidden bg-surface-2 py-16 lg:py-20" aria-label="Customer testimonials">
<div className="container-site flex flex-col items-center gap-10 lg:gap-14">
<div className="flex max-w-[860px] flex-col items-center gap-5 text-center">
<Tag>{c.tag}</Tag>
<h2 className="h2 text-navy">{c.title}</h2>
<p className="lead text-navy">{c.text}</p>
</div>
<div className="w-full">
<AnimatePresence mode="wait" initial={false}>
<motion.div key={current.key} initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} transition={{ duration: 0.3 }}>
<FeaturedCard t={current} />
</motion.div>
</AnimatePresence>
</div>
<div ref={railRef} className="-mx-4 flex w-[calc(100%+2rem)] snap-x gap-6 overflow-x-auto px-4 pb-2 sm:mx-0 sm:w-full sm:px-0 [&::-webkit-scrollbar]:hidden" style={{ scrollbarWidth: 'none' }}>
{list.map((t, i) => (
<button
key={t.key}
data-idx={i}
type="button"
onClick={() => select(i)}
className="group flex w-[240px] shrink-0 snap-start flex-col gap-4 text-left sm:w-[282px]"
aria-current={i === index}
>
<span className="relative grid h-[120px] w-full place-items-center overflow-hidden rounded-[12px] sm:h-[140px]">
<img src={t.thumb} alt="" className="absolute inset-0 size-full object-cover transition duration-500 group-hover:scale-105" loading="lazy" />
<span className="relative grid size-12 place-items-center rounded-full bg-white/80 shadow-[0_4px_12px_rgba(0,0,0,0.1)]">
<Play className="ml-0.5 size-4 text-black" aria-hidden />
</span>
</span>
<span>
<span className="block text-[18px] leading-7 font-bold text-[#111111]">{t.customer_name}</span>
<span className="block text-[14px] leading-[19px] font-bold tracking-[1px] text-[#666666]/80 uppercase">{t.designation}</span>
</span>
</button>
))}
</div>
<div className="flex h-11 items-center gap-4 rounded-full border border-[#E5E7EB] bg-white px-4" aria-label="Testimonial navigation">
<button type="button" onClick={() => go(-1)} className="grid size-5 place-items-center text-[#111111] hover:text-brand" aria-label="Previous testimonial">
<ChevronLeft className="size-[15px]" strokeWidth={2.5} />
</button>
<span className="min-w-14 text-center text-[16px] leading-6 text-[#111111]" aria-live="polite">
{index + 1} <span className="text-[#666666]"> Of {total}</span>
</span>
<button type="button" onClick={() => go(1)} className="grid size-5 place-items-center text-[#111111] hover:text-brand" aria-label="Next testimonial">
<ChevronRight className="size-[15px]" strokeWidth={2.5} />
</button>
</div>
</div>
</section>
)
}
+74
View File
@@ -0,0 +1,74 @@
import axios from 'axios'
const TOKEN_KEY = 'ss_admin_token'
export const tokenStore = {
get: () => {
try { return localStorage.getItem(TOKEN_KEY) } catch { return null }
},
set: (t) => {
try { localStorage.setItem(TOKEN_KEY, t) } catch { /* storage unavailable */ }
},
clear: () => {
try { localStorage.removeItem(TOKEN_KEY) } catch { /* storage unavailable */ }
},
}
const api = axios.create({
baseURL: import.meta.env.VITE_API_BASE_URL || '/api',
timeout: 60000,
})
api.interceptors.request.use((config) => {
const token = tokenStore.get()
if (token && config.url?.startsWith('/admin') || token && config.url?.startsWith('/auth/')) {
config.headers.Authorization = `Bearer ${token}`
}
return config
})
// Listeners notified when the session is no longer valid (expired / revoked).
const unauthorizedListeners = new Set()
export const onUnauthorized = (fn) => {
unauthorizedListeners.add(fn)
return () => unauthorizedListeners.delete(fn)
}
api.interceptors.response.use(
(res) => res,
(error) => {
const status = error.response?.status
const url = error.config?.url || ''
if (status === 401 && !url.includes('/auth/login')) {
tokenStore.clear()
unauthorizedListeners.forEach((fn) => fn(error.response?.data?.detail))
}
return Promise.reject(error)
},
)
/** Human-readable message from any API error. */
export function errorMessage(error, fallback = 'Something went wrong. Please try again.') {
if (!error?.response) return error?.code === 'ECONNABORTED' ? 'The request timed out.' : 'Cannot reach the server. Check your connection.'
const data = error.response.data
if (typeof data?.detail === 'string' && data.detail !== 'Validation failed') return data.detail
if (Array.isArray(data?.detail?.errors)) return data.detail.errors.join(' ')
if (Array.isArray(data?.errors) && data.errors.length) {
return data.errors.map((e) => (e.field ? `${prettyField(e.field)}: ${e.message}` : e.message)).join(' · ')
}
if (error.response.status === 429) return 'Too many attempts. Please wait a minute and try again.'
return fallback
}
/** {field: message} map for inline form errors (422 responses). */
export function fieldErrors(error) {
const out = {}
for (const e of error?.response?.data?.errors || []) {
if (e.field) out[e.field.split('.').pop()] = e.message.replace(/^Value error, /, '')
}
return out
}
const prettyField = (f) => f.split('.').pop().replace(/_/g, ' ')
export default api

Some files were not shown because too many files have changed in this diff Show More