Issue 1: repo scaffold and project structure
This commit is contained in:
@@ -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?
|
||||
@@ -0,0 +1,73 @@
|
||||
# React + TypeScript + Vite
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint 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 ESLint configuration
|
||||
|
||||
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
||||
|
||||
```js
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
|
||||
// Remove tseslint.configs.recommended and replace with this
|
||||
tseslint.configs.recommendedTypeChecked,
|
||||
// Alternatively, use this for stricter rules
|
||||
tseslint.configs.strictTypeChecked,
|
||||
// Optionally, add this for stylistic rules
|
||||
tseslint.configs.stylisticTypeChecked,
|
||||
|
||||
// Other configs...
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```
|
||||
|
||||
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
||||
|
||||
```js
|
||||
// eslint.config.js
|
||||
import reactX from 'eslint-plugin-react-x'
|
||||
import reactDom from 'eslint-plugin-react-dom'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
// Enable lint rules for React
|
||||
reactX.configs['recommended-typescript'],
|
||||
// Enable lint rules for React DOM
|
||||
reactDom.configs.recommended,
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
import js from '@eslint/js'
|
||||
import globals from 'globals'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
import tseslint from 'typescript-eslint'
|
||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
tseslint.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
globals: globals.browser,
|
||||
},
|
||||
},
|
||||
])
|
||||
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>frontend</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
Generated
+3132
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^19.2.6",
|
||||
"react-dom": "^19.2.6",
|
||||
"react-router-dom": "^7.17.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@tailwindcss/vite": "^4.3.0",
|
||||
"@types/node": "^24.12.3",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^6.0.1",
|
||||
"eslint": "^10.3.0",
|
||||
"eslint-plugin-react-hooks": "^7.1.1",
|
||||
"eslint-plugin-react-refresh": "^0.5.2",
|
||||
"globals": "^17.6.0",
|
||||
"tailwindcss": "^4.3.0",
|
||||
"typescript": "~6.0.2",
|
||||
"typescript-eslint": "^8.59.2",
|
||||
"vite": "^8.0.12"
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 9.3 KiB |
@@ -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 |
@@ -0,0 +1,46 @@
|
||||
import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom";
|
||||
import { AuthProvider, useAuth } from "./context/AuthContext";
|
||||
import Layout from "./components/Layout";
|
||||
import Login from "./pages/Login";
|
||||
import EntitiesList from "./pages/EntitiesList";
|
||||
import EntityOverview from "./pages/EntityOverview";
|
||||
import Investments from "./pages/Investments";
|
||||
import ValuationWorkflow from "./pages/ValuationWorkflow";
|
||||
|
||||
function ProtectedRoutes() {
|
||||
const { user, loading } = useAuth();
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center text-gray-500 text-sm">
|
||||
Loading...
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
return <Login />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<Routes>
|
||||
<Route path="/" element={<EntitiesList />} />
|
||||
<Route path="/entities/:id" element={<EntityOverview />} />
|
||||
<Route path="/entities/:id/investments" element={<Investments />} />
|
||||
<Route path="/entities/:id/valuation" element={<ValuationWorkflow />} />
|
||||
<Route path="*" element={<Navigate to="/" replace />} />
|
||||
</Routes>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<BrowserRouter>
|
||||
<AuthProvider>
|
||||
<ProtectedRoutes />
|
||||
</AuthProvider>
|
||||
</BrowserRouter>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
/**
|
||||
* Typed API client for Ten31Portal backend.
|
||||
*/
|
||||
|
||||
// --- Types ---
|
||||
|
||||
export type UserRole = "approver" | "cfo" | "fund_admin" | "viewer";
|
||||
export type EntityType = "fund" | "spv" | "gp" | "mgmt_co";
|
||||
export type EntityStatus = "active" | "closed";
|
||||
export type RoundStatus = "draft" | "submitted" | "approved" | "returned";
|
||||
|
||||
export interface User {
|
||||
id: number;
|
||||
name: string;
|
||||
email: string;
|
||||
role: UserRole;
|
||||
is_active: boolean;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface Entity {
|
||||
id: number;
|
||||
name: string;
|
||||
type: EntityType;
|
||||
vintage_year: number | null;
|
||||
fund_size_cents: number | null;
|
||||
status: EntityStatus;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface Holding {
|
||||
id: number;
|
||||
entity_id: number;
|
||||
company_name: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface Position {
|
||||
id: number;
|
||||
holding_id: number;
|
||||
security_name: string;
|
||||
investment_date: string;
|
||||
shares: string | null;
|
||||
cost_cents: number;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface Valuation {
|
||||
id: number;
|
||||
round_id: number;
|
||||
position_id: number;
|
||||
value_cents: number;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface ValuationRound {
|
||||
id: number;
|
||||
entity_id: number;
|
||||
quarter_end: string;
|
||||
status: RoundStatus;
|
||||
submitted_by: number | null;
|
||||
submitted_at: string | null;
|
||||
approved_by: number | null;
|
||||
approved_at: string | null;
|
||||
return_note: string | null;
|
||||
is_seed: boolean;
|
||||
created_at: string;
|
||||
valuations: Valuation[];
|
||||
}
|
||||
|
||||
export interface AuditEntry {
|
||||
id: number;
|
||||
actor_user_id: number | null;
|
||||
action: string;
|
||||
object_type: string;
|
||||
object_id: number | null;
|
||||
detail: unknown;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
// --- API helpers ---
|
||||
|
||||
class ApiError extends Error {
|
||||
status: number;
|
||||
constructor(status: number, message: string) {
|
||||
super(message);
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
||||
async function request<T>(path: string, options?: RequestInit): Promise<T> {
|
||||
const res = await fetch(path, {
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...options?.headers,
|
||||
},
|
||||
});
|
||||
if (!res.ok) {
|
||||
const body = await res.json().catch(() => ({ detail: res.statusText }));
|
||||
throw new ApiError(res.status, body.detail || res.statusText);
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
// --- Auth ---
|
||||
|
||||
export const api = {
|
||||
login: (email: string, password: string) =>
|
||||
request<User>("/api/auth/login", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ email, password }),
|
||||
}),
|
||||
|
||||
logout: () => request<{ status: string }>("/api/auth/logout", { method: "POST" }),
|
||||
|
||||
me: () => request<User>("/api/auth/me"),
|
||||
|
||||
// Entities
|
||||
listEntities: () => request<Entity[]>("/api/entities"),
|
||||
getEntity: (id: number) => request<Entity>(`/api/entities/${id}`),
|
||||
createEntity: (data: Partial<Entity>) =>
|
||||
request<Entity>("/api/entities", { method: "POST", body: JSON.stringify(data) }),
|
||||
updateEntity: (id: number, data: Partial<Entity>) =>
|
||||
request<Entity>(`/api/entities/${id}`, { method: "PATCH", body: JSON.stringify(data) }),
|
||||
|
||||
// Holdings
|
||||
listHoldings: (entityId: number) =>
|
||||
request<Holding[]>(`/api/entities/${entityId}/holdings`),
|
||||
createHolding: (entityId: number, data: { company_name: string }) =>
|
||||
request<Holding>(`/api/entities/${entityId}/holdings`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(data),
|
||||
}),
|
||||
|
||||
// Positions
|
||||
listPositions: (holdingId: number) =>
|
||||
request<Position[]>(`/api/holdings/${holdingId}/positions`),
|
||||
|
||||
// Rounds
|
||||
listRounds: (entityId: number) =>
|
||||
request<ValuationRound[]>(`/api/entities/${entityId}/rounds`),
|
||||
getRound: (roundId: number) => request<ValuationRound>(`/api/rounds/${roundId}`),
|
||||
createRound: (entityId: number, quarterEnd: string) =>
|
||||
request<ValuationRound>(`/api/entities/${entityId}/rounds`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ quarter_end: quarterEnd }),
|
||||
}),
|
||||
updateValuations: (roundId: number, valuations: { position_id: number; value_cents: number }[]) =>
|
||||
request<ValuationRound>(`/api/rounds/${roundId}/valuations`, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify({ valuations }),
|
||||
}),
|
||||
submitRound: (roundId: number) =>
|
||||
request<ValuationRound>(`/api/rounds/${roundId}/submit`, { method: "POST" }),
|
||||
approveRound: (roundId: number) =>
|
||||
request<ValuationRound>(`/api/rounds/${roundId}/approve`, { method: "POST" }),
|
||||
returnRound: (roundId: number, note: string) =>
|
||||
request<ValuationRound>(`/api/rounds/${roundId}/return`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ note }),
|
||||
}),
|
||||
|
||||
// Audit
|
||||
listAudit: (params?: { object_type?: string; object_id?: number; page?: number }) => {
|
||||
const q = new URLSearchParams();
|
||||
if (params?.object_type) q.set("object_type", params.object_type);
|
||||
if (params?.object_id) q.set("object_id", String(params.object_id));
|
||||
if (params?.page) q.set("page", String(params.page));
|
||||
return request<AuditEntry[]>(`/api/audit?${q}`);
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,73 @@
|
||||
import { Link, useLocation } from "react-router-dom";
|
||||
import { useAuth } from "../context/AuthContext";
|
||||
|
||||
const NAV_ITEMS = [
|
||||
{ label: "Entities", path: "/" },
|
||||
{ label: "Import", path: "/import", stub: true },
|
||||
{ label: "Audit Log", path: "/audit", stub: true },
|
||||
];
|
||||
|
||||
export default function Layout({ children }: { children: React.ReactNode }) {
|
||||
const { user, logout } = useAuth();
|
||||
const location = useLocation();
|
||||
|
||||
return (
|
||||
<div className="flex h-screen bg-gray-50">
|
||||
{/* Left nav */}
|
||||
<nav className="w-56 bg-white border-r border-gray-200 flex flex-col">
|
||||
<div className="p-4 border-b border-gray-200">
|
||||
<h1 className="text-lg font-semibold text-gray-900">Ten31Portal</h1>
|
||||
</div>
|
||||
<ul className="flex-1 py-2">
|
||||
{NAV_ITEMS.map((item) => {
|
||||
const active = item.path === "/"
|
||||
? location.pathname === "/"
|
||||
: location.pathname.startsWith(item.path);
|
||||
return (
|
||||
<li key={item.path}>
|
||||
{item.stub ? (
|
||||
<span className="block px-4 py-2 text-sm text-gray-400 cursor-not-allowed">
|
||||
{item.label}
|
||||
</span>
|
||||
) : (
|
||||
<Link
|
||||
to={item.path}
|
||||
className={`block px-4 py-2 text-sm ${
|
||||
active
|
||||
? "bg-orange-50 text-orange-600 border-r-2 border-orange-500 font-medium"
|
||||
: "text-gray-700 hover:bg-gray-50"
|
||||
}`}
|
||||
>
|
||||
{item.label}
|
||||
</Link>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
{/* Main area */}
|
||||
<div className="flex-1 flex flex-col overflow-hidden">
|
||||
{/* Top bar */}
|
||||
<header className="h-14 bg-white border-b border-gray-200 flex items-center justify-end px-6">
|
||||
<div className="flex items-center gap-4">
|
||||
<span className="text-sm text-gray-600">{user?.name}</span>
|
||||
<span className="text-xs text-gray-400 bg-gray-100 px-2 py-0.5 rounded">
|
||||
{user?.role}
|
||||
</span>
|
||||
<button
|
||||
onClick={logout}
|
||||
className="text-sm text-gray-500 hover:text-gray-800"
|
||||
>
|
||||
Sign out
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{/* Content */}
|
||||
<main className="flex-1 overflow-auto p-6">{children}</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { createContext, useContext, useEffect, useState, type ReactNode } from "react";
|
||||
import { api, type User } from "../api";
|
||||
|
||||
interface AuthState {
|
||||
user: User | null;
|
||||
loading: boolean;
|
||||
login: (email: string, password: string) => Promise<void>;
|
||||
logout: () => Promise<void>;
|
||||
}
|
||||
|
||||
const AuthContext = createContext<AuthState | null>(null);
|
||||
|
||||
export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
const [user, setUser] = useState<User | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
api.me().then(setUser).catch(() => setUser(null)).finally(() => setLoading(false));
|
||||
}, []);
|
||||
|
||||
const login = async (email: string, password: string) => {
|
||||
const u = await api.login(email, password);
|
||||
setUser(u);
|
||||
};
|
||||
|
||||
const logout = async () => {
|
||||
await api.logout();
|
||||
setUser(null);
|
||||
};
|
||||
|
||||
return (
|
||||
<AuthContext.Provider value={{ user, loading, login, logout }}>
|
||||
{children}
|
||||
</AuthContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useAuth() {
|
||||
const ctx = useContext(AuthContext);
|
||||
if (!ctx) throw new Error("useAuth must be inside AuthProvider");
|
||||
return ctx;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Money and date formatting helpers.
|
||||
* Money: cents -> display string. Never float in the DB.
|
||||
*/
|
||||
|
||||
/** Format cents as dollars: $1.2M, $12,345, etc. */
|
||||
export function formatMoney(cents: number | null | undefined): string {
|
||||
if (cents == null) return "—";
|
||||
const dollars = cents / 100;
|
||||
const abs = Math.abs(dollars);
|
||||
const sign = dollars < 0 ? "-" : "";
|
||||
|
||||
if (abs >= 1_000_000_000) {
|
||||
return `${sign}$${(abs / 1_000_000_000).toFixed(1)}B`;
|
||||
}
|
||||
if (abs >= 1_000_000) {
|
||||
return `${sign}$${(abs / 1_000_000).toFixed(1)}M`;
|
||||
}
|
||||
if (abs >= 1_000) {
|
||||
return `${sign}$${Math.round(abs).toLocaleString("en-US")}`;
|
||||
}
|
||||
return `${sign}$${abs.toFixed(2)}`;
|
||||
}
|
||||
|
||||
/** Format cents as compact dollars for tables (no rounding for small values). */
|
||||
export function formatMoneyExact(cents: number | null | undefined): string {
|
||||
if (cents == null) return "—";
|
||||
const dollars = cents / 100;
|
||||
return `$${dollars.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
}
|
||||
|
||||
/** Format date string to short form: Jun 15, 2021 */
|
||||
export function formatDate(dateStr: string | null | undefined): string {
|
||||
if (!dateStr) return "—";
|
||||
const d = new Date(dateStr + (dateStr.includes("T") ? "" : "T00:00:00"));
|
||||
return d.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" });
|
||||
}
|
||||
|
||||
/** Format quarter-end date as "Q2 2026" */
|
||||
export function formatQuarter(dateStr: string): string {
|
||||
const d = new Date(dateStr + "T00:00:00");
|
||||
const month = d.getMonth(); // 0-11
|
||||
const q = Math.floor(month / 3) + 1;
|
||||
return `Q${q} ${d.getFullYear()}`;
|
||||
}
|
||||
|
||||
/** Gain/loss as formatted string with sign */
|
||||
export function formatGainLoss(valueCents: number, costCents: number): {
|
||||
text: string;
|
||||
positive: boolean;
|
||||
cents: number;
|
||||
} {
|
||||
const diff = valueCents - costCents;
|
||||
return {
|
||||
text: formatMoney(Math.abs(diff)),
|
||||
positive: diff >= 0,
|
||||
cents: diff,
|
||||
};
|
||||
}
|
||||
|
||||
/** Per-share calculation: cents / shares string. Returns null if shares is null/zero. */
|
||||
export function perShare(cents: number, shares: string | null): number | null {
|
||||
if (!shares) return null;
|
||||
const s = parseFloat(shares);
|
||||
if (!s || s === 0) return null;
|
||||
return cents / s;
|
||||
}
|
||||
|
||||
/** Format per-share value */
|
||||
export function formatPerShare(cents: number, shares: string | null): string {
|
||||
const val = perShare(cents, shares);
|
||||
if (val == null) return "—";
|
||||
return formatMoneyExact(Math.round(val));
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
@import "tailwindcss";
|
||||
@@ -0,0 +1,10 @@
|
||||
import { StrictMode } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import "./index.css";
|
||||
import App from "./App.tsx";
|
||||
|
||||
createRoot(document.getElementById("root")!).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>
|
||||
);
|
||||
@@ -0,0 +1,148 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, type Entity, type Holding, type Position, type ValuationRound } from "../api";
|
||||
import { formatMoney, formatGainLoss } from "../format";
|
||||
|
||||
interface EntityRow extends Entity {
|
||||
investedCents: number;
|
||||
lastValueCents: number;
|
||||
}
|
||||
|
||||
export default function EntitiesList() {
|
||||
const [entities, setEntities] = useState<EntityRow[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
loadData();
|
||||
}, []);
|
||||
|
||||
async function loadData() {
|
||||
setLoading(true);
|
||||
try {
|
||||
const ents = await api.listEntities();
|
||||
const enriched: EntityRow[] = [];
|
||||
|
||||
for (const ent of ents) {
|
||||
const holdings = await api.listHoldings(ent.id);
|
||||
let investedCents = 0;
|
||||
let lastValueCents = 0;
|
||||
|
||||
// Get all positions for cost
|
||||
for (const h of holdings) {
|
||||
const positions = await api.listPositions(h.id);
|
||||
for (const p of positions) {
|
||||
investedCents += p.cost_cents;
|
||||
}
|
||||
}
|
||||
|
||||
// Get latest approved round for value
|
||||
const rounds = await api.listRounds(ent.id);
|
||||
const approved = rounds.filter((r) => r.status === "approved");
|
||||
if (approved.length > 0) {
|
||||
const latest = approved[0]; // Already sorted desc by quarter_end
|
||||
lastValueCents = latest.valuations.reduce((sum, v) => sum + v.value_cents, 0);
|
||||
}
|
||||
|
||||
enriched.push({ ...ent, investedCents, lastValueCents });
|
||||
}
|
||||
|
||||
setEntities(enriched);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return <div className="text-gray-500 text-sm">Loading...</div>;
|
||||
}
|
||||
|
||||
const funds = entities.filter((e) => e.type === "fund" || e.type === "spv");
|
||||
const gps = entities.filter((e) => e.type === "gp" || e.type === "mgmt_co");
|
||||
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
<EntityTable title="Funds and SPVs" rows={funds} />
|
||||
<EntityTable title="GP Entities and Management Companies" rows={gps} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function EntityTable({ title, rows }: { title: string; rows: EntityRow[] }) {
|
||||
const totalInvested = rows.reduce((s, r) => s + r.investedCents, 0);
|
||||
const totalValue = rows.reduce((s, r) => s + r.lastValueCents, 0);
|
||||
const totalGain = totalValue - totalInvested;
|
||||
|
||||
const TYPE_LABELS: Record<string, string> = {
|
||||
fund: "Fund",
|
||||
spv: "SPV",
|
||||
gp: "GP",
|
||||
mgmt_co: "Mgmt Co",
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2 className="text-lg font-semibold text-gray-900 mb-3">{title}</h2>
|
||||
<div className="bg-white border border-gray-200 rounded-lg overflow-hidden">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="bg-gray-50 border-b border-gray-200">
|
||||
<th className="text-left px-4 py-3 font-medium text-gray-600">Name</th>
|
||||
<th className="text-left px-4 py-3 font-medium text-gray-600">Type</th>
|
||||
<th className="text-left px-4 py-3 font-medium text-gray-600">Vintage</th>
|
||||
<th className="text-right px-4 py-3 font-medium text-gray-600">Invested</th>
|
||||
<th className="text-right px-4 py-3 font-medium text-gray-600">Last Signed Value</th>
|
||||
<th className="text-right px-4 py-3 font-medium text-gray-600">Gain/Loss</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((row) => {
|
||||
const gl = formatGainLoss(row.lastValueCents, row.investedCents);
|
||||
return (
|
||||
<tr key={row.id} className="border-b border-gray-100 hover:bg-gray-50">
|
||||
<td className="px-4 py-3">
|
||||
<Link
|
||||
to={`/entities/${row.id}`}
|
||||
className="text-gray-900 font-medium hover:text-orange-600"
|
||||
>
|
||||
{row.name}
|
||||
</Link>
|
||||
</td>
|
||||
<td className="px-4 py-3">
|
||||
<span className="inline-block px-2 py-0.5 bg-gray-100 text-gray-600 text-xs rounded">
|
||||
{TYPE_LABELS[row.type] || row.type}
|
||||
</span>
|
||||
</td>
|
||||
<td className="px-4 py-3 text-gray-600">{row.vintage_year || "—"}</td>
|
||||
<td className="px-4 py-3 text-right text-gray-900">{formatMoney(row.investedCents)}</td>
|
||||
<td className="px-4 py-3 text-right text-gray-900">{formatMoney(row.lastValueCents)}</td>
|
||||
<td className={`px-4 py-3 text-right font-medium ${gl.positive ? "text-green-600" : "text-red-600"}`}>
|
||||
{gl.positive ? "+" : "-"}{gl.text}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
{rows.length > 0 && (
|
||||
<tr className="bg-gray-50 font-medium">
|
||||
<td className="px-4 py-3 text-gray-900" colSpan={3}>
|
||||
Total
|
||||
</td>
|
||||
<td className="px-4 py-3 text-right text-gray-900">{formatMoney(totalInvested)}</td>
|
||||
<td className="px-4 py-3 text-right text-gray-900">{formatMoney(totalValue)}</td>
|
||||
<td className={`px-4 py-3 text-right ${totalGain >= 0 ? "text-green-600" : "text-red-600"}`}>
|
||||
{totalGain >= 0 ? "+" : "-"}{formatMoney(Math.abs(totalGain))}
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
{rows.length === 0 && (
|
||||
<tr>
|
||||
<td className="px-4 py-6 text-center text-gray-400" colSpan={6}>
|
||||
No entities yet.
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link, useParams } from "react-router-dom";
|
||||
import { api, type Entity, type Holding, type Position, type ValuationRound } from "../api";
|
||||
import { formatMoney, formatDate, formatQuarter } from "../format";
|
||||
|
||||
const TYPE_LABELS: Record<string, string> = {
|
||||
fund: "Fund",
|
||||
spv: "SPV",
|
||||
gp: "GP",
|
||||
mgmt_co: "Mgmt Co",
|
||||
};
|
||||
|
||||
const STATUS_COLORS: Record<string, string> = {
|
||||
draft: "bg-gray-100 text-gray-600",
|
||||
submitted: "bg-yellow-100 text-yellow-700",
|
||||
approved: "bg-green-100 text-green-700",
|
||||
returned: "bg-red-100 text-red-600",
|
||||
};
|
||||
|
||||
export default function EntityOverview() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const [entity, setEntity] = useState<Entity | null>(null);
|
||||
const [holdings, setHoldings] = useState<Holding[]>([]);
|
||||
const [totalInvested, setTotalInvested] = useState(0);
|
||||
const [lastValue, setLastValue] = useState(0);
|
||||
const [latestRound, setLatestRound] = useState<ValuationRound | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id) return;
|
||||
loadData(parseInt(id));
|
||||
}, [id]);
|
||||
|
||||
async function loadData(entityId: number) {
|
||||
setLoading(true);
|
||||
try {
|
||||
const ent = await api.getEntity(entityId);
|
||||
setEntity(ent);
|
||||
|
||||
const holds = await api.listHoldings(entityId);
|
||||
setHoldings(holds);
|
||||
|
||||
let invested = 0;
|
||||
for (const h of holds) {
|
||||
const positions = await api.listPositions(h.id);
|
||||
for (const p of positions) {
|
||||
invested += p.cost_cents;
|
||||
}
|
||||
}
|
||||
setTotalInvested(invested);
|
||||
|
||||
const rounds = await api.listRounds(entityId);
|
||||
const approved = rounds.filter((r) => r.status === "approved");
|
||||
if (approved.length > 0) {
|
||||
setLatestRound(approved[0]);
|
||||
setLastValue(approved[0].valuations.reduce((s, v) => s + v.value_cents, 0));
|
||||
}
|
||||
// Also check for most recent round of any status
|
||||
if (rounds.length > 0) {
|
||||
setLatestRound(rounds[0]);
|
||||
if (rounds[0].status === "approved") {
|
||||
setLastValue(rounds[0].valuations.reduce((s, v) => s + v.value_cents, 0));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (loading || !entity) {
|
||||
return <div className="text-gray-500 text-sm">Loading...</div>;
|
||||
}
|
||||
|
||||
const gainLoss = lastValue - totalInvested;
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Header */}
|
||||
<div className="mb-6">
|
||||
<div className="flex items-center gap-3 mb-1">
|
||||
<h1 className="text-2xl font-semibold text-gray-900">{entity.name}</h1>
|
||||
<span className="inline-block px-2 py-0.5 bg-gray-100 text-gray-600 text-xs rounded">
|
||||
{TYPE_LABELS[entity.type] || entity.type}
|
||||
</span>
|
||||
</div>
|
||||
{/* Tabs */}
|
||||
<div className="flex gap-6 mt-4 border-b border-gray-200">
|
||||
<span className="pb-2 border-b-2 border-orange-500 text-sm font-medium text-orange-600">
|
||||
Overview
|
||||
</span>
|
||||
<Link
|
||||
to={`/entities/${entity.id}/investments`}
|
||||
className="pb-2 text-sm text-gray-500 hover:text-gray-800"
|
||||
>
|
||||
Investments
|
||||
</Link>
|
||||
<span className="pb-2 text-sm text-gray-400 cursor-not-allowed">Partners</span>
|
||||
<span className="pb-2 text-sm text-gray-400 cursor-not-allowed">Documents</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Summary cards */}
|
||||
<div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-8">
|
||||
<SummaryCard label="Vintage" value={entity.vintage_year?.toString() || "—"} />
|
||||
<SummaryCard label="Fund Size" value={formatMoney(entity.fund_size_cents)} />
|
||||
<SummaryCard label="Total Invested" value={formatMoney(totalInvested)} />
|
||||
<SummaryCard label="Holdings" value={holdings.length.toString()} />
|
||||
<SummaryCard label="Last Signed Value" value={formatMoney(lastValue)} />
|
||||
<SummaryCard
|
||||
label="Gain/Loss"
|
||||
value={`${gainLoss >= 0 ? "+" : "-"}${formatMoney(Math.abs(gainLoss))}`}
|
||||
color={gainLoss >= 0 ? "text-green-600" : "text-red-600"}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Current quarter status */}
|
||||
{latestRound && (
|
||||
<div className="bg-white border border-gray-200 rounded-lg p-4">
|
||||
<h3 className="text-sm font-medium text-gray-700 mb-2">Current Quarter Status</h3>
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-sm text-gray-900">{formatQuarter(latestRound.quarter_end)}</span>
|
||||
<span className={`inline-block px-2 py-0.5 text-xs rounded ${STATUS_COLORS[latestRound.status]}`}>
|
||||
{latestRound.status}
|
||||
</span>
|
||||
{latestRound.status === "approved" && latestRound.approved_at && (
|
||||
<span className="text-sm text-gray-500">
|
||||
Signed {formatDate(latestRound.approved_at)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SummaryCard({
|
||||
label,
|
||||
value,
|
||||
color = "text-gray-900",
|
||||
}: {
|
||||
label: string;
|
||||
value: string;
|
||||
color?: string;
|
||||
}) {
|
||||
return (
|
||||
<div className="bg-white border border-gray-200 rounded-lg p-4">
|
||||
<div className="text-xs text-gray-500 mb-1">{label}</div>
|
||||
<div className={`text-lg font-semibold ${color}`}>{value}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link, useParams } from "react-router-dom";
|
||||
import { api, type Entity, type Holding, type Position, type ValuationRound, type Valuation } from "../api";
|
||||
import { formatMoney, formatMoneyExact, formatDate, formatQuarter, formatPerShare } from "../format";
|
||||
|
||||
const TYPE_LABELS: Record<string, string> = {
|
||||
fund: "Fund",
|
||||
spv: "SPV",
|
||||
gp: "GP",
|
||||
mgmt_co: "Mgmt Co",
|
||||
};
|
||||
|
||||
interface PositionWithValuation extends Position {
|
||||
lastValueCents: number | null;
|
||||
valuationDate: string | null;
|
||||
valuationQuarter: string | null;
|
||||
}
|
||||
|
||||
interface HoldingGroup {
|
||||
holding: Holding;
|
||||
positions: PositionWithValuation[];
|
||||
totalCost: number;
|
||||
totalValue: number;
|
||||
}
|
||||
|
||||
export default function Investments() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const [entity, setEntity] = useState<Entity | null>(null);
|
||||
const [groups, setGroups] = useState<HoldingGroup[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id) return;
|
||||
loadData(parseInt(id));
|
||||
}, [id]);
|
||||
|
||||
async function loadData(entityId: number) {
|
||||
setLoading(true);
|
||||
try {
|
||||
const ent = await api.getEntity(entityId);
|
||||
setEntity(ent);
|
||||
|
||||
const holdings = await api.listHoldings(entityId);
|
||||
const rounds = await api.listRounds(entityId);
|
||||
|
||||
// Find latest approved round
|
||||
const approvedRounds = rounds
|
||||
.filter((r) => r.status === "approved")
|
||||
.sort((a, b) => b.quarter_end.localeCompare(a.quarter_end));
|
||||
const latestApproved = approvedRounds[0] || null;
|
||||
|
||||
// Build valuation lookup: position_id -> {value_cents, quarter_end, approved_at}
|
||||
const valMap = new Map<number, { value_cents: number; quarter_end: string; approved_at: string | null }>();
|
||||
if (latestApproved) {
|
||||
for (const v of latestApproved.valuations) {
|
||||
valMap.set(v.position_id, {
|
||||
value_cents: v.value_cents,
|
||||
quarter_end: latestApproved.quarter_end,
|
||||
approved_at: latestApproved.approved_at,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const result: HoldingGroup[] = [];
|
||||
for (const h of holdings) {
|
||||
const positions = await api.listPositions(h.id);
|
||||
const enriched: PositionWithValuation[] = positions.map((p) => {
|
||||
const val = valMap.get(p.id);
|
||||
return {
|
||||
...p,
|
||||
lastValueCents: val?.value_cents ?? null,
|
||||
valuationDate: val?.approved_at ?? null,
|
||||
valuationQuarter: val?.quarter_end ?? null,
|
||||
};
|
||||
});
|
||||
const totalCost = enriched.reduce((s, p) => s + p.cost_cents, 0);
|
||||
const totalValue = enriched.reduce((s, p) => s + (p.lastValueCents ?? 0), 0);
|
||||
result.push({ holding: h, positions: enriched, totalCost, totalValue });
|
||||
}
|
||||
|
||||
setGroups(result);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (loading || !entity) {
|
||||
return <div className="text-gray-500 text-sm">Loading...</div>;
|
||||
}
|
||||
|
||||
const totalCost = groups.reduce((s, g) => s + g.totalCost, 0);
|
||||
const totalValue = groups.reduce((s, g) => s + g.totalValue, 0);
|
||||
const totalGain = totalValue - totalCost;
|
||||
const positionCount = groups.reduce((s, g) => s + g.positions.length, 0);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Header */}
|
||||
<div className="mb-6">
|
||||
<div className="flex items-center gap-3 mb-1">
|
||||
<h1 className="text-2xl font-semibold text-gray-900">{entity.name}</h1>
|
||||
<span className="inline-block px-2 py-0.5 bg-gray-100 text-gray-600 text-xs rounded">
|
||||
{TYPE_LABELS[entity.type] || entity.type}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex gap-6 mt-4 border-b border-gray-200">
|
||||
<Link
|
||||
to={`/entities/${entity.id}`}
|
||||
className="pb-2 text-sm text-gray-500 hover:text-gray-800"
|
||||
>
|
||||
Overview
|
||||
</Link>
|
||||
<span className="pb-2 border-b-2 border-orange-500 text-sm font-medium text-orange-600">
|
||||
Investments
|
||||
</span>
|
||||
<span className="pb-2 text-sm text-gray-400 cursor-not-allowed">Partners</span>
|
||||
<span className="pb-2 text-sm text-gray-400 cursor-not-allowed">Documents</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Header band */}
|
||||
<div className="flex gap-6 mb-6 text-sm">
|
||||
<div>
|
||||
<span className="text-gray-500">Active investments:</span>{" "}
|
||||
<span className="font-medium text-gray-900">{positionCount}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-gray-500">Total cost:</span>{" "}
|
||||
<span className="font-medium text-gray-900">{formatMoney(totalCost)}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-gray-500">Total value:</span>{" "}
|
||||
<span className="font-medium text-gray-900">{formatMoney(totalValue)}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-gray-500">Unrealized gain/loss:</span>{" "}
|
||||
<span className={`font-medium ${totalGain >= 0 ? "text-green-600" : "text-red-600"}`}>
|
||||
{totalGain >= 0 ? "+" : "-"}{formatMoney(Math.abs(totalGain))}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Grouped table */}
|
||||
<div className="bg-white border border-gray-200 rounded-lg overflow-hidden">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="bg-gray-50 border-b border-gray-200">
|
||||
<th className="text-left px-4 py-3 font-medium text-gray-600">Security</th>
|
||||
<th className="text-left px-4 py-3 font-medium text-gray-600">Date</th>
|
||||
<th className="text-right px-4 py-3 font-medium text-gray-600">Shares</th>
|
||||
<th className="text-right px-4 py-3 font-medium text-gray-600">Cost</th>
|
||||
<th className="text-right px-4 py-3 font-medium text-gray-600">Cost/Share</th>
|
||||
<th className="text-right px-4 py-3 font-medium text-gray-600">Signed Value</th>
|
||||
<th className="text-right px-4 py-3 font-medium text-gray-600">Value/Share</th>
|
||||
<th className="text-left px-4 py-3 font-medium text-gray-600">Signed</th>
|
||||
<th className="text-right px-4 py-3 font-medium text-gray-600">Gain/Loss</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{groups.map((group) => {
|
||||
const holdingGain = group.totalValue - group.totalCost;
|
||||
return (
|
||||
<HoldingGroupRows key={group.holding.id} group={group} holdingGain={holdingGain} />
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function HoldingGroupRows({ group, holdingGain }: { group: HoldingGroup; holdingGain: number }) {
|
||||
return (
|
||||
<>
|
||||
{/* Holding header row */}
|
||||
<tr className="bg-gray-50 border-t border-gray-200">
|
||||
<td className="px-4 py-2 font-semibold text-gray-900" colSpan={3}>
|
||||
{group.holding.company_name}
|
||||
</td>
|
||||
<td className="px-4 py-2 text-right font-medium text-gray-900">
|
||||
{formatMoney(group.totalCost)}
|
||||
</td>
|
||||
<td className="px-4 py-2" />
|
||||
<td className="px-4 py-2 text-right font-medium text-gray-900">
|
||||
{formatMoney(group.totalValue)}
|
||||
</td>
|
||||
<td className="px-4 py-2" />
|
||||
<td className="px-4 py-2" />
|
||||
<td className={`px-4 py-2 text-right font-medium ${holdingGain >= 0 ? "text-green-600" : "text-red-600"}`}>
|
||||
{holdingGain >= 0 ? "+" : "-"}{formatMoney(Math.abs(holdingGain))}
|
||||
</td>
|
||||
</tr>
|
||||
{/* Position rows */}
|
||||
{group.positions.map((pos) => {
|
||||
const gain = (pos.lastValueCents ?? 0) - pos.cost_cents;
|
||||
return (
|
||||
<tr key={pos.id} className="border-b border-gray-100 hover:bg-gray-50">
|
||||
<td className="px-4 py-2 pl-8 text-gray-700">{pos.security_name}</td>
|
||||
<td className="px-4 py-2 text-gray-600">{formatDate(pos.investment_date)}</td>
|
||||
<td className="px-4 py-2 text-right text-gray-600">
|
||||
{pos.shares ? parseFloat(pos.shares).toLocaleString() : "—"}
|
||||
</td>
|
||||
<td className="px-4 py-2 text-right text-gray-900">{formatMoney(pos.cost_cents)}</td>
|
||||
<td className="px-4 py-2 text-right text-gray-600">
|
||||
{formatPerShare(pos.cost_cents, pos.shares)}
|
||||
</td>
|
||||
<td className="px-4 py-2 text-right text-gray-900">
|
||||
{pos.lastValueCents != null ? formatMoney(pos.lastValueCents) : "—"}
|
||||
</td>
|
||||
<td className="px-4 py-2 text-right text-gray-600">
|
||||
{pos.lastValueCents != null ? formatPerShare(pos.lastValueCents, pos.shares) : "—"}
|
||||
</td>
|
||||
<td className="px-4 py-2 text-gray-600">
|
||||
{pos.valuationQuarter
|
||||
? `${formatQuarter(pos.valuationQuarter)} ${pos.valuationDate ? formatDate(pos.valuationDate) : ""}`
|
||||
: "—"}
|
||||
</td>
|
||||
<td className={`px-4 py-2 text-right font-medium ${gain >= 0 ? "text-green-600" : "text-red-600"}`}>
|
||||
{pos.lastValueCents != null ? (
|
||||
<>
|
||||
{gain >= 0 ? "▲" : "▼"} {formatMoney(Math.abs(gain))}
|
||||
</>
|
||||
) : (
|
||||
"—"
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import { useState, type FormEvent } from "react";
|
||||
import { useAuth } from "../context/AuthContext";
|
||||
|
||||
export default function Login() {
|
||||
const { login } = useAuth();
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [error, setError] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const handleSubmit = async (e: FormEvent) => {
|
||||
e.preventDefault();
|
||||
setError("");
|
||||
setLoading(true);
|
||||
try {
|
||||
await login(email, password);
|
||||
} catch (err: any) {
|
||||
setError(err.message || "Login failed");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50 flex items-center justify-center">
|
||||
<div className="bg-white p-8 rounded-lg shadow-sm border border-gray-200 w-96">
|
||||
<h1 className="text-xl font-semibold text-gray-900 mb-6">Ten31Portal</h1>
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<div>
|
||||
<label className="block text-sm text-gray-700 mb-1">Email</label>
|
||||
<input
|
||||
type="email"
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded text-sm focus:outline-none focus:ring-2 focus:ring-orange-500 focus:border-transparent"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm text-gray-700 mb-1">Password</label>
|
||||
<input
|
||||
type="password"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded text-sm focus:outline-none focus:ring-2 focus:ring-orange-500 focus:border-transparent"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
{error && <p className="text-sm text-red-600">{error}</p>}
|
||||
<button
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
className="w-full py-2 bg-gray-900 text-white text-sm rounded hover:bg-gray-800 disabled:opacity-50"
|
||||
>
|
||||
{loading ? "Signing in..." : "Sign in"}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,411 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useParams, Link } from "react-router-dom";
|
||||
import {
|
||||
api,
|
||||
type Entity,
|
||||
type Holding,
|
||||
type Position,
|
||||
type ValuationRound,
|
||||
type Valuation,
|
||||
} from "../api";
|
||||
import { useAuth } from "../context/AuthContext";
|
||||
import { formatMoney, formatMoneyExact, formatQuarter, formatDate } from "../format";
|
||||
|
||||
const STATUS_COLORS: Record<string, string> = {
|
||||
draft: "bg-gray-100 text-gray-600",
|
||||
submitted: "bg-yellow-100 text-yellow-700",
|
||||
approved: "bg-green-100 text-green-700",
|
||||
returned: "bg-red-100 text-red-600",
|
||||
};
|
||||
|
||||
interface PosInfo {
|
||||
position: Position;
|
||||
holdingName: string;
|
||||
}
|
||||
|
||||
export default function ValuationWorkflow() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const { user } = useAuth();
|
||||
const [entity, setEntity] = useState<Entity | null>(null);
|
||||
const [rounds, setRounds] = useState<ValuationRound[]>([]);
|
||||
const [selectedRound, setSelectedRound] = useState<ValuationRound | null>(null);
|
||||
const [posMap, setPosMap] = useState<Map<number, PosInfo>>(new Map());
|
||||
const [editValues, setEditValues] = useState<Map<number, string>>(new Map());
|
||||
const [priorValues, setPriorValues] = useState<Map<number, number>>(new Map());
|
||||
const [returnNote, setReturnNote] = useState("");
|
||||
const [newQuarter, setNewQuarter] = useState("");
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
|
||||
const entityId = id ? parseInt(id) : 0;
|
||||
const isApprover = user?.role === "approver";
|
||||
const canEdit =
|
||||
selectedRound &&
|
||||
(selectedRound.status === "draft" || selectedRound.status === "returned") &&
|
||||
user &&
|
||||
["fund_admin", "cfo", "approver"].includes(user.role);
|
||||
const canSubmit = canEdit;
|
||||
const canApprove =
|
||||
selectedRound?.status === "submitted" && isApprover;
|
||||
const canReturn =
|
||||
selectedRound?.status === "submitted" && isApprover;
|
||||
|
||||
useEffect(() => {
|
||||
if (!entityId) return;
|
||||
loadData();
|
||||
}, [entityId]);
|
||||
|
||||
async function loadData() {
|
||||
setLoading(true);
|
||||
try {
|
||||
const ent = await api.getEntity(entityId);
|
||||
setEntity(ent);
|
||||
|
||||
const rds = await api.listRounds(entityId);
|
||||
setRounds(rds);
|
||||
if (rds.length > 0) selectRound(rds[0], entityId);
|
||||
|
||||
// Build position map
|
||||
const holdings = await api.listHoldings(entityId);
|
||||
const pm = new Map<number, PosInfo>();
|
||||
for (const h of holdings) {
|
||||
const positions = await api.listPositions(h.id);
|
||||
for (const p of positions) {
|
||||
pm.set(p.id, { position: p, holdingName: h.company_name });
|
||||
}
|
||||
}
|
||||
setPosMap(pm);
|
||||
|
||||
// Build prior approved values map
|
||||
const approvedRounds = rds.filter((r) => r.status === "approved");
|
||||
if (approvedRounds.length > 0) {
|
||||
const latest = approvedRounds[0];
|
||||
const pv = new Map<number, number>();
|
||||
for (const v of latest.valuations) {
|
||||
pv.set(v.position_id, v.value_cents);
|
||||
}
|
||||
setPriorValues(pv);
|
||||
}
|
||||
} catch (err: any) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
function selectRound(round: ValuationRound, _entityId?: number) {
|
||||
setSelectedRound(round);
|
||||
const ev = new Map<number, string>();
|
||||
for (const v of round.valuations) {
|
||||
ev.set(v.position_id, (v.value_cents / 100).toString());
|
||||
}
|
||||
setEditValues(ev);
|
||||
setError("");
|
||||
}
|
||||
|
||||
async function handleCreateRound() {
|
||||
if (!newQuarter) return;
|
||||
setError("");
|
||||
try {
|
||||
const round = await api.createRound(entityId, newQuarter);
|
||||
setRounds((prev) => [round, ...prev]);
|
||||
selectRound(round);
|
||||
setNewQuarter("");
|
||||
} catch (err: any) {
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSave() {
|
||||
if (!selectedRound) return;
|
||||
setSaving(true);
|
||||
setError("");
|
||||
try {
|
||||
const valuations = Array.from(editValues.entries()).map(([posId, dollars]) => ({
|
||||
position_id: posId,
|
||||
value_cents: Math.round(parseFloat(dollars) * 100),
|
||||
}));
|
||||
const updated = await api.updateValuations(selectedRound.id, valuations);
|
||||
setSelectedRound(updated);
|
||||
setRounds((prev) => prev.map((r) => (r.id === updated.id ? updated : r)));
|
||||
} catch (err: any) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!selectedRound) return;
|
||||
await handleSave();
|
||||
try {
|
||||
const updated = await api.submitRound(selectedRound.id);
|
||||
setSelectedRound(updated);
|
||||
setRounds((prev) => prev.map((r) => (r.id === updated.id ? updated : r)));
|
||||
} catch (err: any) {
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleApprove() {
|
||||
if (!selectedRound) return;
|
||||
try {
|
||||
const updated = await api.approveRound(selectedRound.id);
|
||||
setSelectedRound(updated);
|
||||
setRounds((prev) => prev.map((r) => (r.id === updated.id ? updated : r)));
|
||||
} catch (err: any) {
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleReturn() {
|
||||
if (!selectedRound || !returnNote.trim()) return;
|
||||
try {
|
||||
const updated = await api.returnRound(selectedRound.id, returnNote);
|
||||
setSelectedRound(updated);
|
||||
setRounds((prev) => prev.map((r) => (r.id === updated.id ? updated : r)));
|
||||
setReturnNote("");
|
||||
} catch (err: any) {
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
if (loading || !entity) {
|
||||
return <div className="text-gray-500 text-sm">Loading...</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="mb-6">
|
||||
<div className="flex items-center gap-3 mb-1">
|
||||
<h1 className="text-2xl font-semibold text-gray-900">{entity.name}</h1>
|
||||
</div>
|
||||
<div className="flex gap-6 mt-4 border-b border-gray-200">
|
||||
<Link to={`/entities/${entity.id}`} className="pb-2 text-sm text-gray-500 hover:text-gray-800">
|
||||
Overview
|
||||
</Link>
|
||||
<Link to={`/entities/${entity.id}/investments`} className="pb-2 text-sm text-gray-500 hover:text-gray-800">
|
||||
Investments
|
||||
</Link>
|
||||
<span className="pb-2 border-b-2 border-orange-500 text-sm font-medium text-orange-600">
|
||||
Valuation
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div className="mb-4 p-3 bg-red-50 border border-red-200 rounded text-sm text-red-700">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex gap-6">
|
||||
{/* Round list sidebar */}
|
||||
<div className="w-64 shrink-0">
|
||||
<div className="mb-4">
|
||||
<h3 className="text-sm font-medium text-gray-700 mb-2">New Round</h3>
|
||||
<div className="flex gap-2">
|
||||
<input
|
||||
type="date"
|
||||
value={newQuarter}
|
||||
onChange={(e) => setNewQuarter(e.target.value)}
|
||||
className="flex-1 px-2 py-1.5 border border-gray-300 rounded text-sm"
|
||||
placeholder="Quarter end"
|
||||
/>
|
||||
<button
|
||||
onClick={handleCreateRound}
|
||||
className="px-3 py-1.5 bg-gray-900 text-white text-sm rounded hover:bg-gray-800"
|
||||
>
|
||||
Create
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 className="text-sm font-medium text-gray-700 mb-2">Rounds</h3>
|
||||
<ul className="space-y-1">
|
||||
{rounds.map((r) => (
|
||||
<li key={r.id}>
|
||||
<button
|
||||
onClick={() => selectRound(r)}
|
||||
className={`w-full text-left px-3 py-2 rounded text-sm ${
|
||||
selectedRound?.id === r.id ? "bg-orange-50 text-orange-700" : "hover:bg-gray-50 text-gray-700"
|
||||
}`}
|
||||
>
|
||||
<div className="font-medium">{formatQuarter(r.quarter_end)}</div>
|
||||
<div className="flex items-center gap-2 mt-0.5">
|
||||
<span className={`inline-block px-1.5 py-0.5 text-xs rounded ${STATUS_COLORS[r.status]}`}>
|
||||
{r.status}
|
||||
</span>
|
||||
{r.is_seed && <span className="text-xs text-gray-400">seed</span>}
|
||||
</div>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
{rounds.length === 0 && (
|
||||
<li className="text-sm text-gray-400 px-3">No rounds yet.</li>
|
||||
)}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{/* Round detail */}
|
||||
{selectedRound ? (
|
||||
<div className="flex-1">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<h2 className="text-lg font-semibold text-gray-900">
|
||||
{formatQuarter(selectedRound.quarter_end)}
|
||||
</h2>
|
||||
<span className={`inline-block px-2 py-0.5 text-xs rounded ${STATUS_COLORS[selectedRound.status]}`}>
|
||||
{selectedRound.status}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
{canEdit && (
|
||||
<>
|
||||
<button
|
||||
onClick={handleSave}
|
||||
disabled={saving}
|
||||
className="px-3 py-1.5 border border-gray-300 text-sm rounded hover:bg-gray-50"
|
||||
>
|
||||
{saving ? "Saving..." : "Save"}
|
||||
</button>
|
||||
<button
|
||||
onClick={handleSubmit}
|
||||
className="px-3 py-1.5 bg-gray-900 text-white text-sm rounded hover:bg-gray-800"
|
||||
>
|
||||
Submit for Review
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{canApprove && (
|
||||
<button
|
||||
onClick={handleApprove}
|
||||
className="px-3 py-1.5 bg-green-600 text-white text-sm rounded hover:bg-green-700"
|
||||
>
|
||||
Approve
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{selectedRound.return_note && selectedRound.status === "returned" && (
|
||||
<div className="mb-4 p-3 bg-yellow-50 border border-yellow-200 rounded text-sm text-yellow-800">
|
||||
Return note: {selectedRound.return_note}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{selectedRound.status === "approved" && selectedRound.approved_at && (
|
||||
<div className="mb-4 text-sm text-gray-500">
|
||||
Approved by user #{selectedRound.approved_by} on {formatDate(selectedRound.approved_at)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Valuations table */}
|
||||
<div className="bg-white border border-gray-200 rounded-lg overflow-hidden">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="bg-gray-50 border-b border-gray-200">
|
||||
<th className="text-left px-4 py-3 font-medium text-gray-600">Company</th>
|
||||
<th className="text-left px-4 py-3 font-medium text-gray-600">Security</th>
|
||||
<th className="text-right px-4 py-3 font-medium text-gray-600">Cost</th>
|
||||
{canApprove && (
|
||||
<th className="text-right px-4 py-3 font-medium text-gray-600">Prior Value</th>
|
||||
)}
|
||||
<th className="text-right px-4 py-3 font-medium text-gray-600">
|
||||
{canEdit ? "Value (edit)" : "Value"}
|
||||
</th>
|
||||
{canApprove && (
|
||||
<th className="text-right px-4 py-3 font-medium text-gray-600">Delta</th>
|
||||
)}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{selectedRound.valuations.map((v) => {
|
||||
const info = posMap.get(v.position_id);
|
||||
const prior = priorValues.get(v.position_id) ?? 0;
|
||||
const currentCents = canEdit
|
||||
? Math.round(parseFloat(editValues.get(v.position_id) || "0") * 100)
|
||||
: v.value_cents;
|
||||
const delta = currentCents - prior;
|
||||
|
||||
return (
|
||||
<tr key={v.id} className="border-b border-gray-100">
|
||||
<td className="px-4 py-2 text-gray-700">{info?.holdingName || "—"}</td>
|
||||
<td className="px-4 py-2 text-gray-700">{info?.position.security_name || "—"}</td>
|
||||
<td className="px-4 py-2 text-right text-gray-600">
|
||||
{info ? formatMoney(info.position.cost_cents) : "—"}
|
||||
</td>
|
||||
{canApprove && (
|
||||
<td className="px-4 py-2 text-right text-gray-600">
|
||||
{formatMoney(prior)}
|
||||
</td>
|
||||
)}
|
||||
<td className="px-4 py-2 text-right">
|
||||
{canEdit ? (
|
||||
<input
|
||||
type="number"
|
||||
step="0.01"
|
||||
value={editValues.get(v.position_id) || "0"}
|
||||
onChange={(e) => {
|
||||
const next = new Map(editValues);
|
||||
next.set(v.position_id, e.target.value);
|
||||
setEditValues(next);
|
||||
}}
|
||||
className="w-32 px-2 py-1 border border-gray-300 rounded text-right text-sm"
|
||||
/>
|
||||
) : (
|
||||
<span className="text-gray-900">{formatMoney(v.value_cents)}</span>
|
||||
)}
|
||||
</td>
|
||||
{canApprove && (
|
||||
<td className={`px-4 py-2 text-right font-medium ${delta >= 0 ? "text-green-600" : "text-red-600"}`}>
|
||||
{delta >= 0 ? "+" : "-"}{formatMoney(Math.abs(delta))}
|
||||
</td>
|
||||
)}
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
{selectedRound.valuations.length === 0 && (
|
||||
<tr>
|
||||
<td className="px-4 py-6 text-center text-gray-400" colSpan={6}>
|
||||
No positions in this round.
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{/* Return form for approvers */}
|
||||
{canReturn && (
|
||||
<div className="mt-4 p-4 bg-gray-50 border border-gray-200 rounded">
|
||||
<h3 className="text-sm font-medium text-gray-700 mb-2">Return with note</h3>
|
||||
<div className="flex gap-2">
|
||||
<input
|
||||
type="text"
|
||||
value={returnNote}
|
||||
onChange={(e) => setReturnNote(e.target.value)}
|
||||
className="flex-1 px-3 py-2 border border-gray-300 rounded text-sm"
|
||||
placeholder="Reason for returning..."
|
||||
/>
|
||||
<button
|
||||
onClick={handleReturn}
|
||||
disabled={!returnNote.trim()}
|
||||
className="px-4 py-2 bg-red-600 text-white text-sm rounded hover:bg-red-700 disabled:opacity-50"
|
||||
>
|
||||
Return
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex-1 flex items-center justify-center text-gray-400 text-sm">
|
||||
Select or create a round.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
"target": "es2023",
|
||||
"lib": ["ES2023", "DOM"],
|
||||
"module": "esnext",
|
||||
"types": ["vite/client"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.node.json" }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
"target": "es2023",
|
||||
"lib": ["ES2023"],
|
||||
"module": "esnext",
|
||||
"types": ["node"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { defineConfig } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react(), tailwindcss()],
|
||||
server: {
|
||||
proxy: {
|
||||
"/api": "http://localhost:8000",
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user