feat: in-app support form with email + Gitea issue integration (v0.49.0)
Users can now report bugs, suggestions, or questions from a new /support page. Each submission sends a confirmation email and, when GITEA_URL/ GITEA_TOKEN/GITEA_REPO are configured in admin Settings, opens a labeled issue on that repo automatically (best-effort — failure doesn't block the ticket). Admins get a Support section to triage status and retry failed Gitea issue creation. New support_tickets table, gitea.ts client, site-settings entries for the three new secrets, and OpenAPI docs for the two user-facing endpoints. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -57,6 +57,11 @@ SMTP_FROM=Epicure <noreply@epicure.app>
|
||||
NEXT_PUBLIC_VAPID_PUBLIC_KEY=
|
||||
VAPID_PRIVATE_KEY=
|
||||
|
||||
# Gitea (optional — in-app support tickets open an issue here if all three are set)
|
||||
GITEA_URL=
|
||||
GITEA_TOKEN=
|
||||
GITEA_REPO=owner/repo
|
||||
|
||||
# Stripe (optional — webhook stub only)
|
||||
STRIPE_WEBHOOK_SECRET=
|
||||
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
All notable changes to Epicure are documented here. This file is mirrored in-app at `/changelog` (and in the admin dashboard) via `apps/web/lib/changelog.ts` — update both together.
|
||||
|
||||
## 0.49.0 — 2026-07-18 12:30
|
||||
|
||||
### Added
|
||||
- New Support page — report a bug, share a suggestion, or ask a question right from the app. Submissions email you a confirmation and (if an admin has configured a Gitea repo in Settings) automatically open a tracked issue. Admins get a Support section in the admin panel to triage tickets and retry issue creation.
|
||||
|
||||
## 0.48.2 — 2026-07-18 11:15
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import type { Metadata } from "next";
|
||||
import { headers } from "next/headers";
|
||||
import { auth } from "@/lib/auth/server";
|
||||
import { db, supportTickets, eq, desc } from "@epicure/db";
|
||||
import { SupportManager } from "@/components/support/support-manager";
|
||||
import { getMessages } from "@/lib/i18n/server";
|
||||
|
||||
export const metadata: Metadata = {};
|
||||
|
||||
export default async function SupportPage() {
|
||||
const session = await auth.api.getSession({ headers: await headers() });
|
||||
if (!session) return null;
|
||||
const m = getMessages((session.user as { locale?: string }).locale);
|
||||
|
||||
const rows = await db
|
||||
.select()
|
||||
.from(supportTickets)
|
||||
.where(eq(supportTickets.userId, session.user.id))
|
||||
.orderBy(desc(supportTickets.createdAt));
|
||||
|
||||
return (
|
||||
<div className="space-y-8 max-w-3xl">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold tracking-tight">{m.support.title}</h1>
|
||||
<p className="text-muted-foreground text-sm mt-1">{m.support.subtitle}</p>
|
||||
</div>
|
||||
<SupportManager
|
||||
initialTickets={rows.map((r) => ({
|
||||
id: r.id,
|
||||
type: r.type,
|
||||
title: r.title,
|
||||
description: r.description,
|
||||
status: r.status,
|
||||
giteaIssueUrl: r.giteaIssueUrl,
|
||||
createdAt: r.createdAt.toISOString(),
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { headers } from "next/headers";
|
||||
import { auth } from "@/lib/auth/server";
|
||||
import { db, users, eq } from "@epicure/db";
|
||||
import Link from "next/link";
|
||||
import { Shield, Users, BookOpen, Settings, BarChart3, ClipboardList, HardDrive, Bot, ArrowLeft, Gauge, Mail, Flag, History } from "lucide-react";
|
||||
import { Shield, Users, BookOpen, Settings, BarChart3, ClipboardList, HardDrive, Bot, ArrowLeft, Gauge, Mail, Flag, History, LifeBuoy } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const adminNav = [
|
||||
@@ -12,6 +12,7 @@ const adminNav = [
|
||||
{ href: "/admin/invites", label: "Invites", icon: Mail },
|
||||
{ href: "/admin/recipes", label: "Recipes", icon: BookOpen },
|
||||
{ href: "/admin/reports", label: "Reports", icon: Flag },
|
||||
{ href: "/admin/support", label: "Support", icon: LifeBuoy },
|
||||
{ href: "/admin/tiers", label: "Tier Limits", icon: Gauge },
|
||||
{ href: "/admin/audit-logs", label: "Audit Logs", icon: ClipboardList },
|
||||
{ href: "/admin/storage", label: "Storage", icon: HardDrive },
|
||||
|
||||
@@ -11,6 +11,11 @@ const SETTING_GROUPS = [
|
||||
description: "Keys for web push notifications. Generate with: npx web-push generate-vapid-keys",
|
||||
keys: ["NEXT_PUBLIC_VAPID_PUBLIC_KEY", "VAPID_PRIVATE_KEY"] as const,
|
||||
},
|
||||
{
|
||||
title: "Gitea Integration",
|
||||
description: "Support tickets submitted in-app automatically open an issue on this Gitea repo. Token needs issue read/write scope on the target repo.",
|
||||
keys: ["GITEA_URL", "GITEA_TOKEN", "GITEA_REPO"] as const,
|
||||
},
|
||||
];
|
||||
|
||||
export default async function AdminSettingsPage() {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import type { Metadata } from "next";
|
||||
import { db, users, supportTickets, eq, desc } from "@epicure/db";
|
||||
import { AdminSupportManager } from "@/components/admin/admin-support-manager";
|
||||
|
||||
export const metadata: Metadata = {};
|
||||
|
||||
export default async function AdminSupportPage() {
|
||||
const rows = await db
|
||||
.select({
|
||||
id: supportTickets.id,
|
||||
userEmail: users.email,
|
||||
username: users.username,
|
||||
type: supportTickets.type,
|
||||
title: supportTickets.title,
|
||||
description: supportTickets.description,
|
||||
status: supportTickets.status,
|
||||
giteaIssueUrl: supportTickets.giteaIssueUrl,
|
||||
giteaError: supportTickets.giteaError,
|
||||
createdAt: supportTickets.createdAt,
|
||||
})
|
||||
.from(supportTickets)
|
||||
.innerJoin(users, eq(supportTickets.userId, users.id))
|
||||
.orderBy(desc(supportTickets.createdAt));
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold tracking-tight">Support Tickets</h1>
|
||||
<p className="text-muted-foreground text-sm mt-1">
|
||||
Bug reports, suggestions, and questions submitted through the app.
|
||||
</p>
|
||||
</div>
|
||||
<AdminSupportManager
|
||||
initialTickets={rows.map((r) => ({ ...r, createdAt: r.createdAt.toISOString() }))}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -20,6 +20,9 @@ const ALLOWED_KEYS: SiteSettingKey[] = [
|
||||
"DEFAULT_VISION_MODEL",
|
||||
"DEFAULT_MEAL_PLAN_PROVIDER",
|
||||
"DEFAULT_MEAL_PLAN_MODEL",
|
||||
"GITEA_URL",
|
||||
"GITEA_TOKEN",
|
||||
"GITEA_REPO",
|
||||
];
|
||||
|
||||
async function requireAdmin() {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { z } from "zod";
|
||||
import { db, supportTickets, eq } from "@epicure/db";
|
||||
import { requireAdmin } from "@/lib/api-auth";
|
||||
import { createGiteaIssue } from "@/lib/gitea";
|
||||
|
||||
const UpdateTicketBody = z.object({
|
||||
status: z.enum(["open", "triaged", "closed"]).optional(),
|
||||
retryGitea: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export async function PATCH(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
|
||||
const { response } = await requireAdmin();
|
||||
if (response) return response;
|
||||
|
||||
const { id } = await params;
|
||||
const body = (await req.json()) as unknown;
|
||||
const parsed = UpdateTicketBody.safeParse(body);
|
||||
if (!parsed.success) {
|
||||
return NextResponse.json({ error: "Validation error", issues: parsed.error.issues }, { status: 400 });
|
||||
}
|
||||
|
||||
const [ticket] = await db.select().from(supportTickets).where(eq(supportTickets.id, id));
|
||||
if (!ticket) return NextResponse.json({ error: "Not found" }, { status: 404 });
|
||||
|
||||
const updates: Partial<typeof ticket> = { updatedAt: new Date() };
|
||||
|
||||
if (parsed.data.status) {
|
||||
updates.status = parsed.data.status;
|
||||
}
|
||||
|
||||
if (parsed.data.retryGitea) {
|
||||
const { url, error } = await createGiteaIssue({
|
||||
type: ticket.type,
|
||||
title: ticket.title,
|
||||
body: `${ticket.description}\n\n---\nReported via Epicure support form by user \`${ticket.userId}\`.`,
|
||||
});
|
||||
updates.giteaIssueUrl = url;
|
||||
updates.giteaError = error;
|
||||
}
|
||||
|
||||
await db.update(supportTickets).set(updates).where(eq(supportTickets.id, id));
|
||||
|
||||
return NextResponse.json({ ok: true });
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { db, users, supportTickets, eq, desc } from "@epicure/db";
|
||||
import { requireAdmin } from "@/lib/api-auth";
|
||||
|
||||
export async function GET() {
|
||||
const { response } = await requireAdmin();
|
||||
if (response) return response;
|
||||
|
||||
const rows = await db
|
||||
.select({
|
||||
id: supportTickets.id,
|
||||
userId: supportTickets.userId,
|
||||
userEmail: users.email,
|
||||
username: users.username,
|
||||
type: supportTickets.type,
|
||||
title: supportTickets.title,
|
||||
description: supportTickets.description,
|
||||
status: supportTickets.status,
|
||||
giteaIssueUrl: supportTickets.giteaIssueUrl,
|
||||
giteaError: supportTickets.giteaError,
|
||||
createdAt: supportTickets.createdAt,
|
||||
updatedAt: supportTickets.updatedAt,
|
||||
})
|
||||
.from(supportTickets)
|
||||
.innerJoin(users, eq(supportTickets.userId, users.id))
|
||||
.orderBy(desc(supportTickets.createdAt));
|
||||
|
||||
return NextResponse.json(rows);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import crypto from "node:crypto";
|
||||
import { z } from "zod";
|
||||
import { db, supportTickets, eq, desc } from "@epicure/db";
|
||||
import { requireSession } from "@/lib/api-auth";
|
||||
import { sendEmail, supportTicketReceivedHtml } from "@/lib/email";
|
||||
import { createGiteaIssue } from "@/lib/gitea";
|
||||
|
||||
const CreateTicketBody = z.object({
|
||||
type: z.enum(["bug", "suggestion", "question"]),
|
||||
title: z.string().trim().min(3).max(200),
|
||||
description: z.string().trim().min(10).max(5000),
|
||||
});
|
||||
|
||||
export async function GET() {
|
||||
const { session, response } = await requireSession();
|
||||
if (response) return response;
|
||||
|
||||
const rows = await db
|
||||
.select()
|
||||
.from(supportTickets)
|
||||
.where(eq(supportTickets.userId, session!.user.id))
|
||||
.orderBy(desc(supportTickets.createdAt));
|
||||
|
||||
return NextResponse.json(rows);
|
||||
}
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
const { session, response } = await requireSession();
|
||||
if (response) return response;
|
||||
|
||||
const body = (await req.json()) as unknown;
|
||||
const parsed = CreateTicketBody.safeParse(body);
|
||||
if (!parsed.success) {
|
||||
return NextResponse.json(
|
||||
{ error: "Validation error", issues: parsed.error.issues },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
const { type, title, description } = parsed.data;
|
||||
const id = crypto.randomUUID();
|
||||
const now = new Date();
|
||||
|
||||
const { url: giteaIssueUrl, error: giteaError } = await createGiteaIssue({
|
||||
type,
|
||||
title,
|
||||
body: `${description}\n\n---\nReported via Epicure support form by user \`${session!.user.id}\`.`,
|
||||
});
|
||||
|
||||
await db.insert(supportTickets).values({
|
||||
id,
|
||||
userId: session!.user.id,
|
||||
type,
|
||||
title,
|
||||
description,
|
||||
status: "open",
|
||||
giteaIssueUrl,
|
||||
giteaError,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
});
|
||||
|
||||
const baseUrl = process.env["BETTER_AUTH_URL"] ?? "http://localhost:3000";
|
||||
const ticketUrl = `${baseUrl}/support`;
|
||||
if (session!.user.email) {
|
||||
try {
|
||||
await sendEmail({
|
||||
to: session!.user.email,
|
||||
subject: "We got your message — Epicure",
|
||||
html: supportTicketReceivedHtml({ type, title, ticketUrl, giteaIssueUrl }),
|
||||
});
|
||||
} catch {
|
||||
// Ticket is saved either way — email failure shouldn't fail the request.
|
||||
}
|
||||
}
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
id,
|
||||
userId: session!.user.id,
|
||||
type,
|
||||
title,
|
||||
description,
|
||||
status: "open" as const,
|
||||
giteaIssueUrl,
|
||||
giteaError,
|
||||
createdAt: now.toISOString(),
|
||||
updatedAt: now.toISOString(),
|
||||
},
|
||||
{ status: 201 }
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { toast } from "sonner";
|
||||
import { ExternalLink } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
|
||||
type TicketStatus = "open" | "triaged" | "closed";
|
||||
|
||||
type Ticket = {
|
||||
id: string;
|
||||
userEmail: string;
|
||||
username: string | null;
|
||||
type: string;
|
||||
title: string;
|
||||
description: string;
|
||||
status: TicketStatus;
|
||||
giteaIssueUrl: string | null;
|
||||
giteaError: string | null;
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
function formatDateTime(iso: string) {
|
||||
return new Date(iso).toLocaleString(undefined, {
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
});
|
||||
}
|
||||
|
||||
const statusVariant: Record<TicketStatus, "default" | "secondary" | "outline"> = {
|
||||
open: "default",
|
||||
triaged: "secondary",
|
||||
closed: "outline",
|
||||
};
|
||||
|
||||
export function AdminSupportManager({ initialTickets }: { initialTickets: Ticket[] }) {
|
||||
const [tickets, setTickets] = useState<Ticket[]>(initialTickets);
|
||||
const [retrying, setRetrying] = useState<string | null>(null);
|
||||
|
||||
async function handleStatusChange(id: string, status: TicketStatus) {
|
||||
try {
|
||||
const res = await fetch(`/api/v1/admin/support/${id}`, {
|
||||
method: "PATCH",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ status }),
|
||||
});
|
||||
if (!res.ok) throw new Error();
|
||||
setTickets((prev) => prev.map((t) => (t.id === id ? { ...t, status } : t)));
|
||||
} catch {
|
||||
toast.error("Failed to update status");
|
||||
}
|
||||
}
|
||||
|
||||
async function handleRetryGitea(id: string) {
|
||||
setRetrying(id);
|
||||
try {
|
||||
const res = await fetch(`/api/v1/admin/support/${id}`, {
|
||||
method: "PATCH",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ retryGitea: true }),
|
||||
});
|
||||
if (!res.ok) throw new Error();
|
||||
// Re-fetch the single ticket's fields isn't wired up server-side, so
|
||||
// reload the list to pick up the new giteaIssueUrl/giteaError.
|
||||
const listRes = await fetch("/api/v1/admin/support");
|
||||
if (listRes.ok) {
|
||||
const data = (await listRes.json()) as Ticket[];
|
||||
setTickets(data);
|
||||
}
|
||||
toast.success("Retried Gitea issue creation");
|
||||
} catch {
|
||||
toast.error("Retry failed");
|
||||
} finally {
|
||||
setRetrying(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (tickets.length === 0) {
|
||||
return <p className="text-sm text-muted-foreground">No support tickets yet.</p>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="divide-y rounded-md border">
|
||||
{tickets.map((ticket) => (
|
||||
<div key={ticket.id} className="px-4 py-3 space-y-1.5">
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div className="min-w-0">
|
||||
<p className="text-sm font-medium">{ticket.title}</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{ticket.username ? `@${ticket.username}` : ticket.userEmail} · {formatDateTime(ticket.createdAt)}
|
||||
</p>
|
||||
</div>
|
||||
<Select value={ticket.status} onValueChange={(v) => { void handleStatusChange(ticket.id, v as TicketStatus); }}>
|
||||
<SelectTrigger className="w-32 shrink-0">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="open">Open</SelectItem>
|
||||
<SelectItem value="triaged">Triaged</SelectItem>
|
||||
<SelectItem value="closed">Closed</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground whitespace-pre-wrap">{ticket.description}</p>
|
||||
<div className="flex items-center gap-2 text-xs flex-wrap pt-1">
|
||||
<Badge variant="outline" className="text-xs">{ticket.type}</Badge>
|
||||
<Badge variant={statusVariant[ticket.status]} className="text-xs">{ticket.status}</Badge>
|
||||
{ticket.giteaIssueUrl ? (
|
||||
<Link
|
||||
href={ticket.giteaIssueUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center gap-1 text-primary hover:underline"
|
||||
>
|
||||
View Gitea issue
|
||||
<ExternalLink className="h-3 w-3" />
|
||||
</Link>
|
||||
) : (
|
||||
<>
|
||||
{ticket.giteaError && (
|
||||
<span className="text-destructive" title={ticket.giteaError}>Gitea issue failed</span>
|
||||
)}
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-6 px-2 text-xs"
|
||||
disabled={retrying === ticket.id}
|
||||
onClick={() => { void handleRetryGitea(ticket.id); }}
|
||||
>
|
||||
{retrying === ticket.id ? "Retrying…" : "Create Gitea issue"}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
import Link from "next/link";
|
||||
import { usePathname, useRouter } from "next/navigation";
|
||||
import { useTheme } from "next-themes";
|
||||
import { BookOpen, Calendar, Package, ChefHat, User, FolderOpen, ShoppingCart, Shield, Search, Compass, Menu, Sun, Moon, Monitor, Apple } from "lucide-react";
|
||||
import { BookOpen, Calendar, Package, ChefHat, User, FolderOpen, ShoppingCart, Shield, Search, Compass, Menu, Sun, Moon, Monitor, Apple, LifeBuoy } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Button, buttonVariants } from "@/components/ui/button";
|
||||
import {
|
||||
@@ -130,6 +130,12 @@ export function Nav() {
|
||||
<DropdownMenuItem>
|
||||
<Link href="/settings" className="w-full">{t("settings")}</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem>
|
||||
<Link href="/support" className="w-full flex items-center gap-2">
|
||||
<LifeBuoy className="h-3.5 w-3.5" />
|
||||
{t("support")}
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
<div
|
||||
role="group"
|
||||
aria-label={t("systemMode")}
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { toast } from "sonner";
|
||||
import { ExternalLink } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
|
||||
type TicketType = "bug" | "suggestion" | "question";
|
||||
type TicketStatus = "open" | "triaged" | "closed";
|
||||
|
||||
type Ticket = {
|
||||
id: string;
|
||||
type: TicketType;
|
||||
title: string;
|
||||
description: string;
|
||||
status: TicketStatus;
|
||||
giteaIssueUrl: string | null;
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
function formatDate(iso: string) {
|
||||
return new Date(iso).toLocaleDateString(undefined, {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
});
|
||||
}
|
||||
|
||||
export function SupportManager({ initialTickets }: { initialTickets: Ticket[] }) {
|
||||
const t = useTranslations("support");
|
||||
const [tickets, setTickets] = useState<Ticket[]>(initialTickets);
|
||||
const [type, setType] = useState<TicketType>("bug");
|
||||
const [title, setTitle] = useState("");
|
||||
const [description, setDescription] = useState("");
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
async function handleSubmit(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
if (title.trim().length < 3 || description.trim().length < 10) return;
|
||||
setSubmitting(true);
|
||||
try {
|
||||
const res = await fetch("/api/v1/support", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ type, title: title.trim(), description: description.trim() }),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const data = (await res.json()) as { error?: string };
|
||||
throw new Error(data.error ?? t("submitFailed"));
|
||||
}
|
||||
const ticket = (await res.json()) as Ticket;
|
||||
setTickets((prev) => [ticket, ...prev]);
|
||||
setTitle("");
|
||||
setDescription("");
|
||||
setType("bug");
|
||||
toast.success(t("submitSuccess"));
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : t("submitFailed"));
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
}
|
||||
|
||||
const statusVariant: Record<TicketStatus, "default" | "secondary" | "outline"> = {
|
||||
open: "default",
|
||||
triaged: "secondary",
|
||||
closed: "outline",
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="support-type">{t("typeLabel")}</Label>
|
||||
<Select value={type} onValueChange={(v) => setType(v as TicketType)}>
|
||||
<SelectTrigger id="support-type" className="w-full sm:w-64">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="bug">{t("typeBug")}</SelectItem>
|
||||
<SelectItem value="suggestion">{t("typeSuggestion")}</SelectItem>
|
||||
<SelectItem value="question">{t("typeQuestion")}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="support-title">{t("titleLabel")}</Label>
|
||||
<Input
|
||||
id="support-title"
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
placeholder={t("titlePlaceholder")}
|
||||
maxLength={200}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="support-description">{t("descriptionLabel")}</Label>
|
||||
<Textarea
|
||||
id="support-description"
|
||||
value={description}
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
placeholder={t("descriptionPlaceholder")}
|
||||
maxLength={5000}
|
||||
rows={6}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Button type="submit" disabled={submitting || title.trim().length < 3 || description.trim().length < 10}>
|
||||
{submitting ? t("submitting") : t("submitButton")}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<div className="space-y-3">
|
||||
<h2 className="font-semibold text-lg">{t("historyTitle")}</h2>
|
||||
{tickets.length === 0 ? (
|
||||
<p className="text-sm text-muted-foreground">{t("noTickets")}</p>
|
||||
) : (
|
||||
<div className="divide-y rounded-md border">
|
||||
{tickets.map((ticket) => (
|
||||
<div key={ticket.id} className="px-4 py-3 space-y-1.5">
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<p className="text-sm font-medium">{ticket.title}</p>
|
||||
<Badge variant={statusVariant[ticket.status]} className="text-xs shrink-0">
|
||||
{t(`status.${ticket.status}`)}
|
||||
</Badge>
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground whitespace-pre-wrap">{ticket.description}</p>
|
||||
<div className="flex items-center gap-2 text-xs text-muted-foreground pt-1">
|
||||
<Badge variant="outline" className="text-xs">{t(`type.${ticket.type}`)}</Badge>
|
||||
<span>{formatDate(ticket.createdAt)}</span>
|
||||
{ticket.giteaIssueUrl && (
|
||||
<Link
|
||||
href={ticket.giteaIssueUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center gap-1 text-primary hover:underline"
|
||||
>
|
||||
{t("viewIssue")}
|
||||
<ExternalLink className="h-3 w-3" />
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// Mirrors CHANGELOG.md at the repo root — update both together.
|
||||
export const APP_VERSION = "0.48.2";
|
||||
export const APP_VERSION = "0.49.0";
|
||||
|
||||
export type ChangelogEntry = {
|
||||
version: string;
|
||||
@@ -11,6 +11,13 @@ export type ChangelogEntry = {
|
||||
};
|
||||
|
||||
export const CHANGELOG: ChangelogEntry[] = [
|
||||
{
|
||||
version: "0.49.0",
|
||||
date: "2026-07-18 12:30",
|
||||
added: [
|
||||
"New Support page — report a bug, share a suggestion, or ask a question right from the app. Submissions email you a confirmation and (if an admin has configured a Gitea repo in Settings) automatically open a tracked issue. Admins get a Support section in the admin panel to triage tickets and retry issue creation.",
|
||||
],
|
||||
},
|
||||
{
|
||||
version: "0.48.2",
|
||||
date: "2026-07-18 11:15",
|
||||
|
||||
@@ -141,6 +141,24 @@ export function weeklyDigestHtml(opts: {
|
||||
);
|
||||
}
|
||||
|
||||
export function supportTicketReceivedHtml(opts: {
|
||||
type: string;
|
||||
title: string;
|
||||
ticketUrl: string;
|
||||
giteaIssueUrl: string | null;
|
||||
}) {
|
||||
const { type, title, ticketUrl, giteaIssueUrl } = opts;
|
||||
const typeLabel = type === "bug" ? "bug report" : type === "suggestion" ? "suggestion" : "question";
|
||||
return layout(
|
||||
"We got your message — Epicure",
|
||||
`<h1 style="margin:0 0 8px;font-size:24px;">Thanks for reaching out</h1>
|
||||
<p style="margin:0 0 4px;color:#57534e;line-height:1.6;">We received your ${typeLabel}:</p>
|
||||
<p style="margin:16px 0;padding:12px 16px;background:#fafaf9;border-radius:8px;border:1px solid #e7e5e4;font-weight:600;">${title}</p>
|
||||
<p style="margin:0 0 4px;color:#57534e;line-height:1.6;">We'll follow up if we need more details.${giteaIssueUrl ? " It's also been logged for tracking." : ""}</p>
|
||||
${btn(ticketUrl, "View your ticket")}`
|
||||
);
|
||||
}
|
||||
|
||||
export function welcomeHtml(name: string) {
|
||||
return layout(
|
||||
"Welcome to Epicure",
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import { getSiteSetting } from "@/lib/site-settings";
|
||||
|
||||
const LABELS: Record<string, string[]> = {
|
||||
bug: ["bug"],
|
||||
suggestion: ["enhancement"],
|
||||
question: ["question"],
|
||||
};
|
||||
|
||||
/**
|
||||
* Opens an issue on the configured Gitea repo for a support ticket. Returns
|
||||
* the issue's HTML URL on success, or null if Gitea isn't configured or the
|
||||
* request fails — callers must treat this as best-effort, not block on it,
|
||||
* since the ticket itself is already saved regardless.
|
||||
*/
|
||||
export async function createGiteaIssue(opts: {
|
||||
type: string;
|
||||
title: string;
|
||||
body: string;
|
||||
}): Promise<{ url: string | null; error: string | null }> {
|
||||
const [baseUrl, token, repo] = await Promise.all([
|
||||
getSiteSetting("GITEA_URL"),
|
||||
getSiteSetting("GITEA_TOKEN"),
|
||||
getSiteSetting("GITEA_REPO"),
|
||||
]);
|
||||
|
||||
if (!baseUrl || !token || !repo) {
|
||||
return { url: null, error: null };
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch(`${baseUrl.replace(/\/$/, "")}/api/v1/repos/${repo}/issues`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `token ${token}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
title: opts.title,
|
||||
body: opts.body,
|
||||
labels: LABELS[opts.type] ?? [],
|
||||
}),
|
||||
signal: AbortSignal.timeout(10000),
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const text = await res.text().catch(() => "");
|
||||
return { url: null, error: `Gitea returned ${res.status}: ${text.slice(0, 300)}` };
|
||||
}
|
||||
|
||||
const issue = (await res.json()) as { html_url?: string };
|
||||
return { url: issue.html_url ?? null, error: issue.html_url ? null : "Gitea response had no html_url" };
|
||||
} catch (err) {
|
||||
return { url: null, error: err instanceof Error ? err.message : "Unknown error" };
|
||||
}
|
||||
}
|
||||
@@ -582,6 +582,21 @@ export function generateOpenApiSpec(): object {
|
||||
registry.registerPath({ method: "get", path: "/api/v1/webhooks/{id}/deliveries", summary: "List recent delivery attempts (most recent 20)", security, request: { params: idParam }, responses: { 200: { description: "Deliveries, newest first", content: { "application/json": { schema: z.array(WebhookDeliveryRef) } } }, 404: { description: "Not found", content: { "application/json": { schema: ApiErrorRef } } } } });
|
||||
registry.registerPath({ method: "post", path: "/api/v1/webhooks/{id}/redeliver", summary: "Re-send a past delivery's payload", security, request: { params: idParam, body: { content: { "application/json": { schema: z.object({ deliveryId: z.string().uuid() }) } }, required: true } }, responses: { 200: { description: "Redelivery dispatched", content: { "application/json": { schema: z.object({ ok: z.boolean() }) } } }, 400: { description: "Validation error", content: { "application/json": { schema: ApiErrorRef } } }, 404: { description: "Webhook or delivery not found", content: { "application/json": { schema: ApiErrorRef } } } } });
|
||||
|
||||
// --- Support: bug reports, suggestions, and questions submitted in-app ---
|
||||
const SupportTicketTypeEnum = z.enum(["bug", "suggestion", "question"]);
|
||||
const SupportTicketStatusEnum = z.enum(["open", "triaged", "closed"]);
|
||||
const SupportTicketRef = registry.register("SupportTicket", z.object({
|
||||
id: z.string(), userId: z.string(), type: SupportTicketTypeEnum, title: z.string(), description: z.string(),
|
||||
status: SupportTicketStatusEnum, giteaIssueUrl: z.string().nullable(), giteaError: z.string().nullable(),
|
||||
createdAt: z.string().datetime(), updatedAt: z.string().datetime(),
|
||||
}));
|
||||
const CreateSupportTicketRef = registry.register("CreateSupportTicket", z.object({
|
||||
type: SupportTicketTypeEnum, title: z.string().min(3).max(200), description: z.string().min(10).max(5000),
|
||||
}));
|
||||
|
||||
registry.registerPath({ method: "get", path: "/api/v1/support", summary: "List your support tickets", security, responses: { 200: { description: "Tickets, newest first", content: { "application/json": { schema: z.array(SupportTicketRef) } } }, 401: { description: "Unauthorized", content: { "application/json": { schema: ApiErrorRef } } } } });
|
||||
registry.registerPath({ method: "post", path: "/api/v1/support", summary: "Submit a bug report, suggestion, or question", description: "Best-effort opens a matching issue on the configured Gitea repo (see giteaIssueUrl/giteaError) — this never blocks ticket creation. Sends a confirmation email.", security, request: { body: { content: { "application/json": { schema: CreateSupportTicketRef } }, required: true } }, responses: { 201: { description: "Created", content: { "application/json": { schema: SupportTicketRef } } }, 400: { description: "Validation error", content: { "application/json": { schema: ApiErrorRef } } }, 401: { description: "Unauthorized", content: { "application/json": { schema: ApiErrorRef } } } } });
|
||||
|
||||
// --- Conversations: 1:1 direct messages ---
|
||||
const ConversationSummaryRef = registry.register("ConversationSummary", z.object({
|
||||
id: z.string(),
|
||||
|
||||
@@ -15,13 +15,17 @@ export type SiteSettingKey =
|
||||
| "DEFAULT_VISION_PROVIDER"
|
||||
| "DEFAULT_VISION_MODEL"
|
||||
| "DEFAULT_MEAL_PLAN_PROVIDER"
|
||||
| "DEFAULT_MEAL_PLAN_MODEL";
|
||||
| "DEFAULT_MEAL_PLAN_MODEL"
|
||||
| "GITEA_URL"
|
||||
| "GITEA_TOKEN"
|
||||
| "GITEA_REPO";
|
||||
|
||||
const SECRET_KEYS: SiteSettingKey[] = [
|
||||
"OPENAI_API_KEY",
|
||||
"ANTHROPIC_API_KEY",
|
||||
"OPENROUTER_API_KEY",
|
||||
"VAPID_PRIVATE_KEY",
|
||||
"GITEA_TOKEN",
|
||||
];
|
||||
|
||||
export function isSecretKey(key: SiteSettingKey): boolean {
|
||||
@@ -58,6 +62,9 @@ export async function getAllSiteSettings(): Promise<Record<string, { value: stri
|
||||
"DEFAULT_VISION_MODEL",
|
||||
"DEFAULT_MEAL_PLAN_PROVIDER",
|
||||
"DEFAULT_MEAL_PLAN_MODEL",
|
||||
"GITEA_URL",
|
||||
"GITEA_TOKEN",
|
||||
"GITEA_REPO",
|
||||
];
|
||||
|
||||
const result: Record<string, { value: string | null; isSecret: boolean; fromDb: boolean }> = {};
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
"language": "Language",
|
||||
"notifications": "Notifications",
|
||||
"viewProfile": "View profile",
|
||||
"support": "Support",
|
||||
"lightMode": "Light mode",
|
||||
"darkMode": "Dark mode",
|
||||
"systemMode": "System"
|
||||
@@ -450,6 +451,35 @@
|
||||
"description": "Receive HTTP callbacks when events happen in your Epicure account."
|
||||
}
|
||||
},
|
||||
"support": {
|
||||
"title": "Support",
|
||||
"subtitle": "Report a bug, share a suggestion, or ask a question — we read every message.",
|
||||
"typeLabel": "Type",
|
||||
"typeBug": "Bug report",
|
||||
"typeSuggestion": "Suggestion",
|
||||
"typeQuestion": "Question",
|
||||
"titleLabel": "Title",
|
||||
"titlePlaceholder": "Short summary of the issue or idea",
|
||||
"descriptionLabel": "Description",
|
||||
"descriptionPlaceholder": "What happened, what you expected, and steps to reproduce (if a bug) — or details on your suggestion/question.",
|
||||
"submitButton": "Submit",
|
||||
"submitting": "Submitting…",
|
||||
"submitSuccess": "Thanks! We received your message.",
|
||||
"submitFailed": "Failed to submit — try again.",
|
||||
"historyTitle": "Your tickets",
|
||||
"noTickets": "You haven't submitted anything yet.",
|
||||
"viewIssue": "View issue",
|
||||
"status": {
|
||||
"open": "Open",
|
||||
"triaged": "Triaged",
|
||||
"closed": "Closed"
|
||||
},
|
||||
"type": {
|
||||
"bug": "Bug",
|
||||
"suggestion": "Suggestion",
|
||||
"question": "Question"
|
||||
}
|
||||
},
|
||||
"print": {
|
||||
"footer": "Printed from Epicure",
|
||||
"day": "Day",
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
"language": "Langue",
|
||||
"notifications": "Notifications",
|
||||
"viewProfile": "Voir le profil",
|
||||
"support": "Support",
|
||||
"lightMode": "Mode clair",
|
||||
"darkMode": "Mode sombre",
|
||||
"systemMode": "Système"
|
||||
@@ -450,6 +451,35 @@
|
||||
"description": "Recevez des appels HTTP lorsque des événements se produisent sur votre compte Epicure."
|
||||
}
|
||||
},
|
||||
"support": {
|
||||
"title": "Support",
|
||||
"subtitle": "Signalez un bug, partagez une suggestion ou posez une question — nous lisons chaque message.",
|
||||
"typeLabel": "Type",
|
||||
"typeBug": "Signalement de bug",
|
||||
"typeSuggestion": "Suggestion",
|
||||
"typeQuestion": "Question",
|
||||
"titleLabel": "Titre",
|
||||
"titlePlaceholder": "Résumé court du problème ou de l'idée",
|
||||
"descriptionLabel": "Description",
|
||||
"descriptionPlaceholder": "Ce qui s'est passé, ce que vous attendiez, et les étapes pour reproduire (si bug) — ou les détails de votre suggestion/question.",
|
||||
"submitButton": "Envoyer",
|
||||
"submitting": "Envoi…",
|
||||
"submitSuccess": "Merci ! Nous avons reçu votre message.",
|
||||
"submitFailed": "Échec de l'envoi — réessayez.",
|
||||
"historyTitle": "Vos tickets",
|
||||
"noTickets": "Vous n'avez encore rien soumis.",
|
||||
"viewIssue": "Voir le ticket",
|
||||
"status": {
|
||||
"open": "Ouvert",
|
||||
"triaged": "Trié",
|
||||
"closed": "Fermé"
|
||||
},
|
||||
"type": {
|
||||
"bug": "Bug",
|
||||
"suggestion": "Suggestion",
|
||||
"question": "Question"
|
||||
}
|
||||
},
|
||||
"print": {
|
||||
"footer": "Imprimé depuis Epicure",
|
||||
"day": "Jour",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@epicure/web",
|
||||
"version": "0.48.2",
|
||||
"version": "0.49.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "epicure",
|
||||
"version": "0.48.2",
|
||||
"version": "0.49.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "pnpm --filter web dev",
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
CREATE TYPE "public"."support_ticket_status" AS ENUM('open', 'triaged', 'closed');--> statement-breakpoint
|
||||
CREATE TYPE "public"."support_ticket_type" AS ENUM('bug', 'suggestion', 'question');--> statement-breakpoint
|
||||
CREATE TABLE "support_tickets" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"user_id" text NOT NULL,
|
||||
"type" "support_ticket_type" NOT NULL,
|
||||
"title" text NOT NULL,
|
||||
"description" text NOT NULL,
|
||||
"status" "support_ticket_status" DEFAULT 'open' NOT NULL,
|
||||
"gitea_issue_url" text,
|
||||
"gitea_error" text,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "support_tickets" ADD CONSTRAINT "support_tickets_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "support_tickets_user_idx" ON "support_tickets" USING btree ("user_id","created_at");--> statement-breakpoint
|
||||
CREATE INDEX "support_tickets_status_idx" ON "support_tickets" USING btree ("status","created_at");
|
||||
File diff suppressed because it is too large
Load Diff
@@ -316,6 +316,13 @@
|
||||
"when": 1784326930573,
|
||||
"tag": "0044_polite_living_mummy",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 45,
|
||||
"version": "7",
|
||||
"when": 1784366396485,
|
||||
"tag": "0045_overjoyed_moondragon",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -7,3 +7,4 @@ export * from "./webhooks";
|
||||
export * from "./messaging";
|
||||
export * from "./billing";
|
||||
export * from "./ai-chat";
|
||||
export * from "./support";
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { pgTable, text, timestamp, index, pgEnum } from "drizzle-orm/pg-core";
|
||||
import { relations } from "drizzle-orm";
|
||||
import { users } from "./users";
|
||||
|
||||
export const supportTicketTypeEnum = pgEnum("support_ticket_type", ["bug", "suggestion", "question"]);
|
||||
export const supportTicketStatusEnum = pgEnum("support_ticket_status", ["open", "triaged", "closed"]);
|
||||
|
||||
export const supportTickets = pgTable("support_tickets", {
|
||||
id: text("id").primaryKey(),
|
||||
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
||||
type: supportTicketTypeEnum("type").notNull(),
|
||||
title: text("title").notNull(),
|
||||
description: text("description").notNull(),
|
||||
status: supportTicketStatusEnum("status").notNull().default("open"),
|
||||
giteaIssueUrl: text("gitea_issue_url"),
|
||||
giteaError: text("gitea_error"),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
||||
}, (t) => [
|
||||
index("support_tickets_user_idx").on(t.userId, t.createdAt),
|
||||
index("support_tickets_status_idx").on(t.status, t.createdAt),
|
||||
]);
|
||||
|
||||
export const supportTicketsRelations = relations(supportTickets, ({ one }) => ({
|
||||
user: one(users, { fields: [supportTickets.userId], references: [users.id] }),
|
||||
}));
|
||||
Reference in New Issue
Block a user