Skip to content

Commit

Permalink
Merge pull request #29 from bancodobrasil/feat/back_Icon
Browse files Browse the repository at this point in the history
Feat/back button
  • Loading branch information
eliasfeijo authored Sep 11, 2023
2 parents 57d8b13 + 80db076 commit 455b41b
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 23 deletions.
19 changes: 19 additions & 0 deletions src/components/PageTitle/PageTitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Box, IconButton, Typography } from '@mui/material';
import React from 'react';
import ArrowBackIcon from '@mui/icons-material/ArrowBack';

const PageTitle = ({ onClick, PageTitle }) => (
<Box
className="flex flex-row space-x-1 items-center"
sx={{ minWidth: '10rem', height: '1.5rem', marginTop: '2.1rem', marginBottom: '1.4rem' }}
>
<IconButton onClick={onClick} size="small">
<ArrowBackIcon fontSize="small" color="primary" />
</IconButton>
<Typography variant="h3" component="h1" sx={{ py: '1rem' }}>
{PageTitle}
</Typography>
</Box>
);

export default PageTitle;
3 changes: 3 additions & 0 deletions src/components/PageTitle/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import PageTitle from './PageTitle';

export default PageTitle;
6 changes: 2 additions & 4 deletions src/pages/Menu/Create/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
openDefaultErrorNotification,
} from '../../../contexts/NotificationContext';
import { FormAction } from '../../../types';
import PageTitle from '../../../components/PageTitle';

export const CreateMenu = () => {
const { t } = useTranslation();
Expand Down Expand Up @@ -73,10 +74,7 @@ export const CreateMenu = () => {
]}
onBack={onBackClickHandler}
/>
<Typography variant="h1" component="h1" sx={{ py: '1rem' }}>
{t('menu.create.title')}
</Typography>
<Divider />
<PageTitle onClick={onBackClickHandler} PageTitle={t('menu.create.title')} />
</Box>
<FormBasicInfo
name={name}
Expand Down
10 changes: 3 additions & 7 deletions src/pages/Menu/Edit/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { EnumInputAction, FormAction, IMenuMetaWithErrors } from '../../../types
import { FormAttributes } from '../../../components/Menu/Forms/Attributes/FormAttributes';
import { ItemsPreview } from '../Items';
import { EditTemplateMenu } from '../EditTemplate';
import PageTitle from '../../../components/PageTitle';

export const TAB_BASIC_INFO = '1';
export const TAB_ITEMS = '2';
Expand Down Expand Up @@ -204,13 +205,8 @@ export const EditMenu = () => {
]}
onBack={onBackClickHandler}
/>
<Box className="flex flex-row space-x-1 items-center my-4">
<IconButton onClick={onBackClickHandler} size="small">
<ArrowBackIcon fontSize="small" color="primary" />
</IconButton>
<Typography variant="h3" component="h1">
{t('menu.edit.title')}
</Typography>
<Box className="flex flex-row space-x-1 items-center">
<PageTitle onClick={onBackClickHandler} PageTitle={t('menu.edit.title')} />
<Box
className="space-x-4"
sx={{
Expand Down
8 changes: 5 additions & 3 deletions src/pages/Menu/Revisions/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from '../../../contexts/NotificationContext';
import { MenuRevisionsDiff } from '../../../components/Menu/Revisions';
import { menuRevisionDiff } from '../../../utils/diff/menuRevisionDiff';
import PageTitle from '../../../components/PageTitle';

const CreateRevision = () => {
const { t } = useTranslation();
Expand All @@ -28,6 +29,9 @@ const CreateRevision = () => {
navigate('/');
};

const onBackButtonHandler = () => {
navigate('../edit');
};
const { dispatch } = React.useContext(NotificationContext);

const [description, setDescription] = React.useState('');
Expand Down Expand Up @@ -224,9 +228,7 @@ const CreateRevision = () => {
]}
onBack={onBackClickHandler}
/>
<Typography variant="h1" component="h1" sx={{ my: '1rem' }}>
{t('menuRevision.create.title')}
</Typography>
<PageTitle onClick={onBackButtonHandler} PageTitle={t('menuRevision.create.title')} />
<Typography variant="h2" component="h2" sx={{ my: '0.5rem' }}>
{t('menuRevision.create.reviewChanges.title')}
</Typography>
Expand Down
11 changes: 8 additions & 3 deletions src/pages/Menu/Revisions/Publish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
openDefaultErrorNotification,
} from '../../../contexts/NotificationContext';
import { menuRevisionDiff } from '../../../utils/diff/menuRevisionDiff';
import PageTitle from '../../../components/PageTitle';

const PublishRevision = () => {
const { t } = useTranslation();
Expand All @@ -37,6 +38,10 @@ const PublishRevision = () => {
navigate('/');
};

const onBackButtonHandler = () => {
navigate('../edit');
};

const { dispatch } = React.useContext(NotificationContext);

const [selectedRevision, setSelectedRevision] = React.useState(null);
Expand Down Expand Up @@ -264,9 +269,9 @@ const PublishRevision = () => {
]}
onBack={onBackClickHandler}
/>
<Typography variant="h1" component="h1" sx={{ py: '1rem' }}>
{t('menuRevision.publish.title')}
</Typography>
<Box>
<PageTitle onClick={onBackButtonHandler} PageTitle={t('menuRevision.publish.title')} />
</Box>
<FormControl sx={{ width: '16rem', mb: '1rem' }} className="bg-white">
<InputLabel id="selectedRevision-label">
{t('menu.of', { field: 'revision.title_one' })}
Expand Down
9 changes: 6 additions & 3 deletions src/pages/Menu/Revisions/Restore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
openDefaultErrorNotification,
} from '../../../contexts/NotificationContext';
import { menuRevisionDiff } from '../../../utils/diff/menuRevisionDiff';
import PageTitle from '../../../components/PageTitle';

