diff --git a/webclient/src/AdminMembers.js b/webclient/src/AdminMembers.js index 99d906b..79411a1 100644 --- a/webclient/src/AdminMembers.js +++ b/webclient/src/AdminMembers.js @@ -123,7 +123,7 @@ export function AdminMemberCards(props) { const [error, setError] = useState(false); const [loading, setLoading] = useState(false); const [success, setSuccess] = useState(false); - const [viewCard, setViewCard] = useState(false); + const [cardPhoto, setCardPhoto] = useState(false); const { id } = useParams(); useEffect(() => { @@ -155,6 +155,18 @@ export function AdminMemberCards(props) { }); }; + const getCardPhoto = (e) => { + e.preventDefault(); + requester('/members/' + id + '/card_photo/', 'GET', token) + .then(res => res.blob()) + .then(res => { + setCardPhoto(URL.createObjectURL(res)); + }) + .catch(err => { + console.log(err); + }); + }; + const makeProps = (name) => ({ name: name, onChange: handleChange, @@ -176,17 +188,17 @@ export function AdminMemberCards(props) {
Add a Card
- {result.member.card_photo ? + {result.member.photo_large ?

- +

:

No card image, member photo missing!

} - {viewCard && <> + {cardPhoto && <>

- +

How to Print a Card
diff --git a/webclient/src/utils.js b/webclient/src/utils.js index 6140508..5585257 100644 --- a/webclient/src/utils.js +++ b/webclient/src/utils.js @@ -70,7 +70,17 @@ export const requester = (route, method, token, data) => { if (!response.ok) { throw customError(response); } - return method === 'DELETE' ? {} : response.json(); + + if (method === 'DELETE') { + return {}; + } + + const contentType = response.headers.get('content-type'); + if (contentType && contentType.indexOf('application/json') !== -1) { + return response.json(); + } else { + return response; + } }) .catch(error => { const code = error.data ? error.data.status : null;