Skip to content

Commit

Permalink
Merge branch 'main' into adam-make-post-page
Browse files Browse the repository at this point in the history
  • Loading branch information
aniamisiorek authored Apr 18, 2024
2 parents 93cd10a + 5f7c851 commit b070ec7
Show file tree
Hide file tree
Showing 24 changed files with 881 additions and 163 deletions.
2 changes: 1 addition & 1 deletion backend/src/db/migrations/1_USER_V1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ VALUES
('user_2chL8dX6HdbBAuvu3DDM9f9NzKK', 'Ania', 'Misiorek', 'ania', 'https://ca.slack-edge.com/T2CHL6FEG-U05QP4M4M3P-349be7323f07-512'),
('user_2cpFbBLPGkPbszijtQneek7ZJxg', 'Leroy', 'Shaigorodsky', 'leroy', 'https://ca.slack-edge.com/T2CHL6FEG-U040ST08HM1-c3d453828123-512'),
('user_2dv5XFsCMYc4qLcsAnEJ1aUbxnk', 'Cam', 'Plume', 'campd10', 'https://ca.slack-edge.com/T2CHL6FEG-U06DCDZ3FB8-1c488c509f95-512'),
('user_2cwGfu9zcjsbxq5Lp8gy2rkVNlc', 'Nathan', 'Jung', 'nathan', 'https://ca.slack-edge.com/T2CHL6FEG-U05QL55RDBQ-8fd6c3499cac-512'),
('user_2fFVsSf4viW9pjx6Sd5dxEgutJ1', 'Nathan', 'Jung', 'nathan', 'https://ca.slack-edge.com/T2CHL6FEG-U05QL55RDBQ-8fd6c3499cac-512'),
('user_2dvSY6HpxotzWCfch5m4a4OVpAK', 'Aryan', 'Kale', 'aryankale', 'https://cdn-icons-png.freepik.com/256/552/552848.png');

4 changes: 3 additions & 1 deletion backend/src/db/migrations/2_FOLLOWING_V1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ INSERT INTO followings (follower_user_id, following_user_id)
VALUES
('user_2chL8dX6HdbBAuvu3DDM9f9NzKK', 'user_2cpFbBLPGkPbszijtQneek7ZJxg'),
('user_2chL8dX6HdbBAuvu3DDM9f9NzKK', 'user_2dv5XFsCMYc4qLcsAnEJ1aUbxnk'),
('user_2cpFbBLPGkPbszijtQneek7ZJxg', 'user_2chL8dX6HdbBAuvu3DDM9f9NzKK');
('user_2cpFbBLPGkPbszijtQneek7ZJxg', 'user_2chL8dX6HdbBAuvu3DDM9f9NzKK'),
('user_2fFVsSf4viW9pjx6Sd5dxEgutJ1', 'user_2dv5XFsCMYc4qLcsAnEJ1aUbxnk'),
('user_2dv5XFsCMYc4qLcsAnEJ1aUbxnk', 'user_2fFVsSf4viW9pjx6Sd5dxEgutJ1');
2 changes: 1 addition & 1 deletion backend/src/db/migrations/5_USER_PORTFOLIO_V1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ VALUES
('user_2chL8dX6HdbBAuvu3DDM9f9NzKK', 130, 14, 680, 93),
('user_2cpFbBLPGkPbszijtQneek7ZJxg', -14, -8, 680, 93),
('user_2dv5XFsCMYc4qLcsAnEJ1aUbxnk', 400, 3, 680, 93),
('user_2cwGfu9zcjsbxq5Lp8gy2rkVNlc', 200, 9, 680, 93);
('user_2fFVsSf4viW9pjx6Sd5dxEgutJ1', 200, 9, 680, 93);
2 changes: 1 addition & 1 deletion backend/src/models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package models
import "time"

