Skip to content

Commit

Permalink
refactor: replace widget by antd Card component
Browse files Browse the repository at this point in the history
  • Loading branch information
shootermv committed Nov 1, 2023
1 parent 22df36e commit f31f60d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 43 deletions.
63 changes: 33 additions & 30 deletions src/pages/GapsPatternsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext, useEffect, useState } from 'react'
import './GapsPatternsPage.scss'
import { Moment } from 'moment'
import { Skeleton, Spin } from 'antd'
import { Card, Skeleton, Spin } from 'antd'
import moment from 'moment/moment'
import { useDate } from './components/DateTimePicker'
import { PageContainer } from './components/PageContainer'
Expand Down Expand Up @@ -205,36 +205,39 @@ const GapsPatternsPage = () => {
setLineNumber={(number) => setSearch((current) => ({ ...current, lineNumber: number }))}
/>
</Grid>
</Grid>

<Grid xs={12}>
{routesIsLoading && (
<Row>
<Label text={TEXTS.loading_routes} />
<Spin />
</Row>
)}
{!routesIsLoading &&
routes &&
(routes.length === 0 ? (
<NotFound>{TEXTS.line_not_found}</NotFound>
) : (
<>
<RouteSelector
routes={routes}
routeKey={routeKey}
setRouteKey={(key) => setSearch((current) => ({ ...current, routeKey: key }))}
/>
<Grid xs={12}>
<GapsByHour
lineRef={routes?.find((route) => route.key === routeKey)?.lineRef || 0}
operatorRef={operatorId || ''}
fromDate={startDate}
toDate={endDate}
/>
</Grid>
</>
))}
</Grid>
<Grid xs={12}>
{routesIsLoading && (
<Row>
<Label text={TEXTS.loading_routes} />
<Spin />
</Row>
)}
{!routesIsLoading &&
routes &&
(routes.length === 0 ? (
<NotFound>{TEXTS.line_not_found}</NotFound>
) : (
<>
<RouteSelector
routes={routes}
routeKey={routeKey}
setRouteKey={(key) => setSearch((current) => ({ ...current, routeKey: key }))}
/>
</>
))}
</Grid>

<Grid xs={12}>
<Card>
<GapsByHour
lineRef={routes?.find((route) => route.key === routeKey)?.lineRef || 0}
operatorRef={operatorId || ''}
fromDate={startDate}
toDate={endDate}
/>
</Card>
</Grid>
</PageContainer>
)
Expand Down
7 changes: 1 addition & 6 deletions src/pages/dashboard/DashboardPage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
}

.widget {
border: 1px solid #e0e0e0;
border-radius: 4px;
padding: 20px;
box-sizing: border-box;
margin-bottom: 20px;
background-color: white;


.chart {
height: 400px;
Expand Down
14 changes: 7 additions & 7 deletions src/pages/dashboard/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import LinesHbarChart from './LineHbarChart/LinesHbarChart'
import { FormControlLabel, Switch, Tooltip } from '@mui/material'
import OperatorSelector from 'src/pages/components/OperatorSelector'
import { useDate } from '../components/DateTimePicker'
import { Skeleton } from 'antd'
import { Card, Skeleton } from 'antd'
import Grid from '@mui/material/Unstable_Grid2' // Grid version 2
import { Label } from '../components/Label'
import { DateSelector } from '../components/DateSelector'
Expand Down Expand Up @@ -120,7 +120,7 @@ const DashboardPage = () => {
</Grid>
<Grid container spacing={2} alignItems="flex-start">
<Grid xs={12} lg={6}>
<div className="widget">
<Card className="widget" hoverable>
<h2 className="title">
{TEXTS.dashboard_page_title}
<Tooltip
Expand All @@ -135,7 +135,7 @@ const DashboardPage = () => {
) : (
<OperatorHbarChart operators={convertToChartCompatibleStruct(groupByOperatorData)} />
)}
</div>
</Card>
</Grid>
<Grid xs={6} display={{ xs: 'block', lg: 'none' }}>
<OperatorSelector
Expand All @@ -145,7 +145,7 @@ const DashboardPage = () => {
/>
</Grid>
<Grid xs={12} lg={6}>
<div className="widget">
<Card className="widget" hoverable>
<h2 className="title">{TEXTS.worst_lines_page_title}</h2>
{lineDataLoading ? (
<Skeleton active />
Expand All @@ -155,17 +155,17 @@ const DashboardPage = () => {
operators_whitelist={['אלקטרה אפיקים', 'דן', 'מטרופולין', 'קווים', 'אגד']}
/>
)}
</div>
</Card>
</Grid>
<Grid xs={12}>
<div className="widget">
<Card className="widget" hoverable>
<h2 className="title">{TEXTS.dashboard_page_graph_title}</h2>
{loadingGrap ? (
<Skeleton active />
) : (
<ArrivalByTimeChart data={convertToGraphCompatibleStruct(graphData)} />
)}
</div>
</Card>
</Grid>
</Grid>
</PageContainer>
Expand Down

0 comments on commit f31f60d

Please sign in to comment.