Skip to content
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

Closed
wants to merge 9 commits into from
Closed

Conversation

ryandotfurrer
Copy link
Member

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).

Copy link

vercel bot commented Sep 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gridiron-survivor ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 18, 2024 0:13am
gridiron-survivor-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 18, 2024 0:13am

Copy link

appwrite bot commented Sep 12, 2024

Gridiron Survivor Application 6616ea581ef9f5521c7d

Function ID Status Action
Your function has been successfully deployed.

Project name: Gridiron Survivor Application
Project ID: 6616ea581ef9f5521c7d

Function ID Status Action
userAuth 6626fef885a9f630442b ready Ready View Logs
Your function has been successfully deployed.

Project name: Gridiron Survivor Application
Project ID: 6616ea581ef9f5521c7d

Function ID Status Action
Update User Email 66e9e91800219e84e954 ready Ready View Logs

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.

💡 Did you know?
Appwrite has a Discord community with over 16 000 members. Come join us!

components/LeagueEntries/LeagueEntries.tsx Show resolved Hide resolved
* Checks if the user is locked out from making a pick
*/
const checkLockout = (): void => {
const now = new Date();
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion; changed.

Comment on lines +45 to +53
if (
(day === 4 && hours >= 0) ||
(day > 4 && day < 2) ||
(day === 2 && hours < 12)
) {
setLockedOut(true);
} else {
setLockedOut(false);
}
Copy link
Contributor

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

Copy link
Member Author

@ryandotfurrer ryandotfurrer Sep 18, 2024

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);
      }
    };

Copy link
Contributor

@choir241 choir241 Sep 18, 2024

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);
      
    };

components/LeagueEntries/LeagueEntries.tsx Show resolved Hide resolved
isLockedOut === true && e.preventDefault()
}
size={'defaultButton'}
variant={isPickSet ? 'secondaryButton' : 'primaryButton'}
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

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.

isLockedOut === true && e.preventDefault()
}
size={'defaultButton'}
variant={isPickSet ? 'secondaryButton' : 'primaryButton'}
Copy link
Contributor

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>,
);
Copy link
Contributor

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?

@ryandotfurrer ryandotfurrer marked this pull request as draft September 30, 2024 15:10
@ryandotfurrer ryandotfurrer deleted the ryan/add-lockout-period branch September 30, 2024 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: add lockout period where users cannot make picks
4 participants