-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathpage.tsx
More file actions
46 lines (41 loc) · 1.07 KB
/
page.tsx
File metadata and controls
46 lines (41 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use client';
import { Input } from '@/components/ui/input';
import { useUser } from '@/hooks/use-user';
export default function UploadTestPage() {
const { user } = useUser();
const onSubmit = async (data: any) => {
if (!user?.uid) return;
const formData = new FormData();
formData.append('files', data.target.files[0]);
formData.append('userId', user?.uid);
formData.append('route', 'user-profile-pictures');
try {
const res = await fetch('/api/upload', {
method: 'POST',
body: formData,
});
const { logoUrl } = await res.json();
console.log(logoUrl);
} catch (e) {
console.error(e);
}
};
return (
<div className="h-screen flex items-center justify-center">
<label
htmlFor="logo-file-upload"
className="bg-blue-500 p-2 rounded text-white cursor-pointer"
>
Upload Logo
</label>
<Input
id="logo-file-upload"
type="file"
onChange={() => {
onSubmit(event);
}}
className="hidden!"
/>
</div>
);
}