Skip to content

Commit

Permalink
Added user prop to EventVendorsDisplay to facilitate checking admin s…
Browse files Browse the repository at this point in the history
…tatus. Added debug and error catching print statements.
  • Loading branch information
nh602 committed Aug 24, 2024
1 parent a83ae01 commit fdfc241
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
21 changes: 14 additions & 7 deletions frontend/src/components/EventVendorsDisplay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import React from 'react';
import VendorEventCard from './VendorEventCard';


export default function EventVendorsDisplay({showApproved, requests, vendors, eventService}) {
export default function EventVendorsDisplay({user, showApproved, requests, vendors, eventService}) {
console.log('EventVendorsDisplay Debug info: ', {
showApproved,
requests,
vendors,
eventService,
user
});

const createCardsAdmin = (reqs) => {
// console.log('create cards admin');
return reqs.map((req) => {
console.log('Request:', req);
console.log('Vendors:', vendors);

// No vendors have requested to attend this event
if (vendors.length === 0) return <></>;

Expand All @@ -18,10 +23,12 @@ export default function EventVendorsDisplay({showApproved, requests, vendors, ev
// Returning pending only - The request is not pending
if (showApproved === false && ( req.approved !== null ) ) return <></>;


// Fetch the vendor's profile
const res = vendors.filter((v) => v.id === req.vendorId)[0];
console.log('Vendor Value:', res);
if (!res) {
console.error("Vendor's id not found - even though it should have been.");
return <></>;
}

// Return the card
return <VendorEventCard key={res.id} vendor={res} request={req} eventService={eventService}></VendorEventCard>;
Expand All @@ -37,7 +44,7 @@ export default function EventVendorsDisplay({showApproved, requests, vendors, ev

return <div className='flex flex-wrap p-5 gap-4 justify-center'>
{
requests.length > 0 ? createCardsAdmin(requests) : createCards(vendors)
user && user.isadmin ? createCardsAdmin(requests) : createCards(vendors)
}
</div>;
}
3 changes: 2 additions & 1 deletion frontend/src/routes/event.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function Event({eventService, vendorService}) {
const [event, setEvent] = useState(null);
const navigate = useNavigate();
const {eventId} = useParams();

const {user, setMessage, setBad} = useContext(Context);

const [requests, setRequests] = useState([]);
Expand Down Expand Up @@ -181,7 +182,7 @@ export default function Event({eventService, vendorService}) {
}}>Show {showApproved ? 'Pending' : 'Attending'}</button>
}
</div>
<EventVendorsDisplay showApproved={showApproved} vendors={vendors} requests={requests} eventService={eventService}></EventVendorsDisplay>
<EventVendorsDisplay user={user} showApproved={showApproved} vendors={vendors} requests={requests} eventService={eventService}></EventVendorsDisplay>
<FooterPad />
</div>
</>
Expand Down

0 comments on commit fdfc241

Please sign in to comment.