feat: order members by role and createdAt
This commit is contained in:
@@ -83,7 +83,8 @@ export const workspaceRouter = createTRPCRouter({
|
||||
const isAdmin = userMember?.role === "admin";
|
||||
|
||||
// Show emails if user is admin OR workspace setting allows it
|
||||
const shouldShowEmails = isAdmin || result.showEmailsToMembers === true;
|
||||
const shouldShowEmails =
|
||||
isAdmin || result.showEmailsToMembers === true;
|
||||
|
||||
// If emails should be hidden, filter them out
|
||||
if (!shouldShowEmails) {
|
||||
|
||||
@@ -194,8 +194,13 @@ export const getByPublicIdWithMembers = (
|
||||
email: true,
|
||||
role: true,
|
||||
status: true,
|
||||
createdAt: true,
|
||||
},
|
||||
where: isNull(workspaceMembers.deletedAt),
|
||||
orderBy: (member, { desc }) => [
|
||||
desc(sql`CASE WHEN ${member.role} = 'admin' THEN 1 ELSE 0 END`),
|
||||
desc(member.createdAt),
|
||||
],
|
||||
with: {
|
||||
user: {
|
||||
columns: {
|
||||
|
||||
Reference in New Issue
Block a user