-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3cf169
commit 19c3392
Showing
4 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const formatDate = (date: Date) => { | ||
const year = date.getFullYear(); | ||
const month = (date.getMonth() + 1).toString().padStart(2, '0'); | ||
const day = date.getDate().toString().padStart(2, '0'); | ||
return `${year}-${month}-${day}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { formatDate } from "./formatDate"; | ||
|
||
export const getVoteData = () => { | ||
const voteData = localStorage.getItem('vote_data'); | ||
return voteData ? JSON.parse(voteData) : {}; | ||
} | ||
|
||
export const saveVoteData = (voteData: Record<string, string>[]) => { | ||
localStorage.setItem('vote_data', JSON.stringify(voteData)); | ||
} | ||
|
||
export const canVote = (resortId: string) => { | ||
const voteData = getVoteData(); | ||
const todayDate = formatDate(new Date()); | ||
|
||
if (voteData[resortId] === todayDate) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters