Add portfolio thingies
This commit is contained in:
@ -1,12 +1,10 @@
|
||||
"use client"
|
||||
|
||||
import { generateArtworkColors } from "@/actions/artworks/generateArtworkColors";
|
||||
// import { generateArtworkColors } from "@/actions/artworks/generateArtworkColors";
|
||||
// import { generateImageColors } from "@/actions/portfolio/images/generateImageColors";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ArtworkColor, Color } from "@/generated/prisma/client";
|
||||
// import { Color, ImageColor } from "@/generated/prisma";
|
||||
import { useState, useTransition } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
type ColorWithItems = ArtworkColor & {
|
||||
color: Color
|
||||
@ -16,26 +14,26 @@ export default function ArtworkColors({ colors: initialColors, artworkId, fileKe
|
||||
const [colors, setColors] = useState(initialColors);
|
||||
const [isPending, startTransition] = useTransition();
|
||||
|
||||
const handleGenerate = () => {
|
||||
startTransition(async () => {
|
||||
try {
|
||||
const newColors = await generateArtworkColors(artworkId, fileKey, fileType);
|
||||
setColors(newColors);
|
||||
toast.success("Colors extracted successfully");
|
||||
} catch (err) {
|
||||
toast.error("Failed to extract colors");
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
// const handleGenerate = () => {
|
||||
// startTransition(async () => {
|
||||
// try {
|
||||
// const newColors = await generateArtworkColorsForArtwork(artworkId, fileKey, fileType);
|
||||
// setColors(newColors);
|
||||
// toast.success("Colors extracted successfully");
|
||||
// } catch (err) {
|
||||
// toast.error("Failed to extract colors");
|
||||
// console.error(err);
|
||||
// }
|
||||
// });
|
||||
// };
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<h2 className="font-semibold text-lg">Artwork Colors</h2>
|
||||
<Button size="sm" onClick={handleGenerate} disabled={isPending}>
|
||||
{/* <Button size="sm" onClick={handleGenerate} disabled={isPending}>
|
||||
{isPending ? "Extracting..." : "Generate Palette"}
|
||||
</Button>
|
||||
</Button> */}
|
||||
</div >
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{colors.map((item) => (
|
||||
|
||||
Reference in New Issue
Block a user