Skip to content

Commit

Permalink
fix upload
Browse files Browse the repository at this point in the history
  • Loading branch information
docimin committed Jul 12, 2024
1 parent 62afa03 commit 8eb0281
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 263 deletions.
243 changes: 0 additions & 243 deletions src/app/[locale]/(account)/account/gallery/upload/page.client.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions src/app/[locale]/(account)/account/gallery/upload/page.tsx

This file was deleted.

13 changes: 9 additions & 4 deletions src/components/gallery/uploadImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default function UploadPage() {
const { userMe } = useGetUser()
const { toast } = useToast()
const router = useRouter()
const [selectedFileInput, setSelectedFileInput] = useState(null)
const [selectedFile, setSelectedFile] = useState(null)
const fileInputRef = useRef(null)

Expand All @@ -29,7 +30,8 @@ export default function UploadPage() {
if (img) {
console.log('File read successfully, updating image src.') // Debugging log
img.src = e.target.result as string
setSelectedFile(e.target.result as string)
setSelectedFileInput(e.target.result as string)
setSelectedFile(file)
} else {
console.error('Failed to find the image element.') // Debugging log
}
Expand All @@ -55,7 +57,8 @@ export default function UploadPage() {
if (img) {
console.log('File dropped successfully, updating image src.') // Debugging log
img.src = e.target.result as string
setSelectedFile(e.target.result as string)
setSelectedFileInput(e.target.result as string)
setSelectedFile(file)
} else {
console.error('Failed to find the image element.') // Debugging log
}
Expand Down Expand Up @@ -99,6 +102,7 @@ export default function UploadPage() {
nsfw: (document.getElementById('nsfw') as HTMLInputElement)
.checked, // Extract the checked state
galleryId: fileDataResponse.$id,
mimeType: fileDataResponse.mimeType,
userId: userMe.$id,
}
)
Expand Down Expand Up @@ -187,8 +191,9 @@ export default function UploadPage() {
className="mx-auto h-96 min-w-full rounded-md object-contain cursor-pointer"
alt="Placeholder Image"
src={
selectedFile || '/images/placeholder-image-color.webp'
} // Fallback to a placeholder if selectedFile is null
selectedFileInput ||
'/images/placeholder-image-color.webp'
} // Fallback to a placeholder if selectedFileInput is null
/>
</Label>
</div>
Expand Down

0 comments on commit 8eb0281

Please sign in to comment.