added notification
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import packetsApi from 'api/packets';
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
@@ -26,6 +28,9 @@ interface ModalPayProps {
|
||||
cardModal: boolean;
|
||||
setCardModal: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
payModal: boolean;
|
||||
paymentStatus: string;
|
||||
packId: number;
|
||||
paymentType: string | null;
|
||||
setPayModal: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
success: boolean;
|
||||
setSuccess: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
@@ -35,15 +40,31 @@ const ModalPay = ({
|
||||
isModalVisible,
|
||||
setModalVisible,
|
||||
selectedId,
|
||||
paymentType,
|
||||
setSelectedId,
|
||||
packId,
|
||||
setCardModal,
|
||||
setPayModal,
|
||||
paymentStatus,
|
||||
}: ModalPayProps) => {
|
||||
const translateY = useRef(new Animated.Value(SCREEN_HEIGHT)).current;
|
||||
const opacity = useRef(new Animated.Value(0)).current;
|
||||
const { bottom } = useSafeAreaInsets();
|
||||
const [load, setLoad] = React.useState(false);
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { mutate, isPending } = useMutation({
|
||||
mutationFn: ({ id, payType }: { id: number; payType: string }) =>
|
||||
packetsApi.payPackets(id, { payType }),
|
||||
onSuccess: res => {
|
||||
console.log(res, 'url');
|
||||
setPayModal(true);
|
||||
},
|
||||
onError: err => {
|
||||
console.dir(err);
|
||||
},
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (isModalVisible) {
|
||||
Animated.parallel([
|
||||
@@ -83,7 +104,9 @@ const ModalPay = ({
|
||||
setLoad(true);
|
||||
|
||||
setTimeout(() => {
|
||||
if (selectedId === 'pay') setPayModal(true);
|
||||
if (selectedId === 'pay') {
|
||||
mutate({ id: packId, payType: 'CASH' });
|
||||
}
|
||||
if (selectedId === 'card') setCardModal(true);
|
||||
|
||||
setModalVisible(false);
|
||||
@@ -114,7 +137,6 @@ const ModalPay = ({
|
||||
},
|
||||
]}
|
||||
>
|
||||
{/* CARD OPTION */}
|
||||
<TouchableOpacity
|
||||
style={[
|
||||
styles.option,
|
||||
@@ -154,50 +176,51 @@ const ModalPay = ({
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
|
||||
{/* CASH OPTION */}
|
||||
<TouchableOpacity
|
||||
style={[
|
||||
styles.option,
|
||||
{
|
||||
backgroundColor: selectedId === 'pay' ? '#28A7E81A' : '#fff',
|
||||
},
|
||||
]}
|
||||
onPress={() => setSelectedId('pay')}
|
||||
>
|
||||
<View style={PaymentStyle.paymentCard}>
|
||||
<Usd
|
||||
color={selectedId == 'pay' ? '#28A7E8' : '#000000'}
|
||||
width={28}
|
||||
height={28}
|
||||
colorCircle={selectedId == 'pay' ? '#28A7E8' : '#000000'}
|
||||
/>
|
||||
<Text
|
||||
style={[
|
||||
PaymentStyle.titleMethod,
|
||||
{ color: selectedId == 'pay' ? '#28A7E8' : '#000' },
|
||||
]}
|
||||
>
|
||||
{t('Naqt pul')}
|
||||
</Text>
|
||||
</View>
|
||||
<View
|
||||
{paymentType !== 'CASH' && (
|
||||
<TouchableOpacity
|
||||
style={[
|
||||
PaymentStyle.select,
|
||||
styles.option,
|
||||
{
|
||||
backgroundColor:
|
||||
selectedId === 'pay' ? '#28A7E8' : '#FFFFFF',
|
||||
borderColor: selectedId === 'pay' ? '#28A7E8' : '#383838',
|
||||
selectedId === 'pay' ? '#28A7E81A' : '#fff',
|
||||
},
|
||||
]}
|
||||
onPress={() => {
|
||||
setSelectedId('pay');
|
||||
}}
|
||||
>
|
||||
{selectedId === 'pay' && (
|
||||
<Check color="#fff" width={20} height={20} />
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
|
||||
{/* BUTTON */}
|
||||
<View style={PaymentStyle.paymentCard}>
|
||||
<Usd
|
||||
color={selectedId == 'pay' ? '#28A7E8' : '#000000'}
|
||||
width={28}
|
||||
height={28}
|
||||
colorCircle={selectedId == 'pay' ? '#28A7E8' : '#000000'}
|
||||
/>
|
||||
<Text
|
||||
style={[
|
||||
PaymentStyle.titleMethod,
|
||||
{ color: selectedId == 'pay' ? '#28A7E8' : '#000' },
|
||||
]}
|
||||
>
|
||||
{t('Naqt pul')}
|
||||
</Text>
|
||||
</View>
|
||||
<View
|
||||
style={[
|
||||
PaymentStyle.select,
|
||||
{
|
||||
backgroundColor:
|
||||
selectedId === 'pay' ? '#28A7E8' : '#FFFFFF',
|
||||
borderColor: selectedId === 'pay' ? '#28A7E8' : '#383838',
|
||||
},
|
||||
]}
|
||||
>
|
||||
{selectedId === 'pay' && (
|
||||
<Check color="#fff" width={20} height={20} />
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
<TouchableOpacity
|
||||
style={[
|
||||
PaymentStyle.modalBtn,
|
||||
@@ -249,7 +272,7 @@ const styles = StyleSheet.create({
|
||||
padding: 20,
|
||||
borderTopLeftRadius: 20,
|
||||
borderTopRightRadius: 20,
|
||||
minHeight: 250,
|
||||
minHeight: 'auto',
|
||||
gap: 10,
|
||||
},
|
||||
option: {
|
||||
|
||||
Reference in New Issue
Block a user