Skip to content

Commit

Permalink
Add URI encoding and code clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerlcleung committed Dec 18, 2024
1 parent cc7f6aa commit b26957c
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 36 deletions.
3 changes: 2 additions & 1 deletion frontend/src/app/routes/Compliance.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ const COMPLIANCE = {
export default COMPLIANCE

export const insertIdAndYear = (route, id, modelYear) => {
return `${route.replace(":id", id)}?year=${modelYear}`;
const encode = (str) => encodeURIComponent(str);
return `${route.replace(":id", encode(id))}?year=${encode(modelYear)}`;
}
3 changes: 1 addition & 2 deletions frontend/src/compliance/AssessmentContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import Big from "big.js";
import Loading from "../app/components/Loading";
import CONFIG from "../app/config";
import history from "../app/History";
import ROUTES_COMPLIANCE from "../app/routes/Compliance";
import { insertIdAndYear } from "../app/routes/Compliance";
import ROUTES_COMPLIANCE, { insertIdAndYear } from "../app/routes/Compliance";
import CustomPropTypes from "../app/utilities/props";
import AssessmentDetailsPage from "./components/AssessmentDetailsPage";
import calculateCreditReductionBig from "../app/utilities/calculateCreditReductionBig";
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/compliance/ComplianceObligationContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import ComplianceReportTabs from "./components/ComplianceReportTabs";
import ComplianceObligationDetailsPage from "./components/ComplianceObligationDetailsPage";
import history from "../app/History";
import ROUTES_SIGNING_AUTHORITY_ASSERTIONS from "../app/routes/SigningAuthorityAssertions";
import ROUTES_COMPLIANCE from "../app/routes/Compliance";
import { insertIdAndYear } from "../app/routes/Compliance";
import ROUTES_COMPLIANCE, { insertIdAndYear } from "../app/routes/Compliance";
import CONFIG from "../app/config";
import calculateCreditReduction from "../app/utilities/calculateCreditReduction";
import getClassAReduction from "../app/utilities/getClassAReduction";
Expand Down
24 changes: 11 additions & 13 deletions frontend/src/compliance/ComplianceReportSummaryContainer.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import axios from 'axios'
import React, { useEffect, useState } from 'react'
import { useParams, useLocation } from 'react-router-dom'
import CONFIG from '../app/config'
import history from '../app/History'
import Loading from '../app/components/Loading'
import ROUTES_COMPLIANCE from '../app/routes/Compliance'
import { insertIdAndYear } from '../app/routes/Compliance'
import CustomPropTypes from '../app/utilities/props'
import ComplianceReportTabs from './components/ComplianceReportTabs'
import ComplianceReportSummaryDetailsPage from './components/ComplianceReportSummaryDetailsPage'
import ROUTES_SIGNING_AUTHORITY_ASSERTIONS from '../app/routes/SigningAuthorityAssertions'
import deleteModelYearReport from '../app/utilities/deleteModelYearReport'
import axios from "axios";
import React, { useEffect, useState } from "react";
import { useParams, useLocation } from "react-router-dom";
import CONFIG from "../app/config";
import history from "../app/History";
import ROUTES_COMPLIANCE, { insertIdAndYear } from "../app/routes/Compliance";
import CustomPropTypes from "../app/utilities/props";
import ComplianceReportTabs from "./components/ComplianceReportTabs";
import ComplianceReportSummaryDetailsPage from "./components/ComplianceReportSummaryDetailsPage";
import ROUTES_SIGNING_AUTHORITY_ASSERTIONS from "../app/routes/SigningAuthorityAssertions";
import deleteModelYearReport from "../app/utilities/deleteModelYearReport";
import qs from "qs";

const ComplianceReportSummaryContainer = (props) => {
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/compliance/ConsumerSalesContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import history from "../app/History";
import CustomPropTypes from "../app/utilities/props";
import ComplianceReportTabs from "./components/ComplianceReportTabs";
import ConsumerSalesDetailsPage from "./components/ConsumerSalesDetailsPage";
import ROUTES_COMPLIANCE from "../app/routes/Compliance";
import { insertIdAndYear } from "../app/routes/Compliance";
import ROUTES_COMPLIANCE, { insertIdAndYear } from "../app/routes/Compliance";
import ROUTES_SIGNING_AUTHORITY_ASSERTIONS from "../app/routes/SigningAuthorityAssertions";
import deleteModelYearReport from "../app/utilities/deleteModelYearReport";
import FORECAST_ROUTES from "../salesforecast/constants/routes";
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/compliance/SupplierInformationContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { useParams } from "react-router-dom";
import { withRouter } from "react-router";
import CONFIG from "../app/config";
import history from "../app/History";
import ROUTES_COMPLIANCE from "../app/routes/Compliance";
import { insertIdAndYear } from "../app/routes/Compliance";
import ROUTES_COMPLIANCE, { insertIdAndYear } from "../app/routes/Compliance";
import ROUTES_VEHICLES from "../app/routes/Vehicles";
import CustomPropTypes from "../app/utilities/props";
import ComplianceReportTabs from "./components/ComplianceReportTabs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import ComplianceReportDeleteModal from "./ComplianceReportDeleteModal";

import Modal from "../../app/components/Modal";
import history from "../../app/History";
import ROUTES_COMPLIANCE from "../../app/routes/Compliance";
import { insertIdAndYear } from "../../app/routes/Compliance";
import ROUTES_COMPLIANCE, { insertIdAndYear } from "../../app/routes/Compliance";

const ComplianceObligationDetailsPage = (props) => {
const {
Expand Down
10 changes: 4 additions & 6 deletions frontend/src/compliance/components/ComplianceReportTabs.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import PropTypes from 'prop-types'
import React from 'react'
import { Link, useParams } from 'react-router-dom'

import ROUTES_COMPLIANCE from '../../app/routes/Compliance'
import { insertIdAndYear } from "../../app/routes/Compliance";
import PropTypes from "prop-types";
import React from "react";
import { Link, useParams } from "react-router-dom";
import ROUTES_COMPLIANCE, { insertIdAndYear } from "../../app/routes/Compliance";

const ComplianceReportTabs = (props) => {
const { active, reportStatuses, user, modelYear } = props
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/compliance/components/ComplianceReportsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import React from "react";
import ReactTable from "../../app/components/ReactTable";
import CustomPropTypes from "../../app/utilities/props";
import history from "../../app/History";
import ROUTES_COMPLIANCE from "../../app/routes/Compliance";
import { insertIdAndYear } from "../../app/routes/Compliance";
import ROUTES_COMPLIANCE, { insertIdAndYear } from "../../app/routes/Compliance";
import ROUTES_SUPPLEMENTARY from "../../app/routes/SupplementaryReport";
import formatNumeric from "../../app/utilities/formatNumeric";
import getClassAReduction from "../../app/utilities/getClassAReduction";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import Modal from "../../app/components/Modal";
import history from "../../app/History";
import ComplianceReportSignOff from "./ComplianceReportSignOff";
import ConsumerSalesLDVModalTable from "./ConsumerSalesLDVModelTable";
import ROUTES_COMPLIANCE from "../../app/routes/Compliance";
import { insertIdAndYear } from "../../app/routes/Compliance";
import ROUTES_COMPLIANCE, { insertIdAndYear } from "../../app/routes/Compliance";
import ComplianceReportDeleteModal from "./ComplianceReportDeleteModal";
import RecordsUpload from "../../salesforecast/components/RecordsUpload";
import RecordsTable from "../../salesforecast/components/RecordsTable";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import Loading from "../../app/components/Loading";
import Modal from "../../app/components/Modal";
import history from "../../app/History";
import CustomPropTypes from "../../app/utilities/props";
import ROUTES_COMPLIANCE from "../../app/routes/Compliance";
import { insertIdAndYear } from "../../app/routes/Compliance";
import ROUTES_COMPLIANCE, { insertIdAndYear } from "../../app/routes/Compliance";
import FormatNumeric from "../../app/utilities/formatNumeric";
import ComplianceReportAlert from "./ComplianceReportAlert";
import ComplianceReportSignOff from "./ComplianceReportSignOff";
Expand Down

0 comments on commit b26957c

Please sign in to comment.