diff --git a/apps/web/app/api/workspaces/[workspaceSlug]/invites/[inviteId]/route.ts b/apps/web/app/api/workspaces/[workspaceSlug]/invites/[inviteId]/route.ts new file mode 100644 index 0000000..487bf8b --- /dev/null +++ b/apps/web/app/api/workspaces/[workspaceSlug]/invites/[inviteId]/route.ts @@ -0,0 +1,17 @@ +import { withWorkspaceOwner } from '@saasfy/api/server'; +import { createAdminClient } from '@saasfy/supabase/server'; + +export const DELETE = withWorkspaceOwner<{ inviteId: string }>(async ({ workspace, params }) => { + const { inviteId } = params; + + const supabase = createAdminClient(); + + await supabase + .from('workspace_invites') + .delete() + .eq('id', inviteId) + .eq('status', 'pending') + .eq('workspace_id', workspace.id); + + return Response.json({ success: true }); +}); diff --git a/apps/web/app/app/(dashboard)/[workspaceSlug]/settings/members/invite-table.tsx b/apps/web/app/app/(dashboard)/[workspaceSlug]/settings/members/invite-table.tsx index 37bdd3b..dbe5aeb 100644 --- a/apps/web/app/app/(dashboard)/[workspaceSlug]/settings/members/invite-table.tsx +++ b/apps/web/app/app/(dashboard)/[workspaceSlug]/settings/members/invite-table.tsx @@ -1,9 +1,8 @@ -import { TrashIcon } from 'lucide-react'; - import { Tables } from '@saasfy/supabase'; -import { Button } from '@saasfy/ui/button'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@saasfy/ui/table'; +import { RemoveInviteButton } from './remove-invite-button'; + export function InviteTable({ invites }: { invites: Tables<'workspace_invites'>[] | null }) { if (!invites?.length) { return
No invites found.
; @@ -28,9 +27,7 @@ export function InviteTable({ invites }: { invites: Tables<'workspace_invites'>[ {invite.role} {invite.expires} - + ))} diff --git a/apps/web/app/app/(dashboard)/[workspaceSlug]/settings/members/remove-invite-button.tsx b/apps/web/app/app/(dashboard)/[workspaceSlug]/settings/members/remove-invite-button.tsx new file mode 100644 index 0000000..7b7f667 --- /dev/null +++ b/apps/web/app/app/(dashboard)/[workspaceSlug]/settings/members/remove-invite-button.tsx @@ -0,0 +1,28 @@ +'use client'; + +import { useParams, useRouter } from 'next/navigation'; + +import { TrashIcon } from 'lucide-react'; + +import { Button } from '@saasfy/ui/button'; + +export function RemoveInviteButton({ inviteId }: { inviteId: string }) { + const { workspaceSlug } = useParams(); + const router = useRouter(); + + return ( + + ); +}