-
Notifications
You must be signed in to change notification settings - Fork 1
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
17994b4
commit 75c3361
Showing
8 changed files
with
180 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export async function GET(request: Request) { | ||
const response = await fetch( | ||
"https://ai-imggeneration-ms-azure007.azurewebsites.net/api/getimages", | ||
{ | ||
cache: "no-store", | ||
} | ||
); | ||
|
||
const blob = await response.blob(); | ||
const textData = await blob.text(); | ||
|
||
const data = JSON.parse(textData); | ||
|
||
return new Response(JSON.stringify(data), { | ||
status: 200, | ||
}); | ||
} |
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,8 +1,11 @@ | ||
import Images from "../components/Images"; | ||
|
||
export default function Home() { | ||
async function HomePage() { | ||
return ( | ||
<main> | ||
<h1>hi</h1> | ||
</main> | ||
) | ||
<div className="mx-0 md:10"> | ||
<Images /> | ||
</div> | ||
); | ||
} | ||
|
||
export default HomePage; |
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,15 @@ | ||
"use client"; | ||
import { Toaster } from "react-hot-toast"; | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<> | ||
<Toaster position="bottom-center" /> | ||
{children} | ||
</> | ||
); | ||
} |
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,72 @@ | ||
"use client"; | ||
|
||
import Image from "next/image"; | ||
import useSWR from "swr"; | ||
import fetchImages from "../lib/fetchImages"; | ||
|
||
type ImageType = { | ||
name: string; | ||
url: string; | ||
}; | ||
|
||
function Images() { | ||
const { | ||
data: images, | ||
isLoading, | ||
mutate: refreshImages, | ||
isValidating, | ||
} = useSWR("images", fetchImages, { | ||
revalidateOnFocus: false, | ||
}); | ||
console.log(images); | ||
|
||
|
||
return ( | ||
<div> | ||
<button | ||
className="fixed bottom-10 right-10 bg-violet-400/90 text-white px-5 py-3 rounded-md | ||
hover:bg-violet-500 focus:outline-none focus:ring-2 focus:ring-violet-400 font-bold z-20" | ||
onClick={() => refreshImages(images)} | ||
> | ||
{!isLoading && isValidating ? "Refreshing..." : "Refresh Images"} | ||
</button> | ||
|
||
{isLoading && ( | ||
<p className="animate-pulse text-center pb-7 font-extralight"> | ||
Loading <span className="text-violet-400">AI</span> Generated | ||
Images... | ||
</p> | ||
)} | ||
|
||
<div className="grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 px-0 md:px-10"> | ||
{images?.imageUrls?.map((image: ImageType, i: number) => ( | ||
<div | ||
className={`relative cursor-help ${ | ||
i === 0 && "md:col-span-2 md:row-span-2" | ||
} hover:scale-[103%] transition-transform duration-200 ease-in-out | ||
`} | ||
key={image.name} | ||
> | ||
{/* create a white div that when hovered it appears */} | ||
<div className="absolute flex justify-center items-center w-full h-full bg-white opacity-0 hover:opacity-80 transition-opacity duration-200 z-10"> | ||
<p className="text-center font-light text-lg p-5"> | ||
{/* This removes the Timestamp and File extension */} | ||
{image.name.split("_").shift()?.toString().split(".").shift()} | ||
</p> | ||
</div> | ||
<Image | ||
src={image.url} | ||
alt="" | ||
height={800} | ||
width={800} | ||
className="w-full rounded-sm shadow-2xl drop-shadow-lg -z-10" | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default Images; |
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