react-native-fpay 0.4.29 → 0.4.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/FountainPayProvider.js +5 -0
- package/lib/module/FountainPayProvider.js.map +1 -1
- package/lib/module/core/api/index.js +59 -0
- package/lib/module/core/api/index.js.map +1 -1
- package/lib/module/core/types/index.js +32 -0
- package/lib/module/core/types/index.js.map +1 -1
- package/lib/module/engine/FPEngine.js +9 -0
- package/lib/module/engine/FPEngine.js.map +1 -1
- package/lib/module/hooks/useLocation.js +66 -0
- package/lib/module/hooks/useLocation.js.map +1 -0
- package/lib/module/ui/components/ConfirmScreen.js +43 -51
- package/lib/module/ui/components/ConfirmScreen.js.map +1 -1
- package/lib/module/ui/components/RecurringToggle.js +94 -0
- package/lib/module/ui/components/RecurringToggle.js.map +1 -0
- package/lib/module/ui/modals/FPShell.js +19 -0
- package/lib/module/ui/modals/FPShell.js.map +1 -1
- package/lib/module/ui/screens/BillsScreen.js +186 -0
- package/lib/module/ui/screens/BillsScreen.js.map +1 -0
- package/lib/module/ui/screens/ResultScreen.js +113 -28
- package/lib/module/ui/screens/ResultScreen.js.map +1 -1
- package/lib/module/ui/screens/SendScreen.js +85 -16
- package/lib/module/ui/screens/SendScreen.js.map +1 -1
- package/lib/module/ui/screens/sub/billPayment/AirtimeScreen.js +257 -0
- package/lib/module/ui/screens/sub/billPayment/AirtimeScreen.js.map +1 -0
- package/lib/module/ui/screens/sub/billPayment/CableScreen.js +264 -0
- package/lib/module/ui/screens/sub/billPayment/CableScreen.js.map +1 -0
- package/lib/module/ui/screens/sub/billPayment/DataScreen.js +273 -0
- package/lib/module/ui/screens/sub/billPayment/DataScreen.js.map +1 -0
- package/lib/module/ui/screens/sub/billPayment/ElectricityScreen.js +337 -0
- package/lib/module/ui/screens/sub/billPayment/ElectricityScreen.js.map +1 -0
- package/lib/module/ui/screens/sub/sendPayment/TransferSubScreen.js +1 -1
- package/lib/module/ui/screens/sub/sendPayment/TransferSubScreen.js.map +1 -1
- package/lib/typescript/src/FountainPayProvider.d.ts.map +1 -1
- package/lib/typescript/src/core/api/index.d.ts +52 -63
- package/lib/typescript/src/core/api/index.d.ts.map +1 -1
- package/lib/typescript/src/core/types/index.d.ts +159 -6
- package/lib/typescript/src/core/types/index.d.ts.map +1 -1
- package/lib/typescript/src/engine/FPEngine.d.ts +4 -2
- package/lib/typescript/src/engine/FPEngine.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useLocation.d.ts +12 -0
- package/lib/typescript/src/hooks/useLocation.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/ConfirmScreen.d.ts +25 -4
- package/lib/typescript/src/ui/components/ConfirmScreen.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/RecurringToggle.d.ts +7 -0
- package/lib/typescript/src/ui/components/RecurringToggle.d.ts.map +1 -0
- package/lib/typescript/src/ui/modals/FPShell.d.ts.map +1 -1
- package/lib/typescript/src/ui/screens/BillsScreen.d.ts +10 -0
- package/lib/typescript/src/ui/screens/BillsScreen.d.ts.map +1 -0
- package/lib/typescript/src/ui/screens/ResultScreen.d.ts +20 -3
- package/lib/typescript/src/ui/screens/ResultScreen.d.ts.map +1 -1
- package/lib/typescript/src/ui/screens/SendScreen.d.ts.map +1 -1
- package/lib/typescript/src/ui/screens/sub/billPayment/AirtimeScreen.d.ts +15 -0
- package/lib/typescript/src/ui/screens/sub/billPayment/AirtimeScreen.d.ts.map +1 -0
- package/lib/typescript/src/ui/screens/sub/billPayment/CableScreen.d.ts +14 -0
- package/lib/typescript/src/ui/screens/sub/billPayment/CableScreen.d.ts.map +1 -0
- package/lib/typescript/src/ui/screens/sub/billPayment/DataScreen.d.ts +14 -0
- package/lib/typescript/src/ui/screens/sub/billPayment/DataScreen.d.ts.map +1 -0
- package/lib/typescript/src/ui/screens/sub/billPayment/ElectricityScreen.d.ts +16 -0
- package/lib/typescript/src/ui/screens/sub/billPayment/ElectricityScreen.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/FountainPayProvider.tsx +7 -0
- package/src/core/api/index.ts +149 -27
- package/src/core/types/index.ts +194 -11
- package/src/engine/FPEngine.ts +12 -1
- package/src/hooks/useLocation.ts +81 -0
- package/src/index.ts +9 -1
- package/src/ui/components/ConfirmScreen.tsx +47 -54
- package/src/ui/components/RecurringToggle.tsx +106 -0
- package/src/ui/modals/FPShell.tsx +26 -3
- package/src/ui/screens/BillsScreen.tsx +197 -0
- package/src/ui/screens/ResultScreen.tsx +129 -28
- package/src/ui/screens/SendScreen.tsx +124 -68
- package/src/ui/screens/sub/billPayment/AirtimeScreen.tsx +252 -0
- package/src/ui/screens/sub/billPayment/CableScreen.tsx +274 -0
- package/src/ui/screens/sub/billPayment/DataScreen.tsx +263 -0
- package/src/ui/screens/sub/billPayment/ElectricityScreen.tsx +344 -0
- package/src/ui/screens/sub/sendPayment/TransferSubScreen.tsx +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// components/RecurringToggle.tsx
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import { Switch } from 'react-native';
|
|
6
|
+
import styled from 'styled-components/native';
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
const Wrapper = styled.View`
|
|
9
|
+
background-color: #f5f3ff;
|
|
10
|
+
border-radius: 14px;
|
|
11
|
+
padding: 14px 16px;
|
|
12
|
+
margin-top: 12px;
|
|
13
|
+
border-width: 1px;
|
|
14
|
+
border-color: #ede9fe;
|
|
15
|
+
`;
|
|
16
|
+
const TopRow = styled.View`
|
|
17
|
+
flex-direction: row;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
`;
|
|
21
|
+
const TextBlock = styled.View`flex: 1; margin-right: 12px;`;
|
|
22
|
+
const ToggleLabel = styled.Text`
|
|
23
|
+
font-size: 14px;
|
|
24
|
+
font-weight: 600;
|
|
25
|
+
color: #4f46e5;
|
|
26
|
+
`;
|
|
27
|
+
const ToggleSubtext = styled.Text`
|
|
28
|
+
font-size: 12px;
|
|
29
|
+
color: #7c6fcd;
|
|
30
|
+
margin-top: 2px;
|
|
31
|
+
`;
|
|
32
|
+
const FreqRow = styled.View`
|
|
33
|
+
flex-direction: row;
|
|
34
|
+
gap: 8px;
|
|
35
|
+
margin-top: 12px;
|
|
36
|
+
`;
|
|
37
|
+
const FreqBtn = styled.TouchableOpacity`
|
|
38
|
+
flex: 1;
|
|
39
|
+
padding: 8px 4px;
|
|
40
|
+
border-radius: 8px;
|
|
41
|
+
align-items: center;
|
|
42
|
+
background-color: ${p => p.selected ? '#4f46e5' : '#fff'};
|
|
43
|
+
border-width: 1px;
|
|
44
|
+
border-color: ${p => p.selected ? '#4f46e5' : '#ddd6fe'};
|
|
45
|
+
`;
|
|
46
|
+
const FreqText = styled.Text`
|
|
47
|
+
font-size: 11px;
|
|
48
|
+
font-weight: 600;
|
|
49
|
+
color: ${p => p.selected ? '#fff' : '#7c6fcd'};
|
|
50
|
+
`;
|
|
51
|
+
const FREQUENCIES = ['DAILY', 'WEEKLY', 'MONTHLY', 'YEARLY'];
|
|
52
|
+
export default function RecurringToggle({
|
|
53
|
+
onToggle
|
|
54
|
+
}) {
|
|
55
|
+
const [enabled, setEnabled] = useState(false);
|
|
56
|
+
const [frequency, setFrequency] = useState('MONTHLY');
|
|
57
|
+
const handleSwitch = val => {
|
|
58
|
+
setEnabled(val);
|
|
59
|
+
onToggle(val, frequency);
|
|
60
|
+
};
|
|
61
|
+
const handleFreq = freq => {
|
|
62
|
+
setFrequency(freq);
|
|
63
|
+
if (enabled) onToggle(true, freq);
|
|
64
|
+
};
|
|
65
|
+
return /*#__PURE__*/_jsxs(Wrapper, {
|
|
66
|
+
children: [/*#__PURE__*/_jsxs(TopRow, {
|
|
67
|
+
children: [/*#__PURE__*/_jsxs(TextBlock, {
|
|
68
|
+
children: [/*#__PURE__*/_jsx(ToggleLabel, {
|
|
69
|
+
children: "\uD83D\uDD01 Make this recurring"
|
|
70
|
+
}), /*#__PURE__*/_jsx(ToggleSubtext, {
|
|
71
|
+
children: "Auto-pay this on a schedule"
|
|
72
|
+
})]
|
|
73
|
+
}), /*#__PURE__*/_jsx(Switch, {
|
|
74
|
+
value: enabled,
|
|
75
|
+
onValueChange: handleSwitch,
|
|
76
|
+
trackColor: {
|
|
77
|
+
false: '#ddd',
|
|
78
|
+
true: '#818cf8'
|
|
79
|
+
},
|
|
80
|
+
thumbColor: enabled ? '#4f46e5' : '#f4f3f4'
|
|
81
|
+
})]
|
|
82
|
+
}), enabled && /*#__PURE__*/_jsx(FreqRow, {
|
|
83
|
+
children: FREQUENCIES.map(freq => /*#__PURE__*/_jsx(FreqBtn, {
|
|
84
|
+
selected: frequency === freq,
|
|
85
|
+
onPress: () => handleFreq(freq),
|
|
86
|
+
children: /*#__PURE__*/_jsx(FreqText, {
|
|
87
|
+
selected: frequency === freq,
|
|
88
|
+
children: freq[0] + freq.slice(1).toLowerCase()
|
|
89
|
+
})
|
|
90
|
+
}, freq))
|
|
91
|
+
})]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=RecurringToggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useState","Switch","styled","jsx","_jsx","jsxs","_jsxs","Wrapper","View","TopRow","TextBlock","ToggleLabel","Text","ToggleSubtext","FreqRow","FreqBtn","TouchableOpacity","p","selected","FreqText","FREQUENCIES","RecurringToggle","onToggle","enabled","setEnabled","frequency","setFrequency","handleSwitch","val","handleFreq","freq","children","value","onValueChange","trackColor","false","true","thumbColor","map","onPress","slice","toLowerCase"],"sourceRoot":"../../../../src","sources":["ui/components/RecurringToggle.tsx"],"mappings":";;AAAA;AACA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,MAAM,Q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d","ignoreList":[]}
|
|
@@ -11,6 +11,7 @@ import { View, StyleSheet, Animated, Dimensions, StatusBar, Platform } from 'rea
|
|
|
11
11
|
import { _onEvent } from "../../engine/FPEngine.js";
|
|
12
12
|
import SendScreen from "../screens/SendScreen.js";
|
|
13
13
|
import ReceiveScreen from "../screens/ReceiveScreen.js";
|
|
14
|
+
import BillsScreen from "../screens/BillsScreen.js";
|
|
14
15
|
import FPValidateBvn from "../modals/FPValidateBvn.js";
|
|
15
16
|
import FPCreatePin from "../modals/FPCreatePin.js";
|
|
16
17
|
import { FPPaymentRequestModal } from "./FPPaymentRequestModal.js";
|
|
@@ -70,11 +71,23 @@ export function FPShell() {
|
|
|
70
71
|
currency: data?.currency
|
|
71
72
|
});
|
|
72
73
|
});
|
|
74
|
+
const unsubBills = _onEvent('show_bills', d => {
|
|
75
|
+
const data = d;
|
|
76
|
+
open({
|
|
77
|
+
mode: 'bills',
|
|
78
|
+
user: data?.user,
|
|
79
|
+
amount: data?.amount,
|
|
80
|
+
category: data?.category
|
|
81
|
+
});
|
|
82
|
+
});
|
|
73
83
|
const unsubClose = _onEvent('close_send', () => close());
|
|
84
|
+
const unsubCloseBills = _onEvent('close_bills', () => close());
|
|
74
85
|
return () => {
|
|
75
86
|
unsubSend();
|
|
76
87
|
unsubReceive();
|
|
88
|
+
unsubBills();
|
|
77
89
|
unsubClose();
|
|
90
|
+
unsubCloseBills();
|
|
78
91
|
};
|
|
79
92
|
}, [open, close]);
|
|
80
93
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -104,6 +117,12 @@ export function FPShell() {
|
|
|
104
117
|
onClose: close,
|
|
105
118
|
onPaymentReceived: FPEngine.getCallbacks().onPaymentReceived,
|
|
106
119
|
onError: FPEngine.getCallbacks().onError
|
|
120
|
+
}), sheet.mode === 'bills' && sheet.category && /*#__PURE__*/_jsx(BillsScreen, {
|
|
121
|
+
category: sheet.category,
|
|
122
|
+
amount: sheet.amount ?? 0,
|
|
123
|
+
user: user ?? null,
|
|
124
|
+
onClose: close,
|
|
125
|
+
onError: FPEngine.getCallbacks().onError
|
|
107
126
|
})]
|
|
108
127
|
})
|
|
109
128
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useState","useRef","View","StyleSheet","Animated","Dimensions","StatusBar","Platform","_onEvent","SendScreen","ReceiveScreen","FPValidateBvn","FPCreatePin","FPPaymentRequestModal","FPEngine","C","S","F","useFPStore","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","width","SCREEN_W","height","SCREEN_H","get","FPShell","sheet","setSheet","mode","visible","setVisible","slide","Value","current","user","s","open","state","spring","toValue","useNativeDriver","tension","friction","start","close","timing","duration","unsubSend","d","data","amount","currency","unsubReceive","unsubClose","children","verifyBvn","hasPin","style","st","fullscreen","transform","translateY","content","account","getAccount","onClose","onPaymentSent","tx","getCallbacks","onError","onPaymentReceived","create","position","top","left","backgroundColor","white","zIndex","elevation","safeArea","flex","header","flexDirection","alignItems","justifyContent","paddingHorizontal","lg","paddingTop","OS","currentHeight","sm","md","paddingBottom","closeBtn","borderRadius","surface","closeIcon","closeLine","ink","titleWrap","title","fontSize","fontWeight","color","letterSpacing","dot","marginRight","divider","border","marginHorizontal"],"sourceRoot":"../../../../src","sources":["ui/modals/FPShell.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,OAAO;AAC1D,SACEC,IAAI,EACJC,UAAU,EACVC,QAAQ,EACRC,UAAU,EACVC,SAAS,EACTC,QAAQ,QACH,cAAc;AACrB,SAASC,QAAQ,QAAQ,0BAAuB;AAChD,OAAOC,UAAU,MAAM,0BAAuB;AAC9C,OAAOC,aAAa,MAAM,6BAA0B;AACpD,OAAOC,aAAa,MAAM,4BAAyB;AACnD,OAAOC,WAAW,MAAM,0BAAuB;AAC/C,SAASC,qBAAqB,QAAQ,4BAAyB;AAC/D,SAASC,QAAQ,QAAQ,0BAAuB;AAChD,SAASC,CAAC,EAAEC,CAAC,EAAEC,CAAC,QAAQ,mBAAU;AAElC,SAASC,UAAU,QAAQ,wBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAEjD,MAAM;EAAEC,KAAK,EAAEC,QAAQ;EAAEC,MAAM,EAAEC;AAAS,CAAC,
|
|
1
|
+
{"version":3,"names":["React","useEffect","useState","useRef","View","StyleSheet","Animated","Dimensions","StatusBar","Platform","_onEvent","SendScreen","ReceiveScreen","BillsScreen","FPValidateBvn","FPCreatePin","FPPaymentRequestModal","FPEngine","C","S","F","useFPStore","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","width","SCREEN_W","height","SCREEN_H","get","FPShell","sheet","setSheet","mode","visible","setVisible","slide","Value","current","user","s","open","state","spring","toValue","useNativeDriver","tension","friction","start","close","timing","duration","unsubSend","d","data","amount","currency","unsubReceive","unsubBills","category","unsubClose","unsubCloseBills","children","verifyBvn","hasPin","style","st","fullscreen","transform","translateY","content","account","getAccount","onClose","onPaymentSent","tx","getCallbacks","onError","onPaymentReceived","create","position","top","left","backgroundColor","white","zIndex","elevation","safeArea","flex","header","flexDirection","alignItems","justifyContent","paddingHorizontal","lg","paddingTop","OS","currentHeight","sm","md","paddingBottom","closeBtn","borderRadius","surface","closeIcon","closeLine","ink","titleWrap","title","fontSize","fontWeight","color","letterSpacing","dot","marginRight","divider","border","marginHorizontal"],"sourceRoot":"../../../../src","sources":["ui/modals/FPShell.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,OAAO;AAC1D,SACEC,IAAI,EACJC,UAAU,EACVC,QAAQ,EACRC,UAAU,EACVC,SAAS,EACTC,QAAQ,QACH,cAAc;AACrB,SAASC,QAAQ,QAAQ,0BAAuB;AAChD,OA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AAK;IACjBC,KAAK,EAAEhG,CAAC,CAAC2F,GAAG;IACZM,aAAa,EAAE,CAAC;EAClB,CAAC;EACDC,GAAG,EAAE;IACHxF,KAAK,EAAE,CAAC;IACRE,MAAM,EAAE,CAAC;IACT2E,YAAY,EAAE,CAAC;IACfY,WAAW,EAAE,EAAE,CAAE;EACnB,CAAC;EACDC,OAAO,EAAE;IACPxF,MAAM,EAAE,CAAC;IACTwD,eAAe,EAAEpE,CAAC,CAACqG,MAAM;IACzBC,gBAAgB,EAAE;EACpB,CAAC;EACD/C,OAAO,EAAE;IACPkB,IAAI,EAAE,CAAC;IACPL,eAAe,EAAEpE,CAAC,CAACwF;EACrB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// ─────────────────────────────────────────────
|
|
4
|
+
// Bills Screen
|
|
5
|
+
// Renders the category-specific sub-screen
|
|
6
|
+
// (Airtime / Data / Electricity / Cable), then
|
|
7
|
+
// runs the same Confirm (PIN) → Loading →
|
|
8
|
+
// Result flow SendScreen uses, generalized.
|
|
9
|
+
// ─────────────────────────────────────────────
|
|
10
|
+
import { useState } from 'react';
|
|
11
|
+
import { View, TouchableOpacity, Text } from 'react-native';
|
|
12
|
+
import styled from 'styled-components/native';
|
|
13
|
+
import Ionicons from 'react-native-vector-icons/Ionicons';
|
|
14
|
+
import AirtimeSubScreen from "./sub/billPayment/AirtimeScreen.js";
|
|
15
|
+
import DataSubScreen from "./sub/billPayment/DataScreen.js";
|
|
16
|
+
import ElectricitySubScreen from "./sub/billPayment/ElectricityScreen.js";
|
|
17
|
+
import CableSubScreen from "./sub/billPayment/CableScreen.js";
|
|
18
|
+
import ConfirmScreen from "../components/ConfirmScreen.js";
|
|
19
|
+
import { ResultScreen } from "./ResultScreen.js";
|
|
20
|
+
import LoadingAnimation from "../components/LoadingAnimation/index.js";
|
|
21
|
+
import { billsAPI } from "../../core/api/index.js";
|
|
22
|
+
import { getFPStore } from "../../store/FPStore.js";
|
|
23
|
+
import { C, F, S } from "../theme/index.js";
|
|
24
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
25
|
+
const Container = styled(View)`
|
|
26
|
+
flex: 1;
|
|
27
|
+
background-color: ${C.white};
|
|
28
|
+
`;
|
|
29
|
+
const Header = styled(View)`
|
|
30
|
+
flex-direction: row;
|
|
31
|
+
align-items: center;
|
|
32
|
+
justify-content: space-between;
|
|
33
|
+
padding: ${S.md}px ${S.lg}px;
|
|
34
|
+
`;
|
|
35
|
+
const HeaderTitle = styled(Text)`
|
|
36
|
+
font-size: ${F.lg}px;
|
|
37
|
+
font-weight: 800;
|
|
38
|
+
color: ${C.ink};
|
|
39
|
+
`;
|
|
40
|
+
const CloseBtn = styled(TouchableOpacity)`
|
|
41
|
+
width: 36px;
|
|
42
|
+
height: 36px;
|
|
43
|
+
border-radius: 18px;
|
|
44
|
+
background-color: ${C.surface};
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
`;
|
|
48
|
+
const CATEGORY_TITLES = {
|
|
49
|
+
AIRTIME: 'Buy Airtime',
|
|
50
|
+
DATA: 'Buy Data',
|
|
51
|
+
ELECTRICITY: 'Pay Electricity Bill',
|
|
52
|
+
CABLE: 'Pay TV Subscription'
|
|
53
|
+
};
|
|
54
|
+
export default function BillsScreen({
|
|
55
|
+
category,
|
|
56
|
+
amount,
|
|
57
|
+
user,
|
|
58
|
+
onClose,
|
|
59
|
+
onError
|
|
60
|
+
}) {
|
|
61
|
+
const [stage, setStage] = useState('FORM');
|
|
62
|
+
const [loading, setLoading] = useState(false);
|
|
63
|
+
const [pendingPayload, setPendingPayload] = useState(null);
|
|
64
|
+
const [pendingSummaryRows, setPendingSummaryRows] = useState([]);
|
|
65
|
+
const [completedTx, setCompletedTx] = useState(null);
|
|
66
|
+
const handleFormContinue = (payload, summaryRows) => {
|
|
67
|
+
setPendingPayload(payload);
|
|
68
|
+
setPendingSummaryRows(summaryRows);
|
|
69
|
+
setStage('CONFIRM');
|
|
70
|
+
};
|
|
71
|
+
const handleResultClose = () => {
|
|
72
|
+
setCompletedTx(null);
|
|
73
|
+
setStage('FORM');
|
|
74
|
+
onClose();
|
|
75
|
+
};
|
|
76
|
+
const handlePinAuthorized = async tempId => {
|
|
77
|
+
if (!pendingPayload) return;
|
|
78
|
+
setLoading(true);
|
|
79
|
+
try {
|
|
80
|
+
let response;
|
|
81
|
+
switch (pendingPayload.category) {
|
|
82
|
+
case 'AIRTIME':
|
|
83
|
+
response = await billsAPI.purchaseAirtime(pendingPayload, tempId);
|
|
84
|
+
break;
|
|
85
|
+
case 'DATA':
|
|
86
|
+
response = await billsAPI.purchaseData(pendingPayload, tempId);
|
|
87
|
+
break;
|
|
88
|
+
case 'ELECTRICITY':
|
|
89
|
+
response = await billsAPI.purchaseElectricity(pendingPayload, tempId);
|
|
90
|
+
break;
|
|
91
|
+
case 'CABLE':
|
|
92
|
+
response = await billsAPI.purchaseCable(pendingPayload, tempId);
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (!response?.status) {
|
|
96
|
+
onError?.({
|
|
97
|
+
code: 'PURCHASE_FAILED',
|
|
98
|
+
message: response?.message ?? 'Purchase failed'
|
|
99
|
+
});
|
|
100
|
+
// Still show the result screen — ResultScreen polls status itself
|
|
101
|
+
// and renders the failed state, same pattern SendScreen uses.
|
|
102
|
+
}
|
|
103
|
+
setCompletedTx(response?.payload ?? null);
|
|
104
|
+
setStage('RESULT');
|
|
105
|
+
} catch (error) {
|
|
106
|
+
onError?.(error);
|
|
107
|
+
} finally {
|
|
108
|
+
setLoading(false);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const renderForm = () => {
|
|
112
|
+
switch (category) {
|
|
113
|
+
case 'AIRTIME':
|
|
114
|
+
return /*#__PURE__*/_jsx(AirtimeSubScreen, {
|
|
115
|
+
amount: amount,
|
|
116
|
+
onProcessTransaction: handleFormContinue,
|
|
117
|
+
onError: onError
|
|
118
|
+
});
|
|
119
|
+
case 'DATA':
|
|
120
|
+
return /*#__PURE__*/_jsx(DataSubScreen, {
|
|
121
|
+
onProcessTransaction: handleFormContinue,
|
|
122
|
+
onError: onError
|
|
123
|
+
});
|
|
124
|
+
case 'ELECTRICITY':
|
|
125
|
+
return /*#__PURE__*/_jsx(ElectricitySubScreen, {
|
|
126
|
+
amount: amount,
|
|
127
|
+
user: user,
|
|
128
|
+
onProcessTransaction: handleFormContinue,
|
|
129
|
+
onError: onError
|
|
130
|
+
});
|
|
131
|
+
case 'CABLE':
|
|
132
|
+
return /*#__PURE__*/_jsx(CableSubScreen, {
|
|
133
|
+
onProcessTransaction: handleFormContinue,
|
|
134
|
+
onError: onError
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
if (stage === 'RESULT' && completedTx) {
|
|
139
|
+
return /*#__PURE__*/_jsx(ResultScreen, {
|
|
140
|
+
reference: completedTx.reference,
|
|
141
|
+
summaryRows: pendingSummaryRows,
|
|
142
|
+
allowRecurring: false,
|
|
143
|
+
statusFetcher: billsAPI.status,
|
|
144
|
+
onClose: handleResultClose
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return /*#__PURE__*/_jsxs(Container, {
|
|
148
|
+
children: [loading && /*#__PURE__*/_jsx(LoadingAnimation, {
|
|
149
|
+
text: "Processing..."
|
|
150
|
+
}), stage === 'FORM' && /*#__PURE__*/_jsxs(_Fragment, {
|
|
151
|
+
children: [/*#__PURE__*/_jsxs(Header, {
|
|
152
|
+
children: [/*#__PURE__*/_jsx(HeaderTitle, {
|
|
153
|
+
children: CATEGORY_TITLES[category]
|
|
154
|
+
}), /*#__PURE__*/_jsx(CloseBtn, {
|
|
155
|
+
onPress: onClose,
|
|
156
|
+
children: /*#__PURE__*/_jsx(Ionicons, {
|
|
157
|
+
name: "close",
|
|
158
|
+
size: 20,
|
|
159
|
+
color: C.ink
|
|
160
|
+
})
|
|
161
|
+
})]
|
|
162
|
+
}), renderForm()]
|
|
163
|
+
}), stage === 'CONFIRM' && pendingPayload && /*#__PURE__*/_jsxs(_Fragment, {
|
|
164
|
+
children: [/*#__PURE__*/_jsxs(Header, {
|
|
165
|
+
children: [/*#__PURE__*/_jsx(HeaderTitle, {
|
|
166
|
+
children: "Confirm Purchase"
|
|
167
|
+
}), /*#__PURE__*/_jsx(CloseBtn, {
|
|
168
|
+
onPress: () => setStage('FORM'),
|
|
169
|
+
children: /*#__PURE__*/_jsx(Ionicons, {
|
|
170
|
+
name: "close",
|
|
171
|
+
size: 20,
|
|
172
|
+
color: C.ink
|
|
173
|
+
})
|
|
174
|
+
})]
|
|
175
|
+
}), /*#__PURE__*/_jsx(ConfirmScreen, {
|
|
176
|
+
amount: pendingPayload.amountInKobo / 100,
|
|
177
|
+
currency: "\u20A6",
|
|
178
|
+
subtitle: "Double check the details before you proceed. Please note that successful bill payments cannot be reversed.",
|
|
179
|
+
summaryRows: pendingSummaryRows,
|
|
180
|
+
validate: pin => billsAPI.validateBillPin(pin, getFPStore().psspId || ''),
|
|
181
|
+
onContinue: handlePinAuthorized
|
|
182
|
+
})]
|
|
183
|
+
})]
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=BillsScreen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useState","View","TouchableOpacity","Text","styled","Ionicons","AirtimeSubScreen","DataSubScreen","ElectricitySubScreen","CableSubScreen","ConfirmScreen","ResultScreen","LoadingAnimation","billsAPI","getFPStore","C","F","S","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","Container","white","Header","md","lg","HeaderTitle","ink","CloseBtn","surface","CATEGORY_TITLES","AIRTIME","DATA","ELECTRICITY","CABLE","BillsScreen","category","amount","user","onClose","onError","stage","setStage","loading","setLoading","pendingPayload","setPendingPayload","pendingSummaryRows","setPendingSummaryRows","completedTx","setCompletedTx","handleFormContinue","payload","summaryRows","handleResultClose","handlePinAuthorized","tempId","response","purchaseAirtime","purchaseData","purchaseElectricity","purchaseCable","status","code","message","error","renderForm","onProcessTransaction","reference","allowRecurring","statusFetcher","children","text","onPress","name","size","color","amountInKobo","currency","subtitle","validate","pin","validateBillPin","psspId","onContinue"],"sourceRoot":"../../../../src","sources":["ui/screens/BillsScreen.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,OAAO;AAChC,SAASC,IAAI,EAAEC,gBAAgB,EAAEC,IAAI,QAAQ,cAAc;AAC3D,OAAOC,MAAM,MAAM,0BAA0B;AAC7C,OAAOC,QAAQ,MAAM,oCAAoC;AACzD,OAAOC,gBAAgB,MAAM,oCAAiC;AAC9D,OAAOC,aAAa,MAAM,iCAA8B;AACxD,OAAOC,oBAAoB,MAAM,wCAAqC;AACtE,OAAOC,cAAc,MAAM,kCAA+B;AAC1D,OAAOC,aAAa,MAAM,gCAA6B;AACvD,SAASC,YAAY,QAAQ,mBAAgB;AAC7C,OAAOC,gBAAgB,MAAM,yCAAgC;AAC7D,SAASC,QAAQ,QAAQ,yBAAgB;AACzC,SAASC,UAAU,QAAQ,wBAAqB;AAChD,SAASC,CAAC,EAAEC,CAAC,EAAEC,CAAC,QAAQ,mBAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAWnC,MAAMC,SAAS,GAAGpB,MAAM,CAACH,IAAI,CAAC;AAC9B;AACA,sBAAsBc,CAAC,CAACU,KAAK;AAC7B,CAAC;AAED,MAAMC,MAAM,GAAGtB,MAAM,CAACH,IAAI,CAAC;AAC3B;AACA;AACA;AACA,aAAagB,CAAC,CAACU,EAAE,MAAMV,CAAC,CAACW,EAAE;AAC3B,CAAC;AAED,MAAMC,WAAW,GAAGzB,MAAM,CAACD,IAAI,CAAC;AAChC,eAAea,CAAC,CAACY,EAAE;AACnB;AACA,WAAW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pC3B,KAAA,CAAAE,SAAA;MAAAmD,QAAA,gBACErD,KAAA,CAACK,MAAM;QAAAgD,QAAA,gBACLvD,IAAA,CAACU,WAAW;UAAA6C,QAAA,EAAC;QAAgB,CAAa,CAAC,eAC3CvD,IAAA,CAACY,QAAQ;UAAC6C,OAAO,EAAEA,CAAA,KAAM/B,QAAQ,CAAC,MAAM,CAAE;UAAA6B,QAAA,eACxCvD,IAAA,CAACd,QAAQ;YAACwE,IAAI,EAAC,OAAO;YAACC,IAAI,EAAE,EAAG;YAACC,KAAK,EAAEhE,CAAC,CAACe;UAAI,CAAE;QAAC,CACzC,CAAC;MAAA,CACL,CAAC,eACTX,IAAA,CAACT,aAAa;QACZ8B,MAAM,EAAEQ,cAAc,CAACgC,YAAY,GAAG,GAAI;QAC1CC,QAAQ,EAAC,QAAG;QACZC,QAAQ,EAAC,4GAA4G;QACrH1B,WAAW,EAAEN,kBAAmB;QAChCiC,QAAQ,EAAGC,GAAW,IAAKvE,QAAQ,CAACwE,eAAe,CAACD,GAAG,EAAEtE,UAAU,CAAC,CAAC,CAACwE,MAAM,IAAI,EAAE,CAAE;QACpFC,UAAU,EAAE7B;MAAoB,CACjC,CAAC;IAAA,CACF,CACH;EAAA,CACQ,CAAC;AAEhB","ignoreList":[]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { Animated, Easing, TouchableOpacity } from 'react-native';
|
|
5
5
|
import Svg, { Path, Circle } from 'react-native-svg';
|
|
6
6
|
import styled from 'styled-components/native';
|
|
7
7
|
import { C, F, R, S } from "../theme/index.js";
|
|
8
|
-
import { transferAPI } from "../../core/api/index.js";
|
|
8
|
+
import { subscriptionAPI, transferAPI } from "../../core/api/index.js";
|
|
9
9
|
import Gradients from "../components/Gradients/index.js";
|
|
10
|
+
import RecurringToggle from "../components/RecurringToggle.js";
|
|
10
11
|
|
|
11
12
|
// ── Icons ─────────────────────────────────────────────────────
|
|
12
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -198,10 +199,10 @@ function CountdownRing({
|
|
|
198
199
|
|
|
199
200
|
// ── Row ──────────────────────────────────────────────────────
|
|
200
201
|
|
|
201
|
-
|
|
202
|
+
const Row = ({
|
|
202
203
|
label,
|
|
203
204
|
value
|
|
204
|
-
}) {
|
|
205
|
+
}) => {
|
|
205
206
|
return /*#__PURE__*/_jsxs(RowWrap, {
|
|
206
207
|
children: [/*#__PURE__*/_jsx(RowLabel, {
|
|
207
208
|
children: label
|
|
@@ -209,12 +210,28 @@ function Row({
|
|
|
209
210
|
children: value
|
|
210
211
|
})]
|
|
211
212
|
});
|
|
212
|
-
}
|
|
213
|
+
};
|
|
213
214
|
|
|
214
215
|
// ── Main ─────────────────────────────────────────────────────
|
|
215
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Generalized props — ResultScreen no longer assumes a "recipient" or that
|
|
219
|
+
* the underlying transaction came through transferAPI.
|
|
220
|
+
* - reference: used to poll status (via statusFetcher, defaults to transferAPI.status)
|
|
221
|
+
* - summaryRows: extra rows to render in the detail card (e.g. "To", "Channel")
|
|
222
|
+
* beyond the always-present Reference/Date/Status rows
|
|
223
|
+
* - allowRecurring: SendScreen keeps the existing recurring-payment upsell;
|
|
224
|
+
* domains with no concept of "this recipient" (bills) pass false
|
|
225
|
+
* - statusFetcher: which endpoint to poll — defaults to the shared
|
|
226
|
+
* agencyTransaction-backed transferAPI.status, which bill transactions
|
|
227
|
+
* also live in
|
|
228
|
+
*/
|
|
229
|
+
|
|
216
230
|
export function ResultScreen({
|
|
217
|
-
|
|
231
|
+
reference,
|
|
232
|
+
summaryRows,
|
|
233
|
+
allowRecurring = true,
|
|
234
|
+
statusFetcher = transferAPI.status,
|
|
218
235
|
onClose
|
|
219
236
|
}) {
|
|
220
237
|
const [loading, setLoading] = useState(false);
|
|
@@ -223,27 +240,42 @@ export function ResultScreen({
|
|
|
223
240
|
const slideAnim = useRef(new Animated.Value(0)).current; // ← start in place
|
|
224
241
|
const scaleAnim = useRef(new Animated.Value(1)).current; // ← start full size
|
|
225
242
|
|
|
243
|
+
const [recurringEnabled, setRecurringEnabled] = useState(false);
|
|
244
|
+
const [recurringFrequency, setRecurringFrequency] = useState('MONTHLY');
|
|
226
245
|
const isSuccess = transactionDetail?.status.toLowerCase() === 'successful';
|
|
227
246
|
const accentColor = isSuccess ? C.green : C.red;
|
|
228
247
|
const bgColor = isSuccess ? '#E3FCEF' : '#FFEBE6';
|
|
248
|
+
const timerRef = useRef(null);
|
|
249
|
+
const startTimeRef = useRef(Date.now());
|
|
250
|
+
const remainingTimeRef = useRef(COUNTDOWN_SECONDS * 1000);
|
|
251
|
+
const isPausedRef = useRef(false);
|
|
252
|
+
const startTimer = useCallback(duration => {
|
|
253
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
254
|
+
startTimeRef.current = Date.now();
|
|
255
|
+
timerRef.current = setTimeout(onClose, duration);
|
|
256
|
+
}, [onClose]);
|
|
257
|
+
const pauseTimer = useCallback(() => {
|
|
258
|
+
if (isPausedRef.current) return;
|
|
259
|
+
isPausedRef.current = true;
|
|
260
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
261
|
+
// Calculate how much time is left
|
|
262
|
+
const elapsed = Date.now() - startTimeRef.current;
|
|
263
|
+
remainingTimeRef.current = Math.max(remainingTimeRef.current - elapsed, 0);
|
|
264
|
+
}, []);
|
|
265
|
+
const resumeTimer = useCallback(() => {
|
|
266
|
+
if (!isPausedRef.current) return;
|
|
267
|
+
isPausedRef.current = false;
|
|
268
|
+
startTimer(remainingTimeRef.current);
|
|
269
|
+
}, [startTimer]);
|
|
229
270
|
const formatted = `${transactionDetail?.currency || 'NGN'} ${Number(transactionDetail?.amount).toLocaleString('en-NG', {
|
|
230
271
|
minimumFractionDigits: 2
|
|
231
272
|
})}`;
|
|
232
|
-
const recipient = transaction?.recipient;
|
|
233
|
-
const recipientName = recipient?.accountName ?? recipient?.name ?? '—';
|
|
234
|
-
const channelLabel = {
|
|
235
|
-
transfer: 'Bank Transfer',
|
|
236
|
-
bluetooth: 'Bluetooth',
|
|
237
|
-
proximity: 'Nearby',
|
|
238
|
-
nqr: 'QR Code',
|
|
239
|
-
nfc: 'NFC Tap'
|
|
240
|
-
};
|
|
241
273
|
const dateStr = transactionDetail?.createdAt ? new Date(transactionDetail?.createdAt).toLocaleString('en-NG') : '—';
|
|
242
274
|
const loadTransaction = async () => {
|
|
243
275
|
setLoading(true);
|
|
244
276
|
setTransactionDetail(null);
|
|
245
277
|
try {
|
|
246
|
-
const response = await
|
|
278
|
+
const response = await statusFetcher(reference);
|
|
247
279
|
console.log("Transaction payload: ", response);
|
|
248
280
|
if (response.status) {
|
|
249
281
|
setTransactionDetail(response.payload);
|
|
@@ -254,15 +286,65 @@ export function ResultScreen({
|
|
|
254
286
|
setLoading(false);
|
|
255
287
|
}
|
|
256
288
|
};
|
|
289
|
+
const calculateNextDate = (current, frequency) => {
|
|
290
|
+
const date = new Date(current);
|
|
291
|
+
switch (frequency) {
|
|
292
|
+
case 'DAILY':
|
|
293
|
+
date.setDate(date.getDate() + 1);
|
|
294
|
+
break;
|
|
295
|
+
case 'WEEKLY':
|
|
296
|
+
date.setDate(date.getDate() + 7);
|
|
297
|
+
break;
|
|
298
|
+
case 'MONTHLY':
|
|
299
|
+
date.setMonth(date.getMonth() + 1);
|
|
300
|
+
break;
|
|
301
|
+
case 'YEARLY':
|
|
302
|
+
date.setFullYear(date.getFullYear() + 1);
|
|
303
|
+
break;
|
|
304
|
+
default:
|
|
305
|
+
throw new Error(`Unknown frequency: ${frequency}`);
|
|
306
|
+
}
|
|
307
|
+
return date;
|
|
308
|
+
};
|
|
309
|
+
const handlePayment = async () => {
|
|
310
|
+
pauseTimer();
|
|
311
|
+
try {
|
|
312
|
+
await subscriptionAPI.create({
|
|
313
|
+
serviceName: summaryRows?.find(r => r.label === 'To')?.value ?? 'Payment',
|
|
314
|
+
serviceCategory: 'Payment',
|
|
315
|
+
// default category
|
|
316
|
+
amount: transactionDetail.amount,
|
|
317
|
+
// from your existing payment data
|
|
318
|
+
currency: transactionDetail.currency,
|
|
319
|
+
frequency: recurringFrequency,
|
|
320
|
+
accountNumber: transactionDetail.senderAccountNumber,
|
|
321
|
+
receiverAccountNumber: transactionDetail.destAccountNumber,
|
|
322
|
+
logoUrl: transactionDetail.recipientLogo ?? '',
|
|
323
|
+
nextPaymentDate: calculateNextDate(new Date(), recurringFrequency).toISOString()
|
|
324
|
+
});
|
|
325
|
+
} catch {
|
|
326
|
+
console.warn('Subscription registration failed silently');
|
|
327
|
+
} finally {
|
|
328
|
+
resumeTimer();
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
// useEffect(() => {
|
|
333
|
+
// const timer = setTimeout(onClose, COUNTDOWN_SECONDS * 1000);
|
|
334
|
+
// return () => clearTimeout(timer);
|
|
335
|
+
// }, [onClose]);
|
|
336
|
+
|
|
257
337
|
useEffect(() => {
|
|
258
|
-
|
|
259
|
-
return () =>
|
|
260
|
-
|
|
338
|
+
startTimer(remainingTimeRef.current);
|
|
339
|
+
return () => {
|
|
340
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
341
|
+
};
|
|
342
|
+
}, [startTimer]);
|
|
261
343
|
useEffect(() => {
|
|
262
|
-
if (
|
|
344
|
+
if (reference) {
|
|
263
345
|
loadTransaction();
|
|
264
346
|
}
|
|
265
|
-
}, [
|
|
347
|
+
}, [reference]);
|
|
266
348
|
if (loading && !transactionDetail) {
|
|
267
349
|
return /*#__PURE__*/_jsx(Gradients, {});
|
|
268
350
|
}
|
|
@@ -289,13 +371,10 @@ export function ResultScreen({
|
|
|
289
371
|
}), /*#__PURE__*/_jsx(Amount, {
|
|
290
372
|
children: formatted
|
|
291
373
|
}), /*#__PURE__*/_jsxs(Card, {
|
|
292
|
-
children: [/*#__PURE__*/_jsx(Row, {
|
|
293
|
-
label:
|
|
294
|
-
value:
|
|
295
|
-
}), /*#__PURE__*/_jsx(Row, {
|
|
296
|
-
label: "Channel",
|
|
297
|
-
value: channelLabel[transactionDetail?.channel] ?? transaction?.channel
|
|
298
|
-
}), /*#__PURE__*/_jsx(Row, {
|
|
374
|
+
children: [summaryRows?.map(row => /*#__PURE__*/_jsx(Row, {
|
|
375
|
+
label: row.label,
|
|
376
|
+
value: row.value
|
|
377
|
+
}, row.label)), /*#__PURE__*/_jsx(Row, {
|
|
299
378
|
label: "Reference",
|
|
300
379
|
value: transactionDetail?.reference
|
|
301
380
|
}), /*#__PURE__*/_jsx(Row, {
|
|
@@ -305,6 +384,12 @@ export function ResultScreen({
|
|
|
305
384
|
label: "Status",
|
|
306
385
|
value: transactionDetail?.status?.toUpperCase()
|
|
307
386
|
})]
|
|
387
|
+
}), allowRecurring && /*#__PURE__*/_jsx(RecurringToggle, {
|
|
388
|
+
onToggle: (enabled, freq) => {
|
|
389
|
+
setRecurringEnabled(enabled);
|
|
390
|
+
setRecurringFrequency(freq);
|
|
391
|
+
handlePayment();
|
|
392
|
+
}
|
|
308
393
|
}), /*#__PURE__*/_jsxs(Footer, {
|
|
309
394
|
children: [/*#__PURE__*/_jsx(CountdownRing, {
|
|
310
395
|
duration: COUNTDOWN_SECONDS * 1000
|