Skip to content

Commit 1027384

Browse files
authored
Merge pull request #40 from dgomie/debugging-v1beta
Debugging v1beta
2 parents a784063 + 2efefd3 commit 1027384

File tree

5 files changed

+60
-34
lines changed

5 files changed

+60
-34
lines changed

public/img/shuffle.svg

Lines changed: 1 addition & 0 deletions
Loading

src/components/profileSettings/ProfileSettings.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ export const ProfileSettings = ({ currentUser }) => {
132132
onChange={handleInputChange}
133133
disabled={!isEditing}
134134
/>
135-
<Input
135+
{/* <Input
136136
id="email"
137137
name="email"
138138
label="Email"
139139
value={formData.email}
140140
onChange={handleInputChange}
141141
disabled={!isEditing}
142-
/>
142+
/> */}
143143

144144
<div className={styles.buttonContainer}>
145145
<Button variant="aquamarine" onClick={handleEditClick}>

src/components/roundPageInfo/RoundPageInfo.js

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,18 @@ export const RoundPageInfo = ({
1717
const now = new Date();
1818
const deadlineDate = new Date(deadline);
1919

20-
const isToday =
21-
new Date(
22-
now.getFullYear(),
23-
now.getMonth(),
24-
now.getDate() + 1
25-
).toDateString() === deadlineDate.toDateString();
26-
20+
const isToday = now.toDateString() === deadlineDate.toDateString();
2721
const isTomorrow =
2822
new Date(
2923
now.getFullYear(),
3024
now.getMonth(),
31-
now.getDate() + 2
25+
now.getDate() + 1
3226
).toDateString() === deadlineDate.toDateString();
3327

34-
// const dayName = deadlineDate.toLocaleDateString('en-US', {
35-
// weekday: 'long',
36-
// });
37-
// const monthDay = deadlineDate.toLocaleDateString('en-US', {
38-
// month: 'numeric',
39-
// day: 'numeric',
40-
// });
41-
42-
const previousDay = new Date(deadlineDate);
43-
previousDay.setDate(deadlineDate.getDate() - 1);
44-
45-
const previousDayName = previousDay.toLocaleDateString('en-US', {
28+
const dayName = deadlineDate.toLocaleDateString('en-US', {
4629
weekday: 'long',
4730
});
48-
49-
const previousMonthDay = previousDay.toLocaleDateString('en-US', {
31+
const monthDay = deadlineDate.toLocaleDateString('en-US', {
5032
month: 'numeric',
5133
day: 'numeric',
5234
});
@@ -56,7 +38,7 @@ export const RoundPageInfo = ({
5638
} else if (isTomorrow) {
5739
return `${type} due tomorrow at midnight`;
5840
} else {
59-
return `${type} due ${previousDayName} ${previousMonthDay} at midnight`;
41+
return `${type} due ${dayName} ${monthDay} at midnight`;
6042
}
6143
};
6244

@@ -116,4 +98,4 @@ export const RoundPageInfo = ({
11698
)}
11799
</div>
118100
);
119-
};
101+
};

src/components/roundSettingsModal/RoundSettingsModal.js

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React, { useMemo, useState } from 'react';
22
import styles from './RoundSettingsModal.module.css';
33
import Input from '@/components/input/Input';
44
import Button from '@/components/button/Button';
5+
import Image from 'next/image';
6+
import { musicLeaguePrompts } from '@/data/defaultPrompts'; // Import prompts
57

68
const RoundSettingsModal = ({
79
editableRoundData,
@@ -13,7 +15,23 @@ const RoundSettingsModal = ({
1315
const [submissionError, setSubmissionError] = useState('');
1416
const [voteError, setVoteError] = useState('');
1517

16-
// Check if there are any changes between editableRoundData and originalRoundData
18+
// Function to generate a random prompt
19+
const handleShufflePrompt = () => {
20+
if (musicLeaguePrompts.length === 0) {
21+
setEditableRoundData({
22+
...editableRoundData,
23+
prompt: 'No prompts available', // Fallback prompt
24+
});
25+
return;
26+
}
27+
const randomPrompt =
28+
musicLeaguePrompts[Math.floor(Math.random() * musicLeaguePrompts.length)];
29+
setEditableRoundData({
30+
...editableRoundData,
31+
prompt: randomPrompt,
32+
});
33+
};
34+
1735
const hasChanges = useMemo(() => {
1836
if (!editableRoundData || !originalRoundData) return false;
1937
return (
@@ -27,34 +45,37 @@ const RoundSettingsModal = ({
2745
const handleSubmissionDeadlineChange = (e) => {
2846
const newSubmissionDeadline = new Date(e.target.value).toISOString();
2947
const now = new Date().toISOString();
30-
48+
3149
if (newSubmissionDeadline <= now) {
3250
setSubmissionError('Submission deadline must be a future date.');
3351
return;
3452
}
35-
36-
if (editableRoundData.voteDeadline && newSubmissionDeadline >= editableRoundData.voteDeadline) {
53+
54+
if (
55+
editableRoundData.voteDeadline &&
56+
newSubmissionDeadline >= editableRoundData.voteDeadline
57+
) {
3758
setSubmissionError('');
3859
setVoteError('Vote deadline must be after the submission deadline.');
3960
} else {
4061
setVoteError('');
4162
}
42-
63+
4364
setSubmissionError('');
4465
setEditableRoundData({
4566
...editableRoundData,
4667
submissionDeadline: newSubmissionDeadline,
4768
});
4869
};
49-
70+
5071
const handleVoteDeadlineChange = (e) => {
5172
const newVoteDeadline = new Date(e.target.value).toISOString();
52-
73+
5374
if (newVoteDeadline <= editableRoundData.submissionDeadline) {
5475
setVoteError('Vote deadline must be after the submission deadline.');
5576
return;
5677
}
57-
78+
5879
setVoteError('');
5980
setEditableRoundData({
6081
...editableRoundData,
@@ -68,6 +89,7 @@ const RoundSettingsModal = ({
6889
<div className={styles.modal}>
6990
<div className={styles.modalContent}>
7091
<div className={styles.title}>Edit Round Settings</div>
92+
7193
<Input
7294
id="prompt"
7395
name="prompt"
@@ -82,6 +104,19 @@ const RoundSettingsModal = ({
82104
}
83105
required
84106
/>
107+
<Button variant="aquamarine" onClick={handleShufflePrompt}>
108+
<div className={styles.randomizeButtonContent}>
109+
<Image
110+
src="/img/shuffle.svg"
111+
height={20}
112+
width={20}
113+
alt="shuffle"
114+
className={styles.shuffleIcon}
115+
/>
116+
Randomize Prompt
117+
</div>
118+
</Button>
119+
85120
<Input
86121
id="submissionDeadline"
87122
name="submissionDeadline"

src/components/roundSettingsModal/RoundSettingsModal.module.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
display: flex;
2727
justify-content: space-between;
2828
margin-top: 20px;
29+
gap: .5rem;
2930
}
3031

3132
.title {
@@ -39,4 +40,11 @@
3940
text-align: center;
4041
font-size: .85rem;
4142
font-weight: bold;
43+
}
44+
45+
.randomizeButtonContent {
46+
display: flex;
47+
gap: 1rem;
48+
justify-content: center;
49+
align-items: center;
4250
}

0 commit comments

Comments
 (0)