type User struct {
ID string `gorm:"column:id;primaryKey;"`
ID string `gorm:"column:id;primaryKey;" json:"id"`
CreatedAt time.Time `json:"created_at" example:"2023-09-20T16:34:50Z"`
UpdatedAt time.Time `json:"updated_at" example:"2023-09-20T16:34:50Z"`
FirstName string `gorm:"type:varchar(255)" json:"first_name"`
Expand Down
4 changes: 4 additions & 0 deletions backend/src/services/etrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"backend/src/models"
"backend/src/types"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -326,6 +327,9 @@ func getETradePortfolio(client *http.Client, tokens *models.OAuthTokens, account
func (s *ETradeService) GetUserPortfolio(userID string) (models.UserPortfolio, error) {
var portfolio models.UserPortfolio
if err := s.DB.Preload("Positions").Where("user_id = ?", userID).First(&portfolio).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return models.UserPortfolio{}, nil
}
return models.UserPortfolio{}, fmt.Errorf("error retrieving all positions from the database: %s", err)
}

Expand Down
128 changes: 72 additions & 56 deletions frontend/components/Feed/FeedTopBar.tsx
Original file line number Diff line number Diff line change
@@ -1,62 +1,78 @@
import React from "react";
import { StyleSheet, Text, View } from "react-native";
import { useNavigation } from '@react-navigation/native';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
// import FeedPage from '../../pages/FeedPage';
// import Follow from '../../pages/Follow';
import { AuthNavigationProp } from '../../types/navigationTypes';

type FeedBarProps = {
tab: string,
setTab: React.Dispatch<React.SetStateAction<string>>,
}
type FeedBarProps = {
tab: string;
setTab: React.Dispatch<React.SetStateAction<string>>;
};

const FeedTopBar: React.FC<FeedBarProps> = ({tab, setTab}) => {
return (
<View style={styles.top_bar}>
<Text
style={tab == 'Explore' ? styles.explore : styles.follow}
onPress={() => setTab('Explore')}>
Explore
</Text>
<Text
style={tab == 'Following' ? styles.explore : styles.follow}
onPress={() => setTab('Following')}>
Following
</Text>
</View>
)
}
const FeedTopBar: React.FC<FeedBarProps> = ({ tab, setTab }) => {
const navigation = useNavigation<AuthNavigationProp>();

const handleButtonPress = () => {
setTab('Explore')
navigation.navigate('Feed');
};

const handleButtonPress2 = () => {
setTab('Explore')
navigation.navigate('Follow');
};

return (
<View style={styles.top_bar}>
<Text
style={tab == 'Explore' ? styles.explore : styles.follow}
onPress={handleButtonPress}>
Explore
</Text>
<Text
style={tab == 'Following' ? styles.explore : styles.follow}
onPress={handleButtonPress2}>
Following
</Text>
</View>
);
};

export default FeedTopBar;

const styles = StyleSheet.create({
top_bar: {
width: "100%",
flex: 1,
marginTop: "15%",
backgroundColor: '#FFFFFF',
flexDirection: "row",
// backgroundRepeat: 'no-repeat',
// backgroundPosition: 'center center',
// backgroundSize: 'cover',
padding: 20,
overflow: 'hidden',
zIndex: 2,
},
explore: {
width: "50%",
color: 'rgba(0,0,0,1)',
fontFamily: 'Circular Std',
fontWeight: '500',
fontSize: 17,
opacity: 1,
textAlign: 'center',
borderBottomColor: 'rgba(0,0,0,1)',
borderBottomWidth: 1,
},
follow: {
width: "50%",
color: 'rgba(102,102,102,1)',
fontFamily: 'Circular Std',
fontWeight: '500',
fontSize: 17,
opacity: 1,
textAlign: 'center',
},
})
top_bar: {
width: '100%',
flex: 1,
marginTop: '15%',
backgroundColor: '#FFFFFF',
flexDirection: 'row',
// backgroundRepeat: 'no-repeat',
// backgroundPosition: 'center center',
// backgroundSize: 'cover',
padding: 20,
overflow: 'hidden',
zIndex: 2,
},
explore: {
width: '50%',
color: 'rgba(0,0,0,1)',
fontFamily: 'Circular Std',
fontWeight: '500',
fontSize: 17,
opacity: 1,
textAlign: 'center',
borderBottomColor: 'rgba(0,0,0,1)',
borderBottomWidth: 1,
},
follow: {
width: '50%',
color: 'rgba(102,102,102,1)',
fontFamily: 'Circular Std',
fontWeight: '500',
fontSize: 17,
opacity: 1,
textAlign: 'center',
},
});
122 changes: 122 additions & 0 deletions frontend/components/Feed/Info.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import { Text, View } from 'react-native';
// import { Post } from '../../types/types';
// import Vote from './Vote';
// import { SvgXml } from 'react-native-svg';

type PostProps = {
type: number;
company: string;
price: number;
percent: number;
};

const Info: React.FC<PostProps> = ({ type, company, price, percent }) => {
if (type == 1) {
return (
<View
style={{
flexDirection: 'row',
paddingLeft: 15,
paddingRight: 15,
paddingTop: 10,
paddingBottom: 10,
backgroundColor: 'rgba(2, 173, 152, 0.10)',
borderRadius: 5,
width: 220,
}}>
<View
style={{
flexDirection: 'row',
}}>
<Text
style={{
color: '#02AD98',
fontSize: 16,
fontFamily: 'SF Pro Text',
fontWeight: '400',
width: 40,
}}>
BUY
</Text>
<Text
style={{
color: '#121212',
fontSize: 16,
fontFamily: 'SF Pro Text',
fontWeight: '400',
width: 120,
}}>
{company} @ {price}
</Text>
</View>
<View>
<Text
style={{
color: '#02AD98',
fontSize: 17,
fontFamily: 'SF Pro',
lineHeight: 20,
}}>
{percent}%
</Text>
</View>
</View>
);
}
if (type == 2) {
return (
<View
style={{
flexDirection: 'row',
paddingLeft: 15,
paddingRight: 15,
paddingTop: 10,
paddingBottom: 10,
backgroundColor: 'rgba(255, 43, 81, 0.1)',
borderRadius: 5,
width: 220,
}}>
<View
style={{
flexDirection: 'row',
}}>
<Text
style={{
color: '#FF2B51',
fontSize: 16,
fontFamily: 'SF Pro Text',
fontWeight: '400',
width: 40,
}}>
BUY
</Text>
<Text
style={{
color: '#121212',
fontSize: 16,
fontFamily: 'SF Pro Text',
fontWeight: '400',
width: 120,
}}>
{company} @ {price}
</Text>
</View>
<View>
<Text
style={{
color: '#FF2B51',
fontSize: 17,
fontFamily: 'SF Pro',
lineHeight: 20,
}}>
17%
</Text>
</View>
</View>
);
}
};

// Define the styles for the component

export default Info;
Loading

0 comments on commit b070ec7

Please sign in to comment.