removed feedback

This commit is contained in:
chark1es 2025-03-07 21:54:59 -08:00
parent aeda1094b5
commit f48e2ff32a
3 changed files with 166 additions and 261 deletions

View file

@ -26,7 +26,6 @@ interface ExtendedEventRequest extends EventRequest {
};
[key: string]: any;
};
feedback?: string;
[key: string]: any; // For other optional properties
}
@ -41,14 +40,9 @@ try {
console.log("Fetching event requests in Astro component...");
// Expand the requested_user field to get user details
allEventRequests = await get
.getAll<ExtendedEventRequest>(
Collections.EVENT_REQUESTS,
"",
"-created",
{
.getAll<ExtendedEventRequest>(Collections.EVENT_REQUESTS, "", "-created", {
expand: ["requested_user"],
}
)
})
.catch((err) => {
console.error("Error in get.getAll:", err);
// Return empty array instead of throwing
@ -56,7 +50,7 @@ try {
});
console.log(
`Fetched ${allEventRequests.length} event requests in Astro component`
`Fetched ${allEventRequests.length} event requests in Astro component`,
);
// Process the event requests to add the requested_user_expand property
@ -100,21 +94,16 @@ try {
</style>
<div class="mb-8">
<h1 class="text-3xl font-bold text-white mb-2">
Event Request Management
</h1>
<h1 class="text-3xl font-bold text-white mb-2">Event Request Management</h1>
<p class="text-gray-300 mb-4">
Review and manage event requests submitted by officers. Update
status, provide feedback, and coordinate with the team.
Review and manage event requests submitted by officers. Update status and
coordinate with the team.
</p>
<div class="bg-base-300/50 p-4 rounded-lg text-sm text-gray-300">
<p class="font-medium mb-2">As an executive officer, you can:</p>
<ul class="list-disc list-inside space-y-1 ml-2">
<li>View all submitted event requests</li>
<li>
Update the status of requests (Pending, Completed, Declined)
</li>
<li>Add comments or feedback for the requesting officer</li>
<li>Update the status of requests (Pending, Completed, Declined)</li>
<li>Filter and sort requests by various criteria</li>
</ul>
</div>
@ -181,7 +170,7 @@ try {
Collections.EVENT_REQUESTS,
"",
"-created",
{ expand: "requested_user" }
{ expand: "requested_user" },
);
console.log("Initial data sync complete");
} catch (err) {
@ -195,7 +184,7 @@ try {
errorElement.textContent?.includes("Authentication error")
) {
console.log(
"Authentication error detected in UI, redirecting to login..."
"Authentication error detected in UI, redirecting to login...",
);
// Redirect to login page after a short delay
setTimeout(() => {
@ -208,11 +197,11 @@ try {
const tableContainer = document.querySelector(".event-table-container");
if (tableContainer) {
console.log(
"Event table container found, component should load normally"
"Event table container found, component should load normally",
);
} else {
console.log(
"Event table container not found, might be an issue with rendering"
"Event table container not found, might be an issue with rendering",
);
}
});

View file

@ -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<void>;
onFeedbackChange: (id: string, feedback: string) => Promise<boolean>;
}
// 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<string>(request.feedback || '');
const [isSaving, setIsSaving] = useState<boolean>(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 = ({
<ASFundingTab request={request} />
)}
</div>
{/* Feedback section */}
<div className="p-4 border-t border-base-300">
<h4 className="text-sm font-medium text-gray-400 mb-2">Feedback for Requester</h4>
<div className="flex flex-col gap-3">
<textarea
className="textarea textarea-bordered w-full"
placeholder="Add feedback or notes for the event requester..."
rows={3}
value={feedback}
onChange={(e) => setFeedback(e.target.value)}
></textarea>
<div className="flex justify-end">
<button
className="btn btn-primary btn-sm"
onClick={handleSaveFeedback}
disabled={isSaving || feedback === request.feedback}
>
{isSaving ? (
<>
<span className="loading loading-spinner loading-xs"></span>
Saving...
</>
) : (
'Save Feedback'
)}
</button>
</div>
</div>
</div>
</motion.div>
</div>
);

View file

@ -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<ExtendedEventRequest>(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}
/>
</AnimatePresence>
)}