Skip to content

Commit c477ad0

Browse files
authored
Merge pull request #40 from Lemoncode/feature/add-new-scenes-for-edit-user
Refactor user editing functionality
2 parents 954d467 + ef993cf commit c477ad0

File tree

13 files changed

+39
-47
lines changed

13 files changed

+39
-47
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from 'react';
2+
3+
export const EditResetPassword: React.FC = () => {
4+
return <h3>Reset Password</h3>;
5+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './edit-reset-password.pod';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
3+
interface Props {
4+
id: string;
5+
}
6+
7+
export const EditUserSheet: React.FC<Props> = props => {
8+
const { id } = props;
9+
return <h3>User id: {id}</h3>;
10+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './edit-user-sheet.pod';

src/modules/users/edit/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/modules/users/edit/user-edit.pod.tsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/modules/users/edit/user-edit.styles.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/scenes/_auth/edit-user/$id.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createFileRoute } from '@tanstack/react-router';
2-
import { UserEditPod } from '#modules/users/edit';
2+
import { UserScene } from './edit-user.scene';
33

44
export const Route = createFileRoute('/_auth/edit-user/$id')({
5-
component: UserEditPod,
5+
component: UserScene,
66
});

src/modules/users/edit/components/tab-panel.component.tsx renamed to src/scenes/_auth/edit-user/components/tab-panel.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import { useWithTheme } from '#core/theme/theme.hooks.ts';
3-
import * as innerClasses from './tabs.styles';
3+
import * as innerClasses from './tab-panel.styles';
44

55
interface TabPanelProps {
66
index: number;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { css } from '@emotion/css';
2+
import { Theme } from '@mui/material';
3+
4+
export const tabPanel = (theme: Theme) => css`
5+
padding-block: ${theme.spacing(2)};
6+
`;

src/modules/users/edit/components/tabs.component.tsx renamed to src/scenes/_auth/edit-user/edit-user.scene.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
import * as React from 'react';
2-
import { TabPanel } from './tab-panel.component';
1+
import React from 'react';
2+
import { useParams } from '@tanstack/react-router';
33
import { Tabs as MUITabs, Tab, Paper } from '@mui/material/';
4-
5-
import * as innerClasses from './tabs.styles';
4+
import { EditUserSheet } from '#modules/users/edit-user-sheet/edit-user-sheet.pod.tsx';
5+
import { EditResetPassword } from '#modules/users/edit-reset-password/edit-reset-password.pod.tsx';
6+
import { TabPanel } from './components/tab-panel.component';
7+
import * as innerClasses from './edit-user.styles';
68

79
enum TabIndex {
810
USER_SHEET,
911
RESET_PASSWORD,
1012
}
1113

12-
interface Props {
13-
id: string;
14-
}
15-
16-
export const Tabs: React.FC<Props> = ({ id }) => {
14+
export const UserScene: React.FC = () => {
15+
const { id } = useParams({ from: '/_auth/edit-user/$id' });
1716
const [activeTab, setActiveTab] = React.useState<number>(0);
1817

1918
const handleChange = (_event: React.SyntheticEvent, newValue: number) => setActiveTab(newValue);
@@ -28,10 +27,10 @@ export const Tabs: React.FC<Props> = ({ id }) => {
2827
</MUITabs>
2928
</div>
3029
<TabPanel value={activeTab} index={TabIndex.USER_SHEET}>
31-
<h3>User id: {id}</h3>
30+
<EditUserSheet id={id} />
3231
</TabPanel>
3332
<TabPanel value={activeTab} index={TabIndex.RESET_PASSWORD}>
34-
<h3>Reset Password</h3>
33+
<EditResetPassword />
3534
</TabPanel>
3635
</Paper>
3736
</div>
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
import { css } from '@emotion/css';
2-
import { Theme } from '@mui/material';
32

43
export const tabsComponent = css`
54
display: 'flex';
6-
flexdirection: 'column';
7-
alignitems: 'center';
5+
flex-direction: 'column';
6+
align-items: 'center';
87
width: 100%;
98
`;
109

1110
export const tabsContainer = css`
1211
border-bottom: 1;
1312
border-color: 'divider';
1413
`;
15-
16-
export const tabPanel = (theme: Theme) => css`
17-
padding-block: ${theme.spacing(2)};
18-
`;

vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default defineConfig(({ mode }) => {
1212
routesDirectory: 'src/scenes',
1313
generatedRouteTree: 'src/core/router/route-tree.ts',
1414
autoCodeSplitting: true,
15+
routeFileIgnorePattern: '.((scene|component|styles).(ts|tsx))',
1516
}),
1617
react(),
1718
],

0 commit comments

Comments
 (0)