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