Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apps/backend/lambdas/auth/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ WORKDIR /shared/types
COPY shared/types/package.json ./
COPY shared/types/ ./

# Before lambda-auth: it resolves @branch/rbac as file:../rbac and needs its dist.
WORKDIR /shared/rbac
COPY shared/rbac/package.json shared/rbac/tsconfig.json ./
COPY shared/rbac/src ./src/
RUN npm install && npm run build

WORKDIR /shared/lambda-auth
COPY shared/lambda-auth/package.json shared/lambda-auth/tsconfig.json ./
COPY shared/lambda-auth/src ./src/
Expand All @@ -17,6 +23,11 @@ COPY shared/lambda-http/package.json shared/lambda-http/tsconfig.json ./
COPY shared/lambda-http/src ./src/
RUN npm install && npm run build

WORKDIR /shared/store
COPY shared/store/package.json shared/store/tsconfig.json ./
COPY shared/store/src ./src/
RUN npm install && npm run build

WORKDIR /app

# Copy package files
Expand Down
11 changes: 11 additions & 0 deletions apps/backend/lambdas/donors/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ WORKDIR /shared/types
COPY shared/types/package.json ./
COPY shared/types/ ./

# Before lambda-auth: it resolves @branch/rbac as file:../rbac and needs its dist.
WORKDIR /shared/rbac
COPY shared/rbac/package.json shared/rbac/tsconfig.json ./
COPY shared/rbac/src ./src/
RUN npm install && npm run build

WORKDIR /shared/lambda-auth
COPY shared/lambda-auth/package.json shared/lambda-auth/tsconfig.json ./
COPY shared/lambda-auth/src ./src/
Expand All @@ -15,6 +21,11 @@ COPY shared/lambda-http/package.json shared/lambda-http/tsconfig.json ./
COPY shared/lambda-http/src ./src/
RUN npm install && npm run build

WORKDIR /shared/store
COPY shared/store/package.json shared/store/tsconfig.json ./
COPY shared/store/src ./src/
RUN npm install && npm run build

WORKDIR /app
COPY apps/backend/lambdas/donors/package*.json ./
RUN npm install --no-package-lock
Expand Down
11 changes: 11 additions & 0 deletions apps/backend/lambdas/expenditures/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ WORKDIR /shared/types
COPY shared/types/package.json ./
COPY shared/types/ ./

# Before lambda-auth: it resolves @branch/rbac as file:../rbac and needs its dist.
WORKDIR /shared/rbac
COPY shared/rbac/package.json shared/rbac/tsconfig.json ./
COPY shared/rbac/src ./src/
RUN npm install && npm run build

WORKDIR /shared/lambda-auth
COPY shared/lambda-auth/package.json shared/lambda-auth/tsconfig.json ./
COPY shared/lambda-auth/src ./src/
Expand All @@ -15,6 +21,11 @@ COPY shared/lambda-http/package.json shared/lambda-http/tsconfig.json ./
COPY shared/lambda-http/src ./src/
RUN npm install && npm run build

WORKDIR /shared/store
COPY shared/store/package.json shared/store/tsconfig.json ./
COPY shared/store/src ./src/
RUN npm install && npm run build

WORKDIR /app
COPY apps/backend/lambdas/expenditures/package*.json ./
RUN npm install --no-package-lock
Expand Down
11 changes: 11 additions & 0 deletions apps/backend/lambdas/projects/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ WORKDIR /shared/types
COPY shared/types/package.json ./
COPY shared/types/ ./

# Before lambda-auth: it resolves @branch/rbac as file:../rbac and needs its dist.
WORKDIR /shared/rbac
COPY shared/rbac/package.json shared/rbac/tsconfig.json ./
COPY shared/rbac/src ./src/
RUN npm install && npm run build

WORKDIR /shared/lambda-auth
COPY shared/lambda-auth/package.json shared/lambda-auth/tsconfig.json ./
COPY shared/lambda-auth/src ./src/
Expand All @@ -15,6 +21,11 @@ COPY shared/lambda-http/package.json shared/lambda-http/tsconfig.json ./
COPY shared/lambda-http/src ./src/
RUN npm install && npm run build

WORKDIR /shared/store
COPY shared/store/package.json shared/store/tsconfig.json ./
COPY shared/store/src ./src/
RUN npm install && npm run build

