From 258585e9810f50ef086f2f40a013fcc2664759c3 Mon Sep 17 00:00:00 2001 From: msukkari Date: Wed, 12 Feb 2025 21:19:15 -0800 Subject: [PATCH] action button styling in settings and toast on copy --- .../settings/components/inviteTable.tsx | 11 ++++++- .../components/inviteTableColumns.tsx | 26 ++++++++++++--- .../settings/components/memberInviteForm.tsx | 4 +++ .../components/memberTableColumns.tsx | 32 +++++++++++++++++++ 4 files changed, 68 insertions(+), 5 deletions(-) diff --git a/packages/web/src/app/[domain]/settings/components/inviteTable.tsx b/packages/web/src/app/[domain]/settings/components/inviteTable.tsx index b270322f..56149fc3 100644 --- a/packages/web/src/app/[domain]/settings/components/inviteTable.tsx +++ b/packages/web/src/app/[domain]/settings/components/inviteTable.tsx @@ -2,6 +2,7 @@ import { useMemo } from "react"; import { DataTable } from "@/components/ui/data-table"; import { InviteColumnInfo, inviteTableColumns } from "./inviteTableColumns" +import { useToast } from "@/components/hooks/use-toast"; export interface InviteInfo { id: string; @@ -14,6 +15,14 @@ interface InviteTableProps { } export const InviteTable = ({ initialInvites }: InviteTableProps) => { + const { toast } = useToast(); + + const displayToast = (message: string) => { + toast({ + description: message, + }); + } + const inviteRows: InviteColumnInfo[] = useMemo(() => { return initialInvites.map(invite => { return { @@ -28,7 +37,7 @@ export const InviteTable = ({ initialInvites }: InviteTableProps) => {

Invites

[] => { +export const inviteTableColumns = (displayToast: (message: string) => void): ColumnDef[] => { return [ { accessorKey: "email", @@ -28,19 +29,36 @@ export const inviteTableColumns = (): ColumnDef[] => { } }, { - accessorKey: "copy", + id: "copy", cell: ({ row }) => { const invite = row.original; return ( ) } diff --git a/packages/web/src/app/[domain]/settings/components/memberInviteForm.tsx b/packages/web/src/app/[domain]/settings/components/memberInviteForm.tsx index 5cdedf91..1814da35 100644 --- a/packages/web/src/app/[domain]/settings/components/memberInviteForm.tsx +++ b/packages/web/src/app/[domain]/settings/components/memberInviteForm.tsx @@ -10,12 +10,14 @@ import { createInvite } from "@/actions" import { isServiceError } from "@/lib/utils"; import { useDomain } from "@/hooks/useDomain"; import { ErrorCode } from "@/lib/errorCodes"; +import { useRouter } from "next/navigation"; const formSchema = z.object({ email: z.string().min(2).max(40), }); export const MemberInviteForm = ({ userId }: { userId: string }) => { + const router = useRouter(); const { toast } = useToast(); const domain = useDomain(); @@ -37,6 +39,8 @@ export const MemberInviteForm = ({ userId }: { userId: string }) => { toast({ description: `✅ Invite created successfully!` }); + + router.refresh(); } } diff --git a/packages/web/src/app/[domain]/settings/components/memberTableColumns.tsx b/packages/web/src/app/[domain]/settings/components/memberTableColumns.tsx index e4b1364a..3bbe6ae8 100644 --- a/packages/web/src/app/[domain]/settings/components/memberTableColumns.tsx +++ b/packages/web/src/app/[domain]/settings/components/memberTableColumns.tsx @@ -1,5 +1,6 @@ 'use client' +import { Button } from "@/components/ui/button" import { ColumnDef } from "@tanstack/react-table" export type MemberColumnInfo = { @@ -22,6 +23,37 @@ export const memberTableColumns = (): ColumnDef[] => { const member = row.original; return
{member.role}
; } + }, + { + id: "remove", + cell: () => { + return ( + + ); + } } ] } \ No newline at end of file