From 7196a6437042ad51693d7daac20359f218d55707 Mon Sep 17 00:00:00 2001 From: amimaro Date: Thu, 24 Jul 2025 19:29:32 -0300 Subject: [PATCH 1/2] fix: remove team member action display condition --- app/(dashboard)/dashboard/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/(dashboard)/dashboard/page.tsx b/app/(dashboard)/dashboard/page.tsx index 60475a8587..70b567f014 100644 --- a/app/(dashboard)/dashboard/page.tsx +++ b/app/(dashboard)/dashboard/page.tsx @@ -153,7 +153,7 @@ function TeamMembers() {

- {index > 1 ? ( + {index >= 1 ? (
-
- ) : null} - + ))} - {removeState?.error && ( -

{removeState.error}

- )} ); } +function TeamMemberRow({ + member, + index, +}: { + member: TeamMemberWithUser; + index: number; +}) { + const [visible, setVisible] = useState(true); + const [removeState, removeAction, isRemovePending] = useActionState< + ActionState, + FormData + >(async (actionState,formData) => { + const result = await removeTeamMember(actionState,formData); + if ('success' in result && typeof result.success !== 'undefined') { + setVisible(false); + } + return result; + }, {}); + + const getUserDisplayName = (user: Pick) => { + return user.name || user.email || "Unknown User"; + }; + + if (!visible) return null; + + return ( +
  • +
    + + {/* + This app doesn't save profile images, but here + is how you'd show them: + + + */} + + {getUserDisplayName(member.user) + .split(' ') + .map((n) => n[0]) + .join('')} + + +
    +

    + {getUserDisplayName(member.user)} +

    +

    + {member.role} +

    +
    +
    + {index > 0 && ( +
    +
    + + +
    + {removeState?.error && ( +

    {removeState.error}

    + )} +
    + )} +
  • + ); +} + function InviteTeamMemberSkeleton() { return ( diff --git a/app/(login)/actions.ts b/app/(login)/actions.ts index 532adc0ef4..1791a6a2e5 100644 --- a/app/(login)/actions.ts +++ b/app/(login)/actions.ts @@ -359,7 +359,7 @@ export const updateAccount = validatedActionWithUser( ); const removeTeamMemberSchema = z.object({ - memberId: z.number() + memberId: z.string().transform((val) => Number(val)), }); export const removeTeamMember = validatedActionWithUser( diff --git a/lib/db/schema.ts b/lib/db/schema.ts index 1d047ce661..25162b91af 100644 --- a/lib/db/schema.ts +++ b/lib/db/schema.ts @@ -122,10 +122,11 @@ export type ActivityLog = typeof activityLogs.$inferSelect; export type NewActivityLog = typeof activityLogs.$inferInsert; export type Invitation = typeof invitations.$inferSelect; export type NewInvitation = typeof invitations.$inferInsert; +export type TeamMemberWithUser = TeamMember & { + user: Pick; +}; export type TeamDataWithMembers = Team & { - teamMembers: (TeamMember & { - user: Pick; - })[]; + teamMembers: TeamMemberWithUser[]; }; export enum ActivityType {