Skip to content
Open
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
33 changes: 28 additions & 5 deletions app/(builder)/builder/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type GrantSummary = {
amount: bigint;
deadline: bigint;
proofType: number;
state: number;
}>;
};

Expand Down Expand Up @@ -143,8 +144,15 @@ export default function BuilderDashboardPage() {
let pending = 0;
for (const { grant } of dashboardGrantRows) {
for (const milestone of grant.milestones) {
escrow += milestone.amount;
pending += 1;
const state = milestone.state ?? 0;
const isApproved = state === 2 || state === 5;
if (!isApproved) {
escrow += milestone.amount;
}
const requiresAction = state === 0 || state === 3;
if (requiresAction) {
pending += 1;
}
}
}
return {
Expand Down Expand Up @@ -247,7 +255,10 @@ export default function BuilderDashboardPage() {
const grantKey = grant.id.toString();
const expanded = Boolean(expandedGrantKeys[grantKey]);
const totalGrantAmount = grant.milestones.reduce((sum, m) => sum + m.amount, BigInt(0));
const completed = grant.milestones.length > 0 ? 1 : 0; // Simplified for now
const completed = grant.milestones.filter(m => {
const state = m.state ?? 0;
return state === 2 || state === 5;
}).length;
const progressPct = grant.milestones.length > 0 ? Math.round((completed / grant.milestones.length) * 100) : 0;

return (
Expand Down Expand Up @@ -279,7 +290,19 @@ export default function BuilderDashboardPage() {
<tbody>
{grant.milestones.map((m, idx) => {
const submission = backendSubmissions[`${grant.id}-${idx}`];
const status = submission ? submission.status : 'Pending';
const state = m.state ?? 0;
let status: 'Pending' | 'Submitted' | 'Approved' | 'Rejected' | 'Slashed' = 'Pending';
if (state === 1) status = 'Submitted';
else if (state === 2 || state === 5) status = 'Approved';
else if (state === 3) status = 'Rejected';
else if (state === 4) status = 'Slashed';
else if (submission) {
const dbStatus = submission.status?.toLowerCase();
if (dbStatus === 'approved') status = 'Approved';
else if (dbStatus === 'submitted') status = 'Submitted';
else if (dbStatus === 'rejected') status = 'Rejected';
}

const overdue = Number(m.deadline) > 0 && Date.now() > Number(m.deadline) * 1000;
const submitHref = `/grants/${pathSegment}/milestones/${idx}/submit`;

Expand All @@ -295,7 +318,7 @@ export default function BuilderDashboardPage() {
</span>
</td>
<td className="px-4 py-3">
{status === 'Pending' ? (
{status === 'Pending' || status === 'Rejected' ? (
m.proofType === 0 ? (
<Link href={submitHref} className="inline-flex items-center gap-1 rounded-lg bg-violet-600 px-3 py-2 text-xs font-semibold text-white hover:bg-violet-700">
Generate Proof
Expand Down
47 changes: 47 additions & 0 deletions app/(builder)/builders/[address]/page-old.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import OnboardingShell from '@/app/(onboarding)/OnboardingShell';
import BuilderProfileContent from '@/components/builders/BuilderProfileContent';
import { getDaoDashboardSnapshot } from '@/demo/dao-dashboard';
import { formatBuilderPageTitle, loadBuilderProfile } from '@/lib/builder-profile-server';
import { getAddress, isAddress, type Address } from 'viem';
import type { Metadata } from 'next';

export const dynamicParams = true;

export function generateStaticParams(): { address: string }[] {
const snap = getDaoDashboardSnapshot(0);
const builders = [...new Set(snap.grants.map((g) => g.builder))];
return builders.map((address) => ({ address: address.toLowerCase() }));
}

export async function generateMetadata({
params,
}: {
params: Promise<{ address: string }>;
}): Promise<Metadata> {
const { address: raw } = await params;
const trimmed = decodeURIComponent(raw ?? '').trim();
if (!trimmed || !isAddress(trimmed)) {
return { title: 'Builder — GrantOS v3' };
}
try {
const address = getAddress(trimmed) as Address;
return { title: formatBuilderPageTitle(address) };
} catch {
return { title: 'Builder — GrantOS v3' };
}
}

export default async function BuilderProfilePage({
params,
}: {
params: Promise<{ address: string }>;
}) {
const { address: raw } = await params;
const data = await loadBuilderProfile(raw ?? '');

return (
<OnboardingShell>
<BuilderProfileContent data={data} />
</OnboardingShell>
);
}
Loading