Skip to content

Commit 164cd09

Browse files
test commit 1
1 parent 0c415f5 commit 164cd09

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

app/generate/page.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { Button } from "@/components/ui/button";
4+
import { saveWork } from "@/lib/actions/saveWork";
45
import { AnimatePresence, motion } from "framer-motion";
56
import {
67
AlertCircle,
@@ -85,7 +86,7 @@ export default function UploadPage() {
8586
setError(null);
8687
setSvgResult(null);
8788
},
88-
[setError, setUploadedFiles, setSvgResult],
89+
[setError, setUploadedFiles, setSvgResult]
8990
);
9091

9192
const handleDrop = useCallback(
@@ -98,7 +99,7 @@ export default function UploadPage() {
9899
handleFiles(files);
99100
}
100101
},
101-
[handleFiles],
102+
[handleFiles]
102103
);
103104

104105
const handleDragOver = useCallback((e: React.DragEvent<HTMLDivElement>) => {
@@ -174,6 +175,14 @@ export default function UploadPage() {
174175
setError("Failed to upload image. Please try again.");
175176
} finally {
176177
setIsUploading(false);
178+
saveWork(
179+
// "085c190b-63be-4e54-81cf-7665e558493d",
180+
"Sample Title",
181+
"Sample Description",
182+
"https://example.com/image.png",
183+
"https://example.com/image.svg",
184+
svgResult || ""
185+
);
177186
}
178187
};
179188

@@ -223,7 +232,7 @@ export default function UploadPage() {
223232
if (!/viewBox=/.test(svg)) {
224233
svg = svg.replace(
225234
/<svg([^>]*)>/,
226-
`<svg$1 viewBox="0 0 ${width} ${height}">`,
235+
`<svg$1 viewBox="0 0 ${width} ${height}">`
227236
);
228237
}
229238
}
@@ -398,8 +407,8 @@ export default function UploadPage() {
398407
{file.progress === 0
399408
? "Ready to convert"
400409
: file.progress < 100
401-
? `Converting... ${file.progress}%`
402-
: "Conversion complete!"}
410+
? `Converting... ${file.progress}%`
411+
: "Conversion complete!"}
403412
</span>
404413
{file.progress === 100 && !isUploading && (
405414
<motion.div

lib/actions/saveWork.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { createClient } from "@/lib/supabase/client";
2+
3+
const supabase = createClient();
4+
5+
export async function saveWork(
6+
title: string,
7+
description: string,
8+
imageUrl: string,
9+
svgUrl: string,
10+
svgData: string
11+
) {
12+
const { data, error } = await supabase.from("works").insert([
13+
{
14+
user_id: supabase.auth.id(),
15+
title,
16+
description,
17+
original_image_url: imageUrl,
18+
svg_data: svgData,
19+
},
20+
]);
21+
22+
if (error) console.error(error);
23+
return data;
24+
}

0 commit comments

Comments
 (0)