Fix relationship issue

This commit is contained in:
timothycarambat
2023-09-28 19:12:24 -07:00
parent f8ede2afc0
commit cc6bd126c0
3 changed files with 10 additions and 12 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ function organizationEndpoints(app) {
response.sendStatus(403).end();
return;
}
const organizations = await Organization.where({ id: { not: null } });
const organizations = await Organization.where({});
response.status(200).json({ organizations, error: null });
} catch (e) {
console.log(e.message, e);
+8 -10
View File
@@ -87,14 +87,13 @@ const Organization = {
getWithOwner: async function (userId, clause = {}) {
try {
const orgIds = (
await OrganizationUser.where({ user_id: Number(userId) })
).map((record) => record.organization_id);
const result = await prisma.organizations.findFirst({
where: {
...clause,
organization_users: {
every: {
user_id: Number(userId),
},
},
id: { in: orgIds },
},
});
return result;
@@ -135,14 +134,13 @@ const Organization = {
orderBy = null
) {
try {
const orgIds = (
await OrganizationUser.where({ user_id: Number(userId) })
).map((record) => record.organization_id);
const results = await prisma.organizations.findMany({
where: {
id: { in: orgIds },
...clause,
organization_users: {
every: {
user_id: Number(userId),
},
},
},
...(limit ? { take: limit } : {}),
...(orderBy ? { orderBy } : {}),
+1 -1
View File
@@ -329,7 +329,7 @@ export default function Sidebar({
to={paths.organizationSettings(organization)}
className={`group relative flex items-center gap-2.5 rounded-sm px-4 py-2 font-medium text-bodydark1 duration-300 ease-in-out hover:bg-graydark dark:hover:bg-meta-4 ${
(pathname === '/' ||
pathname.includes('users')) &&
pathname.includes('settings')) &&
'bg-graydark dark:bg-meta-4'
}`}
>