-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: add lockout period #526
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Gridiron Survivor Application
Project name: Gridiron Survivor Application
Project name: Gridiron Survivor Application
Only deployments on the production branch are activated automatically. If you'd like to activate this deployment, navigate to your deployments. Learn more about Appwrite Function deployments.
|
…ustomLink to have necessary variants.
* Checks if the user is locked out from making a pick | ||
*/ | ||
const checkLockout = (): void => { | ||
const now = new Date(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this variable name could be renamed to currentDateTime
or currentDateAndTime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion; changed.
if ( | ||
(day === 4 && hours >= 0) || | ||
(day > 4 && day < 2) || | ||
(day === 2 && hours < 12) | ||
) { | ||
setLockedOut(true); | ||
} else { | ||
setLockedOut(false); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We could add a return
in the if statement and remove the else block entirely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting a TypeScript Parsing error when I try that:
The parser expected to find a ')' to match the '(' token here.
const checkLockout = (): void => {
const currentDateAndTime = new Date();
const day = currentDateAndTime.getUTCDay();
const hours = currentDateAndTime.getUTCHours();
if (
(day === 4 && hours >= 0) ||
(day > 4 && day < 2) ||
(day === 2 && hours < 12)
return setLockedOut(true);
) else {
setLockedOut(false);
}
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're missing curly braces for your if statement here, also I meant something along the lines of the following:
const checkLockout = (): void => {
const currentDateAndTime = new Date();
const day = currentDateAndTime.getUTCDay();
const hours = currentDateAndTime.getUTCHours();
if (
(day === 4 && hours >= 0) ||
(day > 4 && day < 2) ||
(day === 2 && hours < 12)){
setLockedOut(true);
return;
}
setLockedOut(false);
};
isLockedOut === true && e.preventDefault() | ||
} | ||
size={'defaultButton'} | ||
variant={isPickSet ? 'secondaryButton' : 'primaryButton'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we using isLockedOut === true
in line 112, but here we're checking for truthy/falsy values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not get the functionally working without explicitly checking if isLockedOut === true
. When I built the LeagueEntries
component previously I was able to make it work with the truthy/falsy values.
I'm all for making it more explicit if that is the consensus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shashilo what are your thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ryandotfurrer @choir27 I think it has to do with how the prop is being brought in and the useEffect is changing the state of isLockedOut.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ryandotfurrer we don't need to bring this in as a prop as the parent component calling it is not doing anything to change that value.
Remove the prop, set the default state to false. and then see if that allows you to do isLockedOut without the check if it === true.
…entries page.test
isLockedOut === true && e.preventDefault() | ||
} | ||
size={'defaultButton'} | ||
variant={isPickSet ? 'secondaryButton' : 'primaryButton'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ryandotfurrer we don't need to bring this in as a prop as the parent component calling it is not doing anything to change that value.
Remove the prop, set the default state to false. and then see if that allows you to do isLockedOut without the check if it === true.
children="Test link" | ||
dataTestidProp="linkCustom" | ||
href="https://example.com" | ||
></LinkCustom>, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Do we need to individually test each properties?
Lockout period is where users can no longer make or change picks. This should be from 8pm EST on Thursdays (12:00AM UTC on Friday) through 8am EST on the following Tuesday (12:00pm UTC on Tuesday).