Conversation
…/adto-admin into feat/39-media-asset-upload-section
…om/SAMAHAN-Systems-Development/adto-admin into feat/39-media-asset-upload-section
…/adto-admin into feat/39-media-asset-upload-section
…nce ticket management features
…om/SAMAHAN-Systems-Development/adto-admin into feat/39-media-asset-upload-section
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR implements media asset upload functionality for the admin application, enabling S3-based image uploads for event banners, event thumbnails, and ticket thumbnails. The changes integrate upload components with auto-save to the database and add UI features for managing ticket images and links.
Changes:
- Added S3 upload service with endpoints for event banners, generic assets, and organization icons
- Created reusable upload components with drag-and-drop support and preview functionality
- Integrated ticket thumbnail uploads with display in ticket cards and detail modals
- Added event banner and thumbnail upload sections in event details page with persistence
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 19 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/types/requests/ticketsRequests.ts | Added optional thumbnail field to ticket request types |
| lib/types/requests/EventRequests.ts | Added optional banner and thumbnail fields to UpdateEventRequest |
| lib/types/entities/index.ts | Added optional banner and thumbnail fields to Event entity |
| lib/api/services/assetService.ts | New service with upload functions for event banners, generic assets, and organization icons |
| components/shared/upload-image.tsx | New reusable upload component with drag-and-drop, validation, and preview |
| components/shared/CreateTicket.tsx | Integrated ticket thumbnail upload with auto-save and added ticket link field |
| components/shared/CardTicket.tsx | Updated ticket cards to display thumbnails and added download/request buttons |
| components/features/events/upload-thumbnail-modal.tsx | Modal component for uploading event thumbnails |
| components/features/events/upload-banner-modal.tsx | Modal component for uploading event banners |
| app/(main)/events/[id]/page.tsx | Added banner/thumbnail upload UI with auto-save to database |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| setTicketLink(tempTicketLink); | ||
| setIsEditingTicketLink(false); | ||
| // TODO: Save to database when API is ready | ||
| console.log("Ticket link saved:", tempTicketLink); |
There was a problem hiding this comment.
Console.log statements left in production code. These debug statements should be removed before merging to production as they can expose sensitive information and clutter the console.
| console.log("Ticket link saved:", tempTicketLink); |
| if (onUploadError) { | ||
| onUploadError(errorMessage); | ||
| } | ||
| console.error("Error uploading image:", error); |
There was a problem hiding this comment.
Console.log statements left in production code. These debug statements should be removed before merging to production as they can expose sensitive information and clutter the console.
| console.error("Error uploading image:", error); |
| console.log("Banner uploaded:", data); | ||
| setUploadData(data); | ||
| setUploadError(null); | ||
| }; | ||
|
|
||
| const handleUploadError = (error: string) => { | ||
| console.error("Upload error:", error); |
There was a problem hiding this comment.
Console.log statements left in production code. These debug statements should be removed before merging to production as they can expose sensitive information and clutter the console.
| console.log("Banner uploaded:", data); | |
| setUploadData(data); | |
| setUploadError(null); | |
| }; | |
| const handleUploadError = (error: string) => { | |
| console.error("Upload error:", error); | |
| setUploadData(data); | |
| setUploadError(null); | |
| }; | |
| const handleUploadError = (error: string) => { |
| {/* <UploadImage | ||
| onUploadComplete={(imageData) => { | ||
| // imageData is a JSON object with: | ||
| // { | ||
| // name: "image.png", | ||
| // type: "image/png", | ||
| // size: 12345, | ||
| // data: "data:image/png;base64,...", | ||
| // url: "data:image/png;base64,..." | ||
| // } | ||
|
|
||
| // You can save this to a JSON file: | ||
| // const jsonString = JSON.stringify(imageData, null, 2); | ||
| // Or use it directly | ||
| console.log(imageData); | ||
| }} | ||
| /> */} |
There was a problem hiding this comment.
Large commented-out code block left in the file. This appears to be example/documentation code that should be removed. Commented code should generally be removed before merging to keep the codebase clean and maintainable.
| {/* <UploadImage | |
| onUploadComplete={(imageData) => { | |
| // imageData is a JSON object with: | |
| // { | |
| // name: "image.png", | |
| // type: "image/png", | |
| // size: 12345, | |
| // data: "data:image/png;base64,...", | |
| // url: "data:image/png;base64,..." | |
| // } | |
| // You can save this to a JSON file: | |
| // const jsonString = JSON.stringify(imageData, null, 2); | |
| // Or use it directly | |
| console.log(imageData); | |
| }} | |
| /> */} |
| { | ||
| /* <UploadImage | ||
| uploadType="event-banner" // or "asset" | ||
| folder="custom-folder" // optional, for asset uploads | ||
| onUploadComplete={(uploadData) => { | ||
| // uploadData contains: { url, key, bucket, fileName } | ||
| console.log(uploadData); | ||
| }} | ||
| /> */ | ||
| } |
There was a problem hiding this comment.
This JSX block containing usage documentation is invalid JavaScript syntax. It will cause compilation errors. Usage documentation should be moved to a comment block or removed entirely.
| { | |
| /* <UploadImage | |
| uploadType="event-banner" // or "asset" | |
| folder="custom-folder" // optional, for asset uploads | |
| onUploadComplete={(uploadData) => { | |
| // uploadData contains: { url, key, bucket, fileName } | |
| console.log(uploadData); | |
| }} | |
| /> */ | |
| } | |
| /* | |
| <UploadImage | |
| uploadType="event-banner" // or "asset" | |
| folder="custom-folder" // optional, for asset uploads | |
| onUploadComplete={(uploadData) => { | |
| // uploadData contains: { url, key, bucket, fileName } | |
| console.log(uploadData); | |
| }} | |
| /> | |
| */ |
components/shared/CreateTicket.tsx
Outdated
| console.log("Ticket thumbnail uploaded:", uploadData); | ||
| setTicketThumbnailData(uploadData); | ||
| }} | ||
| onUploadError={(error) => { | ||
| console.error("Ticket thumbnail upload error:", error); |
There was a problem hiding this comment.
Console.log statements left in production code. These debug statements should be removed before merging to production as they can expose sensitive information and clutter the console.
| console.log("Ticket thumbnail uploaded:", uploadData); | |
| setTicketThumbnailData(uploadData); | |
| }} | |
| onUploadError={(error) => { | |
| console.error("Ticket thumbnail upload error:", error); | |
| setTicketThumbnailData(uploadData); | |
| }} | |
| onUploadError={(error) => { |
| console.log("Thumbnail uploaded:", data); | ||
| setUploadData(data); | ||
| setUploadError(null); | ||
| }; | ||
|
|
||
| const handleUploadError = (error: string) => { | ||
| console.error("Upload error:", error); |
There was a problem hiding this comment.
Console.log statements left in production code. These debug statements should be removed before merging to production as they can expose sensitive information and clutter the console.
| console.log("Thumbnail uploaded:", data); | |
| setUploadData(data); | |
| setUploadError(null); | |
| }; | |
| const handleUploadError = (error: string) => { | |
| console.error("Upload error:", error); | |
| setUploadData(data); | |
| setUploadError(null); | |
| }; | |
| const handleUploadError = (error: string) => { |
app/(main)/events/[id]/page.tsx
Outdated
| <img | ||
| src={thumbnailImageData.url} | ||
| alt="Thumbnail preview" | ||
| className="absolute inset-0 w-full h-full object-cover" | ||
| /> |
There was a problem hiding this comment.
Using native img tags instead of Next.js Image component bypasses important optimizations and can lead to performance issues. The codebase consistently uses Next.js Image component for rendering images (see components/features/organizations/organizations-columns.tsx:57-63). Consider using the Next.js Image component for optimization benefits including automatic image optimization, lazy loading, and proper sizing.
| console.log("Banner saved to state:", uploadData); | ||
|
|
||
| // Automatically save to database | ||
| try { | ||
| await updateEventMutation.mutateAsync({ | ||
| id: params.id, | ||
| data: { banner: uploadData.url }, | ||
| }); | ||
| toast.success("Banner image uploaded and saved!"); | ||
| } catch (error) { | ||
| console.error("Failed to save banner:", error); | ||
| toast.error("Failed to save banner to database"); | ||
| } | ||
| }} | ||
| /> | ||
|
|
||
| {/* Upload Thumbnail Modal */} | ||
| <UploadThumbnailModal | ||
| isOpen={showThumbnailModal} | ||
| onClose={() => setShowThumbnailModal(false)} | ||
| onSubmit={async (uploadData) => { | ||
| setThumbnailImageData(uploadData); | ||
| console.log("Thumbnail saved to state:", uploadData); |
There was a problem hiding this comment.
Console.log statements left in production code. These debug statements should be removed before merging to production as they can expose sensitive information and clutter the console.
| <Input | ||
| value={isEditingTicketLink ? tempTicketLink : ticketLink} | ||
| onChange={(e) => setTempTicketLink(e.target.value)} | ||
| placeholder="Enter ticket link URL" | ||
| className="flex-1" | ||
| disabled={!isEditingTicketLink} | ||
| /> |
There was a problem hiding this comment.
Missing input validation for the Ticket Link field. The input accepts any string without validation for URL format. If this field is intended to store URLs, add proper URL validation to ensure data integrity. Consider using a URL validation library or regex pattern.
…rs and thumbnails, enhance ticket management features
…odals and ticket creation
Issue ticket number and link
Resolves 39 - Admin Side: Event Thumbnail and Banner Upload
Features
Notes
Usage
TODO