Skip to content

Commit 006b8b4

Browse files
fix: time formating for matches
1 parent 1ca8116 commit 006b8b4

File tree

3 files changed

+23
-57
lines changed

3 files changed

+23
-57
lines changed

client/src/components/Dashboard.tsx

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { useUserID } from '../contexts/UserIDContext';
2525
import { Link as RouterLink } from 'react-router-dom';
2626
import { useMatchActions } from '../hooks/useMatchActions';
2727
import MatchActionDialogs from './MatchActionDialogs';
28-
import { formatTimeslots } from '../utils/formatting';
28+
import { formatTimeslots, formatTime } from '../utils/formatting';
2929

3030
const Dashboard = () => {
3131
const { user } = useAuth0();
@@ -176,26 +176,9 @@ const Dashboard = () => {
176176
});
177177
};
178178

179-
const formatTime = (timeSlot: number) => {
180-
const times = [
181-
'8:00 AM',
182-
'8:30 AM',
183-
'9:00 AM',
184-
'9:30 AM',
185-
'10:00 AM',
186-
'10:30 AM',
187-
'11:00 AM',
188-
'11:30 AM',
189-
'12:00 PM',
190-
'12:30 PM',
191-
'1:00 PM',
192-
'1:30 PM',
193-
'2:00 PM',
194-
'2:30 PM',
195-
'3:00 PM',
196-
'3:30 PM',
197-
];
198-
return times[timeSlot - 1] || 'Unknown time';
179+
// Use the existing formatTime function for matches (single timeslot)
180+
const formatMatchTime = (timeSlot: number) => {
181+
return formatTime(timeSlot);
199182
};
200183

201184
// Skeleton component for match boxes
@@ -331,7 +314,7 @@ const Dashboard = () => {
331314
{formatDate(match.group.date)}
332315
</Typography>
333316
<Typography variant="body2" sx={{ color: 'text.secondary', mb: 0.5 }}>
334-
{formatTime(match.group.time)}
317+
{formatMatchTime(match.group.time)}
335318
</Typography>
336319
<Typography variant="body2" sx={{ color: 'text.secondary', mb: 1 }}>
337320
{match.group.location}
@@ -433,7 +416,7 @@ const Dashboard = () => {
433416
variant="body2"
434417
sx={{ color: 'text.secondary', mb: { xs: 0.5, md: 0 } }}
435418
>
436-
{formatTime(match.group.time)}
419+
{formatMatchTime(match.group.time)}
437420
</Typography>
438421
<Typography
439422
variant="body2"
@@ -518,9 +501,9 @@ const Dashboard = () => {
518501
<Typography variant="body2" sx={{ fontWeight: 600, mb: 0.5 }}>
519502
{formatDate(match.group.date)}
520503
</Typography>
521-
<Typography variant="body2" sx={{ color: 'text.secondary', mb: 0.5 }}>
522-
{formatTime(match.group.time)}
523-
</Typography>
504+
<Typography variant="body2" sx={{ color: 'text.secondary', mb: 0.5 }}>
505+
{formatMatchTime(match.group.time)}
506+
</Typography>
524507
<Typography variant="body2" sx={{ color: 'text.secondary', mb: 1 }}>
525508
{match.group.location}
526509
</Typography>
@@ -633,7 +616,7 @@ const Dashboard = () => {
633616
variant="body2"
634617
sx={{ color: 'text.secondary', mb: { xs: 0.5, md: 0 } }}
635618
>
636-
{formatTime(match.group.time)}
619+
{formatMatchTime(match.group.time)}
637620
</Typography>
638621
<Typography
639622
variant="body2"

client/src/components/Matches.tsx

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { MatchesResponse, Match, MatchStatus, ConversationStarter } from '../typ
2525
import { useMatchActions } from '../hooks/useMatchActions';
2626
import MatchActionDialogs from './MatchActionDialogs';
2727
import { useUserID } from '../contexts/UserIDContext';
28+
import { formatTime } from '../utils/formatting';
2829

2930
const Matches = () => {
3031
const { getMatches } = useMatchesService();
@@ -124,27 +125,9 @@ const Matches = () => {
124125
});
125126
};
126127

127-
const formatTime = (timeSlot: number) => {
128-
// Assuming time slots are 1-16 representing different times
129-
const times = [
130-
'8:00 AM',
131-
'8:30 AM',
132-
'9:00 AM',
133-
'9:30 AM',
134-
'10:00 AM',
135-
'10:30 AM',
136-
'11:00 AM',
137-
'11:30 AM',
138-
'12:00 PM',
139-
'12:30 PM',
140-
'1:00 PM',
141-
'1:30 PM',
142-
'2:00 PM',
143-
'2:30 PM',
144-
'3:00 PM',
145-
'3:30 PM',
146-
];
147-
return times[timeSlot - 1] || 'Unknown time';
128+
// Use the existing formatTime function for matches (single timeslot)
129+
const formatMatchTime = (timeSlot: number) => {
130+
return formatTime(timeSlot);
148131
};
149132

150133
const handleViewAllStarters = (starters: ConversationStarter[]) => {
@@ -310,7 +293,7 @@ const Matches = () => {
310293
color="text.secondary"
311294
sx={{ fontSize: '0.8rem', mb: 0.5 }}
312295
>
313-
<strong>Time:</strong> {formatTime(match.group.time)}
296+
<strong>Time:</strong> {formatMatchTime(match.group.time)}
314297
</Typography>
315298
<Typography
316299
variant="body2"

client/src/utils/formatting.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ export const formatDate = (dateString: string) => {
1111

1212
export const formatTime = (timeSlot: number) => {
1313
const times = [
14-
'8:00 AM',
15-
'8:30 AM',
16-
'9:00 AM',
17-
'9:30 AM',
1814
'10:00 AM',
15+
'10:15 AM',
1916
'10:30 AM',
17+
'10:45 AM',
2018
'11:00 AM',
19+
'11:15 AM',
2120
'11:30 AM',
21+
'11:45 AM',
2222
'12:00 PM',
23+
'12:15 PM',
2324
'12:30 PM',
25+
'12:45 PM',
2426
'1:00 PM',
27+
'1:15 PM',
2528
'1:30 PM',
26-
'2:00 PM',
27-
'2:30 PM',
28-
'3:00 PM',
29-
'3:30 PM',
29+
'1:45 PM',
3030
];
3131
return times[timeSlot - 1] || 'Unknown time';
3232
};

0 commit comments

Comments
 (0)