id
stringlengths
12
53
messages
listlengths
3
3
code_search_c8eec16d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/utils/withRuntime.tsx from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { useRuntime } from 'vtex.render-runtime'\nimport React from 'react'\n\n// tslint:disable-next-line:variable-name\nexport function withRuntime(ComponentWrapped: typeof React.Component) {\n return function Wrapped(props: any) {\n return <ComponentWrapped {...props} runtime={useRuntime()} />\n }\n}\n\n```" } ]
code_search_eea2ee2e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/utils/getSession.tsx from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nconst getSession = async (rootPath?: string) => {\n const headers = new Headers()\n\n headers.append('Content-Type', 'application/json')\n\n const requestOptions: RequestInit = {\n method: 'GET',\n headers,\n redirect: 'follow',\n }\n\n const session = await fetch(\n `${rootPath || ''}/api/sessions?items=public.shippingOption`,\n requestOptions\n )\n\n const data = await session.json()\n\n if (!data?.namespaces?.public?.shippingOption?.value) {\n return null\n }\n\n return JSON.parse(data.namespaces.public.shippingOption.value)\n}\n\nexport default getSession\n\n```" } ]
code_search_997265dd
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/utils/string-utils.ts from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport function removeBaseUrl(url: string) {\n const baseUrlPattern = /^https?:\\/\\/[a-z\\:0-9.]+/\n\n const match = baseUrlPattern.exec(url)\n\n if (match) {\n return url.replace(match[0], '')\n }\n\n return url\n}\n\nexport function decodeUrlString(str: string) {\n return str.replace(/\\$2F/gi, '/')\n}\n\nexport function encodeUrlString(str: string) {\n return str.replace(/\\//gi, '$2F')\n}\n\n```" } ]
code_search_43de6158
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/models/search-result.ts from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ISearchProduct } from './search-product'\n\ninterface IResultResponsePagination {\n count: number\n current: IResultResponsePaginationItem\n before: IResultResponsePaginationItem[]\n after: IResultResponsePaginationItem[]\n next: IResultResponsePaginationItem\n previous: IResultResponsePaginationItem\n first: IResultResponsePaginationItem\n last: IResultResponsePaginationItem\n}\n\ninterface IResultResponsePaginationItem {\n index: number\n proxyUrl: string\n}\n\ninterface ISearchSort {\n field: string\n order: string\n active: boolean\n proxyUrl: string\n}\n\ninterface ISearchOptions {\n sorts: ISearchSort[]\n counts: ISearchOptionsCount[]\n}\n\ninterface ISearchOptionsCount {\n count: number\n active: boolean\n proxyUrl: string\n}\n\nexport interface IAttributeResponseKey {\n key: string\n label: string\n type: string\n visible: boolean\n values: IAttributeResponseValue[]\n minValue: number\n maxValue: number\n active: boolean\n activeFrom: string\n activeTo: string\n templateUrl: string\n proxyUrl: string\n}\n\ninterface IAttributeResponseValue {\n count: number\n active: boolean\n proxyUrl: string\n key: string\n label: string\n from: string\n to: string\n}\n\ninterface ISuggestionSearchesOutput {\n searches: ISuggestionQueryResponseSearch[]\n}\n\ninterface ISuggestionQueryResponseSearch {\n term: string\n count: number\n attributes: IElasticProductText[]\n}\n\ninterface IElasticProductText {\n key: string\n value: string\n labelKey: string\n labelValue: string\n}\n\ninterface IPhraseSuggestion {\n text: string\n highlighted: string\n misspelled: boolean\n correction: boolean\n}\n\nexport interface ISearchResult {\n query: string\n operator: string\n total: number\n products: ISearchProduct[] | any[]\n pagination: IResultResponsePagination\n options: ISearchOptions\n attributes: IAttributeResponseKey[]\n suggestion: ISuggestionSearchesOutput\n correction: IPhraseSuggestion\n}\n\n```" } ]
code_search_7e163cd0
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/models/store-preferences.ts from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport interface StorePreferences {\n priceFormatPreferences: PriceFormatPreferences\n tilePreferences: TilePreferences\n autoCompletePreferences: AutoCompletePreferences\n}\n\nexport interface PriceFormatPreferences {\n prefix: string\n decimalPlaces: number\n floatIndicator: string\n}\n\nexport interface TilePreferences {\n unavailableMessage: string\n oldPricePrefix: string\n pricePrefix: string\n showPrefixOnlyWhenPriceHasOldPrice?: boolean\n}\n\nexport interface AutoCompletePreferences {\n productCount: number\n inputPlaceHolder: string\n topSearchedListTitle: string\n historyListTitle: string\n suggestionListTitle: string\n emptySuggestionListTitle: string\n tileListTitle: string\n subListItemPrefix: string\n}\n\n```" } ]
code_search_7e4ec0ec
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/models/search-product.ts from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport interface ISearchProductText {\n key: string\n value: string\n labelKey: string\n labelValue: string\n}\n\nexport interface ISearchProduct {\n id: string\n name: string\n url: string\n images: IElasticProductImage[]\n oldPrice: number\n price: number\n oldPriceText: string\n priceText: string\n installment: IElasticProductInstallment\n attributes: IElasticProductText[]\n extraInfo: IExtraInfo[]\n brand: string\n product: string\n categories: string[]\n skus: IProductSku[]\n}\n\ninterface IProductSku {\n id: string\n references: string\n price: number\n oldPrice: number\n installment: {\n count: number\n value: number\n }\n sellers: Array<{\n id: string\n price: number\n oldPrice: number\n installment: {\n count: number\n value: number\n }\n }>\n}\n\ninterface IElasticProductImage {\n name: string\n value: string\n}\n\nexport interface IElasticProductInstallment {\n count: number\n value: number\n interest: boolean\n valueText: string\n}\n\ninterface IElasticProductText {\n key: string\n value: string\n labelKey: string\n labelValue: string\n}\n\nexport interface IExtraInfo {\n key: string\n value: string\n}\n\nexport interface ISearchProductImage {\n name: string\n value: string\n}\n\nexport interface ISearchProductInstallment {\n count: number\n value: number\n interest: boolean\n valueText: string\n}\n\nexport interface ISearchProductExtraInfo {\n key: string\n value: string\n}\n\n```" } ]
code_search_8cd3fe23
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/components/Autocomplete/index.tsx from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n// /* eslint-disable no-restricted-syntax */\n/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable @typescript-eslint/explicit-member-accessibility */\nimport React from 'react'\nimport { withApollo, WithApolloClient } from 'react-apollo'\nimport { FormattedMessage } from 'react-intl'\nimport { IconClose, IconClock } from 'vtex.styleguide'\nimport { ProductListContext } from 'vtex.product-list-context'\nimport { withDevice } from 'vtex.device-detector'\nimport debounce from 'debounce'\nimport { withPixel } from 'vtex.pixel-manager/PixelContext'\n\nimport BiggyClient from '../../utils/biggy-client'\nimport stylesCss from './styles.css'\nimport TileList from './components/TileList/TileList'\nimport {\n Item,\n instanceOfAttributeItem,\n AttributeItem,\n} from './components/ItemList/types'\nimport { ItemList } from './components/ItemList/ItemList'\nimport { withRuntime } from '../../utils/withRuntime'\nimport { decodeUrlString, encodeUrlString } from '../../utils/string-utils'\nimport {\n EventType,\n handleAutocompleteSearch,\n handleItemClick,\n handleProductClick,\n handleSeeAllClick,\n} from '../../utils/pixel'\nimport getSession from '../../utils/getSession'\n\nconst MAX_TOP_SEARCHES_DEFAULT = 10\nconst MAX_SUGGESTED_TERMS_DEFAULT = 5\nconst MAX_SUGGESTED_PRODUCTS_DEFAULT = 3\nconst MAX_HISTORY_DEFAULT = 5\n\n// eslint-disable-next-line no-shadow, no-restricted-syntax\nexport enum ProductLayout {\n Horizontal = 'HORIZONTAL',\n Vertical = 'VERTICAL',\n}\n\ninterface AutoCompleteProps {\n isOpen: boolean\n runtime: { page: string; rootPath?: string }\n inputValue: string\n maxTopSearches: number\n maxSuggestedTerms: number\n maxSuggestedProducts: number\n maxHistory: number\n autocompleteWidth: number\n productLayout?: ProductLayout\n hideTitles: boolean\n historyFirst: boolean\n isMobile: boolean\n customBreakpoints?: {\n md: {\n width: number\n maxSuggestedProducts: number\n }\n lg: {\n width: number\n maxSuggestedProducts: number\n }\n xlg: {\n width: number\n maxSuggestedProducts: number\n }\n }\n __unstableProductOrigin: 'BIGGY' | 'VTEX'\n __unstableProductOriginVtex: boolean\n simulationBehavior: 'default' | 'skip' | null\n hideUnavailableItems: boolean\n push: (data: any) => void\n HorizontalProductSummary?: React.ComponentType<{\n product: Product\n placement: string\n actionOnClick: () => void\n }>\n customPage?: string\n closeMenu: () => void\n orderBy?: string\n}\n\ninterface AutoCompleteState {\n topSearchedItems: Item[]\n suggestionItems: Item[]\n history: Item[]\n products: any[]\n totalProducts: number\n queryFromHover: { key?: string; value?: string }\n dynamicTerm: string\n isProductsLoading: boolean\n currentHeightWhenOpen: number\n searchId: string\n}\n\nconst { ProductListProvider } = ProductListContext\n\nclass AutoComplete extends React.Component<\n WithApolloClient<AutoCompleteProps>,\n Partial<AutoCompleteState>\n> {\n autocompleteRef: React.RefObject<any>\n client: BiggyClient\n isIOS: boolean\n\n public readonly state: AutoCompleteState = {\n topSearchedItems: [],\n history: [],\n products: [],\n suggestionItems: [],\n totalProducts: 0,\n queryFromHover: {},\n dynamicTerm: '',\n isProductsLoading: false,\n currentHeightWhenOpen: 0,\n searchId: '',\n }\n\n constructor(props: WithApolloClient<AutoCompleteProps>) {\n super(props)\n\n this.client = new BiggyClient(this.props.client)\n this.autocompleteRef = React.createRef()\n this.isIOS = navigator && !!navigator.userAgent.match(/(iPod|iPhone|iPad)/)\n }\n\n fitAutocompleteInWindow() {\n if (\n !window ||\n !this.autocompleteRef.current ||\n !this.props.isMobile ||\n this.isIOS\n ) {\n return\n }\n\n const windowHeight = window.innerHeight\n const autocompletePosition = this.autocompleteRef.current.getBoundingClientRect()\n .y\n\n const autocompleteHeight = this.autocompleteRef.current.offsetHeight\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n const autocompleteEnd = autocompletePosition + autocompleteHeight\n\n const currentHeight = autocompleteHeight - (autocompleteEnd - windowHeight)\n\n this.autocompleteRef.current.style.maxHeight = `${currentHeight}px`\n }\n\n addEvents() {\n window.addEventListener(\n 'resize',\n debounce(this.fitAutocompleteInWindow.bind(this), 100)\n )\n }\n\n componentDidMount() {\n this.updateTopSearches()\n this.updateHistory()\n this.addEvents()\n }\n\n shouldUpdate(prevProps: AutoCompleteProps) {\n return (\n prevProps.inputValue !== this.props.inputValue ||\n (!prevProps.isOpen && this.props.isOpen)\n )\n }\n\n addTermToHistory() {\n const path = window.location.href.split('_q=')\n\n if (path[1]) {\n const term = path[1].split('&')[0]\n\n try {\n return this.client.prependSearchHistory(decodeURI(term))\n } catch {\n return this.client.prependSearchHistory(term)\n }\n }\n }\n\n closeModal() {\n if (this.props.closeMenu) {\n this.props.closeMenu()\n }\n }\n\n componentDidUpdate(prevProps: AutoCompleteProps) {\n if (!this.shouldUpdate(prevProps)) {\n return\n }\n\n this.addTermToHistory()\n this.fitAutocompleteInWindow()\n\n const { inputValue } = this.props\n\n this.setState({\n dynamicTerm: inputValue,\n queryFromHover: undefined,\n })\n\n if (inputValue === null || inputValue === '') {\n this.updateTopSearches()\n this.updateHistory()\n\n this.setState({\n suggestionItems: [],\n products: [],\n })\n } else {\n this.updateSuggestions()\n .then(() => {\n this.fitAutocompleteInWindow()\n\n return this.updateProducts(inputValue)\n })\n .then(() => this.fitAutocompleteInWindow())\n }\n }\n\n highlightTerm(label: string, query: string) {\n const splittedLabel = label.split(query)\n\n return (\n <>\n {splittedLabel.map((str: string, index: number) => {\n return (\n <>\n {str}\n {index !== splittedLabel.length - 1 ? (\n <span className=\"b\">{query}</span>\n ) : null}\n </>\n )\n })}\n </>\n )\n }\n\n async updateSuggestions() {\n const result = await this.client.suggestionSearches(this.props.inputValue)\n const { searches } = result.data.autocompleteSearchSuggestions\n const { maxSuggestedTerms = MAX_SUGGESTED_TERMS_DEFAULT } = this.props\n\n const items = searches.slice(0, maxSuggestedTerms).map(query => {\n const attributes = query.attributes || []\n\n return {\n term: query.term,\n attributes: attributes.map(att => ({\n label: att.labelValue,\n value: att.value,\n link: `/${query.term}/${att.value}/?map=ft,${att.key}`,\n groupValue: query.term,\n key: att.key,\n })),\n }\n })\n\n const suggestionItems: Item[] = items.map(suggestion => ({\n label: this.highlightTerm(\n suggestion.term.toLowerCase(),\n this.props.inputValue.toLocaleLowerCase()\n ),\n value: suggestion.term,\n groupValue: suggestion.term,\n link: `/${suggestion.term}?map=ft`,\n attributes: suggestion.attributes,\n }))\n\n this.setState({ suggestionItems })\n }\n\n async updateProducts(itemTerm: string) {\n const term = itemTerm\n\n const {\n __unstableProductOrigin,\n __unstableProductOriginVtex = false,\n simulationBehavior = 'default',\n hideUnavailableItems = false,\n orderBy,\n } = this.props\n\n const { queryFromHover } = this.state\n\n if (!term) {\n this.setState({\n products: [],\n totalProducts: 0,\n })\n\n return\n }\n\n if (__unstableProductOrigin) {\n console.warn(\n 'The prop `__unstableProductOrigin` has been deprecated. Use the boolean prop `__unstableProductOriginVtex` instead.'\n )\n }\n\n this.setState({\n isProductsLoading: true,\n })\n\n const session = await getSession(this.props.runtime.rootPath)\n const shippingOptions =\n session?.map((item: Record<string, string>) => item.value) ?? []\n\n const advertisementOptions: AdvertisementOptions = {\n showSponsored: true,\n sponsoredCount: 2,\n repeatSponsoredProducts: false,\n advertisementPlacement: 'autocomplete',\n }\n\n const result = await this.client.suggestionProducts(\n term,\n queryFromHover ? queryFromHover.key : undefined,\n queryFromHover ? queryFromHover.value : undefined,\n __unstableProductOrigin === 'VTEX' || __unstableProductOriginVtex,\n simulationBehavior,\n hideUnavailableItems,\n orderBy,\n this.props.maxSuggestedProducts || MAX_SUGGESTED_PRODUCTS_DEFAULT,\n shippingOptions,\n advertisementOptions\n )\n\n if (!queryFromHover) {\n const { count, operator, misspelled } = result.data.productSuggestions\n\n handleAutocompleteSearch(\n this.props.push,\n operator,\n misspelled,\n count,\n term\n )\n }\n\n this.setState({\n isProductsLoading: false,\n })\n\n const { productSuggestions } = result.data\n\n const products = productSuggestions.products.slice(\n 0,\n this.getProductCount()\n )\n\n this.setState({\n products,\n totalProducts: productSuggestions.count,\n searchId: productSuggestions.searchId || '',\n })\n }\n\n async updateTopSearches() {\n const result = await this.client.topSearches()\n const { searches } = result.data.topSearches\n const { maxTopSearches = MAX_TOP_SEARCHES_DEFAULT } = this.props\n\n const topSearchedItems = searches.slice(0, maxTopSearches).map(\n (query, index) =>\n ({\n prefix: (\n <>\n {`${index + 1}`}\n <FormattedMessage id=\"store/ordinalNumber\" />\n </>\n ),\n value: query.term,\n label: query.term,\n link: `/${query.term}?map=ft`,\n } as Item)\n )\n\n this.setState({ topSearchedItems })\n }\n\n updateHistory() {\n const history = this.client\n .searchHistory()\n .slice(0, this.props.maxHistory || MAX_HISTORY_DEFAULT)\n .map((item: string) => {\n return {\n label: decodeUrlString(item),\n value: item,\n link: `/${item}?map=ft`,\n icon: <IconClock />,\n }\n })\n\n this.setState({\n history,\n })\n }\n\n handleItemHover = (item: Item | AttributeItem) => {\n if (instanceOfAttributeItem(item)) {\n this.setState({\n dynamicTerm: item.groupValue,\n queryFromHover: {\n key: item.key,\n value: item.value,\n },\n })\n this.updateProducts(item.groupValue)\n } else {\n this.setState({\n dynamicTerm: item.value,\n queryFromHover: {\n key: undefined,\n value: undefined,\n },\n })\n this.updateProducts(item.value)\n }\n }\n\n renderSuggestions() {\n const hasSuggestion =\n !!this.state.suggestionItems && this.state.suggestionItems.length > 0\n\n const titleMessage = hasSuggestion ? (\n <FormattedMessage id=\"store/suggestions\" />\n ) : (\n <FormattedMessage id=\"store/emptySuggestion\" />\n )\n\n return (\n <ItemList\n title={titleMessage}\n items={this.state.suggestionItems || []}\n modifier=\"suggestion\"\n showTitle={!hasSuggestion || !this.props.hideTitles}\n onItemHover={this.handleItemHover}\n showTitleOnEmpty={this.props.maxSuggestedTerms !== 0}\n onItemClick={(value, position) => {\n handleItemClick(\n this.props.push,\n this.props.runtime.page,\n EventType.SearchSuggestionClick\n )(value, position)\n this.closeModal()\n }}\n customPage={this.props.customPage}\n closeModal={() => this.closeModal()}\n />\n )\n }\n\n contentWhenQueryIsEmpty() {\n return (\n <div\n className={stylesCss['history-and-top-wrapper']}\n style={{\n flexDirection: this.props.historyFirst ? 'row-reverse' : 'row',\n }}\n >\n {!this.props.isMobile ||\n (this.props.isMobile && !this.props.historyFirst) ||\n this.state.history.length === 0 ? (\n <ItemList\n modifier=\"top-search\"\n title={<FormattedMessage id=\"store/topSearches\" />}\n items={this.state.topSearchedItems || []}\n showTitle={!this.props.hideTitles}\n onItemClick={(value, position) => {\n handleItemClick(\n this.props.push,\n this.props.runtime.page,\n EventType.TopSearchClick\n )(value, position)\n this.closeModal()\n }}\n customPage={this.props.customPage}\n closeModal={() => this.closeModal()}\n />\n ) : null}\n\n {!this.props.isMobile ||\n (this.props.isMobile && this.props.historyFirst) ? (\n <ItemList\n modifier=\"history\"\n title={<FormattedMessage id=\"store/history\" />}\n items={this.state.history || []}\n showTitle={!this.props.hideTitles}\n onItemClick={(value, position) => {\n handleItemClick(\n this.props.push,\n this.props.runtime.page,\n EventType.HistoryClick\n )(value, position)\n this.closeModal()\n }}\n customPage={this.props.customPage}\n closeModal={() => this.closeModal()}\n />\n ) : null}\n </div>\n )\n }\n\n contentWhenQueryIsNotEmpty() {\n const { products, totalProducts, isProductsLoading, searchId } = this.state\n const { hideTitles, push, runtime, inputValue } = this.props\n const inputValueEncoded = encodeUrlString(inputValue)\n\n return (\n <>\n {this.renderSuggestions()}\n <TileList\n term={inputValueEncoded || ''}\n customPage={this.props.customPage}\n shelfProductCount={this.getProductCount()}\n title={\n <FormattedMessage\n id=\"store/suggestedProducts\"\n values={{ term: inputValue }}\n />\n }\n products={products || []}\n showTitle={!hideTitles}\n totalProducts={totalProducts || 0}\n layout={this.getProductLayout()}\n isLoading={isProductsLoading}\n onProductClick={(id, position, term) => {\n handleProductClick(push, runtime.page)(id, position, term)\n this.closeModal()\n }}\n onSeeAllClick={term => {\n handleSeeAllClick(push, runtime.page)(term)\n this.closeModal()\n }}\n HorizontalProductSummary={this.props.HorizontalProductSummary}\n searchId={searchId}\n />\n </>\n )\n }\n\n renderContent() {\n const query = this.props.inputValue.trim()\n\n return query && query !== ''\n ? this.contentWhenQueryIsNotEmpty()\n : this.contentWhenQueryIsEmpty()\n }\n\n hasContent() {\n const { topSearchedItems, suggestionItems, history, products } = this.state\n\n return (\n topSearchedItems.length > 0 ||\n suggestionItems.length > 0 ||\n history.length > 0 ||\n products.length > 0\n )\n }\n\n getProductLayout = () => {\n const { productLayout, isMobile } = this.props\n\n if (typeof productLayout !== 'undefined') {\n return productLayout\n }\n\n return isMobile ? ProductLayout.Horizontal : ProductLayout.Vertical\n }\n\n getProductCount() {\n const {\n customBreakpoints,\n isMobile,\n maxSuggestedProducts = MAX_SUGGESTED_PRODUCTS_DEFAULT,\n } = this.props\n\n if (!window || isMobile || !customBreakpoints) {\n return maxSuggestedProducts\n }\n\n const windowWidth = window.innerWidth\n\n if (\n !customBreakpoints.md ||\n !customBreakpoints.lg ||\n !customBreakpoints.xlg\n ) {\n return maxSuggestedProducts\n }\n\n if (windowWidth >= customBreakpoints.xlg.width) {\n return customBreakpoints.xlg.maxSuggestedProducts\n }\n\n if (windowWidth >= customBreakpoints.lg.width) {\n return customBreakpoints.lg.maxSuggestedProducts\n }\n\n if (windowWidth >= customBreakpoints.md.width) {\n return customBreakpoints.md.maxSuggestedProducts\n }\n\n return maxSuggestedProducts\n }\n\n render() {\n const hiddenClass =\n !this.props.isOpen || !this.hasContent()\n ? stylesCss['biggy-js-container--hidden']\n : ''\n\n return (\n <div\n className={stylesCss['biggy-autocomplete-wrapper']}\n style={{\n width: this.props.autocompleteWidth\n ? `${this.props.autocompleteWidth}vw`\n : undefined,\n }}\n >\n <section\n ref={this.autocompleteRef}\n // tslint:disable-next-line: max-line-length\n className={`${stylesCss['biggy-autocomplete']} ${hiddenClass} w-100`}\n style={{\n flexDirection:\n this.getProductLayout() === ProductLayout.Horizontal\n ? 'column'\n : 'row',\n }}\n >\n <ProductListProvider listName=\"autocomplete-result-list\">\n {this.renderContent()}\n {this.props.isMobile ? (\n <button\n onClick={() => this.closeModal()}\n className={stylesCss['close-btn']}\n >\n <IconClose />\n </button>\n ) : null}\n </ProductListProvider>\n </section>\n </div>\n )\n }\n}\n\nexport default withPixel(withDevice(withApollo(withRuntime(AutoComplete))))\n\n```" } ]
code_search_f7cc0aa2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/components/Autocomplete/styles.css from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.biggy-autocomplete-wrapper {\n width: 50vw;\n}\n\n.biggy-autocomplete {\n position: absolute;\n transition: opacity 0.15s ease-in 0.05s, max-height 0.3s ease-out,\n padding 0.6s ease-out;\n padding: 20px 0 10px 0;\n max-height: 630px;\n box-shadow: 0 5px 7px rgba(0, 0, 0, 0.2);\n background: #fff;\n overflow: auto;\n display: flex;\n}\n\n.close-btn {\n cursor: pointer;\n position: absolute;\n top: 10px;\n right: 10px;\n background: none;\n border: none;\n outline: none;\n}\n\n.history-and-top-wrapper {\n display: flex;\n flex: 1;\n}\n\n.biggy-js-container--hidden {\n opacity: 0;\n max-height: 0 !important;\n padding: 0;\n}\n\n```" } ]
code_search_021fbfd3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/components/Suggestions/index.tsx from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport { Link } from 'vtex.render-runtime'\nimport { FormattedMessage } from 'react-intl'\nimport searchSuggestionsQuery from 'vtex.store-resources/QuerySearchSuggestions'\nimport { useSearchPage } from 'vtex.search-page-context/SearchPageContext'\nimport { useQuery } from 'react-apollo'\n\nimport styles from './styles.css'\n\ninterface SuggestionsProps {\n customPage: string\n}\n\ninterface Suggestion {\n searches: Array<{\n term: string\n count: number\n }>\n}\n\nconst Suggestions: FC<SuggestionsProps> = ({ customPage }) => {\n const {\n searchQuery: {\n variables: { fullText },\n },\n } = useSearchPage()\n\n if (!fullText) {\n return null\n }\n\n const { loading, data } = useQuery(searchSuggestionsQuery, {\n variables: {\n fullText,\n },\n })\n\n const suggestion: Suggestion | undefined = data?.searchSuggestions\n\n if (loading || !suggestion || suggestion.searches.length === 0) {\n return null\n }\n\n return (\n <div\n className={`${styles.suggestionListWrapper} flex flex-row items-center`}\n >\n <p className={`${styles.suggestionsListPrefix} mr5 b f7 ma0`}>\n <FormattedMessage id=\"store/searchSuggestions\" />\n {': '}\n </p>\n <ul className={`${styles.suggestionsList} list flex pa0 ma0`}>\n {suggestion.searches.map(search => (\n <li className={styles.suggestionsListItem} key={search.term}>\n <Link\n className={`${styles.suggestionsListLink} link f7`}\n page={customPage || 'store.search'}\n query=\"map=ft\"\n params={{\n term: search.term,\n }}\n >\n {search.term}\n </Link>\n </li>\n ))}\n </ul>\n </div>\n )\n}\n\nexport default Suggestions\n\n```" } ]
code_search_03575dbe
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/components/Suggestions/styles.css from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.suggestionsList li:not(:first-child):before {\n content: \"-\";\n margin: 0 15px;\n}\n\n.suggestionsListLink {}\n\n.suggestionsListPrefix {}\n\n.suggestionListWrapper {}\n\n.suggestionsListItem {}\n\n```" } ]
code_search_64d25f6f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/components/DidYouMean/index.tsx from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { Link } from 'vtex.render-runtime'\nimport { useCssHandles } from 'vtex.css-handles'\nimport correctionQuery from 'vtex.store-resources/QueryCorrection'\nimport { useSearchPage } from 'vtex.search-page-context/SearchPageContext'\nimport { useQuery } from 'react-apollo'\nimport { FormattedMessage } from 'react-intl'\nimport React from 'react'\n\ninterface Correction {\n correction: boolean\n misspelled: boolean\n text: string\n highlighted: string\n}\n\nconst CSS_HANDLES = ['didYouMeanPrefix', 'didYouMeanTerm']\n\nconst DidYouMean = () => {\n const handles = useCssHandles(CSS_HANDLES)\n\n const {\n searchQuery: {\n variables: { fullText },\n },\n } = useSearchPage()\n\n const { loading, data } = useQuery(correctionQuery, {\n variables: {\n fullText,\n },\n })\n\n const correction: Correction = data?.correction?.correction\n\n return !loading && correction?.correction ? (\n <p>\n <span className={`${handles.didYouMeanPrefix} c-muted-1`}>\n <FormattedMessage id=\"store/didYouMean\" />\n {': '}\n </span>\n <span className={handles.didYouMeanTerm}>\n <Link className=\"link\" to={`/${correction.text}?map=ft`}>\n {correction.text}\n </Link>\n </span>\n </p>\n ) : null\n}\n\nexport default DidYouMean\n\n```" } ]
code_search_08c5bba4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/components/Banner/index.tsx from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable no-restricted-syntax */\nimport { useCssHandles } from 'vtex.css-handles'\nimport bannersQuery from 'vtex.store-resources/QueryBanners'\nimport { useSearchPage } from 'vtex.search-page-context/SearchPageContext'\nimport { useQuery } from 'react-apollo'\nimport React from 'react'\n\ninterface ElasticBanner {\n id: string\n name: string\n area: string\n html: string\n}\n\n// eslint-disable-next-line no-shadow\nenum HorizotalAlignment {\n Left = 'left',\n Right = 'right',\n Center = 'center',\n}\n\ninterface BannerProps {\n area: string\n blockClass?: string\n horizontalAlignment?: HorizotalAlignment\n}\n\ninterface SelectedFacet {\n key: string\n value: string\n}\n\nconst getAlignmentClass = (alignment: HorizotalAlignment | undefined) => {\n switch (alignment) {\n case 'left':\n return 'justify-start'\n\n case 'right':\n return 'justify-end'\n\n default:\n return 'justify-center'\n }\n}\n\nconst Banner = (props: BannerProps) => {\n const { area, horizontalAlignment } = props\n\n const CSS_HANDLES = ['searchBanner']\n const handles = useCssHandles(CSS_HANDLES)\n\n const { searchQuery } = useSearchPage()\n\n if (!searchQuery) {\n return null\n }\n\n const {\n variables: { fullText, selectedFacets },\n } = searchQuery\n\n const { loading, data } = useQuery(bannersQuery, {\n variables: {\n fullText,\n selectedFacets: selectedFacets.filter(\n (facet: SelectedFacet) => facet.key !== 'ft'\n ),\n },\n })\n\n if (loading || !data) {\n return null\n }\n\n const banners = data?.banners?.banners || []\n\n const selectedBanner = banners.find(\n (banner: ElasticBanner) => banner.area === area\n )\n\n if (!selectedBanner) {\n return null\n }\n\n const className = `flex ${getAlignmentClass(horizontalAlignment)} ${\n handles.searchBanner\n }`\n\n return (\n <div\n className={className}\n dangerouslySetInnerHTML={{ __html: selectedBanner.html }}\n />\n )\n}\n\nexport default Banner\n\n```" } ]
code_search_9c9c0e1b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/components/Autocomplete/components/ItemList/styles.css from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.itemList {\n flex: 1;\n vertical-align: top;\n font-family: Open Sans, Roboto, sans-serif;\n}\n\n.itemListList {\n padding: 0;\n margin: 0;\n}\n\n.itemListList li {\n padding: 0;\n margin: 0;\n}\n\n.itemList ol, .itemList ul {\n padding: 0;\n list-style: none;\n}\n\n.itemListTitle {\n margin-bottom: 5px;\n padding: 0 20px;\n font-size: 14px;\n font-weight: 600;\n text-transform: uppercase;\n}\n\n.itemListItem a, .itemListItem a:hover {\n display: block;\n height: 35px;\n line-height: 35px;\n padding: 0 20px;\n font-size: 13px;\n text-decoration: none;\n max-width: 100%;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.itemListItem a:hover {\n background: #eee;\n}\n\n.itemListSubItem a {\n padding: 0 30px;\n font-weight: 600;\n text-transform: capitalize;\n white-space: nowrap;\n text-overflow: ellipsis;\n margin-right: 16px;\n overflow: hidden;\n}\n\n.itemListSubItemLink {}\n\n.itemListPrefix, .itemListIcon {\n display: inline-block;\n width: 30px;\n font-weight: 600;\n color: #999;\n}\n\n.itemListLink {}\n\n.itemListLinkTitle {}\n\n.itemList--suggestion {}\n\n.itemList--history {}\n\n.itemList--top-search {\n width: 100%;\n}\n\n@media only screen and (min-width: 1025px) {\n .itemList {\n overflow: hidden;\n }\n}\n\n```" } ]
code_search_cfc55523
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/components/Autocomplete/components/ItemList/Attribute.tsx from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { Link } from 'vtex.render-runtime'\n\nimport { Item } from './types'\nimport stylesCss from './styles.css'\n\ninterface IAttributeProps {\n item: Item\n onMouseOver: (ee: React.MouseEvent | React.FocusEvent, item: Item) => void\n onMouseOut: () => void\n closeModal: () => void\n onItemClick: (term: string, position: number) => void\n}\n\nconst Attribute = (props: IAttributeProps) =>\n props.item?.attributes ? (\n <ul className={stylesCss.itemListSubList}>\n {props.item.attributes.map((attribute, index) => (\n <li\n key={index}\n className={`${stylesCss.itemListSubItem} c-on-base pointer`}\n onMouseOver={e => props.onMouseOver(e, attribute)}\n onFocus={e => props.onMouseOver(e, attribute)}\n onMouseOut={() => props.onMouseOut()}\n onBlur={() => props.onMouseOut()}\n >\n <Link\n className={`${stylesCss.itemListSubItemLink} c-on-base`}\n to={`/${props.item.value}/${attribute.value}`}\n query={`map=ft,${attribute.key}`}\n onClick={() => {\n props.closeModal()\n props.onItemClick(attribute.label, index)\n }}\n >\n {attribute.label}\n </Link>\n </li>\n ))}\n </ul>\n ) : null\n\nexport default Attribute\n\n```" } ]
code_search_64ff0069
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/components/Autocomplete/components/ItemList/types.ts from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport interface Item {\n label: string | JSX.Element\n value: string\n link: string\n attributes?: AttributeItem[]\n icon?: JSX.Element\n prefix?: string | JSX.Element\n}\n\nexport interface AttributeItem {\n groupValue: string\n value: string\n label: string\n link: string\n key: string\n}\n\nexport function instanceOfAttributeItem(object: any): object is AttributeItem {\n return 'groupValue' in object\n}\n\n```" } ]
code_search_05e38a3f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/components/Autocomplete/components/ItemList/ItemList.tsx from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/explicit-member-accessibility */\nimport * as React from 'react'\nimport { Link } from 'vtex.render-runtime'\n\nimport { Item, AttributeItem } from './types'\nimport stylesCss from './styles.css'\nimport Attribute from './Attribute'\n\ninterface ItemListProps {\n title: string | JSX.Element\n items: Item[]\n showTitle: boolean\n onItemClick: (term: string, position: number) => void\n modifier?: string\n onItemHover?: (item: Item | AttributeItem) => void\n showTitleOnEmpty?: boolean\n customPage?: string\n closeModal: () => void\n}\n\ninterface ItemListState {\n currentTimeoutId: ReturnType<typeof setTimeout> | null\n}\n\nexport class ItemList extends React.Component<ItemListProps> {\n public readonly state: ItemListState = {\n currentTimeoutId: null,\n }\n\n handleMouseOver = (e: React.MouseEvent | React.FocusEvent, item: Item) => {\n e.stopPropagation()\n\n const { currentTimeoutId } = this.state\n\n if (!currentTimeoutId) {\n const timeoutId = setTimeout(() => {\n this.props.onItemHover ? this.props.onItemHover(item) : null\n this.setState({ currentTimeoutId: null })\n }, 100)\n\n this.setState({ currentTimeoutId: timeoutId })\n }\n }\n\n handleMouseOut = () => {\n const { currentTimeoutId } = this.state\n\n if (currentTimeoutId) {\n clearTimeout(currentTimeoutId)\n this.setState({ currentTimeoutId: null })\n }\n }\n\n render() {\n if (this.props.items.length === 0 && !this.props.showTitleOnEmpty) {\n return null\n }\n\n const modifier = this.props.modifier\n ? stylesCss[`itemList--${this.props.modifier}`]\n : ''\n\n return (\n <article className={`${stylesCss.itemList} ${modifier}`}>\n {this.props.showTitle ? (\n <p className={`${stylesCss.itemListTitle} c-on-base`}>\n {this.props.title}\n </p>\n ) : null}\n {this.props.items.length > 0 && (\n <ol className={stylesCss.itemListList}>\n {this.props.items.map((item, index) => {\n return (\n <li\n key={item.value}\n className={`${stylesCss.itemListItem}`}\n onMouseOver={e => this.handleMouseOver(e, item)}\n onFocus={e => this.handleMouseOver(e, item)}\n onMouseOut={() => this.handleMouseOut()}\n onBlur={() => this.handleMouseOut()}\n >\n <Link\n page={this.props.customPage ?? 'store.search'}\n params={{\n term: item.value,\n }}\n query={`map=ft&_q=${item.value}`}\n onClick={() => this.props.onItemClick(item.value, index)}\n className={stylesCss.itemListLink}\n >\n {item.icon ? (\n <span className={stylesCss.itemListIcon}>\n {item.icon}\n </span>\n ) : null}\n\n {item.prefix ? (\n <span className={stylesCss.itemListPrefix}>\n {item.prefix}\n </span>\n ) : null}\n\n <span\n className={`${stylesCss.itemListLinkTitle} c-on-base`}\n >\n {item.label}\n </span>\n </Link>\n <Attribute\n item={item}\n onMouseOver={this.handleMouseOver}\n onMouseOut={this.handleMouseOut}\n closeModal={this.props.closeModal}\n onItemClick={this.props.onItemClick}\n />\n </li>\n )\n })}\n </ol>\n )}\n </article>\n )\n }\n}\n\n```" } ]
code_search_2c847d87
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/components/Autocomplete/components/CustomListItem/styles.css from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n\n.clearLink {}\n\n.element {\n position: relative;\n}\n\n.imageContainer {\n max-height: 80px;\n}\n\n.image {}\n\n.information {}\n\n.productNameContainer {}\n\n.productBrand {}\n\n.priceContainer {}\n\n.priceOld {}\n\n.priceNew {}\n\n.discount {\n background: rgb(228, 1, 46);\n color: #fff;\n position: absolute;\n top: 1px;\n left: 1px;\n font-size: 14px;\n}\n```" } ]
code_search_c9c73775
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/components/Autocomplete/components/CustomListItem/CustomListItem.tsx from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable jsx-a11y/alt-text */\nimport React, { FC } from 'react'\nimport { Link } from 'vtex.render-runtime'\nimport { SellingPrice, ListPrice } from 'vtex.product-price'\nimport { ProductContextProvider } from 'vtex.product-context'\n\nimport styles from './styles.css'\n\ninterface CustomListItemProps {\n product: Product\n onClick: () => void\n}\n\nconst CustomListItem: FC<CustomListItemProps> = ({ product, onClick }) => {\n const sku = product?.sku\n const taxPercentage = sku?.sellers?.[0]?.commertialOffer?.taxPercentage\n\n return (\n <div>\n <Link\n params={{\n slug: product?.linkText,\n id: product?.productId,\n }}\n page=\"store.product\"\n className=\"no-underline\"\n onClick={onClick}\n >\n <article\n className={`${styles.element} flex flex-row justify-start items-center pa3 bg-animate hover-bg-light-gray`}\n >\n <div className={`${styles.imageContainer} h3`}>\n <img\n className={`${styles.image} h-100 w-auto mw-none`}\n src={sku?.image?.imageUrl}\n />\n </div>\n <div\n className={`${styles.information} flex flex-column justify-between items-start ml4`}\n >\n <div className={styles.productNameContainer}>\n <span className={`${styles.productBrand} f5 c-on-base`}>\n {product.productName}\n </span>\n </div>\n <div className={styles.priceContainer}>\n <ProductContextProvider\n product={product}\n query={{\n skuId: sku?.itemId,\n }}\n >\n <span className=\"db f7 c-muted-2\">\n <ListPrice\n message={\n taxPercentage ? '{listPriceWithTax}' : '{listPriceValue}'\n }\n />\n </span>\n <span className=\"dib t-small c-muted-2\">\n <SellingPrice\n message={\n taxPercentage\n ? '{sellingPriceWithTax}'\n : '{sellingPriceValue}'\n }\n />\n </span>\n </ProductContextProvider>\n </div>\n </div>\n </article>\n </Link>\n </div>\n )\n}\n\nexport default CustomListItem\n\n```" } ]
code_search_88c8d855
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/components/Autocomplete/components/TileList/TileList.tsx from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport { ExtensionPoint, Link } from 'vtex.render-runtime'\nimport { Spinner } from 'vtex.styleguide'\nimport ProductSummary from 'vtex.product-summary/ProductSummaryCustom'\nimport { FormattedMessage } from 'react-intl'\n\nimport styles from './styles.css'\nimport CustomListItem from '../CustomListItem/CustomListItem'\nimport { ProductLayout } from '../..'\n\ninterface TileListProps {\n term: string\n title: string | JSX.Element\n customPage?: string\n products: any[]\n showTitle: boolean\n shelfProductCount: number\n totalProducts: number\n layout: ProductLayout\n isLoading: boolean\n onProductClick: (product: string, position: number, term: string) => void\n onSeeAllClick: (term: string) => void\n HorizontalProductSummary?: React.ComponentType<{\n product: Product\n placement: string\n actionOnClick: () => void\n }>\n searchId: string\n}\n\nconst AUTOCOMPLETE_PLACEMENT = 'autocomplete'\n\nconst TileList: FC<TileListProps> = ({\n term,\n title,\n products,\n showTitle,\n totalProducts,\n layout,\n isLoading,\n onProductClick,\n onSeeAllClick,\n HorizontalProductSummary,\n customPage,\n searchId,\n}) => {\n if (products.length === 0 && !isLoading) {\n return null\n }\n\n return (\n <section\n className={styles.tileList}\n data-af-element={searchId ? 'search-autocomplete' : undefined}\n data-af-onimpression={searchId ? true : undefined}\n data-af-search-id={searchId}\n >\n {showTitle ? (\n <p className={`${styles.tileListTitle} c-on-base`}>{title}</p>\n ) : null}\n {isLoading ? (\n <div className={styles.tileListSpinner}>\n <Spinner />\n </div>\n ) : (\n <>\n <ul\n className={styles.tileListList}\n style={{\n flexDirection:\n layout === ProductLayout.Horizontal ? 'column' : 'row',\n }}\n >\n {products.map((product, index: number) => {\n const productSummary: Product = ProductSummary.mapCatalogProductToProductSummary(\n product\n )\n\n return (\n <li\n key={product.productId}\n className={styles.tileListItem}\n data-af-element={searchId ? 'search-autocomplete' : undefined}\n data-af-onclick={\n searchId && product.productId ? true : undefined\n }\n data-af-search-id={searchId}\n data-af-product-position={index + 1}\n data-af-product-id={product.productId}\n data-af-product-specification={product.specification}\n >\n {layout === ProductLayout.Horizontal ? (\n HorizontalProductSummary ? (\n <HorizontalProductSummary\n product={productSummary}\n placement={AUTOCOMPLETE_PLACEMENT}\n actionOnClick={() => {\n onProductClick(productSummary.productId, index, term)\n }}\n />\n ) : (\n <CustomListItem\n product={productSummary}\n onClick={() => {\n onProductClick(productSummary.productId, index, term)\n }}\n />\n )\n ) : (\n <ExtensionPoint\n id=\"product-summary\"\n product={productSummary}\n placement={AUTOCOMPLETE_PLACEMENT}\n actionOnClick={() => {\n onProductClick(productSummary.productId, index, term)\n }}\n />\n )}\n </li>\n )\n })}\n </ul>\n\n <footer className={styles.tileListFooter}>\n {totalProducts > 0 ? (\n <Link\n query={`map=ft&_q=${term}`}\n params={{\n term,\n }}\n page={customPage || 'store.search'}\n className={styles.tileListSeeMore}\n onClick={() => onSeeAllClick(term)}\n >\n <FormattedMessage\n id=\"store/seeMore\"\n values={{ count: totalProducts }}\n />\n </Link>\n ) : null}\n </footer>\n </>\n )}\n </section>\n )\n}\n\nexport default TileList\n\n```" } ]
code_search_b6ca5c40
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search/react/components/Autocomplete/components/TileList/styles.css from the search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.tileList {\n flex: 2;\n vertical-align: top;\n border-left: 1px solid #eee;\n}\n\n.tileListList {}\n\n.tileList ul {\n padding: 0;\n display: flex;\n}\n\n.tileListTitle {\n margin-bottom: 5px;\n padding: 0 20px;\n font-size: 14px;\n font-weight: 600;\n text-transform: uppercase;\n}\n\n.tileListItem {\n display: flex;\n flex: 1;\n}\n\n.tileListSeeMore {\n display: block;\n height: 60px;\n line-height: 60px;\n font-size: 13px;\n color: #787878;\n text-align: center;\n}\n\n.tileListSpinner {\n display: flex;\n height: 80%;\n justify-content: center;\n align-items: center;\n}\n\n.tileListFooter {}\n\n@media only screen and (min-width: 1024px) {\n .tileList {\n display: inline-block;\n }\n}\n\n```" } ]
code_brightedge-integration_d8c26af2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of brightedge-integration/docs/README.md from the brightedge-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/vtex-apps/brightedge-integration) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n\n[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)\n\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\n# BrightEdge\n\nThis app implements BrightEdge AutoPilot - Self Connecting Pages within VTEX IO. The app provides a block which can be placed in your store layout and which will be populated with dynamic link content designed to improve SEO.\n\n## Configuration\n\n1. [Install](https://vtex.io/docs/recipes/store/installing-an-app) `vtex.brightedge-integration` in the desired account.\n2. In your account's admin dashboard, go to `Apps > My Apps` and then click the box for `BrightEdge`.\n3. Enter your BrightEdge `Account ID` in the provided settings field and then click Save.\n4. In your `store-theme`, add BrightEdge as a dependency:\n\n```json\n\"dependencies\": {\n \"vtex.brightedge-integration\": \"0.x\"\n }\n```\n\n5. In your `store-theme`'s `store/` folder, place the `brightedge` block in the desired location (BrightEdge recommends displaying their link content in the store's footer). For example:\n\n```json\n\"footer-layout.desktop\": {\n \"children\": [\n \"brightedge\",\n \"flex-layout.row#footer-1-desktop\",\n \"flex-layout.row#footer-2-desktop\",\n \"flex-layout.row#footer-3-desktop\"\n ]\n },\n```\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n```" } ]
code_brightedge-integration_a99e47eb
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of brightedge-integration/react/index.tsx from the brightedge-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FunctionComponent, useState, useEffect } from 'react'\n\nimport useScript from './hooks/useScriptLoader'\n\ninterface Props {\n appSettings: any\n}\n\nconst BrightEdgeScript: FunctionComponent<{ accountId: string }> = ({\n accountId,\n}) => {\n const [loaded, error] = useScript(\n `//cdn.bc0a.com/autopilot/${accountId}/autopilot_sdk.js`\n )\n\n if (!loaded || error) return null\n return null\n}\n\nconst BrightEdge: FunctionComponent<Props> = ({ appSettings }) => {\n const { accountId } = appSettings\n const [shouldLoadScript, setShouldLoadScript] = useState(false)\n\n useEffect(() => {\n setShouldLoadScript(true)\n }, [])\n\n if (!accountId) return null\n return (\n <div>\n <div className=\"be-ix-link-block\" />\n {shouldLoadScript ? <BrightEdgeScript accountId={accountId} /> : null}\n </div>\n )\n}\n\nexport default BrightEdge\n\n```" } ]
code_brightedge-integration_e111eaae
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of brightedge-integration/react/package.json from the brightedge-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"brightedge-integration\",\n \"version\": \"0.0.2\",\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"apollo-client\": \"^2.6.8\",\n \"react\": \"^16.12.0\",\n \"react-apollo\": \"^3.1.3\",\n \"react-dom\": \"^16.12.0\",\n \"react-intl\": \"^3.12.0\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^3.1.3\",\n \"@types/jest\": \"^25.1.4\",\n \"@types/node\": \"^13.9.8\",\n \"@types/react\": \"^16.9.31\",\n \"@vtex/test-tools\": \"^3.1.0\",\n \"@vtex/tsconfig\": \"^0.4.4\",\n \"apollo-cache-inmemory\": \"^1.6.5\",\n \"graphql\": \"^14.6.0\",\n \"prop-types\": \"^15.7.2\",\n \"typescript\": \"3.8.3\",\n \"vtex.pixel-interfaces\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.pixel-interfaces@1.1.1/public/_types/react\",\n \"vtex.product-context\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.product-context@0.8.0/public/@types/vtex.product-context\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.111.0/public/@types/vtex.render-runtime\",\n \"vtex.store\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store@2.99.1/public/@types/vtex.store\"\n }\n}\n\n```" } ]
code_brightedge-integration_328d7751
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of brightedge-integration/store/interfaces.json from the brightedge-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"brightedge\": {\n \"component\": \"index\"\n }\n}\n\n```" } ]
code_brightedge-integration_768a3d3e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of brightedge-integration/react/__tests__/index.test.tsx from the brightedge-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\ndescribe('Orders List Scenarios', () => {\n it('should work', () => {\n expect(1).toBe(1)\n })\n})\n\n```" } ]
code_brightedge-integration_3c3fb438
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of brightedge-integration/react/hooks/useScriptLoader.tsx from the brightedge-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { useEffect, useState } from 'react'\n\nconst cachedScripts: string[] = []\nfunction useScript(src: string) {\n // Keeping track of script loaded and error state\n const [state, setState] = useState({\n loaded: false,\n error: false,\n })\n\n useEffect(() => {\n // If cachedScripts array already includes src that means another instance ...\n // ... of this hook already loaded this script, so no need to load again.\n if (cachedScripts.includes(src)) {\n setState({\n loaded: true,\n error: false,\n })\n return\n }\n cachedScripts.push(src)\n\n // Create script\n const script = document.createElement('script')\n script.src = src\n\n // Script event listener callbacks for load and error\n const onScriptLoad = () => {\n setState({\n loaded: true,\n error: false,\n })\n }\n\n const onScriptError = () => {\n // Remove from cachedScripts we can try loading again\n const index = cachedScripts.indexOf(src)\n if (index >= 0) cachedScripts.splice(index, 1)\n script.remove()\n\n setState({\n loaded: true,\n error: true,\n })\n }\n\n script.addEventListener('load', onScriptLoad)\n script.addEventListener('error', onScriptError)\n\n // Add script to document head\n\n const [t] = document.getElementsByTagName('script')\n t.parentNode?.insertBefore(script, t)\n\n // Remove event listeners on cleanup\n return () => {\n script.removeEventListener('load', onScriptLoad)\n script.removeEventListener('error', onScriptError)\n }\n }, [src])\n\n return [state.loaded, state.error]\n}\n\nexport default useScript\n\n```" } ]
code_storefront-permissions-components_bb068c92
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/messages/nl.json from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"B2B-informatie\",\n \"admin/storefront-permissions.button.cancel\": \"Annuleren\",\n \"admin/storefront-permissions.button.delete\": \"B2B-info verwijderen\",\n \"admin/storefront-permissions.button.save\": \"Opslaan\",\n \"admin/storefront-permissions.description\": \"Rollen en gebruikersbeheer\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, rollen, profielen\",\n \"admin/storefront-permissions.navigation.label\": \"Storefront-machtigingen\",\n \"admin/storefront-permissions.required\": \"Vereist\",\n \"admin/storefront-permissions.tab.new.button\": \"Nieuwe aanmaken\",\n \"admin/storefront-permissions.tab.roles\": \"Rollen\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"Kan geen apps vinden die verbonden zijn met de storefront-machtigingen\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"Rol\",\n \"admin/storefront-permissions.tab.users\": \"Gebruikers\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"Kan imiteren\",\n \"admin/storefront-permissions.tab.users.email.label\": \"E-mailadres\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"Organisatie\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"Kostencentrum\",\n \"admin/storefront-permissions.tab.users.error\": \"Fout bij opslaan B2B-info\",\n \"admin/storefront-permissions.tab.users.name.label\": \"Naam\",\n \"admin/storefront-permissions.tab.users.success\": \"B2B-info opgeslagen\",\n \"admin/storefront-permissions.title\": \"Storefront-machtigingen\",\n \"admin/storefront-permissions.alert-pick\": \"U moet een kostencentrum kiezen voordat u wijzigingen kunt opslaan\",\n \"admin/storefront-permissions.searchOrganizations\": \"Organisaties zoeken...\"\n}\n\n```" } ]
code_storefront-permissions-components_772ec0d3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/messages/ja.json from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"B2B 情報\",\n \"admin/storefront-permissions.button.cancel\": \"キャンセル\",\n \"admin/storefront-permissions.button.delete\": \"B2B 情報を削除する\",\n \"admin/storefront-permissions.button.save\": \"保存\",\n \"admin/storefront-permissions.description\": \"役割およびユーザー管理\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, 役割, プロファイル\",\n \"admin/storefront-permissions.navigation.label\": \"店頭権限\",\n \"admin/storefront-permissions.required\": \"必須\",\n \"admin/storefront-permissions.tab.new.button\": \"新規作成\",\n \"admin/storefront-permissions.tab.roles\": \"役割\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"店頭権限に接続したアプリは見つかりませんでした\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"役割\",\n \"admin/storefront-permissions.tab.users\": \"ユーザー\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"偽装することができます\",\n \"admin/storefront-permissions.tab.users.email.label\": \"メール\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"組織\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"コストセンター\",\n \"admin/storefront-permissions.tab.users.error\": \"B2B 情報を保存する時にエラーが発生しました\",\n \"admin/storefront-permissions.tab.users.name.label\": \"名前\",\n \"admin/storefront-permissions.tab.users.success\": \"B2B 情報を保存しました\",\n \"admin/storefront-permissions.title\": \"店頭権限\",\n \"admin/storefront-permissions.alert-pick\": \"変更を保存する前にコストセンターを選択しなければなりません\",\n \"admin/storefront-permissions.searchOrganizations\": \"組織を検索…\"\n}\n\n```" } ]
code_storefront-permissions-components_f0ff02e1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/messages/pt.json from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"Informações B2B\",\n \"admin/storefront-permissions.button.cancel\": \"Cancelar\",\n \"admin/storefront-permissions.button.delete\": \"Remover informações B2B\",\n \"admin/storefront-permissions.button.save\": \"Salvar\",\n \"admin/storefront-permissions.description\": \"Gerenciamento de perfis de acesso e usuários\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, perfis de acesso, usuários\",\n \"admin/storefront-permissions.navigation.label\": \"Permissões da loja\",\n \"admin/storefront-permissions.required\": \"Obrigatório\",\n \"admin/storefront-permissions.tab.new.button\": \"Criar nova\",\n \"admin/storefront-permissions.tab.roles\": \"Perfis de acesso\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"Não foi possível encontrar nenhum app conectado às permissões da loja\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"Perfil de acesso\",\n \"admin/storefront-permissions.tab.users\": \"Usuários\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"Pode personificar\",\n \"admin/storefront-permissions.tab.users.email.label\": \"Email\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"Organização\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"Centro de custo\",\n \"admin/storefront-permissions.tab.users.error\": \"Erro ao salvar informações B2B\",\n \"admin/storefront-permissions.tab.users.name.label\": \"Nome\",\n \"admin/storefront-permissions.tab.users.success\": \"Informações B2B salvas\",\n \"admin/storefront-permissions.title\": \"Permissões da loja\",\n \"admin/storefront-permissions.alert-pick\": \"Você precisa selecionar um centro de custo antes de salvar as alterações\",\n \"admin/storefront-permissions.searchOrganizations\": \"Buscar organizações...\"\n}\n\n```" } ]
code_storefront-permissions-components_ce762a1c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/messages/en.json from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"B2B Information\",\n \"admin/storefront-permissions.button.cancel\": \"Cancel\",\n \"admin/storefront-permissions.button.delete\": \"Remove B2B Info\",\n \"admin/storefront-permissions.button.save\": \"Save\",\n \"admin/storefront-permissions.description\": \"Roles and User Management\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, Roles, Profiles\",\n \"admin/storefront-permissions.navigation.label\": \"Storefront Permissions\",\n \"admin/storefront-permissions.required\": \"Required\",\n \"admin/storefront-permissions.tab.new.button\": \"Create new\",\n \"admin/storefront-permissions.tab.roles\": \"Roles\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"Couldn't find any apps connected to the storefront permissions\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"Role\",\n \"admin/storefront-permissions.tab.users\": \"Users\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"Can impersonate\",\n \"admin/storefront-permissions.tab.users.email.label\": \"Email\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"Organization\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"Cost Center\",\n \"admin/storefront-permissions.tab.users.error\": \"Error saving B2B info\",\n \"admin/storefront-permissions.tab.users.name.label\": \"Name\",\n \"admin/storefront-permissions.tab.users.success\": \"B2B info saved\",\n \"admin/storefront-permissions.title\": \"Storefront Permissions\",\n \"admin/storefront-permissions.alert-pick\": \"You need to choose a cost center before saving changes\",\n \"admin/storefront-permissions.searchOrganizations\": \"Search organizations...\"\n}\n\n```" } ]
code_storefront-permissions-components_12e8a5a8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/messages/it.json from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"Informazioni B2B\",\n \"admin/storefront-permissions.button.cancel\": \"Annulla\",\n \"admin/storefront-permissions.button.delete\": \"Rimuovi informazioni B2B\",\n \"admin/storefront-permissions.button.save\": \"Salva\",\n \"admin/storefront-permissions.description\": \"Ruoli e gestione utenti\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, ruoli, profili\",\n \"admin/storefront-permissions.navigation.label\": \"Permessi del negozio\",\n \"admin/storefront-permissions.required\": \"Obbligatorio\",\n \"admin/storefront-permissions.tab.new.button\": \"Crea nuovo permesso\",\n \"admin/storefront-permissions.tab.roles\": \"Ruoli\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"Non è stato possibile trovare nessuna app associata ai permessi del negozio\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"Ruolo\",\n \"admin/storefront-permissions.tab.users\": \"Utenti\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"Può impersonare\",\n \"admin/storefront-permissions.tab.users.email.label\": \"Email\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"Organizzazione\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"Centro di costo\",\n \"admin/storefront-permissions.tab.users.error\": \"Errore durante il salvataggio delle informazioni B2B\",\n \"admin/storefront-permissions.tab.users.name.label\": \"Nome\",\n \"admin/storefront-permissions.tab.users.success\": \"Informazioni B2B salvate\",\n \"admin/storefront-permissions.title\": \"Permessi del negozio\",\n \"admin/storefront-permissions.alert-pick\": \"È necessario scegliere un centro di costo prima di salvare le modifiche\",\n \"admin/storefront-permissions.searchOrganizations\": \"Cerca organizzazioni...\"\n}\n\n```" } ]
code_storefront-permissions-components_90514a4f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/messages/fr.json from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"Information B2B\",\n \"admin/storefront-permissions.button.cancel\": \"Annuler\",\n \"admin/storefront-permissions.button.delete\": \"Supprimer les infos B2B\",\n \"admin/storefront-permissions.button.save\": \"Sauvegarder\",\n \"admin/storefront-permissions.description\": \"Rôles et gestion des utilisateurs\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, rôles, profiles\",\n \"admin/storefront-permissions.navigation.label\": \"Autorisations de la vitrine\",\n \"admin/storefront-permissions.required\": \"Requis\",\n \"admin/storefront-permissions.tab.new.button\": \"Créer nouveau\",\n \"admin/storefront-permissions.tab.roles\": \"Rôles\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"Impossible de trouver les applications connectées aux autorisations de la vitrine\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"Rôle\",\n \"admin/storefront-permissions.tab.users\": \"Utilisateurs\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"Peut se faire passer pour\",\n \"admin/storefront-permissions.tab.users.email.label\": \"Email\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"Organisation\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"Centre de coûts\",\n \"admin/storefront-permissions.tab.users.error\": \"Erreur lors de l’enregistrement des infos B2B\",\n \"admin/storefront-permissions.tab.users.name.label\": \"Nom\",\n \"admin/storefront-permissions.tab.users.success\": \"Infos B2B enregistrées\",\n \"admin/storefront-permissions.title\": \"Autorisations de la vitrine\",\n \"admin/storefront-permissions.alert-pick\": \"Vous devez choisir un centre de coûts avant d’enregistrer les modifications\",\n \"admin/storefront-permissions.searchOrganizations\": \"Rechercher des organisations...\"\n}\n\n```" } ]
code_storefront-permissions-components_6e92d1b4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/messages/bg.json from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"Информация за B2B\",\n \"admin/storefront-permissions.button.cancel\": \"Отказ\",\n \"admin/storefront-permissions.button.delete\": \"Премахване на информация за B2B\",\n \"admin/storefront-permissions.button.save\": \"Запазване\",\n \"admin/storefront-permissions.description\": \"Управление на роли и потребители\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, роли, профили\",\n \"admin/storefront-permissions.navigation.label\": \"Разрешения на витрината\",\n \"admin/storefront-permissions.required\": \"Задължително\",\n \"admin/storefront-permissions.tab.new.button\": \"Създаване на нов\",\n \"admin/storefront-permissions.tab.roles\": \"Роли\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"Не са открити приложения, свързани с разрешенията за витрината\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"Роля\",\n \"admin/storefront-permissions.tab.users\": \"Потребители\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"Може да въплъщава\",\n \"admin/storefront-permissions.tab.users.email.label\": \"Имейл адрес\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"Организация\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"Разходен център\",\n \"admin/storefront-permissions.tab.users.error\": \"Грешка при запазването на информацията за B2B\",\n \"admin/storefront-permissions.tab.users.name.label\": \"Име\",\n \"admin/storefront-permissions.tab.users.success\": \"Информация за B2B е запазена\",\n \"admin/storefront-permissions.title\": \"Разрешения на витрината\",\n \"admin/storefront-permissions.alert-pick\": \"Трябва да изберете разходен център, преди да запазите промените\",\n \"admin/storefront-permissions.searchOrganizations\": \"Търсене на организации...\"\n}\n\n```" } ]
code_storefront-permissions-components_3ec67cf6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/messages/ro.json from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"Informații B2B\",\n \"admin/storefront-permissions.button.cancel\": \"Anulare\",\n \"admin/storefront-permissions.button.delete\": \"Ștergere informații B2B\",\n \"admin/storefront-permissions.button.save\": \"Salvare\",\n \"admin/storefront-permissions.description\": \"Funcții și gestionare utilizatori\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, funcții și profiluri\",\n \"admin/storefront-permissions.navigation.label\": \"Permisiuni magazin\",\n \"admin/storefront-permissions.required\": \"Obligatoriu\",\n \"admin/storefront-permissions.tab.new.button\": \"Creare nou\",\n \"admin/storefront-permissions.tab.roles\": \"Funcții\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"Nu am putut găsi nicio aplicație conectată la permisiunile magazinului\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"Funcții\",\n \"admin/storefront-permissions.tab.users\": \"Utilizatori\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"Pot înlocui\",\n \"admin/storefront-permissions.tab.users.email.label\": \"E-mail\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"Organizație\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"Centru de Cost\",\n \"admin/storefront-permissions.tab.users.error\": \"Eroare la salvarea informațiilor B2B\",\n \"admin/storefront-permissions.tab.users.name.label\": \"Nume\",\n \"admin/storefront-permissions.tab.users.success\": \"Informații B2B salvate\",\n \"admin/storefront-permissions.title\": \"Permisiuni storefront\",\n \"admin/storefront-permissions.alert-pick\": \"Trebuie să alegi un centru de cost înainte de a salva modificările\",\n \"admin/storefront-permissions.searchOrganizations\": \"Căutare organizații...\"\n}\n\n```" } ]
code_storefront-permissions-components_f1a6a487
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/messages/context.json from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"admin/storefront-permissions.b2bInfo.title\",\n \"admin/storefront-permissions.button.cancel\": \"admin/storefront-permissions.button.cancel\",\n \"admin/storefront-permissions.button.delete\": \"admin/storefront-permissions.button.delete\",\n \"admin/storefront-permissions.button.save\": \"admin/storefront-permissions.button.save\",\n \"admin/storefront-permissions.description\": \"admin/storefront-permissions.description\",\n \"admin/storefront-permissions.navigation.keywords\": \"admin/storefront-permissions.navigation.keywords\",\n \"admin/storefront-permissions.navigation.label\": \"admin/storefront-permissions.navigation.label\",\n \"admin/storefront-permissions.required\": \"admin/storefront-permissions.required\",\n \"admin/storefront-permissions.tab.new.button\": \"admin/storefront-permissions.tab.new.button\",\n \"admin/storefront-permissions.tab.roles\": \"admin/storefront-permissions.tab.roles\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"admin/storefront-permissions.tab.roles.featuresNotFound\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"admin/storefront-permissions.tab.roles.name.label\",\n \"admin/storefront-permissions.tab.users\": \"admin/storefront-permissions.tab.users\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"admin/storefront-permissions.tab.users.canImpersonate.label\",\n \"admin/storefront-permissions.tab.users.email.label\": \"admin/storefront-permissions.tab.users.email.label\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"admin/storefront-permissions.tab.users.organization.label\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"admin/storefront-permissions.tab.users.costCenter.label\",\n \"admin/storefront-permissions.tab.users.error\": \"admin/storefront-permissions.tab.users.error\",\n \"admin/storefront-permissions.tab.users.name.label\": \"admin/storefront-permissions.tab.users.name.label\",\n \"admin/storefront-permissions.tab.users.success\": \"admin/storefront-permissions.tab.users.success\",\n \"admin/storefront-permissions.title\": \"admin/storefront-permissions.title\",\n \"admin/storefront-permissions.alert-pick\": \"admin/storefront-permissions.alert-pick\",\n \"admin/storefront-permissions.searchOrganizations\": \"admin/storefront-permissions.searchOrganizations\"\n}\n\n```" } ]
code_storefront-permissions-components_9d34ffe1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/messages/ko.json from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"B2B 정보\",\n \"admin/storefront-permissions.button.cancel\": \"취소\",\n \"admin/storefront-permissions.button.delete\": \"B2B 정보 제거\",\n \"admin/storefront-permissions.button.save\": \"저장\",\n \"admin/storefront-permissions.description\": \"역할 및 사용자 관리\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, 역할, 프로필\",\n \"admin/storefront-permissions.navigation.label\": \"스토어프론트 권한\",\n \"admin/storefront-permissions.required\": \"필수\",\n \"admin/storefront-permissions.tab.new.button\": \"새로 만들기\",\n \"admin/storefront-permissions.tab.roles\": \"역할\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"스토어프론트 권한에 연결된 앱을 찾을 수 없습니다.\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"역할\",\n \"admin/storefront-permissions.tab.users\": \"사용자\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"가장할 수 있음\",\n \"admin/storefront-permissions.tab.users.email.label\": \"이메일\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"조직\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"비용 센터\",\n \"admin/storefront-permissions.tab.users.error\": \"B2B 정보를 저장하는 동안 오류가 발생했습니다.\",\n \"admin/storefront-permissions.tab.users.name.label\": \"이름\",\n \"admin/storefront-permissions.tab.users.success\": \"B2B 정보 저장됨\",\n \"admin/storefront-permissions.title\": \"스토어프론트 권한\",\n \"admin/storefront-permissions.alert-pick\": \"변경 사항을 저장하기 전에 비용 센터를 선택해야 합니다.\",\n \"admin/storefront-permissions.searchOrganizations\": \"조직 검색...\"\n}\n\n```" } ]
code_storefront-permissions-components_324e5c28
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/messages/th.json from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"ข้อมูล B2B\",\n \"admin/storefront-permissions.button.cancel\": \"ยกเลิก\",\n \"admin/storefront-permissions.button.delete\": \"ลบข้อมูล B2B ออก\",\n \"admin/storefront-permissions.button.save\": \"บันทึก\",\n \"admin/storefront-permissions.description\": \"บทบาทและการบริหารจัดผู้ใช้\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, บทบาท, โปรไฟล์\",\n \"admin/storefront-permissions.navigation.label\": \"สิทธิ์หน้าร้าน\",\n \"admin/storefront-permissions.required\": \"บังคับ\",\n \"admin/storefront-permissions.tab.new.button\": \"สร้างใหม่\",\n \"admin/storefront-permissions.tab.roles\": \"บทบาท\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"ไม่พบว่ามีแอปใดเชือมต่อกับสิทธิ์หน้าร้าน\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"บทบาท\",\n \"admin/storefront-permissions.tab.users\": \"ผู้ใช้\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"สามารถเลียนแบบ\",\n \"admin/storefront-permissions.tab.users.email.label\": \"อีเมล\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"องค์กร\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"ศูนย์ต้นทุน\",\n \"admin/storefront-permissions.tab.users.error\": \"มีข้อผิดพลาดขณะบันทึกข้อมูล B2B\",\n \"admin/storefront-permissions.tab.users.name.label\": \"ชื่อ\",\n \"admin/storefront-permissions.tab.users.success\": \"บันทึกข้อมูล B2B แล้ว\",\n \"admin/storefront-permissions.title\": \"สิทธิ์หน้าร้าน\",\n \"admin/storefront-permissions.alert-pick\": \"คุณต้องเลือกศูนย์ต้นทุนก่อนบันทึกการเปลี่ยนแปลง\",\n \"admin/storefront-permissions.searchOrganizations\": \"ค้นหาองค์กร...\"\n}\n\n```" } ]
code_storefront-permissions-components_71d9b73f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/messages/es.json from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"Información B2B\",\n \"admin/storefront-permissions.button.cancel\": \"Cancelar\",\n \"admin/storefront-permissions.button.delete\": \"Eliminar información B2B\",\n \"admin/storefront-permissions.button.save\": \"Guardar\",\n \"admin/storefront-permissions.description\": \"Gestión de roles y usuarios\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, roles, perfiles\",\n \"admin/storefront-permissions.navigation.label\": \"Permisos del storefront\",\n \"admin/storefront-permissions.required\": \"Obligatorio\",\n \"admin/storefront-permissions.tab.new.button\": \"Nueva\",\n \"admin/storefront-permissions.tab.roles\": \"Roles\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"No pudo encontrar ninguna aplicación conectada a los permisos del storefront\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"Rol\",\n \"admin/storefront-permissions.tab.users\": \"Usuarios\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"Puede suplantar\",\n \"admin/storefront-permissions.tab.users.email.label\": \"Email\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"Organización\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"Centro de costos\",\n \"admin/storefront-permissions.tab.users.error\": \"Error al guardar información B2B\",\n \"admin/storefront-permissions.tab.users.name.label\": \"Nombre\",\n \"admin/storefront-permissions.tab.users.success\": \"Información B2B guardada\",\n \"admin/storefront-permissions.title\": \"Permisos del storefront\",\n \"admin/storefront-permissions.alert-pick\": \"Debes elegir un centro de costos antes de guardar los cambios\",\n \"admin/storefront-permissions.searchOrganizations\": \"Buscar organizaciones...\"\n}\n\n```" } ]
code_storefront-permissions-components_dd69b594
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/react/StorefrontPermissions.tsx from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport StorefrontPermissions from './components/customers-admin'\n\nexport default StorefrontPermissions\n\n```" } ]
code_storefront-permissions-components_21ba37aa
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/react/package.json from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.storefront-permissions-components\",\n \"version\": \"2.0.1\",\n \"scripts\": {\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n },\n \"devDependencies\": {\n \"@types/faker\": \"^4.1.5\",\n \"@types/node\": \"^11.12.1\",\n \"@types/react\": \"^16.8.10\",\n \"@types/react-intl\": \"^3.0.0\",\n \"apollo-client\": \"^2.4.7\",\n \"graphql\": \"^14.0.2\",\n \"prop-types\": \"^15.7.2\",\n \"typescript\": \"3.9.7\",\n \"vtex.admin-customers-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.admin-customers-graphql@3.0.2/public/@types/vtex.admin-customers-graphql\",\n \"vtex.b2b-organizations-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.b2b-organizations-graphql@0.19.7/public/@types/vtex.b2b-organizations-graphql\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.132.4/public/@types/vtex.render-runtime\",\n \"vtex.storefront-permissions\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.storefront-permissions@1.23.0/public/@types/vtex.storefront-permissions\",\n \"vtex.storefront-permissions-components\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.storefront-permissions-components@0.2.0/public/@types/vtex.storefront-permissions-components\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.146.13/public/@types/vtex.styleguide\"\n },\n \"dependencies\": {\n \"faker\": \"^4.1.0\",\n \"react\": \"^16.8.6\",\n \"react-apollo\": \"^3.1.5\",\n \"react-dom\": \"^16.8.6\",\n \"react-intl\": \"^5.13.4\"\n }\n}\n\n```" } ]
code_storefront-permissions-components_ae0908a6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/react/mutations/deleteUser.gql from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation DeleteUser($id: ID!, $userId: ID, $email: String!, $clId: ID!) {\n removeUser(id: $id, userId: $userId, email: $email, clId: $clId)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n status\n message\n }\n}\n\n```" } ]
code_storefront-permissions-components_ffc58962
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/react/mutations/addUser.gql from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation add(\n $id: ID\n $roleId: ID!\n $userId: ID\n $orgId: ID\n $costId: ID\n $canImpersonate: Boolean\n $name: String!\n $email: String!\n) {\n addUser(\n id: $id\n roleId: $roleId\n userId: $userId\n orgId: $orgId\n costId: $costId\n canImpersonate: $canImpersonate\n name: $name\n email: $email\n ) @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n status\n message\n }\n}\n\n```" } ]
code_storefront-permissions-components_b809fdaa
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/react/typings/graphql.d.ts from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.graphql' {\n import type { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\ndeclare module '*.gql' {\n import type { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\n```" } ]
code_storefront-permissions-components_0f31054f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/react/queries/getUser.gql from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery GetUser($id: ID!) {\n getUser(id: $id) @context(provider: \"vtex.storefront-permissions\") {\n id\n roleId\n orgId\n costId\n userId\n name\n email\n canImpersonate\n }\n}\n\n```" } ]
code_storefront-permissions-components_e1b889f2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/react/queries/getOrganizationsByEmail.graphql from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery GetOrganizationsByEmail($email: String!) {\n getOrganizationsByEmail(email: $email)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n costId\n orgId\n roleId\n clId\n organizationName\n costCenterName\n role {\n name\n }\n }\n}\n\n```" } ]
code_storefront-permissions-components_beb01b6d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/react/queries/costCentersByOrg.gql from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery CostCenters(\n $id: ID!\n $page: Int\n $pageSize: Int\n $sortOrder: String\n $search: String\n $sortedBy: String\n) {\n getCostCentersByOrganizationId(\n id: $id\n search: $search\n page: $page\n pageSize: $pageSize\n sortOrder: $sortOrder\n sortedBy: $sortedBy\n ) @context(provider: \"vtex.b2b-organizations-graphql\") {\n data {\n id\n name\n }\n pagination {\n page\n pageSize\n total\n }\n }\n}\n\n```" } ]
code_storefront-permissions-components_09d52ae7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/react/queries/getOrganization.graphql from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery GetOrganization($id: ID) {\n getOrganizationById(id: $id)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n name\n status\n created\n collections {\n id\n name\n }\n paymentTerms {\n id\n name\n }\n priceTables\n costCenters\n }\n}\n\n```" } ]
code_storefront-permissions-components_cef014d5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/react/queries/ListRoles.gql from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery ListRoles {\n listRoles @context(provider: \"vtex.storefront-permissions\") {\n id\n name\n }\n}\n\n```" } ]
code_storefront-permissions-components_7534bea6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/react/queries/listOrganizations.gql from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery Organizations(\n $search: String\n $page: Int\n $pageSize: Int\n $sortOrder: String\n $sortedBy: String\n) {\n getOrganizations(\n status: [\"active\"]\n search: $search\n page: $page\n pageSize: $pageSize\n sortOrder: $sortOrder\n sortedBy: $sortedBy\n ) @context(provider: \"vtex.b2b-organizations-graphql\") {\n data {\n id\n name\n costCenters\n }\n pagination {\n page\n pageSize\n total\n }\n }\n}\n\n```" } ]
code_storefront-permissions-components_fdb46efb
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/react/components/OrganizationsAutocomplete.tsx from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useEffect, useState, useMemo, useCallback } from 'react'\nimport { useQuery } from 'react-apollo'\nimport { AutocompleteInput } from 'vtex.styleguide'\nimport { useIntl } from 'react-intl'\n\nimport { messages } from './customers-admin'\nimport GET_ORGANIZATIONS from '../queries/listOrganizations.gql'\nimport GET_ORGANIZATION_BY_ID from '../queries/getOrganization.graphql'\nimport { SEARCH_TERM_DELAY_MS } from '../constants/debounceDelay'\n\nconst initialState = {\n status: ['active', 'on-hold', 'inactive'],\n search: '',\n page: 1,\n pageSize: 500,\n sortOrder: 'ASC',\n sortedBy: 'name',\n}\n\ninterface Props {\n onChange: (value: { value: string | null; label: string }) => void\n organizationId: string\n}\n\nconst OrganizationsAutocomplete = ({ onChange, organizationId }: Props) => {\n const { formatMessage } = useIntl()\n const [term, setTerm] = useState('')\n const [debouncedTerm, setDebouncedTerm] = useState(term)\n\n const [values, setValues] = useState<Array<{ value: string; label: string }>>(\n []\n )\n\n const { data, loading, refetch } = useQuery(GET_ORGANIZATIONS, {\n variables: initialState,\n ssr: false,\n notifyOnNetworkStatusChange: true,\n })\n\n const { data: organization, loading: orgLoading } = useQuery(\n GET_ORGANIZATION_BY_ID,\n {\n variables: { id: organizationId },\n ssr: false,\n fetchPolicy: 'network-only',\n notifyOnNetworkStatusChange: true,\n skip: !organizationId,\n }\n )\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedTerm(term)\n }, SEARCH_TERM_DELAY_MS) // 500ms delay\n\n return () => clearTimeout(handler)\n }, [term])\n\n useEffect(() => {\n if (debouncedTerm.length > 2) {\n refetch({\n ...initialState,\n search: debouncedTerm,\n })\n } else if (debouncedTerm === '') {\n refetch({\n ...initialState,\n search: '',\n })\n }\n }, [debouncedTerm, refetch])\n\n useEffect(() => {\n if (!organization?.getOrganizationById) {\n return\n }\n\n const { name, id } = organization.getOrganizationById\n\n setTerm(name)\n onChange({ value: id, label: name })\n }, [organization, onChange])\n\n useEffect(() => {\n if (data?.getOrganizations?.data) {\n setValues(\n data.getOrganizations.data.map(\n (item: { id: string; name: string }) => ({\n value: item.id,\n label: item.name,\n })\n )\n )\n }\n }, [data])\n\n const onClear = useCallback(() => {\n setTerm('')\n\n refetch({\n ...initialState,\n search: '',\n })\n onChange({ value: null, label: '' })\n }, [onChange, refetch])\n\n const options = useMemo(\n () => ({\n maxHeight: 250,\n onSelect: onChange,\n loading,\n value: values,\n }),\n [loading, values, onChange, orgLoading]\n )\n\n useEffect(() => {\n if (term && term.length > 1) {\n refetch({\n ...initialState,\n search: term,\n })\n } else if (term === '') {\n onClear()\n }\n }, [term])\n\n const input = useMemo(\n () => ({\n onChange: (_term: string) => setTerm(_term),\n onClear,\n placeholder: formatMessage(messages.searchOrganizations),\n value: term,\n }),\n [term, onClear, formatMessage]\n )\n\n return <AutocompleteInput input={input} options={options} />\n}\n\nexport default OrganizationsAutocomplete\n\n```" } ]
code_storefront-permissions-components_6f3acc4c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/react/components/customers-admin.tsx from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { FC } from 'react'\nimport React, { Fragment, useState } from 'react'\nimport { useIntl, defineMessages } from 'react-intl'\nimport { useQuery, useMutation, useLazyQuery } from 'react-apollo'\nimport {\n Button,\n Dropdown,\n Alert,\n Spinner,\n Tabs,\n Tab,\n Table,\n} from 'vtex.styleguide'\n\nimport OrganizationsAutocomplete from './OrganizationsAutocomplete'\nimport GET_USER from '../queries/getUser.gql'\nimport GET_ROLES from '../queries/ListRoles.gql'\nimport GET_COST from '../queries/costCentersByOrg.gql'\nimport GET_ORGANIZATIONS from '../queries/getOrganizationsByEmail.graphql'\nimport ADD_USER from '../mutations/addUser.gql'\nimport DELETE_USER from '../mutations/deleteUser.gql'\nimport CostCenterAutocomplete from './CostCentersAutocomplete'\n\nexport const messages = defineMessages({\n b2bInfo: {\n id: 'admin/storefront-permissions.b2bInfo.title',\n defaultMessage: 'B2B Information',\n },\n role: {\n id: 'admin/storefront-permissions.tab.roles.name.label',\n defaultMessage: 'Role',\n },\n canImpersonate: {\n id: 'admin/storefront-permissions.tab.users.canImpersonate.label',\n defaultMessage: 'Can impersonate',\n },\n name: {\n id: 'admin/storefront-permissions.tab.users.name.label',\n defaultMessage: 'Name',\n },\n email: {\n id: 'admin/storefront-permissions.tab.users.email.label',\n defaultMessage: 'Email',\n },\n organization: {\n id: 'admin/storefront-permissions.tab.users.organization.label',\n defaultMessage: 'Organization',\n },\n costCenter: {\n id: 'admin/storefront-permissions.tab.users.costCenter.label',\n defaultMessage: 'Cost Center',\n },\n required: {\n id: 'admin/storefront-permissions.required',\n defaultMessage: 'Required',\n },\n cancel: {\n id: 'admin/storefront-permissions.button.cancel',\n defaultMessage: 'Cancel',\n },\n save: {\n id: 'admin/storefront-permissions.button.save',\n defaultMessage: 'Save',\n },\n add: {\n id: 'admin/storefront-permissions.button.add',\n defaultMessage: 'Add',\n },\n remove: {\n id: 'admin/storefront-permissions.button.remove',\n defaultMessage: 'Remove',\n },\n options: {\n id: 'admin/storefront-permissions.label.options',\n defaultMessage: 'Options',\n },\n b2bRoles: {\n id: 'admin/storefront-permissions.label.b2bRoles',\n defaultMessage: 'B2b Roles',\n },\n addNew: {\n id: 'admin/storefront-permissions.button.addNew',\n defaultMessage: 'Add New',\n },\n delete: {\n id: 'admin/storefront-permissions.button.delete',\n defaultMessage: 'Remove B2B Info',\n },\n success: {\n id: 'admin/storefront-permissions.tab.users.success',\n defaultMessage: 'B2B info saved',\n },\n alertPick: {\n id: 'admin/storefront-permissions.alert-pick',\n defaultMessage:\n 'You need to pick a cost center before you can save changes',\n },\n error: {\n id: 'admin/storefront-permissions.tab.users.error',\n defaultMessage: 'Error saving B2B info',\n },\n searchOrganizations: {\n id: 'admin/storefront-permissions.searchOrganizations',\n defaultMessage: 'Search organizations...',\n },\n})\n\nconst parseOptions = (options: any) => {\n return (\n options?.data?.map((orgOrCostCenter: any) => {\n return {\n value: orgOrCostCenter.id,\n label: orgOrCostCenter.name,\n }\n }) ?? []\n )\n}\n\nconst initialState = {\n message: null,\n id: null,\n roleId: null,\n orgId: null,\n costId: null,\n userId: null,\n clId: null,\n name: null,\n email: null,\n canImpersonate: false,\n organizationName: null,\n}\n\nconst UserEdit: FC<any> = (props: any) => {\n const { formatMessage } = useIntl()\n const {\n id,\n name = null,\n email = null,\n showName,\n showEmail,\n showCancel,\n onCancel,\n onSave,\n } = props\n\n const [state, setState] = useState<any>({\n ...initialState,\n clId: id,\n name,\n email,\n })\n\n const [tabs, setTabs] = useState(0)\n const [organizations, setOrganizations] = useState([] as any)\n const [isRemoving, setIsRemoving] = useState(false)\n\n const { loading, refetch } = useQuery(GET_USER, {\n skip: !id,\n variables: {\n id,\n },\n fetchPolicy: 'network-only',\n notifyOnNetworkStatusChange: true,\n onCompleted: (res: any) => {\n setState({\n ...state,\n ...res.getUser,\n })\n },\n })\n\n const handleTabs = (tab: number) => {\n setTabs(tab)\n setState({\n ...state,\n roleId: null,\n orgId: null,\n costId: null,\n message: null,\n })\n }\n\n const { refetch: refetchOrganizations, loading: loadingOrganizations } =\n useQuery(GET_ORGANIZATIONS, {\n variables: {\n email,\n },\n fetchPolicy: 'network-only',\n notifyOnNetworkStatusChange: true,\n onCompleted: (res: any) => {\n const result = res.getOrganizationsByEmail?.map((organization: any) => {\n return {\n ...organization,\n role: organization.role.name,\n }\n })\n\n if (result.length === 0) {\n handleTabs(1)\n }\n\n setOrganizations([\n ...result,\n ...organizations.filter(\n (item: any) =>\n !result.find((subitem: any) => subitem.id !== item.id)\n ),\n ])\n },\n })\n\n const { loading: loadingRoles, data: dataRoles } = useQuery(GET_ROLES)\n\n const [saveUser, { loading: saveUserLoading }] = useMutation(ADD_USER)\n\n const [deleteUser, { loading: deleteUserLoading }] = useMutation(DELETE_USER)\n\n const [\n getCostCenter,\n { data: dataCostCenter, called, loading: loadingCostCenters },\n ] = useLazyQuery(GET_COST)\n\n const onMutationError = () => {\n setState({\n ...state,\n message: 'error',\n })\n }\n\n const roleOptions =\n dataRoles?.listRoles?.map((role: any) => {\n return {\n value: role.id,\n label: role.name,\n }\n }) ?? []\n\n const optionsCost = parseOptions(\n dataCostCenter?.getCostCentersByOrganizationId\n )\n\n const handleSaveUser = () => {\n const variables = {\n clId: state.clId,\n userId: state.userId,\n roleId: state.roleId,\n orgId: state.orgId,\n costId: state.costId,\n name: state.name,\n email: state.email,\n canImpersonate: state.canImpersonate,\n }\n\n const roleName = roleOptions.find(\n (role: any) => role.value === state.roleId\n )?.name\n\n const costCenterName = optionsCost.find(\n (costCenter: any) => costCenter.value === state.costId\n )?.name\n\n const { organizationName } = state\n\n saveUser({\n variables,\n })\n .then((res) => {\n if (onSave) {\n onSave()\n }\n\n setState({\n ...state,\n id: state.id ?? res?.data?.addUser?.id,\n message: 'success',\n })\n refetchOrganizations()\n setOrganizations([\n ...organizations,\n {\n ...variables,\n id: res?.data?.addUser?.id,\n role: roleName,\n organizationName,\n costCenterName,\n },\n ])\n })\n .catch(onMutationError)\n }\n\n const handleDeleteUser = (userData: any) => {\n const variables = {\n id: userData.id,\n userId: userData.userId,\n email: state.email,\n clId: userData.clId,\n }\n\n setIsRemoving(true)\n\n deleteUser({\n variables,\n })\n .then((res) => {\n if (onSave) {\n onSave()\n }\n\n setState({\n ...state,\n roleId: null,\n orgId: null,\n costId: null,\n id: state.id ?? res?.data?.deleteUser?.id,\n message: 'success',\n })\n setOrganizations([])\n refetch()\n refetchOrganizations()\n })\n .catch(onMutationError)\n .finally(() => {\n setIsRemoving(false)\n })\n }\n\n if (state.costId && !called) {\n getCostCenter({\n variables: {\n id: state.orgId,\n },\n })\n }\n\n if (loading || loadingRoles || loadingCostCenters) {\n return (\n <div className=\"w-100 pt6 flex items-center justify-center\">\n <Spinner />\n </div>\n )\n }\n\n const customSchema = {\n properties: {\n role: {\n title: formatMessage(messages.role),\n },\n organizationName: {\n title: formatMessage(messages.organization),\n },\n costCenterName: {\n title: formatMessage(messages.costCenter),\n },\n options: {\n title: formatMessage(messages.options),\n // you can customize cell component render (also header component with headerRenderer)\n cellRenderer: ({ rowData }: any) => {\n return (\n <Fragment>\n <div className=\"mt2 mb2\">\n <Button\n variation=\"danger\"\n size=\"small\"\n disabled={isRemoving}\n onClick={() => handleDeleteUser(rowData)}\n >\n {formatMessage(messages.remove)}\n </Button>\n </div>\n </Fragment>\n )\n },\n },\n },\n }\n\n return (\n <div className=\"w-100 pt6\">\n <Tabs fullWidth className=\"mb4\">\n <Tab\n active={tabs === 0}\n label={formatMessage(messages.b2bRoles)}\n onClick={() => handleTabs(0)}\n />\n <Tab\n active={tabs === 1}\n label={formatMessage(messages.addNew)}\n onClick={() => handleTabs(1)}\n />\n </Tabs>\n <div className=\"pa7\">\n {tabs === 0 ? (\n <Fragment>\n <Table\n loading={loadingOrganizations || isRemoving}\n fullWidth\n schema={customSchema}\n items={organizations}\n />\n </Fragment>\n ) : (\n <Fragment>\n {showName && <div className=\"mb5\">{state.name}</div>}\n {showEmail && <div className=\"mb5\">{state.email}</div>}\n {roleOptions.length > 1 && (\n <div className=\"mb5\">\n <Dropdown\n label={formatMessage(messages.role)}\n options={roleOptions}\n value={state.roleId}\n onChange={(_: any, v: string) => {\n setState({\n ...state,\n roleId: v,\n })\n }}\n />\n </div>\n )}\n\n {dataRoles && state.roleId && (\n <div className=\"mb5 w-100\">\n <div className=\"flex\">\n <div className=\"w-100\">\n <label className=\"h-100\">\n <span className=\"db mt0 mb3 c-on-base t-small\">\n {formatMessage(messages.organization)}\n </span>\n <OrganizationsAutocomplete\n organizationId={state.orgId}\n onChange={(event) => {\n if (event.value === state.orgId) {\n return\n }\n\n setState({\n ...state,\n orgId: event.value,\n costId: null,\n organizationName: event.label,\n })\n if (!event.value) return\n getCostCenter({\n variables: {\n id: event.value,\n },\n })\n }}\n />\n </label>\n </div>\n </div>\n </div>\n )}\n\n {state.orgId && (\n <div className=\"mb5 w-100\">\n <div className=\"flex\">\n <div className=\"w-100\">\n <label className=\"h-100\">\n <span className=\"db mt0 mb3 c-on-base t-small\">\n {formatMessage(messages.costCenter)}\n </span>\n <CostCenterAutocomplete\n organizationId={state.orgId}\n onChange={(event) => {\n setState({ ...state, costId: event.value })\n }}\n />\n </label>\n </div>\n </div>\n </div>\n )}\n\n {state.orgId && !state.costId ? (\n <div className=\"mv4\">\n <Alert type=\"error\">{formatMessage(messages.alertPick)}</Alert>\n </div>\n ) : null}\n\n <div className=\"mv4 flex justify-start\">\n {showCancel && onCancel && (\n <div className=\"mr3\">\n <Button\n variation=\"tertiary\"\n disabled={loading}\n onClick={() => {\n onCancel()\n }}\n >\n {formatMessage(messages.cancel)}\n </Button>\n </div>\n )}\n <Button\n variation=\"primary\"\n disabled={\n loading ||\n saveUserLoading ||\n deleteUserLoading ||\n !state.name ||\n !state.email ||\n !state.orgId ||\n !state.costId ||\n !state.roleId\n }\n onClick={() => {\n handleSaveUser()\n }}\n >\n {formatMessage(messages.add)}\n </Button>\n </div>\n {state.message && (\n <Alert\n type={state.message}\n onClose={() => {\n setState({ ...state, message: null })\n }}\n >\n {state.message === 'success'\n ? formatMessage(messages.success)\n : formatMessage(messages.error)}\n </Alert>\n )}\n </Fragment>\n )}\n </div>\n </div>\n )\n}\n\nexport default UserEdit\n\n```" } ]
code_storefront-permissions-components_6d90bf15
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-components/react/components/CostCentersAutocomplete.tsx from the storefront-permissions-components VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useEffect, useState } from 'react'\nimport { useQuery } from 'react-apollo'\nimport { useIntl } from 'react-intl'\nimport { EXPERIMENTAL_Select } from 'vtex.styleguide'\n\nimport { messages } from './customers-admin'\nimport GET_COST_CENTER_BY_ORG from '../queries/costCentersByOrg.gql'\nimport { SEARCH_TERM_DELAY_MS } from '../constants/debounceDelay'\n\ninterface Props {\n onChange: (value: { value: string | null; label: string }) => void\n organizationId?: string\n}\n\nconst initialState = {\n search: '',\n page: 1,\n pageSize: 25,\n sortOrder: 'ASC',\n sortedBy: 'name',\n}\n\nconst CostCenterAutocomplete = ({ onChange, organizationId }: Props) => {\n const { formatMessage } = useIntl()\n const [costCenterTextInput, setCostCenterTextInput] = useState('')\n const [debouncedSearchTerm, setDebouncedSearchTerm] =\n useState(costCenterTextInput)\n\n const { data, loading, refetch } = useQuery(GET_COST_CENTER_BY_ORG, {\n variables: {\n ...initialState,\n id: organizationId,\n },\n ssr: false,\n notifyOnNetworkStatusChange: true,\n skip: !organizationId,\n })\n\n const options =\n data?.getCostCentersByOrganizationId?.data?.map(\n (costCenter: { id: string; name: string }) => ({\n value: costCenter.id,\n label: costCenter.name,\n })\n ) || []\n\n const handleSearchInputChange = (searchInput: string | null) => {\n setCostCenterTextInput(searchInput ?? '')\n }\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedSearchTerm(costCenterTextInput)\n }, SEARCH_TERM_DELAY_MS) // 500ms delay\n\n return () => {\n clearTimeout(handler)\n }\n }, [costCenterTextInput])\n\n useEffect(() => {\n if (debouncedSearchTerm) {\n refetch({\n ...initialState,\n id: organizationId,\n search: debouncedSearchTerm,\n })\n } else if (debouncedSearchTerm === '') {\n onChange({ value: null, label: '' })\n }\n }, [debouncedSearchTerm])\n\n const handleChange = (\n selectedOption: { value: string | null; label: string } | null\n ) => {\n if (!selectedOption || !selectedOption.value) {\n setCostCenterTextInput('')\n refetch({\n ...initialState,\n id: organizationId,\n search: '',\n })\n }\n\n onChange(selectedOption ?? { value: null, label: '' })\n }\n\n return (\n <EXPERIMENTAL_Select\n onSearchInputChange={handleSearchInputChange}\n onChange={handleChange}\n loading={loading}\n options={options}\n placeholder={formatMessage(messages.costCenter)}\n multi={false}\n valuesMaxHeight={200}\n claerable={true}\n />\n )\n}\n\nexport default CostCenterAutocomplete\n\n```" } ]
code_checkout-button-example_c0f1234e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-button-example/pages/pages.json from the checkout-button-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"extensions\": {\n \"checkout/buttons/checkout-button-example\": {\n \"component\": \"index\"\n }\n }\n}\n\n```" } ]
code_checkout-button-example_313f3042
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-button-example/react/index.tsx from the checkout-button-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { Component } from 'react'\n\nimport CustomButton from './components/CustomButton'\n\nclass CheckoutButtonExample extends Component<{}, CheckoutButtonExampleState> {\n /**\n * This component is the one that is referenced in the extension point. To use it\n * as an example, we add an event listener, which updates the state every time the\n * order form changes. This order form is then passed to its children so as to render\n * a table with the items.\n */\n constructor(props: any) {\n super(props)\n this.state = {\n orderForm: null,\n }\n }\n\n setOrderForm = (_: any, orderForm: OrderForm) => {\n this.setState({ orderForm })\n }\n\n componentDidMount() {\n $(window).on('orderFormUpdated.vtex', this.setOrderForm)\n }\n\n componentWillUnmount() {\n $(window).off('orderFormUpdated.vtex', this.setOrderForm)\n }\n\n render() {\n console.log(window.vtex.i18n.getLocale())\n\n return <CustomButton {...this.state.orderForm!} />\n }\n}\n\ninterface CheckoutButtonExampleProps {}\n\ninterface CheckoutButtonExampleState {\n orderForm: OrderForm | null\n}\n\nexport default CheckoutButtonExample\n\n```" } ]
code_checkout-button-example_cce13191
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-button-example/react/package.json from the checkout-button-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.checkout-button-example\",\n \"version\": \"0.0.3\",\n \"scripts\": {\n \"lint\": \"eslint --ext js,jsx,ts,tsx .\"\n },\n \"dependencies\": {\n \"@vtex/styleguide\": \"^9.96.6\"\n },\n \"devDependencies\": {\n \"@types/jquery\": \"^3.3.38\",\n \"@types/graphql\": \"^0.13.3\",\n \"@types/node\": \"^9.4.7\",\n \"@types/prop-types\": \"^15.5.2\",\n \"@types/react\": \"^16.3.16\",\n \"@types/react-dom\": \"^16.0.5\",\n \"@types/react-helmet\": \"^5.0.5\",\n \"@types/react-intl\": \"^2.3.5\",\n \"eslint\": \"^6.4.0\",\n \"eslint-config-vtex\": \"^11.0.0\",\n \"eslint-config-vtex-react\": \"^5.0.1\",\n \"graphql\": \"^0.13.0\",\n \"prettier\": \"^1.18.2\",\n \"react\": \"^16.2.0\",\n \"react-apollo\": \"^2.0.4\",\n \"react-dom\": \"^16.2.0\",\n \"react-intl\": \"^2.4.0\",\n \"typescript\": \"3.9.7\"\n }\n}\n\n```" } ]
code_checkout-button-example_aedb8c05
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-button-example/react/orderFormExample.json from the checkout-button-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\"orderFormId\":\"e68b71fb196842d9b9c65d959fe3e39d\",\"salesChannel\":\"1\",\"loggedIn\":false,\"isCheckedIn\":false,\"storeId\":null,\"checkedInPickupPointId\":null,\"allowManualPrice\":false,\"canEditData\":true,\"userProfileId\":null,\"userType\":null,\"ignoreProfileData\":false,\"value\":135000,\"messages\":[],\"items\":[{\"uniqueId\":\"CB3975B315E149A2BC26D0E6BCB8DD7A\",\"id\":\"96\",\"productId\":\"45\",\"productRefId\":\"8349560862\",\"refId\":\"79523795364\",\"ean\":null,\"name\":\"Black Steel Film Camera\",\"skuName\":\"Black Steel Film Camera\",\"modalType\":null,\"parentItemIndex\":null,\"parentAssemblyBinding\":null,\"assemblies\":[],\"priceValidUntil\":\"2021-06-17T21:39:42.9421855Z\",\"tax\":0,\"price\":45000,\"listPrice\":45000,\"manualPrice\":null,\"manualPriceAppliedBy\":null,\"sellingPrice\":45000,\"rewardValue\":0,\"isGift\":false,\"additionalInfo\":{\"brandName\":\"VTEX\",\"brandId\":\"2000000\",\"offeringInfo\":null,\"offeringType\":null,\"offeringTypeId\":null},\"preSaleDate\":null,\"productCategoryIds\":\"/3/12/\",\"productCategories\":{\"12\":\"Cameras\",\"3\":\"Electronics\"},\"quantity\":3,\"seller\":\"1\",\"sellerChain\":[\"1\"],\"imageUrl\":\"http://appliancetheme.vteximg.com.br/arquivos/ids/155762-55-55/camera-01.jpg?v=637080673910200000\",\"detailUrl\":\"/black-steel-film-camera/p\",\"components\":[],\"bundleItems\":[],\"attachments\":[],\"attachmentOfferings\":[],\"offerings\":[],\"priceTags\":[],\"availability\":\"available\",\"measurementUnit\":\"un\",\"unitMultiplier\":1.0000,\"manufacturerCode\":null}],\"selectableGifts\":[],\"totalizers\":[{\"id\":\"Items\",\"name\":\"Items Total\",\"value\":135000}],\"shippingData\":{\"address\":null,\"logisticsInfo\":[{\"itemIndex\":0,\"selectedSla\":null,\"selectedDeliveryChannel\":null,\"addressId\":null,\"slas\":[],\"shipsTo\":[\"BRA\"],\"itemId\":\"96\",\"deliveryChannels\":[{\"id\":\"delivery\"}]}],\"selectedAddresses\":[],\"availableAddresses\":[],\"pickupPoints\":[]},\"clientProfileData\":null,\"paymentData\":{\"installmentOptions\":[{\"paymentSystem\":\"17\",\"bin\":null,\"paymentName\":null,\"paymentGroupName\":null,\"value\":135000,\"installments\":[{\"count\":1,\"hasInterestRate\":false,\"interestRate\":0,\"value\":135000,\"total\":135000,\"sellerMerchantInstallments\":[{\"id\":\"APPLIANCETHEME\",\"count\":1,\"hasInterestRate\":false,\"interestRate\":0,\"value\":135000,\"total\":135000}]}]}],\"paymentSystems\":[{\"id\":17,\"name\":\"Promissory\",\"groupName\":\"promissoryPaymentGroup\",\"validator\":{\"regex\":null,\"mask\":null,\"cardCodeRegex\":null,\"cardCodeMask\":null,\"weights\":null,\"useCvv\":false,\"useExpirationDate\":false,\"useCardHolderName\":false,\"useBillingAddress\":false},\"stringId\":\"17\",\"template\":\"promissoryPaymentGroup-template\",\"requiresDocument\":false,\"isCustom\":false,\"description\":null,\"requiresAuthentication\":false,\"dueDate\":\"2020-06-24T23:56:33.9009616Z\",\"availablePayments\":null}],\"payments\":[],\"giftCards\":[],\"giftCardMessages\":[],\"availableAccounts\":[],\"availableTokens\":[]},\"marketingData\":null,\"sellers\":[{\"id\":\"1\",\"name\":\"treinamento\",\"logo\":\"\"}],\"clientPreferencesData\":{\"locale\":\"en-US\",\"optinNewsLetter\":false},\"commercialConditionData\":null,\"storePreferencesData\":{\"countryCode\":\"BRA\",\"saveUserData\":true,\"timeZone\":\"Eastern Standard Time\",\"currencyCode\":\"BRL\",\"currencyLocale\":1046,\"currencySymbol\":\"R$\",\"currencyFormatInfo\":{\"currencyDecimalDigits\":2,\"currencyDecimalSeparator\":\",\",\"currencyGroupSeparator\":\".\",\"currencyGroupSize\":3,\"startsWithCurrencySymbol\":true}},\"giftRegistryData\":null,\"openTextField\":null,\"invoiceData\":null,\"customData\":null,\"itemMetadata\":{\"items\":[{\"id\":\"96\",\"seller\":\"1\",\"name\":\"Black Steel Film Camera\",\"skuName\":\"Black Steel Film Camera\",\"productId\":\"45\",\"refId\":\"79523795364\",\"ean\":null,\"imageUrl\":\"http://appliancetheme.vteximg.com.br/arquivos/ids/155762-55-55/camera-01.jpg?v=637080673910200000\",\"detailUrl\":\"/black-steel-film-camera/p\",\"assemblyOptions\":[]}]},\"hooksData\":null,\"ratesAndBenefitsData\":{\"rateAndBenefitsIdentifiers\":[],\"teaser\":[]},\"subscriptionData\":null,\"itemsOrdination\":null}\n\n```" } ]
code_checkout-button-example_16320c33
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-button-example/react/typings/global.d.ts from the checkout-button-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ninterface Window extends Window {\n vtex: any\n}\n\ninterface OrderFormContext {\n orderForm: OrderForm\n loading: boolean\n}\n\ninterface OrderFormItem {\n additionalInfo: ItemAdditionalInfo\n availability: string\n detailUrl: string\n id: string\n imageUrl: string\n listPrice: number\n measurementUnit: string\n name: string\n price: number\n productId: string\n quantity: number\n sellingPrice: number\n skuName: string\n skuSpecifications: SKUSpecification[]\n uniqueId: string\n productCategories: Record<string, string>\n productCategoryIds: string\n productRefId: string\n refId: string\n}\n\ninterface ItemAdditionalInfo {\n brandName: string\n}\n\ninterface SKUSpecification {\n fieldName: string\n fieldValues: string[]\n}\n\ninterface OrderForm {\n id: string\n items: OrderFormItem[]\n marketingData: MarketingData\n totalizers: Totalizer[]\n value: number\n messages: OrderFormMessages\n}\n\ninterface MarketingData {\n coupon: string\n}\n\ninterface Totalizer {\n id: string\n name: string\n value: number\n}\n\ninterface OrderFormMessages {\n couponMessages: Message[]\n generalMessages: Message[]\n}\n\ninterface Message {\n code: string\n status: string\n text: string\n}\n\n```" } ]
code_checkout-button-example_f8b0da0a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-button-example/react/components/Table.tsx from the checkout-button-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { Component } from 'react'\n\nclass Table extends Component<TableProps> {\n constructor(props: any) {\n super(props)\n }\n render() {\n const { items } = this.props\n return (\n <div>\n {items.map(item => (\n <p>{item.name}</p>\n ))}\n </div>\n )\n }\n}\n\ninterface TableProps {\n items: OrderFormItem[]\n}\n\nexport default Table\n\n```" } ]
code_checkout-button-example_db2697b4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-button-example/react/components/CustomButton.tsx from the checkout-button-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { Component } from 'react'\n\nimport Table from './Table'\n\n/**\n * This component is responsible for rendering the custom button itself. For instance,\n * we use it to render a table that contains the name of the items that are in the\n * order form.\n */\nclass CustomButton extends Component<CustomButtonProps, {}> {\n render() {\n const { items } = this.props\n\n return items ? (\n <div>\n <h2>This is a checkout button</h2>\n <Table items={items} />\n </div>\n ) : (\n <div>Loading...</div>\n )\n }\n}\n\ninterface CustomButtonProps {\n items: OrderFormItem[]\n}\n\ninterface CustomButtonState {}\n\nexport default CustomButton\n\n```" } ]
code_on-view_cd40fd46
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of on-view/docs/README.md from the on-view VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# on-view\n\n<!-- DOCS-IGNORE:start -->\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n\n[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)\n\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n<!-- DOCS-IGNORE:end -->\n\n## Usage\n\n```sh\nvtex add vtex.on-view@1.x\n```\n\n## API\n\n### `useOnView`\n\nThe `onView` function is called whenever the HTML element is inside the viewport. It differs from [react-intersection-observer](https://www.npmjs.com/package/react-intersection-observer) in that it uses a callback approach instead of using a `setState`, improving performance by preventing unnecessary re-renders.\n\n```tsx\nimport React from 'react'\nimport { useOnView } from 'vtex.on-view'\n\nfunction MyComponent() {\n const element = useRef<HTMLDivElement | null>(null)\n\n useOnView({\n ref: element,\n once: true,\n onView: () => {\n console.log('Element is visible')\n },\n })\n\n return <div ref={element}>Hello World</div>\n}\n\nexport default MyComponent\n```\n\n### `useRenderOnView`\n\nIt renders a dummy element while the element is not inside the viewport.\n\n```tsx\nimport React from 'react'\nimport { useRenderOnView } from 'vtex.on-view'\n\nfunction MyComponent() {\n const element = useRef<HTMLDivElement | null>(null)\n\n const { hasBeenViewed, placeholderElement } = useRenderOnView({\n lazyRender: true,\n })\n\n if (!hasBeenViewed) {\n return placeholderElement\n }\n\n return <div>Hello World</div>\n}\n\nexport default MyComponent\n```\n\n<!-- DOCS-IGNORE:start -->\n\n## Contributors ✨\n\nThanks goes to these wonderful people:\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!\n\n<!-- DOCS-IGNORE:end -->\n\n```" } ]
code_on-view_626f9027
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of on-view/react/package.json from the on-view VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"on-view\",\n \"version\": \"1.0.0\",\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"apollo-client\": \"^2.6.8\",\n \"react\": \"^16.12.0\",\n \"react-apollo\": \"^3.1.3\",\n \"react-dom\": \"^16.12.0\",\n \"react-intl\": \"^3.12.0\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^3.1.3\",\n \"@types/jest\": \"^25.1.4\",\n \"@types/node\": \"^13.9.8\",\n \"@types/react\": \"^16.9.31\",\n \"@vtex/test-tools\": \"^3.3.2\",\n \"@vtex/tsconfig\": \"^0.4.4\",\n \"apollo-cache-inmemory\": \"^1.6.5\",\n \"graphql\": \"^14.6.0\",\n \"typescript\": \"3.9.7\"\n }\n}\n\n```" } ]
code_on-view_803ca954
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of on-view/react/useRenderOnView.tsx from the on-view VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useState, useRef } from 'react'\n\nimport useOnView from './useOnView'\n\nconst useRenderOnView = ({\n lazyRender = false,\n height = 400,\n offset = 200,\n waitForUserInteraction = true,\n}) => {\n const placeholder = useRef<HTMLDivElement | null>(null)\n const [hasBeenViewed, setHasBeenViewed] = useState(false)\n\n useOnView({\n ref: placeholder,\n onView: () => setHasBeenViewed(true),\n once: true,\n initializeOnInteraction: waitForUserInteraction,\n bailOut: !lazyRender,\n })\n\n const placeholderElement = (\n <div\n style={{\n width: '100%',\n height,\n position: 'relative',\n }}\n >\n <div\n ref={placeholder}\n style={{\n /** Allows detecting the view a bit earlier, allowing rendering before the user\n * sees the whitespace where the component should be */\n top: -offset,\n bottom: 0,\n left: 0,\n right: 0,\n position: 'absolute',\n }}\n />\n </div>\n )\n\n return { hasBeenViewed: hasBeenViewed || !lazyRender, placeholderElement }\n}\n\nexport default useRenderOnView\n\n```" } ]
code_on-view_0f223739
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of on-view/react/useOnView.ts from the on-view VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { useEffect, useRef, MutableRefObject } from 'react'\n\ninterface IntersectionEvent {\n entry: IntersectionObserverEntry\n unobserve: () => void\n}\n\ninterface HookOptions {\n ref: MutableRefObject<HTMLElement | null>\n onView?: (event: IntersectionEvent) => any\n threshold?: number\n once?: boolean\n bailOut?: boolean\n initializeOnInteraction?: boolean\n}\n\n/** Hook for detecting when an element is inside the viewport.\n * Differs from react-intersection-observer (https://www.npmjs.com/package/react-intersection-observer)\n * in that this hook doesn't use setState, using a callback approach instead, to improve\n * performance by preventing re-rendering.\n */\nconst useOnView = ({\n ref,\n onView,\n threshold = 0,\n once = false,\n bailOut = false,\n initializeOnInteraction = false,\n}: HookOptions) => {\n const isObserving = useRef(false)\n const didIntersect = useRef(false)\n\n useEffect(() => {\n const initializeObserver = () => {\n const element = ref.current\n\n if (\n bailOut ||\n isObserving.current ||\n !element ||\n !onView ||\n (once && didIntersect.current)\n ) {\n return () => {}\n }\n\n isObserving.current = true\n\n const unobserve = () => {\n if (isObserving.current) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n observer.unobserve(element)\n isObserving.current = false\n }\n }\n\n const observer = new IntersectionObserver(([entry]) => {\n if (!entry.isIntersecting) {\n return\n }\n\n if (entry.intersectionRatio < threshold) {\n return\n }\n\n if (once) {\n unobserve()\n }\n\n didIntersect.current = true\n onView({ entry, unobserve })\n })\n\n observer.observe(element)\n\n return unobserve\n }\n\n if (initializeOnInteraction) {\n const cleanUpEvents = () => {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n window?.document?.removeEventListener('scroll', handleInteraction)\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n window?.document?.removeEventListener('mouseover', handleInteraction)\n }\n\n let unobserve = () => {\n cleanUpEvents()\n }\n\n const handleInteraction = () => {\n cleanUpEvents()\n unobserve = initializeObserver()\n }\n\n window?.document?.addEventListener('scroll', handleInteraction)\n window?.document?.addEventListener('mouseover', handleInteraction)\n\n return unobserve\n }\n\n return initializeObserver()\n }, [bailOut, initializeOnInteraction, onView, once, ref, threshold])\n}\n\nexport default useOnView\n\n```" } ]
code_on-view_9f8080af
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of on-view/react/__tests__/index.test.tsx from the on-view VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\ndescribe('Orders List Scenarios', () => {\n it('should work', () => {\n expect(1).toBe(1)\n })\n})\n\n```" } ]
code_adserver-graphql_19f735eb
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of adserver-graphql/docs/README.md from the adserver-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# VTEX Adserver Graphql\n\n`vtex.adserver-graphql` is the Graphql schema for the Adserver feature.\n\nCheck the full documentation to learn how to create a adserver for your account.\n\n<!-- TODO: add link to the documentation -->\n\n```" } ]
code_adserver-graphql_6427f4e4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of adserver-graphql/graphql/schema.graphql from the adserver-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype Query {\n sponsoredProducts(\n \"\"\"\n Search term. It can contain any character\n \"\"\"\n query: String\n \"\"\"\n Page number\n \"\"\"\n page: Int\n \"\"\"\n Number of items per page. **Warning:** Use `sponsoredCount` to limit the number of sponsored products.\n \"\"\"\n count: Int\n \"\"\"\n Sort the result by a criteria\n \"\"\"\n sort: String\n \"\"\"\n Indicates how the search-engine will deal with the fullText if there is more than one word. Set `and` if the returned products must have all the words in its metadata or `or` otherwise.\n \"\"\"\n operator: Operator\n \"\"\"\n Indicates how the search engine will correct misspelled words by using fuzzy logic.\n It can be a number representing the max number of misspelled letters, or the string `auto` suggesting that the search-engine should set this value by itself.\n \"\"\"\n fuzzy: String\n \"\"\"\n As fuzzy and operator, it controls the search state, but it is for general purposes. This field allows the search engines to apply features that are not handled by the other fields.\n The possible values in this field are defined by each search engine.\n \"\"\"\n searchState: String\n \"\"\"\n If the search has a redirect enabled, this allows (`true`) or not (`false`) the redirect to be used.\n \"\"\"\n allowRedirect: Boolean\n \"\"\"\n Indicates the user region. Useful for regionalized accounts.\n \"\"\"\n regionId: String\n \"\"\"\n If you want faster searches and do not care about most up to date prices and promotions, use skip value.\n \"\"\"\n simulationBehavior: SimulationBehavior\n \"\"\"\n If true, uses isAvailablePerSalesChannel_ parameter on query with segment's sales channel. Will override any given salesChannel arg\n \"\"\"\n hideUnavailableItems: Boolean\n \"\"\"\n List of the selected facets\n\n The order in which the terms appear is not relevant to the search.\n\n You can also repeat the same `facetKey` several times for different values.\n \"\"\"\n selectedFacets: [SelectedFacetInput]\n \"\"\"\n Rules for pormoting, demoting, adding or removing products\n \"\"\"\n dynamicRules: [DynamicRuleInput]\n \"\"\"\n Identifier for users, logged in or not. Used for A/B tests.\n \"\"\"\n anonymousId: String\n \"\"\"\n Identifier for user device, used for analytics purposes.\n \"\"\"\n macId: String\n \"\"\"\n Identifier for user ID if logged in, used for analytics purposes.\n \"\"\"\n userId: String\n \"\"\"\n Where the sponsored product in being shown. Used for analytics purposes.\n \"\"\"\n placement: String\n \"\"\"\n Maximum number of sponsored products that should be returned.\n \"\"\"\n sponsoredCount: Int\n \"\"\"\n SKU identifier used to segment the ads.\n \"\"\"\n skuId: String\n ): [SponsoredProduct] @cacheControl(scope: PUBLIC, maxAge: SHORT)\n sponsoredBanners(\n \"\"\"\n Maximum number of sponsored banners that should be returned.\n \"\"\"\n sponsoredCount: Int\n \"\"\"\n Placement of the banner. Used for analytics purposes.\n \"\"\"\n placement: Placement\n \"\"\"\n Banner dimensions.\n \"\"\"\n adUnit: AdUnit\n \"\"\"\n Channel where the banner is being shown. Used for analytics purposes.\n \"\"\"\n channel: Channel\n \"\"\"\n Identifier for users, logged in or not. Used for A/B tests.\n \"\"\"\n anonymousId: String\n ): [SponsoredBanner] @cacheControl(scope: PUBLIC, maxAge: SHORT)\n}\n\n```" } ]
code_adserver-graphql_b2522eaa
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of adserver-graphql/node/package.json from the adserver-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"search-graphql\",\n \"description\": \"Don't delete this file, it's necessary to generate the TypeScript types of the GraphQL\"\n}\n\n```" } ]
code_adserver-graphql_0f8cea8b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of adserver-graphql/graphql/types/Channel.graphql from the adserver-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nenum Channel {\n website\n android\n ios\n msite\n whatsapp\n}\n\n```" } ]
code_adserver-graphql_1d99edbd
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of adserver-graphql/graphql/types/DynamicRule.graphql from the adserver-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nenum BoostAction {\n add\n remove\n promote\n demote\n}\n\nenum BoostType {\n term\n id\n skuId\n skuEan\n skuReference\n productLink\n product\n sku\n productId\n attribute\n}\n\ntype DynamicRule {\n \"\"\"\n Rule action that will be applied to the products\n \"\"\"\n action: BoostAction\n \"\"\"\n Type of identifier\n \"\"\"\n type: BoostType\n \"\"\"\n Value related to the identifier\n \"\"\"\n value: String\n}\n\ninput DynamicRuleInput {\n \"\"\"\n Rule action that will be applied to the products\n \"\"\"\n action: BoostAction\n \"\"\"\n Type of identifier\n \"\"\"\n type: BoostType\n \"\"\"\n Value related to the identifier\n \"\"\"\n value: String\n}\n\n```" } ]
code_adserver-graphql_4e3723d0
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of adserver-graphql/graphql/types/SponsoredProduct.graphql from the adserver-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype SponsoredProduct {\n \"\"\"\n Unique identifier of the product. Can be SKU, EAN or VTEX Product ID.\n \"\"\"\n identifier: ProductUniqueIdentifier\n\n \"\"\"\n ID of the sponsored product.\n \"\"\"\n productId: ID @deprecated(reason: \"Use `identifier` instead.\")\n\n \"\"\"\n Merchandising rule applied to the product.\n \"\"\"\n rule: Rule\n\n \"\"\"\n Sponsored campaign related information should be added here.\n \"\"\"\n advertisement: Advertisement\n\n \"\"\"\n Seller ID.\n \"\"\"\n sellerId: ID\n}\n\ntype ProductUniqueIdentifier {\n \"\"\"\n Product ID value. If null, consider anyId as the default.\n \"\"\"\n field: ProductUniqueIdentifierField\n \"\"\"\n Product ID value.\n \"\"\"\n value: ID\n}\n\nenum ProductUniqueIdentifierField {\n \"\"\"\n Any ID, being SKU, EAN or VTEX Product ID. Keep in mind that multiple products can have equivalent SKU or Product ID.\n \"\"\"\n anyId\n\n \"\"\"\n VTEX Product ID, unique to this account.\n \"\"\"\n product\n\n \"\"\"\n SKU ID, unique to each variation of a product such as size, color, etc.\n \"\"\"\n skuId\n}\n\ntype Rule {\n \"\"\"\n Rule ID.\n \"\"\"\n id: String\n}\n\ntype Advertisement {\n \"\"\"\n ID of the ad item associated with the sponsored product.\n \"\"\"\n adId: ID\n \"\"\"\n ID of the campaign owner of the ad item.\n \"\"\"\n campaignId: ID\n \"\"\"\n Cost of the goal action. E.g: CPC, cost per click.\n \"\"\"\n actionCost: Float\n \"\"\"\n Ad Request ID.\n \"\"\"\n adRequestId: ID\n \"\"\"\n Ad Response ID.\n \"\"\"\n adResponseId: ID\n}\n\n```" } ]
code_adserver-graphql_ea9eea51
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of adserver-graphql/graphql/types/Operator.graphql from the adserver-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\n\"\"\"\nIndicates how the search-engine will deal with the fullText if there is more than one word. Set `and` if the returned products must have all the words in its metadata or `or` otherwise.\n\"\"\"\nenum Operator {\n and\n or\n}\n\n```" } ]
code_adserver-graphql_35e6f25c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of adserver-graphql/graphql/types/Placement.graphql from the adserver-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nenum Placement {\n top_search\n middle_search\n home_shelfpdp_shelf\n search_shelf\n cart_shelf\n plp_shelf\n autocomplete\n homepage\n}\n\n```" } ]
code_adserver-graphql_6c8c6bf4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of adserver-graphql/graphql/types/SelectedFacets.graphql from the adserver-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\n\"\"\"\nObject that represents a selected facet. For example: {key: color, value: blue}\n\"\"\"\ntype SelectedFacet {\n \"\"\"\n Facet key\n \"\"\"\n key: String\n \"\"\"\n Facet value\n \"\"\"\n value: String\n}\n\n\"\"\"\nObject that represents a selected facet. For example: {key: color, value: blue}\n\"\"\"\ninput SelectedFacetInput {\n \"\"\"\n Facet key\n \"\"\"\n key: String\n \"\"\"\n Facet value\n \"\"\"\n value: String\n}\n\n```" } ]
code_adserver-graphql_7daf2dae
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of adserver-graphql/graphql/types/AdUnit.graphql from the adserver-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nenum AdUnit {\n billboard\n smartphonebanner\n leaderboard\n superleaderboard\n portrait\n skyscraper\n mediumrectangle\n button120x60\n mobilephoneinterstitial\n featurephonesmallbanner\n featurephonemediumbanner\n featurephonelargebanner\n}\n\n```" } ]
code_adserver-graphql_d854ff96
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of adserver-graphql/graphql/types/SearchParams.graphql from the adserver-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype SearchParams {\n \"\"\"\n Search term. It can contain any character\n \"\"\"\n query: String\n \"\"\"\n List of the selected facets\n\n The order in which the terms appear is not relevant to the search.\n\n You can also repeat the same `facetKey` several times for different values.\n \"\"\"\n selectedFacets: [SelectedFacet]\n \"\"\"\n Sort the result by a criteria\n \"\"\"\n sort: String\n \"\"\"\n Page number\n \"\"\"\n page: Int\n \"\"\"\n Number of items per page\n \"\"\"\n count: Int\n \"\"\"\n If true, uses isAvailablePerSalesChannel_ parameter on query with segment's sales channel. Will override any given salesChannel arg\n \"\"\"\n hideUnavailableItems: Boolean\n \"\"\"\n Indicates how the search-engine will deal with the fullText if there is more than one word. Set `and` if the returned products must have all the words in its metadata or `or` otherwise.\n \"\"\"\n operator: Operator\n \"\"\"\n Indicates how the search engine will correct misspelled words by using fuzzy logic.\n It can be a number representing the max number of misspelled letters, or the string `auto` suggesting that the search-engine should set this value by itself.\n \"\"\"\n fuzzy: String\n \"\"\"\n As fuzzy and operator, it controls the search state, but it is for general purposes. This field allows the search engines to apply features that are not handled by the other fields.\n The possible values in this field are defined by each search engine.\n \"\"\"\n searchState: String\n \"\"\"\n If the search has a redirect enabled, this allows (`true`) or not (`false`) the redirect to be used.\n \"\"\"\n allowRedirect: String\n \"\"\"\n Rules for pormoting, demoting, adding or removing products\n \"\"\"\n dynamicRules: [DynamicRule]\n \"\"\"\n Indicates the user region. Useful for regionalized accounts.\n \"\"\"\n regionId: String\n \"\"\"\n If you want faster searches and do not care about most up to date prices and promotions, use skip value.\n \"\"\"\n simulationBehavior: SimulationBehavior\n}\n\n```" } ]
code_adserver-graphql_16998fab
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of adserver-graphql/graphql/types/SponsoredBanner.graphql from the adserver-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype SponsoredBanner {\n \"\"\"\n ID of the sponsored banner.\n \"\"\"\n adResponseId: ID\n \"\"\"\n Sponsored campaign related information should be added here.\n \"\"\"\n advertisement: AdvertisementBanner\n}\n\ntype AdvertisementBanner {\n \"\"\"\n Banner Image ID.\n \"\"\"\n bannerImageId: ID\n \"\"\"\n URL of the image to be displayed in the ad.\n \"\"\"\n imageUrl: String\n \"\"\"\n URL to be redirected to when the ad is clicked.\n \"\"\"\n targetUrl: String\n \"\"\"\n Width of the banner in pixels.\n \"\"\"\n width: Int\n \"\"\"\n Height of the banner in pixels.\n \"\"\"\n height: Int\n}\n\n```" } ]
code_adserver-graphql_241a2d19
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of adserver-graphql/graphql/types/SimulationBehavior.graphql from the adserver-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\n\"\"\"\nIf you want faster searches and do not care about most up to date prices and promotions, use skip value.\n\"\"\"\nenum SimulationBehavior {\n \"\"\"\n Ignore simulation calls\n \"\"\"\n skip\n \"\"\"\n Calls the simulation only for first party sellers\n \"\"\"\n only1P\n \"\"\"\n Calls the simulation for every single seller\n \"\"\"\n default\n}\n\n```" } ]
code_user-identifier-extension-example_8187191c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of user-identifier-extension-example/docs/README.md from the user-identifier-extension-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# User identifier extension example\n\nThis app is an example implementation of the [Login's user identifier extension](https://github.com/vtex-apps/login#advanced-configuration).\n\n```" } ]
code_user-identifier-extension-example_65e843be
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of user-identifier-extension-example/react/Cpf.tsx from the user-identifier-extension-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { ReactNode } from 'react'\nimport React, { useState, useCallback, useEffect } from 'react'\n\ninterface OptionsRenderInput {\n value: string\n onChange: (newValue: string) => void\n placeholder: string\n}\n\ntype HandleSubmit = () => Promise<string>\n\ninterface Props {\n renderInput: (options: OptionsRenderInput) => ReactNode\n identifierPlaceholder: string\n registerSubmitter: (handleSubmit: HandleSubmit) => void\n}\n\nconst ComponentName = ({ renderInput, registerSubmitter }: Props) => {\n const [cpf, setCpf] = useState('')\n const onChangeInput = useCallback(e => setCpf(e.target.value), [setCpf])\n\n const onSubmit = useCallback(async () => {\n const email = `${cpf}@email.com`\n\n return email\n }, [cpf])\n\n useEffect(() => {\n registerSubmitter(onSubmit)\n }, [registerSubmitter, onSubmit])\n\n return (\n <>\n <div>This is a custom identifier (CPF) input</div>\n {renderInput({\n value: cpf,\n onChange: onChangeInput,\n placeholder: 'Your CPF here',\n })}\n </>\n )\n}\n\nexport default ComponentName\n\n```" } ]
code_user-identifier-extension-example_4069ffc1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of user-identifier-extension-example/react/package.json from the user-identifier-extension-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"react\": \"^16.4.1\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^16.11.9\",\n \"@types/react\": \"^17.0.35\",\n \"@vtex/tsconfig\": \"^0.6.0\",\n \"typescript\": \"3.9.7\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.132.4/public/@types/vtex.render-runtime\"\n }\n}\n\n```" } ]
code_user-identifier-extension-example_0498e247
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of user-identifier-extension-example/store/interfaces.json from the user-identifier-extension-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"user-identifier.cpf\": {\n \"component\": \"Cpf\"\n }\n}\n\n```" } ]
code_user-identifier-extension-example_1e01aba5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of user-identifier-extension-example/store/plugins.json from the user-identifier-extension-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"login > user-identifier\": \"user-identifier.cpf\",\n \"login-content > user-identifier\": \"user-identifier.cpf\"\n}\n\n```" } ]
code_multi-tenant-search_4fc145f2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of multi-tenant-search/docs/README.md from the multi-tenant-search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n\n\n# Service Example\n\nA reference app implementing a VTEX IO service with HTTP route handlers.\n\n![Service Example Architecture](https://user-images.githubusercontent.com/18706156/77381360-72489680-6d5c-11ea-9da8-f4f03b6c5f4c.jpg)\n\nWe use [**KoaJS**](https://koajs.com/) as the web framework, so you might want to get into that\n\nWe also use the [**node-vtex-api**](https://github.com/vtex/node-vtex-api), a VTEX set of utilities for Node services. You can import this package using NPM from `@vtex/api` (already imported on this project)\n\n- Start from `node/index.ts` and follow the comments and imports :)\n\n## Recipes\n\n### Defining routes on _service.json_ \n```json\n{\n \"memory\": 256,\n \"ttl\": 10,\n \"timeout\": 2,\n \"minReplicas\": 2,\n \"maxReplicas\": 4,\n \"routes\": {\n \"status\": {\n \"path\": \"/_v/status/:code\",\n \"public\": true\n }\n }\n}\n```\n\nThe `service.json` file that sits on the root of the `node` folder holds informations about this service, like the maximum timeout and number of replicas, what might be discontinued on the future, but also **sets its routes**. \n\nKoa uses the [path-to-regexp](https://github.com/pillarjs/path-to-regexp) format for defining routes and, as seen on the example, we use the `:code` notation for declaring a **route param** named code, in this case. A HTTP request for `https://{{workspace}}--{{account}}.myvtex.com/_v/status/500` will match the route we've defined. \n\nFor cach _key_ on the `routes` object, there should be a **corresponding entry** on the exported Service object on `node/index.ts`, this will hook your code to a specific route.\n\n### Access Control\nYou can also provide a `public` option for each route. If `true`, that resource will be reachable for everyone on the internet. If `false`, VTEX credentials will be requested as well.\n\nAnother way of controlling access to specific routes is using **ReBACs (Resource-based access)**, that supports more robust configuration. You can read more [on this document](https://docs.google.com/document/d/1ZxNHMFIXfXz3BgTN9xyrHL3V5dYz14wivYgQjRBZ6J8/edit#heading=h.z7pad3qd2qw7) (VTEX only).\n\n#### Query String\nFor `?accepting=query-string`, you **don't need to declare anything**, as any query provided to the URL will already be available for you to use on the code as `ctx.query`, already parsed as an object, or `ctx.queryString`, taken directly from the URL as a string.\n\n#### Route Params\nRoute Params will be available for you to use on the code as `ctx.vtex.params`, already parsed as an object.\nFor a path like `/_v/status/:code`, if you receive the request `/_v/status/200`, `ctx.vtex.params` will return `{ code: '200' }`\n\n#### HTTP methods\nWhen you define a route on the `service.json`, your NodeJS handlers for that route will be triggered **on every HTTP method** (GET, POST, PUT...), so, if you need to handle them separately you need to implement a \"sub-router\". Fortunately, the _node-vtex-api_ provides a helper function `method`, exported from `@vtex/api`, to accomplish that behaviour. Instead of passing your handlers directly to the corresponding route on `index.ts`, you pass a `method` call passing **an object with the desired method as key and one handler as its corresponding value**. Check this example:\n```typescript\nimport { method } from '@vtex/api'\n...\n\nexport default new Service<Clients, State>({\n clients,\n routes: {\n status: method({\n GET: statusGetHandler,\n POST: statusPostHandler,\n }),\n },\n})\n```\n\n### Throwing errors\n\nWhen building a HTTP service, we should follow HTTP rules regarding data types, cache, authorization, and status code. Our example app sets a `ctx.status` value that will be used as a HTTP status code return value, but often we also want to give proper information about errors as well.\n\nThe **node-vtex-api** already exports a handful of **custom error classes** that can be used for that purpose, like the `NotFoundError`. You just need to throw them inside one of the the route handlers that the appropriate response will be sent to the server.\n\n```typescript\nimport { UserInputError } from '@vtex/api'\n\nexport async function validate(ctx: Context, next: () => Promise<any>) {\n const { code } = ctx.vtex.route.params\n if (isNaN(code) || code < 100 || code > 600) {\n throw new UserInputError('Code must be a number between 100 and 600')\n }\n...\n```\n\nYou can check all the available errors [here](https://github.com/vtex/node-vtex-api/tree/fd6139349de4e68825b1074f1959dd8d0c8f4d5b/src/errors), but some are not useful for just-HTTP services. Check the most useful ones:\n\n|Error Class | HTTP Code |\n|--|:--:|\n| `UserInputError` | 400 |\n| `AuthenticationError` | 401 |\n| `ForbiddenError` | 403 |\n| `NotFoundError` | 404 |\n\nYou can also **create your custom error**, just see how it's done above ;)\n\n### Reading a JSON body\n\nWhen writing POST or PUT handlers, for example, often you need to have access to the **request body** that comes as a JSON format, which is not provided directly by the handler function.\n\nFor this, you have to use the [co-body](https://www.npmjs.com/package/co-body) package that will parse the request into a readable JSON object, used as below: \n```typescript\nimport { json } from 'co-body'\nexport async function method(ctx: Context, next: () => Promise<any>) {\n const body = await json(ctx.req)\n```\n\n### Other example apps\n\nWe use Node services across all VTEX, and there are a lot inspiring examples. If you want to dive deeper on learning about this subject, don't miss those internal apps: [builder-hub](https://github.com/vtex/builder-hub) or [store-sitemap](https://github.com/vtex-apps/store-sitemap)\n\n\n## Testing\n\n`@vtex/test-tools` and `@types/jest` should be installed on `./node` package as `devDependencies`.\n\nRun `vtex test` and [Jest](https://jestjs.io/) will do its thing.\n\nCheck the `node/__tests__/simple.test.ts` test case and also [Jest's Documentation](https://jestjs.io/docs/en/getting-started).\n\n## Splunk Dashboard\n\nWe have an (for now, VTEX-only, internal) Splunk dashboard to show all metrics related to your app. You can find it [here](https://splunk7.vtex.com/en-US/app/vtex_colossus/node_app_metrics).\n\nAfter linking this app and making some requests, you can select `vtex.service-example` and see the metrics for your app. **Don't forget to check the box Development, as you are linking your app in a development workspace**.\n\nFor convenience, the link for the current version: https://splunk7.vtex.com/en-US/app/vtex_colossus/node_app_metrics?form.time.earliest=-30m%40m&form.time.latest=%40m&form.picked_context=false&form.picked_region=aws-us-east-*&form.picked_service=vtex.service-example\n\n```" } ]
code_multi-tenant-search_e2ee41c6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of multi-tenant-search/node/service.json from the multi-tenant-search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"memory\": 256,\n \"ttl\": 10,\n \"timeout\": 2,\n \"minReplicas\": 2,\n \"maxReplicas\": 4,\n \"workers\": 1,\n \"routes\": {\n \"status\": {\n \"path\": \"/_v/status/:code\",\n \"public\": true\n }\n }\n}\n\n```" } ]
code_multi-tenant-search_0ce87856
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of multi-tenant-search/node/package.json from the multi-tenant-search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"co-body\": \"^6.0.0\",\n \"ramda\": \"^0.25.0\"\n },\n \"devDependencies\": {\n \"@types/co-body\": \"^0.0.3\",\n \"@types/jest\": \"^24.0.18\",\n \"@types/node\": \"^12.0.0\",\n \"@types/ramda\": \"types/npm-ramda#dist\",\n \"@vtex/api\": \"6.37.1\",\n \"@vtex/test-tools\": \"^1.0.0\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"typescript\": \"3.9.7\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty\"\n },\n \"version\": \"0.2.0\"\n}\n\n```" } ]
code_multi-tenant-search_3594a2a2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of multi-tenant-search/node/index.ts from the multi-tenant-search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { ClientsConfig, ServiceContext, RecorderState } from '@vtex/api'\nimport { LRUCache, method, Service } from '@vtex/api'\n\nimport { Clients } from './clients'\nimport { status } from './middlewares/status'\nimport { validate } from './middlewares/validate'\n\nconst TIMEOUT_MS = 800\n\n// Create a LRU memory cache for the Status client.\n// The @vtex/api HttpClient respects Cache-Control headers and uses the provided cache.\nconst memoryCache = new LRUCache<string, any>({ max: 5000 })\n\nmetrics.trackCache('status', memoryCache)\n\n// This is the configuration for clients available in `ctx.clients`.\nconst clients: ClientsConfig<Clients> = {\n // We pass our custom implementation of the clients bag, containing the Status client.\n implementation: Clients,\n options: {\n // All IO Clients will be initialized with these options, unless otherwise specified.\n default: {\n retries: 2,\n timeout: TIMEOUT_MS,\n },\n // This key will be merged with the default options and add this cache to our Status client.\n status: {\n memoryCache,\n },\n },\n}\n\ndeclare global {\n // We declare a global Context type just to avoid re-writing ServiceContext<Clients, State> in every handler and resolver\n type Context = ServiceContext<Clients, State>\n\n // The shape of our State object found in `ctx.state`. This is used as state bag to communicate between middlewares.\n interface State extends RecorderState {\n code: number\n }\n}\n\n// Export a service that defines route handlers and client options.\nexport default new Service({\n clients,\n routes: {\n // `status` is the route ID from service.json. It maps to an array of middlewares (or a single handler).\n status: method({\n GET: [validate, status],\n }),\n },\n})\n\n```" } ]
code_multi-tenant-search_077219e3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of multi-tenant-search/node/clients/status.ts from the multi-tenant-search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext, IOResponse } from '@vtex/api'\nimport { ExternalClient } from '@vtex/api'\n\nexport default class Status extends ExternalClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super('http://httpstat.us', context, options)\n }\n\n public async getStatus(status: number): Promise<string> {\n return this.http.get(status.toString(), {\n metric: 'status-get',\n })\n }\n\n public async getStatusWithHeaders(\n status: number\n ): Promise<IOResponse<string>> {\n return this.http.getRaw(status.toString(), {\n metric: 'status-get-raw',\n })\n }\n}\n\n```" } ]
code_multi-tenant-search_4d2db628
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of multi-tenant-search/node/clients/index.ts from the multi-tenant-search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\n\nimport Status from './status'\n\n// Extend the default IOClients implementation with our own custom clients.\nexport class Clients extends IOClients {\n public get status() {\n return this.getOrSet('status', Status)\n }\n}\n\n```" } ]
code_multi-tenant-search_1d184bb5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of multi-tenant-search/node/middlewares/status.ts from the multi-tenant-search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport async function status(ctx: Context, next: () => Promise<any>) {\n const {\n state: { code },\n clients: { status: statusClient },\n } = ctx\n\n console.info('Received code:', code)\n\n const statusResponse = await statusClient.getStatus(code)\n\n console.info('Status response:', statusResponse)\n\n const {\n headers,\n data,\n status: responseStatus,\n } = await statusClient.getStatusWithHeaders(code)\n\n console.info('Status headers', headers)\n console.info('Status data:', data)\n\n ctx.status = responseStatus\n ctx.body = data\n ctx.set('Cache-Control', headers['cache-control'])\n\n await next()\n}\n\n```" } ]
code_multi-tenant-search_a09e719f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of multi-tenant-search/node/middlewares/validate.ts from the multi-tenant-search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { UserInputError } from '@vtex/api'\n\nexport async function validate(ctx: Context, next: () => Promise<any>) {\n const {\n vtex: {\n route: { params },\n },\n } = ctx\n\n console.info('Received params:', params)\n\n const { code } = params\n\n if (!code) {\n throw new UserInputError('Code is required') // Wrapper for a Bad Request (400) HTTP Error. Check others in https://github.com/vtex/node-vtex-api/blob/fd6139349de4e68825b1074f1959dd8d0c8f4d5b/src/errors/index.ts\n }\n\n const codeNumber = parseInt(code as string, 10)\n\n ctx.state.code = codeNumber\n\n await next()\n}\n\n```" } ]
code_multi-tenant-search_ccc3481b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of multi-tenant-search/node/__tests__/simple.test.ts from the multi-tenant-search VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n// You can import your files here for testing them\n//\n// More info: https://github.com/sapegin/jest-cheat-sheet\n\ndescribe('simpleTest', () => {\n it('one test case', async () => {\n expect(0.2 + 0.1).not.toBe(0.3)\n })\n})\n\n```" } ]
code_dartel-external-prices-node_e41de30e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of dartel-external-prices-node/docs/README.md from the dartel-external-prices-node VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# B2B Seller Price\n\nA reference IO app to allow B2B sellers to define prices based on the user email, by using the external price source through the Pricing Hub service.\n\n## Implementation\n\nThis app is ready to use. You can install it on the `master` workspace of the seller account.\n\nIf you want to customize the app to use other price parameters, follow the instructions below.\n\n1. Fork this app.\n\n2. In the `manifest.json` file:\n * Change the `vendor` field to the name of the account you are using.\n * Change the `name` field to one of your choosing.\n * Add your service host (e.g. `myhost.com`) in an `outbound-access` policy.\n\n3. In the `node/env.ts` file, add your service endpoint as follows:\n\n ```\n const ENV = {\n SERVICE_ENDPOINT: 'http://myservice.com',\n }\n \n export default ENV\n ```\n\n4. Change the ` node/clients/externalPrice.ts` file to parse data received by the external pricing app and return it in a way that Pricing Hub can understand. See more details on the specification of this format in the [Pricing Hub documentation](https://developers.vtex.com/vtex-rest-api/docs/pricing-hub).\n\n\n> ⛔ Do not change the `\"routes\"` in `node/service.json` nor the files in `node/typings/`, since they were created to reflect Pricing Hub behavior.\n\n```" } ]
code_dartel-external-prices-node_ab549800
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of dartel-external-prices-node/node/service.json from the dartel-external-prices-node VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"memory\": 512,\n \"ttl\": 10,\n \"timeout\": 2,\n \"minReplicas\": 2,\n \"maxReplicas\": 120,\n \"workers\": 1,\n \"cpu\": {\n \"type\": \"shared\",\n \"value\": 20\n },\n \"routes\": {\n \"price\": {\n \"path\": \"/_v/external-prices/price\",\n \"public\": false,\n \"access\": \"authorized\",\n \"policies\": [\n {\n \"effect\": \"allow\",\n \"actions\": [\"post\"],\n \"principals\": [\"vrn:vtex.vtex-id:*:*:*:user/vtexappkey-appvtex\"]\n }\n ]\n },\n \"keep-alive\": {\n \"path\": \"/_v/external-prices/keep-alive\",\n \"public\": true,\n \"policies\": [\n {\n \"effect\": \"allow\",\n \"actions\": [\"get\"]\n }\n ]\n }\n }\n}\n\n```" } ]
code_dartel-external-prices-node_49892137
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of dartel-external-prices-node/node/package.json from the dartel-external-prices-node VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"co-body\": \"^6.0.0\",\n \"ramda\": \"^0.25.0\"\n },\n \"devDependencies\": {\n \"@types/co-body\": \"^0.0.3\",\n \"@types/jest\": \"^24.0.18\",\n \"@types/node\": \"^12.0.0\",\n \"@types/node-fetch\": \"^2.5.8\",\n \"@types/ramda\": \"types/npm-ramda#dist\",\n \"@vtex/api\": \"6.45.12\",\n \"@vtex/test-tools\": \"^1.0.0\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"typescript\": \"3.9.7\",\n \"vtex.external-prices-node-unilever\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.external-prices-node-unilever@0.7.0/public/_types/react\",\n \"vtex.splunk-monitoring\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.splunk-monitoring@1.2.0/public/@types/vtex.splunk-monitoring\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty\"\n },\n \"version\": \"0.7.6\"\n}\n\n```" } ]
code_dartel-external-prices-node_cd99015c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of dartel-external-prices-node/node/index.ts from the dartel-external-prices-node VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { ClientsConfig } from '@vtex/api'\nimport { LRUCache, method, Service } from '@vtex/api'\n\nimport { Clients } from './clients'\nimport { validate } from './handlers/validate'\nimport { fetchPrice } from './handlers/fetchPrice'\nimport { formatResponse } from './handlers/formatResponse'\n\nconst TIMEOUT_MS = 800\nconst memoryCache = new LRUCache<string, never>({ max: 5000 })\n\nconst clients: ClientsConfig<Clients> = {\n implementation: Clients,\n options: {\n default: {\n retries: 2,\n timeout: TIMEOUT_MS,\n },\n status: {\n memoryCache,\n },\n },\n}\n\nasync function keepAlive(ctx: Context) {\n ctx.set('Cache-Control', 'no-cache')\n ctx.status = 200\n}\n\nexport default new Service({\n clients,\n routes: {\n price: method({\n POST: [validate, fetchPrice, formatResponse],\n }),\n 'keep-alive': method({\n GET: keepAlive,\n }),\n },\n})\n\n```" } ]
code_dartel-external-prices-node_699be0d3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of dartel-external-prices-node/node/env.ts from the dartel-external-prices-node VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n// App Settings\nconst ENV = {\n SERVICE_ENDPOINT: 'YOUR_SERVICE_ENDPOINT',\n}\n\nexport default ENV\n\n```" } ]
code_dartel-external-prices-node_69e569ef
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of dartel-external-prices-node/node/clients/externalPrice.ts from the dartel-external-prices-node VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { ExternalClient, TooManyRequestsError } from '@vtex/api'\n\nimport type { InputItem } from '../typings/externalPrice'\nimport ENV from '../env'\n\nexport interface ExternalPriceClient {\n getPrice: (item: InputItem) => Promise<number | undefined>\n}\n\nexport default class ExternalPrice\n extends ExternalClient\n implements ExternalPriceClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(ENV.SERVICE_ENDPOINT, context, options)\n }\n\n public async getPrice(item: InputItem): Promise<number | undefined> {\n try {\n return await this.http.get(item.skuId, {\n metric: 'get-price',\n })\n } catch (e) {\n if (e.response.status === 404) {\n return undefined\n }\n\n if (e.response.status === 429) {\n throw new TooManyRequestsError()\n }\n\n throw e\n }\n }\n}\n\n```" } ]
code_dartel-external-prices-node_e116f985
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of dartel-external-prices-node/node/clients/profileSystemClient.ts from the dartel-external-prices-node VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext, RequestConfig } from '@vtex/api'\nimport { JanusClient } from '@vtex/api'\nimport type { AxiosError } from 'axios'\n\nimport { statusToError } from '../utils/statusCodeUtils'\nimport type { CurrentProfile, Profile } from '../typings/profileSystem'\n\nconst FIVE_SECONDS_MS = 5 * 1000\n\nexport class ProfileSystemClient extends JanusClient {\n private baseUrl = '/api/profile-system/pvt/profiles'\n\n constructor(context: IOContext, options?: InstanceOptions) {\n super(context, {\n ...options,\n headers: {\n ...options?.headers,\n VtexIdClientAutCookie: context.authToken,\n },\n timeout: FIVE_SECONDS_MS,\n })\n }\n\n public getProfileInfo = (user: CurrentProfile, customFields?: string) =>\n this.get<Profile>(\n `${this.baseUrl}/${this.getUserIdentification(user)}/personalData`,\n {\n metric: 'profile-system-getProfileInfo',\n params: {\n extraFields: customFields,\n },\n }\n )\n\n protected get = <T>(url: string, config?: RequestConfig) =>\n this.http.get<T>(url, config).catch<AxiosError>(statusToError)\n\n private getUserIdentification = (user: CurrentProfile) =>\n user.userId ?? encodeURIComponent(user.email)\n}\n\n```" } ]
code_dartel-external-prices-node_a54bb358
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of dartel-external-prices-node/node/clients/externalPriceMock.ts from the dartel-external-prices-node VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { IOClient } from '@vtex/api'\n\nimport type { ExternalPriceClient } from './externalPrice'\nimport type { InputItem } from '../typings/externalPrice'\n\nexport default class ExternalPrice\n extends IOClient\n implements ExternalPriceClient {\n public async getPrice(item: InputItem): Promise<number | undefined> {\n return Number(item.skuId) * 10\n }\n}\n\n```" } ]
code_dartel-external-prices-node_1a5daa51
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of dartel-external-prices-node/node/clients/index.ts from the dartel-external-prices-node VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\n\nimport ExternalPrice from './externalPriceMock'\nimport PricingClient from './pricingClient'\nimport { ProfileSystemClient } from './profileSystemClient'\n\n// Extend the default IOClients implementation with our own custom clients.\nexport class Clients extends IOClients {\n public get externalPrice() {\n return this.getOrSet('externalPrice', ExternalPrice)\n }\n\n public get pricing() {\n return this.getOrSet('pricing', PricingClient)\n }\n\n public get profileSystem() {\n return this.getOrSet('profileSystem', ProfileSystemClient)\n }\n}\n\n```" } ]