diff --git a/src/components/dashboard/Officer_EventRequestManagement.astro b/src/components/dashboard/Officer_EventRequestManagement.astro index cf8813e..85576ab 100644 --- a/src/components/dashboard/Officer_EventRequestManagement.astro +++ b/src/components/dashboard/Officer_EventRequestManagement.astro @@ -13,21 +13,20 @@ const auth = Authentication.getInstance(); // Extended EventRequest interface with additional properties needed for this component interface ExtendedEventRequest extends EventRequest { - requested_user_expand?: { - name: string; - email: string; + requested_user_expand?: { + name: string; + email: string; + }; + expand?: { + requested_user?: { + id: string; + name: string; + email: string; + [key: string]: any; }; - expand?: { - requested_user?: { - id: string; - name: string; - email: string; - [key: string]: any; - }; - [key: string]: any; - }; - feedback?: string; - [key: string]: any; // For other optional properties + [key: string]: any; + }; + [key: string]: any; // For other optional properties } // Initialize variables for all event requests @@ -35,185 +34,175 @@ let allEventRequests: ExtendedEventRequest[] = []; let error = null; try { - // Don't check authentication here - let the client component handle it - // The server-side check is causing issues when the token is valid client-side but not server-side + // Don't check authentication here - let the client component handle it + // The server-side check is causing issues when the token is valid client-side but not server-side - console.log("Fetching event requests in Astro component..."); - // Expand the requested_user field to get user details - allEventRequests = await get - .getAll( - Collections.EVENT_REQUESTS, - "", - "-created", - { - expand: ["requested_user"], - } - ) - .catch((err) => { - console.error("Error in get.getAll:", err); - // Return empty array instead of throwing - return []; - }); - - console.log( - `Fetched ${allEventRequests.length} event requests in Astro component` - ); - - // Process the event requests to add the requested_user_expand property - allEventRequests = allEventRequests.map((request) => { - const requestWithExpand = { ...request }; - - // Add the requested_user_expand property if the expand data is available - if ( - request.expand && - request.expand.requested_user && - request.expand.requested_user.name && - request.expand.requested_user.email - ) { - requestWithExpand.requested_user_expand = { - name: request.expand.requested_user.name, - email: request.expand.requested_user.email, - }; - } - - return requestWithExpand; + console.log("Fetching event requests in Astro component..."); + // Expand the requested_user field to get user details + allEventRequests = await get + .getAll(Collections.EVENT_REQUESTS, "", "-created", { + expand: ["requested_user"], + }) + .catch((err) => { + console.error("Error in get.getAll:", err); + // Return empty array instead of throwing + return []; }); + + console.log( + `Fetched ${allEventRequests.length} event requests in Astro component`, + ); + + // Process the event requests to add the requested_user_expand property + allEventRequests = allEventRequests.map((request) => { + const requestWithExpand = { ...request }; + + // Add the requested_user_expand property if the expand data is available + if ( + request.expand && + request.expand.requested_user && + request.expand.requested_user.name && + request.expand.requested_user.email + ) { + requestWithExpand.requested_user_expand = { + name: request.expand.requested_user.name, + email: request.expand.requested_user.email, + }; + } + + return requestWithExpand; + }); } catch (err) { - console.error("Error fetching event requests:", err); - error = err; + console.error("Error fetching event requests:", err); + error = err; } ---
- + -
-

- Event Request Management -

-

- Review and manage event requests submitted by officers. Update - status, provide feedback, and coordinate with the team. -

-
-

As an executive officer, you can:

-
    -
  • View all submitted event requests
  • -
  • - Update the status of requests (Pending, Completed, Declined) -
  • -
  • Add comments or feedback for the requesting officer
  • -
  • Filter and sort requests by various criteria
  • -
-
+
+

Event Request Management

+

+ Review and manage event requests submitted by officers. Update status and + coordinate with the team. +

+
+

As an executive officer, you can:

+
    +
  • View all submitted event requests
  • +
  • Update the status of requests (Pending, Completed, Declined)
  • +
  • Filter and sort requests by various criteria
  • +
