From 87b6e1710d8b0c7d1d00d3f2526c6c7f3f091099 Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Sat, 4 Mar 2023 11:08:14 +0100 Subject: [PATCH] Cosmetics --- src/components/invitation/Invitation.tsx | 39 +++++++++++++++--------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/components/invitation/Invitation.tsx b/src/components/invitation/Invitation.tsx index 6a17a44..b86e782 100644 --- a/src/components/invitation/Invitation.tsx +++ b/src/components/invitation/Invitation.tsx @@ -13,6 +13,14 @@ interface props {} const [invitation, setInvitation] = createSignal(false); +const fetchInvitation = () => { + fetch(invitation().url) + .then((response) => response.json()) + .then((data) => { + setInvitation({ ...invitation(), data }); + }); +}; + export const searchInvitation = () => { const hash = location.hash; console.log({ caller: 'Invitation / searchInvitation', hash }); @@ -22,16 +30,8 @@ export const searchInvitation = () => { const payload = hash.slice(1); const decoded = atob(payload); const url = new URL(decoded); - fetch(url) - .then((response) => response.json()) - .then((data) => { - setInvitation({ url, data }); - console.log({ - caller: 'Invitation / searchInvitation', - hash, - invitation: invitation(), - }); - }); + setInvitation({ url }); + fetchInvitation(); } catch { console.warn({ caller: 'Invitation / searchInvitation', @@ -63,7 +63,12 @@ const Invitation: Component = (props) => { failure: codeData.response !== 'OK', success: codeData.response === 'OK', }); - } catch (error) {} + } catch (error) { + setInvitation({ + ...invitation(), + failure: true, + }); + } }; const codeChangeHandler = (event: any) => { @@ -74,14 +79,14 @@ const Invitation: Component = (props) => { setInvitation({ ...invitation(), failure: undefined }); }; - const handleModalSuccessClose = () => { + const handleCloseAll = () => { setInvitation(false); }; return ( <> = (props) => { + + = (props) => { {' '}