-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
d078815
commit 36cc68b
Showing
3 changed files
with
26 additions
and
0 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
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 { createCookie } from 'remix' | ||
|
||
import { Team, UserPreferences } from '~/types' | ||
|
||
import { ONE_YEAR_IN_SECONDS } from './constants' | ||
|
||
const userPrefsCookie = createCookie('user-prefs', { | ||
maxAge: ONE_YEAR_IN_SECONDS, | ||
}) | ||
|
||
export async function getUserPrefsCookie(request: Request) { | ||
const cookie: UserPreferences = | ||
(await userPrefsCookie.parse(request.headers.get('Cookie'))) || {} | ||
return { | ||
getFavoriteTeam: (): Team | undefined => cookie.favoriteTeam, | ||
setFavoriteTeam: (team: Team) => { | ||
cookie.favoriteTeam = team | ||
}, | ||
commitUserPrefs: () => userPrefsCookie.serialize(cookie), | ||
} | ||
} |
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
36cc68b
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.
Successfully deployed to the following URLs: