-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
117 changed files
with
2,461 additions
and
1,324 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
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
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
This file was deleted.
Oops, something went wrong.
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,47 @@ | ||
import { ChangeEvent } from 'react'; | ||
|
||
import { useDispatch } from 'react-redux'; | ||
|
||
import { togglePartnersPromotionAction } from 'app/store/partners-promotion/actions'; | ||
import { useShouldShowPartnersPromoSelector } from 'app/store/partners-promotion/selectors'; | ||
import { t } from 'lib/i18n'; | ||
import { useConfirm } from 'lib/ui/dialog'; | ||
|
||
export const usePartnersPromotionSettings = () => { | ||
const dispatch = useDispatch(); | ||
const confirm = useConfirm(); | ||
|
||
const isEnabled = useShouldShowPartnersPromoSelector(); | ||
|
||
const handleHidePromotion = async () => { | ||
const confirmed = await confirm({ | ||
title: t('closePartnersPromotion'), | ||
children: t('closePartnersPromoConfirm'), | ||
confirmButtonText: t('disable') | ||
}); | ||
|
||
if (confirmed) { | ||
dispatch(togglePartnersPromotionAction(false)); | ||
} | ||
}; | ||
|
||
const handleShowPromotion = async () => { | ||
const confirmed = await confirm({ | ||
title: t('enablePartnersPromotionConfirm'), | ||
children: t('enablePartnersPromotionDescriptionConfirm'), | ||
confirmButtonText: t('enable') | ||
}); | ||
|
||
if (confirmed) { | ||
dispatch(togglePartnersPromotionAction(true)); | ||
} | ||
}; | ||
|
||
const setEnabled = (toChecked: boolean, event?: ChangeEvent<HTMLInputElement>) => { | ||
event?.preventDefault(); | ||
|
||
return toChecked ? handleShowPromotion() : handleHidePromotion(); | ||
}; | ||
|
||
return { isEnabled, setEnabled }; | ||
}; |
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,67 @@ | ||
import React, { ChangeEvent, useCallback } from 'react'; | ||
|
||
import { useDispatch } from 'react-redux'; | ||
|
||
import { setAcceptedTermsVersionAction, setReferralLinksEnabledAction } from 'app/store/settings/actions'; | ||
import { useAcceptedTermsVersionSelector, useReferralLinksEnabledSelector } from 'app/store/settings/selectors'; | ||
import { | ||
PRIVACY_POLICY_URL, | ||
RECENT_TERMS_VERSION, | ||
TERMS_OF_USE_URL, | ||
TERMS_WITH_REFERRALS_VERSION | ||
} from 'lib/constants'; | ||
import { t, T } from 'lib/i18n'; | ||
import { useConfirm } from 'lib/ui/dialog'; | ||
|
||
export const useReferralLinksSettings = () => { | ||
const dispatch = useDispatch(); | ||
const enabled = useReferralLinksEnabledSelector(); | ||
const acceptedTermsVersion = useAcceptedTermsVersionSelector(); | ||
const confirm = useConfirm(); | ||
|
||
const setEnabled = useCallback( | ||
async (toChecked: boolean, event?: ChangeEvent<HTMLInputElement>) => { | ||
event?.preventDefault(); | ||
|
||
if (toChecked && acceptedTermsVersion < TERMS_WITH_REFERRALS_VERSION) { | ||
const confirmed = await confirm({ | ||
title: <T id="confirmEnableReferralLinksTitle" />, | ||
description: ( | ||
<T | ||
id="confirmEnableReferralLinksDescription" | ||
substitutions={[ | ||
<a | ||
href={TERMS_OF_USE_URL} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="underline text-secondary" | ||
> | ||
<T id="termsOfUsage" key="termsLink" /> | ||
</a>, | ||
<a | ||
href={PRIVACY_POLICY_URL} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="underline text-secondary" | ||
> | ||
<T id="privacyPolicy" key="privacyPolicyLink" /> | ||
</a> | ||
]} | ||
/> | ||
), | ||
confirmButtonText: t('agreeAndContinue') | ||
}); | ||
|
||
if (!confirmed) { | ||
return; | ||
} | ||
} | ||
|
||
dispatch(setAcceptedTermsVersionAction(RECENT_TERMS_VERSION)); | ||
dispatch(setReferralLinksEnabledAction(toChecked)); | ||
}, | ||
[acceptedTermsVersion, confirm, dispatch] | ||
); | ||
|
||
return { isEnabled: enabled, setEnabled }; | ||
}; |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.