feat(announcement): Popup and pinned

This commit is contained in:
web@ppanel
2024-12-21 00:10:09 +07:00
parent 79621623d5
commit f3680a7020
35 changed files with 465 additions and 351 deletions
+42 -7
View File
@@ -5,7 +5,6 @@ import {
deleteAnnouncement,
getAnnouncementList,
updateAnnouncement,
updateAnnouncementEnable,
} from '@/services/admin/announcement';
import { ConfirmButton } from '@repo/ui/confirm-button';
import { format } from '@shadcn/ui/lib/date-fns';
@@ -51,16 +50,52 @@ export default function Page() {
}}
columns={[
{
accessorKey: 'enable',
header: t('enable'),
accessorKey: 'show',
header: t('show'),
cell: ({ row }) => {
return (
<Switch
defaultChecked={row.getValue('enable')}
defaultChecked={row.getValue('show')}
onCheckedChange={async (checked) => {
await updateAnnouncementEnable({
id: row.original.id,
enable: checked,
await updateAnnouncement({
...row.original,
show: checked,
});
ref.current?.refresh();
}}
/>
);
},
},
{
accessorKey: 'pinned',
header: t('pinned'),
cell: ({ row }) => {
return (
<Switch
defaultChecked={row.getValue('pinned')}
onCheckedChange={async (checked) => {
await updateAnnouncement({
...row.original,
pinned: checked,
});
ref.current?.refresh();
}}
/>
);
},
},
{
accessorKey: 'popup',
header: t('popup'),
cell: ({ row }) => {
return (
<Switch
defaultChecked={row.getValue('popup')}
onCheckedChange={async (checked) => {
await updateAnnouncement({
...row.original,
popup: checked,
});
ref.current?.refresh();
}}