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

Launched black friday promo for shop users. #546

Merged
merged 1 commit into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added src/assets/promos/kiwico.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/promos/lego.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/promos/macys.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/promos/microsoft.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/promos/oldnavy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/promos/samsung.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/promos/sephora.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/promos/sonos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/promos/thriftbooks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/promos/ultra-beauty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/promos/walmart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/promos/zulily.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 4 additions & 6 deletions src/components/promos/November2023NoShopUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,17 @@ const November2023NoShopUser = ({ user }) => {
</Typography>

<Typography variant="body1" gutterBottom align="center">
Expand your giving this holiday season by using{' '}
Double your impact when you shop this holiday season with{' '}
<a
href="http://shop.gladly.io"
target="_blank"
rel="noreferrer"
>
Shop for a Cause
</a>
, allowing you to make a positive impact with every purchase,
and double the joy of giving back while you shop. As a bonus,
everyone who activates Shop for a Cause on one of our over
10,000 partner shops in November will be entered into a drawing
for two $100 Visa gift cards (
. Simply add the extension, activate the offers, and shop. As a
bonus for activating an offer, you’ll be entered into a drawing
for one of two $100 Visa gift cards (
<a
href="https://gladly.zendesk.com/hc/en-us/articles/21341815958541-Black-Friday-2023-100-Gift-Card-Giveaway-Details"
target="_blank"
Expand Down
294 changes: 294 additions & 0 deletions src/components/promos/November2023ShopUser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
import Box from '@material-ui/core/Box'
import React, { useEffect, useState } from 'react'
import gtag from 'ga-gtag'
import PropTypes from 'prop-types'
import Card from '@material-ui/core/Card'
import CardContent from '@material-ui/core/CardContent'
import Typography from '@material-ui/core/Typography'
import IconButton from '@material-ui/core/IconButton'
import CloseIcon from '@material-ui/icons/Close'
import localStorageMgr from 'src/utils/localstorage-mgr'
import { NOTIF_DISMISS_PREFIX } from 'src/utils/constants'

import LegoLogo from 'src/assets/promos/lego.png'
import WalmartLogo from 'src/assets/promos/walmart.png'
import SephoraLogo from 'src/assets/promos/sephora.png'
import UltraBeautyLogo from 'src/assets/promos/ultra-beauty.png'
import ThriftBooksLogo from 'src/assets/promos/thriftbooks.png'
import OldNavyLogo from 'src/assets/promos/oldnavy.png'
import KiwicoLogo from 'src/assets/promos/kiwico.png'
import SamsungLogo from 'src/assets/promos/samsung.png'
import SonosLogo from 'src/assets/promos/sonos.png'
import MacysLogo from 'src/assets/promos/macys.png'
import MicrosoftLogo from 'src/assets/promos/microsoft.png'
import ZulilyLogo from 'src/assets/promos/zulily.png'
import styles from './November2023ShopUser.module.css'

const batchKey = 'november-2023-shop-batch'
const baseUrl = 'https://wild.link/e?d=54321'

const contStyles = {
position: 'relative',
marginLeft: 'auto',
marginRight: 'auto',
width: 700,
marginTop: 40,
marginBottom: 20,
zIndex: 100000,
}

const imageGroupStyles = {
display: 'flex',
justifyContent: 'space-evenly',
marginTop: 20,
}

const November2023ShopUser = ({ user }) => {
const [show, setShow] = useState(false)
const [batch, setBatch] = useState(1)

Check warning on line 48 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L47-L48

Added lines #L47 - L48 were not covered by tests

useEffect(() => {

Check warning on line 50 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L50

Added line #L50 was not covered by tests
// Function to update the state
function updateState() {
const now = new Date().getTime()
const storedData = localStorageMgr.getItem(batchKey)

Check warning on line 54 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L52-L54

Added lines #L52 - L54 were not covered by tests

if (storedData) {
const { timestamp, currentState } = JSON.parse(storedData)

Check warning on line 57 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L57

Added line #L57 was not covered by tests

// Calculate the number of 3-min intervals passed since the timestamp
const intervalsPassed = Math.floor((now - timestamp) / (3 * 60 * 1000))

Check warning on line 60 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L60

Added line #L60 was not covered by tests

if (intervalsPassed > 0) {
// Calculate the new state based on intervals passed
const newState = ((currentState + intervalsPassed - 1) % 4) + 1
const newTimestamp = timestamp + intervalsPassed * 3 * 60 * 1000

Check warning on line 65 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L64-L65

Added lines #L64 - L65 were not covered by tests

// Update local storage and state
localStorageMgr.setItem(

Check warning on line 68 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L68

Added line #L68 was not covered by tests
batchKey,
JSON.stringify({ timestamp: newTimestamp, currentState: newState })
)
setBatch(newState)
} else {

Check warning on line 73 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L72-L73

Added lines #L72 - L73 were not covered by tests
// If less than 3 min have passed, keep the current state
setBatch(currentState)

Check warning on line 75 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L75

Added line #L75 was not covered by tests
}
} else {

Check warning on line 77 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L77

Added line #L77 was not covered by tests
// If no data in local storage, set default state and store it
const defaultData = { timestamp: now, currentState: 1 }
localStorageMgr.setItem(batchKey, JSON.stringify(defaultData))
setBatch(1)

Check warning on line 81 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L79-L81

Added lines #L79 - L81 were not covered by tests
}
}

// Call the function on component mount
updateState()

Check warning on line 86 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L86

Added line #L86 was not covered by tests
}, [])

const getNotifDismissKey = (code) => `${NOTIF_DISMISS_PREFIX}.${code}`

Check warning on line 89 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L89

Added line #L89 was not covered by tests

const onDismiss = (e) => {
e.stopPropagation()
e.nativeEvent.stopImmediatePropagation()
gtag('event', 'november_2023_shop_user_dismiss')
localStorageMgr.setItem(getNotifDismissKey('november-2023-shop'), true)
setShow(false)
return false

Check warning on line 97 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L91-L97

Added lines #L91 - L97 were not covered by tests
}

useEffect(() => {

Check warning on line 100 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L100

Added line #L100 was not covered by tests
const dissNotif =
localStorageMgr.getItem(getNotifDismissKey('november-2023-shop')) || false

if (!dissNotif) {
setShow(true)
} else {
setShow(false)

Check warning on line 107 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L105-L107

Added lines #L105 - L107 were not covered by tests
}
}, [user])

return (

Check warning on line 111 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L111

Added line #L111 was not covered by tests
<>
{show && (
<div style={contStyles}>

Check warning on line 114 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L113-L114

Added lines #L113 - L114 were not covered by tests
<Card>
<CardContent
style={{
display: 'flex',
justifyContent: 'center',
flexDirection: 'column',
}}
>
<IconButton
onClick={onDismiss}
style={{
position: 'absolute',
right: 10,
top: 0,
}}
>
<CloseIcon sx={{ color: '#fff', width: 28, height: 28 }} />
</IconButton>

<Typography
variant="h4"
gutterBottom
align="center"
style={{ marginTop: 20 }}
>
Give back during your <br /> Holiday Shopping
</Typography>

<Typography variant="body1" gutterBottom align="center">
Raise money for {user.cause.nameForShop || 'Charity'} when you

Check warning on line 144 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L144

Added line #L144 was not covered by tests
shop these Black Friday deals–you can earn up to 10% back! As a
bonus for activating an offer, you’ll be entered into a drawing
for one of two $100 Visa gift cards (
<a
href="https://gladly.zendesk.com/hc/en-us/articles/21341815958541-Black-Friday-2023-100-Gift-Card-Giveaway-Details"
target="_blank"
rel="noreferrer"
>
promo details
</a>
).
</Typography>

{batch === 1 && (
<Box sx={imageGroupStyles}>

Check warning on line 159 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L158-L159

Added lines #L158 - L159 were not covered by tests
<a
href={`${baseUrl}&c=5482116&UUID=${user.userId}&url=https://www.lego.com/`}
className={styles.hoverable}
target="_blank"
rel="noreferrer"
>
<img src={LegoLogo} width="100" alt="" />
</a>
<a
className={styles.hoverable}
href={`${baseUrl}&c=5483936&UUID=${user.userId}&url=https://www.walmart.com/`}
target="_blank"
rel="noreferrer"
>
<img src={WalmartLogo} width="100" alt="" />
</a>
<a
className={styles.hoverable}
href={`${baseUrl}&c=5481985&UUID=${user.userId}&url=https://www.sephora.com/`}
target="_blank"
rel="noreferrer"
>
<img src={SephoraLogo} width="100" alt="" />
</a>
</Box>
)}

{batch === 2 && (
<Box sx={imageGroupStyles}>

Check warning on line 188 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L187-L188

Added lines #L187 - L188 were not covered by tests
<a
className={styles.hoverable}
href={`${baseUrl}&c=5483579&UUID=${user.userId}&url=https://www.ulta.com/`}
target="_blank"
rel="noreferrer"
>
<img src={UltraBeautyLogo} width="100" alt="" />
</a>
<a
className={styles.hoverable}
href={`${baseUrl}&c=144406&UUID=${user.userId}&url=https://www.thriftbooks.com/`}
target="_blank"
rel="noreferrer"
>
<img src={ThriftBooksLogo} width="100" alt="" />
</a>
<a
className={styles.hoverable}
href={`${baseUrl}&c=5480737&UUID=${user.userId}&url=https://oldnavy.gap.com/`}
target="_blank"
rel="noreferrer"
>
<img src={OldNavyLogo} width="100" alt="" />
</a>
</Box>
)}

{batch === 3 && (
<Box sx={imageGroupStyles}>

Check warning on line 217 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L216-L217

Added lines #L216 - L217 were not covered by tests
<a
className={styles.hoverable}
href={`${baseUrl}&c=5479361&UUID=${user.userId}&url=https://www.kiwico.com/`}
target="_blank"
rel="noreferrer"
>
<img src={KiwicoLogo} width="100" alt="" />
</a>
<a
className={styles.hoverable}
href={`${baseUrl}&c=5481855&UUID=${user.userId}&url=https://www.samsung.com/`}
target="_blank"
rel="noreferrer"
>
<img src={SamsungLogo} width="100" alt="" />
</a>{' '}
<a
className={styles.hoverable}
href={`${baseUrl}&c=5482453&UUID=${user.userId}&url=https://www.sonos.com/`}
target="_blank"
rel="noreferrer"
>
<img src={SonosLogo} width="100" alt="" />
</a>{' '}
</Box>
)}

{batch === 4 && (
<Box sx={imageGroupStyles}>

Check warning on line 246 in src/components/promos/November2023ShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023ShopUser.js#L245-L246

Added lines #L245 - L246 were not covered by tests
<a
className={styles.hoverable}
href={`${baseUrl}&c=5479868&UUID=${user.userId}&url=https://www.macys.com/`}
target="_blank"
rel="noreferrer"
>
<img src={MacysLogo} width="100" alt="" />
</a>{' '}
<a
className={styles.hoverable}
href={`${baseUrl}&c=5482649&UUID=${user.userId}&url=https://www.microsoft.com/`}
target="_blank"
rel="noreferrer"
>
<img src={MicrosoftLogo} width="100" alt="" />
</a>
<a
className={styles.hoverable}
href={`${baseUrl}&c=5484304&UUID=${user.userId}&url=https://shop.zulily.com/`}
target="_blank"
rel="noreferrer"
>
<img src={ZulilyLogo} width="100" alt="" />
</a>
</Box>
)}
</CardContent>
</Card>
</div>
)}
</>
)
}

November2023ShopUser.displayName = 'November2023ShopUserComponent'

November2023ShopUser.propTypes = {
user: PropTypes.shape({
userId: PropTypes.string,
cause: PropTypes.shape({
nameForShop: PropTypes.string,
}),
}).isRequired,
}

November2023ShopUser.defaultProps = {}

export default November2023ShopUser
13 changes: 13 additions & 0 deletions src/components/promos/November2023ShopUser.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.hoverable {
border: 1px solid transparent;
transition: 0.3s;
width: 100px;
height: 100px;
}

.hoverable:hover {
width: 106px;
height: 106px;
border: 3px solid #ccc;
margin-bottom: -5px;
}
7 changes: 7 additions & 0 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@
import FrontpageShortcutListContainer from 'src/components/FrontpageShortcutListContainer'
import Modal from '@material-ui/core/Modal'
import { Box } from '@material-ui/core'

import November2023ShopUser from 'src/components/promos/November2023ShopUser'
import November2023NoShopUser from 'src/components/promos/November2023NoShopUser'

const getNotifDismissKey = (code) => `${NOTIF_DISMISS_PREFIX}.${code}`
Expand Down Expand Up @@ -1143,6 +1145,11 @@
{/* Prime day 2023 Promo */}
{/* {user.userId && notif && <PrimeDay2023 user={user} />} */}

{/* November Shop User 2023 Promo */}
{user.userId && user.shopSignupTimestamp && (
<November2023ShopUser user={user} />

Check warning on line 1150 in src/pages/index.js

View check run for this annotation

Codecov / codecov/patch

src/pages/index.js#L1150

Added line #L1150 was not covered by tests
)}

<Logo
includeText
color={enableBackgroundImages ? 'white' : null}
Expand Down
Loading