add filter for min and max number of bedrooms
This commit is contained in:
parent
69d15e9a16
commit
dadb56aa16
2 changed files with 42 additions and 0 deletions
|
|
@ -38,6 +38,14 @@ function App() {
|
||||||
if (parameters.max_price) {
|
if (parameters.max_price) {
|
||||||
queryString.append("max_price", parameters.max_price.toString());
|
queryString.append("max_price", parameters.max_price.toString());
|
||||||
}
|
}
|
||||||
|
if (parameters.min_bedrooms) {
|
||||||
|
queryString.append('min_bedrooms', parameters.min_bedrooms.toString());
|
||||||
|
}
|
||||||
|
if (parameters.max_bedrooms) {
|
||||||
|
queryString.append('max_bedrooms', parameters.max_bedrooms.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch("/api/listing_geojson?" + queryString,
|
const response = await fetch("/api/listing_geojson?" + queryString,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ export enum ListingType {
|
||||||
export interface ParameterValues {
|
export interface ParameterValues {
|
||||||
metric: Metric
|
metric: Metric
|
||||||
listing_type: ListingType
|
listing_type: ListingType
|
||||||
|
min_bedrooms?: number
|
||||||
|
max_bedrooms?: number
|
||||||
max_price?: number
|
max_price?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,12 +43,16 @@ export function Parameters(
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
metric: z.nativeEnum(Metric, { required_error: "Metric is required" }),
|
metric: z.nativeEnum(Metric, { required_error: "Metric is required" }),
|
||||||
listing_type: z.nativeEnum(ListingType, { required_error: "Listing Type is required" }),
|
listing_type: z.nativeEnum(ListingType, { required_error: "Listing Type is required" }),
|
||||||
|
min_bedrooms: z.number().min(1).max(10).optional(),
|
||||||
|
max_bedrooms: z.number().min(1).max(10).optional(),
|
||||||
max_price: z.number().optional(),
|
max_price: z.number().optional(),
|
||||||
})
|
})
|
||||||
const form = useForm<z.infer<typeof formSchema>>({
|
const form = useForm<z.infer<typeof formSchema>>({
|
||||||
resolver: zodResolver(formSchema),
|
resolver: zodResolver(formSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
metric: Metric.qmprice,
|
metric: Metric.qmprice,
|
||||||
|
min_bedrooms: 1,
|
||||||
|
max_bedrooms: 3,
|
||||||
max_price: 3000,
|
max_price: 3000,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
@ -118,6 +124,34 @@ export function Parameters(
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="min_bedrooms"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Minimum number of bedrooms</FormLabel>
|
||||||
|
<FormControl >
|
||||||
|
<Input type="number" placeholder={"# bedrooms"} {...field} onChange={(e) => field.onChange(Number(e.target.value))} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="max_bedrooms"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Maximum number of bedrooms</FormLabel>
|
||||||
|
<FormControl >
|
||||||
|
<Input type="number" placeholder={"# bedrooms"} {...field} onChange={(e) => field.onChange(Number(e.target.value))} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="max_price"
|
name="max_price"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue