Skip to content

Commit 7dad9c9

Browse files
feat(user): replace edit icon button with tab (#273)
* feat(user): replace edit icon button with tab * fix(pages/user): remove `formWidth` page styling
1 parent 807668f commit 7dad9c9

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
lines changed

components/user/display.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import { Fragment, useMemo } from 'react';
2-
import { IconButton } from '@rmwc/icon-button';
32
import Image from 'next/image';
4-
import Link from 'next/link';
53
import cn from 'classnames';
64
import useTranslation from 'next-translate/useTranslation';
75

86
import Avatar from 'components/avatar';
9-
import EditIcon from 'components/icons/edit';
107
import RequestForm from 'components/user/request-form';
118

129
import { getEmailLink, getPhoneLink, join } from 'lib/utils';
1310
import { User } from 'lib/model/user';
14-
import { useOrg } from 'lib/context/org';
1511
import { useUser } from 'lib/context/user';
1612

1713
import styles from './display.module.scss';
@@ -27,7 +23,6 @@ export default function UserDisplay({
2723
langs,
2824
subjects,
2925
}: UserDisplayProps): JSX.Element {
30-
const { org } = useOrg();
3126
const { orgs } = useUser();
3227
const { t, lang: locale } = useTranslation();
3328

@@ -102,13 +97,6 @@ export default function UserDisplay({
10297
src={user?.photo}
10398
priority
10499
/>
105-
{user && admin && (
106-
<div className={styles.actions}>
107-
<Link href={`/${org?.id || ''}/users/${user?.id || ''}/edit`}>
108-
<IconButton icon={<EditIcon />} label='Edit user' />
109-
</Link>
110-
</div>
111-
)}
112100
</a>
113101
<a
114102
rel='noopener noreferrer'

components/user/edit.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111

1212
.wrapper {
13-
@include common.wrapper(sizes.$form-width-with-margin);
13+
@include common.wrapper();
1414
padding: 48px 24px;
1515

1616
.display {

pages/[org]/users/[id]/edit.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { GetStaticPaths, GetStaticProps, GetStaticPropsContext } from 'next';
44
import { useRouter } from 'next/router';
55
import useSWR from 'swr';
66

7-
import { EmptyHeader } from 'components/navigation';
87
import Page from 'components/page';
8+
import { TabHeader } from 'components/navigation';
99
import UserEdit from 'components/user/edit';
1010

1111
import { Org, OrgJSON } from 'lib/model/org';
@@ -40,12 +40,24 @@ function UserEditPage({
4040

4141
return (
4242
<OrgContext.Provider value={{ org: org ? Org.fromJSON(org) : undefined }}>
43-
<Page
44-
title={`${data?.name || 'Loading'} - Edit - Tutorbook`}
45-
formWidth
46-
{...props}
47-
>
48-
<EmptyHeader formWidth />
43+
<Page title={`${data?.name || 'Loading'} - Edit - Tutorbook`} {...props}>
44+
<TabHeader
45+
tabs={[
46+
{
47+
label: 'About',
48+
href: `/${query.org as string}/users/${query.id as string}`,
49+
},
50+
{
51+
active: true,
52+
label: 'Edit',
53+
href: `/${query.org as string}/users/${query.id as string}/edit`,
54+
},
55+
{
56+
label: 'Hours',
57+
href: `/${query.org as string}/users/${query.id as string}/hours`,
58+
},
59+
]}
60+
/>
4961
<UserEdit user={data ? User.fromJSON(data) : undefined} />
5062
</Page>
5163
</OrgContext.Provider>

pages/[org]/users/[id]/hours.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ function UserHoursPage({
4040

4141
return (
4242
<OrgContext.Provider value={{ org: org ? Org.fromJSON(org) : undefined }}>
43-
<Page
44-
title={`${data?.name || 'Loading'} - Hours - Tutorbook`}
45-
formWidth
46-
{...props}
47-
>
43+
<Page title={`${data?.name || 'Loading'} - Hours - Tutorbook`} {...props}>
4844
<TabHeader
4945
tabs={[
5046
{
5147
label: 'About',
5248
href: `/${query.org as string}/users/${query.id as string}`,
5349
},
50+
{
51+
label: 'Edit',
52+
href: `/${query.org as string}/users/${query.id as string}/edit`,
53+
},
5454
{
5555
active: true,
5656
label: 'Hours',

pages/[org]/users/[id]/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ function UserDisplayPage({
9898
label: 'About',
9999
href: `/${query.org as string}/users/${query.id as string}`,
100100
},
101+
{
102+
label: 'Edit',
103+
href: `/${query.org as string}/users/${query.id as string}/edit`,
104+
},
101105
{
102106
label: 'Hours',
103107
href: `/${query.org as string}/users/${

0 commit comments

Comments
 (0)