update all deps
This commit is contained in:
@@ -2,25 +2,15 @@
|
||||
import { useGSAP } from "@gsap/react";
|
||||
import { useGsapContext } from "../_providers/GsapProvicer";
|
||||
import { trpc } from "../_trpc/Client";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { SidebarContent, SidebarProvider, Sidebar } from "~/components/ui/sidebar";
|
||||
import { useRef } from "react";
|
||||
import { SidebarContent, SidebarProvider, Sidebar } from "~/components/ui/sidebar";
|
||||
import SidebarTriggerDisappearsOnMobile from "./_components/SidebarTriggerDisappearsOnMobile";
|
||||
import CvCategory from "./_components/CvCategory";
|
||||
import type { CategoryRouterOutputs } from "~/server/routers/cv/category";
|
||||
export default function CvPage() {
|
||||
const [sidebarCategories,setSidebarCategories] = useState<CategoryRouterOutputs['list']>([]);
|
||||
const [headerCategories,setHeaderCategories] = useState<CategoryRouterOutputs['list']>([]);
|
||||
const [col1Categories,setCol1Categories] = useState<CategoryRouterOutputs['list']>([]);
|
||||
const [col2Categories,setCol2Categories] = useState<CategoryRouterOutputs['list']>([]);
|
||||
const categories = trpc.cv.category.list.useQuery();
|
||||
useEffect(() => {
|
||||
if (categories.data !== undefined) {
|
||||
setSidebarCategories(categories.data.filter((cat) => cat.layoutPosition == "sidebar"))
|
||||
setHeaderCategories(categories.data.filter((cat) => cat.layoutPosition == "header"))
|
||||
setCol1Categories(categories.data.filter((cat) => cat.layoutPosition == "col1"))
|
||||
setCol2Categories(categories.data.filter((cat) => cat.layoutPosition == "col2"))
|
||||
}
|
||||
},[categories.data])
|
||||
const sidebarCategories = trpc.categoryv2.listByLayoutPosition.useQuery("sidebar");
|
||||
const col1Categories = trpc.categoryv2.listByLayoutPosition.useQuery("col1");
|
||||
const headerCategories = trpc.categoryv2.listByLayoutPosition.useQuery("header");
|
||||
const col2Categories = trpc.categoryv2.listByLayoutPosition.useQuery("col2");
|
||||
const gsap = useGsapContext()
|
||||
const container = useRef<HTMLDivElement>(null)
|
||||
enum Direction {
|
||||
@@ -53,66 +43,55 @@ export default function CvPage() {
|
||||
dir = dir + 1
|
||||
}
|
||||
})
|
||||
}, { scope: container, dependencies: [col1Categories,col2Categories,headerCategories,sidebarCategories], revertOnUpdate: true })
|
||||
if (categories.data !== undefined) {
|
||||
return (
|
||||
<>
|
||||
<SidebarProvider ref={container}>
|
||||
{categories.data.filter((cat) => cat.layoutPosition == 'sidebar').length > 0 ?
|
||||
<>
|
||||
<SidebarTriggerDisappearsOnMobile />
|
||||
<Sidebar className="gsapan ">
|
||||
<SidebarContent className="p-2 lg:pt-[3.2rem]">
|
||||
{sidebarCategories.map((cat) => {
|
||||
}, { scope: container, dependencies: [headerCategories.data, sidebarCategories.data], revertOnUpdate: true })
|
||||
return (
|
||||
<>
|
||||
<SidebarProvider ref={container}>
|
||||
{(sidebarCategories.data?.length ? sidebarCategories.data?.length : 0) > 0 ?
|
||||
<>
|
||||
<SidebarTriggerDisappearsOnMobile />
|
||||
<Sidebar className="gsapan ">
|
||||
<SidebarContent className="p-2 lg:pt-[3.2rem]">
|
||||
{sidebarCategories.data?.map((cat) => {
|
||||
if (cat !== undefined) {
|
||||
return (
|
||||
<CvCategory layout="col" initialData={cat} key={cat.id} />
|
||||
)
|
||||
})}
|
||||
</SidebarContent>
|
||||
</Sidebar>
|
||||
</> :
|
||||
<></>
|
||||
}
|
||||
<div className="h-full w-full flex flex-wrap flex-row p-[1rem] pt-[2rem] ">
|
||||
<div id="mainwrap" className="flex w-full flex-col gap-[1rem] lg:px-[15vw]">
|
||||
<div id="header" className="flex w-full h-fit flex-row gap-[1rem] flex-wrap">
|
||||
{headerCategories.map((cat) => {
|
||||
}
|
||||
})}
|
||||
</SidebarContent>
|
||||
</Sidebar>
|
||||
</> :
|
||||
<></>
|
||||
}
|
||||
<div className="h-full w-full flex flex-wrap flex-row p-4 pt-8 ">
|
||||
<div id="mainwrap" className="flex w-full flex-col gap-4 lg:px-[15vw]">
|
||||
<div id="header" className="flex w-full h-fit flex-row gap-4 flex-wrap">
|
||||
{headerCategories.data?.map((cat) => {
|
||||
return (
|
||||
<CvCategory layout="row" initialData={cat} key={cat.id} />
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
<div id="colwrapper" className="flex flex-col lg:flex-row w-full h-3/4 gap-4">
|
||||
<div id="col1" className={`flex flex-col w-full ${col1Categories.data?.length ? col1Categories.data?.length : 0 > 0 ? "lg:w-1/2" : ""} h-full gap-4`}>
|
||||
{col1Categories.data?.map((cat) => {
|
||||
return (
|
||||
<CvCategory layout="row" initialData={cat} key={cat.id} />
|
||||
<CvCategory layout="col" initialData={cat} key={cat.id} />
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
<div id="colwrapper" className="flex flex-col lg:flex-row w-full h-3/4 gap-[1rem]">
|
||||
{col1Categories.length > 0 ?
|
||||
<div id="col1" className={`flex flex-col w-full ${col2Categories.length > 0 ? "lg:w-1/2" : ""} h-full gap-[1rem]`}>
|
||||
{col1Categories.map((cat) => {
|
||||
return (
|
||||
<CvCategory layout="col" initialData={cat} key={cat.id} />
|
||||
)
|
||||
})}
|
||||
</div> :
|
||||
<></>
|
||||
}
|
||||
{col2Categories.length > 0 ?
|
||||
<div id="col2" className={`flex flex-col w-full ${col1Categories.length > 0 ? "lg:w-1/2" : ""} h-full gap-[1rem]`}>
|
||||
{col2Categories.map((cat) => {
|
||||
return (
|
||||
<CvCategory layout="col" initialData={cat} key={cat.id} />
|
||||
)
|
||||
})}
|
||||
</div> :
|
||||
<></>
|
||||
}
|
||||
<div id="col2" className={`flex flex-col w-full ${col2Categories.data?.length ? col2Categories.data?.length : 0 > 0 ? "lg:w-1/2" : ""} h-full gap-4`}>
|
||||
{col2Categories.data?.map((cat) => {
|
||||
return (
|
||||
<CvCategory layout="col" initialData={cat} key={cat.id} />
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</SidebarProvider>
|
||||
</>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<>
|
||||
</>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
</SidebarProvider>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user