Skip to content

Commit

Permalink
feat: add widget component (#283)
Browse files Browse the repository at this point in the history
* New Widget Component


---------

Co-authored-by: yadenmezi <[email protected]>
  • Loading branch information
yardenmezi and yadenmezi authored Dec 10, 2023
1 parent 0023217 commit 1d6d636
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/pages/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import RouteSelector from './components/RouteSelector'
//API
// import { /*getGtfsRidesList,*/ getRidesAsync } from 'src/api/profileService'
import { getRoutesAsync } from '../api/gtfsService'
import Widget from 'src/shared/Widget'

// time inputs
// import { DateSelector } from './components/DateSelector'
Expand Down Expand Up @@ -92,7 +93,7 @@ const LineProfileComponent = ({ search }: { search: PageSearchState }) => {

return (
<Grid xs={12} lg={6}>
<div className="widget">
<Widget>
<h2 className="title">{t('profile_page')}</h2>
<label> מפעיל: {search.operatorId} </label>
<br></br>
Expand Down Expand Up @@ -143,7 +144,7 @@ const LineProfileComponent = ({ search }: { search: PageSearchState }) => {
<Label text="הערות ועדכונים על הקו:" />
<div></div>
</div>
</div>
</Widget>
</Grid>
)
}
Expand Down
5 changes: 3 additions & 2 deletions src/pages/components/Widget.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import type { Meta, StoryObj } from '@storybook/react'
import { BusToolTip } from './MapLayers/BusToolTip'
import '../../shared/shared.css'
import Widget from 'src/shared/Widget'
const meta = {
title: 'Components/Widget',
component: () => (
<div style={{ background: '#f0f2f5', width: '400px', padding: '20px' }}>
<div className="widget">
<Widget>
שלום חברים!
<br />
ככה נראה widget util
</div>
</Widget>
</div>
),
parameters: {
Expand Down
5 changes: 3 additions & 2 deletions src/pages/dashboard/AllLineschart/AllLinesChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import OperatorHbarChart from './OperatorHbarChart/OperatorHbarChart'
import { GroupByRes, useGroupBy } from 'src/api/groupByService'
import { FC } from 'react'
import { Moment } from 'moment/moment'
import Widget from 'src/shared/Widget'

const convertToChartCompatibleStruct = (arr: GroupByRes[]) => {
return arr.map((item: GroupByRes) => ({
Expand All @@ -29,7 +30,7 @@ export const AllLinesChart: FC<AllChartComponentProps> = ({ startDate, endDate }
})

return (
<div className="widget">
<Widget>
<h2 className="title">
{TEXTS.dashboard_page_title}
<Tooltip
Expand All @@ -44,7 +45,7 @@ export const AllLinesChart: FC<AllChartComponentProps> = ({ startDate, endDate }
) : (
<OperatorHbarChart operators={convertToChartCompatibleStruct(groupByOperatorData)} />
)}
</div>
</Widget>
)
}

Expand Down
5 changes: 3 additions & 2 deletions src/pages/dashboard/ArrivalByTimeChart/DayTimeChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Skeleton, Radio, RadioChangeEvent } from 'antd'
import ArrivalByTimeChart from './ArrivalByTimeChart'
import { GroupByRes, useGroupBy } from 'src/api/groupByService'
import { Moment } from 'moment/moment'
import Widget from 'src/shared/Widget'

const convertToGraphCompatibleStruct = (arr: GroupByRes[]) => {
return arr.map((item: GroupByRes) => ({
Expand Down Expand Up @@ -33,7 +34,7 @@ const DayTimeChart: FC<DayTimeChartProps> = ({ startDate, endDate, operatorId })
})

return (
<div className="widget">
<Widget>
<h2 className="title">
{groupByHour ? TEXTS.dashboard_page_graph_title_hour : TEXTS.dashboard_page_graph_title_day}
</h2>
Expand All @@ -52,7 +53,7 @@ const DayTimeChart: FC<DayTimeChartProps> = ({ startDate, endDate, operatorId })
operatorId={operatorId}
/>
)}
</div>
</Widget>
)
}

Expand Down
5 changes: 3 additions & 2 deletions src/pages/dashboard/WorstLinesChart/WorstLinesChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import LinesHbarChart from './LineHbarChart/LinesHbarChart'
import { TEXTS } from 'src/resources/texts'
import { FC } from 'react'
import { Moment } from 'moment/moment'
import Widget from 'src/shared/Widget'

interface WorstLinesChartProps {
startDate: Moment
Expand Down Expand Up @@ -35,7 +36,7 @@ export const WorstLinesChart: FC<WorstLinesChartProps> = ({ startDate, endDate,
}

return (
<div className="widget">
<Widget>
<h2 className="title">{TEXTS.worst_lines_page_title}</h2>
{lineDataLoading ? (
<Skeleton active />
Expand All @@ -45,7 +46,7 @@ export const WorstLinesChart: FC<WorstLinesChartProps> = ({ startDate, endDate,
operators_whitelist={['אלקטרה אפיקים', 'דן', 'מטרופולין', 'קווים', 'אגד']}
/>
)}
</div>
</Widget>
)
}

Expand Down
5 changes: 3 additions & 2 deletions src/pages/gapsPatterns/GapsPatternsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { DateSelector } from '../components/DateSelector'
import { INPUT_SIZE } from 'src/resources/sizes'
const { Title } = Typography
import { useTranslation } from 'react-i18next'
import Widget from 'src/shared/Widget'
// Define prop types for the component
interface BusLineStatisticsProps {
lineRef: number
Expand Down Expand Up @@ -71,7 +72,7 @@ function GapsByHour({ lineRef, operatorRef, fromDate, toDate }: BusLineStatistic

return (
lineRef > 0 && (
<div className="widget">
<Widget>
<Title level={3}>{t('dashboard_page_graph_title')}</Title>

{isLoading && lineRef ? (
Expand Down Expand Up @@ -137,7 +138,7 @@ function GapsByHour({ lineRef, operatorRef, fromDate, toDate }: BusLineStatistic
</ResponsiveContainer>
</>
)}
</div>
</Widget>
)
)
}
Expand Down
5 changes: 5 additions & 0 deletions src/shared/Widget.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const Widget = (props: { children: React.ReactNode }) => {
return <div className="widget">{props.children}</div>
}

export default Widget

0 comments on commit 1d6d636

Please sign in to comment.