Skip to content

Commit

Permalink
cccchanges - routing add funds + project
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-brennan2005 committed Dec 5, 2024
1 parent f5baa80 commit 9ff7cfd
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 53 deletions.
21 changes: 1 addition & 20 deletions backend/internal/controllers/investors.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,6 @@ func (c *InvestorsController) GetPortfolio(ctx *fiber.Ctx) error {
return ctx.JSON(investors)
}

func (c *InvestorsController) GetCashBalance(ctx *fiber.Ctx) error {
userId, ok := ctx.Locals("userId").(string)
if !ok {
return &api_errors.INVALID_UUID
}

id, err := uuid.Parse(userId)
if err != nil {
return &api_errors.INVALID_UUID
}

investors, err := transactions.GetCashBalance(c.ServiceParams.DB, id)
if err != nil {
return err
}

return ctx.JSON(investors)
}

func (c *InvestorsController) GetHistory(ctx *fiber.Ctx) error {
paginationParams := new(types.PaginationParams)

Expand Down Expand Up @@ -184,7 +165,7 @@ func (c *InvestorsController) GetInvestor(ctx *fiber.Ctx) error {
return err
}

cashBalance, err := transactions.GetCashBalance(c.ServiceParams.DB, id)
cashBalance, err := transactions.GetCashBalance(c.ServiceParams.DB, id.String())
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion backend/internal/transactions/investors.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func GetHistory(db *pgxpool.Pool, investorID uuid.UUID, limit int, offset int) (
return history, nil
}

func GetCashBalance(pool *pgxpool.Pool, investorID uuid.UUID) (int, error) {
func GetCashBalance(pool *pgxpool.Pool, investorID string) (int, error) {
query := "SELECT cash_balance_cents FROM investors WHERE supabase_id = $1"

var balance int
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Divider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { View, Image, ImageSourcePropType } from 'react-native';
import { styled } from 'nativewind';
import { CaptionText } from './typography';
import { CaptionText } from './Typography';

const StyledView = styled(View);
const StyledImage = styled(Image);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const API_URL = 'https://6ed0-155-33-133-6.ngrok-free.app';
export const SUPABASE_URL = 'https://0427-155-33-133-6.ngrok-free.app';
export const API_URL = 'https://bbc4-155-33-133-6.ngrok-free.app';
export const SUPABASE_URL = 'https://c4ca-155-33-133-6.ngrok-free.app';
export const SUPABASE_JWT_SECRET =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0';
12 changes: 0 additions & 12 deletions frontend/src/navigation/BottomTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,6 @@ export default function TabNavigator() {
headerShown: false,
}}
/>
<Tab.Screen
name='Project'
component={ProjectNavigator}
options={{
tabBarIcon: ({ focused }) => (
<TabBarIcon color={focused ? 'blue' : 'black'} name='building' />
),
tabBarLabel: 'Project',
title: '',
headerShown: false,
}}
/>
<Tab.Screen
name='Profile'
component={ProfileNavigator}
Expand Down
10 changes: 6 additions & 4 deletions frontend/src/navigation/ProjectNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ const StyledView = styled(View);
const StyledTouchableOpacity = styled(TouchableOpacity);
const StyledSafeAreaView = styled(SafeAreaView);

export default function ProjectNavigator() {
export default function ProjectNavigator({ route }) {
const projectId = route?.params?.projectId;

return (
<Stack.Navigator initialRouteName='project' >
<Stack.Navigator initialRouteName='project-initial' >
<Stack.Screen
name='project'
name='project-initial'
component={ProjectScreen}
initialParams={{projectId: 'c3733692-5a86-441f-8ad0-9c32c648bb72'}}
initialParams={{ projectId: projectId || 'c3733692-5a86-441f-8ad0-9c32c648bb72' }}
options={{ title: 'Project details', header: (props) => {
return (
<StyledSafeAreaView className="bg-surfaceBG">
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/navigation/RootNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import React from 'react';
import { useAuth } from '../context/AuthContext';
import TabNavigator from './BottomTabs';
import LoginNavigator from './LoginNavigator';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import ProjectNavigator from './ProjectNavigator';

const Stack = createNativeStackNavigator();

// Navigates user to the log in screen if seesion is not found (i.e. user not logged in)
export default function RootNavigator() {
Expand All @@ -11,5 +15,10 @@ export default function RootNavigator() {
return null; // or some loading screen (maybe we make in future?)
}

return session ? <TabNavigator /> : <LoginNavigator />;
return session ? (
<Stack.Navigator>
<Stack.Screen options={{headerShown: false}} name="Tabs" component={TabNavigator} />
<Stack.Screen options={{headerShown: false}} name="project" component={ProjectNavigator} />
</Stack.Navigator>
) : <LoginNavigator />;
}
6 changes: 4 additions & 2 deletions frontend/src/screens/home/components/BottomSheetComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const Investments = ({ portfolio, navigation }: {
<StyledText className='text-[5vw] font-heading py-[2vh]'>Your Investments</StyledText>
{portfolio &&
Object.keys(portfolio).map((projectId) => (
<StyledTouchableOpacity onPress={() => navigation.navigate('Project')} key={projectId}>
<StyledTouchableOpacity onPress={() => {
console.log(`From portfolio screen: ${projectId}`)
navigation.navigate('project', {projectId: projectId})}} key={projectId}>
<InvestmentContainer projectId={projectId} />
<StyledView className='w-full h-[1px] bg-borderPrimary'></StyledView>
</StyledTouchableOpacity>
Expand All @@ -32,7 +34,7 @@ const Investments = ({ portfolio, navigation }: {
<StyledText className='text-[5vw] font-heading pt-[3vh]'>Recently Viewed</StyledText>
{portfolio &&
Object.keys(portfolio).map((projectId) => (
<StyledTouchableOpacity onPress={() => navigation.navigate('Project')} key={projectId} className='mt-[3vh]'>
<StyledTouchableOpacity onPress={() => navigation.navigate('project', {projectId: projectId})} key={projectId} className='mt-[3vh]'>
<RecentlyViewedCard projectId={projectId} />
</StyledTouchableOpacity>
))}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/screens/home/components/portfolioValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const AddFundsButton = ({
<WideButton
name={'Add Funds'}
iconRoute={require('../../../../assets/images/attach-money.png')}
navigation={() => navigation.navigate('Profile')}
navigation={() => navigation.navigate('profile-transaction', { withdraw: 'Deposit'})}
intent='secondary'
></WideButton>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import PlaidLink from '../../../expo-plaid-link/Index';
import { useLink } from '../../../services/plaid';
import TextField from '../../../components/TextField';
import TextInputComponent from '../components/TextInputComponent';
import { BodyBoldText, BodyText, CaptionText } from '../../../components/typography';
import { BodyBoldText, BodyText, CaptionText } from '../../../components/Typography';
import Button from '../../../components/Button';
import NavProgressBar from '../components/NavProgressBar';
import OnboardingScreenWrapper from '../components/OnboardingScreenWrapper';
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/screens/profile/ProfileEditScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { NavigationScreenProp } from 'react-navigation';

import Divider from '../../components/Divider';
import Button from '../../components/Button';
import { BodyText, SubheadingText } from '../../components/typography';
import { BodyText, SubheadingText } from '../../components/Typography';
import { useInvestorProfile } from '../../services/investor';
import ProfiileHeaderNavigation from './components/PageHeaderNavigation';
import PageHeaderNavigation from './components/PageHeaderNavigation';
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/screens/profile/ProfileScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useInvestorProfile } from '../../../src/services/investor';

import Button from '../../components/Button';
import Divider from '../../components/Divider';
import { BodyBoldText, BodyText, SubheadingText } from '../../components/typography';
import { BodyBoldText, BodyText, SubheadingText } from '../../components/Typography';

const StyledView = styled(View);
const StyledText = styled(Text);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/screens/profile/ProfileSettingsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ProfilePageNavigator from './components/ProfilePageNavigator';
import { NavigationScreenProp } from 'react-navigation';

import Divider from '../../components/Divider';
import { SubheadingText } from '../../components/typography';
import { SubheadingText } from '../../components/Typography';
import PageHeaderNavigation from './components/PageHeaderNavigation';

const StyledView = styled(View);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { TouchableOpacity, View, Text, Image, ImageSourcePropType } from 'react-native';
import { NavigationScreenProp } from 'react-navigation';
import { styled } from 'nativewind';
import { SubheadingText } from '../../../components/typography';
import { SubheadingText } from '../../../components/Typography';

interface ProfilePageNavigatorProps {
// This actually should be `any`, so disabling the linter rule
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/screens/project/ProjectInvestScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function ProjectInvestScreen({ navigation, route }) {
<StyledText className="text-[#282828]font-body text-base font-normal leading-[22px]">Total Cash Available</StyledText>
<StyledView className="flex flex-row items-center justify-between mt-1">
<StyledText className="truncate text-[#282828] font-heading text-[32px] font-extrabold leading-[40px]">{`\$${(balance/100).toFixed(2)}`}</StyledText>
<Button type="secondary" size="small">
<Button type="secondary" size="small" onPress={() => { navigation.navigate("profile-transaction", { withdraw: 'Deposit'})}}>
Add funds
</Button>
</StyledView>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/screens/project/ProjectInvestSuccessScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const StyledTouchableWithoutFeedback = styled(TouchableWithoutFeedback);


export default function ProjectInvestSuccessScreen({ route }) {
const navigation = useNavigation();
const navigation: NavigationScreenProp<any, any> = useNavigation();
const { balance, isLoading: isInvestorLoading} = useInvestorBalance();

console.log(route.params)
Expand All @@ -43,7 +43,7 @@ export default function ProjectInvestSuccessScreen({ route }) {
<StyledText className="text-[#282828]font-body text-base font-normal leading-[22px]">Total Cash Available</StyledText>
<StyledView className="flex flex-row items-center justify-between mt-1">
<StyledText className="truncate text-[#282828] font-heading text-[32px] font-extrabold leading-[40px]">{`\$${(balance/100).toFixed(2)}`}</StyledText>
<Button type="secondary" size="small">
<Button type="secondary" size="small" onPress={() => { navigation.navigate("profile-transaction", { withdraw: 'Deposit'})}}>
Add funds
</Button>
</StyledView>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/screens/project/ProjectScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const StyledMapView = styled(MapView);

export default function ProjectScreen({ navigation, route }) {
const projectId: string = route.params.projectId;
console.log(`From project screen: ${projectId}`)
const { project, isLoading } = useProject(projectId);
const { projectTotalFunded, isLoading: isProjectTotalFundedLoading } =
useProjectTotalFunded(projectId);
Expand Down Expand Up @@ -151,7 +152,7 @@ export default function ProjectScreen({ navigation, route }) {

<StyledView className='flex flex-col gap-y-2 py-6'>
{propertyDetails.map((val, idx, arr) => (
<StyledView className='flex flex-row justify-between'>
<StyledView key={val[0]} className='flex flex-row justify-between'>
<StyledText className='font-heading text-base'>{val[0]}</StyledText>
<StyledText className='font-body text-base'>{val[1]}</StyledText>
</StyledView>
Expand Down

0 comments on commit 9ff7cfd

Please sign in to comment.