Skip to content

Commit 78e2a97

Browse files
authored
Merge pull request #104 from UTDNebula/develop
v1.2.5
2 parents 81760c3 + ea818b1 commit 78e2a97

File tree

16 files changed

+131
-151
lines changed

16 files changed

+131
-151
lines changed

public/icon-black.svg

Lines changed: 0 additions & 21 deletions
This file was deleted.

public/icon-white.svg

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/app/Home.tsx

Lines changed: 11 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22

33
import Background from '@/../public/background.png';
44
import NebulaLogo from '@/components/NebulaLogo';
5-
import snapTime, { defaultEndTime, defaultStartTime } from '@/lib/snapTime';
5+
import {
6+
defaultEndTime,
7+
defaultStartTime,
8+
snapTime,
9+
validTime,
10+
} from '@/lib/timeUtils';
611
import { Checkbox, CircularProgress, FormControlLabel } from '@mui/material';
712
import Button from '@mui/material/Button';
813
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
914
import { TimePicker } from '@mui/x-date-pickers/TimePicker';
1015
import dayjs, { Dayjs } from 'dayjs';
1116
import Image from 'next/image';
1217
import { useRouter } from 'next/navigation';
13-
import React, { useRef, useState, useTransition } from 'react';
18+
import React, { useState, useTransition } from 'react';
1419

1520
/**
1621
* Returns the home page with Nebula Branding and search options
@@ -40,10 +45,6 @@ export default function Home() {
4045
dayjs(endTime, 'HH:mm').isBefore(dayjs(startTime, 'HH:mm')),
4146
);
4247

43-
// for saving the input values on change but only updating them onBlur or onKeyDown+enter
44-
const startTimeChange = useRef<Dayjs | null>(startTime);
45-
const endTimeChange = useRef<Dayjs | null>(endTime);
46-
4748
const [nearby, setNearby] = useState(false);
4849

4950
// only show checkbox if location is possible
@@ -134,10 +135,8 @@ export default function Home() {
134135
label="Start time"
135136
value={startTime}
136137
timeSteps={{ minutes: 15 }}
137-
onChange={(newValue) => (startTimeChange.current = newValue)}
138-
onAccept={(newValue) =>
139-
setStartTime(newValue == null ? null : snapTime(newValue))
140-
}
138+
onChange={(newValue) => setStartTime(newValue)}
139+
onAccept={(newValue) => setStartTime(snapTime(validTime(newValue)))}
141140
className="w-full"
142141
slotProps={{
143142
actionBar: {
@@ -151,35 +150,15 @@ export default function Home() {
151150
},
152151
error: error,
153152
helperText: error && 'Start time must be before end time',
154-
onBlur: () => {
155-
setStartTime(
156-
startTimeChange.current == null ||
157-
!startTimeChange.current.isValid()
158-
? null
159-
: snapTime(startTimeChange.current),
160-
);
161-
},
162-
onKeyDown: (e) => {
163-
if (e.key === 'Enter') {
164-
setStartTime(
165-
startTimeChange.current == null ||
166-
!startTimeChange.current.isValid()
167-
? null
168-
: snapTime(startTimeChange.current),
169-
);
170-
}
171-
},
172153
},
173154
}}
174155
/>
175156
<TimePicker
176157
label="End time"
177158
value={endTime}
178159
timeSteps={{ minutes: 15 }}
179-
onChange={(newValue) => (endTimeChange.current = newValue)}
180-
onAccept={(newValue) =>
181-
setEndTime(newValue == null ? null : snapTime(newValue))
182-
}
160+
onChange={(newValue) => setEndTime(newValue)}
161+
onAccept={(newValue) => setEndTime(snapTime(validTime(newValue)))}
183162
className="w-full"
184163
slotProps={{
185164
actionBar: {
@@ -193,25 +172,6 @@ export default function Home() {
193172
},
194173
error: error,
195174
helperText: error && 'Start time must be before end time',
196-
onBlur: () => {
197-
console.log(endTimeChange.current);
198-
setEndTime(
199-
endTimeChange.current == null ||
200-
!endTimeChange.current.isValid()
201-
? null
202-
: snapTime(endTimeChange.current),
203-
);
204-
},
205-
onKeyDown: (e) => {
206-
if (e.key === 'Enter') {
207-
setEndTime(
208-
endTimeChange.current == null ||
209-
!endTimeChange.current.isValid()
210-
? null
211-
: snapTime(endTimeChange.current),
212-
);
213-
}
214-
},
215175
},
216176
}}
217177
/>

src/app/apple-icon.png

1.07 KB
Loading

src/app/favicon.ico

-3.56 KB
Binary file not shown.

src/app/icon-16.png

-37 Bytes
Loading

src/app/icon-192.png

1.16 KB
Loading

src/app/icon-32.png

-168 Bytes
Loading

src/app/icon-512.png

3.37 KB
Loading

0 commit comments

Comments
 (0)