|
|
|
|
@ -35,21 +35,6 @@ const Mailings = () => { |
|
|
|
|
|
|
|
|
|
if (!userInfo) return null |
|
|
|
|
|
|
|
|
|
const { |
|
|
|
|
address_line1, |
|
|
|
|
address_line2, |
|
|
|
|
city, |
|
|
|
|
cityId, |
|
|
|
|
country, |
|
|
|
|
firstname, |
|
|
|
|
is_unsubscribed, |
|
|
|
|
language, |
|
|
|
|
lastname, |
|
|
|
|
phone, |
|
|
|
|
postal_code, |
|
|
|
|
region, |
|
|
|
|
} = { ...userInfo } |
|
|
|
|
|
|
|
|
|
const currentYear = format(new Date(), 'Y') |
|
|
|
|
|
|
|
|
|
const onUnsubscribe = async (isUnsubscribed: boolean) => { |
|
|
|
|
@ -57,86 +42,83 @@ const Mailings = () => { |
|
|
|
|
setIsReSubscribed(true) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
await saveUserInfo({ |
|
|
|
|
address_line1, |
|
|
|
|
address_line2, |
|
|
|
|
city, |
|
|
|
|
cityId, |
|
|
|
|
countryId: country?.id!, |
|
|
|
|
firstname, |
|
|
|
|
isUnsubscribed, |
|
|
|
|
language_id: language?.id, |
|
|
|
|
lastname, |
|
|
|
|
phone, |
|
|
|
|
postalCode: postal_code, |
|
|
|
|
region, |
|
|
|
|
}) |
|
|
|
|
await fetchUserInfo() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let content |
|
|
|
|
if (is_unsubscribed) { |
|
|
|
|
content = ( |
|
|
|
|
<ContentWrapper> |
|
|
|
|
<Title> |
|
|
|
|
<T9n t='you_are_now_unsubscribed' /> |
|
|
|
|
</Title> |
|
|
|
|
<br /> |
|
|
|
|
<Text> |
|
|
|
|
<T9n t='you_have_been_removed_from_the_inSports_newsletter' /> |
|
|
|
|
</Text> |
|
|
|
|
<ButtonsBlock> |
|
|
|
|
<SolidButton onClick={() => onUnsubscribe(false)}> |
|
|
|
|
<T9n t='resubscribe' /> |
|
|
|
|
</SolidButton> |
|
|
|
|
<ScLink to={PAGES.home}> |
|
|
|
|
<OutlineButton> |
|
|
|
|
<T9n t='go_to_the_main_page' /> |
|
|
|
|
</OutlineButton> |
|
|
|
|
</ScLink> |
|
|
|
|
</ButtonsBlock> |
|
|
|
|
</ContentWrapper> |
|
|
|
|
) |
|
|
|
|
} else { |
|
|
|
|
content = ( |
|
|
|
|
<ContentWrapper> |
|
|
|
|
<Title><T9n t='unsubscribe' /></Title> |
|
|
|
|
<br /> |
|
|
|
|
<Text> |
|
|
|
|
<T9n t='click_unsubscribe_to_stop_receiving_inSports_emails_to' /> |
|
|
|
|
<Email>{' '}{userInfo?.email}</Email> |
|
|
|
|
</Text> |
|
|
|
|
<ButtonsBlock> |
|
|
|
|
<ScLink to={PAGES.home}> |
|
|
|
|
<SolidButton> |
|
|
|
|
<T9n t='cancel' /> |
|
|
|
|
</SolidButton> |
|
|
|
|
</ScLink> |
|
|
|
|
<OutlineButton onClick={() => onUnsubscribe(true)}> |
|
|
|
|
<T9n t='unsubscribe' /> |
|
|
|
|
</OutlineButton> |
|
|
|
|
</ButtonsBlock> |
|
|
|
|
</ContentWrapper> |
|
|
|
|
) |
|
|
|
|
try { |
|
|
|
|
await saveUserInfo({ |
|
|
|
|
...userInfo, |
|
|
|
|
countryId: userInfo.country?.id!, |
|
|
|
|
isUnsubscribed, |
|
|
|
|
language_id: userInfo.language?.id, |
|
|
|
|
postalCode: userInfo.postal_code, |
|
|
|
|
}) |
|
|
|
|
await fetchUserInfo() |
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-empty
|
|
|
|
|
} catch (error) {} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isReSubscribed) { |
|
|
|
|
content = ( |
|
|
|
|
<ContentWrapper> |
|
|
|
|
<Title><T9n t='resubscription_successful' /></Title> |
|
|
|
|
<br /> |
|
|
|
|
<Text> |
|
|
|
|
<T9n t='you_have_been_resubscribed_to_inSports_newsletter' /> |
|
|
|
|
</Text> |
|
|
|
|
<ButtonsBlock> |
|
|
|
|
<ScLink to={PAGES.home}> |
|
|
|
|
<SolidButton> |
|
|
|
|
<T9n t='go_to_the_main_page' /> |
|
|
|
|
</SolidButton> |
|
|
|
|
</ScLink> |
|
|
|
|
</ButtonsBlock> |
|
|
|
|
</ContentWrapper> |
|
|
|
|
) |
|
|
|
|
const getContent = () => { |
|
|
|
|
switch (true) { |
|
|
|
|
case userInfo.is_unsubscribed: |
|
|
|
|
return ( |
|
|
|
|
<ContentWrapper> |
|
|
|
|
<Title> |
|
|
|
|
<T9n t='you_are_now_unsubscribed' /> |
|
|
|
|
</Title> |
|
|
|
|
<br /> |
|
|
|
|
<Text> |
|
|
|
|
<T9n t='you_have_been_removed_from_the_inSports_newsletter' /> |
|
|
|
|
</Text> |
|
|
|
|
<ButtonsBlock> |
|
|
|
|
<SolidButton onClick={() => onUnsubscribe(false)}> |
|
|
|
|
<T9n t='resubscribe' /> |
|
|
|
|
</SolidButton> |
|
|
|
|
<ScLink to={PAGES.home}> |
|
|
|
|
<OutlineButton> |
|
|
|
|
<T9n t='go_to_the_main_page' /> |
|
|
|
|
</OutlineButton> |
|
|
|
|
</ScLink> |
|
|
|
|
</ButtonsBlock> |
|
|
|
|
</ContentWrapper> |
|
|
|
|
) |
|
|
|
|
case isReSubscribed: |
|
|
|
|
return ( |
|
|
|
|
<ContentWrapper> |
|
|
|
|
<Title><T9n t='resubscription_successful' /></Title> |
|
|
|
|
<br /> |
|
|
|
|
<Text> |
|
|
|
|
<T9n t='you_have_been_resubscribed_to_inSports_newsletter' /> |
|
|
|
|
</Text> |
|
|
|
|
<ButtonsBlock> |
|
|
|
|
<ScLink to={PAGES.home}> |
|
|
|
|
<SolidButton> |
|
|
|
|
<T9n t='go_to_the_main_page' /> |
|
|
|
|
</SolidButton> |
|
|
|
|
</ScLink> |
|
|
|
|
</ButtonsBlock> |
|
|
|
|
</ContentWrapper> |
|
|
|
|
) |
|
|
|
|
default: |
|
|
|
|
return ( |
|
|
|
|
<ContentWrapper> |
|
|
|
|
<Title><T9n t='unsubscribe' /></Title> |
|
|
|
|
<br /> |
|
|
|
|
<Text> |
|
|
|
|
<T9n t='click_unsubscribe_to_stop_receiving_inSports_emails_to' /> |
|
|
|
|
<Email>{' '}{userInfo?.email}</Email> |
|
|
|
|
</Text> |
|
|
|
|
<ButtonsBlock> |
|
|
|
|
<ScLink to={PAGES.home}> |
|
|
|
|
<SolidButton> |
|
|
|
|
<T9n t='cancel' /> |
|
|
|
|
</SolidButton> |
|
|
|
|
</ScLink> |
|
|
|
|
<OutlineButton onClick={() => onUnsubscribe(true)}> |
|
|
|
|
<T9n t='unsubscribe' /> |
|
|
|
|
</OutlineButton> |
|
|
|
|
</ButtonsBlock> |
|
|
|
|
</ContentWrapper> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
@ -147,7 +129,7 @@ const Mailings = () => { |
|
|
|
|
</Link> |
|
|
|
|
</HeaderWrapper> |
|
|
|
|
<Body> |
|
|
|
|
{content} |
|
|
|
|
{getContent()} |
|
|
|
|
</Body> |
|
|
|
|
<Footer> |
|
|
|
|
<FooterLogo /> |
|
|
|
|
|