Skip to content

Commit

Permalink
Connecting the bottom half of the screen to the backend
Browse files Browse the repository at this point in the history
  • Loading branch information
abby-stevenson committed Nov 30, 2024
1 parent 2f78237 commit 1497d92
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 117 deletions.
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://6482-155-33-135-54.ngrok-free.app";
export const SUPABASE_URL = " https://4006-155-33-135-54.ngrok-free.app";
export const API_URL = "https://cbdc-155-33-135-54.ngrok-free.app";
export const SUPABASE_URL = "https://d9c1-155-33-135-54.ngrok-free.app";
export const SUPABASE_JWT_SECRET = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0";

124 changes: 24 additions & 100 deletions frontend/src/screens/portfolio/PortfolioScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import PortfolioDetails from './components/PortfolioDetails';
import UpdateCard from './components/PortfolioUpdateCard';
import { useInvestorPortfolio } from '../../../src/services/investor'
import { useAuth } from "../../../src/context/AuthContext";
import { useProjectTotalFunded, useAllProjects } from "../../services/project";
import { useProjectTotalFunded, useAllProjects, useProjectPosts } from "../../services/project";



interface PortfolioScreenProps {
Expand All @@ -31,28 +32,20 @@ export default function PorfolioScreen({ navigation }: PortfolioScreenProps) {

const [activeTab, setActiveTab] = useState('Your Projects');

const InvestorPortfolio = () => {
const { session } = useAuth();
const { portfolio, isLoading } = useInvestorPortfolio();

if (!portfolio) {
return <p>Failed to load portfolio. Please try again later.</p>;
}
const { portfolio, isLoading: portfolioLoading } = useInvestorPortfolio();
const { allProjects, isLoading: projectsLoading } = useAllProjects();

const { allProjects} = useAllProjects();
if (portfolioLoading || projectsLoading) {
return <StyledText className='text-lg font-bold'>Loading...</StyledText>;
}

if (isLoading) {
return <StyledText className='text-lg font-bold '>
Your Projects
</StyledText>;
}
if (!portfolio) {
return <StyledText>Failed to load portfolio. Please try again later.</StyledText>;
}

if (!allProjects || allProjects.length === 0) {
return <p>No projects found.</p>;
}

const projectIds = allProjects.map((project) => project.id);

if (!allProjects || allProjects.length === 0) {
return <StyledText>No projects found.</StyledText>;
}

return (
<StyledView className='flex-1 justify-center bg-surfaceBG overflow-auto'>
Expand Down Expand Up @@ -120,95 +113,26 @@ export default function PorfolioScreen({ navigation }: PortfolioScreenProps) {
image={<Image key={project.images[0].id} src={project.images[0].url} alt="Project Image" />}
></PortfolioItem>
</StyledView>))}







<StyledView className = 'mb-4'>
<PortfolioItem
address={''}
location={''}
price={0}
duration={''}
invested={0}
completion={0}
imageUrl={''}
></PortfolioItem>
</StyledView>
<StyledView className = 'mb-4'>
<PortfolioItem
address={''}
location={''}
price={0}
duration={''}
invested={0}
completion={0}
imageUrl={''}
></PortfolioItem>
</StyledView>
<StyledView className = 'mb-4'>
<PortfolioItem
address={''}
location={''}
price={0}
duration={''}
invested={0}
completion={0}
imageUrl={''}
></PortfolioItem>
</StyledView>
<StyledView className = 'mb-4'>
<PortfolioItem
address={''}
location={''}
price={0}
duration={''}
invested={0}
completion={0}
imageUrl={''}
></PortfolioItem>
</StyledView>
<StyledView className = 'mb-4'>
<PortfolioItem
address={''}
location={''}
price={0}
duration={''}
invested={0}
completion={0}
imageUrl={''}
></PortfolioItem>
</StyledView>
<StyledView className = 'mb-4'>
<PortfolioItem
address={''}
location={''}
price={0}
duration={''}
invested={0}
completion={0}
imageUrl={''}
></PortfolioItem>
</StyledView>
</StyledView>
</StyledView>)
</StyledView>

)
:
(<StyledView className = 'bg-defaultPrimary'>
<StyledView className={`flex p-[16px] flex-col items-start bg-white ${activeTab === 'Updates' ? 'rounded-tl-[27px]' : 'rounded-tr-[27px]'}`}>
{/* Updates */}
<UpdateCard topText='931 1st Street' bottomText='You invested $200' quantity='+$200.00' />
<UpdateCard topText='931 1st Street' bottomText='You invested $200' quantity='+$200.00' />
<UpdateCard topText='931 1st Street' bottomText='You invested $200' quantity='+$200.00' />
<UpdateCard topText='931 1st Street' bottomText='You invested $200' quantity='+$200.00' />
<UpdateCard topText='931 1st Street' bottomText='You invested $200' quantity='+$200.00' />
{allProjects.flatMap(project => {
const { projectPosts = [] } = useProjectPosts(project.id) ?? {};
return projectPosts.map((post) => (
<StyledView key={post.id} className="mb-2">
<UpdateCard topText={post.title} bottomText={post.description} quantity={''} />
</StyledView>
));
})}
</StyledView>
</StyledView>
)}
</StyledScrollView>
</StyledView>
);
}
};
15 changes: 0 additions & 15 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1474,11 +1474,6 @@
postcss "~8.4.32"
resolve-from "^5.0.0"

"@expo/[email protected]":
version "2.3.41"
resolved "https://registry.npmjs.org/@expo/ngrok-bin-linux-x64/-/ngrok-bin-linux-x64-2.3.41.tgz"
integrity sha512-LcU3MbYHv7Sn2eFz8Yzo2rXduufOvX1/hILSirwCkH+9G8PYzpwp2TeGqVWuO+EmvtBe6NEYwgdQjJjN6I4L1A==

"@expo/[email protected]":
version "2.3.42"
resolved "https://registry.npmjs.org/@expo/ngrok-bin/-/ngrok-bin-2.3.42.tgz"
Expand Down Expand Up @@ -6550,16 +6545,6 @@ lighthouse-logger@^1.0.0:
debug "^2.6.9"
marky "^1.2.2"

[email protected]:
version "1.27.0"
resolved "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.27.0.tgz"
integrity sha512-Dk/jovSI7qqhJDiUibvaikNKI2x6kWPN79AQiD/E/KeQWMjdGe9kw51RAgoWFDi0coP4jinaH14Nrt/J8z3U4A==

[email protected]:
version "1.27.0"
resolved "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.27.0.tgz"
integrity sha512-QKjTxXm8A9s6v9Tg3Fk0gscCQA1t/HMoF7Woy1u68wCk5kS4fR+q3vXa1p3++REW784cRAtkYKrPy6JKibrEZA==

lightningcss@~1.27.0:
version "1.27.0"
resolved "https://registry.npmjs.org/lightningcss/-/lightningcss-1.27.0.tgz"
Expand Down

0 comments on commit 1497d92

Please sign in to comment.