Skip to content

Commit

Permalink
feat: add button salvar ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
ialexanderbrito committed Apr 8, 2022
1 parent 91ff8a5 commit aece97d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/pages/MyTicket/MyTicket.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
}
}

.containerButton {
display: flex;
justify-content: center;
margin-top: 1rem;
margin-bottom: 2rem;
}

@media screen and (min-width: 839px) {
.home {
background: var(--background);
Expand All @@ -36,3 +43,12 @@
}
}
}

@media print {
@page {
margin: 0;
}
body {
margin: 4.6cm;
}
}
24 changes: 22 additions & 2 deletions src/pages/MyTicket/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { SpinnerCircular } from 'spinners-react';

import { Button } from 'components/Button';
import ComponentToPrint from 'components/ComponentToPrint';
import { Header } from 'components/Header';
import { Ticket } from 'components/Ticket';

Expand All @@ -11,7 +13,7 @@ import styles from './MyTicket.module.scss';

export function MyTicket() {
const { theme } = useTheme();
const { loading, cliente } = useTicket();
const { loading, cliente, componentToPrintRef, handleClickPrint } = useTicket();

return (
<>
Expand All @@ -20,7 +22,25 @@ export function MyTicket() {

<div className={styles.container}>
<h2>Apresente esse ticket para o seu barbeiro</h2>
{loading ? <SpinnerCircular color="#ff9000" size={64} /> : <Ticket cliente={cliente} />}
{loading ? (
<SpinnerCircular color="#ff9000" size={64} />
) : (
<>
<ComponentToPrint ref={componentToPrintRef}>
<Ticket cliente={cliente} />
</ComponentToPrint>
</>
)}
<div className={styles.containerButton}>
<Button
type="button"
onClick={() => {
handleClickPrint();
}}
>
Salvar ticket
</Button>
</div>
</div>
</div>
</>
Expand Down

0 comments on commit aece97d

Please sign in to comment.