diff --git a/frontend/editor2d/src/GalleryRootComponent/GalleryRootComponent.tsx b/frontend/editor2d/src/GalleryRootComponent/GalleryRootComponent.tsx new file mode 100644 index 0000000000..ad2ca09538 --- /dev/null +++ b/frontend/editor2d/src/GalleryRootComponent/GalleryRootComponent.tsx @@ -0,0 +1,118 @@ +import { faFolder } from "@fortawesome/pro-solid-svg-icons" +import { useEffect, useState } from "react"; +import { Button } from "~/components/ui" + +const testUrl = "https://api.fakeyou.com/v1/media_files/list/user/hanashi?include_user_uploads=true&page_size=24&filter_media_classes=unknown"; +const getTestData = (callback: (data: any) => void) => { + const netCall = async () => { + // GET the test url + const testResults = await fetch(testUrl); + const testJson = await testResults.json(); + console.log("testResults", testJson); + return testJson; + } + + netCall().then(callback); +} + +export const GalleryRootComponent = ({ + className +}: { + className?: string +}) => { + + const [testData, setTestData] = useState(); + + useEffect(() => { + getTestData(setTestData); + }, []) + + const aggregatedData = aggregateGalleryData({ data: testData }); + + return ( +
+
+
+ My Gallery + +
+
+ {Array.from(aggregatedData.entries()).map(([dateEpoch, results]) => ())} +
+
+
+ ) +} + +const GallerySection = ({ + dateEpoch, + results +}: { + dateEpoch: number, + results: any[] +}) => { + + const dateObj = new Date(dateEpoch); + const title = dateObj.toLocaleDateString("en-US", { + year: "numeric", + month: "long", + day: "numeric" + }); + + return ( +
+ {title} +
+ {results.map((result) => ())} +
+
+ ) +} + +const GalleryCard = ({ result }: { + result: { + media_links: { + cdn_url: string, + maybe_thumbnail_template: string, + }, + } +}) => { + return ( +
+ Thumbnail +
+ ) +} + +const aggregateGalleryData = ({ + data +}: { + data?: { + results: any[] + } +}) => { + const aggregateMap = new Map(); + + if (!data) { + return aggregateMap; + } + + data.results.forEach((result) => { + const dateString = result.updated_at as string; + const dateObj = new Date(dateString); + + // Move it the start of the day for comparison + dateObj.setUTCHours(0, 0, 0, 0); + + const dateEpoch = dateObj.getTime(); + if (!aggregateMap.has(dateEpoch)) { + aggregateMap.set(dateEpoch, []); + } + + aggregateMap.get(dateEpoch)!.push(result); + }) + + return aggregateMap; +} diff --git a/frontend/editor2d/src/GalleryRootComponent/index.ts b/frontend/editor2d/src/GalleryRootComponent/index.ts new file mode 100644 index 0000000000..53d55888c8 --- /dev/null +++ b/frontend/editor2d/src/GalleryRootComponent/index.ts @@ -0,0 +1 @@ +export * from "./GalleryRootComponent"; diff --git a/frontend/editor2d/src/app/pages/main/index.tsx b/frontend/editor2d/src/app/pages/main/index.tsx index bf3d039a28..3f71d28719 100644 --- a/frontend/editor2d/src/app/pages/main/index.tsx +++ b/frontend/editor2d/src/app/pages/main/index.tsx @@ -17,6 +17,7 @@ import { EditModeRootComponent } from "~/EditModeRootComponent/EditModeRootCompo import { useRef } from "react"; import { EngineType } from "~/KonvaApp"; import { GenerationEngine } from "~/KonvaApp/GenerationEngine"; +import { GalleryRootComponent } from "~/GalleryRootComponent"; export const Main = withProtectionRoute(() => { // This is a hook that will log the number of times the component has rerendered @@ -59,8 +60,10 @@ export const Main = withProtectionRoute(() => { } return ( -
- {childView} +
+
+ {childView} +
@@ -74,6 +77,8 @@ export const Main = withProtectionRoute(() => {
+ {appModeValue === "gallery" && + ()}
); });