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}>) {
|
export default async function RoutePage(props: PageParams<{slug: string}>) {
|
||||||
const {slug: organizationSlug} = await props.params
|
const {slug: organizationSlug} = await props.params
|
||||||
|
|
||||||
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
||||||
if(currentOrganizationSlug != organizationSlug) {
|
if(currentOrganizationSlug != organizationSlug) {
|
||||||
notFound()
|
notFound()
|
||||||
|
|||||||
@@ -14,12 +14,6 @@ export default async function RoutePage(props: PageParams<{slug: string}>) {
|
|||||||
const {slug: organizationSlug} = await props.params
|
const {slug: organizationSlug} = await props.params
|
||||||
|
|
||||||
|
|
||||||
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
|
||||||
|
|
||||||
// if(currentOrganizationSlug != organizationSlug) {
|
|
||||||
// notFound()
|
|
||||||
// }
|
|
||||||
|
|
||||||
const projects = await prisma.project.findMany({
|
const projects = await prisma.project.findMany({
|
||||||
where: {
|
where: {
|
||||||
isArchived: {not: true},
|
isArchived: {not: true},
|
||||||
@@ -46,7 +40,7 @@ export default async function RoutePage(props: PageParams<{slug: string}>) {
|
|||||||
</PageTitle>
|
</PageTitle>
|
||||||
{projects.length > 0 && (
|
{projects.length > 0 && (
|
||||||
<PageActions>
|
<PageActions>
|
||||||
<Link href={`/dashboard/${currentOrganizationSlug}/projects/new`}>
|
<Link href={`/dashboard/${organizationSlug}/projects/new`}>
|
||||||
<Button>+ Create Project</Button>
|
<Button>+ Create Project</Button>
|
||||||
</Link>
|
</Link>
|
||||||
</PageActions>
|
</PageActions>
|
||||||
@@ -58,7 +52,7 @@ export default async function RoutePage(props: PageParams<{slug: string}>) {
|
|||||||
|
|
||||||
{projects.length > 0 ?
|
{projects.length > 0 ?
|
||||||
<CardsWithPagination
|
<CardsWithPagination
|
||||||
organizationSlug={currentOrganizationSlug}
|
organizationSlug={organizationSlug}
|
||||||
data={projects}
|
data={projects}
|
||||||
cardItem={ProjectCard}
|
cardItem={ProjectCard}
|
||||||
cardsPerPage={4}
|
cardsPerPage={4}
|
||||||
@@ -66,7 +60,7 @@ export default async function RoutePage(props: PageParams<{slug: string}>) {
|
|||||||
/>
|
/>
|
||||||
:
|
:
|
||||||
<Link
|
<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">
|
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
|
Create new Project
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -3,22 +3,15 @@ import {redirect} from "next/navigation";
|
|||||||
|
|
||||||
import {SidebarInset, SidebarProvider} from "@/components/ui/sidebar"
|
import {SidebarInset, SidebarProvider} from "@/components/ui/sidebar"
|
||||||
import {AppSidebar} from "@/components/wrappers/dashboard/sideBar/app-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 {Header} from "@/features/layout/Header";
|
||||||
import {prisma} from "@/prisma";
|
import {prisma} from "@/prisma";
|
||||||
|
|
||||||
|
|
||||||
export default async function Layout({children}: { children: React.ReactNode }) {
|
export default async function Layout({children}: { children: React.ReactNode }) {
|
||||||
|
|
||||||
const user = await currentUser()
|
const user = await requiredCurrentUser()
|
||||||
if (user) {
|
|
||||||
const userInfo = await prisma.user.findUnique({
|
|
||||||
where: {
|
|
||||||
email: user?.email
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (!userInfo) redirect('/login')
|
|
||||||
}
|
|
||||||
if (!user) redirect('/login')
|
if (!user) redirect('/login')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ export default async function Index() {
|
|||||||
const user = await currentUser()
|
const user = await currentUser()
|
||||||
if (user) {
|
if (user) {
|
||||||
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
||||||
console.log(currentOrganizationSlug)
|
|
||||||
redirect(`/dashboard/${currentOrganizationSlug}/projects`)
|
redirect(`/dashboard/${currentOrganizationSlug}/projects`)
|
||||||
}
|
}
|
||||||
redirect("/login")
|
redirect("/login")
|
||||||
|
|||||||
+1
-21
@@ -1,26 +1,6 @@
|
|||||||
import {redirect, useRouter} from "next/navigation";
|
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() {
|
export default async function NotFound() {
|
||||||
|
console.log("not found");
|
||||||
// const user = await currentUser()
|
|
||||||
// if (!user) {
|
|
||||||
// redirect("/")
|
|
||||||
// }else{
|
|
||||||
// redirect("/")
|
|
||||||
// }
|
|
||||||
|
|
||||||
redirect("/")
|
redirect("/")
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user