@autobusal/order-process 1.1.0 → 1.2.0
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/Content.tsx +4 -0
- package/Mollie/Mollie.tsx +28 -0
- package/package.json +1 -1
- package/services.ts +14 -1
- package/types.ts +4 -0
package/Content.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { TFunction } from 'i18next';
|
|
|
2
2
|
import Standard from './Standard/Standard';
|
|
3
3
|
import Bkt from './BKT/Bkt';
|
|
4
4
|
import Stripe from './Stripe/Stripe';
|
|
5
|
+
import Mollie from './Mollie/Mollie';
|
|
5
6
|
|
|
6
7
|
interface Props {
|
|
7
8
|
type?: string
|
|
@@ -17,6 +18,9 @@ const Content = ({ type, hash, t }: Props): JSX.Element => {
|
|
|
17
18
|
case 'stripe':
|
|
18
19
|
return <Stripe hash={ hash } t={ t } />;
|
|
19
20
|
|
|
21
|
+
case 'mollie':
|
|
22
|
+
return <Mollie hash={ hash } t={ t } />;
|
|
23
|
+
|
|
20
24
|
default:
|
|
21
25
|
return <Standard type={ type } hash={ hash } t={ t } />;
|
|
22
26
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { TFunction } from 'i18next';
|
|
3
|
+
import { Inline } from '@autobusal/common';
|
|
4
|
+
import { Container } from '../styles';
|
|
5
|
+
import { useMakeMollie } from '../services';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
hash?: string
|
|
9
|
+
t: TFunction<'common'>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Mollie = ({ hash, t }: Props): JSX.Element => {
|
|
13
|
+
const { data, isSuccess } = useMakeMollie(String(hash));
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (isSuccess) {
|
|
17
|
+
window.location.href = data.redirect;
|
|
18
|
+
}
|
|
19
|
+
}, [data, isSuccess]);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Container>
|
|
23
|
+
<Inline text={ t('order_process.mollie') } />
|
|
24
|
+
</Container>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default Mollie;
|
package/package.json
CHANGED
package/services.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQuery, UseQueryResult } from '@tanstack/react-query';
|
|
2
2
|
import { apiClient } from '@autobusal/providers';
|
|
3
|
-
import { BKTData, StripeData } from './types';
|
|
3
|
+
import { BKTData, StripeData, MollieData } from './types';
|
|
4
4
|
|
|
5
5
|
export const useMakeStandard = (type: string, hash: string): UseQueryResult<string> => (
|
|
6
6
|
useQuery({
|
|
@@ -42,4 +42,17 @@ export const useMakeStripe = (hash: string): UseQueryResult<StripeData> => (
|
|
|
42
42
|
))
|
|
43
43
|
)
|
|
44
44
|
})
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export const useMakeMollie = (hash: string): UseQueryResult<MollieData> => (
|
|
48
|
+
useQuery({
|
|
49
|
+
queryKey: ['process-payment-mollie', { hash }],
|
|
50
|
+
queryFn: async () => (
|
|
51
|
+
await apiClient
|
|
52
|
+
.post('/api/payment/mollie', { hash })
|
|
53
|
+
.then(response => (
|
|
54
|
+
response?.data ?? ''
|
|
55
|
+
))
|
|
56
|
+
)
|
|
57
|
+
})
|
|
45
58
|
);
|