Skip to content

Commit

Permalink
deposit screens finished
Browse files Browse the repository at this point in the history
  • Loading branch information
sumershinde22 committed Dec 2, 2024
1 parent d023fb3 commit 371bc37
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 104 deletions.
19 changes: 16 additions & 3 deletions frontend/src/navigation/ProfileNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
import ProfileScreen from '../screens/profile/ProfileScreen';
import ProfileLegalDocumentsScreen from '../screens/profile/ProfileLegalDocumentsScreen';
import WithdrawScreen from '../screens/profile/WithdrawScreen';
import WithdrawConfirmScreen from '../screens/profile/WithdrawConfirmScreen'; // Ensure this path is correct
import DepositScreen from '../screens/profile/DepositScreen';
import ConfirmScreen from '../screens/profile/ConfirmScreen';

const Stack = createNativeStackNavigator();

Expand All @@ -28,8 +29,20 @@ export default function ProfileNavigator() {
/>
<Stack.Screen
name='profile-withdraw-confirm'
component={WithdrawConfirmScreen}
options={{ title: 'Withdraw', headerShown: true }}
component={ConfirmScreen}
initialParams={{ withdraw: true }} // Pass withdraw as true
options={{ title: 'Withdraw Confirm', headerShown: true }}
/>
<Stack.Screen
name='profile-deposit'
component={DepositScreen}
options={{ title: 'Deposit', headerShown: true }}
/>
<Stack.Screen
name='profile-deposit-confirm'
component={ConfirmScreen}
initialParams={{ withdraw: false }} // Pass withdraw as false
options={{ title: 'Deposit Confirm', headerShown: true }}
/>
</Stack.Navigator>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// WithdrawConfirmScreen.js
import React from 'react';
import { View, Text, Dimensions } from 'react-native';
import { styled } from 'nativewind';
Expand All @@ -11,7 +10,8 @@ const Ellipse = styled(View);
const StyledView = styled(View);
const StyledText = styled(Text);

export default function WithdrawConfirmScreen() {
export default function ConfirmScreen({ route }) {
const { withdraw } = route.params || {}; // Get the `withdraw` prop from the route params
const numberOfEllipses = 15;
const ellipsesArray = Array.from({ length: numberOfEllipses });
const ellipseWidth = 18;
Expand Down Expand Up @@ -48,16 +48,19 @@ export default function WithdrawConfirmScreen() {

{/* White Card */}
<StyledView className='bg-white rounded-t-2xl mx-6 px-7 py-8 pb-10'>
{/* The 'pb-10' adds padding at the bottom to accommodate the perforated ellipses */}
<StyledView>
{/* Conditional Title and Message */}
<StyledText className='text-2xl font-heading font-bold text-defaultText mb-2'>
Pending transfer
{withdraw ? 'Pending Withdrawal' : 'Pending Deposit'}
</StyledText>
<StyledText className='font-nunitoRegular text-base'>
You successfully withdrew $200 out of your 3 Stones account.
{withdraw
? 'You successfully withdrew $200 out of your 3 Stones account.'
: 'You successfully deposited $200 into your 3 Stones account.'}
</StyledText>

{/* Transaction Details */}
<StyledView className='py-6'>
{/* Transaction Details */}
<StyledView className='flex-row justify-between items-center mb-2'>
<StyledText className='font-sourceSans3Bold text-base'>Transaction ID</StyledText>
<StyledText className='font-sourceSans3 text-gray-900'>
Expand Down
131 changes: 131 additions & 0 deletions frontend/src/screens/profile/DepositScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// DepositScreen.js
import React, { useState } from 'react';
import { View, Text, Image } from 'react-native';
import { styled } from 'nativewind';
import Button from '../../components/Button';
import TextField from '../../components/TextField';
import ConfirmDialog from './components/ConfirmDialog'; // Adjust the import path if necessary

const StyledView = styled(View);
const StyledText = styled(Text);
const StyledImage = styled(Image);

export default function DepositScreen({ navigation }) {
const [inputValue, setInputValue] = useState('');
const [isValidInput, setIsValidInput] = useState(false);
const [confirmVisible, setConfirmVisible] = useState(false);

const handleInputChange = (text) => {
setInputValue(text);

// Validate the input
const regex = /^\d+(\.\d{1,2})?$/;
const amount = Number(text);

if (regex.test(text) && !isNaN(amount) && amount > 0) {
setIsValidInput(true);
} else {
setIsValidInput(false);
}
};

const handleDepositPress = () => {
setConfirmVisible(true);
};

const handleConfirm = () => {
setConfirmVisible(false);
navigation.navigate('profile-deposit-confirm');
};

const handleCancel = () => {
setConfirmVisible(false);
};

const buttonBgColor = isValidInput ? 'bg-defaultPrimary' : 'bg-gray-300';

return (
<StyledView className='flex-1 bg-white p-4'>
<StyledView className='py-8 px-6'>
<StyledView className='bg-brand-400 rounded-2xl w-full gap-y-[10px]'>
<StyledView className='bg-brand-400 rounded-lg p-[4vw] flex-col w-full'>
<StyledView className='flex-row justify-between items-center mb-4'>
<StyledText className='text-inverseText font-sourceSans3Bold'>
Available Balance
</StyledText>
<Button
type='primary'
size='small'
className='rounded-[50px] bg-defaultPrimary'
onPress={() => console.log('View Portfolio button pressed')}
>
View Portfolio
</Button>
</StyledView>

<StyledText className='text-[32px] text-inverseText font-title mb-2'>
$700.00
</StyledText>

<StyledText className='font-sourceSans3 text-inverseText'>
Total Available Cash
</StyledText>
</StyledView>
</StyledView>

<StyledView className='pt-6 -m-4'>
<TextField
intent='default'
size='large'
icon='suffix'
placeholder='Enter Amount'
prefix='$'
suffix='USD'
onChangeText={handleInputChange}
value={inputValue}
/>
</StyledView>
</StyledView>

<StyledView className='flex flex-col justify-end items-start flex-grow py-4 px-6 gap-4'>
<StyledText className='font-sourceSans3'>Transferring from</StyledText>
<StyledView className='flex-row items-center justify-between w-full'>
<StyledView className='flex-row items-center'>
<StyledImage source={require('../../../assets/images/chase.png')} className='w-8 h-8' />
<StyledView className='flex-row px-2 py-1 items-center'>
<StyledText className='font-sourceSans3Bold pr-2'>Chase Bank</StyledText>
<StyledText className='font-sourceSans3'>xxxx2731</StyledText>
</StyledView>
</StyledView>
<StyledImage
source={require('../../../assets/images/edit-icon-dark.png')}
className='w-8 h-8 ml-4'
/>
</StyledView>
<StyledText className='font-sourceSans3 font-normal text-xs text-gray-800 leading-4'>
Transfer speed depends on your bank and could take up to 30 minutes. Transfers are
reviewed which may result in delays or funds being frozen or removed from your account.
</StyledText>
<StyledView className='w-full'>
<Button
type='primary'
size='large'
className={`w-full rounded-[50px] ${buttonBgColor} ${isValidInput ? '' : 'bg-gray-300'}`}
onPress={handleDepositPress}
disabled={!isValidInput}
>
Deposit
</Button>
</StyledView>
</StyledView>

{/* Confirm Dialog */}
<ConfirmDialog
visible={confirmVisible}
onConfirm={handleConfirm}
onCancel={handleCancel}
withdraw={false}
/>
</StyledView>
);
}
152 changes: 92 additions & 60 deletions frontend/src/screens/profile/ProfileScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { styled } from 'nativewind';
import ProfilePageNavigator from './components/ProfilePageNavigator';
import { NavigationScreenProp } from 'react-navigation';
import { useAuth } from '../../context/AuthContext';
import { useInvestorProfile } from '../../../src/services/investor'
import { useInvestorProfile } from '../../../src/services/investor';

import Button from '../../components/Button';
import Divider from '../../components/Divider';
Expand All @@ -14,70 +14,102 @@ const StyledText = styled(Text);
const StyledImage = styled(Image);

interface ProfileScreenProps {
// This actually should be `any`, so disabling the linter rule
// eslint-disable-next-line @typescript-eslint/no-explicit-any
navigation: NavigationScreenProp<any, any>;
// This actually should be `any`, so disabling the linter rule
// eslint-disable-next-line @typescript-eslint/no-explicit-any
navigation: NavigationScreenProp<any, any>;
}

//Button to navigate to the portfolio page
const EditProfileButton = ({ navigation }) => {
return (
<StyledView className='h-[4vh] w-[15vh]'>
<Button onPress={() => {navigation.navigate('profile-edit-profile')}}
type='secondary'
>Edit Profile</Button>
</StyledView>
);
};
return (
<StyledView className='h-[4vh] w-[15vh]'>
<Button
onPress={() => {
navigation.navigate('profile-edit-profile');
}}
type='secondary'
>
Edit Profile
</Button>
</StyledView>
);
};

const UserName = () => {
const { profile, isLoading } = useInvestorProfile();
if(isLoading) {
return <StyledText>loading...</StyledText>
}
if(!profile) {
return <StyledText>no profile found!</StyledText>
}
return (
<StyledText>
{profile.first} {profile.last}
</StyledText>
);
};
const UserName = () => {
const { profile, isLoading } = useInvestorProfile();
if (isLoading) {
return <StyledText>loading...</StyledText>;
}
if (!profile) {
return <StyledText>no profile found!</StyledText>;
}
return (
<StyledText>
{profile.first} {profile.last}
</StyledText>
);
};

export default function ProfileScreen({ navigation }: ProfileScreenProps) {
return(
<StyledView className='flex h-screen py-[6vh]'>
{/*Your Profile ...*/}
<StyledView className="flex-row py-[2vh] px-[4vw] justify-between">
<StyledText className="text-3xl align-center font-Nunito-BoldItalic text-center">
Your Profile
</StyledText>
</StyledView>
<StyledView className="flex px-[vw] py-[2vh] flex-col items-center space-y-[10vh]">
<StyledImage className="w-12 h-12" source={require('../../../assets/images/PlaceHolderPFP.png')}/>
<UserName/>
<StyledText>
</StyledText>
<EditProfileButton navigation={navigation}/>
</StyledView>
<StyledView className='flex flex-col space-y-[32vw]'>
<Divider/>
<StyledView className='flex flex-col gap-y-[40vh]'>
<ProfilePageNavigator iconRoute={require('../../../assets/images/deposit-icon.png')} navigation={navigation} navigationName = 'profile-deposit' pageName='Deposit'/>
<ProfilePageNavigator iconRoute={require('../../../assets/images/withdraw-icon.png')} navigation={navigation} navigationName = 'profile-withdraw' pageName='Withdraw'/>
</StyledView>
<Divider/>
<StyledView className='flex flex-col'>
<ProfilePageNavigator iconRoute={require('../../../assets/images/settings-icon.png')} navigation={navigation} navigationName = 'profile-settings' pageName='Settings'/>
<ProfilePageNavigator iconRoute={require('../../../assets/images/document-icon.png')} navigation={navigation} navigationName = 'profile-legal-documents' pageName='Legal Documents'/>
</StyledView>
<Divider/>
<StyledView className='flex flex-col'>
<ProfilePageNavigator iconRoute={require('../../../assets/images/risk-tolerance-icon.png')} navigation={navigation} navigationName = 'profile-risk-tolerance' pageName='Risk Tolerance'/>
</StyledView>
<Divider/>
</StyledView>
return (
<StyledView className='flex h-screen py-[6vh]'>
{/*Your Profile ...*/}
<StyledView className='flex-row py-[2vh] px-[4vw] justify-between'>
<StyledText className='text-3xl align-center font-Nunito-BoldItalic text-center'>
Your Profile
</StyledText>
</StyledView>
<StyledView className='flex px-[vw] py-[2vh] flex-col items-center space-y-[10vh]'>
<StyledImage
className='w-12 h-12'
source={require('../../../assets/images/PlaceHolderPFP.png')}
/>
<UserName />
<StyledText></StyledText>
<EditProfileButton navigation={navigation} />
</StyledView>
<StyledView className='flex flex-col space-y-[32vw]'>
<Divider />
<StyledView className='flex flex-col gap-y-[40vh]'>
<ProfilePageNavigator
iconRoute={require('../../../assets/images/deposit-icon.png')}
navigation={navigation}
navigationName='profile-deposit'
pageName='Deposit'
/>
<ProfilePageNavigator
iconRoute={require('../../../assets/images/withdraw-icon.png')}
navigation={navigation}
navigationName='profile-withdraw'
pageName='Withdraw'
/>
</StyledView>
);
}
<Divider />
<StyledView className='flex flex-col'>
<ProfilePageNavigator
iconRoute={require('../../../assets/images/settings-icon.png')}
navigation={navigation}
navigationName='profile-settings'
pageName='Settings'
/>
<ProfilePageNavigator
iconRoute={require('../../../assets/images/document-icon.png')}
navigation={navigation}
navigationName='profile-legal-documents'
pageName='Legal Documents'
/>
</StyledView>
<Divider />
<StyledView className='flex flex-col'>
<ProfilePageNavigator
iconRoute={require('../../../assets/images/risk-tolerance-icon.png')}
navigation={navigation}
navigationName='profile-risk-tolerance'
pageName='Risk Tolerance'
/>
</StyledView>
<Divider />
</StyledView>
</StyledView>
);
}
Loading

0 comments on commit 371bc37

Please sign in to comment.