const RestoreRevision = () => {
const { t } = useTranslation();
Expand All @@ -37,6 +38,10 @@ const RestoreRevision = () => {
navigate('/');
};

const onBackButtonHandler = () => {
navigate('../edit');
};

const { dispatch } = React.useContext(NotificationContext);

const [selectedRevision, setSelectedRevision] = React.useState(null);
Expand Down Expand Up @@ -250,9 +255,7 @@ const RestoreRevision = () => {
]}
onBack={onBackClickHandler}
/>
<Typography variant="h1" component="h1" sx={{ py: '1rem' }}>
{t('menuRevision.restore.title')}
</Typography>
<PageTitle onClick={onBackButtonHandler} PageTitle={t('menuRevision.restore.title')} />
<FormControl sx={{ width: '16rem', mb: '1rem' }} className="bg-white">
<InputLabel id="selectedRevision-label">
{t('menu.of', { field: 'revision.title_one' })}
Expand Down
14 changes: 11 additions & 3 deletions src/pages/Menu/Show/Show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
openDefaultErrorNotification,
} from '../../../contexts/NotificationContext';
import { JAMIE_FEATURE_CONDITIONS } from '../../../constants';
import PageTitle from '../../../components/PageTitle';

export const ShowMenu = () => {
const { t, i18n } = useTranslation();
Expand All @@ -27,6 +28,10 @@ export const ShowMenu = () => {
navigate('/');
};

const onBackButtonHandler = () => {
navigate('../edit');
};

const { dispatch } = React.useContext(NotificationContext);

const { loading, error, data, refetch } = useQuery(MenuService.GET_MENU, {
Expand Down Expand Up @@ -172,9 +177,12 @@ export const ShowMenu = () => {
]}
onBack={onBackClickHandler}
/>
<Typography variant="h1" component="h1" sx={{ py: '1rem' }}>
{data?.menu.name}
</Typography>
<Box className="flex flex-row space-x-1 items-center my-4">
<PageTitle onClick={onBackButtonHandler} PageTitle={data?.menu.name} />
<Typography variant="h1" component="h1" sx={{ py: '1rem' }}>
{data?.menu.name}
</Typography>
</Box>
<Box sx={{ mb: '1rem' }} className="space-y-4">
<Box className="space-y-1">
<Typography variant="h5" component="h5" className="mb-2">
Expand Down

0 comments on commit 455b41b

Please sign in to comment.