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 November shop promo #543

Merged
merged 1 commit into from
Nov 15, 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
139 changes: 139 additions & 0 deletions src/components/promos/November2023NoShopUser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import React, { useEffect, useState } from 'react'
import gtag from 'ga-gtag'
import PropTypes from 'prop-types'
import Button from '@material-ui/core/Button'
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'

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

const November2023NoShopUser = ({ user }) => {
const [show, setShow] = useState(false)

Check warning on line 24 in src/components/promos/November2023NoShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023NoShopUser.js#L24

Added line #L24 was not covered by tests

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

Check warning on line 26 in src/components/promos/November2023NoShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023NoShopUser.js#L26

Added line #L26 was not covered by tests

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

Check warning on line 34 in src/components/promos/November2023NoShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023NoShopUser.js#L28-L34

Added lines #L28 - L34 were not covered by tests
}

useEffect(() => {

Check warning on line 37 in src/components/promos/November2023NoShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023NoShopUser.js#L37

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

Check warning on line 40 in src/components/promos/November2023NoShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023NoShopUser.js#L40

Added line #L40 was not covered by tests

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

Check warning on line 45 in src/components/promos/November2023NoShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023NoShopUser.js#L43-L45

Added lines #L43 - L45 were not covered by tests
}
}, [user])

return (

Check warning on line 49 in src/components/promos/November2023NoShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023NoShopUser.js#L49

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

Check warning on line 52 in src/components/promos/November2023NoShopUser.js

View check run for this annotation

Codecov / codecov/patch

src/components/promos/November2023NoShopUser.js#L51-L52

Added lines #L51 - L52 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 }}
>
Win $100 by Giving Back during Black Friday and Cyber Monday
</Typography>

<Typography variant="body1" gutterBottom align="center">
Expand your giving this holiday season by using{' '}
<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 (
<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>

<Button
variant="contained"
color="primary"
style={{
marginTop: 10,
marginBottom: 10,
width: 250,
marginLeft: 'auto',
marginRight: 'auto',
}}
>
Install Shop for a Cause
</Button>
</CardContent>
</Card>
</div>
)}
</>
)
}

November2023NoShopUser.displayName = 'November2023NoShopUserComponent'

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

November2023NoShopUser.defaultProps = {}

export default November2023NoShopUser
33 changes: 31 additions & 2 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
import FrontpageShortcutListContainer from 'src/components/FrontpageShortcutListContainer'
import Modal from '@material-ui/core/Modal'
import { Box } from '@material-ui/core'
import November2023NoShopUser from 'src/components/promos/November2023NoShopUser'

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

