-
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
8311e35
commit 2eea4a1
Showing
9 changed files
with
163 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use client"; | ||
|
||
import { useGetCategories } from "@/types/generated/category"; | ||
|
||
import CategoriesItem from "@/containers/categories/item"; | ||
|
||
import { Accordion } from "@/components/ui/accordion"; | ||
|
||
const Categories = () => { | ||
const { data: categoriesData } = useGetCategories({ | ||
"pagination[pageSize]": 100, | ||
}); | ||
|
||
return ( | ||
<Accordion | ||
type="multiple" | ||
className="mt-5" | ||
defaultValue={categoriesData?.data?.data?.map((c) => `${c?.id}`)} | ||
> | ||
{categoriesData?.data?.data?.map((category) => { | ||
if (!category.id) return null; | ||
|
||
return <CategoriesItem key={category.id} {...category} />; | ||
})} | ||
</Accordion> | ||
); | ||
}; | ||
|
||
export default Categories; |
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,20 @@ | ||
"use client"; | ||
|
||
import { CategoryListResponseDataItem } from "@/types/generated/strapi.schemas"; | ||
|
||
import Datasets from "@/containers/datasets"; | ||
|
||
import { AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"; | ||
|
||
const CategoriesItem = (category: CategoryListResponseDataItem) => { | ||
return ( | ||
<AccordionItem key={category?.id} value={`${category?.id}`}> | ||
<AccordionTrigger>{category?.attributes?.name}</AccordionTrigger> | ||
<AccordionContent> | ||
{!!category?.id && <Datasets categoryId={category?.id} />} | ||
</AccordionContent> | ||
</AccordionItem> | ||
); | ||
}; | ||
|
||
export default CategoriesItem; |
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,29 @@ | ||
"use client"; | ||
|
||
import { useGetDatasets } from "@/types/generated/dataset"; | ||
|
||
import DatasetsItem from "@/containers/datasets/item"; | ||
|
||
type DatasetsProps = { | ||
categoryId: number; | ||
}; | ||
|
||
const Datasets = ({ categoryId }: DatasetsProps) => { | ||
const { data: datasetsData } = useGetDatasets({ | ||
"pagination[pageSize]": 100, | ||
filters: { | ||
category: categoryId, | ||
}, | ||
populate: "*", | ||
}); | ||
|
||
return ( | ||
<div className="space-y-2.5"> | ||
{datasetsData?.data?.data?.map((dataset) => { | ||
return <DatasetsItem key={dataset?.id} {...dataset} />; | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Datasets; |
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,52 @@ | ||
"use client"; | ||
|
||
import { LuInfo } from "react-icons/lu"; | ||
|
||
import { DatasetListResponseDataItem } from "@/types/generated/strapi.schemas"; | ||
|
||
import { useSyncLayers } from "@/app/url-query-params"; | ||
|
||
import { Switch } from "@/components/ui/switch"; | ||
|
||
const DatasetsItem = ({ id, attributes }: DatasetListResponseDataItem) => { | ||
const lysIds = attributes?.layers?.data?.map((l) => l.id); | ||
const [layers, setLayers] = useSyncLayers(); | ||
|
||
return ( | ||
<div | ||
key={id} | ||
className="flex items-center justify-between space-x-2.5 rounded-[18px] border p-2.5" | ||
> | ||
<div className="flex items-center justify-start space-x-2.5"> | ||
<Switch | ||
defaultChecked={layers?.some((l) => lysIds?.includes(l))} | ||
onCheckedChange={(c: boolean) => { | ||
const lys = attributes?.layers; | ||
|
||
if (!lys) return; | ||
|
||
setLayers((prev) => { | ||
const ids = lys?.data?.map((l) => { | ||
return l.id as number; | ||
}); | ||
|
||
if (c && ids) return [...ids, ...prev]; | ||
if (!c && ids) { | ||
return prev.filter((id) => !ids.includes(id)); | ||
} | ||
|
||
return prev; | ||
}); | ||
}} | ||
/> | ||
<div> | ||
<h2>{attributes?.name}</h2> | ||
</div> | ||
</div> | ||
|
||
<LuInfo className="h-5 w-5" /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DatasetsItem; |
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