Skip to content

Commit

Permalink
[Web App] Select target recommendations are taken from the backend / …
Browse files Browse the repository at this point in the history
…Components structure - refactor (#996)

* Select target recommendations are taken from the backend / components structure refactor

* RewardStore: rewardFromResource functionaliti applied to getRecommendedRewards request response - cover image urls issue resolved

* functionality to minimize target reward thumbnail on 'get inspire' button click - added

* unnecessary functionality - removed

* SelectTargetRewardPage: 'Want something different?' block - added

* SelectTargetRewardContainer: refactor
  • Loading branch information
vitto-moz authored Apr 18, 2023
1 parent ca35325 commit 9188c15
Show file tree
Hide file tree
Showing 43 changed files with 362 additions and 256 deletions.
2 changes: 1 addition & 1 deletion packages/web-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"@fortawesome/free-regular-svg-icons": "6.3.0",
"@fortawesome/free-solid-svg-icons": "6.3.0",
"@fortawesome/react-fontawesome": "0.2.0",
"@saladtechnologies/garden-components": "1.1.2",
"@saladtechnologies/garden-components": "1.1.5",
"@saladtechnologies/garden-fonts": "1.0.3",
"@saladtechnologies/garden-icons": "1.0.11",
"@storybook/addon-a11y": "6.5.16",
Expand Down
1 change: 0 additions & 1 deletion packages/web-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ const styles = (theme: SaladTheme) => ({
flex: 1,
maxWidth: 1600,
position: 'relative',
paddingBottom: 100,
marginTop: 60,
},
})
Expand Down
7 changes: 3 additions & 4 deletions packages/web-app/src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ReferralOnboardingContainer, ReferralWelcomeContainer } from './modules
import { LoginPageContainer } from './modules/auth-views'
import { ReplaceBonusModalContainer } from './modules/bonus-views'
import { EarnMenuContainer } from './modules/earn-views'
import { RewardDetailsContainer } from './modules/reward-views'
import { RewardDetailsContainer, SelectTargetRewardContainer } from './modules/reward-views'
import { SaladPayOrderSummaryContainer } from './modules/salad-pay-views'
import { SettingsContainer } from './modules/settings-views'
import { StorefrontHomePage } from './modules/storefront-views/pages/StorefrontHomePage'
Expand All @@ -30,9 +30,8 @@ const _Routes = ({ location }: RouteComponentProps) => {
<Route path={['/store', '/store/search']} exact render={() => <StorefrontHomePage />} />
<Route path="/store/rewards/:id" exact component={RewardDetailsContainer} />
<Route path="/store/vault" exact component={VaultListContainer} />
{/* Target Reward Page */}
{/* * NOTE: Should be uncommented when backend is ready */}
{/* <Route path="/store/select-target-reward" exact component={SelectTargetRewardContainer} /> */}
{/* Recommended Target Rewards Page */}
<Route path="/store/select-target-reward" exact component={SelectTargetRewardContainer} />

{/* Modals */}
{/* SaladPay: This is stand in until we figure out iFrames, popups... */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const mapStoreToProps = (store: RootStore): any => {
store.auth.login()
}

const goToAccount = () => store.routing.push('/account/summary')
const bonus = store.bonuses.firstExpiringUnclaimedBonus

const selectedAvatar = store.profile.profileAvatar
Expand All @@ -27,6 +26,10 @@ const mapStoreToProps = (store: RootStore): any => {
}
: null

const goToAccount = () => store.routing.push('/account/summary')
const goToSelectTargetRewardPage = () => store.routing.push('/store/select-target-reward')
const goToTargetRewardPage = () => store.routing.push(`/store/rewards/${targetReward?.id}`)

return {
avatar: isAuthenticated ? (
selectedAvatar ? (
Expand Down Expand Up @@ -63,6 +66,8 @@ const mapStoreToProps = (store: RootStore): any => {
startButtonHoverLabel: undefined,
startButtonErrorClick: startButton.onClickWithError,
onRemoveTargetRewardClick: store.rewards.removeSelectedTargetReward,
onSelectTargetRewardClick: goToSelectTargetRewardPage,
onOpenTargetRewardClick: goToTargetRewardPage,
startButtonProgress: startButton.progress,
startButtonRunningTime: startButton.runningTime,
startButtonToolTip: startButton.toolTip,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ import { connect } from '../../connect'
import type { RootStore } from '../../Store'
import { SelectTargetRewardPage } from './pages'

const mapStoreToProps = (store: RootStore): any => ({
// * NOTE: Should be replaced with real data when backend is ready
targetRewards: [],
onConfirmTargetReward: store.rewards.setSelectedTargetReward,
})
const mapStoreToProps = (store: RootStore): any => {
const navigateToStorePage = () => store.routing.push(`/store`)
return {
recommendedRewards: store.rewards.recommendedRewards,
targetReward: store.rewards.selectedTargetReward,
onConfirmTargetReward: store.rewards.setSelectedTargetReward,
onSelectDifferentReward: store.rewards.removeSelectedTargetReward,
fetchRecommendedRewards: store.rewards.fetchRecommendedRewards,
navigateToStorePage,
}
}

export const SelectTargetRewardContainer = connect(mapStoreToProps, SelectTargetRewardPage)
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export * from '../../storefront-views/pages/StorefrontHomePage/RewardSearchBar/RewardSearchBar'
export * from './RewardDescriptionPanel'
export * from './RewardDisclaimers'
export * from './RewardHeaderBar'
export * from './RewardHowToPanel'
export * from './RewardImageCarousel'
export * from './RewardInfoPanel'
export * from './RewardRequirementsPanel'
export * from './RewardSearchBar'
export * from './RewardSlider'
4 changes: 1 addition & 3 deletions packages/web-app/src/modules/reward-views/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export * from './RewardDetailsContainer'
export * from './RewardSearchBarContainer'
export * from './RewardSearchResultContainer'
export * from './SelectTargetRewardContainer'
export * from './RewardDetailsContainer'
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { ReactNode } from 'react'
import { Component } from 'react'
import type { WithStyles } from 'react-jss'
import withStyles from 'react-jss'
import { Head, Scrollbar } from '../../../components'
import type { SaladTheme } from '../../../SaladTheme'
import type { Reward } from '../../reward/models'
import { Head, Scrollbar } from '../../../../components'
import type { SaladTheme } from '../../../../SaladTheme'
import type { Reward } from '../../../reward/models'
import {
RewardDescriptionPanel,
RewardDisclaimers,
Expand All @@ -13,7 +13,7 @@ import {
RewardImageCarousel,
RewardInfoPanel,
RewardRequirementsPanel,
} from '../components'
} from '../../components'

const styles = (theme: SaladTheme) => ({
container: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './RewardDetailsPage';

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { Img } from 'react-image'
import type { WithStyles } from 'react-jss'
import withStyles from 'react-jss'
import Skeleton from 'react-loading-skeleton'
import type { SaladTheme } from '../../../../SaladTheme'
import { DefaultTheme } from '../../../../SaladTheme'
import type { Reward } from '../../../reward/models'
import { RewardMissingImage } from '../RewardMissingImage'
import type { SaladTheme } from '../../../../../../SaladTheme'
import { DefaultTheme } from '../../../../../../SaladTheme'
import type { Reward } from '../../../../../reward/models'
import { RewardMissingImage } from '../../../../components/RewardMissingImage'

const styles = (theme: SaladTheme) => ({
export const styles = (theme: SaladTheme) => ({
selected: {},
imageOverlay: {
display: 'none',
Expand Down Expand Up @@ -128,7 +128,7 @@ const _RewardCard: FunctionComponent<Props> = ({ classes, reward, isSelected, on
</div>
</div>
<div className={classes.name}>{reward.name}</div>
<div className={classes.price}>{reward.price.toFixed(2)}</div>
<div className={classes.price}>${reward.price.toFixed(2)}</div>
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import type { FunctionComponent } from 'react'
import { useState } from 'react'
import type { WithStyles } from 'react-jss'
import withStyles from 'react-jss'
import type { Reward } from '../../../../reward/models'
import { RewardCard } from './RewardCard'

export const styles = {
rewards: {
display: 'flex',
gap: '32px',
alignItems: 'stretch',
maxWidth: 655,
flexWrap: 'wrap',
paddingBottom: '40px',
},
}

interface Props extends WithStyles<typeof styles> {
rewards: Reward[]
onConfirmTargetReward: (reward: Reward) => void
}

const visibleRewardsAmount = 6

const _RewardsList: FunctionComponent<Props> = ({ classes, rewards, onConfirmTargetReward }) => {
const [selectedRewardId, setSelectedRewardId] = useState<string | null>(null)

const selectTargetReward = (rewardId: string) => {
setSelectedRewardId(rewardId)
}

return (
<div className={classes.rewards}>
{rewards.slice(0, visibleRewardsAmount).map((reward) => (
<RewardCard
key={reward.id}
reward={reward}
isSelected={selectedRewardId === reward.id}
onSelectReward={selectTargetReward}
onConfirmReward={onConfirmTargetReward}
/>
))}
</div>
)
}

export const RewardsList = withStyles(styles)(_RewardsList)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './RewardsList';

Loading

0 comments on commit 9188c15

Please sign in to comment.