Skip to content

Commit 9d53610

Browse files
Merge pull request #334 from SwissBitcoinPay/webinar-update
Improved referral code handling
2 parents b3e4f45 + db3607c commit 9d53610

File tree

10 files changed

+192
-81
lines changed

10 files changed

+192
-81
lines changed

src/App.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
import ErrorBoundary, {
2626
FallbackComponentProps
2727
} from "react-native-error-boundary";
28-
import { useEffect } from "react";
28+
import { useEffect, useState } from "react";
2929
import { useToast } from "react-native-toast-notifications";
3030
import { useTranslation } from "react-i18next";
3131
import * as Sentry from "@sentry/react-native";
@@ -46,18 +46,29 @@ const ErrorComponent = ({ resetError }: FallbackComponentProps) => {
4646
};
4747

4848
const App = () => {
49+
const toast = useToast();
50+
const [isToastLoaded, setIsToastLoaded] = useState(false);
51+
4952
const { accountConfig } = useAccountConfig({
5053
refresh: false,
5154
listenAppState: true
5255
});
5356
const navigate = useNavigate();
5457

58+
const getIsToastLoaded = () => Object.entries(toast).length === 0;
59+
60+
useEffect(() => {
61+
if (getIsToastLoaded()) {
62+
setIsToastLoaded(true);
63+
}
64+
}, [getIsToastLoaded()]);
65+
5566
useDeepLink();
5667
useRefCode();
5768
useBackHandler();
5869
useSplashScreen();
5970

60-
return (
71+
return isToastLoaded ? (
6172
<>
6273
<ErrorBoundary
6374
FallbackComponent={ErrorComponent}
@@ -92,7 +103,7 @@ const App = () => {
92103
</ErrorBoundary>
93104
<TopLeftLogo />
94105
</>
95-
);
106+
) : null;
96107
};
97108

98109
export default App;

src/assets/translations/en.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,10 @@
408408
"title": "Payout configuration",
409409
"iWantToReceive": "I want to receive my funds...",
410410
"in": "in",
411-
"fees": "From {{percent}}% fees",
411+
"fees": "{{percent}}% fees",
412412
"feesDetails1": "Fees",
413-
"feesFirstYear": "1st year of registration",
414-
"feesAfterwards": "After the 1st year",
413+
"firstThreeMonths": "3 first months",
414+
"feesAfterwards": "After the 3 first months",
415415
"cryptoSignature": "Required signature",
416416
"instantTransfer": "Instant transfer",
417417
"dailyTransfer": "Daily transfer",
@@ -558,7 +558,8 @@
558558
"yourCurrency": "Your currency",
559559
"currency": "Currency",
560560
"currencyDescription": "The default currency of your Business",
561-
"referralCode": "Referral code",
561+
"referralCode": "Referral/promo code",
562+
"feesDiscount": "First 3 months at 0% fees !",
562563
"referralCodeDescription": "If someone brought you to Swiss Bitcoin Pay, please write their referral code here",
563564
"submitDescription1": "By creating your account, you're accepting our",
564565
"submitDescription2": "and",

src/assets/translations/fr.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,10 @@
408408
"title": "Configuration des paiements",
409409
"iWantToReceive": "Je veux recevoir mes fonds...",
410410
"in": "en",
411-
"fees": "Dès {{percent}}% de frais",
411+
"fees": "{{percent}}% de frais",
412412
"feesDetails1": "Frais",
413-
"feesFirstYear": "1ère année d'inscription",
414-
"feesAfterwards": "Après la 1ère année",
413+
"firstThreeMonths": "3 premiers mois",
414+
"feesAfterwards": "Après les 3 premiers mois",
415415
"cryptoSignature": "Signature obligatoire",
416416
"instantTransfer": "Transfert instantané",
417417
"dailyTransfer": "Transfert quotidien",
@@ -558,7 +558,8 @@
558558
"yourCurrency": "Votre devise",
559559
"currency": "Devise",
560560
"currencyDescription": "La devise par défaut de votre entreprise",
561-
"referralCode": "Code de parrainage",
561+
"referralCode": "Code promo/parrainage",
562+
"feesDiscount": "3 premiers mois à 0% de frais !",
562563
"referralCodeDescription": "Si quelqu'un vous a amené à Swiss Bitcoin Pay, écrivez ici son code de parrainage",
563564
"submitDescription1": "En créant votre compte, vous acceptez nos",
564565
"submitDescription2": "et notre",
@@ -639,4 +640,4 @@
639640
"instructions2": "Ne faites jamais de copie dans un cloud, sur votre téléphone ou votre ordinateur. Tout appareil connecté à internet est vulnérable !",
640641
"instructions3": "Ne partagez jamais votre {{backup}} à qui que ce soit. Toute personne qui accède à votre {{backup}} pourra voler tous vos fonds."
641642
}
642-
}
643+
}