const useStyles = makeStyles((theme) => ({
pageContainer: {
Expand Down Expand Up @@ -384,6 +387,7 @@
joined
showYahooPrompt
showSfacExtensionPrompt
shopSignupTimestamp
cause {
causeId
impactType
Expand Down Expand Up @@ -637,6 +641,23 @@
}
}, [showYahooPrompt, interactedWithSFACNotification, features, searches])

// Figure out margin of search
const [searchMargin, setSearchMargin] = useState(0)

useEffect(() => {
if (!user) {
return
}

if (!user.shopSignupTimestamp) {
if (
!localStorageMgr.getItem(getNotifDismissKey('november-2023-no-shop'))
) {
setSearchMargin(-250)
}
}
}, [user])

// set the causeId in local storage for tab ads
useEffect(() => {
localStorageMgr.setItem(STORAGE_NEW_USER_CAUSE_ID, causeId)
Expand Down Expand Up @@ -692,7 +713,7 @@
const bookmarkWidgetEnabled = bookmarkWidget && bookmarkWidget.node.enabled

useEffect(() => {
const getNotifDismissKey = (code) => `${NOTIF_DISMISS_PREFIX}.${code}`
// const getNotifDismissKey = (code) => `${NOTIF_DISMISS_PREFIX}.${code}`
const onNotificationClose = (code) => {
localStorageMgr.setItem(getNotifDismissKey(code), 'true')
setNotifsToShow((notifsToShow) =>
Expand Down Expand Up @@ -1109,7 +1130,15 @@
) : null}
</div>

<div className={classes.centerContainer}>
{/* November No Shop User 2023 Promo */}
{user.userId && !user.shopSignupTimestamp && (
<November2023NoShopUser user={user} />

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

View check run for this annotation

Codecov / codecov/patch

src/pages/index.js#L1135

Added line #L1135 was not covered by tests
)}

<div
className={classes.centerContainer}
style={{ marginTop: searchMargin }}
>
<div className={classes.searchBarContainer}>
{/* Prime day 2023 Promo */}
{/* {user.userId && notif && <PrimeDay2023 user={user} />} */}
Expand Down
46 changes: 46 additions & 0 deletions src/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -981,11 +981,17 @@ type User implements Node {
"""whether or not the user has opted into searching for extra impact"""
yahooPaidSearchRewardOptIn: Boolean!

"""ISO datetime string of when this Shop Signup Timestamp was started"""
shopSignupTimestamp: String

"""Current UserGroupImpactMetric"""
userGroupImpactMetric: UserGroupImpactMetric

"""Current UserGroupImpactMetrics leaderboard"""
leaderboard: [leaderboardEntry]

"""User historical data related to group impacts"""
groupImpactHistory: [UserGroupImpactMetricLog]
}

"""a user's charity specific impact"""
Expand Down Expand Up @@ -1331,6 +1337,45 @@ type leaderboardEntry {
user: User
}

"""
A historical view of a specific users contribution to a GroupImpactMetric
"""
type UserGroupImpactMetricLog implements Node {
"""The ID of an object"""
id: ID!

"""The ID of the user which the UserGroupImpactMetric belongs to"""
userId: String!

"""
The micro USD amount raised for this instance of GroupImpactMetric so far by this user
"""
dollarContribution: Int!

"""
The micro USD amount raised for this instance of GroupImpactMetric so far by this user from tabs
"""
tabDollarContribution: Int!

"""
The micro USD amount raised for this instance of GroupImpactMetric so far by this user from search
"""
searchDollarContribution: Int!

"""
The micro USD amount raised for this instance of GroupImpactMetric so far by this user from shopping
"""
shopDollarContribution: Int!

"""
The micro USD amount raised for this instance of GroupImpactMetric so far by this user from referrals
"""
referralDollarContribution: Int!

"""Date the group impact metric started"""
dateStarted: String!
}

"""The Wildfire object"""
type Wildfire {
causeName: String
Expand Down Expand Up @@ -1698,6 +1743,7 @@ input CreateNewUserInput {
v4BetaEnabled: Boolean
missionId: String
causeId: String
campaignId: String
clientMutationId: String
}

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15315,10 +15315,10 @@ synchronous-promise@^2.0.15:
resolved "https://registry.yarnpkg.com/synchronous-promise/-/synchronous-promise-2.0.16.tgz#669b75e86b4295fdcc1bb0498de9ac1af6fd51a9"
integrity sha512-qImOD23aDfnIDNqlG1NOehdB9IYsn1V9oByPjKY1nakv2MQYCEMyX033/q+aEtYCpmYK1cv2+NTmlH+ra6GA5A==

tab-ads@^1.1.20:
version "1.1.20"
resolved "https://registry.yarnpkg.com/tab-ads/-/tab-ads-1.1.20.tgz#b3ef70a03127f746171daf81fa7d6461c9767977"
integrity sha512-dagHnOnf4827hQRmDZ+thvldFac5CuY7pEVSsVO/iJ+02xYc7/g2wn3d4wyQUifXjwf8AJBVCpEerckZAKANgA==
tab-ads@^1.1.23:
version "1.1.23"
resolved "https://registry.yarnpkg.com/tab-ads/-/tab-ads-1.1.23.tgz#aa02b7ce727d42ef0310cbb56b56e1b982090cc1"
integrity sha512-hhWhLGoUiuZDokqMG37yDzgfUMZUuDh9K/AlU2yLSBWL/1ZIif5jqCISHp3P9NG6u8TGS1L/Lt/pBCF6oav3EA==
dependencies:
lodash "^4.17.21"

Expand Down
Loading