-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
111 additions
and
8 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
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import MenuIcon from '@mui/icons-material/Menu'; | ||
import { Drawer, Fab } from '@mui/material'; | ||
import List from './List'; | ||
|
||
const SDrawer = (props) => { | ||
const [isDrawerOpen, setIsDrawerOpen] = React.useState(true); | ||
|
||
return ( | ||
<React.Fragment> | ||
<Fab | ||
sx={{ | ||
zIndex: 10000, | ||
position: 'fixed', | ||
bottom: 16, | ||
right: 16, | ||
opacity: isDrawerOpen ? 0.5 : 1, | ||
}} | ||
variant={'circular'} | ||
onClick={() => setIsDrawerOpen(!isDrawerOpen)}> | ||
<MenuIcon /> | ||
</Fab> | ||
<Drawer | ||
PaperProps={{ | ||
sx: { backgroundColor: 'transparent' }, | ||
className: 'launches-list', | ||
}} | ||
open={isDrawerOpen} | ||
onClick={() => setIsDrawerOpen(false)}> | ||
<List {...props} /> | ||
</Drawer> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
export default SDrawer; |
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from 'react'; | ||
import MList from '@mui/material/List'; | ||
import ListItem from '@mui/material/ListItem'; | ||
import ListItemButton from '@mui/material/ListItemButton'; | ||
import ListItemText from '@mui/material/ListItemText'; | ||
import ListItemAvatar from '@mui/material/ListItemAvatar'; | ||
import Avatar from '@mui/material/Avatar'; | ||
import { queryUpcomingLaunches } from '@shared/api/index'; | ||
import Skeleton from './Skeleton.jsx'; | ||
import '../index.scss'; | ||
|
||
const List = ({ | ||
setSelectedLaunch, | ||
}: { | ||
setSelectedLaunch: React.Dispatch<React.SetStateAction<{}>>; | ||
}) => { | ||
const { data, status } = queryUpcomingLaunches(); | ||
const launches = data || []; | ||
|
||
const skeletons = Array.from({ length: 10 }, (_, index) => ( | ||
<Skeleton key={index} /> | ||
)); | ||
|
||
return ( | ||
<React.Fragment> | ||
<MList> | ||
{status === 'loading' && skeletons} | ||
|
||
{launches.map((item) => { | ||
const time = item.t0 && new Date(item.t0).toLocaleString('ru'); | ||
const header = `${item.provider.name} • ${item.name}`; | ||
const subheader = `${item.provider.name} • ${item.vehicle.name} • ${ | ||
time || 'Время старта неизвестно' | ||
}`; | ||
|
||
return ( | ||
<ListItem | ||
onClick={() => { | ||
location.hash = `id=${item.id}`; | ||
setSelectedLaunch(item); | ||
}} | ||
disablePadding | ||
key={item.id}> | ||
<ListItemButton> | ||
<ListItemAvatar> | ||
<Avatar alt={item.name} src={item.image} /> | ||
</ListItemAvatar> | ||
<ListItemText primary={header} secondary={subheader} /> | ||
</ListItemButton> | ||
</ListItem> | ||
); | ||
})} | ||
</MList> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
export default List; |