Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#165053196 admin is able to view department details. #244

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions src/_mock/departments.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,29 @@ export default {
export const departmentDetailWithAssignedAsset = {
name: 'Technology',
id: 2,
assets_assigned: [
{
uuid: 'cde76cd9-3161-43a5-b0be-c20d44d5ba49',
asset_category: 'Electronics',
serial_number: 'SERIAL-NUMBERS',
asset_code: 'TAGTAGTAG',
asset_type: 'Monitors'
}
]
assets_assigned: {
count: 0,
next: null,
previous: null,
results: [
{
uuid: 'cde76cd9-3161-43a5-b0be-c20d44d5ba49',
asset_category: 'Electronics',
serial_number: 'SERIAL-NUMBERS',
asset_code: 'TAGTAGTAG',
asset_type: 'Monitors'
}
]
}
};

export const departmentDetailWithoutAssignedAsset = {
name: 'Travel',
id: 3,
assets_assigned: []
assets_assigned: {
count: 0,
next: null,
previous: null,
results: []
}
};
10 changes: 6 additions & 4 deletions src/components/Departments/DepartmentDetailComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export class DepartmentDetailComponent extends React.Component {
}

getAssignedAssets = assets =>
this.props.getAssetsSuccess({ results: assets.assets_assigned, count: assets.assets_assigned.length }, '');
this.props.getAssetsSuccess({ results: assets.assets_assigned.results, count: assets.assets_assigned.count }, '');


assetsAssigned = (assets) => {
if (isEmpty(assets.assets_assigned)) {
if (isEmpty(assets.assets_assigned.results)) {
return (
<Card>
<Card.Content extra>
Expand All @@ -38,6 +38,8 @@ export class DepartmentDetailComponent extends React.Component {

render() {
const { isLoading, details } = this.props;
// eslint-disable-next-line camelcase
const { name, assets_assigned } = details;
if (isLoading) {
return (
<LoaderComponent />
Expand Down Expand Up @@ -67,10 +69,10 @@ export class DepartmentDetailComponent extends React.Component {
<Grid columns={3} relaxed="very" stackable>
<Grid.Column>
<Header>
Department Name: {details.name || 'Not Provided'}
Department Name: {name || 'Not Provided'}
</Header>
<Header>
Total Assets Assigned: {details.assets_assigned.length}
Total Assets Assigned: {assets_assigned.count}
</Header>
{this.assetsAssigned(details)}
</Grid.Column>
Expand Down