Skip to content

Commit

Permalink
Cleans up the code in Account react component (PR #632 and #657)
Browse files Browse the repository at this point in the history
  - Refactors Account class and improves tests
  - Updates the package version of react website

---------
Co-authored-by: Jeevika Sirwani <[email protected]>
  • Loading branch information
prasadtalasila authored Apr 5, 2024
1 parent bfe3227 commit eaa22d5
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 31 deletions.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@into-cps-association/dtaas-web",
"version": "0.3.2",
"version": "0.3.3",
"description": "Web client for Digital Twin as a Service (DTaaS)",
"main": "index.tsx",
"author": "prasadtalasila <[email protected]> (http://prasad.talasila.in/)",
Expand Down
27 changes: 19 additions & 8 deletions client/src/route/auth/Account.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import * as React from 'react';
import Layout from 'page/Layout';
import AccountTabs from './AccountTabs';
import { Typography } from '@mui/material';
import TabComponent from 'components/tab/TabComponent';
import { TabData } from 'components/tab/subcomponents/TabRender';
import tabs from './AccountTabData';

const DTContent: React.FC = () => (
<Layout>
<AccountTabs />
</Layout>
);
function AccountContent() {
const AccountTab: TabData[] = tabs.map((tab) => ({
label: tab.label,
body: <Typography variant="body1">{tab.body}</Typography>,
}));

const DigitalTwins: React.FC = () => <DTContent />; /* jshint ignore:line */
export default DigitalTwins;
return (
<Layout>
<TabComponent assetType={AccountTab} scope={[]} />
</Layout>
);
}

export default function Account() {
return <AccountContent />;
}
14 changes: 14 additions & 0 deletions client/src/route/auth/AccountTabData.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ITabs } from 'route/IData';

const tabs: ITabs[] = [
{
label: 'Profile',
body: `Profile - potentially visible to other users.`,
},
{
label: 'Settings',
body: `Account settings - private to a user.`,
},
];

export default tabs;
22 changes: 0 additions & 22 deletions client/src/route/auth/AccountTabs.tsx

This file was deleted.

12 changes: 12 additions & 0 deletions client/test/unitTests/Routes/Account.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as React from 'react';
import Account from 'route/auth/Account';
import tabs from 'route/auth/AccountTabData';
import { InitRouteTests, itDisplaysContentOfTabs } from '../testUtils';

describe('Account Page', () => {
const tabLabels: string[] = [];
tabs.forEach((tab) => tabLabels.push(tab.label));
InitRouteTests(<Account />);

itDisplaysContentOfTabs(tabs);
});

0 comments on commit eaa22d5

Please sign in to comment.