feat: add Object Edit page (#1968)

Closes #1907
This commit is contained in:
Thaïs 2023-10-11 15:34:10 +02:00 committed by GitHub
parent 7731525317
commit a342af74d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 80 additions and 0 deletions

View File

@ -19,6 +19,7 @@ import { People } from '~/pages/people/People';
import { PersonShow } from '~/pages/people/PersonShow';
import { SettingsExperience } from '~/pages/settings/SettingsExperience';
import { SettingsObjectDetail } from '~/pages/settings/SettingsObjectDetail';
import { SettingsObjectEdit } from '~/pages/settings/SettingsObjectEdit';
import { SettingsObjects } from '~/pages/settings/SettingsObjects';
import { SettingsProfile } from '~/pages/settings/SettingsProfile';
import { SettingsWorkspace } from '~/pages/settings/SettingsWorkspace';
@ -80,6 +81,10 @@ export const App = () => {
path={SettingsPath.ObjectDetail}
element={<SettingsObjectDetail />}
/>
<Route
path={SettingsPath.ObjectEdit}
element={<SettingsObjectEdit />}
/>
</Routes>
}
/>

View File

@ -3,6 +3,7 @@ export enum SettingsPath {
Experience = 'profile/experience',
Objects = 'objects',
ObjectDetail = 'objects/:pluralObjectName',
ObjectEdit = 'objects/:pluralObjectName/edit',
WorkspaceMembersPage = 'workspace-members',
Workspace = 'workspace',
}

View File

@ -0,0 +1,45 @@
import { useEffect } from 'react';
import { useNavigate, useParams } from 'react-router-dom';
import styled from '@emotion/styled';
import { AppPath } from '@/types/AppPath';
import { Breadcrumb } from '@/ui/breadcrumb/components/Breadcrumb';
import { IconSettings } from '@/ui/icon';
import { SubMenuTopBarContainer } from '@/ui/layout/components/SubMenuTopBarContainer';
import { activeObjectItems } from './constants/mockObjects';
import { objectSettingsWidth } from './constants/objectSettings';
const StyledContainer = styled.div`
padding: ${({ theme }) => theme.spacing(8)};
width: ${objectSettingsWidth};
`;
export const SettingsObjectEdit = () => {
const navigate = useNavigate();
const { pluralObjectName = '' } = useParams();
const activeObject = activeObjectItems.find(
(activeObject) => activeObject.name.toLowerCase() === pluralObjectName,
);
useEffect(() => {
if (!activeObject) navigate(AppPath.NotFound);
}, [activeObject, navigate]);
return (
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
<StyledContainer>
<Breadcrumb
links={[
{ children: 'Objects', href: '/settings/objects' },
{
children: activeObject?.name ?? '',
href: `/settings/objects/${pluralObjectName}`,
},
{ children: 'Edit' },
]}
/>
</StyledContainer>
</SubMenuTopBarContainer>
);
};

View File

@ -0,0 +1,29 @@
import { Meta, StoryObj } from '@storybook/react';
import {
PageDecorator,
PageDecoratorArgs,
} from '~/testing/decorators/PageDecorator';
import { graphqlMocks } from '~/testing/graphqlMocks';
import { SettingsObjectEdit } from '../SettingsObjectEdit';
const meta: Meta<PageDecoratorArgs> = {
title: 'Pages/Settings/SettingsObjectEdit',
component: SettingsObjectEdit,
decorators: [PageDecorator],
args: {
routePath: '/settings/objects/:pluralObjectName/edit',
routeParams: { ':pluralObjectName': 'companies' },
},
parameters: {
docs: { story: 'inline', iframeHeight: '500px' },
msw: graphqlMocks,
},
};
export default meta;
export type Story = StoryObj<typeof SettingsObjectEdit>;
export const Default: Story = {};