diff --git a/Frontend/src/components/screens/Analysis/AnalysisList.jsx b/Frontend/src/components/screens/Analysis/AnalysisList.jsx
index a0e38c5f..2a04aeb6 100644
--- a/Frontend/src/components/screens/Analysis/AnalysisList.jsx
+++ b/Frontend/src/components/screens/Analysis/AnalysisList.jsx
@@ -53,12 +53,16 @@ const AnalysisList = (props) => {
onChange={handleChange}
value={analysisType}
>
- {props.analysisTypes.map((type, index) => (
-
- ))}
+ {props.analysisTypes.map((type, index) => {
+ if(props.allArrays[index].length > 0){
+ return ();
+ }
+ })
+
+ }
- {
+ {
props.allArrays[analysisType] && props.allArrays[analysisType].map((share, index) => (
{
}
);
+
}
AnalysisList.propTypes = {
diff --git a/Frontend/src/components/screens/Analysis/AnalysisScreen.jsx b/Frontend/src/components/screens/Analysis/AnalysisScreen.jsx
index 2fae2b48..77e23358 100644
--- a/Frontend/src/components/screens/Analysis/AnalysisScreen.jsx
+++ b/Frontend/src/components/screens/Analysis/AnalysisScreen.jsx
@@ -1,10 +1,11 @@
import React, {useState} from 'react';
import ScreensTemplate from '../../ScreensTemplate';
-import {Grid} from '@mui/material';
+import {Grid, Typography, Button} from '@mui/material';
import PropTypes from 'prop-types';
import AnalysisList from './AnalysisList';
import {DoughnutChart} from '../../common';
+import { useNavigate } from "react-router-dom";
/**
* Component related to the analysis page
@@ -16,11 +17,23 @@ const AnalysisScreen = props => {
const [analysisType, setAnalysisType] = useState(0);
+ let navigate = useNavigate();
+
+ const routeChange = () =>{
+ let path = `/activities/addActivity`;
+ navigate(path);
+ }
+
const portfolioData = props.portfolioData[props.activePortfolio];
const analysisTypes = ['Asset Type Allocation', 'Shares Allocation', 'Crypto Allocation', 'Cash Allocation', 'Region Allocation', 'Sub region Allocation', 'Country Allocation', 'Sector Allocation', 'Industry Allocation', 'Asset Class Allocation'];
let keywordCollection = ['region', 'sub_region', 'country', 'sector', 'branche', 'assetClass'];
let allArrays = [];
let doughnutChartData = {};
+ let isPortfolioSet = false;
+
+ if(portfolioData.value > 0){
+ isPortfolioSet = true;
+ }
const calculateStockSplit = keyword => { //Calculate Stock, Crypto and Cash Allocation
let value;
@@ -70,7 +83,13 @@ const AnalysisScreen = props => {
}
})
} else {
- sectorArray.push([element.analysisInfo[keyword], parseFloat(element.value)]);
+ if(element.analysisInfo[keyword]){
+ sectorArray.push([element.analysisInfo[keyword], parseFloat(element.value)]);
+ } else{
+ let unknowKeyword = 'Unknown ' +keyword;
+ sectorArray.push([unknowKeyword, parseFloat(element.value)]);
+ }
+
}
});
@@ -97,35 +116,43 @@ const AnalysisScreen = props => {
}
})
- percentage = stockValue / value * 100;
-
- stockArray.push({
- asset: 'Stock',
- percentage: percentage.toFixed(2)
- })
-
+
- percentage = etfValue / value * 100;
+ if(stockValue){
+ percentage = stockValue / value * 100;
- stockArray.push({
- asset: 'ETF',
- percentage: percentage.toFixed(2)
- })
+ stockArray.push({
+ asset: 'Stock',
+ percentage: percentage.toFixed(2)
+ })
+ }
+
+ if(etfValue){
+ percentage = etfValue / value * 100;
+ stockArray.push({
+ asset: 'ETF',
+ percentage: percentage.toFixed(2)
+ })
+ }
- percentage = portfolioData.cryptoValue / value * 100;
+ if(portfolioData.cryptoValue){
+ percentage = portfolioData.cryptoValue / value * 100;
- stockArray.push({
- asset: 'Crypto',
- percentage: percentage.toFixed(2)
- })
+ stockArray.push({
+ asset: 'Crypto',
+ percentage: percentage.toFixed(2)
+ })
+ }
- percentage = portfolioData.cashValue / value * 100;
+ if(portfolioData.cashValue ){
+ percentage = portfolioData.cashValue / value * 100;
- stockArray.push({
- asset: 'Cash',
- percentage: percentage.toFixed(2)
- })
+ stockArray.push({
+ asset: 'Cash',
+ percentage: percentage.toFixed(2)
+ })
+ }
}
return orderArray(stockArray);
@@ -170,28 +197,110 @@ const AnalysisScreen = props => {
doughnutChartData = getDoughnutChartData(allArrays[analysisType]);
- const renderBody = () => (
-
-
-
-
-
-
-
-
- );
+ const renderBody = () => {
+ if(isPortfolioSet){
+ return(
+
+
+
+
+
+
+
+
+ );
+ } else{
+ return(
+
+
+
+
+
+
+
+
+ Start off by adding a Activity
+
+
+ With activities you can fill your portfolio with your diffrent types of assets.
+
+
+ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
+
+
+
+
+
+
+ );
+ }
+
+ }
+
return (