-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
TrafficJamsCounter
and A11yTransportCounters
- Loading branch information
1 parent
7e512cb
commit 5d1a8c0
Showing
5 changed files
with
52 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,42 @@ | ||
import { Unit } from 'transport-common/types/masstrans'; | ||
import { fetchApi } from 'api/utils/fetch'; | ||
|
||
export const MainPageApi = { | ||
getCards: () => { | ||
return fetchApi( | ||
getCards: async () => { | ||
return await fetchApi( | ||
'https://transport-cms.ekaterinburg.io/api/cards/?populate=backgroundImage', | ||
{ dataField: 'data' }, | ||
); | ||
}, | ||
|
||
getMarqueeItems: () => { | ||
return fetchApi('https://transport-cms.ekaterinburg.io/api/marquees', { | ||
dataField: 'data', | ||
}); | ||
getTrafficJamsCounter: async () => { | ||
return await fetchApi( | ||
'https://ekb-probki.vercel.app/api', | ||
{ dataField: 'score' }, | ||
); | ||
}, | ||
|
||
getNotifications: () => { | ||
return fetchApi('https://transport-cms.ekaterinburg.io/api/notifications', { | ||
getA11yTransportCounters: async () => { | ||
const countA11yUnits = async (type) => { | ||
const units = <Unit[]>await fetchApi( | ||
`https://transport.ekaterinburg.city/api/masstrans/${type}`, | ||
{ dataField: 'data' } | ||
); | ||
return units | ||
.filter(({ accessibility }) => accessibility) | ||
.length; | ||
} | ||
|
||
return { | ||
buses: await countA11yUnits('bus'), | ||
trolls: await countA11yUnits('troll'), | ||
trams: await countA11yUnits('tram') | ||
} | ||
}, | ||
|
||
getMarqueeItems: async () => { | ||
return await fetchApi('https://transport-cms.ekaterinburg.io/api/marquees', { | ||
dataField: 'data', | ||
}); | ||
}, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
import type { Card, Marquee, Notification } from 'api/main-page/main-page.types'; | ||
import type { | ||
Card, | ||
AccessibilityTransportCounters, | ||
Marquee, | ||
Notification | ||
} from 'api/main-page/main-page.types'; | ||
|
||
export type MainPageTypes = { | ||
cards: Card[]; | ||
trafficJams: number; | ||
a11yTransportCounters: AccessibilityTransportCounters, | ||
notifications: Notification[]; | ||
marqueeItems: Marquee[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5d1a8c0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for transport ready!
✅ Preview
https://transport-ope5s5yn8-ekbdev.vercel.app
https://ekbdev-transport-feature-main-page-data.vercel.app
Built with commit 5d1a8c0.
This pull request is being automatically deployed with vercel-action