diff --git a/backend/src/models/units.ts b/backend/src/models/units.ts index 157f3ed..a801901 100644 --- a/backend/src/models/units.ts +++ b/backend/src/models/units.ts @@ -22,6 +22,7 @@ const unitSchema = new Schema( numBeds: { type: Number, required: true }, numBaths: { type: Number, required: true }, appliances: { type: [String], required: true }, + utilities: { type: [String], required: true }, communityFeatures: { type: [String], required: true }, parking: { type: [String], required: true }, accessibility: { type: [String], required: true }, diff --git a/backend/src/validators/units.ts b/backend/src/validators/units.ts index 7856049..c356e60 100644 --- a/backend/src/validators/units.ts +++ b/backend/src/validators/units.ts @@ -90,6 +90,7 @@ const createUnitSchema = [ body("numBeds").exists().withMessage("is required").isNumeric().withMessage("must be a number"), body("numBaths").exists().withMessage("is required").isNumeric().withMessage("must be a number"), body("appliances").exists().withMessage("is required").isArray().withMessage("must be an array"), + body("utilities").exists().withMessage("is required").isArray().withMessage("must be an array"), body("communityFeatures") .exists() .withMessage("is required") diff --git a/frontend/src/api/units.ts b/frontend/src/api/units.ts index 03d16fe..1e6639f 100644 --- a/frontend/src/api/units.ts +++ b/frontend/src/api/units.ts @@ -27,6 +27,7 @@ export type Unit = { numBeds: number; numBaths: number; appliances: string[]; + utilities: string[]; communityFeatures: string[]; parking: string[]; accessibility: string[]; diff --git a/frontend/src/components/ListingForm/Utilities.tsx b/frontend/src/components/ListingForm/Utilities.tsx new file mode 100644 index 0000000..9a358a6 --- /dev/null +++ b/frontend/src/components/ListingForm/Utilities.tsx @@ -0,0 +1,84 @@ +import { + CustomCheckboxRadio, + FieldHeader, + Margin32, + OptionLabel, + RadioCheckBoxContainer, + RadioCheckboxCol, + Required, +} from "@/components/ListingForm/CommonStyles"; + +type UtilitiesProps = { + utilities: string[]; + setUtilities: React.Dispatch>; + handleCheckBoxNA: ( + option: string, + getter: string[], + setter: React.Dispatch>, + ) => void; +}; + +export const Utilities = (props: UtilitiesProps) => { + return ( + + + Utilities Included * + + + + + { + props.handleCheckBoxNA("Electricity", props.utilities, props.setUtilities); + }} + /> + Electricity + + + + { + props.handleCheckBoxNA("Water", props.utilities, props.setUtilities); + }} + /> + Water + + + + { + props.handleCheckBoxNA("Gas", props.utilities, props.setUtilities); + }} + /> + Gas + + + + { + props.handleCheckBoxNA("Trash", props.utilities, props.setUtilities); + }} + /> + Trash + + + + + ); +}; diff --git a/frontend/src/components/ListingFormComponents.tsx b/frontend/src/components/ListingFormComponents.tsx index bc67628..2bcf1f3 100644 --- a/frontend/src/components/ListingFormComponents.tsx +++ b/frontend/src/components/ListingFormComponents.tsx @@ -32,6 +32,7 @@ import { Pets } from "@/components/ListingForm/Pets"; import { SharingHousing } from "@/components/ListingForm/SharingHousing"; import { Textbox } from "@/components/ListingForm/Textbox"; import { ThirdPartyPayment } from "@/components/ListingForm/ThirdPartyPayment"; +import { Utilities } from "@/components/ListingForm/Utilities"; const ErrorMessage = styled.div` color: #b64201; @@ -89,6 +90,7 @@ export function ListingFormComponents(props: ListingFormComponentsProps) { ); const [numberOfBathsOther, setNumberOfBathsOther] = useState(); const [appliances, setAppliances] = useState(props.initialValues?.appliances ?? []); + const [utilities, setUtilities] = useState(props.initialValues?.utilities ?? []); const [communityAndNeighborInfo, setCommunityAndNeighborInfo] = useState( props.initialValues?.communityFeatures ?? [], ); @@ -296,6 +298,7 @@ export function ListingFormComponents(props: ListingFormComponentsProps) { numBeds: numberOfBedrooms ?? parseInt(numberOfBedroomsOther ?? ""), numBaths: numberOfBaths ?? parseFloat(numberOfBathsOther ?? ""), appliances, + utilities, communityFeatures: communityAndNeighborInfo[0] === "" ? [communityAndNeighborInfoOther] @@ -480,6 +483,11 @@ export function ListingFormComponents(props: ListingFormComponentsProps) { setAppliances={setAppliances} handleCheckBoxNA={handleCheckBoxNA} /> + { - const { allHousingLocators, allReferringStaff } = useContext(DataContext); + const { currentUser, allReferringStaff } = useContext(DataContext); const [referrals, setReferrals] = useState([]); const [popup, setPopup] = useState(false); @@ -148,6 +148,27 @@ export const ReferralTable = (props: ReferralTableProps) => { }); }; + const HLSection = (referral: Referral) => { + if (currentUser?.isHousingLocator) { + return ( + { + handleUpdate(referral, value as User, ReferralUpdateType.ReferringStaff); + }} + initialSelection={referral.assignedHousingLocator} + options={allReferringStaff} + /> + ); + } + return ( + <> + {referral.assignedHousingLocator.firstName + " " + referral.assignedHousingLocator.lastName} + + ); + }; + return ( @@ -173,13 +194,7 @@ export const ReferralTable = (props: ReferralTableProps) => { { - const { - status, - renterCandidate, - assignedReferringStaff, - assignedHousingLocator, - updatedAt, - } = referral; + const { status, renterCandidate, assignedReferringStaff, updatedAt } = referral; // Generate a list of cells for each row return [ { initialSelection={assignedReferringStaff} options={allReferringStaff} />, - { - handleUpdate(referral, value as User, ReferralUpdateType.HousingLocator); - }} - initialSelection={assignedHousingLocator} - options={allHousingLocators} - />, + HLSection(referral), { diff --git a/frontend/src/pages/UnitDetails.tsx b/frontend/src/pages/UnitDetails.tsx index 48179b3..98df2f5 100644 --- a/frontend/src/pages/UnitDetails.tsx +++ b/frontend/src/pages/UnitDetails.tsx @@ -513,6 +513,9 @@ export function UnitDetails() { const appliances = unit.appliances.map((appliance, i) => ( {appliance} )); + const utilities = unit.utilities.map((utility, i) => ( + {utility} + )); const parkingRequirements = unit.parking.map((parking, i) => ( {parking} )); @@ -731,6 +734,8 @@ export function UnitDetails() { {pets} Appliances: {appliances} + Utilities: + {utilities} Housing Authority: {unit.housingAuthority} Additional Comments from Landlord: