mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Correcting some bugs in statistics.
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
import React from "react";
|
||||
import {getCurrentOrganizationSlug} from "@/features/dashboard/organization-cookie";
|
||||
import {notFound, redirect} from "next/navigation";
|
||||
|
||||
|
||||
export default async function Layout({children, params}: { children: React.ReactNode , params: { slug: string };}) {
|
||||
const {slug: organizationSlug} = await params
|
||||
console.log(organizationSlug);
|
||||
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
||||
console.log(currentOrganizationSlug);
|
||||
if(currentOrganizationSlug != organizationSlug) {
|
||||
redirect("charles")
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import {redirect, useRouter} from "next/navigation";
|
||||
import {useEffect} from "react";
|
||||
import {currentUser} from "@/auth/current-user";
|
||||
|
||||
// export default function NotFound() {
|
||||
//
|
||||
// const router = useRouter();
|
||||
//
|
||||
// useEffect(() => {
|
||||
// router.push('/');
|
||||
// }, [router]);
|
||||
//
|
||||
// return null; // You can return null or a loading spinner while the redirect happens
|
||||
// }
|
||||
|
||||
export default async function NotFound() {
|
||||
|
||||
// const user = await currentUser()
|
||||
// if (!user) {
|
||||
// redirect("/")
|
||||
// }else{
|
||||
// redirect("/")
|
||||
// }
|
||||
|
||||
redirect("/dashboard/default")
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import {getCurrentOrganizationSlug} from "@/features/dashboard/organization-cook
|
||||
|
||||
export default async function RoutePage(props: PageParams<{slug: string}>) {
|
||||
const {slug: organizationSlug} = await props.params
|
||||
|
||||
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
||||
if(currentOrganizationSlug != organizationSlug) {
|
||||
notFound()
|
||||
|
||||
@@ -14,12 +14,6 @@ export default async function RoutePage(props: PageParams<{slug: string}>) {
|
||||
const {slug: organizationSlug} = await props.params
|
||||
|
||||
|
||||
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
||||
|
||||
// if(currentOrganizationSlug != organizationSlug) {
|
||||
// notFound()
|
||||
// }
|
||||
|
||||
const projects = await prisma.project.findMany({
|
||||
where: {
|
||||
isArchived: {not: true},
|
||||
@@ -46,7 +40,7 @@ export default async function RoutePage(props: PageParams<{slug: string}>) {
|
||||
</PageTitle>
|
||||
{projects.length > 0 && (
|
||||
<PageActions>
|
||||
<Link href={`/dashboard/${currentOrganizationSlug}/projects/new`}>
|
||||
<Link href={`/dashboard/${organizationSlug}/projects/new`}>
|
||||
<Button>+ Create Project</Button>
|
||||
</Link>
|
||||
</PageActions>
|
||||
@@ -58,7 +52,7 @@ export default async function RoutePage(props: PageParams<{slug: string}>) {
|
||||
|
||||
{projects.length > 0 ?
|
||||
<CardsWithPagination
|
||||
organizationSlug={currentOrganizationSlug}
|
||||
organizationSlug={organizationSlug}
|
||||
data={projects}
|
||||
cardItem={ProjectCard}
|
||||
cardsPerPage={4}
|
||||
@@ -66,7 +60,7 @@ export default async function RoutePage(props: PageParams<{slug: string}>) {
|
||||
/>
|
||||
:
|
||||
<Link
|
||||
href={`/dashboard/${currentOrganizationSlug}/projects/new`}
|
||||
href={`/dashboard/${organizationSlug}/projects/new`}
|
||||
className=" flex item-center justify-center border-2 border-dashed transition-colors border-primary p-8 lg:p-12 w-full rounded-md">
|
||||
Create new Project
|
||||
</Link>
|
||||
|
||||
@@ -3,22 +3,15 @@ import {redirect} from "next/navigation";
|
||||
|
||||
import {SidebarInset, SidebarProvider} from "@/components/ui/sidebar"
|
||||
import {AppSidebar} from "@/components/wrappers/dashboard/sideBar/app-sidebar";
|
||||
import {currentUser} from "@/auth/current-user";
|
||||
import {currentUser, requiredCurrentUser} from "@/auth/current-user";
|
||||
import {Header} from "@/features/layout/Header";
|
||||
import {prisma} from "@/prisma";
|
||||
|
||||
|
||||
export default async function Layout({children}: { children: React.ReactNode }) {
|
||||
|
||||
const user = await currentUser()
|
||||
if (user) {
|
||||
const userInfo = await prisma.user.findUnique({
|
||||
where: {
|
||||
email: user?.email
|
||||
}
|
||||
})
|
||||
if (!userInfo) redirect('/login')
|
||||
}
|
||||
const user = await requiredCurrentUser()
|
||||
|
||||
if (!user) redirect('/login')
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user