-
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
1 parent
9a3841a
commit b26da14
Showing
9 changed files
with
281 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { | ||
makeStyles, | ||
Paper, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableContainer, | ||
TableHead, | ||
TableRow, | ||
Typography, | ||
} from '@material-ui/core'; | ||
import React from 'react'; | ||
import { BookOrder } from '../../../types/database'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
card: { | ||
margin: theme.spacing(1), | ||
}, | ||
})); | ||
|
||
interface Props { | ||
books: BookOrder[]; | ||
} | ||
|
||
export default function OrderBookList({ books }: Props) { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<div> | ||
<div className={classes.card}> | ||
<TableContainer component={Paper}> | ||
<Table aria-label="order table"> | ||
<TableHead> | ||
<TableRow> | ||
<TableCell>Livro</TableCell> | ||
<TableCell>Qnt. Alvo</TableCell> | ||
<TableCell>Qnt. Encomendada</TableCell> | ||
<TableCell>Qnt. Disponível</TableCell> | ||
<TableCell>Qnt. Levantada</TableCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{books.map((book: BookOrder) => ( | ||
<TableRow hover key={book.id}> | ||
<TableCell> | ||
<Typography>{book.name}</Typography> | ||
<Typography color="textSecondary"> | ||
{book.isbn} | ||
{book.codePe && ` (${book.codePe})`} | ||
</Typography> | ||
</TableCell> | ||
<TableCell>{book.targetQuantity}</TableCell> | ||
<TableCell>{book.orderedQuantity}</TableCell> | ||
<TableCell>{book.availableQuantity}</TableCell> | ||
<TableCell>{book.pickedupQuantity}</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
</div> | ||
<div className={classes.card}> | ||
<Typography> | ||
<strong>Qnt. Alvo: </strong>Quantidade que o cliente encomendou. | ||
</Typography> | ||
<Typography> | ||
<strong>Qnt. Encomenda: </strong>Quantidade que já foi encomendada à | ||
distribuidora e ainda não chegou. | ||
</Typography> | ||
<Typography> | ||
<strong>Qnt. Disponível: </strong>Quantidade disponível para | ||
levantamento. | ||
</Typography> | ||
<Typography> | ||
<strong>Qnt. Levantada: </strong>Quantidade já levantada pelo cliente. | ||
</Typography> | ||
</div> | ||
</div> | ||
); | ||
} |
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,75 @@ | ||
import { | ||
Card, | ||
CardContent, | ||
Grid, | ||
TextField, | ||
Typography, | ||
makeStyles, | ||
} from '@material-ui/core'; | ||
import React from 'react'; | ||
import { Order } from '../../../types/database'; | ||
import OrderStatusChip from '../OrderStatusChip'; | ||
import OrderBookList from './OrderBookList'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
card: { | ||
margin: theme.spacing(1), | ||
}, | ||
})); | ||
|
||
interface Props { | ||
order: Order; | ||
} | ||
|
||
export default function OrderData({ order }: Props) { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<div> | ||
<Typography variant="h4" className={classes.card}> | ||
Encomenda #{order.id} | ||
</Typography> | ||
<Card className={classes.card}> | ||
<CardContent> | ||
<Typography variant="h5">Informação</Typography> | ||
<Grid container spacing={2}> | ||
<Grid item xs={12} sm={6} md={4}> | ||
<Typography variant="h6">Cliente</Typography> | ||
<Typography> | ||
{order.customer?.name || 'Nome Desconhecido'} | ||
</Typography> | ||
<Typography>{order.customer?.phone}</Typography> | ||
<Typography>{order.customer?.email}</Typography> | ||
</Grid> | ||
<Grid item xs={12} sm={6} md={4}> | ||
<Typography variant="h6">Estado</Typography> | ||
<OrderStatusChip status={order.status} /> | ||
</Grid> | ||
<Grid item xs={12} sm={6} md={4}> | ||
<Typography variant="h6">Data de Encomenda</Typography> | ||
<Typography>{order.created_at}</Typography> | ||
<Typography color="textSecondary"> | ||
Última atualização a {order.updated_at} | ||
</Typography> | ||
</Grid> | ||
</Grid> | ||
</CardContent> | ||
</Card> | ||
<Card className={classes.card}> | ||
<CardContent> | ||
<Typography variant="h5">Observações</Typography> | ||
<TextField | ||
value={order.notes} | ||
InputProps={{ | ||
readOnly: true, | ||
}} | ||
multiline | ||
variant="outlined" | ||
fullWidth | ||
/> | ||
</CardContent> | ||
</Card> | ||
<OrderBookList books={order.books || []} /> | ||
</div> | ||
); | ||
} |
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,18 @@ | ||
import { Chip } from '@material-ui/core'; | ||
import React from 'react'; | ||
|
||
import { orderStatus } from '../../constants/enums'; | ||
import { OrderStatus } from '../../types/database'; | ||
|
||
interface Props { | ||
status: OrderStatus; | ||
} | ||
|
||
export default function OrderStatusChip({ status }: Props) { | ||
return ( | ||
<Chip | ||
style={{ backgroundColor: orderStatus[status].color }} | ||
label={orderStatus[status].displayName} | ||
/> | ||
); | ||
} |
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,44 @@ | ||
import { useSnackbar } from 'notistack'; | ||
import React, { useEffect, useState } from 'react'; | ||
import { useHistory, useParams } from 'react-router'; | ||
import BackButton from '../components/BackButton'; | ||
import Loading from '../components/Loading'; | ||
import OrderData from '../components/Orders/OrderPage/OrderData'; | ||
import { Order } from '../types/database'; | ||
|
||
const { ipcRenderer } = require('electron'); | ||
|
||
type ParamType = { | ||
id: string | undefined; | ||
}; | ||
|
||
export default function OrderOnePage() { | ||
const { id } = useParams<ParamType>(); | ||
const [data, setData] = useState<Order>(); | ||
const history = useHistory(); | ||
const { enqueueSnackbar } = useSnackbar(); | ||
|
||
useEffect(() => { | ||
ipcRenderer.send('db-order-find-one', id); | ||
ipcRenderer.once( | ||
'db-result-order-find-one', | ||
(_: never, response: Order | false) => { | ||
if (!response) { | ||
enqueueSnackbar('Encomenda não encontrada', { variant: 'error' }); | ||
history.goBack(); | ||
return; | ||
} | ||
setData(response); | ||
} | ||
); | ||
}, [enqueueSnackbar, history, id]); | ||
|
||
if (!data) return <Loading />; | ||
|
||
return ( | ||
<div> | ||
<BackButton /> | ||
<OrderData order={data} /> | ||
</div> | ||
); | ||
} |
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