Skip to content

Commit

Permalink
Merge pull request #265 from vtex-apps/feature/hide-address-link
Browse files Browse the repository at this point in the history
Settings for hiding addresses section
  • Loading branch information
juliarocha authored May 2, 2022
2 parents a463d6b + 5a703a3 commit 7e32fe3
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 8 deletions.
1 change: 1 addition & 0 deletions graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ type AppSettings {
showGenders: Boolean
showMyCards: Boolean
showMyOrders: Boolean
showMyAddresses: Boolean
}
11 changes: 11 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@
"default": true
}
}
},
"addresses": {
"type": "object",
"title": "Addresses",
"properties": {
"showMyAddresses": {
"type": "boolean",
"title": "Visible",
"default": true
}
}
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"vtex.styleguide": "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.styleguide"
},
"dependencies": {
"@vtex/api": "6.45.3"
"@vtex/api": "6.45.12"
},
"version": "1.25.0"
}
6 changes: 5 additions & 1 deletion node/resolvers/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ async function settings(_: unknown, __: unknown, ctx: ServiceContext) {
showGenders: result.profile && result.profile.showGenders,
showMyCards: result.cards && result.cards.showMyCards,
showMyOrders: result.orders && result.orders.showMyOrders,
showMyAddresses: result.addresses && result.addresses.showMyAddresses,
}
}

interface Settings {
addresses?: { useMap: boolean }
addresses?: {
useMap: boolean
showMyAddresses: boolean
}
profile?: { showGenders: boolean }
cards?: { showMyCards: boolean }
orders?: { showMyOrders: boolean }
Expand Down
8 changes: 4 additions & 4 deletions node/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@
lodash.unescape "4.0.1"
semver "5.5.0"

"@vtex/[email protected].3":
version "6.45.3"
resolved "https://registry.yarnpkg.com/@vtex/api/-/api-6.45.3.tgz#fe7d08adb4eab1fda5e34143cc6302a4c5aa5f52"
integrity sha512-kiD7We1TCKDyBdpYoh2Se3An+jTJRUzXGNpKifoDZylWQ1PyIx+3oL5ZAif9InlY3uJkfEisSAI6nxoKTgvPfw==
"@vtex/[email protected].12":
version "6.45.12"
resolved "https://registry.yarnpkg.com/@vtex/api/-/api-6.45.12.tgz#b13c04398b12f576263ea823369f09c970d57479"
integrity sha512-SVLKo+Q/TxQy+1UKzH8GswTI3F2OCRCLfgaNQOrVAVdbM6Ci4wzTeX8j/S4Q1aEEnqBFlH/wVpHf8I6NBa+g9A==
dependencies:
"@types/koa" "^2.11.0"
"@types/koa-compose" "^3.2.3"
Expand Down
10 changes: 8 additions & 2 deletions react/components/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ const CSS_HANDLES = ['css', 'menu', 'menuLinks', 'menuLink'] as const
interface RenderLinksOptions {
showMyCards: boolean | null
showMyOrders: boolean | null
showMyAddresses: boolean | null
}

function renderLinks(
links: Link[],
{ showMyCards, showMyOrders }: RenderLinksOptions
{ showMyCards, showMyOrders, showMyAddresses }: RenderLinksOptions
) {
const linksToDisplay = links.filter(link => {
if (showMyCards === false && link.path === '/cards') {
Expand All @@ -34,6 +35,10 @@ function renderLinks(
return false
}

if (showMyAddresses === false && link.path === '/addresses') {
return false
}

return true
})

Expand All @@ -51,7 +56,7 @@ class Menu extends Component<Props, { isModalOpen: boolean }> {

public render() {
const { cssHandles, intl, settings, runtime } = this.props
const { showMyCards = false, showMyOrders = false } = settings || {}
const { showMyCards = false, showMyOrders = false, showMyAddresses = false } = settings || {}

return (
<aside
Expand All @@ -65,6 +70,7 @@ class Menu extends Component<Props, { isModalOpen: boolean }> {
renderLinks(links, {
showMyCards,
showMyOrders,
showMyAddresses,
})
}
/>
Expand Down
1 change: 1 addition & 0 deletions react/components/shared/withSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ export interface Settings {
showGenders: boolean
showMyCards: boolean | null
showMyOrders: boolean | null
showMyAddresses: boolean | null
useMap: boolean
}
1 change: 1 addition & 0 deletions react/graphql/settings.gql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ query MyAccountSettings {
showGenders
showMyCards
showMyOrders
showMyAddresses
useMap
}
}

0 comments on commit 7e32fe3

Please sign in to comment.