diff --git a/.github/workflows/blackduck.yml b/.github/workflows/blackduck.yml new file mode 100644 index 0000000..f69b1a3 --- /dev/null +++ b/.github/workflows/blackduck.yml @@ -0,0 +1,40 @@ +name: Blackduck + +on: + schedule: + # run scans twice a month + - cron: "0 2 1,15 * *" + +jobs: + blackduck: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: "16" + cache: "npm" + - run: npm install + - run: npm run build + + # ota-admin-portal + - name: Run Synopsys Detect - ota-admin-portal + uses: synopsys-sig/detect-action@v0.3.2 + env: + DETECT_PROJECT_NAME: ota-admin-portal + DETECT_EXCLUDED_DIRECTORIES: node_modules + DETECT_PROJECT_VERSION_NAME: default + DETECT_NPM_INCLUDE_DEV_DEPENDENCIES: "FALSE" + # DETECT_DETECTOR_SEARCH_EXCLUSION_DEFAULTS: "true" + DETECT_DETECTOR_SEARCH_DEPTH: 0 + DETECT_DETECTOR_SEARCH_CONTINUE: "true" + + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + detect-version: 7.9.0 + blackduck-url: ${{ secrets.BLACKDUCK_URL }} + blackduck-api-token: ${{ secrets.BLACKDUCK_API_KEY }} + scan-mode: INTELLIGENT diff --git a/src/components/Contexts/SupplierDetailsContext.jsx b/src/components/Contexts/SupplierDetailsContext.jsx index a061c24..f3365fe 100644 --- a/src/components/Contexts/SupplierDetailsContext.jsx +++ b/src/components/Contexts/SupplierDetailsContext.jsx @@ -1,5 +1,6 @@ import React, { useContext, useEffect, useState } from "react"; import api from "../../services/suppliersAPI"; +import { LocalDateTimeString } from "../../utils/dates"; import { validateSupplier, @@ -12,26 +13,26 @@ const SupplierDetailsContext = React.createContext(); export const SupplierDetailsProvider = ({ children }) => { const { getSuppliers, suppliers } = useSupplierContext(); const [busy, setBusy] = useState(false); - const [id, setID] = useState(""); const [contact, setContact] = useState(""); const [company, setCompany] = useState(""); const [address, setAddress] = useState(""); const [phone, setPhone] = useState(""); const [program, setProgram] = useState(""); const [ecus, setECUs] = useState(""); + const [activated, setActivated] = useState(null); useEffect(() => { if (!suppliers || suppliers.length === 0) return; const supplier = suppliers[0]; - setID(supplier?.id || ""); setContact(supplier?.contact || ""); setCompany(supplier?.company || ""); setAddress(supplier?.address || ""); setPhone(supplier?.telephone || ""); setProgram(supplier?.program || ""); setECUs(supplier?.ecus.join(",") || ""); + setActivated(LocalDateTimeString(supplier?.activated)); }, [suppliers]); const getSupplier = async (email, token) => { @@ -55,7 +56,6 @@ export const SupplierDetailsProvider = ({ children }) => { }; const formData = (email) => ({ - id, contact, company, address, @@ -65,6 +65,25 @@ export const SupplierDetailsProvider = ({ children }) => { ecus: getECUs(), }); + const activateSupplier = async (email, token) => { + try { + setBusy(true); + validateEmail(email); + + const result = await api.activateSupplier(email, token); + if (result.error) + throw new Error(`Activate supplier error. ${result.message}`); + + setActivated( + LocalDateTimeString(result.activate) || new Date().toDateString() + ); + + return result; + } finally { + setBusy(false); + } + }; + const updateSupplier = async (email, token) => { try { const supplier = formData(email); @@ -80,14 +99,15 @@ export const SupplierDetailsProvider = ({ children }) => { } }; - const deleteSupplier = async (vin, token) => { + const deleteSupplier = async (email, token) => { try { setBusy(true); - validateEmail(vin); + validateEmail(email); - const result = await api.deleteSupplier(vin, token); + const result = await api.deleteSupplier(email, token); if (result.error) throw new Error(`Delete supplier error. ${result.message}`); + return result; } finally { setBusy(false); @@ -97,18 +117,18 @@ export const SupplierDetailsProvider = ({ children }) => { return ( -
- -
- - -
-
@@ -341,6 +295,20 @@ exports[`Supplier page Render 1`] = `
+ + )}