Merge pull request 'feat(i18n): events/polls admin table columns' (#8) from feat/events-polls-table-i18n into main
Local Build and Deploy / deploy (push) Successful in 1m0s

Reviewed-on: #8
This commit is contained in:
Simo committed 2026-07-18 21:43:48 +02:00
commit dd9c5e70c2
5 files changed
+139 -49

No files matched your search

+32 -21
View File
@@ -2,6 +2,7 @@
import { Pencil } from "lucide-react";
import Link from "next/link";
import { useTranslations } from "next-intl";
import { DataTable } from "@/components/admin/data-table";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
@@ -28,18 +29,31 @@ const statusVariants: Record<
completed: "outline",
};
function getColumns(): DataTableColumn<EventRow>[] {
return [
{ key: "id", label: "ID", sortable: true },
interface EventsTableProps {
data: PaginatedResult<EventRow>;
}
export function EventsTable({ data }: EventsTableProps) {
const t = useTranslations("pages.admin.events");
const statusLabel: Record<string, string> = {
published: t("statusPublished"),
draft: t("statusDraft"),
cancelled: t("statusCancelled"),
completed: t("statusCompleted"),
};
const columns: DataTableColumn<EventRow>[] = [
{ key: "id", label: t("colId"), sortable: true },
{
key: "title",
label: "Title",
label: t("colTitle"),
sortable: true,
render: (value) => <span className="font-medium">{String(value)}</span>,
},
{
key: "typeName",
label: "Type",
label: t("colType"),
sortable: false,
render: (_, row) => (
<Badge style={{ backgroundColor: row.typeColor, color: "#fff" }}>
@@ -49,7 +63,7 @@ function getColumns(): DataTableColumn<EventRow>[] {
},
{
key: "startsAt",
label: "Starts",
label: t("colStarts"),
sortable: true,
render: (value) => (
<span className="text-sm">
@@ -59,17 +73,20 @@ function getColumns(): DataTableColumn<EventRow>[] {
},
{
key: "status",
label: "Status",
label: t("colStatus"),
sortable: true,
render: (value) => (
<Badge variant={statusVariants[String(value)] ?? "secondary"}>
{String(value)}
</Badge>
),
render: (value) => {
const key = String(value);
return (
<Badge variant={statusVariants[key] ?? "secondary"}>
{statusLabel[key] ?? key}
</Badge>
);
},
},
{
key: "actions",
label: "Actions",
label: t("colActions"),
render: (_, row) => (
<Button variant="ghost" size="icon" asChild>
<Link href={`/admin/events/${row.id}`}>
@@ -79,18 +96,12 @@ function getColumns(): DataTableColumn<EventRow>[] {
),
},
];
}
interface EventsTableProps {
data: PaginatedResult<EventRow>;
}
export function EventsTable({ data }: EventsTableProps) {
return (
<DataTable
data={data}
columns={getColumns()}
searchPlaceholder="Search events..."
columns={columns}
searchPlaceholder={t("searchPlaceholder")}
/>
);
}
+32 -22
View File
@@ -2,6 +2,7 @@
import { Pencil } from "lucide-react";
import Link from "next/link";
import { useTranslations } from "next-intl";
import { DataTable } from "@/components/admin/data-table";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
@@ -24,37 +25,52 @@ const statusVariants: Record<string, "default" | "secondary" | "outline"> = {
closed: "outline",
};
function getColumns(): DataTableColumn<PollRow>[] {
return [
{ key: "id", label: "ID", sortable: true },
interface PollsTableProps {
data: PaginatedResult<PollRow>;
}
export function PollsTable({ data }: PollsTableProps) {
const t = useTranslations("pages.admin.polls");
const statusLabel: Record<string, string> = {
active: t("statusActive"),
draft: t("statusDraft"),
closed: t("statusClosed"),
};
const columns: DataTableColumn<PollRow>[] = [
{ key: "id", label: t("colId"), sortable: true },
{
key: "title",
label: "Title",
label: t("colTitle"),
sortable: true,
render: (value) => <span className="font-medium">{String(value)}</span>,
},
{
key: "status",
label: "Status",
label: t("colStatus"),
sortable: true,
render: (value) => (
<Badge variant={statusVariants[String(value)] ?? "secondary"}>
{String(value)}
</Badge>
),
render: (value) => {
const key = String(value);
return (
<Badge variant={statusVariants[key] ?? "secondary"}>
{statusLabel[key] ?? key}
</Badge>
);
},
},
{
key: "multipleChoice",
label: "Type",
label: t("colType"),
render: (value) => (
<span className="text-sm">
{Number(value) ? "Multiple choice" : "Single choice"}
{Number(value) ? t("typeMultiple") : t("typeSingle")}
</span>
),
},
{
key: "createdAt",
label: "Created",
label: t("colCreated"),
sortable: true,
render: (value) => (
<span className="text-sm">
@@ -64,7 +80,7 @@ function getColumns(): DataTableColumn<PollRow>[] {
},
{
key: "actions",
label: "Actions",
label: t("colActions"),
render: (_, row) => (
<Button variant="ghost" size="icon" asChild>
<Link href={`/admin/polls/${row.id}`}>
@@ -74,18 +90,12 @@ function getColumns(): DataTableColumn<PollRow>[] {
),
},
];
}
interface PollsTableProps {
data: PaginatedResult<PollRow>;
}
export function PollsTable({ data }: PollsTableProps) {
return (
<DataTable
data={data}
columns={getColumns()}
searchPlaceholder="Search polls..."
columns={columns}
searchPlaceholder={t("searchPlaceholder")}
/>
);
}
+25 -2
View File
@@ -838,12 +838,35 @@
"events": {
"newEvent": "+ New event",
"createTitle": "Create event",
"createSubtitle": "Schedule a new hotel event"
"createSubtitle": "Schedule a new hotel event",
"searchPlaceholder": "Search events…",
"colId": "ID",
"colTitle": "Title",
"colType": "Type",
"colStarts": "Starts",
"colStatus": "Status",
"colActions": "Actions",
"statusPublished": "Published",
"statusDraft": "Draft",
"statusCancelled": "Cancelled",
"statusCompleted": "Completed"
},
"polls": {
"newPoll": "+ New poll",
"createTitle": "Create poll",
"createSubtitle": "Create a new community poll or survey"
"createSubtitle": "Create a new community poll or survey",
"searchPlaceholder": "Search polls…",
"colId": "ID",
"colTitle": "Title",
"colStatus": "Status",
"colType": "Type",
"colCreated": "Created",
"colActions": "Actions",
"statusActive": "Active",
"statusDraft": "Draft",
"statusClosed": "Closed",
"typeMultiple": "Multiple choice",
"typeSingle": "Single choice"
},
"multiAccounts": {
"minAccounts": "Min accounts per cluster",
+25 -2
View File
@@ -802,12 +802,35 @@
"events": {
"newEvent": "+ Nuovo evento",
"createTitle": "Crea evento",
"createSubtitle": "Programma un nuovo evento dell'hotel"
"createSubtitle": "Programma un nuovo evento dell'hotel",
"searchPlaceholder": "Cerca eventi…",
"colId": "ID",
"colTitle": "Titolo",
"colType": "Tipo",
"colStarts": "Inizio",
"colStatus": "Stato",
"colActions": "Azioni",
"statusPublished": "Pubblicato",
"statusDraft": "Bozza",
"statusCancelled": "Annullato",
"statusCompleted": "Completato"
},
"polls": {
"newPoll": "+ Nuovo sondaggio",
"createTitle": "Crea sondaggio",
"createSubtitle": "Crea un nuovo sondaggio o survey della community"
"createSubtitle": "Crea un nuovo sondaggio o survey della community",
"searchPlaceholder": "Cerca sondaggi…",
"colId": "ID",
"colTitle": "Titolo",
"colStatus": "Stato",
"colType": "Tipo",
"colCreated": "Creato",
"colActions": "Azioni",
"statusActive": "Attivo",
"statusDraft": "Bozza",
"statusClosed": "Chiuso",
"typeMultiple": "Scelta multipla",
"typeSingle": "Scelta singola"
},
"multiAccounts": {
"minAccounts": "Min. account per cluster",
+25 -2
View File
@@ -838,12 +838,35 @@
"events": {
"newEvent": "+ Nieuw evenement",
"createTitle": "Evenement aanmaken",
"createSubtitle": "Plan een nieuw hotel-evenement"
"createSubtitle": "Plan een nieuw hotel-evenement",
"searchPlaceholder": "Zoek evenementen…",
"colId": "ID",
"colTitle": "Titel",
"colType": "Type",
"colStarts": "Start",
"colStatus": "Status",
"colActions": "Acties",
"statusPublished": "Gepubliceerd",
"statusDraft": "Concept",
"statusCancelled": "Geannuleerd",
"statusCompleted": "Voltooid"
},
"polls": {
"newPoll": "+ Nieuwe poll",
"createTitle": "Poll aanmaken",
"createSubtitle": "Maak een nieuwe community-poll of enquête"
"createSubtitle": "Maak een nieuwe community-poll of enquête",
"searchPlaceholder": "Zoek polls…",
"colId": "ID",
"colTitle": "Titel",
"colStatus": "Status",
"colType": "Type",
"colCreated": "Aangemaakt",
"colActions": "Acties",
"statusActive": "Actief",
"statusDraft": "Concept",
"statusClosed": "Gesloten",
"typeMultiple": "Meerkeuze",
"typeSingle": "Enkele keuze"
},
"multiAccounts": {
"minAccounts": "Min. accounts per cluster",