i18n events and polls admin DataTable columns.
Wire column headers, search placeholders, and status/type labels through pages.admin.events/polls (en/nl/it), matching tickets-table. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
3bf63b17de
commit
8009491245
5 files changed
+139
-49
No files matched your search
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { Pencil } from "lucide-react";
|
import { Pencil } from "lucide-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
import { DataTable } from "@/components/admin/data-table";
|
import { DataTable } from "@/components/admin/data-table";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
@@ -28,18 +29,31 @@ const statusVariants: Record<
|
|||||||
completed: "outline",
|
completed: "outline",
|
||||||
};
|
};
|
||||||
|
|
||||||
function getColumns(): DataTableColumn<EventRow>[] {
|
interface EventsTableProps {
|
||||||
return [
|
data: PaginatedResult<EventRow>;
|
||||||
{ key: "id", label: "ID", sortable: true },
|
}
|
||||||
|
|
||||||
|
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",
|
key: "title",
|
||||||
label: "Title",
|
label: t("colTitle"),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
render: (value) => <span className="font-medium">{String(value)}</span>,
|
render: (value) => <span className="font-medium">{String(value)}</span>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "typeName",
|
key: "typeName",
|
||||||
label: "Type",
|
label: t("colType"),
|
||||||
sortable: false,
|
sortable: false,
|
||||||
render: (_, row) => (
|
render: (_, row) => (
|
||||||
<Badge style={{ backgroundColor: row.typeColor, color: "#fff" }}>
|
<Badge style={{ backgroundColor: row.typeColor, color: "#fff" }}>
|
||||||
@@ -49,7 +63,7 @@ function getColumns(): DataTableColumn<EventRow>[] {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "startsAt",
|
key: "startsAt",
|
||||||
label: "Starts",
|
label: t("colStarts"),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
render: (value) => (
|
render: (value) => (
|
||||||
<span className="text-sm">
|
<span className="text-sm">
|
||||||
@@ -59,17 +73,20 @@ function getColumns(): DataTableColumn<EventRow>[] {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "status",
|
key: "status",
|
||||||
label: "Status",
|
label: t("colStatus"),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
render: (value) => (
|
render: (value) => {
|
||||||
<Badge variant={statusVariants[String(value)] ?? "secondary"}>
|
const key = String(value);
|
||||||
{String(value)}
|
return (
|
||||||
</Badge>
|
<Badge variant={statusVariants[key] ?? "secondary"}>
|
||||||
),
|
{statusLabel[key] ?? key}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "actions",
|
key: "actions",
|
||||||
label: "Actions",
|
label: t("colActions"),
|
||||||
render: (_, row) => (
|
render: (_, row) => (
|
||||||
<Button variant="ghost" size="icon" asChild>
|
<Button variant="ghost" size="icon" asChild>
|
||||||
<Link href={`/admin/events/${row.id}`}>
|
<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 (
|
return (
|
||||||
<DataTable
|
<DataTable
|
||||||
data={data}
|
data={data}
|
||||||
columns={getColumns()}
|
columns={columns}
|
||||||
searchPlaceholder="Search events..."
|
searchPlaceholder={t("searchPlaceholder")}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { Pencil } from "lucide-react";
|
import { Pencil } from "lucide-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
import { DataTable } from "@/components/admin/data-table";
|
import { DataTable } from "@/components/admin/data-table";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
@@ -24,37 +25,52 @@ const statusVariants: Record<string, "default" | "secondary" | "outline"> = {
|
|||||||
closed: "outline",
|
closed: "outline",
|
||||||
};
|
};
|
||||||
|
|
||||||
function getColumns(): DataTableColumn<PollRow>[] {
|
interface PollsTableProps {
|
||||||
return [
|
data: PaginatedResult<PollRow>;
|
||||||
{ key: "id", label: "ID", sortable: true },
|
}
|
||||||
|
|
||||||
|
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",
|
key: "title",
|
||||||
label: "Title",
|
label: t("colTitle"),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
render: (value) => <span className="font-medium">{String(value)}</span>,
|
render: (value) => <span className="font-medium">{String(value)}</span>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "status",
|
key: "status",
|
||||||
label: "Status",
|
label: t("colStatus"),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
render: (value) => (
|
render: (value) => {
|
||||||
<Badge variant={statusVariants[String(value)] ?? "secondary"}>
|
const key = String(value);
|
||||||
{String(value)}
|
return (
|
||||||
</Badge>
|
<Badge variant={statusVariants[key] ?? "secondary"}>
|
||||||
),
|
{statusLabel[key] ?? key}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "multipleChoice",
|
key: "multipleChoice",
|
||||||
label: "Type",
|
label: t("colType"),
|
||||||
render: (value) => (
|
render: (value) => (
|
||||||
<span className="text-sm">
|
<span className="text-sm">
|
||||||
{Number(value) ? "Multiple choice" : "Single choice"}
|
{Number(value) ? t("typeMultiple") : t("typeSingle")}
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "createdAt",
|
key: "createdAt",
|
||||||
label: "Created",
|
label: t("colCreated"),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
render: (value) => (
|
render: (value) => (
|
||||||
<span className="text-sm">
|
<span className="text-sm">
|
||||||
@@ -64,7 +80,7 @@ function getColumns(): DataTableColumn<PollRow>[] {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "actions",
|
key: "actions",
|
||||||
label: "Actions",
|
label: t("colActions"),
|
||||||
render: (_, row) => (
|
render: (_, row) => (
|
||||||
<Button variant="ghost" size="icon" asChild>
|
<Button variant="ghost" size="icon" asChild>
|
||||||
<Link href={`/admin/polls/${row.id}`}>
|
<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 (
|
return (
|
||||||
<DataTable
|
<DataTable
|
||||||
data={data}
|
data={data}
|
||||||
columns={getColumns()}
|
columns={columns}
|
||||||
searchPlaceholder="Search polls..."
|
searchPlaceholder={t("searchPlaceholder")}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
+25
-2
@@ -838,12 +838,35 @@
|
|||||||
"events": {
|
"events": {
|
||||||
"newEvent": "+ New event",
|
"newEvent": "+ New event",
|
||||||
"createTitle": "Create 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": {
|
"polls": {
|
||||||
"newPoll": "+ New poll",
|
"newPoll": "+ New poll",
|
||||||
"createTitle": "Create 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": {
|
"multiAccounts": {
|
||||||
"minAccounts": "Min accounts per cluster",
|
"minAccounts": "Min accounts per cluster",
|
||||||
|
|||||||
+25
-2
@@ -802,12 +802,35 @@
|
|||||||
"events": {
|
"events": {
|
||||||
"newEvent": "+ Nuovo evento",
|
"newEvent": "+ Nuovo evento",
|
||||||
"createTitle": "Crea 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": {
|
"polls": {
|
||||||
"newPoll": "+ Nuovo sondaggio",
|
"newPoll": "+ Nuovo sondaggio",
|
||||||
"createTitle": "Crea 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": {
|
"multiAccounts": {
|
||||||
"minAccounts": "Min. account per cluster",
|
"minAccounts": "Min. account per cluster",
|
||||||
|
|||||||
+25
-2
@@ -838,12 +838,35 @@
|
|||||||
"events": {
|
"events": {
|
||||||
"newEvent": "+ Nieuw evenement",
|
"newEvent": "+ Nieuw evenement",
|
||||||
"createTitle": "Evenement aanmaken",
|
"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": {
|
"polls": {
|
||||||
"newPoll": "+ Nieuwe poll",
|
"newPoll": "+ Nieuwe poll",
|
||||||
"createTitle": "Poll aanmaken",
|
"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": {
|
"multiAccounts": {
|
||||||
"minAccounts": "Min. accounts per cluster",
|
"minAccounts": "Min. accounts per cluster",
|
||||||
|
|||||||
Reference in new issue
Block a user