id
stringlengths 12
53
| messages
listlengths 3
3
|
|---|---|
code_product-customizer_fa510a5c
|
[
{
"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 product-customizer/react/components/ProductAssemblyOptions/ProductAssemblyOptionInputValues.tsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC, Fragment } from 'react'\n\nimport { useProductAssemblyGroupState } from '../ProductAssemblyContext/Group'\nimport TextInputValue from './InputValue/TextInputValue'\nimport OptionsInputValue, {\n OptionDisplay,\n} from './InputValue/OptionsInputValue'\nimport BooleanInputValue from './InputValue/BooleanInputValue'\nimport { InputValueType } from '../../modules/inputValueType'\n\ninterface Props {\n optionsDisplay?: OptionDisplay\n}\n\nconst ProductAssemblyOptionItemInputValues: FC<Props> = ({\n optionsDisplay,\n}) => {\n const state = useProductAssemblyGroupState()\n\n if (!state) {\n return null\n }\n\n const { inputValues } = state\n\n return (\n <Fragment>\n {inputValues.map((inputValue, index) => {\n if (inputValue.type === InputValueType.TEXT) {\n return <TextInputValue key={index} inputValueInfo={inputValue} />\n }\n\n if (inputValue.type === InputValueType.OPTIONS) {\n return (\n <OptionsInputValue\n key={index}\n inputValueInfo={inputValue}\n optionsDisplay={optionsDisplay}\n />\n )\n }\n\n if (inputValue.type === InputValueType.BOOLEAN) {\n return <BooleanInputValue key={index} inputValueInfo={inputValue} />\n }\n\n return null\n })}\n </Fragment>\n )\n}\n\nexport default ProductAssemblyOptionItemInputValues\n\n```"
}
] |
code_product-customizer_03467815
|
[
{
"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 product-customizer/react/components/ProductAssemblyOptions/ProductAssemblyOptionItemChildrenDescription.tsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\n\nimport { useProductAssemblyItem } from '../ProductAssemblyContext/Item'\nimport { GROUP_TYPES } from '../../modules/assemblyGroupType'\nimport { withItem } from './withItem'\n\nconst getItemText = (item: AssemblyItem, groupType: GroupTypes) => {\n const deltaQuantity = item.quantity - item.initialQuantity\n\n if (deltaQuantity === 0) {\n return null\n }\n\n if (groupType === GROUP_TYPES.SINGLE) {\n return deltaQuantity > 0 ? item.name : null\n }\n\n if (groupType === GROUP_TYPES.TOGGLE) {\n return deltaQuantity > 0 ? item.name : `No ${item.name}`\n }\n\n const sign = deltaQuantity < 0 ? '-' : '+'\n\n return `${sign}${deltaQuantity}x ${item.name}`\n}\n\nconst ProductAssemblyOptionItemChildrenDescription: FC = () => {\n const { children } = useProductAssemblyItem() as AssemblyItem\n\n if (!children) {\n return null\n }\n\n const groups = Object.values(children)\n\n return (\n <div>\n {groups.map((group) => {\n const assemblyGroup = group as AssemblyOptionGroup\n\n const items = Object.values(assemblyGroup.items || []).filter(\n ({ quantity, initialQuantity }) => quantity !== initialQuantity\n )\n\n if (items.length === 0) {\n return null\n }\n\n return (\n <div className=\"flex\" key={assemblyGroup.id}>\n <div className=\"mh2\">\n {items.map((item) => {\n const itemText = getItemText(item, assemblyGroup.type)\n\n return (\n itemText && (\n <div key={itemText} className=\"c-on-base t-body\">\n {itemText}\n </div>\n )\n )\n })}\n </div>\n </div>\n )\n })}\n </div>\n )\n}\n\nexport default withItem(ProductAssemblyOptionItemChildrenDescription)\n\n```"
}
] |
code_product-customizer_f5aedb3d
|
[
{
"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 product-customizer/react/components/ProductAssemblyOptions/ProductAssemblyOptionInputValues.test.tsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport {\n render,\n fireEvent,\n within,\n waitForElementToBeRemoved,\n} from '@vtex/test-tools/react'\nimport useProduct, { ProductContext } from 'vtex.product-context/useProduct'\nimport { useProductDispatch } from 'vtex.product-context/ProductDispatchContext'\n\nimport ProductAssemblyOptions from '../../ProductAssemblyOptions'\nimport InputValue from './ProductAssemblyOptionInputValues'\nimport productAttachment from '../../__fixtures__/productAttachment.json'\nimport productRecursive from '../../__fixtures__/productRecursive.json'\nimport ProductAssemblyOptionItemName from './ProductAssemblyOptionItemName'\nimport ProductAssemblyOptionItemCustomize from './ProductAssemblyOptionItemCustomize'\nimport ProductAssemblyOptionItemQuantity from './ProductAssemblyOptionItemQuantity'\n\nconst mockedUseProductDispatch = useProductDispatch as jest.Mock<\n () => jest.Mock\n>\n\nconst mockUseProduct = useProduct as jest.Mock<ProductContext>\n\nfunction renderComponent(customProps = {}) {\n return render(\n <ProductAssemblyOptions>\n <ProductAssemblyOptionItemName />\n <InputValue {...customProps} />\n </ProductAssemblyOptions>\n )\n}\n\nmockUseProduct.mockImplementation(() => ({\n product: productAttachment.data.product,\n selectedItem: productAttachment.data.product.items[6],\n selectedQuantity: 1,\n}))\n\nlet mockedDispatch = jest.fn()\n\nbeforeEach(() => {\n mockedDispatch = jest.fn()\n mockedUseProductDispatch.mockImplementation(() => mockedDispatch)\n})\n\ntest('should handle Options input value', () => {\n const { getByLabelText } = renderComponent()\n\n const font = getByLabelText(/Font/) as HTMLSelectElement\n\n fireEvent.change(font, { target: { value: 'Roman' } })\n\n expect(font.value).toBe('Roman')\n})\n\ntest('should handle Text input value', () => {\n const { getByLabelText } = renderComponent()\n\n const frontText = getByLabelText(/Front text/) as HTMLInputElement\n\n fireEvent.change(frontText, { target: { value: 'Foobar' } })\n\n expect(frontText.value).toBe('Foobar')\n})\n\ntest('should handle Boolean input value', () => {\n const { getByLabelText } = renderComponent()\n\n const glossyPrint = getByLabelText(/Glossy print/) as HTMLInputElement\n\n fireEvent.click(glossyPrint)\n\n expect(glossyPrint.checked).toBe(false)\n})\n\ntest('should show other type of options', () => {\n const { getByText } = renderComponent({ optionsDisplay: 'box' })\n\n getByText(/Sans serif/)\n\n const romanOption = getByText(/Roman/)\n\n fireEvent.click(romanOption)\n\n const lastCall =\n mockedDispatch.mock.calls[mockedDispatch.mock.calls.length - 1]\n\n expect(lastCall[0].args.groupInputValues.Font).toBe('Roman')\n})\n\ntest('should trigger changes to Product Context', () => {\n const { getByLabelText } = renderComponent()\n\n const font = getByLabelText(/Font/) as HTMLSelectElement\n\n fireEvent.change(font, { target: { value: 'Roman' } })\n\n expect(mockedDispatch.mock.calls[0][0].args.groupInputValues.Font).toBe(\n 'Roman'\n )\n expect(\n mockedDispatch.mock.calls[0][0].args.groupInputValues['Front text']\n ).toBe('')\n expect(\n mockedDispatch.mock.calls[0][0].args.groupInputValues['Back text']\n ).toBe('')\n expect(\n mockedDispatch.mock.calls[0][0].args.groupInputValues['Glossy print']\n ).toBe(true)\n\n const frontText = getByLabelText(/Front text/) as HTMLInputElement\n\n fireEvent.change(frontText, { target: { value: 'Foobar' } })\n const glossyPrint = getByLabelText(/Glossy print/) as HTMLInputElement\n\n fireEvent.click(glossyPrint)\n\n expect(mockedDispatch.mock.calls).toHaveLength(4)\n expect(mockedDispatch.mock.calls[0][0].type).toBe('SET_ASSEMBLY_OPTIONS')\n expect(mockedDispatch.mock.calls[1][0].args.groupInputValues.Font).toBe(\n 'Roman'\n )\n expect(\n mockedDispatch.mock.calls[2][0].args.groupInputValues['Front text']\n ).toBe('Foobar')\n expect(\n mockedDispatch.mock.calls[3][0].args.groupInputValues['Glossy print']\n ).toBe(false)\n})\n\nfunction renderComponentRecursive() {\n return render(\n <ProductAssemblyOptions>\n <ProductAssemblyOptionItemName />\n <InputValue />\n <ProductAssemblyOptionItemCustomize>\n <ProductAssemblyOptionItemName />\n <InputValue />\n </ProductAssemblyOptionItemCustomize>\n </ProductAssemblyOptions>\n )\n}\n\nwindow.scroll = () => null\nwindow.scrollTo = () => null\n\ntest('should keep input values for recursive assemblies', async () => {\n mockUseProduct.mockImplementation(() => ({\n product: productRecursive.data.product,\n selectedItem: productRecursive.data.product.items[0],\n selectedQuantity: 1,\n }))\n\n const { getByText, getByLabelText } = renderComponentRecursive()\n\n // Click on button Customize\n const assembly = getByText('Bells add-ons 1-3 lines')\n const customizeButton = assembly.parentElement?.querySelector(\n '.vtex-button'\n ) as HTMLElement\n\n fireEvent.click(customizeButton)\n\n // Click on Add 1-3-lines inside the modal\n const modal = within(\n document.querySelector('.vtex-modal__modal') as HTMLElement\n )\n\n const modalCustomizeButton = modal.getByText('Add 1-3-lines')\n\n fireEvent.click(modalCustomizeButton)\n\n // Type \"Foobar\" in the Input Value \"Line 1\"\n const input = modal.getByLabelText('Line 1')\n\n fireEvent.change(input, { target: { value: 'Foobar' } })\n\n expect(mockedDispatch.mock.calls).toHaveLength(7)\n // eslint-disable-next-line prefer-destructuring\n const [lastCall] = mockedDispatch.mock.calls[5]\n\n expect(lastCall.type).toBe('SET_ASSEMBLY_OPTIONS')\n expect(lastCall.args.groupInputValues['Line 1']).toBe('Foobar')\n\n // Close the modal\n fireEvent.click(\n document.querySelector('.vtex-modal__modal .vtex__icon-close') as Element\n )\n\n // Wait for the close transition to end\n await waitForElementToBeRemoved(() =>\n document.querySelector('.vtex-modal__modal .vtex__icon-close')\n )\n\n // Click on Customize button to open the modal again\n fireEvent.click(customizeButton)\n\n // Check if input still set with \"Foobar\" previously typed\n const inputLine1 = getByLabelText('Line 1') as HTMLInputElement\n\n expect(inputLine1.value).toBe('Foobar')\n})\n\ntest('should select option when click in customize', () => {\n mockUseProduct.mockImplementation(() => ({\n product: productRecursive.data.product,\n selectedItem: productRecursive.data.product.items[0],\n selectedQuantity: 1,\n }))\n\n const { getByText } = render(\n <ProductAssemblyOptions>\n <ProductAssemblyOptionItemName />\n <InputValue />\n <ProductAssemblyOptionItemQuantity />\n <ProductAssemblyOptionItemCustomize>\n <ProductAssemblyOptionItemName />\n <InputValue />\n </ProductAssemblyOptionItemCustomize>\n </ProductAssemblyOptions>\n )\n\n const checkStyleguideCheckboxChecked = (container: HTMLElement) => {\n const radioButton = container.querySelector(\n '.vtex-checkbox__inner-container'\n ) as HTMLElement\n\n const classList = Array.from(radioButton.classList)\n\n return classList.includes('b--action-primary')\n }\n\n // Click on button Customize\n const assembly = getByText('Bells add-ons 1-3 lines')\n\n const isCheckedBefore = checkStyleguideCheckboxChecked(\n assembly.parentElement as HTMLElement\n )\n\n expect(isCheckedBefore).toBe(false)\n\n const customizeButton = assembly.parentElement?.querySelector(\n '.vtex-button'\n ) as HTMLElement\n\n fireEvent.click(customizeButton)\n\n const isCheckedAfter = checkStyleguideCheckboxChecked(\n assembly.parentElement as HTMLElement\n )\n\n expect(isCheckedAfter).toBe(true)\n})\n\n```"
}
] |
code_product-customizer_4d90fad8
|
[
{
"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 product-customizer/react/components/Product/ToggleChoiceAttachment.jsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```jsx\nimport React, { Component, Fragment } from 'react'\n\nimport ToggledChoice from '../Variation/Items/ToggledChoice'\n\nconst parseItem = ({ id, quantity, seller, name }) => ({\n [name]: { id, quantity: Number(!quantity), seller },\n})\n\nclass ToggleChoiceAttachment extends Component {\n handleChange = (itemName) => {\n const { items, name, onAttachmentChange } = this.props\n\n onAttachmentChange(name, parseItem(items[itemName]), false)\n }\n\n render() {\n const { items } = this.props\n\n return (\n <Fragment>\n {Object.entries(items).map(([itemName, item]) => (\n <ToggledChoice\n imageUrl={item.imageUrl}\n name={item.name}\n selected={item.quantity === 1}\n disabled={item.minQuantity === 1}\n onChange={this.handleChange}\n key={itemName}\n />\n ))}\n </Fragment>\n )\n }\n}\n\nexport default ToggleChoiceAttachment\n\n```"
}
] |
code_product-customizer_25b61553
|
[
{
"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 product-customizer/react/components/Product/SingleChoiceAttachment.jsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```jsx\nimport React, { Fragment, Component } from 'react'\n\nimport SingleChoice from '../Variation/Items/SingleChoice'\n\nconst parseItem = ({ id, seller, name }) => ({\n [name]: { id, seller, quantity: 1 },\n})\n\nclass SingleChoiceAttachment extends Component {\n handleOnChange = (itemName) => {\n const { name, onAttachmentChange, items } = this.props\n\n onAttachmentChange(name, parseItem(items[itemName]), true)\n }\n\n render() {\n const { items } = this.props\n\n return (\n <Fragment>\n {Object.entries(items).map(([itemName, item]) => (\n <SingleChoice\n price={item.price}\n imageUrl={item.imageUrl}\n name={item.name}\n selected={item.quantity === 1}\n onChange={this.handleOnChange}\n key={itemName}\n showPlus\n />\n ))}\n </Fragment>\n )\n }\n}\n\nexport default SingleChoiceAttachment\n\n```"
}
] |
code_product-customizer_50ba448b
|
[
{
"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 product-customizer/react/components/Product/MultipleChoiceAttachment.jsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```jsx\nimport React, { Fragment, Component } from 'react'\n\nimport MultipleChoice from '../Variation/Items/MultipleChoice'\n\nclass MultipleChoiceAttachment extends Component {\n getUpdatedQuantities(updatedItem, quantity) {\n const quantities = Object.values(this.props.items).reduce(\n (acc, item) => ({\n ...acc,\n [item.name]: {\n id: item.id,\n quantity: item.quantity,\n seller: item.seller,\n },\n }),\n {}\n )\n\n quantities[updatedItem].quantity = quantity\n\n return quantities\n }\n\n canChangeTotalItems(delta) {\n const { minTotalItems, maxTotalItems, items } = this.props\n const totalItems = Object.values(items).reduce(\n (count, item) => count + item.quantity,\n 0\n )\n\n const newTotalItems = totalItems + delta\n\n return minTotalItems <= newTotalItems && newTotalItems <= maxTotalItems\n }\n\n canChangeItemQuantity(itemName, newQuantity) {\n const { minQuantity, quantity, maxQuantity } = this.props.items[itemName]\n\n return (\n minQuantity <= newQuantity &&\n newQuantity <= maxQuantity &&\n this.canChangeTotalItems(newQuantity - quantity)\n )\n }\n\n handleChangeItemQuantity(itemName, quantity) {\n const { name, onAttachmentChange } = this.props\n\n // eslint-disable-next-line vtex/prefer-early-return\n if (this.canChangeItemQuantity(itemName, quantity)) {\n const quantities = this.getUpdatedQuantities(itemName, quantity)\n\n onAttachmentChange(name, quantities, false)\n }\n }\n\n handleOnChange = (value, itemName) =>\n this.handleChangeItemQuantity(itemName, value)\n\n getItemProps(itemName) {\n const { items } = this.props\n const { imageUrl, price, name, quantity } = items[itemName]\n\n return {\n imageUrl,\n price,\n name,\n chosenAmount: quantity,\n canIncrease: this.canChangeItemQuantity(itemName, quantity + 1),\n canDecrease: this.canChangeItemQuantity(itemName, quantity - 1),\n onChange: this.handleOnChange,\n }\n }\n\n render() {\n const { items } = this.props\n const itemsNames = Object.keys(items)\n\n return (\n <Fragment>\n {itemsNames.map((itemName) => (\n <MultipleChoice {...this.getItemProps(itemName)} key={itemName} />\n ))}\n </Fragment>\n )\n }\n}\n\nexport default MultipleChoiceAttachment\n\n```"
}
] |
code_product-customizer_72b38318
|
[
{
"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 product-customizer/react/components/Product/AttachmentPicker.jsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```jsx\nimport React, { Fragment } from 'react'\nimport { FormattedMessage } from 'react-intl'\n\nimport SingleChoiceAttachment from './SingleChoiceAttachment'\nimport MultipleChoiceAttachment from './MultipleChoiceAttachment'\nimport ToggleChoiceAttachment from './ToggleChoiceAttachment'\n\nfunction getTitleId({ name }) {\n const key = name.toLowerCase().split(' ').join('-')\n\n return `store/product-customizer.${key}-title`\n}\n\nfunction AttachmentPicker({\n name,\n items,\n properties: { minTotalItems, maxTotalItems },\n onAttachmentChange,\n isToggleChoice,\n isSingleChoice,\n}) {\n if (isSingleChoice) {\n return (\n <SingleChoiceAttachment\n name={name}\n items={items}\n onAttachmentChange={onAttachmentChange}\n />\n )\n }\n\n if (isToggleChoice) {\n return (\n <ToggleChoiceAttachment\n name={name}\n items={items}\n onAttachmentChange={onAttachmentChange}\n />\n )\n }\n\n return (\n <MultipleChoiceAttachment\n {...{ name, items, onAttachmentChange, minTotalItems, maxTotalItems }}\n />\n )\n}\n\nfunction AttachmentPickerWithTitle(props) {\n return (\n <Fragment>\n <div className=\"ph5 pv4 c-muted-2 t-small\">\n <FormattedMessage id={getTitleId(props)} />\n </div>\n <AttachmentPicker {...props} />\n </Fragment>\n )\n}\n\nexport default AttachmentPickerWithTitle\n\n```"
}
] |
code_product-customizer_f2454fc0
|
[
{
"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 product-customizer/react/components/Product/ProductCustomizerWrapper.jsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```jsx\n/* eslint-disable max-params */\nimport React, { Fragment, Component } from 'react'\nimport smoothscroll from 'smoothscroll-polyfill'\nimport { withToast } from 'vtex.styleguide'\nimport { injectIntl } from 'react-intl'\nimport { compose, pathOr } from 'ramda'\nimport { graphql } from 'react-apollo'\n\nimport SkuSelector from './SkuSelector'\nimport AttachmentsPicker from './AttachmentsPicker'\nimport MovingBottomButton from '../Buttons/MovingBottomButton'\nimport { scrollToElementTop } from '../../utils/scroll'\nimport ADD_TO_CART_MUTATION from '../../mutations/addToCart.gql'\n\nclass ProductCustomizerWrapper extends Component {\n state = {\n selectedSku: null,\n chosenAttachments: {},\n isAddingToCart: false,\n }\n\n attachmentView = React.createRef()\n\n componentDidMount() {\n smoothscroll.polyfill()\n }\n\n handleSkuChange = (item, shouldScroll) => {\n this.setState({\n selectedSku: item,\n chosenAttachments: this.getQuantitiesFromSkuAttachments(item),\n })\n item && shouldScroll && scrollToElementTop(this.attachmentView.current)\n }\n\n getQuantitiesFromSkuAttachments = (sku) =>\n sku\n ? Object.entries(this.props.product.items[sku].attachments).reduce(\n (quantities, [attName, attachment]) => ({\n ...quantities,\n [attName]: this.getQuantitiesFromItems(attachment.items),\n }),\n {}\n )\n : {}\n\n getQuantitiesFromItems = (items) =>\n Object.entries(items).reduce(\n (quantities, [itemName, item]) => ({\n ...quantities,\n [itemName]: {\n id: item.id,\n quantity: +item.initialQuantity,\n seller: item.seller,\n },\n }),\n {}\n )\n\n handleAttachmentChange = (\n attachmentName,\n quantities,\n isSingleChoice,\n callback\n ) => {\n this.setState(\n (state) => ({\n chosenAttachments: {\n ...state.chosenAttachments,\n [attachmentName]: {\n ...(state.chosenAttachments[attachmentName] && !isSingleChoice),\n ...quantities,\n },\n },\n }),\n () => callback && callback(this.state.chosenAttachments)\n )\n }\n\n getTotalPrice(attachments) {\n const { selectedSku } = this.state\n const baseValue = this.props.product.items[selectedSku].price\n\n return Object.values(attachments).reduce(\n (total, attachment) => total + this.getAttachmentPrice(attachment),\n baseValue * 100\n )\n }\n\n getAttachmentPrice(attachment) {\n return Object.values(attachment.items).reduce(\n (total, { price, quantity }) => total + price * quantity,\n 0\n )\n }\n\n getAttachmentsWithQuantities(attachments, quantities) {\n return Object.entries(attachments).reduce(\n (obj, [name, attachment]) => ({\n ...obj,\n [name]: this.getAttachmentWithQuantities(attachment, quantities[name]),\n }),\n {}\n )\n }\n\n getAttachmentWithQuantities(attachment, quantities) {\n const [quantity, items] = Object.entries(attachment.items).reduce(\n ([total, obj], [name, item]) => {\n // eslint-disable-next-line no-shadow\n const quantity =\n name in quantities ? quantities[name].quantity : +item.initialQuantity\n\n return [total + quantity, { ...obj, [name]: { ...item, quantity } }]\n },\n [0, {}]\n )\n\n return { ...attachment, items, quantity }\n }\n\n isSkuReady(attachments) {\n return Object.values(attachments).every(this.isAttachmentReady)\n }\n\n isAttachmentReady(attachment) {\n const {\n quantity,\n properties: { minTotalItems, maxTotalItems },\n } = attachment\n\n return quantity >= minTotalItems && quantity <= maxTotalItems\n }\n\n getChoiceType = ({ isSingleChoice, isToggleChoice }) => {\n if (isSingleChoice) {\n return 'SINGLE'\n }\n\n if (isToggleChoice) {\n return 'TOGGLE'\n }\n\n return 'MULTIPLE'\n }\n\n getAssemblyOptions = () => {\n const { chosenAttachments, selectedSku } = this.state\n const { product } = this.props\n\n const options = []\n const added = []\n const removed = []\n\n Object.entries(chosenAttachments).forEach(([suffix, attachObj]) => {\n const attachmentTypeInfo = product.items[selectedSku].attachments[suffix]\n const { assemblyId } = attachmentTypeInfo\n\n Object.entries(attachObj).forEach(([name, { id, quantity, seller }]) => {\n const initialQuantity = pathOr(\n 0,\n [\n 'items',\n selectedSku,\n 'attachments',\n suffix,\n 'items',\n name,\n 'initialQuantity',\n ],\n product\n )\n\n if (quantity > initialQuantity) {\n added.push({\n normalizedQuantity: quantity,\n extraQuantity: quantity - initialQuantity,\n choiceType: this.getChoiceType(attachmentTypeInfo),\n item: {\n name,\n sellingPrice:\n pathOr(\n 0,\n [\n 'items',\n selectedSku,\n 'attachments',\n suffix,\n 'items',\n name,\n 'price',\n ],\n product\n ) / 100,\n quantity,\n id,\n },\n })\n }\n\n if (quantity < initialQuantity) {\n removed.push({\n name,\n initialQuantity,\n removedQuantity: initialQuantity - quantity,\n })\n }\n\n if (quantity !== initialQuantity) {\n options.push({ assemblyId, id, quantity, seller })\n }\n })\n })\n\n return { options, removed, added }\n }\n\n showToast = (success) => {\n const suffix = success ? 'buy-success' : 'add-failure'\n const message = this.props.intl.formatMessage({\n id: `store/product-customizer.${suffix}`,\n })\n\n this.props.showToast({ message })\n }\n\n handleSubmitAddToCart = async () => {\n const { product, addToCart } = this.props\n const { selectedSku } = this.state\n\n this.setState({ isAddingToCart: true })\n\n const skuData = product.items[selectedSku]\n const {\n skuId,\n seller,\n commertialOffer,\n skuImageUrl,\n name,\n detailUrl,\n } = skuData\n\n const { options, added, removed } = this.getAssemblyOptions()\n const payload = {\n quantity: 1,\n options,\n id: skuId,\n sellingPrice: commertialOffer.Price,\n listPrice: commertialOffer.ListPrice,\n skuName: name,\n imageUrl: skuImageUrl,\n name,\n detailUrl,\n seller,\n assemblyOptions: {\n added,\n removed,\n parentPrice: commertialOffer.Price,\n },\n }\n\n try {\n const {\n data: { addToCart: linkStateItems },\n } = await addToCart([payload])\n\n const success =\n linkStateItems && !!linkStateItems.find(({ id }) => id === skuId)\n\n this.showToast(success)\n } catch (err) {\n this.showToast(false)\n // TODO send to splunk\n }\n\n this.setState({ isAddingToCart: false })\n }\n\n render() {\n const { imageText, imageUrl, items, productName } = this.props.product\n const { selectedSku, chosenAttachments, isAddingToCart } = this.state\n\n const attachments =\n selectedSku &&\n this.getAttachmentsWithQuantities(\n items[selectedSku].attachments,\n chosenAttachments\n )\n\n const ready = attachments && this.isSkuReady(attachments)\n const total = attachments && this.getTotalPrice(attachments)\n\n return (\n <Fragment>\n <div className=\"flex-ns pv6-ns justify-center-ns\">\n <div className=\"w-100 w-third-ns flex tc items-center-ns h-100-ns ph2-ns\">\n <img\n className=\"vtex-product-customizer__image\"\n src={imageUrl}\n alt={imageText}\n />\n </div>\n <div className=\"w-40-ns ph2-ns\">\n <div className=\"t-heading-4 c-on-base ph5 pt5-s\">{productName}</div>\n <SkuSelector\n items={items}\n selectedSku={selectedSku}\n onSkuChange={this.handleSkuChange}\n productQuery={this.props.productQuery}\n />\n <div ref={this.attachmentView}>\n {selectedSku && (\n <AttachmentsPicker\n attachments={attachments}\n selectedSku={selectedSku}\n onAttachmentChange={this.handleAttachmentChange}\n chosenAttachments={chosenAttachments}\n />\n )}\n </div>\n <MovingBottomButton\n ready={ready}\n total={total}\n onSubmitAddToCart={this.handleSubmitAddToCart}\n isLoading={isAddingToCart}\n />\n </div>\n </div>\n </Fragment>\n )\n }\n}\n\nconst withMutation = graphql(ADD_TO_CART_MUTATION, {\n props: ({ mutate }) => ({\n addToCart: (items) => mutate({ variables: { items } }),\n }),\n})\n\nexport default compose(\n injectIntl,\n withToast,\n withMutation\n)(ProductCustomizerWrapper)\n\n```"
}
] |
code_product-customizer_76bdd49c
|
[
{
"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 product-customizer/react/components/Product/AttachmentsPicker.jsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```jsx\nimport React, { Component, Fragment } from 'react'\nimport smoothscroll from 'smoothscroll-polyfill'\n\nimport AttachmentPicker from './AttachmentPicker'\nimport { scrollToElementTop } from '../../utils/scroll'\n\nfunction precedence({ isSingleChoice, isToggleChoice }) {\n if (isSingleChoice) {\n return 0\n }\n\n if (isToggleChoice) {\n return 1\n }\n\n return 2\n}\n\nfunction compareAttachments([_, att1], [__, att2]) {\n return precedence(att1) - precedence(att2)\n}\n\nfunction isSingleChoicePicked(chosenAttachment) {\n return Object.values(chosenAttachment).some(({ quantity }) => quantity > 0)\n}\n\nfunction areAllSinglesPicked(attachments, chosenAttachments) {\n return Object.values(attachments)\n .filter(({ isSingleChoice }) => isSingleChoice)\n .every(({ name }) => isSingleChoicePicked(chosenAttachments[name]))\n}\n\nfunction shouldShowAttachment(attachment, canShowOtherAttachments) {\n if (attachment.isSingleChoice) return true\n\n return canShowOtherAttachments\n}\n\nfunction findFirstNonSingleChoice(attachments) {\n return Object.entries(attachments)\n .sort(compareAttachments)\n .find(([_, { isSingleChoice }]) => !isSingleChoice)\n}\n\nclass AttachmentsPicker extends Component {\n pickers = Object.keys(this.props.attachments).reduce(\n (prev, name) => ({ ...prev, [name]: React.createRef() }),\n {}\n )\n\n state = {\n allSinglesPicked: areAllSinglesPicked(\n this.props.attachments,\n this.props.chosenAttachments\n ),\n }\n\n componentDidMount() {\n smoothscroll.polyfill()\n }\n\n componentDidUpdate(prevProps) {\n const { attachments, chosenAttachments } = this.props\n\n if (this.props.selectedSku !== prevProps.selectedSku) {\n this.setState({\n allSinglesPicked: areAllSinglesPicked(attachments, chosenAttachments),\n })\n }\n }\n\n attachmentChangeCallback = (newChosenAttachments) => {\n const { attachments } = this.props\n const currentAllSinglesPicked = this.state.allSinglesPicked\n const newSinglesPicked = areAllSinglesPicked(\n attachments,\n newChosenAttachments\n )\n\n // eslint-disable-next-line vtex/prefer-early-return\n if (currentAllSinglesPicked !== newSinglesPicked) {\n this.setState({ allSinglesPicked: newSinglesPicked })\n const [firstNotSingleName] = findFirstNonSingleChoice(attachments) || []\n const picker = firstNotSingleName && this.pickers[firstNotSingleName]\n\n picker && scrollToElementTop(picker.current)\n }\n }\n\n handleOnAttachmentChange = (attachmentName, quantities, isSingleChoice) => {\n this.props.onAttachmentChange(\n attachmentName,\n quantities,\n isSingleChoice,\n this.attachmentChangeCallback\n )\n }\n\n render() {\n const { attachments } = this.props\n const { allSinglesPicked } = this.state\n\n return (\n <Fragment>\n {Object.entries(attachments)\n .sort(compareAttachments)\n .map(([name, attachment]) => (\n <div\n ref={this.pickers[name]}\n key={name}\n className={`${\n shouldShowAttachment(attachment, allSinglesPicked) ? '' : 'dn'\n }`}\n >\n <AttachmentPicker\n key={name}\n onAttachmentChange={this.handleOnAttachmentChange}\n {...attachment}\n />\n </div>\n ))}\n </Fragment>\n )\n }\n}\n\nexport default AttachmentsPicker\n\n```"
}
] |
code_product-customizer_520df7ef
|
[
{
"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 product-customizer/react/components/Product/ProductCustomizerContainer.jsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```jsx\nimport React, { Component } from 'react'\nimport { all, both, propEq, values, find, path, prop, findLast } from 'ramda'\n\nimport ProductCustomizerWrapper from './ProductCustomizerWrapper'\n\nclass ProductCustomizerContainer extends Component {\n parseProduct(product) {\n const compositionPrices = this.getPriceMap(product.itemMetadata.priceTable)\n\n const items = product.itemMetadata.items.reduce(\n (acc, item) => ({\n ...acc,\n ...this.parseItemMetadata(item, compositionPrices, product.items),\n }),\n {}\n )\n\n return {\n productName: product.productName,\n imageUrl: product.items[0].images[0].imageUrl,\n imageText: product.items[0].images[0].imageText,\n items,\n }\n }\n\n /**\n * Produces an object in which each key is a price table (like small) and the fields are objects that map\n * product ids to its prices\n */\n getPriceMap(priceTable) {\n return priceTable.reduce((prev, curr) => {\n // eslint-disable-next-line no-shadow\n const { type, values } = curr\n const priceMap = values.reduce(\n (currMap, itemPrice) => ({\n ...currMap,\n [itemPrice.id]: itemPrice.price,\n }),\n {}\n )\n\n return { ...prev, [type]: priceMap }\n }, {})\n }\n\n parseAssemblyOption(assemblyOption, prices) {\n const { composition, id } = assemblyOption\n const [, optionName] = id.split('_')\n const items = composition.items.reduce(\n (prev, compCurr) => ({\n ...prev,\n ...this.parseCompositionItem(compCurr, prices),\n }),\n {}\n )\n\n return {\n [optionName]: {\n name: optionName,\n assemblyId: id,\n items,\n properties: {\n maxTotalItems: composition.maxQuantity,\n minTotalItems: composition.minQuantity,\n },\n isSingleChoice: both(\n propEq('minQuantity', 1),\n propEq('maxQuantity', 1)\n )(composition),\n isToggleChoice: all(propEq('maxQuantity', 1))(\n values(composition.items)\n ),\n },\n }\n }\n\n parseCompositionItem(compItem, prices) {\n const { product } = this.props.productQuery\n const metadatas = product.itemMetadata.items\n const { id, priceTable } = compItem\n const compMeta = metadatas.find((metadata) => metadata.id === id)\n const price = prices[priceTable][id]\n const fullComp = {\n ...compMeta,\n ...compItem,\n price,\n }\n\n return { [compMeta.name]: fullComp }\n }\n\n parseItemMetadata(itemMetadata, prices, productItems) {\n if (itemMetadata.assemblyOptions.length === 0) {\n return {}\n }\n\n const { name } = itemMetadata\n const attachments = itemMetadata.assemblyOptions.reduce(\n (prev, option) => ({\n ...prev,\n ...this.parseAssemblyOption(option, prices),\n }),\n {}\n )\n\n const productItem = find(propEq('itemId', itemMetadata.id))(productItems)\n const crustImage = prop('imageUrl')(\n findLast(propEq('imageLabel', 'Crust'))(productItem.images)\n )\n\n const commertialOffer = prop('commertialOffer')(\n find(propEq('sellerId', itemMetadata.seller))(productItem.sellers)\n )\n\n return {\n [name]: {\n attachments,\n commertialOffer,\n imageUrl: crustImage,\n price: commertialOffer.Price,\n seller: itemMetadata.seller,\n skuId: itemMetadata.id,\n listPrice: commertialOffer.ListPrice,\n name: productItem.nameComplete,\n detailUrl: `${this.props.productQuery.product.linkText}/p`,\n skuImageUrl: path(['images', '0', 'imageUrl'], productItem),\n },\n }\n }\n\n render() {\n const { product } = this.props.productQuery\n\n if (!product) {\n return null\n }\n\n return (\n <ProductCustomizerWrapper\n productQuery={this.props.productQuery}\n product={this.parseProduct(product)}\n />\n )\n }\n}\n\nexport default ProductCustomizerContainer\n\n```"
}
] |
code_product-customizer_3dc5782e
|
[
{
"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 product-customizer/react/components/Product/SkuSelector.jsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```jsx\nimport React, { Fragment } from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport { ExtensionPoint } from 'vtex.render-runtime'\nimport { find, pathOr, prop, propEq, sort } from 'ramda'\nimport ProductPrice from 'vtex.store-components/ProductPrice'\n\nimport SingleChoice from '../Variation/Items/SingleChoice'\n\n// Order by availability or by Price\nconst compareSku = (item, otherItem) => {\n const [\n {\n commertialOffer: { AvailableQuantity: quantity, Price: price },\n },\n ] = item.sellers\n\n const [\n {\n commertialOffer: { AvailableQuantity: otherQuantity, Price: otherPrice },\n },\n ] = otherItem.sellers\n\n return quantity === 0 ? 1 : (otherQuantity === 0 && -1) || price - otherPrice\n}\n\nconst moreThanVariations = (items, count) =>\n pathOr(0, ['0', 'variations', 'length'], items) > count\n\nconst getSkuItems = (items) => sort(compareSku, items)\n\nconst getSelectedItem = (items, selectedSku) =>\n selectedSku ? find(propEq('name', selectedSku), items) : null\n\nconst saveSkuSelector = (onSkuChange, skuId, items) => {\n const name = prop('name', find(propEq('itemId', skuId), items))\n\n onSkuChange(name, false)\n}\n\nconst SelectorOptions = ({\n productQuery,\n selectedSku,\n onSkuChange,\n parsedItems,\n}) => {\n const items = pathOr([], ['product', 'items'], productQuery)\n\n // If item has variations field, show SKUSelector\n if (moreThanVariations(items, 0)) {\n return (\n <div className=\"ph5\">\n <ExtensionPoint\n id=\"sku-selector\"\n skuItems={getSkuItems(items)}\n skuSelected={getSelectedItem(items, selectedSku)}\n productSlug={productQuery.product.linkText}\n onSKUSelected={(skuId) => saveSkuSelector(onSkuChange, skuId, items)}\n alwaysShowSecondary={false}\n />\n </div>\n )\n }\n\n // Otherwise, show simple list\n return (\n <Fragment>\n <div className=\"ph5 pb4 c-muted-2 t-small\">\n <FormattedMessage id=\"store/product-customizer.pick-size\" />\n </div>\n {Object.entries(parsedItems).map(([name, item]) => (\n <SingleChoice\n price={item.price * 100}\n imageUrl={item.imageUrl}\n name={name}\n selected={name === selectedSku}\n onChange={onSkuChange}\n key={name}\n showPlus={false}\n />\n ))}\n </Fragment>\n )\n}\n\nfunction SkuSelector({ items, selectedSku, onSkuChange, productQuery }) {\n return (\n <Fragment>\n <div className=\"ph5 pt4 pb2 pb4-ns\">\n {selectedSku && (\n <ProductPrice\n showListPrice\n showLabels={false}\n sellingPrice={items[selectedSku].commertialOffer.Price}\n listPrice={items[selectedSku].commertialOffer.ListPrice}\n sellingPriceClass=\"t-heading-2\"\n sellingPriceContainerClass=\"pv2\"\n listPriceClass=\"c-muted-2 strike\"\n />\n )}\n </div>\n <SelectorOptions\n productQuery={productQuery}\n selectedSku={selectedSku}\n onSkuChange={onSkuChange}\n parsedItems={items}\n />\n </Fragment>\n )\n}\n\nexport default SkuSelector\n\n```"
}
] |
code_product-customizer_1d49dc90
|
[
{
"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 product-customizer/react/components/ProductAssemblyOptions/InputValue/OptionBox.tsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport classNames from 'classnames'\nimport { useCssHandles, applyModifiers } from 'vtex.css-handles'\n\nimport slugify from '../../../modules/slugify'\nimport styles from '../styles.css'\n\nconst CSS_HANDLES = ['inputValueOptionBox'] as const\n\nconst OptionBox: FC<Props> = ({ option, selected, onClick, onKeyDown }) => {\n const handles = useCssHandles(CSS_HANDLES)\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n className={classNames(\n applyModifiers(handles.inputValueOptionBox, slugify(option)),\n 'relative di pointer flex items-center outline-0 mr4'\n )}\n onClick={onClick}\n onKeyDown={onKeyDown}\n >\n <div\n className={classNames(\n styles.frameAround,\n 'absolute b--action-primary br3 bw1',\n {\n ba: selected,\n }\n )}\n />\n <div\n className={classNames(\n 'w-100 h-100 ba br2 bw1 b--muted-4 z-1 c-muted-5 flex items-center overflow-hidden',\n {\n 'hover-b--muted-2': !selected,\n }\n )}\n >\n <div className=\"c-on-base center pv3 ph5 z-1 t-body\">{option}</div>\n </div>\n </div>\n )\n}\n\ninterface Props {\n option: string\n selected: boolean\n onClick: React.MouseEventHandler\n onKeyDown: React.KeyboardEventHandler\n}\n\nexport default OptionBox\n\n```"
}
] |
code_product-customizer_5ad38185
|
[
{
"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 product-customizer/react/components/ProductAssemblyOptions/InputValue/useInputValue.tsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport {\n useProductAssemblyGroupState,\n useProductAssemblyGroupDispatch,\n} from '../../ProductAssemblyContext/Group'\n\ninterface OnChangeParams {\n value: string | boolean\n}\n\nexport default function useInputValue(\n inputId: string\n): [string | boolean, (param: OnChangeParams) => void] {\n const {\n path,\n valuesOfInputValues,\n } = useProductAssemblyGroupState() as AssemblyOptionGroupState\n\n const dispatch = useProductAssemblyGroupDispatch()\n\n const onChange = ({ value }: OnChangeParams) => {\n dispatch({\n type: 'SET_INPUT_VALUE',\n args: {\n inputValueLabel: inputId,\n inputValue: value,\n groupPath: path,\n },\n })\n }\n\n const value = valuesOfInputValues[inputId]\n\n return [value, onChange]\n}\n\nexport function useInputValueId(inputValueInfo: InputValue) {\n const { path } = useProductAssemblyGroupState() as AssemblyOptionGroupState\n\n return inputValueInfo.label + path.join('-')\n}\n\n```"
}
] |
code_product-customizer_50708788
|
[
{
"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 product-customizer/react/components/ProductAssemblyOptions/InputValue/BooleanInputValue.tsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport { Checkbox } from 'vtex.styleguide'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport useInputValue, { useInputValueId } from './useInputValue'\n\nconst CSS_HANDLES = ['booleanInputValue'] as const\n\nconst BooleanInputValue: FC<Props> = ({ inputValueInfo }) => {\n const [state, onChange] = useInputValue(inputValueInfo.label)\n const id = useInputValueId(inputValueInfo)\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const value = e.target.checked\n\n onChange({ value })\n }\n\n const handles = useCssHandles(CSS_HANDLES)\n\n return (\n <div className={`${handles.booleanInputValue} mb4`}>\n <Checkbox\n id={id}\n value={inputValueInfo.label}\n checked={Boolean(state)}\n name={inputValueInfo.label}\n label={inputValueInfo.label}\n onChange={handleChange}\n />\n </div>\n )\n}\n\ninterface Props {\n inputValueInfo: BooleanInputValue\n}\n\nexport default BooleanInputValue\n\n```"
}
] |
code_product-customizer_5ad71931
|
[
{
"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 product-customizer/react/components/ProductAssemblyOptions/InputValue/OptionsInputValue.tsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC, useMemo } from 'react'\nimport { Dropdown } from 'vtex.styleguide'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { useIntl } from 'react-intl'\n\nimport { useProductAssemblyGroupState } from '../../ProductAssemblyContext/Group'\nimport useInputValue from './useInputValue'\nimport OptionBox from './OptionBox'\nimport {\n formatSubscriptionLabel,\n formatSubscriptionOptions,\n isSubscriptionRelated,\n parseFrequency,\n SUBSCRIPTION_KEY_PURCHASEDAY,\n SUBSCRIPTION_KEY_FREQUENCY,\n} from '../../../modules/subscriptions'\n\nconst DROPDOWN_OPTIONS_HANDLES = ['optionsInputValueDropdown'] as const\nconst BOX_OPTIONS_HANDLES = [\n 'optionsInputValue',\n 'optionsInputValueLabelContainer',\n 'optionsInputValueLabel',\n 'optionsInputValueOptionBoxContainer',\n] as const\n\nexport type OptionDisplay = 'select' | 'box' | 'smart'\n\ntype Options = {\n label: string\n value: string\n}\n\ntype InnerProps = {\n label: string\n options: Options[]\n inputId: string\n}\n\ntype Props = {\n optionsDisplay?: OptionDisplay\n inputValueInfo: OptionsInputValue\n}\n\nconst DropdownOptions: FC<InnerProps> = ({ label, options, inputId }) => {\n const [state, onChange] = useInputValue(inputId)\n const handles = useCssHandles(DROPDOWN_OPTIONS_HANDLES)\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const { value } = e.target\n\n onChange({ value })\n }\n\n return (\n <div className={`${handles.optionsInputValueDropdown} mb4`}>\n <Dropdown\n value={state}\n onChange={handleChange}\n label={label}\n options={options}\n />\n </div>\n )\n}\n\nconst BoxOptions: FC<InnerProps> = ({ label, options, inputId }) => {\n const [state, onChange] = useInputValue(inputId)\n const handles = useCssHandles(BOX_OPTIONS_HANDLES)\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n const selected = state as string\n const selectedIndex: number = options.findIndex((i) => i.value === selected)\n\n switch (event.key) {\n case 'ArrowRight': {\n const count = options.length\n const nextSelectedIndex = (selectedIndex + 1) % count\n const newOption = options[nextSelectedIndex]\n\n onChange({ value: newOption.value })\n break\n }\n\n case 'ArrowLeft': {\n const count = options.length\n const previousSelectedIndex = (selectedIndex - 1 + count) % count\n const newOption = options[previousSelectedIndex]\n\n onChange({ value: newOption.value })\n break\n }\n\n case 'Home': {\n const [newOption] = options\n\n onChange({ value: newOption.value })\n break\n }\n\n case 'End': {\n const count = options.length\n const newOption = options[count - 1]\n\n onChange({ value: newOption.value })\n break\n }\n\n default: {\n break\n }\n }\n }\n\n return (\n <div className={`${handles.optionsInputValue} mb4`}>\n <div className={`${handles.optionsInputValueLabelContainer} mb3`}>\n <span\n className={`${handles.optionsInputValueLabel} c-muted-1 t-small overflow-hidden`}\n >\n {label}\n </span>\n </div>\n <div\n className={`${handles.optionsInputValueOptionBoxContainer} inline-flex flex-wrap flex items-center`}\n >\n {options.map((option) => {\n return (\n <OptionBox\n key={option.value}\n onKeyDown={handleKeyDown}\n option={option.label}\n selected={state === option.value}\n onClick={() => onChange({ value: option.value })}\n />\n )\n })}\n </div>\n </div>\n )\n}\n\nconst SubscriptionOption: FC<Props> = ({ optionsDisplay, inputValueInfo }) => {\n const intl = useIntl()\n const state = useProductAssemblyGroupState()\n const inputId = inputValueInfo.label\n const inputDomain = inputValueInfo.domain\n\n // We get the current `frequency` value here instead of inside the useMemo\n // so it doesn't depend on the state, as it is a new object at every update.\n // For non-subscription inputValues, this is `undefined` which is fine.\n // Prevents re-rendering when changing `purchaseDay`.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const frequency = parseFrequency(\n state?.valuesOfInputValues[SUBSCRIPTION_KEY_FREQUENCY] as string\n )!\n\n const { label, options } = useMemo(() => {\n return {\n label: formatSubscriptionLabel(inputId, intl),\n options: formatSubscriptionOptions({\n inputId,\n inputDomain,\n frequency: {\n type: frequency?.type,\n interval: frequency?.interval,\n },\n intl,\n }),\n }\n }, [inputId, intl, inputDomain, frequency?.type, frequency?.interval])\n\n let OptionComponent = optionsDisplay === 'box' ? BoxOptions : DropdownOptions\n\n // enforce dropdown format for numeric days\n if (\n inputValueInfo.label === SUBSCRIPTION_KEY_PURCHASEDAY &&\n (frequency.type === 'month' || frequency.type === 'year')\n ) {\n OptionComponent = DropdownOptions\n }\n\n return (\n <OptionComponent\n inputId={inputValueInfo.label}\n label={label}\n options={options}\n />\n )\n}\n\nconst OptionsInputValue: FC<Props> = (props) => {\n const { optionsDisplay = 'select', inputValueInfo } = props\n\n if (isSubscriptionRelated(inputValueInfo.label)) {\n return <SubscriptionOption {...props} />\n }\n\n const OptionComponent =\n optionsDisplay === 'box' ? BoxOptions : DropdownOptions\n\n return (\n <OptionComponent\n inputId={inputValueInfo.label}\n label={inputValueInfo.label}\n options={inputValueInfo.domain.map((value) => ({ label: value, value }))}\n />\n )\n}\n\nexport default OptionsInputValue\n\n```"
}
] |
code_product-customizer_5edca055
|
[
{
"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 product-customizer/react/components/ProductAssemblyOptions/InputValue/TextInputValue.tsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport { Input } from 'vtex.styleguide'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport useInputValue from './useInputValue'\n\nconst CSS_HANDLES = ['textInputValue'] as const\n\nconst TextInputValue: FC<Props> = ({ inputValueInfo }) => {\n const [state, onChange] = useInputValue(inputValueInfo.label)\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const { value } = e.target\n\n onChange({ value })\n }\n\n const handles = useCssHandles(CSS_HANDLES)\n\n return (\n <div className={`${handles.textInputValue} mb4`}>\n <Input\n value={state}\n onChange={handleChange}\n label={inputValueInfo.label}\n maxLength={inputValueInfo.maxLength}\n />\n </div>\n )\n}\n\ninterface Props {\n inputValueInfo: TextInputValue\n}\n\nexport default TextInputValue\n\n```"
}
] |
code_product-customizer_003d45d5
|
[
{
"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 product-customizer/react/components/Variation/Items/ToggledChoice.jsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```jsx\nimport React, { memo } from 'react'\nimport PropTypes from 'prop-types'\nimport { Checkbox } from 'vtex.styleguide'\n\nimport '../../../global.css'\n\nconst ToggledChoice = ({ imageUrl, name, selected, onChange, disabled }) => (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label\n className={`vtex-product-customizer__toggled-choice ${\n selected ? 'selected bg-washed-blue' : 'hover-bg-near-white'\n } db pa4 pointer bb b--light-gray`}\n >\n <div className=\"relative flex items-center\">\n <div className=\"flex-none pv2\">\n {/* eslint-disable-next-line jsx-a11y/alt-text */}\n <img src={imageUrl} width=\"48\" className=\"br3\" />\n </div>\n <div className=\"flex-auto ml5\">\n <div className=\"toggled-choice__name t-heading-5\">{name}</div>\n </div>\n <div className={`${disabled ? 'o-70' : ''}`}>\n <Checkbox\n id={`${name}-choice`}\n disabled={disabled}\n name={name}\n checked={selected}\n onChange={() => onChange(name)}\n />\n </div>\n </div>\n </label>\n)\n\nToggledChoice.propTypes = {\n /* Max limit of selections */\n selected: PropTypes.bool,\n /* Trigger function to handle changes on inputs */\n onChange: PropTypes.func,\n disabled: PropTypes.bool,\n name: PropTypes.string.isRequired,\n imageUrl: PropTypes.string,\n}\n\nexport default memo(ToggledChoice)\n\n```"
}
] |
code_product-customizer_a6a5891a
|
[
{
"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 product-customizer/react/components/Variation/Items/SingleChoice.jsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```jsx\nimport PropTypes from 'prop-types'\nimport React, { memo } from 'react'\nimport ProductPrice from 'vtex.store-components/ProductPrice'\nimport Radio from 'vtex.styleguide/Radio'\n\nimport ItemDescription from './ItemDescription'\n\nconst SingleChoice = ({\n imageUrl,\n name,\n price,\n selected,\n onChange,\n showPlus,\n}) => {\n const calculatedPrice = (price / 100).toFixed(2)\n const parsedPrice = parseFloat(calculatedPrice)\n\n const description = parsedPrice && (\n <div className=\"single-choice__price flex t-small fw5 c-action-primary mt1\">\n {showPlus && <div>+ </div>}\n <ProductPrice\n {...{\n showLabels: false,\n showListPrice: false,\n sellingPrice: parsedPrice,\n }}\n />\n </div>\n )\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n onKeyDown={(e) => e.key === ' ' && onChange(name, true)}\n onClick={() => onChange(name, true)}\n className={`${\n selected && 'selected bg-muted-5'\n } hover-bg-muted-5 ph4 pointer bb b--muted-5 bw1`}\n >\n <div className=\"relative flex items-center justify-between pv5\">\n <ItemDescription {...{ description, imageUrl, name }} />\n <div className=\"mt3\">\n <Radio\n checked={selected}\n // Required but useless props\n {...{ id: '', label: '', name: '', value: '', onChange: () => {} }}\n />\n </div>\n </div>\n </div>\n )\n}\n\nSingleChoice.propTypes = {\n /* Define if current component is selected */\n selected: PropTypes.bool,\n /* Trigger function to handle changes on inputs */\n onChange: PropTypes.func.isRequired,\n imageUrl: PropTypes.string,\n price: PropTypes.number,\n name: PropTypes.string,\n showPlus: PropTypes.bool,\n}\n\nexport default memo(SingleChoice)\n\n```"
}
] |
code_product-customizer_a306ba47
|
[
{
"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 product-customizer/react/components/Variation/Items/ItemDescription.jsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```jsx\nimport React, { memo } from 'react'\n\nimport '../../../global.css'\n\n/* eslint-disable jsx-a11y/alt-text */\nfunction ItemDescription({ description, name, imageUrl }) {\n return (\n <div className=\"flex\">\n <div>\n {imageUrl && (\n <img\n src={imageUrl}\n className=\"br3 mr4\"\n style={{ height: '54px', width: '54px' }}\n />\n )}\n </div>\n <div className=\"multiple-choice__title flex flex-column justify-center\">\n <div className=\"multiple-choice__name t-heading-5 c-on-base\">\n {name}\n </div>\n <div className=\"single-choice__description\">{description || null}</div>\n </div>\n </div>\n )\n}\n\nexport default memo(ItemDescription)\n\n```"
}
] |
code_product-customizer_4dd4f2df
|
[
{
"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 product-customizer/react/components/Variation/Items/MultipleChoice.jsx from the product-customizer VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```jsx\nimport PropTypes from 'prop-types'\nimport React, { memo } from 'react'\nimport NumericStepper from 'vtex.styleguide/NumericStepper'\nimport ProductPrice from 'vtex.store-components/ProductPrice'\n\nimport ItemDescription from './ItemDescription'\n\nimport '../../../global.css'\n\nconst MultipleChoice = ({\n imageUrl,\n price,\n name,\n chosenAmount,\n canIncrease,\n canDecrease,\n onChange,\n}) => {\n const calculatedPrice = (price / 100).toFixed(2)\n const parsedPrice = parseFloat(calculatedPrice)\n const isSelected = !!chosenAmount\n\n const sellingPriceClass = 'c-action-primary t-small fw5'\n\n const description = !!parsedPrice && (\n <div className=\"multiple-choice__price flex items-center c-action-primary t-small fw5 mt1\">\n <div>+ </div>\n <ProductPrice\n {...{\n showLabels: false,\n showListPrice: false,\n sellingPrice: parsedPrice,\n sellingPriceClass,\n }}\n />\n </div>\n )\n\n return (\n <div\n className={`vtex-product-customizer__multiple-choice ${\n isSelected && 'selected bg-muted-5'\n } hover-bg-muted-5 w-100 ph4 pv5 bb b--muted-5`}\n >\n <div className=\"relative flex justify-between items-center\">\n <ItemDescription {...{ imageUrl, name, description }} />\n <div className=\"flex-auto flex-none-ns flex justify-end\">\n <div className=\"multiple-choice__actions flex-none ml4 c-action-primary t-body fw5 z-1\">\n <NumericStepper\n lean\n value={chosenAmount}\n minValue={chosenAmount - canDecrease}\n maxValue={chosenAmount + canIncrease}\n onChange={({ value }) => onChange(value, name)}\n />\n </div>\n </div>\n </div>\n </div>\n )\n}\n\nMultipleChoice.propTypes = {\n imageUrl: PropTypes.string,\n price: PropTypes.number,\n name: PropTypes.string,\n chosenAmount: PropTypes.number,\n canIncrease: PropTypes.bool,\n canDecrease: PropTypes.bool,\n onChange: PropTypes.func.isRequired,\n}\n\nexport default memo(MultipleChoice)\n\n```"
}
] |
code_apub-app-center_348ccb18
|
[
{
"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 apub-app-center/messages/pt.json from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"apub-app-center.navigation.label-group\": \"APUB App Center\",\n \"apub-app-center.navigation.search.kws\": \"app, admin, apub, apps\",\n \"apub-app-center.hello-world\": \"APUB App Center\",\n \"apub-app-center.details\": \"Nome da App\",\n \"apub-app-center.filter-header\": \"Filtros\",\n \"apub-app-center.filter\": \"Aplicar\",\n \"apub-app-center.filter-category\": \"Categoria\",\n \"apub-app-center.filter-store\": \"Loja\",\n \"apub-app-center.filter-status\": \"Status\",\n \"apub-app-center.apps-header\": \"Todas as aplicações\",\n \"apub-app-center.apps-view\": \"Ver mais\"\n}\n\n```"
}
] |
code_apub-app-center_ff18d5cf
|
[
{
"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 apub-app-center/messages/en.json from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"apub-app-center.navigation.label-group\": \"APUB App Center\",\n \"apub-app-center.navigation.search.kws\": \"app, admin, apub, apps\",\n \"apub-app-center.hello-world\": \"APUB App Center\",\n \"apub-app-center.details\": \"Name of the App\",\n \"apub-app-center.filter-header\": \"Filters\",\n \"apub-app-center.filter\": \"Apply\",\n \"apub-app-center.filter-category\": \"Category\",\n \"apub-app-center.filter-store\": \"Store\",\n \"apub-app-center.filter-status\": \"Status\",\n \"apub-app-center.apps-header\": \"All the apps\",\n \"apub-app-center.apps-view\": \"See more\"\n}\n\n```"
}
] |
code_apub-app-center_939189be
|
[
{
"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 apub-app-center/messages/es.json from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"apub-app-center.navigation.label-group\": \"APUB App Center\",\n \"apub-app-center.navigation.search.kws\": \"app, admin, apub, apps\",\n \"apub-app-center.hello-world\": \"APUB App Center\",\n \"apub-app-center.details\": \"Nombre de la App\",\n \"apub-app-center.filter-header\": \"Filtros\",\n \"apub-app-center.filter\": \"Aplicar\",\n \"apub-app-center.filter-category\": \"Categoria\",\n \"apub-app-center.filter-store\": \"Tienda\",\n \"apub-app-center.filter-status\": \"Status\",\n \"apub-app-center.apps-header\": \"Totas las apps\",\n \"apub-app-center.apps-view\": \"Ver más\"\n}\n\n```"
}
] |
code_apub-app-center_f187d092
|
[
{
"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 apub-app-center/admin/navigation.json from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"section\": \"other\",\n \"titleId\": \"apub-app-center.navigation.label-group\",\n \"path\": \"/admin/apub-app-center\",\n \"searchKeyWordsHelpers\": \"apub-app-center.navigation.search.kws\"\n}\n\n```"
}
] |
code_apub-app-center_4a78588e
|
[
{
"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 apub-app-center/admin/routes.json from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin.app.apub-app-center\": {\n \"component\": \"Admin\",\n \"path\": \"/admin/app/apub-app-center\"\n },\n \"admin.app.apub-app-center-detail\": {\n \"component\": \"AppDetail\",\n \"path\": \"/admin/app/apub-app-center/:id\"\n }\n}\n\n```"
}
] |
code_apub-app-center_8dcee16f
|
[
{
"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 apub-app-center/docs/README.md from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/vtex-apps/apub-app-center) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# # APUB App Center\n\n<!-- DOCS-IGNORE:start -->\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n<!-- DOCS-IGNORE:end -->\n\nAdmin component that groups all the apps made in the region for quick and easy access to documentation, requirements, tutorials and demos.\n\n### How to develop admins\n\n1. Admins always declare routes in `/admin/app/<route>`\n\n2. Declare the `admin` builder in your manifest\n\n3. When installed, the user navigates to `/admin/<route>`, but your app runs in an iframe that points to `/admin/app/<route>`.\n\n4. You can develop directly in the `/admin/app` route for convenience, but don't forget to test it inside the iframe. :)\n\n### Quickstart\n\n1. Clone this repo\n\n2. `yarn --cwd react/` for code completion\n\n3. `vtex link`\n\n4. Navigate to `workspace--account.myvtex.com/admin/app/example`\n\n```"
}
] |
code_apub-app-center_eddd323d
|
[
{
"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 apub-app-center/react/package.json from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.admin-example\",\n \"version\": \"0.0.12\",\n \"devDependencies\": {\n \"@types/node\": \"^11.12.1\",\n \"@types/react\": \"^16.8.10\",\n \"@types/react-intl\": \"^2.3.17\",\n \"@vtex/tsconfig\": \"^0.4.4\",\n \"apollo-client\": \"^2.4.7\",\n \"graphql\": \"^14.0.2\",\n \"prop-types\": \"^15.7.2\",\n \"react\": \"^16.8.6\",\n \"react-dom\": \"^16.8.6\",\n \"react-intl\": \"^2.7.2\",\n \"typescript\": \"3.9.7\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.132.3/public/@types/vtex.render-runtime\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.146.1/public/@types/vtex.styleguide\",\n \"vtexarg.apub-app-center\": \"https://dev--vtexarg.myvtex.com/_v/private/typings/linked/v1/vtexarg.apub-app-center@0.0.12+build1647284822/public/@types/vtexarg.apub-app-center\"\n },\n \"dependencies\": {\n \"@types/faker\": \"^4.1.5\",\n \"faker\": \"^4.1.0\"\n }\n}\n\n```"
}
] |
code_apub-app-center_f1e7afd9
|
[
{
"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 apub-app-center/react/AppDetail.tsx from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC, useEffect, useState } from 'react'\n// import { FormattedMessage } from 'react-intl'\nimport { Divider, Layout, PageBlock, PageHeader } from 'vtex.styleguide'\nimport './styles/styles.global.css'\nimport AppTabs from './components/Detail/AppTabs'\nimport Resume from './components/Detail/Resume'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { AppData } from './typings/appdata'\nimport MockedData from './data/mockedData'\n\n\ninterface Props {\n params: any\n}\n\nconst AppDetail: FC<Props> = ({ params }) => {\n const { navigate } = useRuntime();\n const [appInfo, setAppInfo] = useState<AppData>();\n useEffect(() => {\n if (!appInfo){\n let apps = MockedData.GetData();\n let app = apps.filter(ap => ap.id == params.id)[0];\n setAppInfo(app);\n }\n }, [])\n\n return (\n <Layout\n pageHeader={\n <PageHeader\n title={appInfo?.name}\n linkLabel=\"APUB App Center\"\n onLinkClick={() => {\n navigate({to: `/admin/app/apub-app-center`})\n }}\n />\n }\n >\n <PageBlock variation=\"full\">\n <div className=\"flex\">\n <Resume\n photo={appInfo?.photo || ''}\n version={appInfo?.version || 0}\n status={appInfo?.status || ''}\n store={appInfo?.store || []}\n category={appInfo?.category || []}\n documentation={appInfo?.documentation || ''}\n />\n <div\n style={{ flexGrow: 1 }}\n className=\"flex items-stretch w-10 justify-center\">\n <Divider orientation=\"vertical\" />\n </div>\n <AppTabs\n name={appInfo?.name || ''}\n download={appInfo?.download || ''}\n overview={appInfo?.overview || ''}\n feature={appInfo?.feature || []}\n screenshot= {appInfo?.screenshot || ''}\n workspace= {appInfo?.workspace || ''}\n video= {appInfo?.video || ''}\n requirements={appInfo?.requirements || []}\n tutorial={appInfo?.tutorial || []}\n assets={appInfo?.assets || []}\n github= {appInfo?.github || ''}\n />\n </div>\n </PageBlock>\n </Layout>\n )\n}\n\nexport default AppDetail\n\n```"
}
] |
code_apub-app-center_d304ccdc
|
[
{
"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 apub-app-center/react/Admin.tsx from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport { Layout, PageBlock, PageHeader } from 'vtex.styleguide'\n\nimport Cards from './components/Cards'\n\nimport './styles/styles.global.css'\n\nconst Admin: FC = () => {\n return (\n <Layout\n pageHeader={\n <PageHeader\n title={<FormattedMessage id=\"apub-app-center.hello-world\" />}\n />\n }\n >\n <PageBlock variation=\"full\">\n <Cards />\n </PageBlock>\n </Layout>\n )\n}\n\nexport default Admin\n\n```"
}
] |
code_apub-app-center_40919708
|
[
{
"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 apub-app-center/react/typings/appdata.d.ts from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport interface AppData {\n id: number,\n name: string,\n photo: string,\n status: string,\n store: string[],\n category: string[],\n description: string\n documentation: string,\n download: string,\n version: number,\n overview: string,\n feature: string[],\n screenshot: string,\n workspace: string,\n video: string,\n requirements: string[],\n tutorial: string[],\n assets: string[],\n github: string\n}\n\n```"
}
] |
code_apub-app-center_2ed7c332
|
[
{
"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 apub-app-center/react/utils/intl.ts from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { defineMessages } from 'react-intl'\n\nconst prefix = 'admin/admin.app.custom-stock-export.'\nconst prefixFilters = 'admin/admin.app.custom-stock-export.filters.'\n\nexport const appMessages = defineMessages({\n pageTitle: { id: `${prefix}pageTitle` },\n exportButton: { id: `${prefix}exportButton` },\n})\n\nexport const filtersMessages = defineMessages({\n clear: { id: `${prefixFilters}clear` },\n all: { id: `${prefixFilters}all` },\n none: { id: `${prefixFilters}none` },\n any: { id: `${prefixFilters}any` },\n is: { id: `${prefixFilters}is` },\n isNot: { id: `${prefixFilters}isNot` },\n contains: { id: `${prefixFilters}contains` },\n apply: { id: `${prefixFilters}apply` },\n loading: { id: `${prefixFilters}category.loading` },\n placeholder: { id: `${prefixFilters}category.placeholder` },\n error: { id: `${prefixFilters}category.error` },\n ok: { id: `${prefixFilters}ok` },\n and: { id: `${prefixFilters}and` },\n noOptionsFound: { id: `${prefixFilters}noOptionsFound` },\n tryAgain: { id: `${prefixFilters}tryAgain` },\n greaterOrEqualDropdown: { id: `${prefixFilters}dropdown.greater-or-equal` },\n greaterOrEqualLabel: { id: `${prefixFilters}label.greater-or-equal-value` },\n lessOrEqualDropdown: { id: `${prefixFilters}dropdown.less-or-equal` },\n lessOrEqualLabel: { id: `${prefixFilters}label.less-or-equal-value` },\n betweenDropdown: { id: `${prefixFilters}dropdown.between` },\n betweenLabel: { id: `${prefixFilters}label.between-values` },\n betweenInvalid: { id: `${prefixFilters}error.between` },\n maximumPlaceholder: { id: `${prefixFilters}placeholder.maximum` },\n minimumPlaceholder: { id: `${prefixFilters}placeholder.minimum` },\n search: { id: `${prefixFilters}search` },\n warehousesQueryError: { id: `${prefixFilters}warehouses-query-error` },\n warehousesNamesQueryError: {\n id: `${prefixFilters}warehouses-names-query-error`,\n },\n})\n\nexport const commonMessages = defineMessages({\n loading: { id: `${prefix}commons.loading` },\n})\n\nexport const columnsMessages = defineMessages({\n lastUpdate: { id: `${prefix}columns.last-update` },\n reserved: { id: `${prefix}columns.reserved` },\n available: { id: `${prefix}columns.available` },\n warehouse: { id: `${prefix}columns.warehouse` },\n})\n\n```"
}
] |
code_apub-app-center_97d81f3c
|
[
{
"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 apub-app-center/react/styles/styles.global.css from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\nhtml,\nbody,\n#render-container,\n#render-provider,\n.render-container,\n.render-provider {\n height: 100%;\n}\n\n.card-hover:hover {\n box-shadow: rgba(61, 62, 64, 0.2) 0px 3px 9px 0px;\n}\n\n.image-size{\n width: 3.5rem;\n height: 3.5rem;\n}\n\n.image-size-detail {\n width: 10rem;\n height: 10rem;\n}\n\n.card-div-name {\n width: calc(100% - 75px);\n}\n\n.vtex-tag {\n padding: .1rem .4rem;\n}\n\n```"
}
] |
code_apub-app-center_6fef46c2
|
[
{
"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 apub-app-center/react/data/mockedData.ts from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { AppData } from '../typings/appdata'\n\nconst CreateData1 = () => {\n let app1 = {} as AppData;\n app1.id = 1;\n app1.name = \"Massive price update\";\n app1.photo = \"https://extensions.vtexassets.com/arquivos/ids/157174/image-b925968a706f46f29cc8ed06633a6f95.jpg?v=637680032654000000\";\n app1.status = \"prod\";\n app1.store = ['legacy', 'io'];\n app1.category = ['service'];\n app1.description = \"This application allows you to update SKU prices in batches.\";\n app1.documentation = \"https://vtex.io/docs/app/vtexarg.massive-price-update@1.x\";\n app1.download = \"https://apps.vtex.com/vtexarg-massive-price-update/p\";\n app1.version = 1;\n app1.overview = \"This application allows you to update SKU prices in batches.\";\n app1.feature = [\"Reduction of integration times\", \"Reduction of overhead for applications\", \"Simplicity\"];\n app1.screenshot = \"https://extensions.vtexassets.com/arquivos/ids/157175/image-25412d34ae77460fa7a7b141b7a00dd6.jpg?v=637680032659230000\";\n app1.workspace = \"\";\n app1.video = \"\";\n app1.requirements = [\"Whitelabel\", \"Search v1\", \"Installar la app\"];\n app1.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app1.assets = [];\n app1.github = \"https://github.com/vtex-apps/massive-price-update\";\n\n return app1;\n}\n\nconst CreateData2 = () => {\n let app2 = {} as AppData;\n app2.id = 2;\n app2.name = \"Product highlight by vtex-segment\";\n app2.photo = \"https://dev--vtexarg.myvtex.com/_v/public/assets/v1/published/vtexarg.product-highlight-by-vtex-segment@0.3.2/public/metadata/images/icon.png\";\n app2.status = \"beta\";\n app2.store = ['io'];\n app2.category = ['pdp', 'gallery'];\n app2.description = \"Filters the product listing results by Whitelabel Seller selected.\";\n app2.documentation = \"https://vtex.io/docs/app/vtexarg.product-highlight-by-vtex-segment@0.3.2/\";\n app2.download = \"\";\n app2.version = 0;\n app2.overview = \"Allows to select a Whitelabel Seller available in their region, and it filters the product listing results.\";\n app2.feature = [\"Es genial\", \"Es gratis\", \"Es rápida\"];\n app2.screenshot = \"https://user-images.githubusercontent.com/55905671/143295939-7d1b5625-5c57-46ad-a197-ef959db268de.gif\";\n app2.workspace = \"Link del workspace\";\n app2.video = \"Preview del video\";\n app2.requirements = [\"Whitelabel\", \"Search v2\", \"Installar la app\"];\n app2.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app2.assets = [\"Imagenes\", \"Videos\", \"Styles\"];\n app2.github = \"https://github.com/vtex-apps/product-highlight-by-vtex-segment\";\n\n return app2;\n}\n\nconst CreateData3 = () => {\n let app3 = {} as AppData;\n app3.id = 3;\n app3.name = \"Massive score update\";\n app3.photo = \"https://dev--vtexarg.myvtex.com/_v/public/assets/v1/published/vtexarg.massive-score-update@3.1.1/public/metadata/images/icon.png\";\n app3.status = \"beta\";\n app3.store = ['legacy', 'io'];\n app3.category = ['service'];\n app3.description = \"Endpoints of massive update of product scores and catalogs.\";\n app3.documentation = \"https://vtex.io/docs/app/vtexarg.massive-score-update@3.1.1/\";\n app3.download = \"\";\n app3.version = 3;\n app3.overview = \"This application that exposes two endpoints of massive update of product scores and catalogs.\";\n app3.feature = [\"Es maravillosa\", \"Es gratis\", \"Es rápida\"];\n app3.screenshot = \"https://user-images.githubusercontent.com/33711188/132861772-a09ddf58-c326-4d43-bd57-0f4c5157e681.png\";\n app3.workspace = \"\";\n app3.video = \"\";\n app3.requirements = [\"Whitelabel\", \"Search v3\", \"Installar la app\"];\n app3.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app3.assets = [];\n app3.github = \"https://github.com/vtex-apps/massive-score-update\";\n\n return app3;\n}\n\nconst CreateData4 = () => {\n let app4 = {} as AppData;\n app4.id = 4;\n app4.name = \"Massive stock update\";\n app4.photo = \"https://extensions.vtexassets.com/arquivos/ids/157172-800-auto?v=637678529445200000&width=800&height=auto&aspect=true\";\n app4.status = \"prod\";\n app4.store = ['legacy', 'io'];\n app4.category = ['service'];\n app4.description = \"Endpoints of massive update stock in batches to decrease integration times.\";\n app4.documentation = \"https://vtex.io/docs/app/vtexarg.massive-stock-update@2.x/\";\n app4.download = \"https://apps.vtex.com/vtexarg-massive-stock-update/p\";\n app4.version = 2;\n app4.overview = \"Update stock in batches to decrease integration times and requests overhead.\";\n app4.feature = [\"Massive inventory stock update service through SKU and warehouseId\"];\n app4.screenshot = \"https://extensions.vtexassets.com/arquivos/ids/157173/image-0b87b2a10d504f7685ecb6f561bd93cf.jpg?v=637678529456730000\";\n app4.workspace = \"\";\n app4.video = \"\";\n app4.requirements = [\"Whitelabel\", \"Search v4\", \"Installar la app\"];\n app4.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app4.assets = [];\n app4.github = \"https://github.com/vtex-apps/massive-stock-update\";\n\n return app4;\n}\n\nconst CreateData5 = () => {\n let app5 = {} as AppData;\n app5.id = 5;\n app5.name = \"Tintometric\";\n app5.photo = \"https://extensions.vtexassets.com/arquivos/ids/157290/image-809fc5c05bdd4e6ab0c6a07ff3106191.jpg?v=637741542193970000\";\n app5.status = \"prod\";\n app5.store = ['io'];\n app5.category = ['admin', 'pdp'];\n app5.description = \"Displays a color chart on your PDP and updates its price by composition.\";\n app5.documentation = \"https://vtex.io/docs/app/vtexarg.tintometric@3.x/\";\n app5.download = \"https://apps.vtex.com/vtexarg-tintometric/p\";\n app5.version = 3;\n app5.overview = \"Displays a color chart on your product page and promptly update its price based on the color composition.\";\n app5.feature = [\"Manage color combination for Color Chart for paint stores\", \"Bulk update SKU prices based on the product color\"];\n app5.screenshot = \"https://extensions.vtexassets.com/arquivos/ids/157294/image-fe602f14a5ee47ca9ad7a763dba6faa0.jpg?v=637741542202600000\";\n app5.workspace = \"Link del workspace\";\n app5.video = \"Preview del video\";\n app5.requirements = [\"Whitelabel\", \"Search v5\", \"Installar la app\"];\n app5.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app5.assets = [\"Imagenes\", \"Videos\", \"Styles\"];\n app5.github = \"https://github.com/vtex-apps/tintometric\";\n\n return app5;\n}\n\nconst CreateData6 = () => {\n let app6 = {} as AppData;\n app6.id = 6;\n app6.name = \"Pharma orders admin\";\n app6.photo = \"\";\n app6.status = \"beta\";\n app6.store = ['io'];\n app6.category = ['admin'];\n app6.description = \"The Pharma Orders Admin app will allow you to manage your Pharma Orders.\";\n app6.documentation = \"https://vtex.io/docs/app/vtexarg.pharma-orders-admin@0.1.4/\";\n app6.download = \"\";\n app6.version = 0;\n app6.overview = \"The Pharma Orders Admin app will allow you to manage your Pharma Orders.\";\n app6.feature = [\"See the orders with products of the category Medicamentos\", \"See the prescription of the orders\", \"See products of the orders\", \"Aprove, Cancel and confirm the Orders\"];\n app6.screenshot = \"https://user-images.githubusercontent.com/55905671/139487826-4fa4dcea-101e-486c-a106-acc8c3abd36a.gif\";\n app6.workspace = \"Link del workspace\";\n app6.video = \"Preview del video\";\n app6.requirements = [\"Whitelabel\", \"Search v6\", \"Installar la app\"];\n app6.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app6.assets = [\"Imagenes\", \"Videos\", \"Styles\"];\n app6.github = \"https://github.com/vtex-apps/pharma-orders-admin\";\n\n return app6;\n}\n\nconst CreateData7 = () => {\n let app7 = {} as AppData;\n app7.id = 7;\n app7.name = \"Product availability gallery\";\n app7.photo = \"\";\n app7.status = \"beta\";\n app7.store = ['io'];\n app7.category = ['pdp', 'gallery', 'search'];\n app7.description = \"The Product Availability component shows the available amount of products. \";\n app7.documentation = \"https://vtex.io/docs/app/vtexarg.product-availability-gallery@1.1.2/\";\n app7.download = \"\";\n app7.version = 1;\n app7.overview = \"The Product Availability component shows the available amount of products. \";\n app7.feature = [\"Es excelente\", \"Es gratis\", \"Es rápida\"];\n app7.screenshot = \"https://extensions.vtexassets.com/arquivos/ids/157316/image-5516ab6fdd624a748e299584e917e082.jpg?v=637771685440800000\";\n app7.workspace = \"Link del workspace\";\n app7.video = \"Preview del video\";\n app7.requirements = [\"Whitelabel\", \"Search v7\", \"Installar la app\"];\n app7.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app7.assets = [\"Imagenes\", \"Videos\", \"Styles\"];\n app7.github = \"https://github.com/vtex-apps/product-availability-gallery\";\n\n return app7;\n}\n\nconst CreateData8 = () => {\n let app8 = {} as AppData;\n app8.id = 8;\n app8.name = \"QR & Barcode Reader\";\n app8.photo = \"https://extensions.vtexassets.com/arquivos/ids/157356-800-auto?v=637789878477770000&width=800&height=auto&aspect=true\";\n app8.status = \"prod\";\n app8.store = ['io'];\n app8.category = ['admin', 'pdp'];\n app8.description = \"Permite escanear y leer códigos de barras o QR de productos para dirigirte a su PDP o agregarlos al carrito.\";\n app8.documentation = \"https://vtex.io/docs/app/vtexarg.qr-barcode-reader@1.x/\";\n app8.download = \"https://apps.vtex.com/vtexarg-qr-barcode-reader/p\";\n app8.version = 1;\n app8.overview = \"Permite escanear y leer códigos QR o código de barras de productos, identificando el EAN del mismo y luego (dependiendo como se configuró la app) tomando una de estas dos acciones:\";\n app8.feature = [\"Te dirige a la PDP\", \"Agrega el producto al carrito\"];\n app8.screenshot = \"https://user-images.githubusercontent.com/55905671/141179209-ebbeeb19-7556-4a59-9913-d04b1f6c8f5d.gif\";\n app8.workspace = \"https://reader--vtexarg.myvtex.com/\";\n app8.video = \"Preview del video\";\n app8.requirements = [\"Whitelabel\", \"Search v8\", \"Installar la app\"];\n app8.tutorial = [\"Instalar la app en la theme dependency\", \"Agregar los bloques Qr & Barcode Reader a la template del theme\", \"Probar, leer documentación\"];\n app8.assets = [\"Imagenes\", \"Videos\", \"Styles\"];\n app8.github = \"https://github.com/vtex-apps/qr-barcode-reader\";\n\n\n return app8;\n}\n\nconst CreateData9 = () => {\n let app9 = {} as AppData;\n app9.id = 9;\n app9.name = \"Workspace manager\";\n app9.photo = \"https://extensions.vtexassets.com/arquivos/ids/157197/image-4974b0ca908a447bb3bbb55156f2496b.jpg?v=637693051293400000\";\n app9.status = \"prod\";\n app9.store = ['io'];\n app9.category = ['admin'];\n app9.description = \"Through this App you can create, delete and promote workspaces from the admin.\";\n app9.documentation = \"https://vtex.io/docs/app/vtexarg.workspace-manager@2.x/\";\n app9.download = \"https://apps.vtex.com/vtexarg-workspace-manager/p\";\n app9.version = 2;\n app9.overview = \"Workspace Manger app enables the possibility to manage both production and development workspaces without the need of using Toolbelt CLI.\";\n app9.feature = [\"Create Workspaces\", \"Delete Workspaces\"];\n app9.screenshot = \"https://user-images.githubusercontent.com/36748003/130658171-88416ced-a160-4677-bdd8-31a0968ad3bd.png\";\n app9.workspace = \"Link del workspace\";\n app9.video = \"Preview del video\";\n app9.requirements = [\"Whitelabel\", \"Search v9\", \"Installar la app\"];\n app9.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app9.assets = [\"Imagenes\", \"Videos\", \"Styles\"];\n app9.github = \"https://github.com/vtex-apps/workspace-manager\";\n\n return app9;\n}\n\nconst CreateData10 = () => {\n let app10 = {} as AppData;\n app10.id = 10;\n app10.name = \"Admin AB Tester\";\n app10.photo = \"https://dev--vtexarg.myvtex.com/_v/public/assets/v1/published/vtexarg.abtester@1.0.4/public/metadata/images/icon.png\";\n app10.status = \"beta\";\n app10.store = ['io'];\n app10.category = ['admin'];\n app10.description = \"Allows you to list, start and finish A/B tests via the VTEX Admin.\";\n app10.documentation = \"https://vtex.io/docs/app/vtexarg.abtester@1.0.7/\";\n app10.download = \"\";\n app10.version = 1;\n app10.overview = \"Allows you to list, start and finish A/B tests via the VTEX Admin.\";\n app10.feature = [\"Create A/B tests\", \"Compare A/B test results\", \"Finish an A/B test\"];\n app10.screenshot = \"https://user-images.githubusercontent.com/36748003/138300964-63bc3545-efd7-435c-acd6-3e3e3a35b285.png\";\n app10.workspace = \"Link del workspace\";\n app10.video = \"Preview del video\";\n app10.requirements = [\"Whitelabel\", \"Search v10\", \"Installar la app\"];\n app10.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app10.assets = [\"Imagenes\", \"Videos\", \"Styles\"];\n app10.github = \"https://github.com/vtex-apps/admin-ab-tester\";\n\n return app10;\n}\n\nconst CreateData11 = () => {\n let app11 = {} as AppData;\n app11.id = 11;\n app11.name = \"Admin Ley de Gondolas Arg\";\n app11.photo = \"\";\n app11.status = \"beta\";\n app11.store = ['legacy', 'io'];\n app11.category = ['admin', 'pdp'];\n app11.description = \"Integration to comply with the Ley de Gondolas from Argentina.\";\n app11.documentation = \"https://vtex.io/docs/app/vtexarg.admin-ley-gondolas-arg@0.2.0/\";\n app11.download = \"\";\n app11.version = 0;\n app11.overview = \"Helps to carry out the necessary integration to comply with the Ley de Gondolas from Argentina.\";\n app11.feature = [\"Es excelente\", \"Es gratis\", \"Es rápida\"];\n app11.screenshot = \"https://user-images.githubusercontent.com/55905671/137961451-a9f0f85e-a3d9-43ab-af9e-84e5be9f6346.gif\";\n app11.workspace = \"Link del workspace\";\n app11.video = \"Preview del video\";\n app11.requirements = [\"Whitelabel\", \"Search v11\", \"Installar la app\"];\n app11.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app11.assets = [\"Imagenes\", \"Videos\", \"Styles\"];\n app11.github = \"https://github.com/vtex-apps/admin-ley-gondolas-arg\";\n\n\n return app11;\n}\n\nconst CreateData12 = () => {\n let app12 = {} as AppData;\n app12.id = 12;\n app12.name = \"Vtex-logger react\";\n app12.photo = \"\";\n app12.status = \"prod\";\n app12.store = ['io'];\n app12.category = ['service'];\n app12.description = \"Makes log entries in the VTEX IO Logging Service on React Apps.\";\n app12.documentation = \"https://vtex.io/docs/app/vtex.vtex-logger-react@1.0.1/\";\n app12.download = \"\";\n app12.version = 1;\n app12.overview = \"The VTEX Logger React app will help to make log entries in the VTEX IO Logging Service on React Apps.\";\n app12.feature = [\"Es excelente\", \"Es gratis\", \"Es rápida\"];\n app12.screenshot = \"https://extensions.vtexassets.com/arquivos/ids/157316/image-5516ab6fdd624a748e299584e917e082.jpg?v=637771685440800000\";\n app12.workspace = \"\";\n app12.video = \"\";\n app12.requirements = [\"Whitelabel\", \"Search v12\", \"Installar la app\"];\n app12.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app12.assets = [];\n app12.github = \"https://github.com/vtex-apps/vtex-logger-react\";\n\n return app12;\n}\n\nconst CreateData13 = () => {\n let app13 = {} as AppData;\n app13.id = 13;\n app13.name = \"Speech to Text\";\n app13.photo = \"https://extensions.vtexassets.com/arquivos/ids/157152/image-a7036d42ff77459ebe575750e2d40871.jpg?v=637644004825600000\";\n app13.status = \"prod\";\n app13.store = ['io'];\n app13.category = ['search'];\n app13.description = \"Speech search using google chrome NLP system.\";\n app13.documentation = \"https://developers.vtex.com/vtex-developer-docs/docs/vtexarg-speech-to-text\";\n app13.download = \"https://apps.vtex.com/vtexarg-speech-to-text/p\";\n app13.version = 1;\n app13.overview = \"Boost your commerce offering quick speech search using google chrome NLP system.\";\n app13.feature = [\"Search in Google Chrome using microphone\"];\n app13.screenshot = \"https://extensions.vtexassets.com/arquivos/ids/157150/image-06311a72e32149ac8ece2702f72e3712.jpg?v=637644004824800000\";\n app13.workspace = \"https://speechtotext--vtexarg.myvtex.com/\";\n app13.video = \"Preview del video\";\n app13.requirements = [\"Whitelabel\", \"Search v13\", \"Installar la app\"];\n app13.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app13.assets = [];\n app13.github = \"https://github.com/vtex-apps/speech-to-text\";\n\n return app13;\n}\n\nconst CreateData14 = () => {\n let app14 = {} as AppData;\n app14.id = 14;\n app14.name = \"Quantity on cart\";\n app14.photo = \"https://extensions.vtexassets.com/arquivos/ids/157188/image-ec75452634b8492f9bd015432f654e42.jpg?v=637692310251370000\";\n app14.status = \"prod\";\n app14.store = ['io'];\n app14.category = ['checkout'];\n app14.description = \"See the quantity of products added to the cart.\";\n app14.documentation = \"https://vtex.io/docs/app/vtexarg.quantity-on-cart@2.2.7/\";\n app14.download = \"https://apps.vtex.com/vtexarg-quantity-on-cart/p\";\n app14.version = 2;\n app14.overview = \"With Quantity On Cart, your users can now see the quantity of products they have added to their cart directly, creating a more seamless and dynamic experience for buyers.\";\n app14.feature = [\"Same-page display of products added to the cart\", \"Integration with minicart for live count\"];\n app14.screenshot = \"https://extensions.vtexassets.com/arquivos/ids/157192/image-4e978d9142484c98a028c256e79d719e.jpg?v=637692310276130000\";\n app14.workspace = \"Link del workspace\";\n app14.video = \"Preview del video\";\n app14.requirements = [\"Whitelabel\", \"Search v14\", \"Installar la app\"];\n app14.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app14.assets = [\"Imagenes\", \"Videos\", \"Styles\"];\n app14.github = \"https://github.com/vtex-apps/quantity-on-cart\";\n\n return app14;\n}\n\nconst CreateData15 = () => {\n let app15 = {} as AppData;\n app15.id = 15;\n app15.name = \"Vtex-logger GraphQL\";\n app15.photo = \"\";\n app15.status = \"prod\";\n app15.store = ['io'];\n app15.category = ['service'];\n app15.description = \"GraphQL API to use the VTEX Logger to be consume through an React Front App.\";\n app15.documentation = \"https://vtex.io/docs/app/vtex.vtex-logger-graphql@0.2.0/\";\n app15.download = \"\";\n app15.version = 0;\n app15.overview = \"GraphQL API build in our VTEX IO Platform to use the VTEX Logger with the objetive of be consume through an React Front App.\";\n app15.feature = [\"Es excelente\", \"Es gratis\", \"Es rápida\"];\n app15.screenshot = \"\";\n app15.workspace = \"\";\n app15.video = \"\";\n app15.requirements = [\"Whitelabel\", \"Search v15\", \"Installar la app\"];\n app15.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app15.assets = [];\n app15.github = \"https://github.com/vtex-apps/vtex-logger-graphql\";\n\n return app15;\n}\n\nconst CreateData16 = () => {\n let app16 = {} as AppData;\n app16.id = 16;\n app16.name = \"Apub App Center\";\n app16.photo = \"\";\n app16.status = \"beta\";\n app16.store = ['legacy', 'io'];\n app16.category = ['admin'];\n app16.description = \"Permite escanear y leer códigos de barras o QR de productos para dirigirte a su PDP o agregarlos al carrito.\";\n app16.documentation = \"https://vtex.io/docs/app/vtex.vtex-logger-graphql@0.2.0/\";\n app16.download = \"\";\n app16.version = 0;\n app16.overview = \"Permite escanear y leer códigos de barras o QR de productos para dirigirte a su PDP o agregarlos al carrito.\";\n app16.feature = [\"Es excelente\", \"Es gratis\", \"Es rápida\"];\n app16.screenshot = \"https://extensions.vtexassets.com/arquivos/ids/157316/image-5516ab6fdd624a748e299584e917e082.jpg?v=637771685440800000\";\n app16.workspace = \"Link del workspace\";\n app16.video = \"Preview del video\";\n app16.requirements = [\"Whitelabel\", \"Search v15\", \"Installar la app\"];\n app16.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app16.assets = [\"Imagenes\", \"Videos\", \"Styles\"];\n app16.github = \"https://github.com/vtex-apps/apub-app-center\";\n\n return app16;\n}\n\nconst CreateData17 = () => {\n let app17 = {} as AppData;\n app17.id = 17;\n app17.name = \"Proxy Mailing Flow\";\n app17.photo = \"\";\n app17.status = \"beta\";\n app17.store = ['legacy', 'io'];\n app17.category = ['service'];\n app17.description = \"Cancels and generates orders without repeating notifications to the user.\";\n app17.documentation = \"https://vtex.io/docs/app/vtexarg.proxy-mailing-flow@3.0.8/\";\n app17.download = \"\";\n app17.version = 3;\n app17.overview = \"This service allows you to handling the mailing to be able to cancel and generate orders without repeating notifications to the user.\";\n app17.feature = [\"Es excelente\", \"Es gratis\", \"Es rápida\"];\n app17.screenshot = \"\";\n app17.workspace = \"\";\n app17.video = \"\";\n app17.requirements = [\"Whitelabel\", \"Search v15\", \"Installar la app\"];\n app17.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app17.assets = [];\n app17.github = \"https://github.com/vtex-apps/proxy-mailing-flow\";\n\n return app17;\n}\n\nconst CreateData18 = () => {\n let app18 = {} as AppData;\n app18.id = 18;\n app18.name = \"Pedidos Ya\";\n app18.photo = \"\";\n app18.status = \"beta\";\n app18.store = ['legacy', 'io'];\n app18.category = ['admin'];\n app18.description = \"Allows you to process orders generated on PedidosYa into VTEX OMS.\";\n app18.documentation = \"https://vtex.io/docs/app/vtexarg.pedidosya@2.0.29/\";\n app18.download = \"\";\n app18.version = 2;\n app18.overview = \"The PedidosYa application allows you to process orders generated on PedidosYa into VTEX OMS.\";\n app18.feature = [\"Es excelente\", \"Es gratis\", \"Es rápida\"];\n app18.screenshot = \"https://camo.githubusercontent.com/128a139d981ed607c3797dad67dc85919984a343fe27060c569327b0e022f3a5/68747470733a2f2f6d656469612e67697068792e636f6d2f6d656469612f764a5641744b545556634d71546d557a43642f67697068792e676966\";\n app18.workspace = \"Link del workspace\";\n app18.video = \"Preview del video\";\n app18.requirements = [\"Whitelabel\", \"Search v15\", \"Installar la app\"];\n app18.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app18.assets = [\"Imagenes\", \"Videos\", \"Styles\"];\n app18.github = \"https://github.com/vtex-apps/pedidosya\";\n\n return app18;\n}\n\nconst CreateData19 = () => {\n let app19 = {} as AppData;\n app19.id = 19;\n app19.name = \"Promotions Cloner\";\n app19.photo = \"\";\n app19.status = \"beta\";\n app19.store = ['legacy', 'io'];\n app19.category = ['admin'];\n app19.description = \"Clones promotions from one environment to another master + white labels and MKP.\";\n app19.documentation = \"https://vtex.io/docs/app/vtexarg.promotion-cloner@4.0.5/\";\n app19.download = \"\";\n app19.version = 4;\n app19.overview = \"Allows to clone promotions from one environment to another, in architecture master + white labels and marketplaces.\";\n app19.feature = [\"Es excelente\", \"Es gratis\", \"Es rápida\"];\n app19.screenshot = \"https://user-images.githubusercontent.com/55905671/139843737-795688e9-c44a-45c5-a32d-3714d2eab2e2.gif\";\n app19.workspace = \"Link del workspace\";\n app19.video = \"Preview del video\";\n app19.requirements = [\"Whitelabel\", \"Search v15\", \"Installar la app\"];\n app19.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app19.assets = [\"Imagenes\", \"Videos\", \"Styles\"];\n app19.github = \"https://github.com/vtex-apps/promotion-cloner\";\n\n return app19;\n}\n\nconst CreateData20 = () => {\n let app20 = {} as AppData;\n app20.id = 20;\n app20.name = \"Catalog Analyzer\";\n app20.photo = \"\";\n app20.status = \"beta\";\n app20.store = ['legacy', 'io'];\n app20.category = ['admin'];\n app20.description = \"Allows to obtain information about the products of any white label seller.\";\n app20.documentation = \"https://vtex.io/docs/app/vtexarg.catalog-analyzer@2.0.1/\";\n app20.download = \"\";\n app20.version = 2;\n app20.overview = \"Allows you to obtain information about the products of any white label seller. The information will be the name, price, stock and images of the products.\";\n app20.feature = [\"Es excelente\", \"Es gratis\", \"Es rápida\"];\n app20.screenshot = \"https://user-images.githubusercontent.com/33711188/134082316-a2ca8998-86fc-4388-9f6e-27a1e62621e8.png\";\n app20.workspace = \"Link del workspace\";\n app20.video = \"Preview del video\";\n app20.requirements = [\"Whitelabel\", \"Search v15\", \"Installar la app\"];\n app20.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app20.assets = [\"Imagenes\", \"Videos\", \"Styles\"];\n app20.github = \"https://github.com/vtex-apps/catalog-analyzer\";\n\n return app20;\n}\n\nconst CreateData21 = () => {\n let app21 = {} as AppData;\n app21.id = 21;\n app21.name = \"File Manager REST\";\n app21.photo = \"\";\n app21.status = \"beta\";\n app21.store = ['legacy', 'io'];\n app21.category = ['service'];\n app21.description = \"This app provides a public POST endpoint using file-manager.\";\n app21.documentation = \"https://vtex.io/docs/app/vtexarg.file-manager-rest@1.0.2/\";\n app21.download = \"\";\n app21.version = 1;\n app21.overview = \"This app provides a public POST endpoint using file-manager.\";\n app21.feature = [\"Es excelente\", \"Es gratis\", \"Es rápida\"];\n app21.screenshot = \"\";\n app21.workspace = \"\";\n app21.video = \"\";\n app21.requirements = [\"Whitelabel\", \"Search v15\", \"Installar la app\"];\n app21.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app21.assets = [];\n app21.github = \"https://github.com/vtex-apps/file-manager-rest\";\n\n return app21;\n}\n\nconst CreateData22 = () => {\n let app22 = {} as AppData;\n app22.id = 22;\n app22.name = \"Custom Stock Export\";\n app22.photo = \"\";\n app22.status = \"beta\";\n app22.store = ['legacy', 'io'];\n app22.category = ['service'];\n app22.description = \"This app provides a public POST endpoint using file-manager.\";\n app22.documentation = \"https://vtex.io/docs/app/vtexarg.file-manager-rest@1.0.2/\";\n app22.download = \"\";\n app22.version = 1;\n app22.overview = \"This app provides a public POST endpoint using file-manager.\";\n app22.feature = [\"Es excelente\", \"Es gratis\", \"Es rápida\"];\n app22.screenshot = \"\";\n app22.workspace = \"\";\n app22.video = \"\";\n app22.requirements = [\"Whitelabel\", \"Search v15\", \"Installar la app\"];\n app22.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app22.assets = [\"\"];\n app22.github = \"https://github.com/vtex-apps/custom-stock-export\";\n\n return app22;\n}\n\nconst CreateData23 = () => {\n let app23 = {} as AppData;\n app23.id = 23;\n app23.name = \"MasterData v2 Manager\";\n app23.photo = \"\";\n app23.status = \"beta\";\n app23.store = ['legacy', 'io'];\n app23.category = ['admin'];\n app23.description = \"Component with interface to use Master Data V2.\";\n app23.documentation = \"https://vtex.io/docs/app/vtexarg.file-manager-rest@1.0.2/\";\n app23.download = \"\";\n app23.version = 1;\n app23.overview = \"Component with interface to use Master Data V2.\";\n app23.feature = [\"Es excelente\", \"Es gratis\", \"Es rápida\"];\n app23.screenshot = \"https://user-images.githubusercontent.com/33711188/134082316-a2ca8998-86fc-4388-9f6e-27a1e62621e8.png\";\n app23.workspace = \"Link del workspace\";\n app23.video = \"Preview del video\";\n app23.requirements = [\"Whitelabel\", \"Search v15\", \"Installar la app\"];\n app23.tutorial = [\"Instalar\", \"Descargar\", \"Probar, leer documentación\"];\n app23.assets = [\"Imagenes\", \"Videos\", \"Styles\"];\n app23.github = \"https://github.com/vtex-apps/Master-Data-Manager\";\n\n return app23;\n}\n\nconst MockedData = {\n GetData: () => {\n let mockedDataList: AppData[] = [];\n\n let app1 = CreateData1();\n let app2 = CreateData2();\n let app3 = CreateData3();\n let app4 = CreateData4();\n let app5 = CreateData5();\n let app6 = CreateData6();\n let app7 = CreateData7();\n let app8 = CreateData8();\n let app9 = CreateData9();\n let app10 = CreateData10();\n let app11 = CreateData11();\n let app12 = CreateData12();\n let app13 = CreateData13();\n let app14 = CreateData14();\n let app15 = CreateData15();\n let app16 = CreateData16();\n let app17 = CreateData17();\n let app18 = CreateData18();\n let app19 = CreateData19();\n let app20 = CreateData20();\n let app21 = CreateData21();\n let app22 = CreateData22();\n let app23 = CreateData23();\n\n mockedDataList.push(app1);\n mockedDataList.push(app2);\n mockedDataList.push(app3);\n mockedDataList.push(app4);\n mockedDataList.push(app5);\n mockedDataList.push(app6);\n mockedDataList.push(app7);\n mockedDataList.push(app8);\n mockedDataList.push(app9);\n mockedDataList.push(app10);\n mockedDataList.push(app11);\n mockedDataList.push(app12);\n mockedDataList.push(app13);\n mockedDataList.push(app14);\n mockedDataList.push(app15);\n mockedDataList.push(app16);\n mockedDataList.push(app17);\n mockedDataList.push(app18);\n mockedDataList.push(app19);\n mockedDataList.push(app20);\n mockedDataList.push(app21);\n mockedDataList.push(app22);\n mockedDataList.push(app23);\n\n return mockedDataList;\n }\n\n}\n\nexport default MockedData\n\n```"
}
] |
code_apub-app-center_5fefc8ef
|
[
{
"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 apub-app-center/react/components/Cards/index.tsx from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useState, useEffect } from 'react'\nimport { FilterBar, Checkbox } from 'vtex.styleguide'\n\nimport { AppData } from '../../typings/appdata'\nimport AppCard from './AppCard'\nimport Header from './Header'\nimport MockedData from '../../data/mockedData'\nimport LoadingSpinner from './LoadingSpinner'\n\ninterface CardFilter {\n category: string[]\n store: string[]\n status: string[]\n}\n\nlet auxCardList: any[] = []\nconst cardFilter: CardFilter = { category: [], store: [], status: [] }\n\nconst SetCardData = (setCardsList: any, setLoadingState: any) => {\n auxCardList = MockedData.GetData()\n setCardsList(auxCardList)\n setLoadingState(false)\n}\n\nconst FilterCardData = (statementList: any) => {\n let cardsId: any[] = []\n FillCardFilter(statementList)\n let listToFilter = auxCardList\n\n if (cardFilter.category.length > 0) {\n listToFilter.forEach((c: AppData) => {\n cardFilter.category.forEach((cat) => {\n const hasCategory = c.category.includes(cat)\n if (hasCategory) {\n if (!cardsId.includes(c.id)) {\n cardsId.push(c.id)\n }\n }\n })\n })\n }\n\n if (cardsId.length > 0) {\n listToFilter = listToFilter.filter((c) => cardsId.includes(c.id))\n\n cardsId = []\n }\n\n if (cardFilter.store.length > 0) {\n listToFilter.forEach((c: AppData) => {\n cardFilter.store.forEach((st) => {\n const hasStore = c.store.includes(st)\n if (hasStore) {\n if (!cardsId.includes(c.id)) {\n cardsId.push(c.id)\n }\n }\n })\n })\n }\n\n if (cardsId.length > 0) {\n listToFilter = listToFilter.filter((c) => cardsId.includes(c.id))\n\n cardsId = []\n }\n\n if (cardFilter.status.length > 0) {\n listToFilter.forEach((c: AppData) => {\n cardFilter.status.forEach((sta) => {\n const hasStatus = c.status.includes(sta)\n if (hasStatus) {\n if (!cardsId.includes(c.id)) {\n cardsId.push(c.id)\n }\n }\n })\n })\n }\n\n if (cardsId.length > 0) {\n listToFilter = listToFilter.filter((c) => cardsId.includes(c.id))\n\n cardsId = []\n }\n\n return listToFilter\n}\n\nconst FillCardFilter = (statementList: any[]) => {\n statementList.forEach((s) => {\n const filteredStatements = GetSelectedStatements(s.object)\n const statements = ConvertStatementsToStringArray(s.object)\n\n const isCategory = IsCategoryFilter(statements)\n const isStore = IsStoreFilter(statements)\n const isStatus = IsStatusFilter(statements)\n\n if (isCategory) {\n cardFilter.category = filteredStatements\n }\n\n if (isStore) {\n cardFilter.store = filteredStatements\n }\n\n if (isStatus) {\n cardFilter.status = filteredStatements\n }\n })\n}\n\nconst IsCategoryFilter = (statementList: string[]) => {\n return statementList.includes('pdp')\n}\n\nconst IsStoreFilter = (statementList: string[]) => {\n return statementList.includes('legacy')\n}\n\nconst IsStatusFilter = (statementList: string[]) => {\n return statementList.includes('prod')\n}\n\nconst ConvertStatementsToStringArray = (statements: any) => {\n const keys = Object.keys(statements)\n\n return keys\n}\n\nconst GetSelectedStatements = (statements: any) => {\n const keys = Object.keys(statements)\n const values = Object.values(statements)\n const filteredStatements: string[] = []\n\n for (let i = 0; i < keys.length; i++) {\n if (values[i] == true) {\n filteredStatements.push(keys[i])\n }\n }\n\n return filteredStatements\n}\n\nconst CategorySelectorObject = ({ value, onChange }: any) => {\n const initialValue = {\n pdp: true,\n admin: true,\n search: true,\n service: true,\n gallery: true,\n checkout: true,\n ...(value || {}),\n }\n const toggleValueByKey = (key: any) => {\n const newValues = {\n ...(value || initialValue),\n [key]: value ? !value[key] : false,\n }\n return newValues\n }\n return (\n <div>\n {Object.keys(initialValue).map((opt, index) => {\n return (\n <div className=\"mb3\" key={`class-statment-object-${opt}-${index}`}>\n <Checkbox\n checked={value ? value[opt] : initialValue[opt]}\n id={`class-${opt}`}\n label={opt}\n name=\"class-checkbox-group\"\n onChange={() => {\n const newValue = toggleValueByKey(`${opt}`)\n onChange(newValue)\n }}\n value={opt}\n />\n </div>\n )\n })}\n </div>\n )\n}\n\nconst StoreSelectorObject = ({ value, onChange }: any) => {\n const initialValue = {\n legacy: true,\n io: true,\n ...(value || {}),\n }\n const toggleValueByKey = (key: any) => {\n const newValues = {\n ...(value || initialValue),\n [key]: value ? !value[key] : false,\n }\n return newValues\n }\n return (\n <div>\n {Object.keys(initialValue).map((opt, index) => {\n return (\n <div className=\"mb3\" key={`class-statment-object-${opt}-${index}`}>\n <Checkbox\n checked={value ? value[opt] : initialValue[opt]}\n id={`class-${opt}`}\n label={opt}\n name=\"class-checkbox-group\"\n onChange={() => {\n const newValue = toggleValueByKey(`${opt}`)\n onChange(newValue)\n }}\n value={opt}\n />\n </div>\n )\n })}\n </div>\n )\n}\n\nconst StatusSelectorObject = ({ value, onChange }: any) => {\n const initialValue = {\n prod: true,\n beta: true,\n ...(value || {}),\n }\n const toggleValueByKey = (key: any) => {\n const newValues = {\n ...(value || initialValue),\n [key]: value ? !value[key] : false,\n }\n return newValues\n }\n return (\n <div>\n {Object.keys(initialValue).map((opt, index) => {\n return (\n <div className=\"mb3\" key={`class-statment-object-${opt}-${index}`}>\n <Checkbox\n checked={value ? value[opt] : initialValue[opt]}\n id={`class-${opt}`}\n label={opt}\n name=\"class-checkbox-group\"\n onChange={() => {\n const newValue = toggleValueByKey(`${opt}`)\n onChange(newValue)\n }}\n value={opt}\n />\n </div>\n )\n })}\n </div>\n )\n}\n\nconst RenderCardList = (filterCardsList: any[]) => {\n return (\n filterCardsList && (\n <div className=\"flex flex-wrap\">\n {}\n {filterCardsList.map((card) => {\n return (\n <AppCard\n key={card.id}\n id={card.id}\n name={card.name}\n photo={card.photo}\n status={card.status}\n store={card.store}\n category={card.category}\n description={card.description}\n documentation={card.documentation}\n download={card.download}\n version={card.version}\n overview={card.overview}\n feature={card.feature}\n screenshot={card.screenshot}\n workspace={card.workspace}\n video={card.video}\n requirements={card.requirements}\n tutorial={card.tutorial}\n assets={card.assets}\n github={card.github}\n />\n )\n })}\n </div>\n )\n )\n}\n\nconst LoadingCards = () => {\n return <LoadingSpinner />\n}\n\nexport default function Cards() {\n const [cardsList, setCardsList] = useState<AppData[]>([])\n useEffect(() => {\n if (cardsList.length === 0) {\n SetCardData(setCardsList, setLoadingState)\n }\n }, [])\n\n const [statementsList, setStatementsList] = useState([])\n useEffect(() => {\n if (statementsList) {\n const list = FilterCardData(statementsList)\n setFilterCardsList(list)\n }\n\n if (cardsList.length > 0 && !statementsList) {\n setFilterCardsList(cardsList)\n } else {\n\n\n if(statementsList && statementsList.length == 0){\n setFilterCardsList(cardsList)\n }\n }\n }, [statementsList, cardsList])\n\n const [isLoading, setLoadingState] = useState<boolean>(true)\n\n const [filterCardsList, setFilterCardsList] = useState<AppData[]>()\n\n const RenderCards = isLoading\n ? LoadingCards()\n : RenderCardList(filterCardsList ?? [])\n\n return (\n <>\n <Header text=\"Filtros\" />\n <div className=\"ma3 pa3 mb2 ba br2 b--muted-4\">\n <FilterBar\n alwaysVisibleFilters={['categoria', 'tienda', 'status']}\n statements={statementsList}\n onChangeStatements={(statement: any) => setStatementsList(statement)}\n clearAllFiltersButtonLabel=\"Limpiar filtros\"\n options={{\n categoria: {\n label: 'Categoria',\n renderFilterLabel: (st: any) => {\n if (!st || !st.object) {\n // you should treat empty object cases only for alwaysVisibleFilters\n return 'Todas'\n }\n const keys = st.object ? Object.keys(st.object) : []\n const isAllTrue = !keys.some((key) => !st.object[key])\n const isAllFalse = !keys.some((key) => st.object[key])\n const trueKeys = keys.filter((key) => st.object[key])\n let trueKeysLabel = ''\n trueKeys.forEach((key, index) => {\n trueKeysLabel += `${key}${\n index === trueKeys.length - 1 ? '' : ', '\n }`\n })\n return `${\n isAllTrue\n ? 'Todas'\n : isAllFalse\n ? 'Ninguna'\n : `${trueKeysLabel}`\n }`\n },\n verbs: [\n {\n value: 'includes',\n object: (props: any) => <CategorySelectorObject {...props} />,\n },\n ],\n },\n\n tienda: {\n label: 'Tienda',\n renderFilterLabel: (st: any) => {\n if (!st || !st.object) {\n // you should treat empty object cases only for alwaysVisibleFilters\n return 'Todas'\n }\n const keys = st.object ? Object.keys(st.object) : []\n const isAllTrue = !keys.some((key) => !st.object[key])\n const isAllFalse = !keys.some((key) => st.object[key])\n const trueKeys = keys.filter((key) => st.object[key])\n let trueKeysLabel = ''\n trueKeys.forEach((key, index) => {\n trueKeysLabel += `${key}${\n index === trueKeys.length - 1 ? '' : ', '\n }`\n })\n return `${\n isAllTrue\n ? 'Todas'\n : isAllFalse\n ? 'Ninguna'\n : `${trueKeysLabel}`\n }`\n },\n verbs: [\n {\n value: 'includes',\n object: (props: any) => <StoreSelectorObject {...props} />,\n },\n ],\n },\n\n status: {\n label: 'Status',\n renderFilterLabel: (st: any) => {\n if (!st || !st.object) {\n // you should treat empty object cases only for alwaysVisibleFilters\n return 'Todas'\n }\n const keys = st.object ? Object.keys(st.object) : []\n const isAllTrue = !keys.some((key) => !st.object[key])\n const isAllFalse = !keys.some((key) => st.object[key])\n const trueKeys = keys.filter((key) => st.object[key])\n let trueKeysLabel = ''\n trueKeys.forEach((key, index) => {\n trueKeysLabel += `${key}${\n index === trueKeys.length - 1 ? '' : ', '\n }`\n })\n return `${\n isAllTrue\n ? 'Todas'\n : isAllFalse\n ? 'Ninguna'\n : `${trueKeysLabel}`\n }`\n },\n verbs: [\n {\n value: 'includes',\n object: (props: any) => <StatusSelectorObject {...props} />,\n },\n ],\n },\n }}\n />\n </div>\n <Header text=\"Todas las Apps\" />\n {RenderCards}\n </>\n )\n}\n\n```"
}
] |
code_apub-app-center_3ad28857
|
[
{
"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 apub-app-center/react/components/Cards/AppCard.tsx from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, {useState} from 'react'\nimport { Button, Tag } from 'vtex.styleguide'\nimport CardDiv from './CardDiv';\nimport { AppData } from '../../typings/appdata'\n\nconst GetStatusTagByColor = (appStatus: string) => {\n switch(appStatus) {\n case 'prod':\n return (\n <Tag size=\"small\" type=\"success\">\n {appStatus}\n </Tag>\n );\n case 'beta':\n return (\n <Tag size=\"small\" type=\"warning\">\n {appStatus}\n </Tag>\n );\n default:\n return (\n <Tag size=\"small\" variation=\"low\">\n {appStatus}\n </Tag>\n );\n }\n}\n\nconst RenderStatusTag = (appStatus: string) => {\n return(\n <div className=\"mb2\">\n <span className=\"mr2\">\n {GetStatusTagByColor(appStatus)}\n </span>\n </div>\n )\n}\n\nconst RenderStoreTags = (appStatus: string, stores: string[]) => {\n return(\n <div className=\"mb2\">\n {stores.map((store, i) => {\n if (appStatus == \"idea\"){\n return(\n <span key={\"span-\" + store + i} className=\"mr2 mb2\">\n <Tag size=\"small\" variation=\"low\">\n {store}\n </Tag>\n </span>\n )\n } else {\n return(\n <span key={\"span-\" + store + i} className=\"mr2 mb2\">\n <Tag size=\"small\">\n {store}\n </Tag>\n </span>\n )\n }\n })}\n </div>\n );\n}\n\nconst RenderCategoryTags = (appStatus: string, categories: string []) => {\n return(\n <div className=\"mb2\">\n {categories.map((category, i) =>{\n if (appStatus == \"idea\"){\n return(\n <span key={\"span-\" + category + i} className=\"mr2 mb2\">\n <Tag size=\"small\" variation=\"low\">\n {category}\n </Tag>\n </span>\n )\n } else {\n return(\n <span key={\"span-\" + category + i} className=\"mr2 mb2\">\n <Tag size=\"small\" bgColor=\"#134CD8\">\n {category}\n </Tag>\n </span>\n )\n }\n })}\n </div>\n )\n}\n\nconst RenderPhoto = (appPhoto: string) => {\n const svg =\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 30 30\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M5 24L9 17L13 20L19 13L25 24H5Z\" stroke=\"#979899\" stroke-width=\"2\" stroke-miterlimit=\"10\" stroke-linecap=\"square\">\n </path>\n <path d=\"M11.5 12C12.8807 12 14 10.8807 14 9.5C14 8.11929 12.8807 7 11.5 7C10.1193 7 9 8.11929 9 9.5C9 10.8807 10.1193 12 11.5 12Z\" stroke=\"#979899\" stroke-width=\"2\" stroke-miterlimit=\"10\" stroke-linecap=\"square\"></path><path d=\"M29 1H1V29H29V1Z\" stroke=\"#979899\" stroke-width=\"2\" stroke-miterlimit=\"10\" stroke-linecap=\"square\">\n </path>\n </svg>;\n\n return(\n <>\n {\n appPhoto == null || appPhoto == '' ?\n (\n <div className=\"image-size mw-100 mh-100 bg-muted-5 flex justify-center items-center mr4\">\n {svg}\n </div>\n )\n :\n (\n <div className=\"image-size mr4\">\n <img\n className='mw-100 mh-100'\n src={appPhoto}\n alt=\"AppIcon\"\n />\n </div>\n )\n }\n </>\n )\n}\n\nconst AppCard = (props: AppData) => {\n const [loadingState, setLoadingState]= useState<boolean>(false);\n return (\n <div className='w-100 w-third-ns pa3' key={\"card-\" + props.id}>\n <CardDiv>\n <div className='flex flex-wrap items-center mv5'>\n {RenderStatusTag(props.status)}\n {RenderStoreTags(props.status, props.store)}\n {RenderCategoryTags(props.status, props.category)}\n </div>\n <div className='flex flex-column'>\n <a className=\"link\" href={`/admin/app/apub-app-center/${props.id}`}>\n <div className='flex'>\n {RenderPhoto(props.photo)}\n <div className=\"card-div-name mr4\">\n <h3 className='f5 fw5 near-black mv3'>\n {props.name}\n </h3>\n </div>\n </div>\n </a>\n <div>\n <p className='f7 c-muted-2'>\n {props.description}\n </p>\n </div>\n <div className='flex justify-end items-center'>\n <Button\n variation=\"secondary\"\n size=\"small\"\n href={`/admin/app/apub-app-center/${props.id}`}\n onClick={() => setLoadingState(!loadingState)}\n isLoading={loadingState}\n >\n Ver más\n </Button>\n </div>\n </div>\n </CardDiv>\n </div>\n )\n}\n\nexport default AppCard\n\n```"
}
] |
code_apub-app-center_63dcfec7
|
[
{
"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 apub-app-center/react/components/Cards/LoadingSpinner.tsx from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { Spinner } from 'vtex.styleguide'\nimport React from 'react'\n\nexport default function LoadingSpinner() {\n return (\n <div className=\"loading-container\">\n <Spinner />\n </div>\n )\n}\n\n```"
}
] |
code_apub-app-center_93c06eb5
|
[
{
"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 apub-app-center/react/components/Cards/Header.tsx from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\ninterface Header {\n text: string\n}\n\nconst Header = (props: Header) => {\n return (\n <div className=\"w-100 flex flex-wrap bg-white pa3 mb2\">\n <div className=\"flex flex-column w-100\">\n <div className=\"flex justify-between w-100 items-center\">\n <span className=\"f4 fw5\">{props.text}</span>\n </div>\n </div>\n </div>\n )\n}\n\nexport default Header\n\n```"
}
] |
code_apub-app-center_fb5fea1a
|
[
{
"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 apub-app-center/react/components/Cards/CardDiv.tsx from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nconst CardDiv = (props: any) => {\n return (\n <div className='w-100 flex flex-wrap bg-white ba br2 b--muted-4 pa6 card-hover pa6 h-100 flex flex-column justify-between'>\n {props.children}\n </div>\n )\n}\n\nexport default CardDiv\n\n```"
}
] |
code_apub-app-center_0f4527b2
|
[
{
"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 apub-app-center/react/components/Detail/Resume.tsx from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from \"react\";\nimport { Link } from 'vtex.styleguide'\n\nconst RenderPhoto = (appPhoto: string) => {\n const svg =\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 30 30\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M5 24L9 17L13 20L19 13L25 24H5Z\" stroke=\"#979899\" stroke-width=\"2\" stroke-miterlimit=\"10\" stroke-linecap=\"square\">\n </path>\n <path d=\"M11.5 12C12.8807 12 14 10.8807 14 9.5C14 8.11929 12.8807 7 11.5 7C10.1193 7 9 8.11929 9 9.5C9 10.8807 10.1193 12 11.5 12Z\" stroke=\"#979899\" stroke-width=\"2\" stroke-miterlimit=\"10\" stroke-linecap=\"square\"></path><path d=\"M29 1H1V29H29V1Z\" stroke=\"#979899\" stroke-width=\"2\" stroke-miterlimit=\"10\" stroke-linecap=\"square\">\n </path>\n </svg>;\n\n return(\n <>\n {\n appPhoto == null || appPhoto == '' ?\n (\n <div className=\"mw-100 mh-100 image-size-detail bg-muted-5 flex justify-center items-center\">\n {svg}\n </div>\n )\n :\n (\n <img src={appPhoto} alt=\"App detail photo\" />\n )\n }\n </>\n )\n}\n\nconst Resume = (props: { photo: string, version: number, status: string, store: string[], category: string[], documentation: string}) => {\n return(\n <div className=\"w-20\">\n <div className=\"mb7\">\n {RenderPhoto(props.photo)}\n </div>\n <h6 className=\"f6 near-black mv3\">Última versión</h6>\n <p className=\"f6 gray mt0 mb7\">\n {props.version}.x\n </p>\n <h6 className=\"f6 near-black mv3\">Status</h6>\n <p className=\"f6 gray mt0 mb7\">\n {props.status}\n </p>\n <h6 className=\"f6 near-black mv3\">Tiendas</h6>\n <p className=\"f6 gray mt0 mb7\">\n {props.store.join(', ')}\n </p>\n <h6 className=\"f6 near-black mv3\">Categorias</h6>\n <p className=\"f6 gray mt0 mb7\">\n {props.category.join(', ')}\n </p>\n <h6 className=\"f6 near-black mv3\">Soporte</h6>\n <p>\n <Link\n href={props.documentation}\n target=\"_blank\"\n mediumWeigth>\n Documentación\n </Link>\n </p>\n </div>\n )\n}\n\nexport default Resume\n\n```"
}
] |
code_apub-app-center_0d70771e
|
[
{
"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 apub-app-center/react/components/Detail/AppTabs.tsx from the apub-app-center VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useState } from 'react'\n// import { FormattedMessage } from 'react-intl'\nimport { Tabs, Tab, Button, Link } from 'vtex.styleguide'\n\nconst Check = (\n <svg className=\"vtex__icon-check\" width=\"20\" height=\"20\" viewBox=\"0 0 12 12\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\">\n <path d=\"M10.8 4.4L9.4 3L5.4 7L3.4 5L2 6.4L5.4 9.8L10.8 4.4Z\" fill=\"currentColor\">\n </path>\n </svg>\n)\n\nconst RenderGetAppButton = ( appStore: string ) => {\n return(\n <>\n {\n appStore == null || appStore == '' ?\n (\n <div className=\"w-30\"></div>\n )\n :\n (\n <div className=\"w-30\">\n <Button variation=\"primary\" href={appStore} target=\"_blank\">\n Descarga la App\n </Button>\n </div>\n )\n }\n </>\n )\n}\n\nconst RenderAppOverview = ( overview: string ) => {\n return(\n <>\n <p className=\"f9 mt8 mb5\">Overview</p>\n <p className=\"f6 gray ma0\">\n {overview}\n </p>\n </>\n )\n}\n\nconst RenderAppFeatures = ( features: string[] ) => {\n return(\n <>\n <p className=\"f9 mt8 mb5\">Features</p>\n <div className='ph6 pv3'>\n {\n (features.map(feature =>{\n return(\n <>\n <div className=\"gray flex ma0\">\n {Check}\n <p className=\"f6 gray ma2\">\n {feature}\n </p>\n </div>\n </>\n )\n }))\n }\n </div>\n </>\n )\n}\n\nconst RenderAppScreenshot = ( screenshot: string ) => {\n return(\n <>\n {\n screenshot == null || screenshot == '' ?\n (\n <>\n <p className=\"f6 mt8 mb5 gray ma0\">No hay screenshot disponible</p>\n </>\n )\n :\n (\n <>\n <p className=\"f9 mt8 mb5\">Screenshots</p>\n <img src={screenshot} alt=\"App detail photo\" />\n </>\n )\n }\n </>\n )\n}\n\nconst RenderAppWorkspace = ( workspace: string ) => {\n return(\n <>\n {\n workspace == null || workspace == '' ?\n (\n <>\n <p className=\"f6 mt8 mb5 gray ma0\">No requiere un workspace especifico</p>\n </>\n )\n :\n (\n <>\n <p className=\"f9 mt8 mb5\">Entorno</p>\n <p className=\"f6 gray ma0\">\n <Link href={workspace}>{workspace}</Link>\n </p>\n </>\n )\n }\n </>\n )\n}\n\nconst RenderAppVideo = ( video: string ) => {\n return(\n <>\n {\n video == null || video == '' ?\n (\n <>\n <p className=\"f6 mt8 mb5 gray ma0\">No hay video disponible</p>\n </>\n )\n :\n (\n <>\n <p className=\"f9 mt8 mb5\">Video</p>\n <p className=\"f6 gray ma0\">\n {video}\n </p>\n </>\n )\n }\n </>\n )\n}\n\nconst RenderAppRequirements = ( requirements: string[] ) => {\n return(\n <>\n <p className=\"f9 mt8 mb5\">Requisitos</p>\n <ul>\n {(requirements.map(requirement =>{\n return(\n <li>\n <p className=\"f6 gray ma0\">\n {requirement}\n </p>\n </li>\n )\n }))}\n </ul>\n </>\n )\n}\n\nconst RenderAppTutorial = ( tutorials: string[] ) => {\n return(\n <>\n <p className=\"f9 mt8 mb5\">Paso a Paso</p>\n <ol>\n {\n (tutorials.map(tutorial =>{\n return(\n <li>\n <p className=\"f6 ma0\">\n {tutorial}\n </p>\n </li>\n )\n }))\n }\n </ol>\n </>\n )\n}\n\nconst RenderAppAssets = ( assets: string[] ) => {\n return(\n <>\n {\n assets.length == 0 ?\n (\n <>\n <p className=\"f6 mt8 mb5 gray ma0\">No es necesario utilizar assets</p>\n </>\n )\n :\n (\n <>\n <p className=\"f9 mt8 mb5\">Descargar Assets</p>\n <div>\n {\n (assets.map(asset =>{\n return(\n <p className=\"f6 gray ma0\">\n <Link\n href=\"\"\n target=\"_blank\"\n mediumWeigth>\n {asset}\n </Link>\n </p>\n )\n }))\n }\n </div>\n </>\n )\n }\n </>\n )\n}\n\nconst RenderAppHelpLinks = ( github: string ) => {\n return(\n <>\n <p className=\"f9 mt8 mb5\">Links de Ayuda</p>\n <Link\n href=\"https://vtex.slack.com/archives/C017JF73XCH\"\n target=\"_blank\"\n mediumWeigth>\n Canal de Slack APUB First Party Apps\n </Link>\n <br></br>\n <Link\n href={github}\n target=\"_blank\"\n mediumWeigth>\n Repo de Github\n </Link>\n </>\n )\n}\n\nconst AppTabs = (props: {\n name: string,\n download: string,\n overview: string,\n feature: string[],\n screenshot: string,\n workspace: string,\n video: string,\n requirements: string[],\n tutorial: string[],\n assets: string[],\n github: string\n}) => {\n const [currentTab, setCurrentTab] = useState<Number>(1);\n return (\n <div className=\"w-80\">\n\n <div className='flex mb9'>\n\n <div className=\"w-70\">\n <h2 className=\"ma3\"> {props.name} </h2>\n </div>\n\n {RenderGetAppButton(props.download)}\n\n </div>\n\n <Tabs fullWidth>\n <Tab\n label=\"Resumen\"\n active={currentTab == 1}\n onClick={() => setCurrentTab(1)}>\n {RenderAppOverview(props.overview)}\n {RenderAppFeatures(props.feature)}\n {RenderAppScreenshot(props.screenshot)}\n </Tab>\n\n <Tab\n label=\"Demo\"\n active={currentTab === 2}\n onClick={() => setCurrentTab(2)}>\n {RenderAppWorkspace(props.workspace)}\n {RenderAppVideo(props.video)}\n </Tab>\n\n <Tab\n label=\"Tutorial\"\n active={currentTab === 3}\n onClick={() => setCurrentTab(3)}>\n {RenderAppRequirements(props.requirements)}\n {RenderAppTutorial(props.requirements)}\n {RenderAppAssets(props.assets)}\n {RenderAppHelpLinks(props.github)}\n </Tab>\n </Tabs>\n\n </div>\n )\n}\n\nexport default AppTabs\n\n```"
}
] |
code_chaordic-graphql_f7adc3c5
|
[
{
"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 chaordic-graphql/docs/README.md from the chaordic-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# Chaordic GraphQL resolvers\n\nTo add your Chaordic token you must create a file in VBase at the `secret_keys` bucket called `keys.json` with this format:\n\n```\n{\n \"apiKey\": \"<apiKey>\",\n \"secretKey\": \"<token>\"\n}\n```\n\nExample curl:\n\n```\ncurl --request PUT \\\n --url 'http://vbase.aws-us-east-1.vtex.io/<account>/<workspace>/buckets/vtex.chaordic-graphql/secret_keys/files/keys.json' \\\n --header 'authorization: <vtex token>' \\\n --header 'content-type: application/json' \\\n --data '{\n \"apiKey\": \"<apiKey>\",\n \"secretKey\": \"<token>\"\n}'\n```\n\nTo grab your vtex token, run on the terminal:\n\n`vtex local token`\n\n```"
}
] |
code_chaordic-graphql_7e695a5b
|
[
{
"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 chaordic-graphql/graphql/schema.graphql from the chaordic-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ntype Query {\n searchProducts(\n terms: String = \"\"\n page: Int = 1\n salesChannel: String\n sortBy: String\n filter: [String]\n productFormat: String\n resultsPerPage: Int = 12\n ): ChaordicSearchOutput!\n @cacheControl(scope: SEGMENT, maxAge: SHORT)\n @withSecretKeys\n\n searchProductsAutoComplete(\n salesChannel: String\n terms: String = \"\"\n ): ChaordicSearchAutoCompleteOutput!\n @cacheControl(scope: SEGMENT, maxAge: SHORT)\n @withSecretKeys\n\n searchProductsAutoCompletePopular: ChaordicSearchAutoCompletePopularOutput!\n @withSecretKeys\n\n chaordicRecommendations(\n showOnlyAvailable: Boolean = true\n chaordicBrowserId: String!\n pathName: String!\n source: String!\n userId: String\n category: [String]\n salesChannel: String\n name: String\n productId: String\n ): ChaordicRecommendationsResult!\n @cacheControl(scope: SEGMENT, maxAge: SHORT)\n @withSecretKeys\n\n chaordicProductPageRecommendations(\n chaordicBrowserId: String!\n productId: String!\n salesChannel: String\n type: String\n size: Int\n ): ChaordicProductPageRecommendations!\n @cacheControl(scope: SEGMENT, maxAge: SHORT)\n @withSecretKeys\n\n searchProductsNavigates(\n fields: String,\n category: String,\n multicategory: [String],\n page: Int = 1,\n resultsPerPage: Int = 10,\n sortBy: String = \"relevance\",\n filter: String\n ): ChaordicNavigatesOutput! @cacheControl(scope: PUBLIC, maxAge: SHORT) @withSecretKeys\n\n}\n\ntype Mutation {\n ChaordicImpression(impressionUrl: String!): Boolean @withSecretKeys\n}\n\n```"
}
] |
code_chaordic-graphql_de84b2f1
|
[
{
"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 chaordic-graphql/graphql/types.graphql from the chaordic-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nscalar ChaordicSearchProductDetails\n\nscalar ChaordicTagParent\n\nscalar ChaordicSpecs\n\nscalar ChaordicRecommendationsSkuDetail\n\nscalar ChaordicRecommendationsSkuSpecs\n\nscalar ChaordicRecommendationsProductDetails\n\ntype ChaordicSearchOutput {\n banners: [ChaordicSearchBanner]\n quickFilters: [ChaordicSearchQuickFilter]\n products: [ChaordicSearchProduct]\n pagination: ChaordicSearchPagination\n filters: [ChaordicSearchFilters]\n queries: ChaordicSearchQueries\n requestId: String\n searchId: String\n size: Int\n queryType: String\n link: String\n}\n\ntype ChaordicSearchBanner {\n position: String\n content: String\n}\n\ntype ChaordicSearchQuickFilter {\n name: String\n image: String\n}\n\ntype ChaordicSearchProduct {\n brand: String\n cacheId: ID\n cId: String\n clickUrl: String\n collectInfo: ChaordicSearchProductCollectionInfo\n details: ChaordicSearchProductDetails\n iId: Int\n id: String\n productId: String\n images: ChaordicSearchProductImages\n installment: ChaordicSearchProductInstallment\n name: String\n oldPrice: Float\n price: Float\n status: String\n url: String\n categories: [ChaordicCategory]\n tags: [ChaordicTag]\n created: String\n selectedSku: String\n skus: [ChaordicSku]\n}\n\ntype ChaordicSku {\n sku: String\n specs: ChaordicSpecs\n properties: ChaordicProperties\n}\n\ntype ChaordicProperties {\n status: String\n price: Float\n oldPrice: Float\n details: ChaordicSearchProductDetails\n name: String\n}\n\n\ntype ChaordicTag {\n parents: [ChaordicTagParent]\n id: String\n name: String\n}\n\ntype ChaordicCategory {\n parents: [String]\n id: String\n name: String\n}\n\ntype ChaordicSearchProductCollectionInfo {\n productId: String\n skuList: [String]\n}\n\n#\n# Fields: Publico, InformacoesImportantes, FamiliaOlfativa, Video\n# Problem: Missing because accent.\n#\n\ntype ChaordicSearchProductDetailsHighLight {\n name: String\n}\n\ntype ChaordicSearchProductImages {\n default: String\n template: String\n}\n\ntype ChaordicSearchProductInstallment {\n price: Float\n count: Int\n}\n\ntype ChaordicSearchPagination {\n first: String\n next: String\n last: String\n}\n\ntype ChaordicSearchFilters {\n attribute: String\n fType: Int\n id: Int\n type: String\n values: [ChaordicSearchFiltersValues]\n}\n\ntype ChaordicSearchFiltersValues {\n label: String\n size: Int\n id: Int\n applyLink: String\n unN: String\n unityId: Int\n min: ChaordicSearchFiltersValuesMin\n max: ChaordicSearchFiltersValuesMax\n idO: String\n filters: [ChaordicSearchFiltersValuesFilters]\n}\n\ntype ChaordicSearchFiltersValuesMin {\n value: Float\n unity: String\n minN: Float\n}\n\ntype ChaordicSearchFiltersValuesMax {\n value: Float\n unity: String\n maxN: Float\n}\n\ntype ChaordicSearchFiltersValuesFilters {\n applyLink: String\n filters: [ChaordicSearchFiltersValuesFilters]\n id: Int\n idO: String\n label: String\n size: Int\n}\n\ntype ChaordicSearchQueries {\n normalized: String\n original: String\n processed: String\n queryType: String\n}\n\ntype ChaordicSearchAutoCompleteOutput {\n requestId: String\n searchId: String\n queries: [ChaordicSearchAutoCompleteQueries]\n products: [ChaordicSearchProduct]\n}\n\ntype ChaordicSearchAutoCompleteQueries {\n query: String\n link: String\n}\n\ntype ChaordicSearchAutoCompletePopularOutput {\n requestId: String\n searchId: String\n queries: [ChaordicSearchAutoCompleteQueries]\n}\n\ntype ChaordicRecommendationsResult {\n top: [ChaordicRecommendations]!\n middle: [ChaordicRecommendations]!\n bottom: [ChaordicRecommendations]!\n}\n\ntype ChaordicRecommendations {\n id: String!\n title: String!\n name: String!\n feature: String!\n impressionUrl: String!\n subtitle: String\n context: String!\n displays: [ChaordicRecommendationsDisplays]!\n}\n\ntype ChaordicProductPageRecommendations {\n context: String!\n displays: [ChaordicRecommendationsDisplays]!\n}\n\ntype ChaordicRecommendationsDisplays {\n references: [ChaordicProductPageRecommendationsProduct]!\n recommendations: [ChaordicProductPageRecommendationsProduct]!\n refreshReferenceUrl: String\n}\n\ntype ChaordicRecommendationsProduct {\n id: String!\n name: String!\n price: Float!\n oldPrice: Float\n url: String!\n images: ChaordicRecommendationsProductImages\n brand: String\n installment: ChaordicRecommendationsProductInstallment\n status: String\n categories: [ChaordicRecommendationsProductCategory]\n details: ChaordicRecommendationsProductDetails\n skus: [ChaordicRecommendationsSku]!\n trackingUrl: String\n}\n\ntype ChaordicProductPageRecommendationsProduct {\n id: String!\n name: String!\n price: Float!\n oldPrice: Float\n url: String!\n images: ChaordicRecommendationsProductImages\n brand: String\n installment: ChaordicProductPageRecommendationsProductInstallment\n status: String\n categories: [ChaordicRecommendationsProductCategory]\n details: ChaordicRecommendationsProductDetails\n skus: [ChaordicRecommendationsSku]!\n trackingUrl: String\n}\n\ntype ChaordicRecommendationsProductImages {\n default: String\n template: String\n # TODO: Rename these fields for valid graphql identifiers, e.g. small, medium, large.\n # _200x200: String\n # _400x400: String\n # _1000x1000: String\n}\n\ntype ChaordicRecommendationsProductInstallment {\n price: Float\n count: Int\n}\n\ntype ChaordicProductPageRecommendationsProductInstallment {\n price: Float\n count: Int\n}\n\ntype ChaordicRecommendationsProductCategory {\n id: String!\n name: String!\n parents: [String]\n}\n\ntype ChaordicRecommendationsSku {\n status: String!\n url: String!\n name: String!\n sku: String!\n images: ChaordicRecommendationsProductImages\n installment: ChaordicRecommendationsProductInstallment\n price: Float\n oldPrice: Float\n stock: Int\n details: ChaordicRecommendationsSkuDetail\n specs: ChaordicRecommendationsSkuSpecs\n}\n\ntype ChaordicRecommendationsProductSkus {\n status: String!\n url: String!\n name: String!\n images: ChaordicRecommendationsProductImages\n installment: ChaordicRecommendationsProductInstallment\n price: Float\n oldPrice: Float\n stock: Int\n details: ChaordicRecommendationsSkuDetail\n sku: String\n specs: ChaordicRecommendationsSkuSpecs\n}\n\ntype ChaordicSort {\n label: String\n name: String\n type: String\n applyLink: String\n}\n\ntype ChaordicNavigatesOutput {\n requestId: String\n searchId: String\n size: Int\n name: String\n sort: [ChaordicSort]\n products: [ChaordicSearchProduct]\n pagination: ChaordicSearchPagination\n filters: [ChaordicSearchFilters]\n}\n\n```"
}
] |
code_chaordic-graphql_dbea99f1
|
[
{
"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 chaordic-graphql/node/service.json from the chaordic-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"stack\": \"nodejs\",\n \"memory\": 512,\n \"ttl\": 60,\n \"timeout\": 10,\n \"minReplicas\": 8,\n \"maxReplicas\": 20\n}\n\n```"
}
] |
code_chaordic-graphql_be56af1e
|
[
{
"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 chaordic-graphql/node/utils.ts from the chaordic-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport function atob(b64Encoded?: string) {\n if (!b64Encoded) {\n return ''\n }\n return Buffer.from(b64Encoded, 'base64').toString()\n}\n\nexport const formatSalesChannel = (segment?: any): string => {\n if (!segment) {\n return ''\n }\n\n const franchise = segment.regionId\n ? `${atob(segment.regionId).replace('SW#', '')}-`\n : ''\n return `${franchise}${segment.channel}`\n}\n\n```"
}
] |
code_chaordic-graphql_defff9bc
|
[
{
"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 chaordic-graphql/node/package.json from the chaordic-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"@types/qs\": \"^6.9.1\",\n \"axios\": \"^0.18.0\",\n \"bluebird\": \"^3.5.0\",\n \"co-body\": \"^6.0.0\",\n \"cookie\": \"^0.3.1\",\n \"graphql\": \"^0.13.2\",\n \"graphql-tools\": \"^3.1.1\",\n \"qs\": \"^6.9.4\",\n \"ramda\": \"^0.25.0\",\n \"request\": \"^2.85.0\",\n \"slugify\": \"^1.2.6\",\n \"url-parse\": \"^1.2.0\",\n \"utf8\": \"^3.0.0\"\n },\n \"devDependencies\": {\n \"@types/bluebird\": \"^3.5.0\",\n \"@types/bluebird-global\": \"^3.5.0\",\n \"@types/es6-shim\": \"^0.31.32\",\n \"@types/graphql\": \"^14.0.5\",\n \"@types/koa\": \"^2.0.39\",\n \"@types/node\": \"^10.5.3\",\n \"@types/ramda\": \"types/npm-ramda#dist\",\n \"@types/request\": \"^2.47.0\",\n \"@vtex/api\": \"^3.8.1\",\n \"tslint\": \"^5.12.0\",\n \"tslint-config-vtex\": \"^2.1.0\",\n \"typescript\": \"3.8.3\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit && tslint --fix -c tslint.json './**/*.ts'\"\n },\n \"version\": \"2.6.0\"\n}\n\n```"
}
] |
code_chaordic-graphql_4c64be17
|
[
{
"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 chaordic-graphql/node/utf8.ts from the chaordic-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const utf8ToChar: Record<string, string> = {\n '\\\\xc2\\\\x80': ' ',\n '\\\\xc2\\\\x81': ' ',\n '\\\\xc2\\\\x82': ' ',\n '\\\\xc2\\\\x83': ' ',\n '\\\\xc2\\\\x84': ' ',\n '\\\\xc2\\\\x85': ' ',\n '\\\\xc2\\\\x86': ' ',\n '\\\\xc2\\\\x87': ' ',\n '\\\\xc2\\\\x88': ' ',\n '\\\\xc2\\\\x89': ' ',\n '\\\\xc2\\\\x8a': ' ',\n '\\\\xc2\\\\x8b': ' ',\n '\\\\xc2\\\\x8c': ' ',\n '\\\\xc2\\\\x8d': ' ',\n '\\\\xc2\\\\x8e': ' ',\n '\\\\xc2\\\\x8f': ' ',\n '\\\\xc2\\\\x90': ' ',\n '\\\\xc2\\\\x91': ' ',\n '\\\\xc2\\\\x92': ' ',\n '\\\\xc2\\\\x93': ' ',\n '\\\\xc2\\\\x94': ' ',\n '\\\\xc2\\\\x95': ' ',\n '\\\\xc2\\\\x96': ' ',\n '\\\\xc2\\\\x97': ' ',\n '\\\\xc2\\\\x98': ' ',\n '\\\\xc2\\\\x99': ' ',\n '\\\\xc2\\\\x9a': ' ',\n '\\\\xc2\\\\x9b': ' ',\n '\\\\xc2\\\\x9c': ' ',\n '\\\\xc2\\\\x9d': ' ',\n '\\\\xc2\\\\x9e': ' ',\n '\\\\xc2\\\\x9f': ' ',\n '\\\\xc2\\\\xa0': ' ',\n '\\\\xc2\\\\xa1': '¡',\n '\\\\xc2\\\\xa2': '¢',\n '\\\\xc2\\\\xa3': '£',\n '\\\\xc2\\\\xa4': '¤',\n '\\\\xc2\\\\xa5': '¥',\n '\\\\xc2\\\\xa6': '¦',\n '\\\\xc2\\\\xa7': '§',\n '\\\\xc2\\\\xa8': '¨',\n '\\\\xc2\\\\xa9': '©',\n '\\\\xc2\\\\xaa': 'ª',\n '\\\\xc2\\\\xab': '«',\n '\\\\xc2\\\\xac': '¬',\n '\\\\xc2\\\\xad': '',\n '\\\\xc2\\\\xae': '®',\n '\\\\xc2\\\\xaf': '¯',\n '\\\\xc2\\\\xb0': '°',\n '\\\\xc2\\\\xb1': '±',\n '\\\\xc2\\\\xb2': '²',\n '\\\\xc2\\\\xb3': '³',\n '\\\\xc2\\\\xb4': '´',\n '\\\\xc2\\\\xb5': 'µ',\n '\\\\xc2\\\\xb6': '¶',\n '\\\\xc2\\\\xb7': '·',\n '\\\\xc2\\\\xb8': '¸',\n '\\\\xc2\\\\xb9': '¹',\n '\\\\xc2\\\\xba': 'º',\n '\\\\xc2\\\\xbb': '»',\n '\\\\xc2\\\\xbc': '¼',\n '\\\\xc2\\\\xbd': '½',\n '\\\\xc2\\\\xbe': '¾',\n '\\\\xc2\\\\xbf': '¿',\n '\\\\xc3\\\\x80': 'À',\n '\\\\xc3\\\\x81': 'Á',\n '\\\\xc3\\\\x82': 'Â',\n '\\\\xc3\\\\x83': 'Ã',\n '\\\\xc3\\\\x84': 'Ä',\n '\\\\xc3\\\\x85': 'Å',\n '\\\\xc3\\\\x86': 'Æ',\n '\\\\xc3\\\\x87': 'Ç',\n '\\\\xc3\\\\x88': 'È',\n '\\\\xc3\\\\x89': 'É',\n '\\\\xc3\\\\x8a': 'Ê',\n '\\\\xc3\\\\x8b': 'Ë',\n '\\\\xc3\\\\x8c': 'Ì',\n '\\\\xc3\\\\x8d': 'Í',\n '\\\\xc3\\\\x8e': 'Î',\n '\\\\xc3\\\\x8f': 'Ï',\n '\\\\xc3\\\\x90': 'Ð',\n '\\\\xc3\\\\x91': 'Ñ',\n '\\\\xc3\\\\x92': 'Ò',\n '\\\\xc3\\\\x93': 'Ó',\n '\\\\xc3\\\\x94': 'Ô',\n '\\\\xc3\\\\x95': 'Õ',\n '\\\\xc3\\\\x96': 'Ö',\n '\\\\xc3\\\\x97': '×',\n '\\\\xc3\\\\x98': 'Ø',\n '\\\\xc3\\\\x99': 'Ù',\n '\\\\xc3\\\\x9a': 'Ú',\n '\\\\xc3\\\\x9b': 'Û',\n '\\\\xc3\\\\x9c': 'Ü',\n '\\\\xc3\\\\x9d': 'Ý',\n '\\\\xc3\\\\x9e': 'Þ',\n '\\\\xc3\\\\x9f': 'ß',\n '\\\\xc3\\\\xa0': 'à',\n '\\\\xc3\\\\xa1': 'á',\n '\\\\xc3\\\\xa2': 'â',\n '\\\\xc3\\\\xa3': 'ã',\n '\\\\xc3\\\\xa4': 'ä',\n '\\\\xc3\\\\xa5': 'å',\n '\\\\xc3\\\\xa6': 'æ',\n '\\\\xc3\\\\xa7': 'ç',\n '\\\\xc3\\\\xa8': 'è',\n '\\\\xc3\\\\xa9': 'é',\n '\\\\xc3\\\\xaa': 'ê',\n '\\\\xc3\\\\xab': 'ë',\n '\\\\xc3\\\\xac': 'ì',\n '\\\\xc3\\\\xad': 'í',\n '\\\\xc3\\\\xae': 'î',\n '\\\\xc3\\\\xaf': 'ï',\n '\\\\xc3\\\\xb0': 'ð',\n '\\\\xc3\\\\xb1': 'ñ',\n '\\\\xc3\\\\xb2': 'ò',\n '\\\\xc3\\\\xb3': 'ó',\n '\\\\xc3\\\\xb4': 'ô',\n '\\\\xc3\\\\xb5': 'õ',\n '\\\\xc3\\\\xb6': 'ö',\n '\\\\xc3\\\\xb7': '÷',\n '\\\\xc3\\\\xb8': 'ø',\n '\\\\xc3\\\\xb9': 'ù',\n '\\\\xc3\\\\xba': 'ú',\n '\\\\xc3\\\\xbb': 'û',\n '\\\\xc3\\\\xbc': 'ü',\n '\\\\xc3\\\\xbd': 'ý',\n '\\\\xc3\\\\xbe': 'þ',\n '\\\\xc3\\\\xbf': 'ÿ',\n}\n\n```"
}
] |
code_chaordic-graphql_29178478
|
[
{
"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 chaordic-graphql/node/index.ts from the chaordic-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { LRUCache, Service, ServiceContext } from '@vtex/api'\n\nimport { Clients } from './clients'\nimport { WithSecretKeys } from './directives/secretKeys'\nimport { mutations as recommendationMutations, queries as recommendationQueries } from './resolvers/recommendations'\nimport { queries as searchQueries, rootResolvers } from './resolvers/search'\n\nconst MEDIUM_TIMEOUT_MS = 2 * 1000\n\ndeclare global {\n interface SecretKeys {\n apiKey: string\n secretKey: string\n }\n\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>\n}\n\nconst vbaseCache = new LRUCache<string, any>({max: 10})\nmetrics.trackCache('vbase', vbaseCache)\n\n// Export a service that defines resolvers and clients' options\nexport default new Service<Clients>({\n clients: {\n implementation: Clients,\n options: {\n default: {\n timeout: MEDIUM_TIMEOUT_MS,\n },\n vbase: {\n memoryCache: vbaseCache,\n },\n },\n },\n graphql: {\n resolvers: {\n ...rootResolvers,\n Mutation: {\n ...recommendationMutations,\n },\n Query: {\n ...recommendationQueries,\n ...searchQueries,\n },\n },\n schemaDirectives: {\n withSecretKeys: WithSecretKeys,\n },\n },\n})\n\n```"
}
] |
code_chaordic-graphql_07888ff5
|
[
{
"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 chaordic-graphql/node/directives/secretKeys.ts from the chaordic-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { defaultFieldResolver, GraphQLField } from 'graphql'\nimport { SchemaDirectiveVisitor } from 'graphql-tools'\n\nexport class WithSecretKeys extends SchemaDirectiveVisitor {\n public visitFieldDefinition (field: GraphQLField<any, any>) {\n const {resolve = defaultFieldResolver} = field\n field.resolve = async (root: any, args: any, ctx: Context, info: any) => {\n const bucket = 'secret_keys'\n const filePath = 'keys.json'\n const secrets = await ctx.clients.vbase.getJSON<SecretKeys>(bucket, filePath)\n ctx.clients.search.init(secrets)\n ctx.clients.recommendation.init(secrets)\n return resolve(root, args, ctx, info)\n }\n }\n}\n\n```"
}
] |
code_chaordic-graphql_44034b1c
|
[
{
"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 chaordic-graphql/node/clients/search.ts from the chaordic-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {\n ExternalClient,\n InstanceOptions,\n IOContext,\n RequestConfig,\n} from '@vtex/api'\nimport { stringify } from 'qs'\n\nexport interface SearchParams {\n filter: string\n page: number\n resultsPerPage: number\n sortBy: string\n terms: string\n salesChannel?: string\n}\n\nexport interface AutocompleteParams {\n terms: string\n salesChannel?: string\n}\n\nexport interface NavigatesParams {\n resultsPerPage: number\n sortBy: string\n filter: string\n page: number\n productFormat: string\n fields: string\n category: string\n multicategory: string[]\n}\n\nconst treatedStatusCodes = [404, 302]\nconst treatedErrors = (e: any) => {\n if (\n e.response &&\n e.response.status &&\n treatedStatusCodes.includes(e.response.status)\n ) {\n return e.response.data\n }\n throw e\n}\n\nexport default class Search extends ExternalClient {\n public apiKey?: string\n public secretKey?: string\n\n constructor(context: IOContext, options?: InstanceOptions) {\n super(`http://api.linximpulse.com/engage/search/v3`, context, {\n ...options,\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n 'X-Vtex-Use-Https': 'true',\n },\n })\n }\n\n // This is initialized by the withSecretKeys directive\n public init(secretKeys: SecretKeys) {\n this.apiKey = secretKeys?.apiKey\n this.secretKey = decodeURIComponent(secretKeys?.secretKey)\n }\n\n public search(params: SearchParams): Promise<any> {\n return this.get(this.routes.search, { metric: 'chaordic-search', params })\n }\n\n public autocomplete(params: AutocompleteParams): Promise<any> {\n return this.get(this.routes.autocomplete, {\n metric: 'chaordic-autocomplete',\n params,\n })\n }\n\n public popular(): Promise<any> {\n return this.get(this.routes.popular, { metric: 'chaordic-popular' })\n }\n\n public navigates(params: NavigatesParams): Promise<any> {\n return this.get(this.routes.navigates, {\n metric: 'chaordic-navigates',\n params,\n })\n }\n\n private get routes() {\n return {\n autocomplete: '/autocompletes',\n popular: '/autocompletes/popular',\n search: '/search',\n navigates: '/navigates',\n }\n }\n\n private get(url: string, config?: RequestConfig) {\n const params = {\n ...config?.params,\n apiKey: this.apiKey,\n secretKey: this.secretKey,\n }\n\n return this.http\n .get(url, {\n ...config,\n params,\n paramsSerializer: oldParams =>\n stringify(oldParams, { arrayFormat: 'repeat' }),\n })\n .catch(treatedErrors)\n }\n}\n\n```"
}
] |
code_chaordic-graphql_73a860ac
|
[
{
"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 chaordic-graphql/node/clients/recommendation.ts from the chaordic-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {\n ExternalClient,\n InstanceOptions,\n IOContext,\n RequestConfig,\n} from '@vtex/api'\nimport { stringify } from 'qs'\n\nexport interface RecommendationParams {\n chaordicBrowserId?: string\n deviceId?: string\n name: string\n salesChannel?: string\n userId?: string\n pathName?: string\n category?: string[]\n productId: string\n productFormat?: string\n source: string\n showOnlyAvailable: boolean\n}\n\nexport interface ProductRecommendationParams {\n chaordicBrowserId?: string\n deviceId?: string\n salesChannel?: string\n productId: string\n size: number\n type: string\n}\n\nexport interface ImpressionParams {\n impressionUrl: string\n}\n\nconst treatedStatusCodes = [404, 302]\nconst treatedErrors = (e: any) => {\n if (\n e.response &&\n e.response.status &&\n treatedStatusCodes.includes(e.response.status)\n ) {\n return e.response.data\n }\n throw e\n}\n\nexport default class Recommendation extends ExternalClient {\n public apiKey?: string\n public secretKey?: string\n\n constructor(context: IOContext, options?: InstanceOptions) {\n super('http://recs.chaordicsystems.com/v0', context, {\n ...options,\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n 'x-vtex-use-https': 'true',\n },\n })\n }\n\n // This is initialized by the withSecretKeys directive\n public init(secretKeys: SecretKeys) {\n this.apiKey = secretKeys?.apiKey\n this.secretKey = decodeURIComponent(secretKeys?.secretKey)\n }\n\n public recommendations(params: RecommendationParams): Promise<any> {\n return this.get(this.routes.recommendations, {\n metric: 'chaordic-recommendations',\n params,\n })\n }\n\n public productRecommendations(\n params: ProductRecommendationParams\n ): Promise<any> {\n return this.get(this.routes.recommendations, {\n metric: 'chaordic-recommendations-product',\n params,\n })\n }\n\n public impression(impressionUrl: string): Promise<any> {\n return this.get(impressionUrl, {\n metric: 'chaordic-recommendations-impression',\n })\n }\n\n private get routes() {\n return {\n recommendations: '/pages/recommendations/',\n }\n }\n\n private get(url: string, config?: RequestConfig) {\n const params = {\n ...config?.params,\n apiKey: this.apiKey,\n secretKey: this.secretKey,\n }\n\n return this.http\n .get(url, {\n ...config,\n params,\n paramsSerializer: oldParams =>\n stringify(oldParams, { arrayFormat: 'repeat' }),\n })\n .catch(treatedErrors)\n }\n}\n\n```"
}
] |
code_chaordic-graphql_e79783bd
|
[
{
"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 chaordic-graphql/node/clients/index.ts from the chaordic-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\n\nimport Recommendation from './recommendation'\nimport Search from './search'\n\nexport class Clients extends IOClients {\n get recommendation() {\n return this.getOrSet('recommendation', Recommendation)\n }\n\n get search() {\n return this.getOrSet('search', Search)\n }\n}\n\n```"
}
] |
code_chaordic-graphql_c44666db
|
[
{
"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 chaordic-graphql/node/resolvers/search.ts from the chaordic-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { ResolverWarning } from '@vtex/api'\nimport { prop, sortBy } from 'ramda'\n\nimport {\n AutocompleteParams,\n SearchParams,\n NavigatesParams,\n} from '../clients/search'\nimport { utf8ToChar } from '../utf8'\nimport { formatSalesChannel, atob } from '../utils'\n\nexport const queries = {\n searchProducts: async (_: any, args: SearchParams, ctx: Context) => {\n const {\n clients: { search },\n } = ctx\n\n return search.search({\n ...args,\n salesChannel:\n args.salesChannel ??\n formatSalesChannel(JSON.parse(atob(ctx.vtex.segmentToken))),\n })\n },\n\n searchProductsAutoComplete: async (\n _: any,\n args: AutocompleteParams,\n ctx: Context\n ) => {\n const {\n clients: { search },\n } = ctx\n return search.autocomplete({\n ...args,\n salesChannel: formatSalesChannel(JSON.parse(atob(ctx.vtex.segmentToken))),\n })\n },\n\n searchProductsAutoCompletePopular: async (_: any, __: any, ctx: Context) => {\n const {\n clients: { search },\n } = ctx\n return search.popular()\n },\n\n searchProductsNavigates: async (\n _: any,\n args: NavigatesParams,\n ctx: Context\n ) => {\n const {\n clients: { search },\n } = ctx\n\n const { fields, category, multicategory } = args\n\n if (fields && (category || multicategory?.length)) {\n throw new Error(\n 'The field \"fields\" cannot be used together with the category or multicategory field'\n )\n /*\n * read more about this rule in the documentation: https://docs.linximpulse.com/v3-search/docs/navigate\n */\n }\n\n if (category && multicategory?.length) {\n throw new Error(\n 'The category and multicategory fields cannot be used together'\n )\n /*\n * read more about this rule in the documentation: https://docs.linximpulse.com/v3-search/docs/navigate\n */\n }\n\n return search.navigates(args)\n },\n}\n\nexport const rootResolvers = {\n ChaordicSearchFilters: {\n values: ({ values }: any) => values && sortBy(prop('id') as any, values),\n },\n ChaordicSearchProduct: {\n cacheId: ({ id, name }: any) => `${id} - ${name}`,\n productId: ({ id }: any) => id,\n },\n ChaordicSearchProductDetails: {\n clusterHighlights: ({ clusterHighlights }: any) => {\n let clusterHighlightsFormatted = []\n try {\n clusterHighlightsFormatted = clusterHighlights.map(\n (clusterHighlight: string) => {\n let clusterHighlightDecoded = clusterHighlight\n\n Object.keys(utf8ToChar).forEach((key: string) => {\n clusterHighlightDecoded = clusterHighlightDecoded.replace(\n new RegExp(key, 'g'),\n utf8ToChar[key]\n )\n })\n\n return {\n name: Object.values(\n JSON.parse(clusterHighlightDecoded.replace(/'/g, '\"'))\n )[0],\n }\n }\n )\n } catch (e) {\n throw new ResolverWarning(e)\n }\n\n return clusterHighlightsFormatted\n },\n },\n}\n\n```"
}
] |
code_chaordic-graphql_888a4ca6
|
[
{
"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 chaordic-graphql/node/resolvers/recommendations.ts from the chaordic-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {\n ImpressionParams,\n ProductRecommendationParams,\n RecommendationParams,\n} from '../clients/recommendation'\nimport { formatSalesChannel, atob } from '../utils'\n\nexport const queries = {\n chaordicProductPageRecommendations: async (\n _: any,\n args: ProductRecommendationParams,\n ctx: Context\n ) => {\n const {\n clients: { recommendation },\n } = ctx\n\n const { chaordicBrowserId, productId, type, size } = args\n\n const params = {\n deviceId: chaordicBrowserId,\n productFormat: 'complete',\n productId,\n salesChannel: formatSalesChannel(JSON.parse(atob(ctx.vtex.segmentToken))),\n size: size || 10,\n type: type || 'BestSellers',\n }\n\n ctx.set('cache-control', 'no-cache')\n\n return recommendation.productRecommendations(params)\n },\n\n chaordicRecommendations: async (\n _: any,\n args: RecommendationParams,\n ctx: Context\n ) => {\n const {\n clients: { recommendation },\n } = ctx\n const forwardedHost = ctx.get('x-forwarded-host')\n\n const {\n chaordicBrowserId,\n pathName,\n source,\n category,\n name,\n userId,\n productId,\n showOnlyAvailable,\n } = args\n\n const params = {\n category,\n deviceId: chaordicBrowserId,\n name: name || 'other',\n productFormat: 'complete',\n productId,\n salesChannel: formatSalesChannel(JSON.parse(atob(ctx.vtex.segmentToken))),\n showOnlyAvailable,\n source,\n url: `https://${forwardedHost}${pathName}`,\n userId,\n }\n\n ctx.set('cache-control', 'no-cache')\n\n return recommendation.recommendations(params)\n },\n}\n\nexport const mutations = {\n ChaordicImpression: async (_: any, args: ImpressionParams, ctx: Context) => {\n const {\n clients: { recommendation },\n } = ctx\n\n return recommendation\n .impression(args.impressionUrl)\n .then(() => true)\n .catch(() => false)\n },\n}\n\n```"
}
] |
code_product-group-context_6ca2e836
|
[
{
"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 product-group-context/docs/README.md from the product-group-context VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# product-group-context\n\nProvides the product group context to shelf child blocks.\n\n```"
}
] |
code_product-group-context_b05390af
|
[
{
"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 product-group-context/react/ProductGroupContext.tsx from the product-group-context VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useContext, useMemo, useState, useCallback } from 'react'\n\ninterface Context {\n items: Item[]\n addItemToGroup: (product: Product, item: SKU) => () => void\n}\n\nconst ProductGroupContext = React.createContext<Context | undefined>(undefined)\n\nexport const ProductGroupProvider: React.FC = ({ children }) => {\n const [itemMap, setItemMap] = useState<Record<string, Item>>({})\n\n const addItemToGroup = useCallback((product: Product, selectedItem: SKU) => {\n setItemMap(prevItemMap => ({\n ...prevItemMap,\n [selectedItem.itemId]: {\n product,\n selectedItem,\n quantity: prevItemMap[selectedItem.itemId]\n ? prevItemMap[selectedItem.itemId].quantity + 1\n : 1,\n },\n }))\n\n return function removeItemFromGroup() {\n setItemMap(({ [selectedItem.itemId]: item, ...prevMap }) =>\n item.quantity > 1\n ? {\n ...prevMap,\n [selectedItem.itemId]: {\n selectedItem: item.selectedItem,\n product: item.product,\n quantity: item.quantity - 1,\n },\n }\n : prevMap\n )\n }\n }, [])\n\n const contextValue = useMemo(\n () => ({\n items: Object.values(itemMap),\n addItemToGroup,\n }),\n [itemMap, addItemToGroup]\n )\n\n return (\n <ProductGroupContext.Provider value={contextValue}>\n {children}\n </ProductGroupContext.Provider>\n )\n}\n\nexport const useProductGroup = () => {\n return useContext(ProductGroupContext)\n}\n\nexport default { ProductGroupProvider, useProductGroup }\n\n```"
}
] |
code_product-group-context_52dc1b3f
|
[
{
"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 product-group-context/react/package.json from the product-group-context VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"product-group-context\",\n \"private\": true,\n \"license\": \"UNLICENSED\",\n \"devDependencies\": {\n \"@types/node\": \"^14.0.23\",\n \"@types/react\": \"^16.9.43\",\n \"@vtex/tsconfig\": \"^0.5.0\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.111.0/public/@types/vtex.render-runtime\"\n },\n \"dependencies\": {\n \"react\": \"^16.13.1\"\n },\n \"version\": \"0.2.0\"\n}\n\n```"
}
] |
code_product-group-context_3eb737a2
|
[
{
"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 product-group-context/react/typings/global.d.ts from the product-group-context VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface CommertialOffer {\n AvailableQuantity: number\n Installments: Installment[]\n ListPrice: number\n Price: number\n PriceWithoutDiscount: number\n Tax: number\n taxPercentage: number\n}\n\ninterface Installment {\n InterestRate: number\n Name: string\n NumberOfInstallments: number\n TotalValuePlusInterestRate: number\n Value: number\n}\n\ninterface Seller {\n addToCartLink: string\n commertialOffer: CommertialOffer\n sellerId: string\n sellerDefault: boolean\n sellerName: string\n}\n\ninterface Image {\n imageTag: string\n imageText: string\n imageUrl: string\n}\n\ninterface SKU {\n ean: string\n image: Image\n images: Image[]\n itemId: string\n measurementUnit: string\n name: string\n nameComplete: string\n seller: Seller\n sellers: Seller[]\n}\n\ninterface PriceRange {\n highPrice: number\n lowPrice: number\n}\n\ninterface ProductPriceRange {\n listPrice: PriceRange\n sellingPrice: PriceRange\n}\n\ninterface Product {\n brand: string\n brandId: number\n cacheId: string\n categories: string[]\n items: SKU[]\n link: string\n linkText: string\n priceRange: ProductPriceRange\n productId: string\n productName: string\n productReference: string\n sku?: SKU\n specificationGroups: any[]\n}\n\ninterface Item {\n product: Product\n selectedItem: SKU\n quantity: number\n}\n\n```"
}
] |
code_search_479e5ebf
|
[
{
"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/messages/hu.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/topSearches\": \"Legnépszerűbb keresések\",\n \"store/history\": \"Keresési előzmények\",\n \"store/suggestions\": \"Javaslatok\",\n \"store/emptySuggestion\": \"Nincsenek javaslatok\",\n \"store/seeMore\": \"Az összes {count} termék megtekintése\",\n \"store/suggestedProducts\": \"Termékek a következőhöz: {term}\",\n \"store/ordinalNumber\": \".\",\n \"store/didYouMean\": \"Úgy értetted\",\n \"store/searchSuggestions\": \"Javaslat\"\n}\n\n```"
}
] |
code_search_b9c8bc3a
|
[
{
"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/messages/pt.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/topSearches\": \"Termos mais buscados\",\n \"store/history\": \"Histórico de buscas\",\n \"store/suggestions\": \"Sugestões\",\n \"store/emptySuggestion\": \"Sem Sugestões\",\n \"store/seeMore\": \"Veja todos os {count} produtos\",\n \"store/suggestedProducts\": \"Produtos para {term}\",\n \"store/ordinalNumber\": \"º\",\n \"store/didYouMean\": \"Você quis dizer\",\n \"store/searchSuggestions\": \"Sugestões\"\n}\n\n```"
}
] |
code_search_d7198b10
|
[
{
"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/messages/en.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/topSearches\": \"Top Searches\",\n \"store/history\": \"Search History\",\n \"store/suggestions\": \"Suggestions\",\n \"store/emptySuggestion\": \"No Suggestions\",\n \"store/seeMore\": \"See all {count} products\",\n \"store/suggestedProducts\": \"Products for {term}\",\n \"store/ordinalNumber\": \".\",\n \"store/didYouMean\": \"Did you mean\",\n \"store/searchSuggestions\": \"Suggestions\"\n}\n\n```"
}
] |
code_search_6f6401b8
|
[
{
"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/messages/it.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/topSearches\": \"Ricerche più frequenti\",\n \"store/history\": \"Cronologia di ricerca\",\n \"store/suggestions\": \"Suggerimenti\",\n \"store/emptySuggestion\": \"Nessun suggerimento\",\n \"store/seeMore\": \"Visualizza tutti i {count} prodotti\",\n \"store/suggestedProducts\": \"Prodotti per {term}\",\n \"store/ordinalNumber\": \".\",\n \"store/didYouMean\": \"Intendevi\",\n \"store/searchSuggestions\": \"Suggerimenti\"\n}\n\n```"
}
] |
code_search_4cb2510f
|
[
{
"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/messages/fr.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/topSearches\": \"Recherches fréquentes\",\n \"store/history\": \"Historique de recherche\",\n \"store/suggestions\": \"Suggestions\",\n \"store/emptySuggestion\": \"Aucune suggestion\",\n \"store/seeMore\": \"Voir les {count} produits\",\n \"store/suggestedProducts\": \"Produits pour {term}\",\n \"store/ordinalNumber\": \".\",\n \"store/didYouMean\": \"Vouliez-vous dire\",\n \"store/searchSuggestions\": \"Suggestions\"\n}\n\n```"
}
] |
code_search_12799bb6
|
[
{
"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/messages/ro.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/topSearches\": \"Căutări populare\",\n \"store/history\": \"Istoric căutări\",\n \"store/suggestions\": \"Sugestii\",\n \"store/emptySuggestion\": \"Fără sugestii\",\n \"store/seeMore\": \"Vezi toate cele {count} produse\",\n \"store/suggestedProducts\": \"Produse pentru {term}\",\n \"store/ordinalNumber\": \".\",\n \"store/didYouMean\": \"Vrei să spui\",\n \"store/searchSuggestions\": \"Sugestii\"\n}\n\n```"
}
] |
code_search_f0388c29
|
[
{
"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/messages/context.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/topSearches\": \"topSearches\",\n \"store/history\": \"history\",\n \"store/suggestions\": \"suggestions\",\n \"store/emptySuggestion\": \"emptySuggestion\",\n \"store/seeMore\": \"seeMore\",\n \"store/suggestedProducts\": \"suggestedProducts\",\n \"store/ordinalNumber\": \"ordinalNumber\",\n \"store/didYouMean\": \"didYouMean\",\n \"store/searchSuggestions\": \"searchSuggestions\"\n}\n\n```"
}
] |
code_search_0fb2cd3d
|
[
{
"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/messages/id.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/topSearches\": \"Pencarian Teratas\",\n \"store/history\": \"Riwayat Pencarian\",\n \"store/suggestions\": \"Saran\",\n \"store/emptySuggestion\": \"Tidak Ada Saran\",\n \"store/seeMore\": \"Lihat semua {count} produk\",\n \"store/suggestedProducts\": \"Produk untuk {term}\",\n \"store/ordinalNumber\": \".\",\n \"store/didYouMean\": \"Mungkin maksud Anda\",\n \"store/searchSuggestions\": \"Saran\"\n}\n\n```"
}
] |
code_search_bce8efa4
|
[
{
"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/messages/no.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/topSearches\": \"Populære søk\",\n \"store/history\": \"Søkehistorikk\",\n \"store/suggestions\": \"Forslag\",\n \"store/emptySuggestion\": \"Ingen forslag\",\n \"store/seeMore\": \"Se alle {count} produkter\",\n \"store/suggestedProducts\": \"Produkter for {term}\",\n \"store/ordinalNumber\": \".\",\n \"store/didYouMean\": \"Mente du\",\n \"store/searchSuggestions\": \"Forslag\"\n}\n\n```"
}
] |
code_search_eeff4ff7
|
[
{
"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/messages/th.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/topSearches\": \"การค้นหายอดนิยม\",\n \"store/history\": \"ประวัติการค้นหา\",\n \"store/suggestions\": \"คำแนะนำ\",\n \"store/emptySuggestion\": \"ไม่มีคำแนะนำ\",\n \"store/seeMore\": \"ดูผลิตภัณฑ์ทั้ง {count} รายการ\",\n \"store/suggestedProducts\": \"ผลิตภัณฑ์สำหรับ {term}\",\n \"store/ordinalNumber\": \".\",\n \"store/didYouMean\": \"คุณหมายถึง... ใช่หรือไม่\",\n \"store/searchSuggestions\": \"คำแนะนำ\"\n}\n\n```"
}
] |
code_search_58cf4f98
|
[
{
"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/messages/nn.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/topSearches\": \"Populære søk\",\n \"store/history\": \"Søkehistorikk\",\n \"store/suggestions\": \"Forslag\",\n \"store/emptySuggestion\": \"Ingen forslag\",\n \"store/seeMore\": \"Se alle {count} produkter\",\n \"store/suggestedProducts\": \"Produkter for {term}\",\n \"store/ordinalNumber\": \".\",\n \"store/didYouMean\": \"Mente du\",\n \"store/searchSuggestions\": \"Forslag\"\n}\n\n```"
}
] |
code_search_a6bb164d
|
[
{
"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/messages/es.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/topSearches\": \"Términos más buscados\",\n \"store/history\": \"Últimas búsquedas\",\n \"store/suggestions\": \"Sugerencias\",\n \"store/emptySuggestion\": \"Sin Sugerencias\",\n \"store/seeMore\": \"Ver todos los {count} productos\",\n \"store/suggestedProducts\": \"Productos para {term}\",\n \"store/ordinalNumber\": \".\",\n \"store/didYouMean\": \"Querías decir\",\n \"store/searchSuggestions\": \"Sugerencias\"\n}\n\n```"
}
] |
code_search_ade4ca15
|
[
{
"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/messages/ar.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/topSearches\": \"اكثر ماتم البحث عنه\",\n \"store/history\": \"سجل البحث\",\n \"store/suggestions\": \"الإقتراحات\",\n \"store/emptySuggestion\": \"لا توجد اقتراحات\",\n \"store/seeMore\": \"مشاهدة جميع المنتجات {count}\",\n \"store/suggestedProducts\": \"المنتجات لـ {term}\",\n \"store/ordinalNumber\": \".\",\n \"store/didYouMean\": \"هل تعني\",\n \"store/searchSuggestions\": \"الإقتراحات\"\n}\n\n```"
}
] |
code_search_3c611c84
|
[
{
"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/docs/README.md from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/vtex-apps/search) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# Search\n\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n\n[](#contributors-)\n\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\nThe VTEX Search app handles the new [**Intelligent Search**](https://help.vtex.com/tracks/vtex-intelligent-search) solution in IO stores by providing new UI components to enhance the search experience, such as the autocomplete feature.\n\n\n\n## Configuration\n\nThe Search app requires the `vtex.admin-search@1.x` and `vtex.search-resolver@1.x` apps to be installed in your store. For more information, read the [Intelligent Search](https://help.vtex.com/tracks/vtex-intelligent-search) documentation.\n\nTo configure the Search app, see the sections below.\n\n### Adding the Search app to your theme dependencies\n\nAdd the `search` app to your theme dependencies in the `manifest.json` as shown below:\n\n```json\n \"dependencies\": {\n \"vtex.search\": \"2.x\"\n }\n```\n\nYou can now use all blocks exported by the `search` app. See the full list below:\n\n| Block name | Description |\n| - | - |\n| `autocomplete-result-list.v2` | Provides customized autocomplete features in the search bar component, such as top searches, search history, product suggestions, or term suggestions. You can read more about the Intelligent Search [autocomplete feature](https://help.vtex.com/en/tracks/vtex-intelligent-search--19wrbB7nEQcmwzDPl1l4Cb/4gXFsEWjF7QF7UtI2GAvhL) in the VTEX Help Center. |\n| `search-banner` | Renders a customized banner based on the search query. |\n| `did-you-mean` | Helps users with possible misspelling corrections for the current search query. |\n| `search-suggestions` | Renders a list of similar search terms for the current search. |\n\n> ℹ️ The `search-banner`, `did-you-mean`, and `search-suggestions` blocks require [Search Result app](https://developers.vtex.com/docs/apps/vtex.search-result) version `3.x` or higher installed in your theme.\n\n### Adding Search blocks to the theme\n\nFirst, declare the `autocomplete-result-list.v2` block as a child block of the [`search-bar` block](https://developers.vtex.com/docs/apps/vtex.store-components/searchbar), exported by the Store Components app. Example:\n\n```json\n{\n \"search-bar\": {\n \"blocks\": [\"autocomplete-result-list.v2\"],\n \"props\": {\n \"openAutocompleteOnFocus\": true\n }\n }\n}\n```\n\n#### `autocomplete-result-list.v2` props\n\n| Prop name | Type | Description | Default value |\n| - | - | - | - |\n| `maxTopSearches` | `number` | Maximum number of items in the top searches list. | `10` |\n| `maxHistory` | `number` | Maximum number of items in the search history. | `5` |\n| `maxSuggestedProducts` | `number` | Maximum number of items in the suggested products list. | `3` |\n| `maxSuggestedTerms` | `number` | Maximum number of items in the suggested terms list. | `3` |\n| `autocompleteWidth` | `number` | Autocomplete list width (percentage). This value must be between `0` and `100`. | `undefined` |\n| `productLayout` | `enum` | Determines the layout the suggested products list will have when rendered. Possible values are `HORIZONTAL` and `VERTICAL`. | `undefined` | \n| `hideTitles` | `boolean` | Determines whether all component titles will be hidden when rendered (`true`) or not (`false`). | `false` |\n| `hideUnavailableItems` | `boolean` | Determines whether autocomplete should hide unavailable items (`true`) or not (`false`). This prop only hides items that are unavailable according to indexed information, without taking into account `simulationBehavior`. | `false` |\n| `historyFirst` | `boolean` | Determines whether the search history list should be prioritized over the other lists (`true`) or not (`false`). | `false` |\n| `customBreakpoints` | `object` | Determines the maximum number of recommended products per breakpoints. Possible values are `md`, `lg`, or `xlg`. | - |\n| `simulationBehavior` | `\"skip\"` or `\"default\"` | If you want faster searches and are not so concern about having the most up-to-date prices and promotions, use `\"skip\"`. | `default` |\n| `HorizontalProductSummary` | `product-summary` block | By default, the mobile autocomplete uses the `CustomListItem` component to render the suggested products using a horizontal layout. But sending a `product-summary` block here will render your customized Product Summary component. Read our documentation to learn [how to build a horizontal Product Summary](https://developers.vtex.com/docs/guides/vtex-io-documentation-building-a-horizontal-product-summary) component. | `undefined` |\n\n##### The `customBreakpoints` object\n\n| Prop name | Type | Description | Default value |\n| --------- | -------- | ---------------------------------------------------------------------------- | ------------- |\n| `md` | `object` | Defines the maximum number of recommended products for the `md` breakpoint. | `undefined` |\n| `lg` | `object` | Defines the maximum number of recommended products for the `lg` breakpoint. | `undefined` |\n| `xlg` | `object` | Defines the maximum number of recommended products for the `xlg` breakpoint. | `undefined` |\n\n##### The `md`, `lg`, and `xlg` objects\n\n| Prop name | Type | Description | Default value |\n| ---------------------- | -------- | ------------------------------------- | ------------- |\n| `width` | `number` | Breakpoint minimum width. | `undefined` |\n| `maxSuggestedProducts` | `number` | Maximum number of suggested products. | `undefined` |\n\nThe `autocomplete-result-list.v2` block also allows you to add a list of child blocks to it. You can declare a theme block and have it rendered among the autocomplete features. Example:\n\n```json\n{\n \"autocomplete-result-list.v2\": {\n \"blocks\": [\"product-summary\"]\n }\n}\n```\n\nNow, you can add the last three search blocks: `search-banner`, `did-you-mean`, and `search-suggestions`.\n\nThese blocks, as opposed to `autocomplete-result-list.v2`, need to be added under the `search-result-layout.desktop` or the `search-result-layout.mobile` blocks, following the Search Results block hierarchy.\n\nOnce added, the blocks can be declared using their respective props for configuration. Example:\n\n```json\n{\n \"search-result-layout.desktop\": {\n \"children\": [\n \"flex-layout.row#did-you-mean\",\n \"flex-layout.row#suggestion\",\n \"flex-layout.row#banner-one\",\n \"flex-layout.row#result\"\n ],\n \"props\": {\n \"pagination\": \"show-more\",\n \"preventRouteChange\": true,\n \"mobileLayout\": {\n \"mode1\": \"small\",\n \"mode2\": \"normal\"\n }\n }\n },\n\n \"flex-layout.row#did-you-mean\": {\n \"children\": [\"did-you-mean\"]\n },\n \"flex-layout.row#suggestion\": {\n \"children\": [\"search-suggestions\"]\n },\n \"flex-layout.row#banner-one\": {\n \"children\": [\"search-banner#one\"]\n },\n\n \"search-banner#one\": {\n \"props\": {\n \"area\": \"one\",\n \"blockClass\": \"myBanner\",\n \"horizontalAlignment\": \"center\"\n }\n }\n}\n```\n\n#### `search-banner` props\n\n| Prop name | Type | Description | Default value |\n| - | - | - | - |\n| `area` | `string` | Area where the banner will be displayed in the store. This needs to match the predefined area value in the banner configuration. | `undefined` |\n| `blockClass` | `string` | Unique block ID to be used in [CSS customizations](https://developers.vtex.com/docs/guides/vtex-io-documentation-using-css-handles-for-store-customization). | `undefined` |\n| `horizontalAlignment` | `string` | Defines the horizontal alignment of the banner. Possible values are `left`, `center`, or `right`. | `center` |\n\n### Catalog integration\n\nAfter installing the app, you need to integrate it with your store's catalog. Go to **Store Settings > Intelligent Search > Integrations** in the VTEX Admin and click **Start integration** to set up the initial indexing of the catalog with Intelligent Search. Learn more about this process at [Setting up Intelligent Search integration with the Catalog](https://help.vtex.com/en/tutorial/setting-up-intelligent-search-integration-with-the-catalog--3Nt5cIdwISSlzVtnYfLeIH).\n\n\n\nAfterwards, you can follow the indexing status of products on the [Indexing History](https://help.vtex.com/en/tracks/vtex-intelligent-search--19wrbB7nEQcmwzDPl1l4Cb/4flMwTaQL8FRKl1YT58ezH) page.\n\n## App behavior: Improving search experience\n\nTo improve the user's search experience in stores where the Intelligent Search engine is supported, the app have the following options:\n\n- **Stores using Universal Analytics (UA)**:\n \n The Search app provides blocks that, when rendered as components, will improve the user's search experience in stores where the Intelligent Search engine is supported.\n\n These components use `_q` as the query-string for the search term, meaning that if you want to track user searches in these components, you will need to add the `_q` query-string to the store's Google Analytics. To activate this behavior, refer to [Set up Site Search](https://support.google.com/analytics/answer/1012264?hl=en#zippy=%2Cin-this-article) Google's documentation.\n\n >❗ Please note that although the Search app's blocks enhance the search experience in VTEX stores, this feature is only compatible with VTEX stores using UA. As UA will be discontinued on July 1st, 2023, **we highly recommend that you update your store to GA4**. For more information on the migration, see the [release notes](https://developers.vtex.com/updates/release-notes/2023-05-04-google-tag-manager-new-version) and follow the option below.\n\n- **Store using Google Analytics 4 (GA4)**:\n \n Install the VTEX Google Tag Manager app, which includes the `search` event within the app's data layer. This app is responsible for tracking the user's search activity. For instructions on setting up Google Tag Manager, consult the [Setting up Google Tag Manager](https://developers.vtex.com/docs/guides/vtex-io-documentation-setting-up-google-tag-manager) documentation.\n\n## Customization\n\nIn order to apply CSS customizations to this and other blocks, follow the instructions given in the recipe on [Using CSS handles for store customizations](https://developers.vtex.com/docs/guides/vtex-io-documentation-using-css-handles-for-store-customization).\n\n| CSS handles |\n| --------------------- |\n| `searchBanner` |\n| `didYouMeanPrefix` |\n| `didYouMeanTerm` |\n| `suggestionsList` |\n| `suggestionsListItem` |\n| `suggestionsListLink` |\n| `itemListSubItemLink` |\n| `itemListLink` |\n| `itemListLinkTitle` |\n\n<!-- DOCS-IGNORE:start -->\n\n## Contributors ✨\n\nThanks goes out 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_search_e7d3d754
|
[
{
"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/node/package.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"node\",\n \"version\": \"1.4.1\",\n \"description\": \"\",\n \"main\": \"index.ts\",\n \"dependencies\": {\n \"@vtex/api\": \"^3.55.0\",\n \"atob\": \"^2.1.2\",\n \"graphql\": \"^14.5.8\",\n \"graphql-tools\": \"^4.0.6\",\n \"ramda\": \"^0.26.1\"\n },\n \"devDependencies\": {\n \"@types/atob\": \"^2.1.2\",\n \"@types/graphql\": \"^14.5.0\",\n \"@types/ramda\": \"types/npm-ramda#dist\",\n \"prettier\": \"^1.18.2\",\n \"tslint\": \"^5.18.0\",\n \"tslint-config-airbnb\": \"^5.11.2\",\n \"tslint-config-prettier\": \"^1.18.0\",\n \"typescript\": \"3.8.3\"\n },\n \"scripts\": {\n \"lint\": \"tslint './**/*.ts' -e './node_modules/**/*'\"\n },\n \"author\": \"\",\n \"license\": \"MIT\"\n}\n\n```"
}
] |
code_search_f2e2a523
|
[
{
"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/Suggestions.js from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport Suggestions from './components/Suggestions'\n\nexport default Suggestions\n\n```"
}
] |
code_search_e2175f0a
|
[
{
"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/DidYouMean.js from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport DidYouMean from './components/DidYouMean'\n\nexport default DidYouMean\n\n```"
}
] |
code_search_ceeba41f
|
[
{
"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/Autocomplete.js from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport Autocomplete from './components/Autocomplete/index'\n\nexport default Autocomplete\n\n```"
}
] |
code_search_3de79951
|
[
{
"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/package.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"react\",\n \"version\": \"2.18.8\",\n \"private\": true,\n \"dependencies\": {\n \"@apollo/react-hooks\": \"^3.1.5\",\n \"@vtex/css-handles\": \"^1.1.3\",\n \"apollo-client\": \"2.4.12\",\n \"axios\": \"^0.19.0\",\n \"classnames\": \"^2.2.6\",\n \"debounce\": \"^1.2.0\",\n \"exenv\": \"^1.2.2\",\n \"graphql\": \"14.1.1\",\n \"prop-types\": \"^15.7.2\",\n \"ramda\": \"^0.26.1\",\n \"react\": \"^16.8.6\",\n \"react-apollo\": \"^3.x\",\n \"react-dom\": \"^16.8.6\",\n \"react-intl\": \"^3.9.2\",\n \"unescape\": \"^1.0.1\"\n },\n \"devDependencies\": {\n \"@types/jest\": \"24.0.15\",\n \"@types/node\": \"12.6.8\",\n \"@types/pubsub-js\": \"^1.5.18\",\n \"@types/ramda\": \"^0.26.38\",\n \"@types/react\": \"16.8.23\",\n \"@types/react-dom\": \"16.8.4\",\n \"@types/superagent\": \"^4.1.3\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"eslint\": \"^6.5.1\",\n \"husky\": \"^3.0.9\",\n \"lint-staged\": \"^9.4.3\",\n \"prettier\": \"^2.2.1\",\n \"typescript\": \"3.9.7\"\n },\n \"scripts\": {\n \"lint\": \"eslint . && tslint './**/*.ts' -e './node_modules/**/*'\"\n },\n \"husky\": {\n \"hooks\": {\n \"pre-commit\": \"lint-staged\"\n }\n },\n \"lint-staged\": {\n \"*.{js,ts,jsx,tsx,md,json}\": [\n \"prettier --write\",\n \"git add\"\n ]\n },\n \"browserslist\": {\n \"production\": [\n \">0.2%\",\n \"not dead\",\n \"not op_mini all\"\n ],\n \"development\": [\n \"last 1 chrome version\",\n \"last 1 firefox version\",\n \"last 1 safari version\"\n ]\n }\n}\n\n```"
}
] |
code_search_a5ec6b7f
|
[
{
"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/tslint.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"defaultSeverity\": \"error\",\n \"extends\": [\"tslint-config-airbnb\", \"tslint-config-prettier\"],\n \"jsRules\": {},\n \"rules\": {\n \"import-name\": false\n },\n \"linterOptions\": {\n \"exclude\": [\"node_modules\"]\n }\n}\n\n```"
}
] |
code_search_89d79b53
|
[
{
"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/Banner.js from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport Banner from './components/Banner'\n\nexport default Banner\n\n```"
}
] |
code_search_16ca1675
|
[
{
"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/index.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport BiggyClient from './utils/biggy-client'\n\nexport default {\n BiggyClient,\n}\n\n```"
}
] |
code_search_9ecaea41
|
[
{
"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/store/interfaces.json from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"autocomplete-result-list.v2\": {\n \"component\": \"Autocomplete\",\n \"required\": [\"product-summary\"]\n },\n \"did-you-mean\": {\n \"component\": \"DidYouMean\"\n },\n \"search-suggestions\": {\n \"component\": \"Suggestions\"\n },\n \"search-banner\": {\n \"component\": \"Banner\"\n }\n}\n\n```"
}
] |
code_search_b20ce2cb
|
[
{
"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/typings/vtex.product-price.d.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.product-price' {\n export const ListPrice\n export const SellingPrice\n}\n\n```"
}
] |
code_search_f3487cba
|
[
{
"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/typings/vtex.css-handles.d.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.css-handles' {\n export const useCssHandles\n}\n\n```"
}
] |
code_search_423b7150
|
[
{
"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/typings/vtex.store-components.d.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport React from 'react'\n\ndeclare module 'vtex.store-components/ProductPrice' {\n export const ProductPrice: React.Component<{ sellingPrice: number }>\n}\n\n```"
}
] |
code_search_680c256b
|
[
{
"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/typings/vtex.product-context.d.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.product-context' {\n export const ProductContextProvider\n}\n\n```"
}
] |
code_search_e3adca26
|
[
{
"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/typings/debounce.d.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'debounce' {\n export default function (fn: () => void, delayms: number): () => void\n}\n\n```"
}
] |
code_search_6d2e66e8
|
[
{
"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/typings/vtex.render-runtime.d.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* Typings for `render-runtime` */\n// tslint:disable:variable-name\ndeclare module 'vtex.render-runtime' {\n import { Component, ComponentType, ReactElement, ReactType } from 'react'\n\n export { Helmet } from 'react-helmet'\n\n export interface NavigationOptions {\n to: string\n page?: string\n params?: any\n query?: string\n }\n\n export interface RenderContextProps {\n runtime: {\n navigate: (options: NavigationOptions) => void\n }\n }\n\n interface ExtensionPointProps {\n id: string\n [key: string]: any\n }\n\n export const ExtensionPoint: ComponentType<ExtensionPointProps>\n\n interface ChildBlockProps {\n id: string\n }\n\n export const ChildBlock: ComponentType<ChildBlockProps>\n export const useChildBlock = function ({ id: string }): object {}\n\n export const Link: ReactType\n export const NoSSR: ReactElement\n export const RenderContextConsumer: ReactElement\n export const canUseDOM: boolean\n export const withRuntimeContext: <TOriginalProps extends {}>(\n Component: ComponentType<TOriginalProps & RenderContextProps>\n ) => ComponentType<TOriginalProps>\n\n export const useRuntime: () => {\n account: string\n navigate: (options: NavigationOptions) => void\n }\n}\n\n```"
}
] |
code_search_ded6e7d5
|
[
{
"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/typings/gql.d.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.gql' {\n const content: any\n export default content\n}\n\n```"
}
] |
code_search_df4cb1a5
|
[
{
"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/typings/unescape.d.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* Typings for unescape */\ndeclare module 'unescape' {\n export default function (codedString: string): string\n}\n\n```"
}
] |
code_search_18bf9899
|
[
{
"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/typings/styles.css.d.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const content: any\n export default content\n}\n\n```"
}
] |
code_search_097f2603
|
[
{
"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/typings/global.d.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare global {\n interface Product {\n brand: string\n brandId: number\n cacheId: string\n categories?: string[]\n clusterHighlights?: Array<{ id: string; name: string }>\n categoryTree?: Array<{ slug: string }>\n description?: string | null\n items: SKU[]\n link: string\n linkText: string\n priceRange: ProductPriceRange\n productClusters?: Array<{ id: string; name: string }>\n productId: string\n productName: string\n productReference: string\n properties?: Array<{ name: string; values: string[] }>\n sku?: SKU\n specificationGroups: SpecificationGroup[]\n }\n\n interface ProductPriceRange {\n sellingPrice: PriceRange\n listPrice: PriceRange\n }\n\n interface PriceRange {\n highPrice: number\n lowPrice: number\n }\n\n interface SpecificationGroup {\n name?: string\n originalName?: string\n specifications?: SpecificationGroupProperty[]\n }\n\n interface SpecificationGroupProperty {\n originalName: string\n name: string\n values: string[]\n }\n\n interface SKU {\n complementName?: string\n ean?: string\n image?: Image\n images: Image[]\n itemId: string\n measurementUnit: string | null\n name: string\n nameComplete?: string\n referenceId: Array<{\n Key: string\n Value: string\n }> | null\n seller?: Seller\n sellers: Seller[]\n unitMultiplier?: number\n variations: Array<{ name: string; values: string[] }>\n }\n\n interface Image {\n cacheId?: string\n imageId?: string\n imageLabel: string | null\n imageTag?: string\n imageUrl: string\n imageText?: string | null\n }\n\n interface Seller {\n addToCartLink?: string\n commertialOffer: CommertialOffer\n sellerId: string\n sellerDefault?: boolean\n sellerName?: string\n }\n\n interface CommertialOffer {\n AvailableQuantity: number\n Installments: Installment[]\n ListPrice: number\n Price: number\n PriceWithoutDiscount: number\n RewardValue?: number\n Tax: number\n discountHighlights?: Array<{ name: string }>\n spotPrice?: number\n taxPercentage: number\n teasers?: Array<{ name: string }>\n }\n\n interface Installment {\n InterestRate: number\n Name: string\n NumberOfInstallments: number\n PaymentSystemName?: string\n TotalValuePlusInterestRate: number\n Value: number\n }\n\n interface AdvertisementOptions {\n showSponsored?: boolean\n sponsoredCount?: number\n repeatSponsoredProducts?: boolean\n advertisementPlacement?: string\n }\n}\n\nexport {}\n\n```"
}
] |
code_search_34381a0b
|
[
{
"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/typings/css.d.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const styles: { [key: string]: string }\n\n export default styles\n}\n\n```"
}
] |
code_search_d726014b
|
[
{
"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/typings/vtex.product-summary.d.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.product-summary/ProductSummaryCustom' {\n export const mapCatalogProductToProductSummary: (product: any) => any\n}\n\n```"
}
] |
code_search_11651ff0
|
[
{
"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/typings/vtex.styleguide.d.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide' {\n export const IconClock\n export const IconClose\n export const Spinner\n}\n\n```"
}
] |
code_search_db714493
|
[
{
"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/compatibility-layer.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport unescape from 'unescape'\n\n/*\n * Functions designed to provide compatibility between our search components\n * and store-components components.\n */\n\nfunction textOverflow(text: string, maxWidth: number) {\n return text.length > maxWidth ? `${text.substr(0, maxWidth - 3)}...` : text\n}\n\ntype UpdateQuery = (prev: any, options: { fetchMoreResult: any }) => void\ntype FetchMoreOptions = {\n variables: { to: number; page?: number }\n updateQuery: UpdateQuery\n}\ntype FetchMore = (options: FetchMoreOptions) => Promise<any>\ntype RefetchVariables = {\n from: number\n to: number\n count: number\n page: number\n}\ntype Refetch = (options: Partial<RefetchVariables>) => Promise<any>\n\n/**\n * Our Query depends on a `page` variable, but store-components' SearchContext\n * works with `from` and `to` variables. This methods provides a layer when\n * fetchMore is called to transform `to` into `page`.\n *\n * @param fetchMore Apollo's fetchMore function for our query.\n */\nexport const makeFetchMore = (\n fetchMore: FetchMore,\n page: number,\n setPage: (func: (page: number) => number) => number\n): FetchMore => async ({ variables, updateQuery = () => {} }) => {\n const newPage = page + 1\n\n await fetchMore({\n updateQuery: makeUpdateQuery(newPage),\n variables: { ...variables, page: newPage },\n })\n\n setPage((page: number) => page + 1)\n\n return updateQuery(\n { productSearch: { products: [] } },\n {\n fetchMoreResult: {\n productSearch: { products: [] },\n },\n }\n )\n}\n\n/**\n * Our Query depends on a `page` variable, but store-components' SearchContext\n * works with `from` and `to` variables. This methods provides a layer when\n * refetch is called to transform `from` and `to` into `page` and `count`.\n *\n * @param refetch Apollo's refetch function for our query.\n */\nexport const makeRefetch = (refetch: Refetch): Refetch => async variables => {\n const { from, to } = variables\n const hasPagination = typeof from !== 'undefined' && typeof to !== 'undefined'\n\n const count = hasPagination ? to! - from! + 1 : undefined\n const page = hasPagination ? Math.round((to! + 1) / (to! - from!)) : undefined\n\n return await refetch({ from, to, page, count })\n}\n\n/**\n * UpdateQuery factory for our own query.\n *\n * @param page Page to search for.\n */\nconst makeUpdateQuery: (page: number) => UpdateQuery = page => (\n prev,\n { fetchMoreResult }\n) => {\n if (!fetchMoreResult || page === 1) return prev\n\n return {\n ...fetchMoreResult,\n searchResult: {\n ...fetchMoreResult.searchResult,\n products: [\n ...prev.searchResult.products,\n ...fetchMoreResult.searchResult.products,\n ],\n },\n }\n}\n\n/**\n * Convert Biggy attributes into VTEX Catalog facets.\n *\n * @export\n * @param {*} attribute A searchResult attribute.\n * @returns A Catalog facet.\n */\nexport function fromAttributesToFacets(attribute: any) {\n if (attribute.type === 'number') {\n return {\n map: 'priceRange',\n name: attribute.label,\n slug: `de-${attribute.minValue}-a-${attribute.maxValue}`,\n }\n }\n\n return {\n name: attribute.label,\n facets: attribute.values.map((value: any) => {\n return {\n quantity: value.count,\n name: unescape(textOverflow(value.label, 40)),\n link: value.proxyUrl,\n linkEncoded: value.proxyUrl,\n map: attribute.key,\n selected: value.active,\n value: `z${value.key}`,\n }\n }),\n }\n}\n\ntype OrderBy =\n | 'OrderByPriceDESC'\n | 'OrderByPriceASC'\n | 'OrderByTopSaleDESC'\n | 'OrderByReviewRateDESC'\n | 'OrderByNameDESC'\n | 'OrderByNameASC'\n | 'OrderByReleaseDateDESC'\n | 'OrderByBestDiscountDESC'\n\n/**\n * Convert from VTEX OrderBy into Biggy's sort.\n *\n * @export\n * @param {OrderBy} orderBy VTEX OrderBy.\n * @returns {string} Biggy's sort.\n */\nexport function convertOrderBy(orderBy: OrderBy): string {\n switch (orderBy) {\n case 'OrderByPriceDESC':\n return 'price:desc'\n\n case 'OrderByPriceASC':\n return 'price:asc'\n\n case 'OrderByTopSaleDESC':\n return 'orders:desc'\n\n case 'OrderByReviewRateDESC':\n return '' // TODO: Not Supported\n\n case 'OrderByNameDESC':\n return 'name:desc'\n\n case 'OrderByNameASC':\n return 'name:asc'\n\n case 'OrderByReleaseDateDESC':\n return 'fields.release:desc'\n\n case 'OrderByBestDiscountDESC':\n return 'discount:desc'\n\n default:\n return ''\n }\n}\n\nexport function convertURLToAttributePath(\n attributePath: string,\n map: string,\n priceRange: string,\n priceRangeKey: string\n) {\n const facets = (attributePath || '').split('/')\n const apiUrlTerms = (map || '')\n .split(',')\n .slice(1)\n .map((item, index) => `${item}/${facets[index].replace(/^z/, '')}`)\n\n const url = apiUrlTerms.join('/')\n\n if (priceRange && priceRangeKey) {\n const [from, to] = priceRange.split(' TO ')\n\n return `${url}/${priceRangeKey}/${from}:${to}`\n }\n\n return url\n}\n\n```"
}
] |
code_search_412c93a9
|
[
{
"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/biggy-client.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport ApolloClient, { ApolloQueryResult } from 'apollo-client'\nimport suggestionProducts from 'vtex.store-resources/QuerySuggestionProducts'\nimport suggestionSearches from 'vtex.store-resources/QueryAutocompleteSearchSuggestions'\nimport topSearches from 'vtex.store-resources/QueryTopSearches'\n\nimport { getCookie, setCookie } from './dom-utils'\nimport { ISearchProduct } from '../models/search-product'\n\nexport default class BiggyClient {\n private historyKey = 'biggy-search-history'\n\n constructor(private client: ApolloClient<any>) {}\n\n public async topSearches(): Promise<\n ApolloQueryResult<{ topSearches: ISearchesOutput }>\n > {\n return this.client.query({\n query: topSearches,\n })\n }\n\n public async suggestionSearches(\n term: string\n ): Promise<\n ApolloQueryResult<{ autocompleteSearchSuggestions: ISearchesOutput }>\n > {\n return this.client.query({\n query: suggestionSearches,\n variables: {\n fullText: term,\n },\n })\n }\n\n // eslint-disable-next-line max-params\n public async suggestionProducts(\n term: string,\n attributeKey?: string,\n attributeValue?: string,\n productOrigin = false,\n simulationBehavior: 'default' | 'skip' | null = 'default',\n hideUnavailableItems = false,\n orderBy?: string,\n count?: number,\n shippingOptions?: string[],\n advertisementOptions?: AdvertisementOptions\n ): Promise<ApolloQueryResult<{ productSuggestions: IProductsOutput }>> {\n return this.client.query({\n query: suggestionProducts,\n variables: {\n simulationBehavior,\n advertisementOptions,\n hideUnavailableItems,\n orderBy,\n fullText: term,\n facetKey: attributeKey,\n facetValue: attributeValue,\n productOriginVtex: productOrigin,\n count,\n shippingOptions,\n variant: getCookie('sp-variant'),\n origin: 'autocomplete',\n },\n fetchPolicy: 'network-only',\n })\n }\n\n public searchHistory(): string[] {\n const history = getCookie(this.historyKey) || ''\n\n return history.split(',').filter(x => !!x)\n }\n\n public prependSearchHistory(term: string, limit = 5) {\n if (term == null || term.trim() === '') {\n return\n }\n\n let history = this.searchHistory()\n\n if (history.indexOf(term) < 0) {\n history.unshift(term)\n history = history.slice(0, limit)\n }\n\n setCookie(this.historyKey, history.join(','))\n }\n}\n\ninterface ISearchesOutput {\n searches: ISuggestionQueryResponseSearch[]\n}\n\ninterface IProductsOutput {\n products: ISearchProduct[]\n count: number\n misspelled: boolean\n operator: string\n searchId: string\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\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\n```"
}
] |
code_search_69478f44
|
[
{
"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/pixel.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nconst EVENT_NAME = 'autocomplete'\n\nexport enum EventType {\n ProductClick = 'product_click',\n SearchSuggestionClick = 'search_suggestion_click',\n TopSearchClick = 'top_search_click',\n HistoryClick = 'history_click',\n Search = 'search',\n SeeAllClick = 'see_all_click',\n}\n\nexport function handleProductClick(push: (data: any) => void, page: string) {\n return (productId: string, position: number, term: string) =>\n push({\n page,\n event: EVENT_NAME,\n eventType: EventType.ProductClick,\n product: {\n productId,\n position,\n },\n term,\n })\n}\n\nexport function handleItemClick(\n push: (data: any) => void,\n page: string,\n type: string\n) {\n return (term: string, position: number) => {\n push({\n page,\n event: EVENT_NAME,\n eventType: type,\n search: {\n term,\n position,\n },\n })\n }\n}\n\nexport function handleSeeAllClick(push: (data: any) => void, page: string) {\n return (term: string) =>\n push({\n page,\n event: EVENT_NAME,\n eventType: EventType.SeeAllClick,\n search: {\n term,\n },\n })\n}\n\nexport function handleAutocompleteSearch(\n push: (data: any) => void,\n operator: string,\n misspelled: boolean,\n count: number,\n term: string\n) {\n try {\n push({\n event: EVENT_NAME,\n eventType: EventType.Search,\n search: {\n operator,\n misspelled,\n text: decodeURI(term),\n match: count,\n },\n })\n } catch (e) {\n push({\n event: EVENT_NAME,\n eventType: EventType.Search,\n search: {\n operator,\n misspelled,\n text: term,\n match: count,\n },\n })\n }\n}\n\n```"
}
] |
code_search_eafcd91e
|
[
{
"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/dom-utils.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport function hasClass(element: HTMLElement, className: string): boolean {\n if (element == null) {\n return false\n }\n\n const regex = new RegExp(`(\\\\s|^)${className}(\\\\s|$)`)\n\n return !!(\n typeof element.className === 'string' && element.className.match(regex)\n )\n}\n\nexport function isDescendant(\n parent: HTMLElement | undefined,\n child: HTMLElement\n): boolean {\n if (!parent) {\n return false\n }\n\n let node = child.parentNode\n\n while (node != null) {\n if (node === parent) {\n return true\n }\n\n node = node.parentNode\n }\n\n return false\n}\n\nexport function hasSomeParentTheClass(\n element: HTMLElement,\n classname: string\n): boolean {\n if (element.className.split(' ').indexOf(classname) >= 0) {\n return true\n }\n\n return (\n !!element.parentElement &&\n hasSomeParentTheClass(element.parentElement, classname)\n )\n}\n\nexport function getCookie(name: string): string | null {\n const regex = new RegExp(`(^|;)[ ]*${name}=([^;]*)`)\n const match = regex.exec(document.cookie)\n\n if (!match) {\n return null\n }\n\n try {\n return decodeURIComponent(match[2])\n } catch {\n return match[2]\n }\n}\n\nexport function setCookie(\n key: string,\n value: string,\n ttl?: number,\n path = '/'\n) {\n let expires = ''\n\n if (ttl && ttl > 0) {\n const expirationDate = new Date()\n\n expirationDate.setTime(new Date().getTime() + ttl)\n expires = `expires=${expirationDate.toUTCString()};`\n }\n\n document.cookie = `${key}=${encodeURIComponent(value)};${expires}path=${path}`\n}\n\n```"
}
] |
code_search_c20615ee
|
[
{
"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/number-utils.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { PriceFormatPreferences } from '../models/store-preferences'\n\nexport function formatPrice(\n price: number,\n preferences: PriceFormatPreferences\n) {\n return `${preferences.prefix}${price\n .toFixed(preferences.decimalPlaces)\n .replace('.', preferences.floatIndicator)}`\n}\n\n```"
}
] |
code_search_aef02ab9
|
[
{
"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/log.ts from the search VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport axios from 'axios'\n\nconst client = axios.create({\n baseURL: 'https://search.biggylabs.com.br/search-api/v1',\n headers: {\n 'Content-Type': 'application/json',\n },\n})\n\nconst logError = (\n store: string,\n workspace: string,\n attributePath: string,\n error: any\n) => {\n const browser =\n typeof navigator !== 'undefined' ? navigator.userAgent : 'server-side-error'\n\n const message = `Workspace: ${workspace}\\nBrowser: ${browser}\\nMessage: ${\n error.message\n }\\n${error.stack != null ? error.stack : ''}`\n\n client.post(`/${store}/log`, {\n message,\n url: `Search App Error at: ${attributePath}`,\n })\n}\n\nexport default logError\n\n```"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.