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
5 changes: 3 additions & 2 deletions app/platform/[projectId]/old-reports/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Link from "next/link";
import { useEffect, useState } from "react";
import { useParams, useRouter } from "next/navigation";
import { FileText, Loader2 } from "lucide-react";
import { ArrowLeft, FileText, Loader2 } from "lucide-react";
import { ProjectShell } from "@/components/project-shell";
import { startReport } from "@/components/report/start-report";
import { supabase } from "@/lib/supabase";
Expand Down Expand Up @@ -95,8 +95,9 @@ export default function ReportsPage() {
}

return <ProjectShell><div className="ops-page">
<Link href={`/platform/${projectId}/reports`} className="platform-btn mb-4"><ArrowLeft size={16} /> Back to report types</Link>
<p className="page-eyebrow">Client deliverables</p>
<h2 className="page-title mt-1">Reports</h2>
<h2 className="page-title mt-1">Technical Audit Report</h2>
<p className="page-description mt-2">Client-ready AI visibility, GEO and SEO audit reports. Each report combines this project&apos;s tracking data with a fresh audit of the brand&apos;s website and its top competitors. Reports are saved here, can be edited before sharing, and download as a PDF.</p>

{canGenerate && <section className="mt-8 platform-card p-6">
Expand Down
7 changes: 4 additions & 3 deletions app/platform/[projectId]/reports/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { useCallback, useEffect, useMemo, useRef, useState, type ChangeEvent } from "react";
import { useParams } from "next/navigation";
import { useParams, useRouter } from "next/navigation";
import { Download, ExternalLink, Loader2, Plus, Printer, RefreshCw, Save, Sparkles, ChevronDown, Trash2, X } from "lucide-react";
import { ProjectShell } from "@/components/project-shell";
import { supabase } from "@/lib/supabase";
Expand All @@ -28,7 +28,7 @@ const TYPES: { id: ReportType; name: string; description: string; ready: boolean
{ id: "monthly", name: "Monthly Report", description: "AI visibility progress, citations, competitor benchmarking and next-month plans.", ready: true },
{ id: "simple", name: "Simple Report", description: "A concise client-facing performance summary.", ready: false },
{ id: "introductory", name: "Introductory Report", description: "An introduction to the brand's AI visibility baseline.", ready: false },
{ id: "technical_audit", name: "Technical Audit Report", description: "Technical SEO, GEO and website audit findings.", ready: false },
{ id: "technical_audit", name: "Technical Audit Report", description: "Technical SEO, GEO and website audit findings.", ready: true },
{ id: "competitor_comparison", name: "Competitor Comparison Report", description: "A focused comparison against selected competitors.", ready: false },
];
const AREAS = ["Website Content and Structure", "Knowledge Assets and Resources", "Branding and Authority", "Community Engagement", "Monitoring and Research"];
Expand Down Expand Up @@ -73,6 +73,7 @@ function Field({ label, value, onChange, placeholder = "Enter information", mult
}
export default function ReportsPage() {
const { projectId } = useParams<{ projectId: string }>();
const router = useRouter();
const [reportType, setReportType] = useState<ReportType>("monthly");
const [selectedMonth, setSelectedMonth] = useState(defaultReportMonth());
const { start, end } = monthDates(selectedMonth);
Expand Down Expand Up @@ -473,7 +474,7 @@ export default function ReportsPage() {
<section className="mt-6 flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-[var(--line)] bg-[var(--card)] p-4 sm:p-5"><div><h2 className="font-bold">Monthly report PowerPoint template</h2><p className="mt-1 text-xs text-[var(--muted-foreground)]">Canonical 10-slide template stored in platform storage.</p>{templateNotice && <p className="mt-2 text-xs text-amber-700">{templateNotice}</p>}</div><div className="flex flex-wrap items-center gap-2">{canManageTemplate && <><input ref={templateInputRef} type="file" accept=".pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation" className="hidden" onChange={uploadTemplate}/><button type="button" className="platform-btn" disabled={uploadingTemplate} onClick={()=>templateInputRef.current?.click()}>{uploadingTemplate?<Loader2 size={14} className="animate-spin"/>:<RefreshCw size={14}/>} Update template</button></>}{templateExists ? <a className="platform-btn platform-btn-primary" href={templateDownloadUrl} download="Client_Monthly_Report_Template.pptx"><Download size={14}/> Download template</a> : <button type="button" className="platform-btn platform-btn-primary" disabled title="The monthly report template is not available in platform storage"><Download size={14}/> Download template</button>}</div></section>
<section className="mt-6 rounded-2xl border border-[var(--line)] bg-[var(--card)] p-4 sm:p-5">
<div className="flex flex-wrap items-center justify-between gap-3"><h2 className="text-base font-bold">Report type</h2><span className="text-xs text-[var(--muted-foreground)]">5 report formats</span></div>
<div className="mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-5">{TYPES.map(t=><button key={t.id} onClick={()=>{setReportType(t.id);setSnapshot(null);setActiveId(null);setError("");setNotice("");}} className={"rounded-xl border p-3 text-left transition "+(reportType===t.id?"border-[var(--primary)] bg-[var(--accent)] ring-1 ring-[var(--primary)]":"border-[var(--line)] hover:bg-[var(--accent)]")}><div className="flex items-center justify-between gap-2"><b className="text-sm">{t.name}</b>{t.ready?<span className="monthly-ready">Available</span>:<span className="monthly-soon">Coming soon</span>}</div><p className="mt-2 text-xs leading-5 text-[var(--muted-foreground)]">{t.description}</p></button>)}</div>
<div className="mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-5">{TYPES.map(t=><button key={t.id} onClick={()=>{if(t.id==="technical_audit"){router.push(`/platform/${projectId}/old-reports`);return;}setReportType(t.id);setSnapshot(null);setActiveId(null);setError("");setNotice("");}} className={"rounded-xl border p-3 text-left transition "+(reportType===t.id?"border-[var(--primary)] bg-[var(--accent)] ring-1 ring-[var(--primary)]":"border-[var(--line)] hover:bg-[var(--accent)]")}><div className="flex items-center justify-between gap-2"><b className="text-sm">{t.name}</b>{t.ready?<span className="monthly-ready">Available</span>:<span className="monthly-soon">Coming soon</span>}</div><p className="mt-2 text-xs leading-5 text-[var(--muted-foreground)]">{t.description}</p></button>)}</div>
{reportType==="monthly"?<div className="mt-5 flex flex-wrap items-end gap-3 border-t border-[var(--line)] pt-4"><label className="block"><span className="mb-1.5 block text-xs font-semibold text-[var(--muted-foreground)]">Reporting month</span><input className="platform-input text-sm" type="month" min={MIN_TRACKING_DATE.slice(0, 7)} max={malaysiaDateString().slice(0, 7)} value={selectedMonth} onChange={e=>setSelectedMonth(e.target.value)} /></label><p className="pb-2 text-xs text-[var(--muted-foreground)]">{start && end ? "Reporting period: " + start + " to " + end : "Select a valid reporting month."}</p><button className="platform-btn platform-btn-primary ml-auto" disabled={loading || !start || !end} onClick={generate}>{loading?<Loader2 size={15} className="animate-spin"/>:<Sparkles size={15}/>} Generate monthly report</button></div>:<div className="mt-5 rounded-xl border border-dashed border-[var(--line)] p-5 text-center text-sm text-[var(--muted-foreground)]">This report format is planned for a future development stage.</div>}
</section>
{error&&<div className="sample-error mt-4 rounded-xl p-3 text-sm">{error}</div>}{notice&&<div className="platform-notice-success mt-4 rounded-xl p-3 text-sm">{notice}</div>}
Expand Down
1 change: 1 addition & 0 deletions components/language-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,7 @@ Object.assign(zh, {
"Generating the report": "正在生成报告",
"This usually takes one to two minutes. You can leave this page and come back.": "通常需要一到两分钟。您可以离开此页面,稍后再回来查看。",
"Back to reports": "返回报告列表",
"Back to report types": "返回报告类型",
"Download PDF": "下载 PDF",
"The report could not be generated": "无法生成报告",
"Retry": "重试",
Expand Down
4 changes: 3 additions & 1 deletion components/project-shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ export function ProjectShell({ children }: { children: React.ReactNode }) {
<nav className="mx-auto flex w-full max-w-[1500px] justify-start gap-1 overflow-x-auto px-2 py-1.5 sm:justify-center sm:px-5 lg:px-8" aria-label="Project navigation">
{nav.map(([label, segment, Icon]) => {
const href = `/platform/${projectId}${segment}`;
const active = pathname === href || (segment !== "" && pathname.startsWith(`${href}/`));
const active = pathname === href || (segment !== "" && pathname.startsWith(`${href}/`))
// The technical audit report pages sit under Reports.
|| (segment === "/reports" && pathname.startsWith(`/platform/${projectId}/old-reports`));
return <Link
key={segment || "dashboard"}
href={href}
Expand Down
Loading