diff --git a/frontend/src/components/PolicyModal.jsx b/frontend/src/components/PolicyModal.jsx index ec8c37d..16ba311 100644 --- a/frontend/src/components/PolicyModal.jsx +++ b/frontend/src/components/PolicyModal.jsx @@ -16,7 +16,7 @@ export default function PolicyModal({ setPolicyModal }) { } return <> - setPolicyModal(false)}> + setPolicyModal(false)}>

Portland Indigenous Marketplace Vendor Policy Handbook

Updated Aug 2024

diff --git a/frontend/src/components/violationmodal.jsx b/frontend/src/components/violationmodal.jsx index 7558c0c..ba529de 100644 --- a/frontend/src/components/violationmodal.jsx +++ b/frontend/src/components/violationmodal.jsx @@ -1,82 +1,25 @@ -import React, {useState} from 'react'; +import React, { useState } from 'react'; import PropTypes from 'prop-types'; -function ViolationModal({closeModal, vendorId, vendorName, handleSubmit}) { // added vendor object so we can send message to vendor - const [activeButtons, setButtons] = useState([]); - const [violationData, setViolationData] = useState({type: '', description: '', vendor_id: vendorId}); +import Modal from './Modal'; +import Violation from '../objects/Violation'; +export default function ViolationModal({ closeModal, vendorId, vendorName, handleSubmit }) { // added vendor object so we can send message to vendor + const [violationData, setViolationData] = useState(new Violation(-1, -1, '', vendorId)); - // ask if theres a way to disable the header button when the modal opens - - // const handleSubmit = () => { - // console.log(`Posting message(${message}) to ${vendor.name}`); - // console.log('... As long as someone finishes my code'); - // if (activeButtons.length == 0) { - // alert('Must select a violated policy to submit!'); - // return; - // } - // setViolations(); - // closeModal(false); - // }; - - const handleButtonClick = (content) => { - // idea: - // search through active button list - // if button already present, set the buttons to be all those except that button - // otherwise, add button to list - if (activeButtons.includes(content)) { // to remove button that was added - setButtons(activeButtons.filter((value) => value !== content)); - return; - } else if (activeButtons.length == 1) { // only add one button at a time - return; - } - setButtons([...activeButtons, content]); // add button - setViolationData({...violationData, type: content}); - }; // changed the code a little bit, easier to use react state and functions than form - return ( -
handleSubmit(violationData)}> -

Add Violations To: {vendorName}

- -

Select Violated Policies

-
- handleButtonClick(1)} content={1} activebuttons={activeButtons}/> - handleButtonClick(2)} content={2} activebuttons={activeButtons}/> - handleButtonClick(3)} content={3} activebuttons={activeButtons}/> - handleButtonClick(4)} content={4} activebuttons={activeButtons}/> - handleButtonClick(5)} content={5} activebuttons={activeButtons}/> - handleButtonClick(6)} content={6} activebuttons={activeButtons}/> - handleButtonClick(7)} content={7} activebuttons={activeButtons}/> - handleButtonClick(8)} content={8} activebuttons={activeButtons}/> - handleButtonClick(9)} content={9} activebuttons={activeButtons}/> - handleButtonClick(10)} content={10} activebuttons={activeButtons}/> - handleButtonClick(11)} content={11} activebuttons={activeButtons}/> -
+ return closeModal(false)} backgroundColor={`bg-greywhite w-4/5 h-[65vh] overflow-x-clip`}> + handleSubmit(violationData)}> +

{vendorName}

+

Fill out the form once for each violation - do not try to submit multiple violations in one form.

+

Policy Number

+ setViolationData({...violationData, type: e.target.value})}/> +

Violation Description

+
- +
- ); -} - -function PolicyButton({activebuttons, content, onClick}) { - return ( - // used Harley's VendorButtons as inspo - ); -} - -export default ViolationModal; - -ViolationModal.propTypes = { - closeModal: PropTypes.func.isRequired, - vendorId: PropTypes.number.isRequired, - vendorName: PropTypes.string.isRequired, - handleSubmit: PropTypes.func.isRequired, -}; - -PolicyButton.propTypes = { - content: PropTypes.number.isRequired, - onClick: PropTypes.func.isRequired, - activebuttons: PropTypes.array.isRequired, -}; +
+} \ No newline at end of file diff --git a/frontend/src/objects/Violation.js b/frontend/src/objects/Violation.js index 1441b77..16c35f3 100644 --- a/frontend/src/objects/Violation.js +++ b/frontend/src/objects/Violation.js @@ -1,9 +1,9 @@ export default class Violation { - constructor(id, type, description, vendorId) { + constructor(id, type, description, vendor_id) { this.id = id; this.type = type; this.description = description; - this.vendorId = vendorId; + this.vendor_id = vendor_id; } get json() { diff --git a/frontend/src/routes/profile.jsx b/frontend/src/routes/profile.jsx index b67d609..b22ca1c 100644 --- a/frontend/src/routes/profile.jsx +++ b/frontend/src/routes/profile.jsx @@ -129,6 +129,12 @@ export default function Profile({ vendorService, violationService }) { { showUploadModal ? : <> } + { + openViolation && + } + { + policyModal && () + }
@@ -204,15 +210,6 @@ export default function Profile({ vendorService, violationService }) {

Policy Handbook

} - <> - {openViolation && ( - - )} -
- - { - policyModal && () - }