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

Add interface to show reference information #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ In order to define the Store Locator custom page UI, you must use the blocks exp
| `store-back-link` | Renders a link to return to the previous page. |
| `store-map` | Renders a map with the retail store localization. |
| `store-address` | Renders the store's address. |
| `store-reference` | Renders the store's reference information. |
| `store-hours` | Renders the store's opening hours. This information comes by default from the Pickup Points configuration, but you can also define manually through the Store's theme |
| `store-instructions` | Renders the desired instructions to access the retail store. |

Expand Down Expand Up @@ -235,6 +236,12 @@ In order to define the Store Locator custom page UI, you must use the blocks exp
| :-------: | :------: | :---------------------------------------------------------: | :-------------: |
| `label` | `string` | Entitles the `store-address` block when rendered on the UI. | `Store address` |

#### `store-reference` props

| Prop name | Type | Description | Default value |
| :-------: | :------: | :-----------------------------------------------------------: | :-----------: |
| `label` | `string` | Entitles the `store-reference` block when rendered on the UI. | `Reference` |

#### `store-hours` props

| Prop name | Type | Description | Default value. |
Expand Down
3 changes: 2 additions & 1 deletion messages/context.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"store/load-all": "store/load-all",
"store/back-link": "store/back-link",
"store/address-label": "store/address-label",
"store/reference-label": "store/reference-label",
"store/information-label": "store/information-label",
"store/store-closed": "store/store-closed",
"store/hours-label": "store/hours-label",
Expand All @@ -14,4 +15,4 @@
"store/day-of-week-thursday": "store/day-of-week-thursday",
"store/day-of-week-friday": "store/day-of-week-friday",
"store/day-of-week-saturday": "store/day-of-week-saturday"
}
}
1 change: 1 addition & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"store/load-all": "Load all stores",
"store/back-link": "Back to all stores",
"store/address-label": "Store address",
"store/reference-label": "Reference",
"store/information-label": "Information",
"store/store-closed": "Closed",
"store/hours-label": "Store hours",
Expand Down
3 changes: 2 additions & 1 deletion messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"store/load-all": "Cargar todas las tiendas",
"store/back-link": "Volver a todas las tiendas",
"store/address-label": "Dirección de la tienda",
"store/reference-label": "Referencia",
"store/information-label": "Información",
"store/store-closed": "Cerrado",
"store/hours-label": "Horario de la tienda",
Expand All @@ -14,4 +15,4 @@
"store/day-of-week-thursday": "Jueves",
"store/day-of-week-friday": "Viernes",
"store/day-of-week-saturday": "Sábado"
}
}
3 changes: 2 additions & 1 deletion messages/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"store/load-all": "Listar todas as lojas",
"store/back-link": "Voltar para lista de lojas",
"store/address-label": "Endereço",
"store/reference-label": "Referência",
"store/information-label": "Informações",
"store/store-closed": "Fechado",
"store/hours-label": "Horário de funcionamento",
Expand All @@ -14,4 +15,4 @@
"store/day-of-week-thursday": "Quinta",
"store/day-of-week-friday": "Sexta",
"store/day-of-week-saturday": "Sábado"
}
}
49 changes: 49 additions & 0 deletions react/StoreReference.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type { FC } from 'react'
import React from 'react'
import type { WrappedComponentProps } from 'react-intl'
import { defineMessages, injectIntl } from 'react-intl'
import { useCssHandles } from 'vtex.css-handles'

import { useStoreGroup } from './StoreGroup'

const CSS_HANDLES = [
'referenceContainer',
'referenceLabel',
'referenceText',
] as const

const messages = defineMessages({
reference: {
defaultMessage: 'Reference',
id: 'store/reference-label',
},
})

interface StoreReferenceProps {
label: string
}

const StoreReference: FC<StoreReferenceProps & WrappedComponentProps> = ({
label,
intl,
}) => {
const group = useStoreGroup()

const handles = useCssHandles(CSS_HANDLES)

if (!group?.address?.reference) {
return null
}

return (
<div className={handles.referenceContainer}>
<span className={handles.referenceLabel}>
{label ?? intl.formatMessage(messages.reference)}
</span>

<span className={handles.referenceText}>{group.address.reference}</span>
</div>
)
}

export default injectIntl(StoreReference)
4 changes: 4 additions & 0 deletions store/interfaces.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
"component": "StoreAddress",
"composition": "children"
},
"store-reference": {
"component": "StoreReference",
"composition": "children"
},
"store-back-link": {
"component": "StoreBackLink",
"composition": "children"
Expand Down