Skip to content

Commit

Permalink
admin is able to view department details [Finishes #165053196]
Browse files Browse the repository at this point in the history
  • Loading branch information
gbols committed Jun 26, 2019
1 parent 366a69b commit bbd4a9f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
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

0 comments on commit bbd4a9f

Please sign in to comment.