Working on settings Page. Adding init function on next.js startup.

This commit is contained in:
charles-gauthereau
2024-11-16 22:00:22 +01:00
parent b8218dcf85
commit b9a56188ae
16 changed files with 382 additions and 26 deletions
+10 -7
View File
@@ -6,16 +6,19 @@ import {prisma} from "@/prisma";
export default async function Layout({children}: { children: React.ReactNode }) {
const user = await currentUser()
// const userInfo = await prisma.user.findUnique({
// where: {
// email: user?.email
// }
// })
//
if(user){
redirect('/dashboard')
const userInfo = await prisma.user.findUnique({
where: {
email: user?.email
}
})
if(userInfo){
redirect('/dashboard')
}
}
return (
<LayoutAdmin>
<div
+26 -11
View File
@@ -16,20 +16,35 @@ export default async function RoutePage(props: PageParams<{}>) {
<PageTitle>
Agents
</PageTitle>
<PageActions>
<Link href={"/dashboard/agents/new"}>
<Button>+ Create Agent</Button>
</Link>
</PageActions>
{agents.length > 0 && (
<PageActions>
<Link href={"/dashboard/agents/new"}>
<Button>+ Create Agent</Button>
</Link>
</PageActions>
)}
</PageHeader>
<PageContent className="mt-10">
<CardsWithPagination
data={agents}
cardItem={AgentCard}
cardsPerPage={4}
numberOfColumns={1}
/>
{agents.length > 0 ?
<CardsWithPagination
data={agents}
cardItem={AgentCard}
cardsPerPage={4}
numberOfColumns={1}
/>
:
<Link
href="/dashboard/agents/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 Agent
</Link>
}
</PageContent>
</Page>
)
+6 -1
View File
@@ -19,6 +19,11 @@ export default async function RoutePage(props: PageParams<{}>) {
}
})
const settings = await prisma.settings.findUnique({
where:{
name: "system"
}
})
return (
<Page>
@@ -31,7 +36,7 @@ export default async function RoutePage(props: PageParams<{}>) {
Manage your Portabase settings
</PageDescription>
<PageContent>
<SettingsTabs users={users}/>
<SettingsTabs settings={settings} users={users}/>
</PageContent>
</Page>
)