Skip to content

Commit ba53bf0

Browse files
committed
Make locationAvailable a boolean
1 parent def863f commit ba53bf0

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/app/Home.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ export default function Home() {
4747
const [nearby, setNearby] = useState(false);
4848

4949
// only show checkbox if location is possible
50-
const [locationAvailable] = useState<'yes' | 'no'>(() => {
50+
const [locationAvailable] = useState(() => {
5151
if (
5252
typeof window !== 'undefined' &&
5353
'permissions' in navigator &&
5454
'geolocation' in navigator
5555
) {
56-
return 'yes';
56+
return true;
5757
}
58-
return 'no';
58+
return false;
5959
});
6060

6161
const [locationGranted, setLocationGranted] = useState(false);
@@ -215,7 +215,7 @@ export default function Home() {
215215
},
216216
}}
217217
/>
218-
{locationAvailable === 'yes' && (
218+
{locationAvailable && (
219219
<FormControlLabel
220220
control={
221221
<Checkbox

src/components/Filters.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ export default function Filters(props: Props) {
134134
const buildings = props.buildings;
135135

136136
// only show checkbox if location is possible
137-
const [locationAvailable] = useState<'yes' | 'no'>(() => {
137+
const [locationAvailable] = useState(() => {
138138
if (
139139
typeof window !== 'undefined' &&
140140
'permissions' in navigator &&
141141
'geolocation' in navigator
142142
) {
143-
return 'yes';
143+
return true;
144144
}
145-
return 'no';
145+
return false;
146146
});
147147

148148
const [locationGranted, setLocationGranted] = useState(false);
@@ -430,7 +430,7 @@ export default function Filters(props: Props) {
430430
<Radio checked={!buildings.length} />
431431
<ListItemText primary="Any" />
432432
</MenuItem>
433-
{locationAvailable === 'yes' && (
433+
{locationAvailable && (
434434
<MenuItem className="h-10" value="nearby">
435435
<Radio
436436
checked={buildings[0] === 'nearby'}

0 commit comments

Comments
 (0)