src/components/FieldContainer/FieldContainer.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PropsWithChildren, useState } from "react";
1+
import { PropsWithChildren, useEffect, useState } from "react";
22
import { useTheme } from "styled-components";
33
import { IconProp } from "@fortawesome/fontawesome-svg-core";
44
import { Button, ComponentStack, Icon, Text } from "@components";
@@ -31,6 +31,10 @@ export const FieldContainer = ({
3131

3232
const [isOpen, setIsOpen] = useState(isDefaultOpen);
3333

34+
useEffect(() => {
35+
setIsOpen(isDefaultOpen);
36+
}, [isDefaultOpen]);
37+
3438
return (
3539
<S.StyledFieldContainer
3640
{...(isLarge
@@ -51,7 +55,6 @@ export const FieldContainer = ({
5155
>
5256
<S.FieldTitleContainer
5357
isOpen={isOpen}
54-
direction="vertical"
5558
{...(isLarge
5659
? {
5760
direction: "horizontal",

src/components/PayoutConfig/PayoutConfig.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export type BitcoinFiatFormSettings = {
104104
rates?: RatesType;
105105
currency: AccountConfigType["currency"];
106106
setIsValid: (value: boolean) => void;
107+
isDiscountFees: boolean;
107108
};
108109

109110
export type PayoutConfigProps = Omit<
@@ -122,7 +123,8 @@ export const PayoutConfig = ({
122123
setValue,
123124
setError,
124125
trigger,
125-
currency
126+
currency,
127+
isDiscountFees
126128
}: PayoutConfigProps) => {
127129
const { t } = useTranslation(undefined, {
128130
keyPrefix: "screens.payoutConfig"
@@ -174,7 +176,7 @@ export const PayoutConfig = ({
174176

175177
const isEURInstantSEPA = useMemo(
176178
() =>
177-
false &&
179+
true &&
178180
currency === "EUR" &&
179181
(!ownerCountry || isSEPACountry(ownerCountry || "")),
180182
[currency, ownerCountry]
@@ -284,7 +286,7 @@ export const PayoutConfig = ({
284286
</S.SubPercentageView>
285287
</S.ValueContent>
286288
<S.SliderDetailsText>
287-
💸 {t("fees", { percent: 0.21 })}
289+
💸 {t("fees", { percent: 1 })}
288290
</S.SliderDetailsText>
289291
<S.SliderDetailsText>
290292
🔑 {t("cryptoSignature")}
@@ -305,7 +307,7 @@ export const PayoutConfig = ({
305307
</S.SubPercentageView>
306308
</S.ValueContent>
307309
<S.SliderDetailsText>
308-
{t("fees", { percent: 0.21 })} 💸
310+
{t("fees", { percent: 1.5 })} 💸
309311
</S.SliderDetailsText>
310312
<S.SliderDetailsText>
311313
{isInstant
@@ -322,7 +324,11 @@ export const PayoutConfig = ({
322324
title={t("bitcoinSettings")}
323325
isValid={isBtcSettingsValid}
324326
/>
325-
<BitcoinSettings {...formProps} currency={currency} />
327+
<BitcoinSettings
328+
{...formProps}
329+
currency={currency}
330+
isDiscountFees={isDiscountFees}
331+
/>
326332
</ComponentStack>
327333
)}
328334
{isReceiveFiat && (
@@ -336,6 +342,7 @@ export const PayoutConfig = ({
336342
currency={bankCurrency}
337343
isEURInstantSEPA={isEURInstantSEPA}
338344
isGBPFasterPayments={isGBPFasterPayments}
345+
isDiscountFees={isDiscountFees}
339346
/>
340347
</ComponentStack>
341348
)}

src/components/PayoutConfig/components/BitcoinSettings/BitcoinSettings.tsx

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ export const BitcoinSettings = ({
7474
setValue,
7575
resetField,
7676
watch,
77-
control
77+
control,
78+
isDiscountFees
7879
}: BitcoinFiatFormSettings) => {
7980
const isLarge = useIsScreenSizeMin("large");
8081
const { t } = useTranslation(undefined, {
@@ -415,7 +416,9 @@ export const BitcoinSettings = ({
415416
},
416417
{ shouldDirty: true }
417418
);
418-
setValue("walletType", signatureData.walletType, { shouldDirty: true });
419+
setValue("walletType", signatureData.walletType, {
420+
shouldDirty: true
421+
});
419422
toast.show(
420423
t("hardwareConnectSuccess", {
421424
hardwareWallet: hardwareNames[signatureData.walletType]
@@ -765,25 +768,32 @@ export const BitcoinSettings = ({
765768
/>
766769
<ComponentStack>
767770
<ComponentStack gapSize={14}>
768-
<FieldDescription>💶 {t("feesDetails1")}</FieldDescription>
769-
<ComponentStack gapSize={2}>
770-
<DescriptionLine>
771-
<FieldDescription isHighlighted={isNewAccount}>
772-
{t("feesFirstYear")}
773-
</FieldDescription>
774-
<FieldDescription isHighlighted={isNewAccount}>
775-
0.21%
776-
</FieldDescription>
777-
</DescriptionLine>
778-
<DescriptionLine>
779-
<FieldDescription isHighlighted={!isNewAccount}>
780-
{t("feesAfterwards")}
781-
</FieldDescription>
782-
<FieldDescription isHighlighted={!isNewAccount}>
783-
1%
784-
</FieldDescription>
785-
</DescriptionLine>
786-
</ComponentStack>
771+
<DescriptionLine>
772+
<FieldDescription>💶 {t("feesDetails1")}</FieldDescription>
773+
{!isDiscountFees ? <FieldDescription>1%</FieldDescription> : null}
774+
</DescriptionLine>
775+
{isDiscountFees ? (
776+
<>
777+
<ComponentStack gapSize={2}>
778+
<DescriptionLine>
779+
<FieldDescription isHighlighted={isNewAccount}>
780+
{t("firstThreeMonths")}
781+
</FieldDescription>
782+
<FieldDescription isHighlighted={isNewAccount}>
783+
0%
784+
</FieldDescription>
785+
</DescriptionLine>
786+
<DescriptionLine>
787+
<FieldDescription isHighlighted={!isNewAccount}>
788+
{t("feesAfterwards")}
789+
</FieldDescription>
790+
<FieldDescription isHighlighted={!isNewAccount}>
791+
1%
792+
</FieldDescription>
793+
</DescriptionLine>
794+
</ComponentStack>
795+
</>
796+
) : null}
787797
<FieldDescription>
788798
🔐 {t("receiveInBtcDescription1", { percent: btcPercent })}
789799
</FieldDescription>

src/components/PayoutConfig/components/FiatSettings/FiatSettings.tsx

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export const FiatSettings = ({
3939
control,
4040
watch,
4141
isEURInstantSEPA,
42-
isGBPFasterPayments
42+
isGBPFasterPayments,
43+
isDiscountFees
4344
}: FiatSettingsProps) => {
4445
const { colors } = useTheme();
4546
const { t: tRoot } = useTranslation();
@@ -272,25 +273,32 @@ export const FiatSettings = ({
272273
return (
273274
<ComponentStack gapSize={32}>
274275
<ComponentStack gapSize={14}>
275-
<FieldDescription>💶 {t("feesDetails1")}</FieldDescription>
276-
<ComponentStack gapSize={2}>
277-
<DescriptionLine>
278-
<FieldDescription isHighlighted={isNewAccount}>
279-
{t("feesFirstYear")}
280-
</FieldDescription>
281-
<FieldDescription isHighlighted={isNewAccount}>
282-
0.21%
283-
</FieldDescription>
284-
</DescriptionLine>
285-
<DescriptionLine>
286-
<FieldDescription isHighlighted={!isNewAccount}>
287-
{t("feesAfterwards")}
288-
</FieldDescription>
289-
<FieldDescription isHighlighted={!isNewAccount}>
290-
1.5%
291-
</FieldDescription>
292-
</DescriptionLine>
293-
</ComponentStack>
276+
<DescriptionLine>
277+
<FieldDescription>💶 {t("feesDetails1")}</FieldDescription>
278+
{!isDiscountFees ? <FieldDescription>1.5%</FieldDescription> : null}
279+
</DescriptionLine>
280+
{isDiscountFees ? (
281+
<>
282+
<ComponentStack gapSize={2}>
283+
<DescriptionLine>
284+
<FieldDescription isHighlighted={isNewAccount}>
285+
{t("firstThreeMonths")}
286+
</FieldDescription>
287+
<FieldDescription isHighlighted={isNewAccount}>
288+
0%
289+
</FieldDescription>
290+
</DescriptionLine>
291+
<DescriptionLine>
292+
<FieldDescription isHighlighted={!isNewAccount}>
293+
{t("feesAfterwards")}
294+
</FieldDescription>
295+
<FieldDescription isHighlighted={!isNewAccount}>
296+
1.5%
297+
</FieldDescription>
298+
</DescriptionLine>
299+
</ComponentStack>
300+
</>
301+
) : null}
294302
<FieldDescription>
295303
🏦{" "}
296304
{t("receiveInBankDescription1", {

src/components/TextField/TextField.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type TextInputProps = Omit<
4040

4141
type TextFieldProps = TextInputProps & {
4242
copyable?: boolean;
43-
pastable?: boolean;
43+
pastable?: boolean | ((pastedValue?: string) => void);
4444
qrDisplayable?: boolean;
4545
qrDisplayValue?: string;
4646
qrScannable?: boolean;
@@ -131,12 +131,16 @@ export const TextField = forwardRef<TextInput, TextFieldProps>(
131131
}, [value]);
132132

133133
const onPaste = useCallback(async () => {
134+
const pastedValue = await Clipboard.getString();
135+
_onChangeText(pastedValue);
136+
if (typeof pastable === "function") {
137+
pastable(pastedValue);
138+
}
134139
setIsPasted(true);
135-
_onChangeText(await Clipboard.getString());
136140
setTimeout(() => {
137141
setIsPasted(false);
138142
}, 1500);
139-
}, [_onChangeText]);
143+
}, [_onChangeText, pastable]);
140144

141145
const onToggleScanQrModal = useCallback(() => {
142146
setIsScanModalOpen(!isScanModalOpen);

0 commit comments

Comments
 (0)