-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from Blueprint-Boulder/photoIntegration
Photo integration
- Loading branch information
Showing
10 changed files
with
206 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import VendorEventCard from './VendorEventCard'; | ||
|
||
export default function EventVendorsDisplay({showApproved, requests, vendors, eventService}) { | ||
const createCardsAdmin = (reqs) => { | ||
console.log('create cards admin'); | ||
return reqs.map((req) => { | ||
console.log('Request:', req); | ||
console.log('Vendors:', vendors); | ||
|
||
if (vendors.length === 0) return <></>; | ||
if (showApproved === true && req.approved !== true) return <></>; | ||
// 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:', res); | ||
|
||
// Return the card | ||
return <VendorEventCard key={res.id} vendor={res} request={req} eventService={eventService}></VendorEventCard>; | ||
}); | ||
}; | ||
|
||
const createCards = (vends) => { | ||
console.log('create cards'); | ||
return vends.map((vendor)=> { | ||
return <VendorEventCard key={vendor.id} vendor={vendor} request={undefined} eventService={eventService}></VendorEventCard>; | ||
}); | ||
}; | ||
|
||
return <div className='flex flex-wrap p-10'> | ||
{ | ||
requests.length > 0 ? createCardsAdmin(requests) : createCards(vendors) | ||
} | ||
</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, {useContext} from 'react'; | ||
|
||
import {Context} from '../services/context'; | ||
|
||
|
||
export default function VendorEventCard({vendor, request, eventService}) { | ||
const {user, setMessage, setBad} = useContext(Context); | ||
|
||
|
||
console.log('LoadingCard:', vendor, request); | ||
|
||
// Sets approved to value | ||
const updateRequest = async (value) => { | ||
const res = await eventService.updateEventRequest(vendor.id, {approved: value}); | ||
if (!res) { | ||
setMessage('Failed to update vendor request for event.'); | ||
setBad(true); | ||
} else { | ||
// Should be checking the res status before saying this succeeded? | ||
setMessage('Vendor request updated for event.'); | ||
} | ||
window.location.reload(); | ||
}; | ||
|
||
const AdminButtons = () => { | ||
if (user && user.isadmin) { | ||
if (request && request.approved) { // Show buttons to reject or set to pending | ||
return <div className='flex flex-row spacing-3'> | ||
<button className='mt-3 text-gray-800 font-semibold drop-shadow-xl rounded-md bg-white w-24 click:text-white' onClick={() => updateRequest(false)}>Reject Request</button> | ||
<button className='mt-3 text-gray-800 font-semibold drop-shadow-xl rounded-md bg-white w-24 click:text-white' onClick={() => updateRequest(undefined)}>Set Pending</button> | ||
</div>; | ||
} else { // Show buttons to reject or approve | ||
return <div className='flex flex-row spacing-3'> | ||
<button className='mt-3 text-gray-800 font-semibold drop-shadow-xl rounded-md bg-white w-24 click:text-white' onClick={() => updateRequest(true)}>Approve</button> | ||
<button className='mt-3 text-gray-800 font-semibold drop-shadow-xl rounded-md bg-white w-24 click:text-white' onClick={() => updateRequest(false)}>Reject Request</button> | ||
</div>; | ||
} | ||
} else { // Only admins need buttons to manage event requests | ||
return <></>; | ||
} | ||
}; | ||
|
||
console.log('vendreq', request); | ||
console.log('vendvend', vendor); | ||
|
||
return ( | ||
<div className='flex flex-col p-10 basis-1/2 items-center'> | ||
<img src={vendor.image ? `/profilepics/${vendor.image}` : '/profile.webp'}></img> | ||
<p className='text-center'>{vendor.name}</p> | ||
{ | ||
<AdminButtons></AdminButtons> | ||
} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.