Skip to content

Commit

Permalink
12 improve tables design and functionality in results page (#16)
Browse files Browse the repository at this point in the history
* 12 Rework Global Statistics component to be Table, and added headers to both tables

* 12 Rework the whole Results screen and Statistics components to better visualise data

---------

Co-authored-by: Anton Arnaudov <anton.arnaudov@audienceplatform.tv>
  • Loading branch information
antonarnaudov and Anton Arnaudov authored Dec 26, 2023
1 parent e6358ca commit 704396a
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 207 deletions.
2 changes: 2 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico"/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" />

<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
Expand Down
2 changes: 1 addition & 1 deletion src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
width: 100%;
height: auto;
min-height: 100vh;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
font-family: 'Roboto', "Segoe UI", sans-serif;
}

body {
Expand Down
12 changes: 12 additions & 0 deletions src/components/design/TableRow.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {styled} from "@mui/material/styles";
import TableRow from "@mui/material/TableRow";

export const ZebraStyleTableRow = styled(TableRow)(() => ({
'&:nth-of-type(odd)': {
backgroundColor: '#e6e6e6',
},
// hide last border
'&:last-child td, &:last-child th': {
border: 0,
},
}));
157 changes: 24 additions & 133 deletions src/components/results/GlobalStatistics.jsx
Original file line number Diff line number Diff line change
@@ -1,143 +1,34 @@
import React from "react";

import {Stack} from "@mui/material";

import {DefaultTextField} from "../design/TextFeld";
import {LevInputAdornment} from "../design/InputAdornment";

import {getGlobalStatistics} from "../../data/local-storage";

import TableRow from "@mui/material/TableRow";
import TableCell from "@mui/material/TableCell";

export const GlobalStatistics = () => {
const globalStatistics = getGlobalStatistics()

return (
<div className="global-statistics">
{/*Global Results*/}
<Stack
id='global-statistics-box'
className="global-statistics-box"
direction="row"
justifyContent="space-evenly"
alignItems="center"
spacing={2}
>
{/* Global Info */}
<Stack direction="column" spacing={5}>
{/* Shop Name */}
<DefaultTextField
disabled
className="global-name"
defaultValue='Global Statistics'
></DefaultTextField>

{/* Shops Count */}
<DefaultTextField
disabled
id="global-shops-count"
label="Total Shops Count"
defaultValue={globalStatistics.total_shops_count}
></DefaultTextField>

{/* Products Count */}
<DefaultTextField
disabled
id="global-products-count"
label="Total Products Count"
defaultValue={globalStatistics.total_products_count}
></DefaultTextField>
</Stack>

{/* Total Values */}
<Stack direction="column" spacing={5}>
{/* Total Commission */}
<DefaultTextField
disabled
id="global-total-commission"
label="Total Commission"
defaultValue={globalStatistics.total_commission}
InputProps={{startAdornment: <LevInputAdornment/>}}
></DefaultTextField>

{/* Total Commission */}
<DefaultTextField
disabled
id="global-total-discount"
label="Total Discount"
defaultValue={globalStatistics.total_discount}
InputProps={{startAdornment: <LevInputAdornment/>}}
></DefaultTextField>

{/* Total Commission */}
<DefaultTextField
disabled
id="global-total-shops-profit"
label="Total Shops Profit"
defaultValue={globalStatistics.total_shop_profit}
InputProps={{startAdornment: <LevInputAdornment/>}}
></DefaultTextField>
</Stack>

{/* Average Values */}
<Stack direction="column" spacing={5}>
{/* Avg Commission */}
<DefaultTextField
disabled
id="global-avg-commission"
label="Average Commission"
defaultValue={globalStatistics.avg_commission}
InputProps={{startAdornment: <LevInputAdornment/>}}
></DefaultTextField>

{/* Avg Commission */}
<DefaultTextField
disabled
id="global-avg-discount"
label="Average Discount"
defaultValue={globalStatistics.avg_discount}
InputProps={{startAdornment: <LevInputAdornment/>}}
></DefaultTextField>

{/* Avg Commission */}
<DefaultTextField
disabled
id="global-avg-shops-profit"
label="Average Shops Profit"
defaultValue={globalStatistics.avg_shop_profit}
InputProps={{startAdornment: <LevInputAdornment/>}}
></DefaultTextField>
</Stack>

{/* Commission Breakdown */}
<Stack direction="column" spacing={5}>
{/* Products Commissioned */}
<DefaultTextField
disabled
id="global-products-commissioned"
label="Total Products Commissioned"
defaultValue={globalStatistics.total_products_commissioned}
InputProps={{startAdornment: <LevInputAdornment/>}}
></DefaultTextField>

{/* Pure Commission */}
<DefaultTextField
disabled
id="global-pure-commission"
label="Total Pure Commission"
defaultValue={globalStatistics.total_pure_commission}
InputProps={{startAdornment: <LevInputAdornment/>}}
></DefaultTextField>

{/* Min Profit */}
<DefaultTextField
disabled
id="global-min-profit"
label="Total Min Profit"
defaultValue={globalStatistics.total_min_profit}
InputProps={{startAdornment: <LevInputAdornment/>}}
></DefaultTextField>
</Stack>
</Stack>
</div>
<React.Fragment>
<TableRow className='global-statistics'>
{/* Info */}
<TableCell className='table-cell' >{globalStatistics.total_shops_count}</TableCell>
<TableCell className='table-cell'>{globalStatistics.total_products_count}</TableCell>

{/* Commission Breakdown */}
<TableCell className='border-left-dark table-cell'>{globalStatistics.total_products_commissioned}</TableCell>
<TableCell className='table-cell'>{globalStatistics.total_pure_commission} лв</TableCell>
<TableCell className='table-cell'>{globalStatistics.total_min_profit} лв</TableCell>

{/* Average Values */}
<TableCell className='border-left-dark table-cell'>{globalStatistics.avg_commission} лв</TableCell>
<TableCell className='table-cell'>{globalStatistics.avg_discount} лв</TableCell>
<TableCell className='table-cell'>{globalStatistics.avg_shop_profit} лв</TableCell>

{/* Total Values */}
<TableCell className='border-left-dark table-cell'>{globalStatistics.total_commission} лв</TableCell>
<TableCell className='table-cell'>{globalStatistics.total_discount} лв</TableCell>
<TableCell className='table-cell'>{globalStatistics.total_shop_profit} лв</TableCell>
</TableRow>
</React.Fragment>
);
};
5 changes: 3 additions & 2 deletions src/components/results/ProductStatistics.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {Typography} from "@mui/material";
import Table from "@mui/material/Table";
import TableHead from "@mui/material/TableHead";
import TableBody from "@mui/material/TableBody";
import {ZebraStyleTableRow} from "../design/TableRow"

export const ProductStatistics = ({products, open}) => {
return (
Expand All @@ -30,15 +31,15 @@ export const ProductStatistics = ({products, open}) => {
</TableHead>
<TableBody>
{products.map((product) => (
<TableRow key={product.id}>
<ZebraStyleTableRow key={product.id}>
<TableCell>{product.name}</TableCell>
<TableCell>{product.price} лв</TableCell>
<TableCell>{product.commission} лв</TableCell>
<TableCell>{product.discount} лв</TableCell>
<TableCell>{product.shop_profit} лв</TableCell>
<TableCell>{product.min_profit} лв</TableCell>
<TableCell>{product.pure_commission} лв</TableCell>
</TableRow>
</ZebraStyleTableRow>
))}
</TableBody>
</Table>
Expand Down
111 changes: 82 additions & 29 deletions src/components/results/ResultsFrame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,100 @@ import {GlobalStatistics} from "./GlobalStatistics";
export const ResultsFrame = () => {
return (
<div className="results-frame">
<GlobalStatistics></GlobalStatistics>

<TableContainer sx={{width: '90%'}} className='shops-table'>
<Table aria-label="collapsible table">
<TableHead>
<TableRow>
<TableCell align="center" colSpan={7}>
{/*---------------- Global Breakdown ----------------*/}
<TableContainer sx={{width: '95%'}} className='global-statistics-table'>
<h1 id='title'>Global Statistics</h1>

<Table className='table'>
<TableHead className='table-head'>
<TableRow className='table-row'>
<TableCell className='info-cell' align="center" colSpan={2}>
Info
</TableCell>
<TableCell className='border-left' align="center" colSpan={3}>
Total Values

<TableCell className='breakdown-cell border-left-dark' align="center" colSpan={3}>
Commission Breakdown
</TableCell>
<TableCell className='border-left' align="center" colSpan={3}>

<TableCell className='avg-cell border-left-dark' align="center" colSpan={3}>
Average Values
</TableCell>
<TableCell className='border-left' align="center" colSpan={3}>

<TableCell className='total-cell border-left-dark' align="center" colSpan={3}>
Total Values
</TableCell>
</TableRow>

<TableRow>
<TableCell className='info-cell-lighter border-left'>Total Shops Count</TableCell>
<TableCell className='info-cell-lighter border-left'>Total Products Count</TableCell>

<TableCell className='breakdown-cell-lighter border-left-dark'>Products Commissioned</TableCell>
<TableCell className='breakdown-cell-lighter border-left'>Pure Commission</TableCell>
<TableCell className='breakdown-cell-lighter border-left border-left'>Min Profit</TableCell>

<TableCell className='avg-cell-lighter border-left-dark'>Avg Commission</TableCell>
<TableCell className='avg-cell-lighter border-left'>Avg Discount</TableCell>
<TableCell className='avg-cell-lighter border-left'>Avg Shop Profit</TableCell>

<TableCell className='total-cell-lighter border-left-dark'>Total Commission</TableCell>
<TableCell className='total-cell-lighter border-left'>Total Discount</TableCell>
<TableCell className='total-cell-lighter border-left'>Total Shop Profit</TableCell>
</TableRow>
</TableHead>

<TableBody>
<GlobalStatistics></GlobalStatistics>
</TableBody>
</Table>
</TableContainer>


{/*---------------- Statistics Breakdown ----------------*/}
<TableContainer sx={{width: '95%'}} className='shops-table'>
<h1 id='title'>Shops Statistics Breakdown</h1>

<Table className='table' aria-label="collapsible table">
<TableHead className='table-head'>
<TableRow>
<TableCell className='info-cell' align="center" colSpan={7}>
Info
</TableCell>
<TableCell className='breakdown-cell border-left-dark' align="center" colSpan={3}>
Commission Breakdown
</TableCell>
<TableCell className='avg-cell border-left-dark' align="center" colSpan={3}>
Average Values
</TableCell>
<TableCell className='total-cell border-left-dark' align="center" colSpan={3}>
Total Values
</TableCell>
</TableRow>
<TableRow>
<TableCell/>
<TableCell>Shop Name</TableCell>
<TableCell>Products Count</TableCell>
<TableCell>Commission</TableCell>
<TableCell>Discount</TableCell>
<TableCell>Min Profit</TableCell>
<TableCell>Profit Limit</TableCell>

<TableCell className='border-left'>Total COMM</TableCell>
<TableCell>Total Discount</TableCell>
<TableCell>Total Shop Profit</TableCell>

<TableCell className='border-left'>Avg COMM</TableCell>
<TableCell>Avg Discount</TableCell>
<TableCell>Avg Shop Profit</TableCell>

<TableCell className='border-left'>Products COMM</TableCell>
<TableCell>Pure COMM</TableCell>
<TableCell>Min Profit</TableCell>
<TableCell className='info-cell-lighter'/>

<TableCell className='info-cell-lighter'>Shop Name</TableCell>
<TableCell className='info-cell-lighter border-left'>Products Count</TableCell>
<TableCell className='info-cell-lighter border-left'>Commission</TableCell>
<TableCell className='info-cell-lighter border-left'>Discount</TableCell>
<TableCell className='info-cell-lighter border-left'>Min Profit</TableCell>
<TableCell className='info-cell-lighter border-left'>Profit Limit</TableCell>

<TableCell className='breakdown-cell-lighter border-left-dark'>Products Commissioned</TableCell>
<TableCell className='breakdown-cell-lighter border-left'>Pure Commission</TableCell>
<TableCell className='breakdown-cell-lighter border-left'>Min Profit</TableCell>

<TableCell className='avg-cell-lighter border-left-dark'>Avg Commission</TableCell>
<TableCell className='avg-cell-lighter border-left'>Avg Discount</TableCell>
<TableCell className='avg-cell-lighter border-left'>Avg Shop Profit</TableCell>

<TableCell className='total-cell-lighter border-left-dark'>Total Commission</TableCell>
<TableCell className='total-cell-lighter border-left'>Total Discount</TableCell>
<TableCell className='total-cell-lighter border-left'>Total Shop Profit</TableCell>
</TableRow>
</TableHead>

<TableBody>
{getShops().map((shop) => (
<ShopStatistics
Expand Down
Loading

0 comments on commit 704396a

Please sign in to comment.