mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Getting organization by slug, adding this in url. And working on permissions.
This commit is contained in:
+11
-4
@@ -7,19 +7,26 @@ import {Button} from "@/components/ui/button";
|
||||
import {Page, PageActions, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
import {ProjectCard} from "@/components/wrappers/dashboard/projects/ProjectCard/ProjectCard";
|
||||
import {requiredCurrentUser} from "@/auth/current-user";
|
||||
import {getCurrentOrganizationId} from "@/features/dashboard/organization-cookie";
|
||||
import {getCurrentOrganizationSlug} from "@/features/dashboard/organization-cookie";
|
||||
import {currentOrganization} from "@/auth/current-organization";
|
||||
import {notFound} from "next/navigation";
|
||||
|
||||
|
||||
export default async function RoutePage(props: PageParams<{}>) {
|
||||
export default async function RoutePage(props: PageParams<{slug: string}>) {
|
||||
const {slug: organizationSlug} = await props.params
|
||||
|
||||
const user = await requiredCurrentUser()
|
||||
|
||||
const currentOrganizationId = await getCurrentOrganizationId()
|
||||
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
||||
|
||||
if(currentOrganizationSlug != organizationSlug) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
const projects = await prisma.project.findMany({
|
||||
where: {
|
||||
organization: {
|
||||
id: currentOrganizationId,
|
||||
slug: organizationSlug,
|
||||
// users: {
|
||||
// some: {
|
||||
// userId: user.id
|
||||
+10
-5
@@ -3,7 +3,7 @@ import {PageParams} from "@/types/next";
|
||||
import {Page, PageActions, PageContent, PageDescription, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
import {requiredCurrentUser} from "@/auth/current-user";
|
||||
import {SettingsTabs} from "@/components/wrappers/dashboard/settings/SettingsTabs/SettingsTabs";
|
||||
import {getCurrentOrganizationId} from "@/features/dashboard/organization-cookie";
|
||||
import {getCurrentOrganizationId, getCurrentOrganizationSlug} from "@/features/dashboard/organization-cookie";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {ButtonWithConfirm} from "@/components/wrappers/common/button/button-with-confirm";
|
||||
import {
|
||||
@@ -14,13 +14,19 @@ import {
|
||||
export default async function RoutePage(props: PageParams<{}>) {
|
||||
const user = await requiredCurrentUser()
|
||||
|
||||
const currentOrganizationId = await getCurrentOrganizationId()
|
||||
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
||||
|
||||
const organization = await prisma.organization.findUnique({
|
||||
where:{
|
||||
slug: currentOrganizationSlug,
|
||||
}
|
||||
})
|
||||
|
||||
const users = await prisma.user.findMany({
|
||||
where: {
|
||||
organizations: {
|
||||
some: {
|
||||
organizationId: currentOrganizationId
|
||||
organizationId: organization.id
|
||||
},
|
||||
},
|
||||
deleted: {not: true},
|
||||
@@ -28,7 +34,6 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
}
|
||||
})
|
||||
|
||||
console.log(currentOrganizationId)
|
||||
|
||||
const settings = await prisma.settings.findUnique({
|
||||
where: {
|
||||
@@ -44,7 +49,7 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
</PageTitle>
|
||||
<PageActions>
|
||||
{/*<Button variant="destructive">Delete Organization</Button>*/}
|
||||
<DeleteOrganizationButton organizationId={currentOrganizationId}/>
|
||||
<DeleteOrganizationButton organizationSlug={currentOrganizationSlug}/>
|
||||
</PageActions>
|
||||
</PageHeader>
|
||||
<PageDescription>
|
||||
@@ -1,6 +1,9 @@
|
||||
import {PageParams} from "@/types/next";
|
||||
import {redirect} from "next/navigation";
|
||||
import {getCurrentOrganizationSlug} from "@/features/dashboard/organization-cookie";
|
||||
|
||||
export default async function RoutePage(props: PageParams<{}>) {
|
||||
redirect("/dashboard/projects")
|
||||
|
||||
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
||||
redirect(`/dashboard/${currentOrganizationSlug}/projects`)
|
||||
}
|
||||
Reference in New Issue
Block a user