diff --git a/src/guests/components/Guest.js b/src/guests/components/Guest.js index 4c8ec8f1..4df4a3dd 100644 --- a/src/guests/components/Guest.js +++ b/src/guests/components/Guest.js @@ -12,6 +12,7 @@ import TicketsList from 'components/TicketsList'; const Guest = ({ id }) => { const [guest, setGuest] = useState(), [event, setEvent] = useState(), + [users, setUsers] = useState(), [editingComment, setEditingComment] = useState(''), [commentInput, setCommentInput] = useState(''); @@ -23,6 +24,12 @@ const Guest = ({ id }) => { .catch(e => console.error('Guest API Error', e)); }, [id]); + useEffect(() => { + apiClient.get('/users') + .then(setUsers) + .catch(e => console.error('Users API Error', e)); + }, []); + useEffect(() => { if(!guest) return; @@ -59,6 +66,16 @@ const Guest = ({ id }) => { { name: eventName } = event, { role } = user; + let createdByName = ''; + if (createdBy) { + createdByName = users.find(u => u.id === createdBy)?.displayName; + } + + let updatedByName = ''; + if (updatedBy) { + updatedByName = users.find(u => u.id === updatedBy)?.displayName; + } + return (

Guest - {eventName}

@@ -89,13 +106,13 @@ const Guest = ({ id }) => { ? createdReason === 'purchase' ? <>Confirmation Id: {orderId} : createdReason === 'comp' - ? <>Comped by: {createdBy} - : <>Created by: {createdBy}/{orderId} + ? <>Comped by: {createdByName} + : <>Created by: {createdByName}/{orderId} : <>Confirmation Id: {orderId} } - {checkScope(role, 'write') && updatedBy &&

Updated by: {updatedBy}

} + {checkScope(role, 'write') && updatedBy &&

Updated by: {updatedByName}

}
diff --git a/src/guests/components/GuestsListItem.js b/src/guests/components/GuestsListItem.js index fbd653f9..7a2f8594 100644 --- a/src/guests/components/GuestsListItem.js +++ b/src/guests/components/GuestsListItem.js @@ -44,7 +44,14 @@ const GuestsListItem = ({ guest, updateGuest, event, role }) => (

- {guest.admissionTier === 'vip' &&

} + {guest.admissionTier === 'vip' + ? checkScope(role, 'write') + ? + :

+ : checkScope(role, 'write') + ? + : '' + }
); diff --git a/src/promos/components/PromosList.js b/src/promos/components/PromosList.js index 96b38024..36032c15 100644 --- a/src/promos/components/PromosList.js +++ b/src/promos/components/PromosList.js @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'; import classnames from 'classnames'; import PromosListItem from './PromosListItem'; -const PromosList = ({ promos, products, event, sortBy, sortOrder, sortPromos, switchPromosOrder, disablePromo }) => { +const PromosList = ({ promos, products, users, event, sortBy, sortOrder, sortPromos, switchPromosOrder, disablePromo }) => { const productsById = products.reduce((obj, cur) => (obj[cur.id] = cur, obj), {}); return ( @@ -66,6 +66,7 @@ const PromosList = ({ promos, products, event, sortBy, sortOrder, sortPromos, sw event={event} product={productsById[promo.productId]} promo={promo} + createdByName={users.find(u => u.id === promo.createdBy)?.displayName} disablePromo={disablePromo} />)} @@ -77,6 +78,7 @@ export default PromosList; PromosList.propTypes = { promos: PropTypes.array.isRequired, products: PropTypes.array.isRequired, + users: PropTypes.array.isRequired, event: PropTypes.object.isRequired, sortPromos: PropTypes.func.isRequired, switchPromosOrder: PropTypes.func.isRequired, diff --git a/src/promos/components/PromosListItem.js b/src/promos/components/PromosListItem.js index fbe2e4b9..eca07648 100644 --- a/src/promos/components/PromosListItem.js +++ b/src/promos/components/PromosListItem.js @@ -4,7 +4,7 @@ import React, { memo } from 'react'; import PropTypes from 'prop-types'; import { format } from 'date-fns'; -const PromosListItem = ({ promo, product, event, disablePromo }) => ( +const PromosListItem = ({ promo, createdByName, product, event, disablePromo }) => (
  • (

    {event.name}

    -

    {product?.name}

    +

    {product?.name}

    Promo Link

    @@ -38,6 +38,7 @@ const PromosListItem = ({ promo, product, event, disablePromo }) => ( PromosListItem.propTypes = { product: PropTypes.object.isRequired, + createdByName: PropTypes.string, event: PropTypes.object.isRequired, promo: PropTypes.object.isRequired, disablePromo: PropTypes.func.isRequired diff --git a/src/promos/components/PromosTable.js b/src/promos/components/PromosTable.js index cdf6a443..76a70ab1 100644 --- a/src/promos/components/PromosTable.js +++ b/src/promos/components/PromosTable.js @@ -20,9 +20,9 @@ function getPromoComparator({sortBy, sortOrder}) { default: case 'recipient': - sort = a.recipient > b.recipient + sort = a.recipientName > b.recipientName ? 1 - : a.recipient === b.recipient + : a.recipientName === b.recipientName ? 0 : -1; break; @@ -35,6 +35,7 @@ function getPromoComparator({sortBy, sortOrder}) { const PromosTable = () => { const [promos, setPromos] = useState([]), [products, setProducts] = useState([]), + [users, setUsers] = useState(), [filter, setFilter] = useState(''), [sort, setSort] = useState({sortBy: 'recipient', sortOrder: 1}); // asc @@ -50,6 +51,10 @@ const PromosTable = () => { apiClient.get('/products') .then(setProducts) .catch(e => console.error('Products API Error', e)); + + apiClient.get('/users') + .then(setUsers) + .catch(e => console.error('Users API Error', e)); }, []); function sortPromos(sortBy) { @@ -87,7 +92,7 @@ const PromosTable = () => { if(!filter) return true; return ( - filterRegExp.test(p.recipient) || + filterRegExp.test(p.recipientName) || filterRegExp.test(p.email) ); }); @@ -112,6 +117,7 @@ const PromosTable = () => { promos={filteredPromos} event={event} products={filteredProducts} + users={users} sortPromos={sortPromos} switchPromosOrder={switchPromosOrder} sortBy={sort.sortBy}