generated from vtex-apps/react-app-template
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add interface to show reference information
- Loading branch information
1 parent
4c04080
commit 194de51
Showing
7 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters