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

ZEVA-427: Automatically hide the Eligible Columns until Validated (for BCEID) #529

Merged
merged 1 commit into from
Jan 26, 2021
Merged
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
5 changes: 5 additions & 0 deletions backend/api/serializers/sales_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,11 @@ def get_sales_submission_comment(self, obj):
return None

def get_eligible(self, instance):
request = self.context.get('request')

if not request.user.is_government and \
instance.validation_status != SalesSubmissionStatuses.VALIDATED:
return None
eligible = RecordOfSale.objects.filter(
submission_id=instance.id
).values('vehicle_id').annotate(
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/credits/components/ModelListTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import React from 'react';
import _ from 'lodash';

import ReactTable from '../../app/components/ReactTable';
import CustomPropTypes from '../../app/utilities/props';

const ModelListTable = (props) => {
const { submission } = props;
const { submission, user } = props;

const columns = [{
accessor: 'sales',
Expand All @@ -35,6 +36,7 @@ const ModelListTable = (props) => {
className: 'text-right',
Header: 'Eligible Sales',
id: 'eligible-sales',
show: (user.isGovernment || submission.validationStatus === 'VALIDATED'),
width: 150,
}, {
accessor: (item) => {
Expand All @@ -61,6 +63,7 @@ const ModelListTable = (props) => {
className: 'text-right',
Header: 'Eligible ZEV Credits',
id: 'eligible-zev-credits',
show: (user.isGovernment || submission.validationStatus === 'VALIDATED'),
width: 200,
}, {
accessor: (item) => (`${item.xlsModelYear} ${item.xlsMake} ${item.xlsModel}`),
Expand Down Expand Up @@ -133,7 +136,9 @@ ModelListTable.propTypes = {
submission: PropTypes.shape({
content: PropTypes.arrayOf(PropTypes.shape()),
eligible: PropTypes.arrayOf(PropTypes.shape()),
validationStatus: PropTypes.string,
}).isRequired,
user: CustomPropTypes.user.isRequired,
};

export default ModelListTable;