Skip to content

Debugging v1beta #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/img/shuffle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/components/profileSettings/ProfileSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ export const ProfileSettings = ({ currentUser }) => {
onChange={handleInputChange}
disabled={!isEditing}
/>
<Input
{/* <Input
id="email"
name="email"
label="Email"
value={formData.email}
onChange={handleInputChange}
disabled={!isEditing}
/>
/> */}
Comment on lines +135 to +142
Copy link
Preview

Copilot AI May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Remove or properly document the commented-out email input code if it is no longer needed to keep the codebase clean.

Copilot uses AI. Check for mistakes.


<div className={styles.buttonContainer}>
<Button variant="aquamarine" onClick={handleEditClick}>
Expand Down
30 changes: 6 additions & 24 deletions src/components/roundPageInfo/RoundPageInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,18 @@ export const RoundPageInfo = ({
const now = new Date();
const deadlineDate = new Date(deadline);

const isToday =
new Date(
now.getFullYear(),
now.getMonth(),
now.getDate() + 1
).toDateString() === deadlineDate.toDateString();

const isToday = now.toDateString() === deadlineDate.toDateString();
const isTomorrow =
new Date(
now.getFullYear(),
now.getMonth(),
now.getDate() + 2
now.getDate() + 1
).toDateString() === deadlineDate.toDateString();

// const dayName = deadlineDate.toLocaleDateString('en-US', {
// weekday: 'long',
// });
// const monthDay = deadlineDate.toLocaleDateString('en-US', {
// month: 'numeric',
// day: 'numeric',
// });

const previousDay = new Date(deadlineDate);
previousDay.setDate(deadlineDate.getDate() - 1);

const previousDayName = previousDay.toLocaleDateString('en-US', {
const dayName = deadlineDate.toLocaleDateString('en-US', {
weekday: 'long',
});

const previousMonthDay = previousDay.toLocaleDateString('en-US', {
const monthDay = deadlineDate.toLocaleDateString('en-US', {
month: 'numeric',
day: 'numeric',
});
Expand All @@ -56,7 +38,7 @@ export const RoundPageInfo = ({
} else if (isTomorrow) {
return `${type} due tomorrow at midnight`;
} else {
return `${type} due ${previousDayName} ${previousMonthDay} at midnight`;
return `${type} due ${dayName} ${monthDay} at midnight`;
}
};

Expand Down Expand Up @@ -116,4 +98,4 @@ export const RoundPageInfo = ({
)}
</div>
);
};
};
51 changes: 43 additions & 8 deletions src/components/roundSettingsModal/RoundSettingsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React, { useMemo, useState } from 'react';
import styles from './RoundSettingsModal.module.css';
import Input from '@/components/input/Input';
import Button from '@/components/button/Button';
import Image from 'next/image';
import { musicLeaguePrompts } from '@/data/defaultPrompts'; // Import prompts

const RoundSettingsModal = ({
editableRoundData,
Expand All @@ -13,7 +15,23 @@ const RoundSettingsModal = ({
const [submissionError, setSubmissionError] = useState('');
const [voteError, setVoteError] = useState('');

// Check if there are any changes between editableRoundData and originalRoundData
// Function to generate a random prompt
const handleShufflePrompt = () => {
if (musicLeaguePrompts.length === 0) {
setEditableRoundData({
...editableRoundData,
prompt: 'No prompts available', // Fallback prompt
});
return;
}
const randomPrompt =
musicLeaguePrompts[Math.floor(Math.random() * musicLeaguePrompts.length)];
setEditableRoundData({
...editableRoundData,
prompt: randomPrompt,
});
};

const hasChanges = useMemo(() => {
if (!editableRoundData || !originalRoundData) return false;
return (
Expand All @@ -27,34 +45,37 @@ const RoundSettingsModal = ({
const handleSubmissionDeadlineChange = (e) => {
const newSubmissionDeadline = new Date(e.target.value).toISOString();
const now = new Date().toISOString();

if (newSubmissionDeadline <= now) {
setSubmissionError('Submission deadline must be a future date.');
return;
}

if (editableRoundData.voteDeadline && newSubmissionDeadline >= editableRoundData.voteDeadline) {

if (
editableRoundData.voteDeadline &&
newSubmissionDeadline >= editableRoundData.voteDeadline
) {
setSubmissionError('');
setVoteError('Vote deadline must be after the submission deadline.');
} else {
setVoteError('');
}

setSubmissionError('');
setEditableRoundData({
...editableRoundData,
submissionDeadline: newSubmissionDeadline,
});
};

const handleVoteDeadlineChange = (e) => {
const newVoteDeadline = new Date(e.target.value).toISOString();

if (newVoteDeadline <= editableRoundData.submissionDeadline) {
setVoteError('Vote deadline must be after the submission deadline.');
return;
}

setVoteError('');
setEditableRoundData({
...editableRoundData,
Expand All @@ -68,6 +89,7 @@ const RoundSettingsModal = ({
<div className={styles.modal}>
<div className={styles.modalContent}>
<div className={styles.title}>Edit Round Settings</div>

<Input
id="prompt"
name="prompt"
Expand All @@ -82,6 +104,19 @@ const RoundSettingsModal = ({
}
required
/>
<Button variant="aquamarine" onClick={handleShufflePrompt}>
<div className={styles.randomizeButtonContent}>
<Image
src="/img/shuffle.svg"
height={20}
width={20}
alt="shuffle"
className={styles.shuffleIcon}
/>
Randomize Prompt
</div>
</Button>

<Input
id="submissionDeadline"
name="submissionDeadline"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
display: flex;
justify-content: space-between;
margin-top: 20px;
gap: .5rem;
}

.title {
Expand All @@ -39,4 +40,11 @@
text-align: center;
font-size: .85rem;
font-weight: bold;
}

.randomizeButtonContent {
display: flex;
gap: 1rem;
justify-content: center;
align-items: center;
}