-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b0bac6
commit 04779be
Showing
12 changed files
with
263 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { NumberInput } from "@mantine/core"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useMediaQuery } from "@mantine/hooks"; | ||
import { selectPropertyOccupations } from "../../store/filtering/filteringSelector"; | ||
import { useAppDispatch, useAppSelector } from "../../hooks/useInitStore"; | ||
import { setPropertyOccupations } from "../../store/filtering/filteringReducer"; | ||
|
||
export function PropertyOccupations() { | ||
const mediaQuerySize = useMediaQuery('(max-width: 768px)') ? 'xl' : 'md'; | ||
const { t } = useTranslation('common', { keyPrefix: 'filtering' }); | ||
|
||
const dispatch = useAppDispatch(); | ||
const propertyOccupations = useAppSelector(selectPropertyOccupations); | ||
|
||
function onPropertyOccupations(min?: number, max?: number) { | ||
const newOccupations = { | ||
min: min ?? propertyOccupations.min, | ||
max: max ?? propertyOccupations.max, | ||
}; | ||
dispatch(setPropertyOccupations(newOccupations)); | ||
} | ||
|
||
return <> | ||
<NumberInput | ||
id="propertyOccupations.min" | ||
label={t('propertyOccupations.min') + ' (%)'} | ||
value={propertyOccupations.min} | ||
min={0} | ||
max={propertyOccupations.max} | ||
allowDecimal={false} | ||
size={mediaQuerySize} | ||
onChange={(e) => onPropertyOccupations(e as number)} | ||
/> | ||
<NumberInput | ||
id="propertyOccupations.max" | ||
label={t('propertyOccupations.max') + ' (%)'} | ||
value={propertyOccupations.max} | ||
min={propertyOccupations.min} | ||
max={100} | ||
allowDecimal={false} | ||
size={mediaQuerySize} | ||
onChange={(e) => onPropertyOccupations(undefined, e as number)} | ||
/> | ||
</> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useAppSelector } from "../../hooks/useInitStore"; | ||
import { useTranslation } from "react-i18next"; | ||
import { analyticsEvent } from "../../services/analytics"; | ||
import { useAppDispatch } from "../../hooks/useInitStore"; | ||
import { selectPropertyTypes } from "../../store/filtering/filteringSelector"; | ||
import { ComboboxData, MultiSelect } from "@mantine/core"; | ||
import { setPropertyTypes } from "../../store/filtering/filteringReducer"; | ||
import { useMemo } from "react"; | ||
import { useMediaQuery } from "@mantine/hooks"; | ||
|
||
export function PropertyType() { | ||
const mediaQuerySize = useMediaQuery('(max-width: 768px)') ? 'xl' : 'md'; | ||
const { t } = useTranslation('common', { keyPrefix: 'filtering' }); | ||
const { t: tPropertyType } = useTranslation('common', { keyPrefix: 'propertyType' }); | ||
const dispatch = useAppDispatch(); | ||
const propertyTypes = useAppSelector(selectPropertyTypes); | ||
|
||
const data: ComboboxData = useMemo(() => [1, 2, 3, 4, 6, 8, 9, 10, 11, 12].map(type => ({ | ||
value: type.toString(), | ||
label: tPropertyType(type.toString()), | ||
})), [tPropertyType]); | ||
|
||
function onPropertyTypes(value: string[]) { | ||
analyticsEvent({ | ||
category: 'Settings', | ||
action: 'Property Types', | ||
label: value.join(', '), | ||
}); | ||
dispatch(setPropertyTypes(value)); | ||
} | ||
|
||
return ( | ||
<MultiSelect | ||
id="propertyTypes" | ||
label={t('propertyTypes')} | ||
data={data} | ||
value={propertyTypes} | ||
size={mediaQuerySize} | ||
onChange={(e) => onPropertyTypes(e)} /> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { NumberInput } from "@mantine/core"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useMediaQuery } from "@mantine/hooks"; | ||
import { selectPropertyYields } from "../../store/filtering/filteringSelector"; | ||
import { useAppDispatch, useAppSelector } from "../../hooks/useInitStore"; | ||
import { setPropertyYields } from "../../store/filtering/filteringReducer"; | ||
|
||
export function PropertyYields() { | ||
const mediaQuerySize = useMediaQuery('(max-width: 768px)') ? 'xl' : 'md'; | ||
const { t } = useTranslation('common', { keyPrefix: 'filtering' }); | ||
|
||
const dispatch = useAppDispatch(); | ||
const propertyYields = useAppSelector(selectPropertyYields); | ||
|
||
function onPropertyYields(min?: number, max?: number) { | ||
const newYields = { | ||
min: min ?? propertyYields.min ?? 0, | ||
max: max as unknown as string === '' | ||
? undefined | ||
: max ?? propertyYields.max ?? undefined, | ||
}; | ||
dispatch(setPropertyYields(newYields)); | ||
} | ||
|
||
return <> | ||
<NumberInput | ||
id="propertyYields.min" | ||
label={t('propertyYields.min') + ' (%)'} | ||
value={propertyYields.min} | ||
min={0} | ||
max={propertyYields.max ?? undefined} | ||
allowDecimal={false} | ||
size={mediaQuerySize} | ||
onChange={(e) => onPropertyYields(e as number)} | ||
/> | ||
<NumberInput | ||
id="propertyYields.max" | ||
label={t('propertyYields.max') + ' (%)'} | ||
value={propertyYields.max ?? undefined} | ||
min={propertyYields.min} | ||
max={100} | ||
allowDecimal={false} | ||
size={mediaQuerySize} | ||
onChange={(e) => onPropertyYields(undefined, e as number)} | ||
/> | ||
</> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.