Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

front-react-portfolio_individual: fix other portfolio buttons. show current. selected is coloured. #194

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions front/react/src/components/portfolio/PortfolioManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import useCombinedPortfolioDetails from "../../hooks/useCombinedPortfolioDetails
const PortfolioManager = () => {
const navigate = useNavigate();
const {portfolioType} = useParams();
const otherPortfolioTypes = portfolioTypes.filter(allPortfolioTypes => allPortfolioTypes.type.toLowerCase() !== portfolioType.toLowerCase());
const currentPortfolioType = portfolioTypes.find(allPortfolioTypes => allPortfolioTypes.type.toLowerCase() === portfolioType.toLowerCase());
const {portfolio, addFunds, withdrawFunds} = usePortfolio(portfolioType.toUpperCase());

const {portfolios} = useCombinedPortfolioDetails();
Expand Down Expand Up @@ -107,13 +107,23 @@ const PortfolioManager = () => {
<PortfolioDetails portfolio={portfolio}/>
</Box>
<Box>
{otherPortfolioTypes.map((portfolio, index) => (
<Button key={index}
mr="1rem"
onClick={() => handlePortfolioSelection(portfolio.type)}
>
{portfolio.title.split(' ')[0]}
</Button>
{portfolioTypes.map((portfolio, index) => (
portfolio.type === currentPortfolioType.type ?
<Button mr="1rem"
p={5}
disabled="true"
bg={chartData.borderColor}
>
{currentPortfolioType.title.split(' ')[0]}
</Button>
:
<Button key={index}
mr="1rem"
p={5}
onClick={() => handlePortfolioSelection(portfolio.type)}
>
{portfolio.title.split(' ')[0]}
</Button>
))}
</Box>
</HStack>
Expand Down
4 changes: 2 additions & 2 deletions front/react/src/pages/portfolio/PortfolioPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ export default function PortfolioPage() {
columns={{ base: 3}}
spacing={5}
px={{ base: 8, lg: 16, xl: 24 }}
py={10}
py={5}
mx="auto"
bg="white"
_dark={{ bg: "gray.800" }}
shadow="xl">

{portfolioTypes.map((portfolio, index) => (
<HStack key={index} title={portfolio.title} align="center" spacing={0} mb={4}>
<HStack key={index} title={portfolio.title} align="center" spacing={0} mb={1}>
<Button
fontSize="md" p={10} mr={2}
onClick={() => handlePortfolioSelection(portfolio.type)}
Expand Down