Update image URL logic in ImageUploader component
Some checks failed
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Has been skipped
Build and Push Docker Images / build-frontend (push) Failing after 49s

Replace direct `fileUrl` usage with `getServerFileUrl` utility for consistent server URL formatting. Remove unnecessary fallback logic to streamline image selection.
This commit is contained in:
2025-03-14 01:18:14 +01:00
parent aaa7c68c12
commit 3d26c0f982
3 changed files with 4 additions and 5 deletions

View File

@@ -11,7 +11,7 @@ import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea"; import { Textarea } from "@/components/ui/textarea";
import { Label } from "@/components/ui/label"; import { Label } from "@/components/ui/label";
import { Switch } from "@/components/ui/switch"; import { Switch } from "@/components/ui/switch";
import { RESERVED_SLUGS } from "@/constants"; import { RESERVED_SLUGS } from "@/lib/constants";
export default function CreateEventPage() { export default function CreateEventPage() {
const router = useRouter(); const router = useRouter();

View File

@@ -7,6 +7,7 @@ import { usePresignedUpload } from "@/hooks/usePresignedUpload";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Progress } from "@/components/ui/progress"; import { Progress } from "@/components/ui/progress";
import { Loader2, RefreshCw, Upload, X } from "lucide-react"; import { Loader2, RefreshCw, Upload, X } from "lucide-react";
import { getServerFileUrl } from "@/lib/utils";
export interface ImageUploaderProps { export interface ImageUploaderProps {
id: string; id: string;
@@ -97,10 +98,9 @@ export function ImageUploader({
const handleSelectClick = () => { const handleSelectClick = () => {
fileInputRef.current?.click(); fileInputRef.current?.click();
}; };
// Determine the current image to display // Determine the current image to display
const currentImage = fileUrl || preview || existingImage; const currentImage = getServerFileUrl(fileUrl) || preview || existingImage;
// const currentImage = preview || existingImage;
return ( return (
<div className={`w-full space-y-2 ${className}`}> <div className={`w-full space-y-2 ${className}`}>
{label && ( {label && (

View File

@@ -52,7 +52,6 @@ export function usePresignedUpload(options: UsePresignedUploadOptions = {}) {
if (!data || !data.upload_url || !data.file_url) { if (!data || !data.upload_url || !data.file_url) {
throw new Error("Invalid response obtaining presigned URLs"); throw new Error("Invalid response obtaining presigned URLs");
} }
console.log("Presigned URL response: ", data);
return data; return data;
}, },
}); });