5.x Giao diện thực hành search (ok)
Previous5.1 Next.js Building a Car Trader App #5- Pagination with filters for the list of carsNext5.xx Thực hành search đã nhận diện được dữ liệu (ok)
Last updated
Was this helpful?
Last updated
Was this helpful?
C:\Users\Administrator\Desktop\pro\pages\cars.tsx
C:\Users\Administrator\Desktop\pro\pages\cars.tsx
import { Grid, Card, CardHeader, Avatar, IconButton, CardMedia, Typography, makeStyles } from '@material-ui/core';
import MoreVertIcon from '@material-ui/icons/MoreVert';
import CardContent from '@material-ui/core/CardContent';
import deepEqual from 'fast-deep-equal';
import { GetServerSideProps } from 'next';
import { useRouter } from 'next/router';
import { stringify } from 'querystring';
import { useState } from 'react';
import useSWR from 'swr';
import Search from '.';
import { CarModel } from './api/Car';
import Link from 'next/link';
import Pagination from '@material-ui/lab/Pagination';
import { getMakes, Make } from './database/getMakes';
import { getModels, Model } from './database/getModels';
import { getPaginatedCars } from './database/getPaginatedCars';
import { getAsString } from '../getAsString';
export interface CarsListProps {
makes: Make[];
models: Model[];
cars: CarModel[];
totalPages: number;
}
const useStyles = makeStyles((theme) => ({
media: {
height: 0,
paddingTop: '56.25%', // 16:9
},
expand: {
transform: 'rotate(0deg)',
marginLeft: 'auto',
transition: theme.transitions.create('transform', {
duration: theme.transitions.duration.shortest,
}),
},
expandOpen: {
transform: 'rotate(180deg)',
},
avatar: {
backgroundColor: 'red',
},
achorTag: {
textDecoration: 'none'
}
}));
export default function CarsList() {
const classes = useStyles();
return (
<Grid container spacing={3}>
<Grid item xs={12} sm={5} md={3} lg={2}>
<Search />
</Grid>
<Grid container item xs={12} sm={7} md={9} lg={10} spacing={3}>
<Grid item xs={12}>
<Pagination count={10} />
</Grid>
<Grid item xs={12} sm={6}>
<Link
href="#"
as={null}
>
<a className={classes.achorTag}>
<Card>
<CardHeader
avatar={
<Avatar aria-label="recipe" className={classes.avatar}>
R
</Avatar>
}
action={
<IconButton aria-label="settings">
<MoreVertIcon />
</IconButton>
}
title={'car.mode'}
subheader={5}
/>
<CardMedia
className={classes.media}
image='photos/cars/volkswagen-eos-2008-14700.jpg'
title={'aaaaaaaaaa'}
/>
<CardContent>
<Typography variant="body2" color="textSecondary" component="p">
{'car.details'}
</Typography>
</CardContent>
</Card>
</a>
</Link>
</Grid>
<Grid item xs={12}>
<Pagination count={10} />
</Grid>
</Grid>
</Grid>
);
}