-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b349b48
commit ead95a7
Showing
23 changed files
with
1,360 additions
and
900 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React, { FC, useState } from 'react'; | ||
import { | ||
Card, | ||
CardBody, | ||
Button, | ||
Image, | ||
Progress, | ||
CardProps, | ||
Slider, | ||
CardFooter, | ||
Link, | ||
Tabs, | ||
Tab, | ||
Dropdown, | ||
DropdownTrigger, | ||
DropdownMenu, | ||
DropdownItem, | ||
Navbar, | ||
NavbarContent, | ||
NavbarItem, | ||
ButtonProps, | ||
LinkProps, | ||
Breadcrumbs as NBreadcrumbs, | ||
BreadcrumbItem as NBreadcrumbItem, | ||
} from '@nextui-org/react'; | ||
import clsx from 'clsx'; | ||
import { Icon } from '@iconify/react'; | ||
|
||
import { NavLink, NavLinkProps, useLocation, useNavigate, useParams } from 'react-router-dom'; | ||
|
||
interface ISideBarItemProps { | ||
icon?: React.ReactNode; | ||
to: string; | ||
} | ||
|
||
const SideBarItem = (props: ButtonProps & NavLinkProps) => { | ||
return ( | ||
<NavLink to={props.to} className='w-full'> | ||
{({ isActive }) => ( | ||
<Button | ||
startContent={<Icon icon='solar:home-2-broken' />} | ||
variant='light' | ||
className='justify-start' | ||
fullWidth | ||
{...props} | ||
></Button> | ||
)} | ||
</NavLink> | ||
); | ||
}; | ||
|
||
const SideBar = () => { | ||
return ( | ||
<Card className='flex flex-shrink-0 pt-10'> | ||
<CardBody className='py-[10vh flex w-32 overflow-y-auto p-0'> | ||
<div className='relative flex w-full list-none flex-col gap-1 p-1'> | ||
<div className='flex w-full flex-col items-center gap-0.5 outline-none'> | ||
<SideBarItem to='/parts'>parts</SideBarItem> | ||
<SideBarItem to='/products'>Products</SideBarItem> | ||
<SideBarItem to='/test'>Home</SideBarItem> | ||
</div> | ||
</div> | ||
</CardBody> | ||
<CardFooter> | ||
<div>card footer</div> | ||
</CardFooter> | ||
</Card> | ||
); | ||
}; | ||
|
||
const Breadcrumbs = () => { | ||
return ( | ||
<NBreadcrumbs> | ||
<NBreadcrumbItem>Home</NBreadcrumbItem> | ||
<NBreadcrumbItem>Tast</NBreadcrumbItem> | ||
</NBreadcrumbs> | ||
); | ||
// return | ||
}; | ||
|
||
type IMainLayoutProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
export const MainLayout = ({ children }: IMainLayoutProps) => { | ||
return ( | ||
<div className='relative flex h-screen overflow-hidden bg-background text-foreground dark'> | ||
<SideBar /> | ||
|
||
<main className='relative flex w-full flex-1 flex-col gap-y-4 p-4'> | ||
<Breadcrumbs /> | ||
{children} | ||
</main> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './MainLayout'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './useGetPartsList'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { QueryResult, QueryData, QueryError } from '@supabase/supabase-js'; | ||
|
||
import { Tables } from '@/types/database.types'; | ||
|
||
import { supabase } from '@/lib/supabase'; | ||
import { useQuery } from '@supabase-cache-helpers/postgrest-react-query'; | ||
import { TypedSupabaseClient } from '@/types'; | ||
// import { useQuery } from '@tanstack/react-query'; | ||
|
||
export type IPartsList = Tables<'parts'>[]; | ||
|
||
export const getParts = (client: TypedSupabaseClient, id: number) => { | ||
return client.from('parts').select(`id,name`, { count: 'exact' }).eq('id', id).throwOnError(); | ||
}; | ||
|
||
export const useGetPartsList = () => { | ||
return useQuery(getParts(supabase, 1)); | ||
}; | ||
|
||
// import { QueryResult, QueryData, QueryError } from '@supabase/supabase-js' | ||
|
||
// const countriesWithCitiesQuery = supabase.from('countries').select(` | ||
// id, | ||
// name, | ||
// cities ( | ||
// id, | ||
// name | ||
// ) | ||
// `) | ||
// type CountriesWithCities = QueryData<typeof countriesWithCitiesQuery> | ||
|
||
// const { data, error } = await countriesWithCitiesQuery | ||
// if (error) throw error | ||
// const countriesWithCities: CountriesWithCities = data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './routes'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useQuery } from '@supabase-cache-helpers/postgrest-react-query'; | ||
import { getParts, useGetPartsList } from '../hooks'; | ||
import { supabase } from '@/lib/supabase'; | ||
|
||
export const PartsList = () => { | ||
const { data, isLoading } = useGetPartsList(); | ||
|
||
if (isLoading) return <div>loading</div>; | ||
|
||
return <div>{data?.map((x) => <div key={x.id}>{x.name}</div>)}</div>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Route, Routes } from 'react-router-dom'; | ||
|
||
import { PartsList } from './PartsList'; | ||
|
||
export const PartsRoutes = () => { | ||
return ( | ||
<Routes> | ||
<Route path='' element={<PartsList />} /> | ||
</Routes> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './routes'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const ProductsList = () => { | ||
return <div>Products list</div>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Route, Routes } from 'react-router-dom'; | ||
|
||
import { ProductsList } from './ProductsList'; | ||
|
||
export const ProductsRoutes = () => { | ||
return ( | ||
<Routes> | ||
<Route path='' element={<ProductsList />} /> | ||
</Routes> | ||
); | ||
}; |
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,39 @@ | ||
export const protectedRoutes = []; | ||
import { Suspense } from 'react'; | ||
import { Outlet, RouteObject } from 'react-router-dom'; | ||
|
||
import { MainLayout } from '@/components/Layout'; | ||
import { lazyImport } from '@/utils'; | ||
|
||
const { PartsRoutes } = lazyImport(() => import('@/features/parts'), 'PartsRoutes'); | ||
const { ProductsRoutes } = lazyImport(() => import('@/features/products'), 'ProductsRoutes'); | ||
|
||
const App = () => { | ||
return ( | ||
<MainLayout> | ||
<Suspense> | ||
<Outlet></Outlet> | ||
</Suspense> | ||
</MainLayout> | ||
); | ||
}; | ||
|
||
export const protectedRoutes: RouteObject[] = [ | ||
{ | ||
path: '/', | ||
element: <App />, | ||
children: [ | ||
{ | ||
path: '/test', | ||
element: <div>test</div>, | ||
}, | ||
{ | ||
path: '/parts', | ||
element: <PartsRoutes />, | ||
}, | ||
{ | ||
path: '/products', | ||
element: <ProductsRoutes />, | ||
}, | ||
], | ||
}, | ||
]; |
Oops, something went wrong.