+
- { - error && ( -
- - - - {error} -
- ) - } + { + error && ( +
+ + + + {error} +
+ ) + } - { - !error && ( -
-
- -
-
- ) - } + { + !error && ( +
+
+ +
+
+ ) + }
diff --git a/src/components/dashboard/Officer_EventRequestManagement/EventRequestDetails.tsx b/src/components/dashboard/Officer_EventRequestManagement/EventRequestDetails.tsx index 6fe7017..8bf7bb3 100644 --- a/src/components/dashboard/Officer_EventRequestManagement/EventRequestDetails.tsx +++ b/src/components/dashboard/Officer_EventRequestManagement/EventRequestDetails.tsx @@ -12,14 +12,12 @@ interface ExtendedEventRequest extends SchemaEventRequest { email: string; }; invoice_data?: string | any; - feedback?: string; } interface EventRequestDetailsProps { request: ExtendedEventRequest; onClose: () => void; onStatusChange: (id: string, status: "submitted" | "pending" | "completed" | "declined") => Promise; - onFeedbackChange: (id: string, feedback: string) => Promise; } // Separate component for AS Funding tab to isolate any issues @@ -225,11 +223,8 @@ const InvoiceTable: React.FC<{ invoiceData: any }> = ({ invoiceData }) => { const EventRequestDetails = ({ request, onClose, - onStatusChange, - onFeedbackChange + onStatusChange }: EventRequestDetailsProps): React.ReactNode => { - const [feedback, setFeedback] = useState(request.feedback || ''); - const [isSaving, setIsSaving] = useState(false); const [activeTab, setActiveTab] = useState<'details' | 'pr' | 'funding'>('details'); const [status, setStatus] = useState<"submitted" | "pending" | "completed" | "declined">(request.status); const [isStatusChanging, setIsStatusChanging] = useState(false); @@ -269,22 +264,6 @@ const EventRequestDetails = ({ } }; - // Handle saving feedback - const handleSaveFeedback = async () => { - if (feedback === request.feedback) { - toast('No changes to save', { icon: 'ℹ️' }); - return; - } - - setIsSaving(true); - const success = await onFeedbackChange(request.id, feedback); - setIsSaving(false); - - if (success) { - toast.success('Feedback saved successfully'); - } - }; - // Handle status change const handleStatusChange = async (newStatus: "submitted" | "pending" | "completed" | "declined") => { setIsStatusChanging(true); @@ -479,36 +458,6 @@ const EventRequestDetails = ({ )}
- - {/* Feedback section */} -
-

Feedback for Requester

-
- -
- -
-
-
); diff --git a/src/components/dashboard/Officer_EventRequestManagement/EventRequestManagementTable.tsx b/src/components/dashboard/Officer_EventRequestManagement/EventRequestManagementTable.tsx index 5046ed2..fc9d852 100644 --- a/src/components/dashboard/Officer_EventRequestManagement/EventRequestManagementTable.tsx +++ b/src/components/dashboard/Officer_EventRequestManagement/EventRequestManagementTable.tsx @@ -25,7 +25,6 @@ interface ExtendedEventRequest extends SchemaEventRequest { [key: string]: any; }; invoice_data?: any; - feedback?: string; status: "submitted" | "pending" | "completed" | "declined"; } @@ -176,37 +175,6 @@ const EventRequestManagementTable = ({ eventRequests: initialEventRequests }: Ev } }; - // Add feedback to event request - const addFeedback = async (id: string, feedback: string) => { - try { - const update = Update.getInstance(); - const result = await update.updateField('event_request', id, 'feedback', feedback); - - // Update local state - setEventRequests(prev => - prev.map(request => - request.id === id ? { ...request, feedback } : request - ) - ); - - setFilteredRequests(prev => - prev.map(request => - request.id === id ? { ...request, feedback } : request - ) - ); - - // Force sync to update IndexedDB - await dataSync.syncCollection(Collections.EVENT_REQUESTS); - - // Remove success toast for saving feedback - return true; - } catch (error) { - console.error('Error saving feedback:', error); - toast.error('Failed to save feedback'); - return false; - } - }; - // Format date for display const formatDate = (dateString: string) => { if (!dateString) return 'Not specified'; @@ -616,7 +584,6 @@ const EventRequestManagementTable = ({ eventRequests: initialEventRequests }: Ev request={selectedRequest} onClose={closeModal} onStatusChange={updateEventRequestStatus} - onFeedbackChange={addFeedback} /> )}