Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 2x 2x 2x 2x 2x 2x 11x 16x 16x 10x 6x | import CenteredSpinner from "components/CenteredSpinner/CenteredSpinner";
import useCurrentUser from "features/userQueries/useCurrentUser";
import React from "react";
import {
ParkingDetails,
SleepingArrangement,
SmokingLocation,
User,
} from "../../../proto/api_pb";
import { HostingPreferenceData } from "../../../service/user";
import { DEFAULT_ABOUT_HOME_HEADINGS } from "./constants";
import EditHostingPreferenceForm from "./EditHostingPreferenceForm";
export default function EditHostingPreference() {
const { data: user } = useCurrentUser();
if (user) {
const userToFormValues = (user: User.AsObject): HostingPreferenceData => ({
lastMinute: !!user.lastMinute?.value,
wheelchairAccessible: !!user.wheelchairAccessible?.value,
campingOk: !!user.campingOk?.value,
acceptsKids: !!user.acceptsKids?.value,
acceptsPets: !!user.acceptsPets?.value,
drinkingAllowed: !!user.drinkingAllowed?.value,
maxGuests: user.maxGuests?.value ?? 1,
smokingAllowed:
user.smokingAllowed || SmokingLocation.SMOKING_LOCATION_UNKNOWN,
aboutPlace: user.aboutPlace || DEFAULT_ABOUT_HOME_HEADINGS,
sleepingArrangement:
user.sleepingArrangement ||
SleepingArrangement.SLEEPING_ARRANGEMENT_UNKNOWN,
hasHousemates: !!user.hasHousemates?.value,
housemateDetails: user.housemateDetails?.value ?? "",
hasKids: !!user.hasKids?.value,
kidDetails: user.kidDetails?.value ?? "",
hasPets: !!user.hasPets?.value,
petDetails: user.petDetails?.value ?? "",
parking: !!user.parking?.value,
parkingDetails:
user.parkingDetails || ParkingDetails.PARKING_DETAILS_UNKNOWN,
drinksAtHome: !!user.drinksAtHome?.value,
smokesAtHome: !!user.smokesAtHome?.value,
area: user.area?.value ?? "",
sleepingDetails: user.sleepingDetails?.value ?? "",
houseRules: user.houseRules?.value ?? "",
otherHostInfo: user.otherHostInfo?.value ?? "",
});
return <EditHostingPreferenceForm user={userToFormValues(user)} />;
}
return <CenteredSpinner />;
}
|