WORKDIR /app
COPY apps/backend/lambdas/projects/package*.json ./
RUN npm install --no-package-lock
Expand Down
11 changes: 11 additions & 0 deletions apps/backend/lambdas/reports/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ WORKDIR /shared/types
COPY shared/types/package.json ./
COPY shared/types/ ./

# Before lambda-auth: it resolves @branch/rbac as file:../rbac and needs its dist.
WORKDIR /shared/rbac
COPY shared/rbac/package.json shared/rbac/tsconfig.json ./
COPY shared/rbac/src ./src/
RUN npm install && npm run build

WORKDIR /shared/lambda-auth
COPY shared/lambda-auth/package.json shared/lambda-auth/tsconfig.json ./
COPY shared/lambda-auth/src ./src/
Expand All @@ -15,6 +21,11 @@ COPY shared/lambda-http/package.json shared/lambda-http/tsconfig.json ./
COPY shared/lambda-http/src ./src/
RUN npm install && npm run build

WORKDIR /shared/store
COPY shared/store/package.json shared/store/tsconfig.json ./
COPY shared/store/src ./src/
RUN npm install && npm run build

WORKDIR /app
COPY apps/backend/lambdas/reports/package*.json ./
RUN npm install --no-package-lock
Expand Down
11 changes: 11 additions & 0 deletions apps/backend/lambdas/users/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ WORKDIR /shared/types
COPY shared/types/package.json ./
COPY shared/types/ ./

# Before lambda-auth: it resolves @branch/rbac as file:../rbac and needs its dist.
WORKDIR /shared/rbac
COPY shared/rbac/package.json shared/rbac/tsconfig.json ./
COPY shared/rbac/src ./src/
RUN npm install && npm run build

WORKDIR /shared/lambda-auth
COPY shared/lambda-auth/package.json shared/lambda-auth/tsconfig.json ./
COPY shared/lambda-auth/src ./src/
Expand All @@ -15,6 +21,11 @@ COPY shared/lambda-http/package.json shared/lambda-http/tsconfig.json ./
COPY shared/lambda-http/src ./src/
RUN npm install && npm run build

WORKDIR /shared/store
COPY shared/store/package.json shared/store/tsconfig.json ./
COPY shared/store/src ./src/
RUN npm install && npm run build

WORKDIR /app
COPY apps/backend/lambdas/users/package*.json ./
RUN npm install --no-package-lock
Expand Down
4 changes: 3 additions & 1 deletion apps/frontend/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ Import direction is one-way and must stay that way: `api.ts` ← `authClient.ts`

**Refresh.** Access tokens last one hour. `AuthProvider` schedules a refresh ~2 minutes before expiry, and `authedFetch` refreshes reactively on a 401. Refresh is single-flight, so a burst of concurrent 401s produces one `POST /auth/refresh`. Cognito does not re-issue a refresh token, so `saveTokens` leaves the stored one alone when the response omits it.

**Guarding.** `src/app/components/AuthGate.tsx`, mounted once in `providers.tsx`, is the app's only route guard — static export means `middleware.ts` would never run. `src/lib/routes.ts` classifies routes and is **protected-by-default**: a new page under `src/app/` is guarded without opting in. Public routes are `/login`, `/forgot-password`, `/reset-password` (authenticated users get bounced off them). Which permission a page needs comes from `PAGE_PERMISSIONS` in `@branch/rbac`, so AuthGate, the Navbar and the lambdas all read one table. Always compare paths through `normalizePath` — `trailingSlash: true` means production sees `/login/` where dev and tests see `/login`.
**Guarding.** `src/app/components/AuthGate.tsx`, mounted once in `providers.tsx`, is the app's only route guard — static export means `middleware.ts` would never run. `src/lib/routes.ts` classifies routes and is **protected-by-default**: a new page under `src/app/` is guarded without opting in. Public routes are `/login`, `/forgot-password`, `/reset-password` (authenticated users get bounced off them). Open routes (`/help/**`) render for everyone, signed in or not, and skip the Chakra/Auth shell in `providers.tsx`: they are prerendered with real content, and Chakra's Emotion styles inline into SSR HTML and break hydration.

**Help pages.** `/help` is the user guide, served at `branchaccounting.org/help`. Guides are data in `src/app/help/guides.ts` (numbered one-line steps; `[label](/path)` makes a link) and `[slug]/page.tsx` prerenders one page per guide via `generateStaticParams`. Screenshots live in `public/help/<guide>/`; `test/app/HelpGuides.test.ts` fails on a missing image or a link to a page that does not exist. Retake screenshots against a local stack with seeded demo data, never production. Which permission a page needs comes from `PAGE_PERMISSIONS` in `@branch/rbac`, so AuthGate, the Navbar and the lambdas all read one table. Always compare paths through `normalizePath` — `trailingSlash: true` means production sees `/login/` where dev and tests see `/login`.

## Permissions

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/frontend/public/help/donors/form-add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/frontend/public/help/profile/edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/frontend/public/help/sign-in/login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions apps/frontend/src/app/components/AuthGate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export default function AuthGate({ children }: { children: React.ReactNode }) {
}
}, [isLoading, isAuthenticated, subject, access, pathname, router]);

if (access === 'open') return <>{children}</>;

if (isLoading) return <FullPageSpinner />;

// Render suppression — the redirect above is asynchronous, and without these
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/src/app/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const NAV_ITEMS: NavItem[] = [
{ label: "Reports", href: "/reports" },
{ label: "Accounts", href: "/accounts" },
{ label: "Profile", href: "/profile" },
{ label: "Help", href: "/help" },
{ label: "Log Out", action: "logout" },
];

Expand Down
18 changes: 18 additions & 0 deletions apps/frontend/src/app/help/AdminTag.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default function AdminTag() {
return (
<span
style={{
marginLeft: 10,
padding: '2px 8px',
borderRadius: 999,
backgroundColor: '#EAEFEB',
color: '#2D6138',
fontSize: 13,
fontWeight: 600,
verticalAlign: 'middle',
}}
>
Admins
</span>
);
}
87 changes: 87 additions & 0 deletions apps/frontend/src/app/help/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import Image from 'next/image';
import Link from 'next/link';
import { notFound } from 'next/navigation';
import { assetPath } from '@/lib/asset';
import { GUIDES, guideBySlug } from '../guides';
import AdminTag from '../AdminTag';

export function generateStaticParams() {
return GUIDES.map((g) => ({ slug: g.slug }));
}

export const dynamicParams = false;

function withLinks(text: string) {
return text.split(/(\[[^\]]+\]\([^)]+\))/).map((part, i) => {
const m = /^\[([^\]]+)\]\(([^)]+)\)$/.exec(part);
if (!m) return part;
return (
<Link key={i} href={m[2]} style={{ color: '#2D6138', fontWeight: 700, textDecoration: 'underline' }}>
{m[1]}
</Link>
);
});
}

export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }) {
const guide = guideBySlug((await params).slug);
return { title: guide ? `${guide.title} | BRANCH Help` : 'BRANCH Help' };
}

export default async function GuidePage({ params }: { params: Promise<{ slug: string }> }) {
const guide = guideBySlug((await params).slug);
if (!guide) notFound();

return (
<article>
<Link href="/help" style={{ color: '#2D6138', fontSize: 15 }}>
← All guides
</Link>
<h1 style={{ fontSize: 32, fontWeight: 700, margin: '12px 0 24px' }}>
{guide.title}
{guide.adminOnly && <AdminTag />}
</h1>
<ol style={{ listStyle: 'decimal', paddingLeft: 24, margin: 0, display: 'grid', gap: 28 }}>
{guide.steps.map((step) => (
<li key={step.text} style={{ fontSize: 18, lineHeight: 1.5 }}>
<p style={{ margin: 0 }}>{withLinks(step.text)}</p>
{step.image && (
<Image
src={assetPath(step.image)}
alt={step.alt ?? ''}
width={1440}
height={904}
style={{
width: '100%',
height: 'auto',
marginTop: 12,
borderRadius: 8,
border: '1px solid #e5e7eb',
}}
/>
)}
</li>
))}
</ol>
{guide.notes && (
<aside
style={{
marginTop: 32,
padding: '16px 20px',
backgroundColor: '#EAEFEB',
borderRadius: 8,
fontSize: 16,
lineHeight: 1.5,
}}
>
<h2 style={{ fontSize: 16, fontWeight: 700, color: '#2D6138', margin: '0 0 8px' }}>Good to know</h2>
<ul style={{ listStyle: 'disc', paddingLeft: 20, margin: 0, display: 'grid', gap: 4 }}>
{guide.notes.map((note) => (
<li key={note}>{note}</li>
))}
</ul>
</aside>
)}
</article>
);
}
Loading
Loading