Correcting some bugs and working on responsive.

This commit is contained in:
charles-gauthereau
2024-11-23 18:54:47 +01:00
parent 761b4401fc
commit e770fcd1a9
7 changed files with 81 additions and 71 deletions
+10 -8
View File
@@ -12,7 +12,7 @@ export default async function Layout({children}: { children: React.ReactNode })
const user = await currentUser() const user = await currentUser()
console.log(user) console.log(user)
if(user){ if (user) {
const userInfo = await prisma.user.findUnique({ const userInfo = await prisma.user.findUnique({
where: { where: {
email: user?.email email: user?.email
@@ -25,13 +25,15 @@ export default async function Layout({children}: { children: React.ReactNode })
return ( return (
<SidebarProvider> <SidebarProvider>
<AppSidebar/> <div className="flex flex-col lg:flex-row w-full">
<SidebarInset> <AppSidebar/>
<Header/> <SidebarInset>
<main className="h-full"> <Header/>
{children} <main className="h-full">
</main> {children}
</SidebarInset> </main>
</SidebarInset>
</div>
</SidebarProvider> </SidebarProvider>
) )
} }
+7 -2
View File
@@ -27,13 +27,18 @@ export default async function RoutePage(props: PageParams<{}>) {
<AvatarWithUpload user={userInfo}/> <AvatarWithUpload user={userInfo}/>
{user.name} {user.name}
<Badge className="ml-3 hidden lg:block">{userInfo.authMethod}</Badge> <Badge className="ml-3 hidden lg:block">{userInfo.authMethod}</Badge>
<Badge className="ml-3 hidden lg:block">{userInfo.role}</Badge>
</PageTitle> </PageTitle>
<PageActions className={"mt-2"}> <PageActions className="mt-2 hidden sm:block">
<ButtonDeleteAccount text="Delete my account"/> <ButtonDeleteAccount text="Delete my account"/>
</PageActions> </PageActions>
</div> </div>
<PageContent> <PageContent>
<UserForm userId={userInfo.id} defaultValues={userInfo}/> <UserForm userId={userInfo.id} defaultValues={userInfo}/>
<div className="mt-4 sm:hidden">
<ButtonDeleteAccount text="Delete my account" />
</div>
</PageContent> </PageContent>
</Page> </Page>
) )
@@ -17,12 +17,13 @@ export type SettingsTabsProps = {
export const SettingsTabs = (props: SettingsTabsProps) => { export const SettingsTabs = (props: SettingsTabsProps) => {
return( return(
<Tabs defaultValue="informations" > <Tabs defaultValue="informations" >
<TabsList className="w-full" > <TabsList className="w-full">
<TabsTrigger className="w-full" value="informations">Informations</TabsTrigger> <TabsTrigger className="w-full " value="informations">Info</TabsTrigger>
<TabsTrigger className="w-full" value="users">Users</TabsTrigger> <TabsTrigger className="w-full " value="users">Users</TabsTrigger>
<TabsTrigger className="w-full" value="email">Email</TabsTrigger> <TabsTrigger className="w-full " value="email">Email</TabsTrigger>
<TabsTrigger className="w-full" value="storage">Storage</TabsTrigger> <TabsTrigger className="w-full " value="storage">Storage</TabsTrigger>
</TabsList> </TabsList>
<TabsContent value="informations"> <TabsContent value="informations">
<div className="flex flex-1 flex-col gap-4 py-4"> <div className="flex flex-1 flex-col gap-4 py-4">
@@ -34,7 +35,7 @@ export const SettingsTabs = (props: SettingsTabsProps) => {
<div className="min-h-[100vh] flex-1 rounded-xl bg-muted/50 md:min-h-min"/> <div className="min-h-[100vh] flex-1 rounded-xl bg-muted/50 md:min-h-min"/>
</div> </div>
</TabsContent> </TabsContent>
<TabsContent value="users" className="h-full justify-between"> <TabsContent value="users" >
<SettingsUsersTab users={props.users}/> <SettingsUsersTab users={props.users}/>
</TabsContent> </TabsContent>
<TabsContent value="email"> <TabsContent value="email">
@@ -44,5 +45,6 @@ export const SettingsTabs = (props: SettingsTabsProps) => {
<SettingsStorageTab settings={props.settings}/> <SettingsStorageTab settings={props.settings}/>
</TabsContent> </TabsContent>
</Tabs> </Tabs>
) )
} }
@@ -9,6 +9,7 @@ export type SettingsUsersTabProps = {
export const SettingsUsersTab = (props: SettingsUsersTabProps) => { export const SettingsUsersTab = (props: SettingsUsersTabProps) => {
return ( return (
<div className="flex flex-col h-full py-4"> <div className="flex flex-col h-full py-4">
<div className="flex gap-4 h-fit justify-between"> <div className="flex gap-4 h-fit justify-between">
<h1>List of Portabase users</h1> <h1>List of Portabase users</h1>
+44 -41
View File
@@ -7,47 +7,50 @@ export type dataTableProps = {
export const DataTable = ({table}: dataTableProps) => { export const DataTable = ({table}: dataTableProps) => {
return ( return (
<Table> <div className="rounded-md border w-full ">
<TableHeader> <Table className="w-full">
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}> <TableHeader>
{headerGroup.headers.map((header) => { {table.getHeaderGroups().map((headerGroup) => (
return ( <TableRow key={headerGroup.id}>
<TableHead key={header.id}> {headerGroup.headers.map((header) => {
{header.isPlaceholder return (
? null <TableHead key={header.id}>
: flexRender( {header.isPlaceholder
header.column.columnDef.header, ? null
header.getContext() : flexRender(
)} header.column.columnDef.header,
</TableHead> header.getContext()
) )}
})} </TableHead>
</TableRow> )
))} })}
</TableHeader>
<TableBody>
{table.getRowModel().rows?.length ? (
table.getRowModel().rows.map((row) => (
<TableRow
key={row.id}
data-state={row.getIsSelected() && "selected"}
>
{row.getVisibleCells().map((cell) => (
<TableCell key={cell.id}>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</TableCell>
))}
</TableRow> </TableRow>
)) ))}
) : ( </TableHeader>
<TableRow> <TableBody>
<TableCell colSpan={table.getAllColumns().length} className="h-24 text-center"> {table.getRowModel().rows?.length ? (
No results. table.getRowModel().rows.map((row) => (
</TableCell> <TableRow
</TableRow> key={row.id}
)} data-state={row.getIsSelected() && "selected"}
</TableBody> >
</Table> {row.getVisibleCells().map((cell) => (
<TableCell key={cell.id}>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</TableCell>
))}
</TableRow>
))
) : (
<TableRow>
<TableCell colSpan={table.getAllColumns().length} className="h-24 text-center">
No results.
</TableCell>
</TableRow>
)}
</TableBody>
</Table>
</div>
) )
} }
@@ -8,26 +8,24 @@ export type tablePaginationSizeProps = {
pageSizeOptions?: number[] pageSizeOptions?: number[]
} }
export const TablePaginationSize = (props: tablePaginationSizeProps) => { export const TablePaginationSize = (props: tablePaginationSizeProps) => {
const { className, table, pageSizeOptions = [10, 20, 30, 40, 50] } = props;
const {className, table, pageSizeOptions = [10, 20, 30, 40, 50]} = props
useEffect(() => { useEffect(() => {
table.setPageSize(Number(pageSizeOptions[0])) table.setPageSize(Number(pageSizeOptions[0]));
}, []); }, []);
return ( return (
<div className={cn("flex items-center justify-center space-x-2", className)}> <div className={cn("flex items-center justify-end sm:justify-center space-x-2", className)}>
<p className="whitespace-nowrap text-sm font-medium">Rows per page</p> <p className="whitespace-nowrap text-sm font-medium">Rows per page</p>
<Select <Select
value={`${table.getState().pagination.pageSize}`} value={`${table.getState().pagination.pageSize}`}
onValueChange={(value) => { onValueChange={(value) => {
table.setPageSize(Number(value)) table.setPageSize(Number(value));
}} }}
> >
<SelectTrigger className="h-8 w-[4.5rem]"> <SelectTrigger className="h-8 w-[4.5rem]">
<SelectValue placeholder={table.getState().pagination.pageSize}/> <SelectValue placeholder={table.getState().pagination.pageSize} />
</SelectTrigger> </SelectTrigger>
<SelectContent side="top"> <SelectContent side="top">
{pageSizeOptions.map((pageSize) => ( {pageSizeOptions.map((pageSize) => (
@@ -38,6 +36,5 @@ export const TablePaginationSize = (props: tablePaginationSizeProps) => {
</SelectContent> </SelectContent>
</Select> </Select>
</div> </div>
) );
};
}
@@ -16,9 +16,9 @@ export function TablePagination(props: tablePaginationProps) {
const {className, table, maxVisiblePages = 3, pageSizeOptions = [10, 20, 30, 40, 50]} = props const {className, table, maxVisiblePages = 3, pageSizeOptions = [10, 20, 30, 40, 50]} = props
return ( return (
<div className={cn("flex mt-6", className)}> <div className={cn("flex flex-col sm:flex-row mt-6", className)}>
<TablePaginationSize table={table} pageSizeOptions={pageSizeOptions}/> <TablePaginationSize table={table} pageSizeOptions={pageSizeOptions} />
<TablePaginationNavigation table={table} maxVisiblePages={maxVisiblePages} className="justify-end"/> <TablePaginationNavigation table={table} maxVisiblePages={maxVisiblePages} className="justify-end mt-5 sm:mt-0" />
</div> </div>
) );
} }