正在为一家医院开展一个项目,在该项目中,患者的数据从他们的 api 中提取并作为卡片加载到页面上(将提供屏幕截图)。当你点击一张卡片时,病人的更多信息会以模态形式出现。这里的目标是让他们在有人根据 slug 搜索它时进行渲染。来自 api 的每个端点都有一个 slug:API 数据
例如,如果您访问 localhost:3000/WebersWarriors (localhost:3000/${shirt.slug}),它将呈现该特定模式,如果您单击卡片,它将在 URL 末尾附加“WebersWarriors”。任何帮助或建议将不胜感激,谢谢! 布局
动态显示的模态代码:
const TshirtItem = props => {
const classes = useStyles();
const { shirt } = props;
const theme = useTheme();
const [open, setOpen] = React.useState(false);
const matches = useMediaQuery(theme.breakpoints.down('sm'));
const handleClickOpen = () => {
setOpen(true);
setTimeout(() => {
handleClose();
}, 30000);
};
const handleClose = () => {
setOpen(false);
};
const handleDetail = content => (
<Dialog
fullScreen={matches}
className={classes.dialog}
open={open}
TransitionComponent={Transition}
keepMounted
onClose={handleClose}
aria-labelledby="alert-dialog-slide-title"
aria-describedby="alert-dialog-slide-description"
>
<DialogContent>
<Grid container>
<Grid item>
{shirt.ar_lens_card !== null ? (
<img
key={shirt.ar_lens_card.id}
src={shirt.ar_lens_card.url}
title={shirt.ar_lens_card.name}
alt={shirt.ar_lens_card.name}
className={classes.dialog_img}
/>
) : null}
</Grid>
<Grid item container>
<Grid item xs={2} container direction="column">
<Typography
className={classes.tshirt_number}
color="textSecondary"
>
#{shirt.Tshirt_Number}
</Typography>
</Grid>
<Grid item xs={10} container>
<Grid item xs>
<Typography className={classes.label}>Team</Typography>
<Typography className={classes.team_name}>
{shirt.team_name}
</Typography>
<hr className={classes.hr} />
<Typography className={classes.patient_name}>
{shirt.patient_first_name}
</Typography>
<Typography
color="textSecondary"
className={classes.patient_diagnosis}
>
{shirt.patient_diagnosis}
</Typography>
<Typography className={classes.patient_bio}>
{shirt.patient_bio}
</Typography>
</Grid>
</Grid>
{matches ? (
<IconButton
edge="start"
color="inherit"
onClick={handleClose}
aria-label="close"
className={classes.arrowback_icon}
>
<ArrowBackIosIcon fontSize="large" />
</IconButton>
) : null}
</Grid>
</Grid>
</DialogContent>
</Dialog>
);