react-code-dataset / wp-calypso /client /sites /deployments /components /deployments-survey /utils.ts
react-code-dataset / wp-calypso /client /sites /deployments /components /deployments-survey /utils.ts
Download wp-calypso/client/sites/deployments/components/deployments-survey/utils.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 804 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/deployments/components/deployments-survey/utils.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/sites/deployments/components/deployments-survey/utils.ts
-
curl -L -o utils.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/deployments/components/deployments-survey/utils.ts
804 Bytes
| import cookie from 'cookie'; | |
| const setSurveyCookie = ( name: string, value: string, maxAge: number ) => { | |
| document.cookie = cookie.serialize( `github-deployments-${ name }`, value, { | |
| path: '/', | |
| maxAge, | |
| } ); | |
| }; | |
| const getSurveyCookie = ( name: string ) => { | |
| return cookie.parse( document.cookie )[ `github-deployments-${ name }` ]; | |
| }; | |
| export const maybeSetDeploymentDone = () => { | |
| const cookieValue = getSurveyCookie( 'has-deployments' ); | |
| if ( cookieValue ) { | |
| return; | |
| } | |
| setSurveyCookie( 'has-deployments', 'true', 365 * 24 * 60 * 60 ) /* 1 year */; | |
| setSurveyCookie( 'hide-survey', 'true', 7 * 24 * 60 * 60 ) /* 7 days */; | |
| }; | |
| export const shouldShowDeploymentSurvey = () => { | |
| const cookieValue = getSurveyCookie( 'hide-survey' ); | |
| if ( cookieValue ) { | |
| return false; | |
| } | |
| return true; | |
| }; | |