id
stringlengths
12
53
messages
listlengths
3
3
code_my-account-commons_03a1e424
[ { "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 my-account-commons/messages/context.json from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"alert.connectionError\": \"alert.connectionError\",\n \"alert.unauthenticated\": \"alert.unauthenticated\",\n \"alert.reload\": \"alert.reload\",\n \"alert.unknownError\": \"alert.unknownError\",\n \"commons.back\": \"commons.back\",\n \"progressBar.package.progress\": \"progressBar.package.progress\",\n \"progressBar.order.status\": \"progressBar.order.status\"\n}\n```" } ]
code_my-account-commons_b7f9eb88
[ { "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 my-account-commons/messages/ko.json from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"alert.connectionError\": \"시스템에 연결하는 동안 오류가 발생했습니다. 페이지를 다시 로딩하십시오.\",\n \"alert.unauthenticated\": \"이 작업을 수행하려면 인증을 받아야 합니다.\",\n \"alert.reload\": \"다시 로딩\",\n \"alert.unknownError\": \"오류가 발생했습니다. 다시 시도하십시오.\",\n \"commons.back\": \"반품\",\n \"progressBar.package.progress\": \"패키지 상태\",\n \"progressBar.order.status\": \"주문 상태\"\n}\n\n```" } ]
code_my-account-commons_4d66b3f4
[ { "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 my-account-commons/messages/da.json from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"alert.connectionError\": \"Der opstod en fejl under forbindelse med systemet, prøv at indlæse siden igen.\",\n \"alert.unauthenticated\": \"Du skal godkendes for at fortsætte med denne handling.\",\n \"alert.reload\": \"Genindlæs\",\n \"alert.unknownError\": \"Der opstod en fejl, prøv igen.\",\n \"commons.back\": \"Gå tilbage\",\n \"progressBar.package.progress\": \"Pakkestatus\",\n \"progressBar.order.status\": \"Ordrestatus\"\n}\n\n```" } ]
code_my-account-commons_fe8d1693
[ { "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 my-account-commons/messages/sv.json from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"alert.connectionError\": \"Det uppstod ett fel vid anslutningen till systemet, försök att ladda om sidan igen.\",\n \"alert.unauthenticated\": \"Du måste verifieras för att fortsätta med den här åtgärden.\",\n \"alert.reload\": \"Ladda om\",\n \"alert.unknownError\": \"Ett fel uppstod, försök igen.\",\n \"commons.back\": \"Återgå\",\n \"progressBar.package.progress\": \"Förpackningsstatus\",\n \"progressBar.order.status\": \"Beställningsstatus\"\n}\n\n```" } ]
code_my-account-commons_f5ead9f5
[ { "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 my-account-commons/messages/es.json from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"alert.connectionError\": \"Hubo un error al conectar con el sistema, intente cargar la página nuevamente.\",\n \"alert.unauthenticated\": \"Debe estar autenticado para continuar con esta acción.\",\n \"alert.reload\": \"Recargar\",\n \"alert.unknownError\": \"Se produjo un error, inténtalo de nuevo.\",\n \"commons.back\": \"Atrás\",\n \"progressBar.package.progress\": \"Estado del paquete\",\n \"progressBar.order.status\": \"Estado del pedido\"\n}\n\n```" } ]
code_my-account-commons_7efb37eb
[ { "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 my-account-commons/docs/README.md from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# My Account Commons\n\nMy Account Commons is a bundle of canonical components that can be used to create new tabs to be inserted on the `vtex.my-account` app.\n\nDISCLAIMER: In order to this components work, they need to be children of `vtex.my-account` app.\n\nTo import it into your code:\n\n```js\nimport {\n ContentWrapper,\n BaseLoading,\n GenericError,\n} from 'vtex.my-account-commons'\n```\n\n## Usages\n\n### ContentWrapper\n\nYou can use it in your code like a React component with the jsx tag: `<ContentWrapper>`.\n\n```jsx\n<ContentWrapper\n namespace=\"my-custom-page\"\n title={`${orderTitle} ${orderNumber}`}\n backButton={backButton}>\n {({ handleError }) => children}\n</ContentWrapper>\n```\n\n| Prop name | Type | Description |\n| -------------------- | --------- | ---------------------------------------------------------------------------- |\n| `title` | `String` | The string that will appear on the page title. |\n| `titleId` | `String` | Intl message id that will be translated and inserted on the page title. |\n| `backbutton.title` | `String` | The string that will appear as a message on the backbutton. |\n| `backbutton.titleId` | `String` | Intl message id that will be translated and inserted as the go back message. |\n| `backbutton.path` | `String!` | Location which the user will be lead to when hit the backbutton. |\n| `headerContent` | `node` | JSX that wil be inserted as children of the `vtex.style-guide/PageHeader`. |\n| `namespace` | `String!` | Css namespace that will be added to the page body. |\n\nThe `ContentWrapper` uses the render prop pattern and returns to its children an object with the following props:\n\n#### Render prop\n\n| Prop name | Type | Description |\n| ------------ | ---------- | ----------------------------------------------------------------------- |\n| `handlError` | `Function` | Function that will be called when the user dismisses the error message. |\n\n### BaseLoading\n\nThis component should be used to implement your own Loader, it analyses the result of a graphql query and displays\nthe loader Skeleton or an error message if any error occurs with retry option to call refetch on the query.\n\n```jsx\n<BaseLoading queryData={data} headerConfig={object}>\n {children}\n</BaseLoading>\n```\n\n| Prop name | Type | Description |\n| -------------- | --------------- | ----------------------------------------------------------------------------------------------------------------- |\n| `queryData` | `QueryResult` | Apollo Graphql query result. |\n| `headerConfig` | `ContentWProps` | The props that will be passed to the `ContentWrapper`. |\n| `nameSpace` | `String` | The name space prop that will be passed to the `ContentWrapper`. `vtex-base-loading` is applied if none is passed |\n| `parseError` | `Function` | Function that parses the graphql error and returns a messageId. |\n\n### GenericError\n\nA wrapper for the `vtex.styleguide/Alert` component.\n\n```jsx\n<GenericError onDismiss={handleError} errorId={error} />\n```\n\n| Prop name | Type | Description |\n| ----------- | ---------- | -------------------------------------------------------------------- |\n| `error` | `String` | The error message that will be displayed on the `Alert`. |\n| `errorId` | `String` | Intl message id that will be translated and inserted on the `Alert`. |\n| `onDismiss` | `Function` | Function that will be called when the user hits the close button. |\n\n### Disclaimer about react/Router.js file\n\nRead carefully the instructions within the file before editing it.\n\n```" } ]
code_my-account-commons_20486461
[ { "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 my-account-commons/react/SkeletonPiece.tsx from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport './style.global.css'\n\nimport React, { FunctionComponent } from 'react'\n\nconst SkeletonPiece: FunctionComponent<Props> = ({ width, size }) => (\n <div\n className={`bg-muted-5 w-${width} ${\n size ? `pa${size}` : 'h-100'\n } relative overflow-hidden`}\n >\n <div className=\"shimmer\" />\n </div>\n)\n\nSkeletonPiece.defaultProps = {\n width: '100',\n}\n\ninterface Props {\n width?:\n | '10'\n | '20'\n | '25'\n | '30'\n | '33'\n | '34'\n | '40'\n | '50'\n | '60'\n | '70'\n | '75'\n | '80'\n | '90'\n | '100'\n | 'third'\n | 'two-thirds'\n size?: '0' | '1' | '2' | '3' | '4' | '5' | '6'\n}\n\nexport default SkeletonPiece\n\n```" } ]
code_my-account-commons_42d2f8db
[ { "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 my-account-commons/react/SkeletonBox.tsx from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FunctionComponent } from 'react'\n\nimport SkeletonPiece from './SkeletonPiece'\n\nconst SkeletonBox: FunctionComponent<Props> = ({\n children,\n maxWidthStep,\n shouldAllowGrowing,\n shouldShowLowerButton,\n}) => {\n const widthClass = maxWidthStep ? `mw${maxWidthStep}-ns` : ''\n const flexClass = shouldAllowGrowing ? 'flex-auto' : 'flex-none'\n\n return (\n <div className={`pb5 pr5-ns ${flexClass} ${widthClass}`}>\n <article className=\"ba bw1 b--muted-5 br2 h-100 flex flex-column justify-between\">\n <main className=\"ph7 pv6\">{children}</main>\n {shouldShowLowerButton && (\n <footer className=\"flex justify-end ph7 pb6 pt3\">\n <SkeletonPiece width=\"50\" size=\"4\" />\n </footer>\n )}\n </article>\n </div>\n )\n}\n\nSkeletonBox.defaultProps = {\n shouldAllowGrowing: false,\n}\n\ninterface Props {\n maxWidthStep?: number\n shouldAllowGrowing?: boolean\n shouldShowLowerButton?: boolean\n}\n\nexport default SkeletonBox\n\n```" } ]
code_my-account-commons_beb5f93e
[ { "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 my-account-commons/react/GenericError.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport GenericError from './components/GenericError'\n\nexport default GenericError\n\n```" } ]
code_my-account-commons_b1a34f7c
[ { "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 my-account-commons/react/style.global.css from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n/* Skeleton animation */\n@keyframes shimmer-anim {\n 0% {\n transform: translate3d(0, 0, 0);\n }\n 100% {\n transform: translate3d(50%, 0, 0);\n }\n}\n\n.shimmer {\n width: 200%;\n height: 100%;\n position: absolute;\n top: 0;\n left: -100%;\n background: linear-gradient(\n 90deg,\n rgba(255, 255, 255, 0),\n rgba(255, 255, 255, 0.7),\n rgba(255, 255, 255, 0)\n );\n background-size: 50% 100%;\n animation: shimmer-anim 0.7s linear infinite;\n}\n\n```" } ]
code_my-account-commons_e8e7ae23
[ { "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 my-account-commons/react/Router.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport * as ReactRouterDom from 'react-router-dom'\n\n/*\n IMPORTANT: READ BEFORE MAKING ANY EDITIONS IN THIS FILE\n\n This file's goal is to make the use of react-router-dom\n unified through all the apps within the My Account ecosystem.\n Delete this if a better solution for the problem of\n having multiple versions of the router comes up.\n*/\n\nexport default ReactRouterDom\n\n```" } ]
code_my-account-commons_7e3ef9b6
[ { "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 my-account-commons/react/package.json from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"lint\": \"tsc --noEmit\",\n \"lint:locales\": \"intl-equalizer\",\n \"test\": \"vtex-test-tools test\",\n \"test:watch\": \"vtex-test-tools test:watch\"\n },\n \"dependencies\": {\n \"lodash\": \"^4.17.11\",\n \"react\": \"^16.3.2\",\n \"react-intl\": \"^2.4.0\",\n \"react-router-dom\": \"^4.3.1\",\n \"react-router-prop-types\": \"^1.0.4\",\n \"recompose\": \"^0.30.0\"\n },\n \"devDependencies\": {\n \"@types/graphql\": \"^14.0.7\",\n \"@types/jest\": \"^24.0.11\",\n \"@types/node\": \"^11.11.3\",\n \"@types/react\": \"^16.8.8\",\n \"@types/react-dates\": \"^17.1.5\",\n \"@types/react-intl\": \"^2.3.17\",\n \"@types/react-outside-click-handler\": \"^1.2.0\",\n \"@types/recompose\": \"^0.30.5\",\n \"@vtex/delivery-packages\": \"^2.17.0\",\n \"@vtex/test-tools\": \"^3.1.0\",\n \"apollo-client\": \"^2.5.1\",\n \"typescript\": \"3.9.7\"\n },\n \"version\": \"0.16.1\"\n}\n\n```" } ]
code_my-account-commons_99237723
[ { "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 my-account-commons/react/ContentWrapper.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport ContentWrapper from './components/ContentWrapper'\n\nexport default ContentWrapper\n\n```" } ]
code_my-account-commons_0c6f51c3
[ { "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 my-account-commons/react/BaseLoading.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport BaseLoading from './components/BaseLoading'\n\nexport default BaseLoading\n\n```" } ]
code_my-account-commons_8a20c0b6
[ { "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 my-account-commons/react/utils.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport reduce from 'lodash/reduce'\nimport { FormattedMessage } from 'react-intl'\n\nfunction estimateShipping(deliveryPackage) {\n const {\n shippingEstimate: slaShippingEstimate,\n shippingEstimateDate: slaShippingEstimateDate,\n } = deliveryPackage\n\n if (!slaShippingEstimate) {\n return slaShippingEstimateDate != null\n ? {\n date: slaShippingEstimateDate,\n }\n : null\n }\n\n const shippingEstimateParts = slaShippingEstimate.match(/\\d+|[a-zA-Z]+/g)\n\n // There's a bug in the API that makes shippingEstimate not to have a unit.\n // This is the case this if is fixing\n if (!shippingEstimateParts || shippingEstimateParts.length <= 1) {\n return {\n date: slaShippingEstimateDate,\n }\n }\n\n const estimateValue = shippingEstimateParts[0]\n const estimateType = shippingEstimateParts[1]\n\n if (slaShippingEstimateDate) {\n const isEstimateInHoursOrMinutes =\n estimateType.indexOf('h') !== -1 || estimateType.indexOf('m') !== -1\n\n return {\n date: slaShippingEstimateDate,\n isEstimateInHoursOrMinutes,\n }\n }\n\n const estimateValueInt = parseInt(estimateValue)\n\n const label = (\n <FormattedMessage\n id={`order.shippingEstimate.${estimateType}`}\n values={{ timeAmount: estimateValueInt }}\n />\n )\n\n return {\n unit: estimateValueInt,\n type: estimateType,\n label: label,\n }\n}\n\nfunction reduceBundleItems(items) {\n return reduce(\n items,\n (acc, item) => {\n acc = acc.concat(item)\n acc = acc.concat(...checkForAttachments(item))\n\n if (item.bundleItems && item.bundleItems.length > 0) {\n acc = acc.concat(\n item.bundleItems.map((bundleItem) =>\n addBundleItemFlagAndParentItemQuantity(item, bundleItem)\n )\n )\n acc = acc.concat(...item.bundleItems.map(checkForAttachments))\n }\n\n return acc\n },\n []\n )\n}\n\nfunction fixImageUrl(imageUrl, width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT) {\n return changeImageUrlSize(\n replaceHttpToRelativeProtocol(cleanImageUrl(imageUrl)),\n width,\n height\n )\n}\n\nexport default { fixImageUrl, reduceBundleItems, estimateShipping }\n\nconst DEFAULT_WIDTH = 50\nconst DEFAULT_HEIGHT = 50\nconst DEFAULT_HDF = 1\n\nconst baseUrlRegex = new RegExp(/.+ids\\/(\\d+)(?:-(\\d+)-(\\d+)|)\\//)\nconst sizeRegex = new RegExp(/-(\\d+)-(\\d+)/)\n\nfunction changeImageUrlSize(\n imageUrl,\n width,\n height,\n highDensityFactor = DEFAULT_HDF\n) {\n // imageUrl example http://omniera.vteximg.com.br/arquivos/ids/155401-135-135/CAN-09-04--1-.jpg\n if (!imageUrl || !width || !height) return undefined\n const widthCalc = width * highDensityFactor\n const heightCalc = height * highDensityFactor\n if (imageUrl.slice(-1) !== '/') {\n return `${imageUrl}?width=${widthCalc}&height=${heightCalc}&aspect=true`\n }\n const resizedImageUrl = imageUrl.slice(0, -1) // Remove last \"/\"\n return `${resizedImageUrl}-${widthCalc}-${heightCalc}`\n}\n\nfunction replaceHttpToRelativeProtocol(url) {\n if (!url) {\n return undefined\n }\n return url.replace(/https:\\/\\/|http:\\/\\//, '//')\n}\n\nfunction cleanImageUrl(imageUrl) {\n let resizedImageUrl = imageUrl\n const result = baseUrlRegex.exec(imageUrl)\n if (result && result.length > 0) {\n if (\n result.length === 4 &&\n result[2] !== undefined &&\n result[3] !== undefined\n ) {\n resizedImageUrl = result[0].replace(sizeRegex, '')\n } else {\n resizedImageUrl = result[0]\n }\n return resizedImageUrl\n }\n return resizedImageUrl\n}\n\nfunction checkForAttachments(item) {\n if (item.attachments && item.attachments.length > 0) {\n return item.attachments.map(addAttachmentFlag)\n }\n\n return []\n}\n\nfunction addAttachmentFlag(attachment) {\n return {\n ...attachment,\n isAttachment: true,\n }\n}\n\nfunction addBundleItemFlagAndParentItemQuantity(product, bundleItem) {\n return {\n ...bundleItem,\n parentItemQuantity: product.quantity,\n isBundleItem: true,\n }\n}\n\n```" } ]
code_my-account-commons_d59c183e
[ { "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 my-account-commons/react/ProgressBarBundle.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport {\n progressBarStates,\n packageProgressBarStates,\n} from './components/ProgressBar/constants'\nimport {\n generatePackageProgressBarStates,\n generateProgressBarStates,\n getCurrentProgressBarState\n} from './components/ProgressBar/utils'\nimport OrderStatus from './components/ProgressBar/OrderStatus'\nimport ProgressBar from './components/ProgressBar/ProgressBar'\nimport ProgressBarSection from './components/ProgressBar/ProgressBarSection'\nimport PackageStatus from './components/ProgressBar/PackageProgressBar/PackageStatus'\nimport PackageProgressBar from './components/ProgressBar/PackageProgressBar/PackageProgressBar'\nimport PackageProgressBarSection from './components/ProgressBar/PackageProgressBar/PackageProgressBarSection'\n\nconst constants = {\n progressBarStates,\n packageProgressBarStates,\n}\n\nconst utils = {\n generatePackageProgressBarStates,\n generateProgressBarStates,\n getCurrentProgressBarState\n}\n\nexport default {\n constants,\n utils,\n OrderStatus,\n ProgressBar,\n ProgressBarSection,\n PackageProgressBar,\n PackageProgressBarSection,\n PackageStatus,\n}\n\n```" } ]
code_my-account-commons_9b380db0
[ { "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 my-account-commons/react/mocks/DeliveredOrder.ts from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport default {\n orderId: '811912939493-01',\n sequence: '1306300',\n marketplaceOrderId: '',\n marketplaceServicesEndpoint:\n 'http://portal.vtexcommerce.com.br/api/oms?an=qamarketplace',\n sellerOrderId: '00-811912939493-01',\n origin: 'Marketplace',\n affiliateId: '',\n salesChannel: '1',\n merchantName: null,\n status: 'invoiced',\n statusDescription: 'Faturado',\n value: 10163,\n creationDate: '2018-02-19T14:49:02.6223868+00:00',\n lastChange: '2018-02-19T19:22:14.2313636+00:00',\n orderGroup: '811912939493',\n totals: [\n {\n id: 'Items',\n name: 'Total dos Itens',\n value: 10064,\n },\n {\n id: 'Discounts',\n name: 'Total dos Descontos',\n value: -1500,\n },\n {\n id: 'Shipping',\n name: 'Total do Frete',\n value: 1599,\n },\n {\n id: 'Tax',\n name: 'Total da Taxa',\n value: 0,\n },\n ],\n items: [\n {\n uniqueId: '8711D11DCD3341678013164883F07931',\n id: '15',\n productId: '4',\n ean: 'produtohomologação',\n lockId: '00-811912939493-01',\n itemAttachment: {\n content: {},\n name: null,\n },\n attachments: [],\n quantity: 1,\n seller: '1',\n name: 'Novalgina',\n refId: 'produtohomologação',\n price: 5764,\n listPrice: 8000,\n manualPrice: null,\n priceTags: [\n {\n name:\n 'discount@price-e518d70e-6da2-47bb-9e1a-6540a1a214c6#1c2d2b41-b7ff-4157-9d4c-2cce8eb508f5',\n value: -1500,\n isPercentual: false,\n identifier: 'e518d70e-6da2-47bb-9e1a-6540a1a214c6',\n rawValue: -15.0,\n },\n ],\n imageUrl:\n 'http://qamarketplace.vteximg.com.br/arquivos/ids/155400-55-55/Novalgina.jpg?v=635985172600570000',\n detailUrl: '/novalgina/p',\n components: [],\n bundleItems: [],\n params: [],\n offerings: [],\n sellerSku: '15',\n priceValidUntil: null,\n commission: 0,\n tax: 0,\n preSaleDate: null,\n additionalInfo: {\n brandName: 'Marca Exemplo',\n brandId: '2000000',\n categoriesIds: '/4/5/',\n productClusterId: '135',\n commercialConditionId: '1',\n dimension: {\n cubicweight: 0.1667,\n height: 10.0,\n length: 10.0,\n weight: 10.0,\n width: 10.0,\n },\n offeringInfo: null,\n offeringType: null,\n offeringTypeId: null,\n },\n measurementUnit: 'un',\n unitMultiplier: 1.0,\n sellingPrice: 4264,\n isGift: false,\n shippingPrice: null,\n rewardValue: 0,\n freightCommission: 0,\n },\n {\n uniqueId: 'F41B33B78B2244BFBB7EE7E453282A52',\n id: '111',\n productId: '96',\n ean: '7896292001404',\n lockId: '00-811912939493-01',\n itemAttachment: {\n content: {},\n name: null,\n },\n attachments: [],\n quantity: 1,\n seller: '1',\n name: 'Açúcar Light Magro 500g',\n refId: '156062',\n price: 3300,\n listPrice: 1000,\n manualPrice: null,\n priceTags: [],\n imageUrl:\n 'http://qamarketplace.vteximg.com.br/arquivos/ids/155463-55-55/mambo.png?v=636053048039670000',\n detailUrl: '/acucar-light-magro-500g/p',\n components: [],\n bundleItems: [],\n params: [],\n offerings: [],\n sellerSku: '111',\n priceValidUntil: null,\n commission: 0,\n tax: 0,\n preSaleDate: null,\n additionalInfo: {\n brandName: 'Mambo',\n brandId: '2000003',\n categoriesIds: '/9/10/',\n productClusterId: '',\n commercialConditionId: '1',\n dimension: {\n cubicweight: 0.0002,\n height: 1.0,\n length: 1.0,\n weight: 1.0,\n width: 1.0,\n },\n offeringInfo: null,\n offeringType: null,\n offeringTypeId: null,\n },\n measurementUnit: 'un',\n unitMultiplier: 1.0,\n sellingPrice: 3300,\n isGift: false,\n shippingPrice: null,\n rewardValue: 0,\n freightCommission: 0,\n },\n {\n uniqueId: '06901310CA6C4794A9B57EE8D5886372',\n id: '79',\n productId: '64',\n ean: '7896292001084',\n lockId: '00-811912939493-01',\n itemAttachment: {\n content: {},\n name: null,\n },\n attachments: [],\n quantity: 1,\n seller: '1',\n name: 'Achocolatado Diet sem Lactose New Choco 210g',\n refId: '208754',\n price: 1000,\n listPrice: 1000,\n manualPrice: null,\n priceTags: [],\n imageUrl:\n 'http://qamarketplace.vteximg.com.br/arquivos/ids/155431-55-55/mambo.png?v=636053047861800000',\n detailUrl: '/achocolatado-diet-sem-lactose-new-choco-210g/p',\n components: [],\n bundleItems: [],\n params: [],\n offerings: [],\n sellerSku: '79',\n priceValidUntil: null,\n commission: 0,\n tax: 0,\n preSaleDate: null,\n additionalInfo: {\n brandName: 'Mambo',\n brandId: '2000003',\n categoriesIds: '/9/10/',\n productClusterId: '',\n commercialConditionId: '1',\n dimension: {\n cubicweight: 0.0002,\n height: 1.0,\n length: 1.0,\n weight: 1.0,\n width: 1.0,\n },\n offeringInfo: null,\n offeringType: null,\n offeringTypeId: null,\n },\n measurementUnit: 'un',\n unitMultiplier: 1.0,\n sellingPrice: 1000,\n isGift: false,\n shippingPrice: null,\n rewardValue: 0,\n freightCommission: 0,\n },\n ],\n marketplaceItems: [],\n clientProfileData: {\n id: 'clientProfileData',\n email: 'breno@mailinator.com',\n firstName: 'Breno',\n lastName: 'Calazans',\n documentType: 'cpf',\n document: '01239526113',\n phone: '+552222222222',\n corporateName: null,\n tradeName: null,\n corporateDocument: null,\n stateInscription: null,\n corporatePhone: null,\n isCorporate: false,\n userProfileId: '2f217ab3-d389-49a8-88e3-72bf372a4343',\n customerClass: null,\n },\n giftRegistryData: null,\n marketingData: null,\n ratesAndBenefitsData: {\n id: 'ratesAndBenefitsData',\n rateAndBenefitsIdentifiers: [\n {\n description: null,\n featured: false,\n id: 'e518d70e-6da2-47bb-9e1a-6540a1a214c6',\n name: 'Desconto no Sku 15',\n matchedParameters: {\n 'product@CatalogSystem': '4|inclusive',\n },\n },\n ],\n },\n shippingData: {\n id: 'shippingData',\n address: {\n addressType: 'residential',\n receiverName: 'auto auto',\n addressId: '-1456253174642',\n postalCode: '22251-030',\n city: 'Rio de Janeiro',\n state: 'RJ',\n country: 'BRA',\n street: 'Rua Assunção',\n number: '2',\n neighborhood: 'Botafogo',\n complement: null,\n reference: null,\n geoCoordinates: [],\n },\n logisticsInfo: [\n {\n itemIndex: 0,\n selectedSla: 'Normal',\n lockTTL: '8d',\n price: 1454,\n listPrice: 1454,\n sellingPrice: 1454,\n deliveryWindow: null,\n deliveryCompany: 'Transportadora',\n shippingEstimate: '7d',\n shippingEstimateDate: '2018-02-26T14:48:41.6499371+00:00',\n slas: [\n {\n id: 'Normal',\n name: 'Normal',\n shippingEstimate: '7d',\n deliveryWindow: null,\n price: 1454,\n deliveryChannel: 'delivery',\n pickupStoreInfo: {\n additionalInfo: null,\n address: null,\n dockId: null,\n friendlyName: null,\n isPickupStore: false,\n },\n },\n ],\n shipsTo: ['BRA'],\n deliveryIds: [\n {\n courierId: '1',\n courierName: 'Transportadora',\n dockId: '1',\n quantity: 1,\n warehouseId: '169cdbc',\n },\n ],\n deliveryChannel: 'delivery',\n pickupStoreInfo: {\n additionalInfo: null,\n address: null,\n dockId: null,\n friendlyName: null,\n isPickupStore: false,\n },\n addressId: '-1456253174642',\n },\n {\n itemIndex: 1,\n selectedSla: 'PAC',\n lockTTL: '8d',\n price: 0,\n listPrice: 0,\n sellingPrice: 0,\n deliveryWindow: null,\n deliveryCompany: '[Teste QA] Nao Mexer',\n shippingEstimate: '3bd',\n shippingEstimateDate: '2018-02-22T14:48:41.6499371+00:00',\n slas: [\n {\n id: 'PAC',\n name: 'PAC',\n shippingEstimate: '3bd',\n deliveryWindow: null,\n price: 0,\n deliveryChannel: 'delivery',\n pickupStoreInfo: {\n additionalInfo: null,\n address: null,\n dockId: null,\n friendlyName: null,\n isPickupStore: false,\n },\n },\n ],\n shipsTo: ['BRA'],\n deliveryIds: [\n {\n courierId: '155ad08',\n courierName: '[Teste QA] Nao Mexer',\n dockId: '1125a08',\n quantity: 1,\n warehouseId: '1f995ee',\n },\n ],\n deliveryChannel: 'delivery',\n pickupStoreInfo: {\n additionalInfo: null,\n address: null,\n dockId: null,\n friendlyName: null,\n isPickupStore: false,\n },\n addressId: '-1456253174642',\n },\n {\n itemIndex: 2,\n selectedSla: 'Normal',\n lockTTL: '8d',\n price: 145,\n listPrice: 145,\n sellingPrice: 145,\n deliveryWindow: null,\n deliveryCompany: 'Transportadora',\n shippingEstimate: '7d',\n shippingEstimateDate: '2018-02-26T14:48:41.6499371+00:00',\n slas: [\n {\n id: 'Normal',\n name: 'Normal',\n shippingEstimate: '7d',\n deliveryWindow: null,\n price: 145,\n deliveryChannel: 'delivery',\n pickupStoreInfo: {\n additionalInfo: null,\n address: null,\n dockId: null,\n friendlyName: null,\n isPickupStore: false,\n },\n },\n ],\n shipsTo: ['BRA'],\n deliveryIds: [\n {\n courierId: '1',\n courierName: 'Transportadora',\n dockId: '1',\n quantity: 1,\n warehouseId: '169cdbc',\n },\n ],\n deliveryChannel: 'delivery',\n pickupStoreInfo: {\n additionalInfo: null,\n address: null,\n dockId: null,\n friendlyName: null,\n isPickupStore: false,\n },\n addressId: '-1456253174642',\n },\n ],\n trackingHints: null,\n selectedAddresses: [\n {\n addressId: '-1456253174642',\n addressType: 'residential',\n receiverName: 'auto auto',\n street: 'Rua Assunção',\n number: '2',\n complement: null,\n neighborhood: 'Botafogo',\n postalCode: '22251-030',\n city: 'Rio de Janeiro',\n state: 'RJ',\n country: 'BRA',\n reference: null,\n geoCoordinates: [],\n },\n ],\n },\n paymentData: {\n transactions: [\n {\n isActive: true,\n transactionId: '314EE37078174BB3A1BB80BB7396B826',\n merchantName: 'QAMARKETPLACE',\n payments: [\n {\n id: '7C6BC1C46FB943A2B4AB0147B99412AB',\n paymentSystem: '4',\n paymentSystemName: 'Mastercard',\n value: 10163,\n installments: 1,\n referenceValue: 10163,\n cardHolder: null,\n cardNumber: null,\n firstDigits: '555500',\n lastDigits: '2222',\n cvv2: null,\n expireMonth: null,\n expireYear: null,\n url: null,\n giftCardId: null,\n giftCardName: null,\n giftCardCaption: null,\n redemptionCode: null,\n group: 'creditCard',\n tid: '46422942',\n dueDate: null,\n connectorResponses: {\n Tid: '46422942',\n ReturnCode: null,\n Message: null,\n authId: '422942',\n },\n },\n ],\n },\n ],\n },\n packageAttachment: {\n packages: [\n {\n items: [\n {\n itemIndex: 1,\n quantity: 1,\n price: 3300,\n description: null,\n },\n ],\n courier: 'Transportadora',\n invoiceNumber: '123312',\n invoiceValue: 3300,\n invoiceUrl: null,\n issuanceDate: '2018-02-19T03:00:00.0000000+00:00',\n trackingNumber: '123233',\n invoiceKey: null,\n trackingUrl: 'facebook.com.br',\n embeddedInvoice: '',\n type: 'Output',\n courierStatus: {\n status: 'unknown',\n finished: true,\n data: [],\n },\n },\n {\n items: [\n {\n itemIndex: 2,\n quantity: 1,\n price: 1000,\n description: null,\n },\n ],\n courier: 'Teste CHECKOUT Sedex',\n invoiceNumber: '4213423423',\n invoiceValue: 1000,\n invoiceUrl: null,\n issuanceDate: '2018-02-19T03:00:00.0000000+00:00',\n trackingNumber: '4132244343',\n invoiceKey: null,\n trackingUrl: 'vtex.com.br',\n embeddedInvoice: '',\n type: 'Output',\n courierStatus: {\n status: 'unknown',\n finished: true,\n data: [],\n },\n },\n {\n items: [\n {\n itemIndex: 0,\n quantity: 1,\n price: 4264,\n description: null,\n },\n ],\n courier: '[Teste QA] Nao Mexer',\n invoiceNumber: '432243344',\n invoiceValue: 4264,\n invoiceUrl: '',\n issuanceDate: '2018-02-19T03:00:00.0000000+00:00',\n trackingNumber: '443214',\n invoiceKey: null,\n trackingUrl: 'g1.com.br',\n embeddedInvoice: '',\n type: 'Output',\n courierStatus: {\n status: 'unknown',\n finished: true,\n data: [],\n },\n },\n ],\n },\n sellers: [\n {\n id: '1',\n name: 'qamarketplace',\n logo: '',\n },\n ],\n callCenterOperatorData: null,\n followUpEmail: '10299ccd675d4cfb8749dfe2c808a421@ct.vtex.com.br',\n lastMessage: null,\n hostname: 'qamarketplace',\n changesAttachment: null,\n openTextField: null,\n roundingError: 0,\n orderFormId: 'fd0ea0aa66ce45768e21e044b4c8b513',\n commercialConditionData: null,\n isCompleted: true,\n customData: null,\n storePreferencesData: {\n countryCode: 'BRA',\n currencyCode: 'BRL',\n currencyFormatInfo: {\n CurrencyDecimalDigits: 2,\n CurrencyDecimalSeparator: ',',\n CurrencyGroupSeparator: '.',\n CurrencyGroupSize: 3,\n StartsWithCurrencySymbol: true,\n },\n currencyLocale: 1046,\n currencySymbol: 'R$',\n timeZone: 'E. South America Standard Time',\n },\n allowCancellation: true,\n allowEdition: true,\n isCheckedIn: false,\n}\n\n```" } ]
code_my-account-commons_5c651b9a
[ { "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 my-account-commons/react/mocks/NotDeliveredOrder.ts from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport default {\n orderId: '834081519069-01',\n sequence: '549600',\n marketplaceOrderId: '',\n marketplaceServicesEndpoint:\n 'http://portal.vtexcommerce.com.br/api/oms?an=vtexgame1',\n sellerOrderId: '00-834081519069-01',\n origin: 'Marketplace',\n affiliateId: '',\n salesChannel: '1',\n merchantName: null,\n status: 'invoiced',\n statusDescription: 'Faturado',\n value: 6798,\n creationDate: '2018-05-23T00:26:05.7454162+00:00',\n lastChange: '2018-07-27T14:05:43.8509746+00:00',\n orderGroup: '834081519069',\n totals: [\n {\n id: 'Items',\n name: 'Total dos Itens',\n value: 6298,\n },\n {\n id: 'Discounts',\n name: 'Total dos Descontos',\n value: 0,\n },\n {\n id: 'Shipping',\n name: 'Total do Frete',\n value: 500,\n },\n {\n id: 'Tax',\n name: 'Total da Taxa',\n value: 0,\n },\n ],\n items: [\n {\n uniqueId: '44FE5E7665F54255A5A6810CEFD4465E',\n id: '31',\n productId: '20',\n ean: null,\n lockId: '00-834081519069-01',\n itemAttachment: {\n content: {},\n name: null,\n },\n attachments: [],\n quantity: 1,\n seller: '1',\n name: 'Camisa Seleção Brasileira',\n refId: '00001',\n price: 3999,\n listPrice: 1000,\n manualPrice: null,\n priceTags: [],\n imageUrl:\n 'http://vtexgame1.vteximg.com.br/arquivos/ids/155369-55-55/Azul-Talla-S_0.jpg?v=635833511570300000',\n detailUrl: '/polera-de-futbol-nike-manga-corta-20/p',\n components: [],\n bundleItems: [],\n params: [],\n offerings: [],\n sellerSku: '31',\n priceValidUntil: null,\n commission: 0,\n tax: 0,\n preSaleDate: null,\n additionalInfo: {\n brandName: 'Marca Exemplo',\n brandId: '2000000',\n categoriesIds: '/1/2/3/',\n productClusterId: '135',\n commercialConditionId: '1',\n dimension: {\n cubicweight: 0.2,\n height: 20.0,\n length: 3.0,\n weight: 50.0,\n width: 20.0,\n },\n offeringInfo: null,\n offeringType: null,\n offeringTypeId: null,\n },\n measurementUnit: 'un',\n unitMultiplier: 1.0,\n sellingPrice: 3999,\n isGift: false,\n shippingPrice: null,\n rewardValue: 0,\n freightCommission: 0,\n priceDefinitions: null,\n },\n {\n uniqueId: '981EC2B9AB804B5990DDD0C904CDA0F5',\n id: '33',\n productId: '22',\n ean: 'Name*\\t Camisa Vasco Preta',\n lockId: '00-834081519069-01',\n itemAttachment: {\n content: {},\n name: null,\n },\n attachments: [],\n quantity: 1,\n seller: '1',\n name: 'Camisa Vasco Preta',\n refId: null,\n price: 2299,\n listPrice: 3400,\n manualPrice: null,\n priceTags: [],\n imageUrl:\n 'http://vtexgame1.vteximg.com.br/arquivos/ids/155639-55-55/ximi.png?v=636562111639370000',\n detailUrl: '/camisa-vasco-preta/p',\n components: [],\n bundleItems: [],\n params: [],\n offerings: [],\n sellerSku: '33',\n priceValidUntil: null,\n commission: 0,\n tax: 0,\n preSaleDate: null,\n additionalInfo: {\n brandName: 'Marca 1',\n brandId: '2000001',\n categoriesIds: '/1/2/',\n productClusterId: '135',\n commercialConditionId: '1',\n dimension: {\n cubicweight: 19.665,\n height: 46.0,\n length: 45.0,\n weight: 45.0,\n width: 57.0,\n },\n offeringInfo: null,\n offeringType: null,\n offeringTypeId: null,\n },\n measurementUnit: 'un',\n unitMultiplier: 1.0,\n sellingPrice: 2299,\n isGift: false,\n shippingPrice: null,\n rewardValue: 0,\n freightCommission: 0,\n priceDefinitions: null,\n },\n ],\n marketplaceItems: [],\n clientProfileData: {\n id: 'clientProfileData',\n email: 'ana.motta@vtex.com.br',\n firstName: 'Ana Luiza',\n lastName: 'Gomes',\n documentType: 'cpf',\n document: '09498512485',\n phone: '+5583991119209',\n corporateName: null,\n tradeName: null,\n corporateDocument: null,\n stateInscription: null,\n corporatePhone: null,\n isCorporate: false,\n userProfileId: 'a8c24a30-cbab-4a16-b53c-b48489975d7e',\n customerClass: null,\n },\n giftRegistryData: null,\n marketingData: null,\n ratesAndBenefitsData: {\n id: 'ratesAndBenefitsData',\n rateAndBenefitsIdentifiers: [],\n },\n shippingData: {\n id: 'shippingData',\n address: {\n addressType: 'residential',\n receiverName: 'Ana Luiza Gomes',\n addressId: '-4564401032532',\n postalCode: '22225-800',\n city: 'Rio de Janeiro',\n state: 'RJ',\n country: 'BRA',\n street: 'Praia de Botafogo',\n number: '260',\n neighborhood: 'Botafogo',\n complement: null,\n reference: null,\n geoCoordinates: [],\n },\n logisticsInfo: [\n {\n itemIndex: 0,\n selectedSla: 'PAC',\n lockTTL: '7d',\n price: 500,\n listPrice: 500,\n sellingPrice: 500,\n deliveryWindow: null,\n deliveryCompany: 'PAC',\n shippingEstimate: '8bd',\n shippingEstimateDate: '2018-06-02T00:26:44.4700669+00:00',\n slas: [\n {\n id: 'PAC',\n name: 'PAC',\n shippingEstimate: '8bd',\n deliveryWindow: null,\n price: 500,\n deliveryChannel: 'delivery',\n pickupStoreInfo: {\n additionalInfo: null,\n address: null,\n dockId: null,\n friendlyName: null,\n isPickupStore: false,\n },\n polygonName: null,\n },\n ],\n shipsTo: ['BRA'],\n deliveryIds: [\n {\n courierId: '1',\n courierName: 'PAC',\n dockId: '1e76746',\n quantity: 1,\n warehouseId: '139edf2',\n },\n ],\n deliveryChannel: 'delivery',\n pickupStoreInfo: {\n additionalInfo: null,\n address: null,\n dockId: null,\n friendlyName: null,\n isPickupStore: false,\n },\n addressId: '-4564401032532',\n polygonName: null,\n },\n {\n itemIndex: 1,\n selectedSla: 'Econômica',\n lockTTL: '7d',\n price: 0,\n listPrice: 0,\n sellingPrice: 0,\n deliveryWindow: null,\n deliveryCompany: 'Baratex',\n shippingEstimate: '10bd',\n shippingEstimateDate: '2018-06-06T00:26:44.4700669+00:00',\n slas: [\n {\n id: 'Econômica',\n name: 'Econômica',\n shippingEstimate: '10bd',\n deliveryWindow: null,\n price: 0,\n deliveryChannel: 'delivery',\n pickupStoreInfo: {\n additionalInfo: null,\n address: null,\n dockId: null,\n friendlyName: null,\n isPickupStore: false,\n },\n polygonName: null,\n },\n {\n id: 'normal',\n name: 'normal',\n shippingEstimate: '11bd',\n deliveryWindow: null,\n price: 199,\n deliveryChannel: 'delivery',\n pickupStoreInfo: {\n additionalInfo: null,\n address: null,\n dockId: null,\n friendlyName: null,\n isPickupStore: false,\n },\n polygonName: null,\n },\n ],\n shipsTo: ['BRA'],\n deliveryIds: [\n {\n courierId: '10014ba',\n courierName: 'Baratex',\n dockId: '11d7fbf',\n quantity: 1,\n warehouseId: '14a6ebe',\n },\n ],\n deliveryChannel: 'delivery',\n pickupStoreInfo: {\n additionalInfo: null,\n address: null,\n dockId: null,\n friendlyName: null,\n isPickupStore: false,\n },\n addressId: '-4564401032532',\n polygonName: null,\n },\n ],\n trackingHints: null,\n selectedAddresses: [\n {\n addressId: '-4564401032532',\n addressType: 'residential',\n receiverName: 'Ana Luiza Gomes',\n street: 'Praia de Botafogo',\n number: '260',\n complement: null,\n neighborhood: 'Botafogo',\n postalCode: '22225-800',\n city: 'Rio de Janeiro',\n state: 'RJ',\n country: 'BRA',\n reference: null,\n geoCoordinates: [],\n },\n ],\n },\n paymentData: {\n transactions: [\n {\n isActive: true,\n transactionId: 'C84FAB684A44487CA716C49A18A6C5B6',\n merchantName: 'VTEXGAME1',\n payments: [\n {\n id: 'DD838CC148374CB48F745077A0EB405A',\n paymentSystem: '2',\n paymentSystemName: 'Visa',\n value: 6798,\n installments: 1,\n referenceValue: 6798,\n cardHolder: null,\n cardNumber: null,\n firstDigits: '444433',\n lastDigits: '1111',\n cvv2: null,\n expireMonth: null,\n expireYear: null,\n url: null,\n giftCardId: null,\n giftCardName: null,\n giftCardCaption: null,\n redemptionCode: null,\n group: 'creditCard',\n tid: '63374265',\n dueDate: null,\n connectorResponses: {\n Tid: '63374265',\n ReturnCode: null,\n Message: null,\n authId: '374265',\n },\n },\n ],\n },\n ],\n },\n packageAttachment: {\n packages: [\n {\n items: [\n {\n itemIndex: 1,\n quantity: 1,\n price: 2299,\n description: null,\n },\n ],\n courier: 'PAC',\n invoiceNumber: '1111',\n invoiceValue: 2299,\n invoiceUrl: 'www.uol.com.br',\n issuanceDate: '2018-07-27T03:00:00.0000000+00:00',\n trackingNumber: '1232213',\n invoiceKey: null,\n trackingUrl: 'facebook.com',\n embeddedInvoice: '',\n type: 'Output',\n courierStatus: {\n status: 'unknown',\n finished: true,\n data: [],\n },\n },\n {\n items: [\n {\n itemIndex: 0,\n quantity: 1,\n price: 3999,\n description: null,\n },\n ],\n courier: 'PAC',\n invoiceNumber: '1234',\n invoiceValue: 4499,\n invoiceUrl: 'www.uol.com.br',\n issuanceDate: '2018-07-27T03:00:00.0000000+00:00',\n trackingNumber: '2222',\n invoiceKey: null,\n trackingUrl: 'www.visa.com.br',\n embeddedInvoice: '',\n type: 'Output',\n courierStatus: {\n status: 'ok',\n finished: false,\n data: [],\n },\n },\n ],\n },\n sellers: [\n {\n id: '1',\n name: 'vtexgame1',\n logo: '',\n },\n ],\n callCenterOperatorData: null,\n followUpEmail: '14fb1186974c4f379123fae55cbff4db@ct.vtex.com.br',\n lastMessage: null,\n hostname: 'vtexgame1',\n invoiceData: null,\n changesAttachment: null,\n openTextField: null,\n roundingError: 0,\n orderFormId: 'b4c2f5dc1b49419fb87878a61014b522',\n commercialConditionData: null,\n isCompleted: true,\n customData: null,\n storePreferencesData: {\n countryCode: 'BRA',\n currencyCode: 'BRL',\n currencyFormatInfo: {\n CurrencyDecimalDigits: 2,\n CurrencyDecimalSeparator: ',',\n CurrencyGroupSeparator: '.',\n CurrencyGroupSize: 3,\n StartsWithCurrencySymbol: true,\n },\n currencyLocale: 1046,\n currencySymbol: 'R$',\n timeZone: 'E. South America Standard Time',\n },\n allowCancellation: false,\n allowEdition: false,\n isCheckedIn: false,\n marketplace: {\n baseURL: 'http://portal.vtexcommerce.com.br/api/oms?an=vtexgame1',\n isCertified: null,\n name: 'vtexgame1',\n },\n}\n\n```" } ]
code_my-account-commons_a0edc7ef
[ { "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 my-account-commons/react/components/GenericError.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { intlShape, injectIntl } from 'react-intl'\nimport { Alert } from 'vtex.styleguide'\n\nconst GenericError = ({ error, errorId, onDismiss, intl }) => {\n return (\n <div className=\"mb5\">\n <Alert type=\"error\" onClose={onDismiss}>\n {errorId ? intl.formatMessage({ id: errorId }) : error}\n </Alert>\n </div>\n )\n}\n\nGenericError.propTypes = {\n error: PropTypes.string,\n errorId: PropTypes.string,\n onDismiss: PropTypes.func,\n intl: intlShape.isRequired,\n}\n\nexport default injectIntl(GenericError)\n\n```" } ]
code_my-account-commons_0bcfe9f2
[ { "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 my-account-commons/react/components/ContentWrapper.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport { withRouter } from 'react-router-dom'\nimport ReactRouterPropTypes from 'react-router-prop-types'\nimport { injectIntl, intlShape } from 'react-intl'\nimport { PageHeader } from 'vtex.styleguide'\n\nimport GenericError from './GenericError'\n\nclass ContentWrapper extends Component {\n state = {\n shouldShowError: false,\n }\n\n handleError = () => {\n this.setState({ shouldShowError: true })\n }\n\n handleDismissError = () => {\n this.setState({ shouldShowError: false })\n }\n\n render() {\n const {\n children,\n intl,\n title,\n titleId,\n backButton,\n history,\n headerContent,\n namespace,\n hideBackButton = false,\n } = this.props\n const { shouldShowError } = this.state\n\n const backButtonConfigs = {\n linkLabel: backButton\n ? backButton.title\n ? backButton.title\n : intl.formatMessage({ id: backButton.titleId })\n : intl.formatMessage({ id: 'commons.back' }),\n onLinkClick: () => history.push(backButton ? backButton.path : '/'),\n }\n\n return (\n <section className=\"vtex-account__page w-100 w-80-m\">\n <header>\n <div className=\"db dn-m\">\n <PageHeader\n title={title || intl.formatMessage({ id: titleId })}\n {...backButtonConfigs}\n >\n {headerContent}\n </PageHeader>\n </div>\n <div className=\"db-m dn\">\n <PageHeader\n title={title || intl.formatMessage({ id: titleId })}\n {...(!hideBackButton && backButtonConfigs)}\n >\n {headerContent}\n </PageHeader>\n </div>\n </header>\n <main className={`vtex-account__page-body ${namespace} w-100 pa4-s`}>\n {shouldShowError && (\n <div className=\"w-100 flex justify-around\">\n <div className=\"w-50-ns w-80-s\">\n <GenericError\n onDismiss={this.handleDismissError}\n errorId=\"alert.unknownError\"\n />\n </div>\n </div>\n )}\n {children({ handleError: this.handleError })}\n </main>\n </section>\n )\n }\n}\n\nContentWrapper.propTypes = {\n intl: intlShape.isRequired,\n children: PropTypes.func.isRequired,\n namespace: PropTypes.string.isRequired,\n title: PropTypes.string,\n titleId: PropTypes.string,\n backButton: PropTypes.shape({\n title: PropTypes.string,\n titleId: PropTypes.string,\n path: PropTypes.string.isRequired,\n }),\n history: ReactRouterPropTypes.history.isRequired,\n hideBackButton: PropTypes.bool,\n headerContent: PropTypes.node,\n}\n\nexport default injectIntl(withRouter(ContentWrapper))\n\n```" } ]
code_my-account-commons_12853300
[ { "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 my-account-commons/react/components/ReloadableError.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { intlShape, injectIntl } from 'react-intl'\nimport { Alert } from 'vtex.styleguide'\n\nconst ReloadableError = ({ errorId, onReload, intl }) => {\n return (\n <Alert\n type=\"error\"\n action={{\n label: intl.formatMessage({ id: 'alert.reload' }),\n onClick: onReload,\n }}>\n {intl.formatMessage({ id: errorId })}\n </Alert>\n )\n}\n\nReloadableError.propTypes = {\n errorId: PropTypes.string.isRequired,\n onReload: PropTypes.func.isRequired,\n intl: intlShape.isRequired,\n}\n\nexport default injectIntl(ReloadableError)\n\n```" } ]
code_my-account-commons_51cdfba3
[ { "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 my-account-commons/react/components/BaseLoading.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component, Fragment } from 'react'\nimport PropTypes from 'prop-types'\n\nimport ReloadableError from './ReloadableError'\nimport ContentWrapper from './ContentWrapper'\n\nclass BaseLoading extends Component {\n state = {\n isLoading: true,\n }\n\n componentDidUpdate = prevProps => {\n if (prevProps.queryData.loading !== this.props.queryData.loading) {\n this.setState({ isLoading: false })\n }\n }\n\n handleReload = () => {\n this.setState({ isLoading: true })\n\n this.props.queryData.refetch().catch(() => {\n this.setState({ isLoading: false })\n })\n }\n\n render() {\n const { isLoading } = this.state\n const {\n headerConfig,\n children,\n queryData,\n namespace,\n parseError,\n } = this.props\n\n let errorMessageId\n if (queryData.error) {\n if (parseError) {\n errorMessageId = parseError(queryData.error)\n }\n\n if (!errorMessageId) {\n errorMessageId =\n queryData.error.toString().indexOf('not authenticated') > -1\n ? 'alert.unauthenticated'\n : 'alert.connectionError'\n }\n }\n\n const content = isLoading\n ? children\n : errorMessageId && (\n <div className=\"mt7\">\n <ReloadableError\n errorId={errorMessageId}\n onReload={this.handleReload}\n />\n </div>\n )\n\n return (\n <ContentWrapper\n namespace={namespace || 'vtex-base-loading'}\n {...headerConfig}>\n {() => <Fragment>{content}</Fragment>}\n </ContentWrapper>\n )\n }\n}\n\nconst headerConfigPropTypes = PropTypes.shape({\n title: PropTypes.string,\n titleId: PropTypes.string,\n backButton: PropTypes.shape({\n title: PropTypes.string,\n titleId: PropTypes.string,\n path: PropTypes.string.isRequired,\n }),\n headerContent: PropTypes.node,\n})\n\nBaseLoading.propTypes = {\n namespace: PropTypes.string,\n parseError: PropTypes.func,\n queryData: PropTypes.any.isRequired,\n headerConfig: headerConfigPropTypes.isRequired,\n children: PropTypes.any.isRequired,\n}\n\nexport default BaseLoading\n\n```" } ]
code_my-account-commons_acd28081
[ { "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 my-account-commons/react/__tests__/getOrderProgress.test.ts from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport packagify from '@vtex/delivery-packages'\n\nimport getOrderProgress from '../components/ProgressBar/getOrderProgress'\nimport {\n FIRST_STEP,\n SECOND_STEP,\n THIRD_STEP,\n FOURTH_STEP,\n FIFTH_STEP,\n} from '../components/ProgressBar/constants'\nimport deliveredOrder from '../mocks/NotDeliveredOrder'\nimport notDeliveredOrder from '../mocks/NotDeliveredOrder'\n\ndescribe('getOrderProgress', () => {\n it('Should return undefined when status is not mapped', () => {\n const progress = getOrderProgress('order-cancelled', [])\n expect(progress).toEqual(undefined)\n })\n\n it('Should map status order-created to the first step of the progress bar', () => {\n const progress = getOrderProgress('order-created', [])\n\n expect(progress).toEqual(FIRST_STEP)\n })\n\n it('Should map status order-completed to the first step of the progress bar', () => {\n const progress = getOrderProgress('order-completed', [])\n\n expect(progress).toEqual(FIRST_STEP)\n })\n\n it('Should map status on-order-completed to the first step of the progress bar', () => {\n const progress = getOrderProgress('on-order-completed', [])\n\n expect(progress).toEqual(FIRST_STEP)\n })\n\n it('Should map status payment-pending to the second step of the progress bar', () => {\n const progress = getOrderProgress('payment-pending', [])\n\n expect(progress).toEqual(SECOND_STEP)\n })\n\n it('Should map status approve-payment to the second step of the progress bar', () => {\n const progress = getOrderProgress('approve-payment', [])\n\n expect(progress).toEqual(SECOND_STEP)\n })\n\n it('Should map status payment-approved to the third step of the progress bar', () => {\n const progress = getOrderProgress('payment-approved', [])\n\n expect(progress).toEqual(THIRD_STEP)\n })\n\n it('Should map status ready-for-handling to the third step of the progress bar', () => {\n const progress = getOrderProgress('ready-for-handling', [])\n\n expect(progress).toEqual(THIRD_STEP)\n })\n\n it('Should map status authorize-fullfilment to the third step of the progress bar', () => {\n const progress = getOrderProgress('authorize-fullfilment', [])\n\n expect(progress).toEqual(THIRD_STEP)\n })\n\n it('Should map status release-to-fullfilment to the third step of the progress bar', () => {\n const progress = getOrderProgress('release-to-fulfillment', [])\n\n expect(progress).toEqual(THIRD_STEP)\n })\n\n it('Should map status handling to the third step of the progress bar', () => {\n const progress = getOrderProgress('handling', [])\n\n expect(progress).toEqual(THIRD_STEP)\n })\n\n it('Should map status invoice to the third step of the progress bar', () => {\n const progress = getOrderProgress('invoice', [])\n\n expect(progress).toEqual(THIRD_STEP)\n })\n\n it('Should map status invoiced to the fourth step of the progress bar', () => {\n const progress = getOrderProgress('invoiced', [])\n\n expect(progress).toEqual(FOURTH_STEP)\n })\n\n it('Should map to the fifth step of the progress bar since all packages were delivered and its status is invoiced', () => {\n const packages = packagify(deliveredOrder)\n\n const progress = getOrderProgress(deliveredOrder.status, packages)\n\n expect(progress).toEqual(FOURTH_STEP)\n })\n\n it('Should map to the fourth step of the progress bar since all packages were not delivered even though its status is invoiced', () => {\n const packages = packagify(notDeliveredOrder)\n\n const progress = getOrderProgress(notDeliveredOrder.status, packages)\n\n expect(progress).toEqual(FOURTH_STEP)\n })\n it('Should return FIFTH_STEP since all packages have courierStatus.data with length greater than 1', () => {\n const packages = [\n {\n items: [[Object]],\n package: {\n items: [Array],\n invoiceNumber: '243433',\n invoiceValue: 5699,\n invoiceUrl: '',\n trackingNumber: '423243423',\n trackingUrl: 'http://ufcg.edu.br',\n courierStatus: {\n status: 'unknown',\n finished: false,\n data: [\n {\n lastChange: '2015-06-23T00:00:00.0000000+00:00',\n city: 'Rio de Janeiro',\n state: 'RJ',\n description: 'Coletado pela transportadora',\n },\n ],\n },\n index: 0,\n },\n item: undefined,\n },\n ]\n\n const progress = getOrderProgress('invoiced', packages)\n\n expect(progress).toEqual(FIFTH_STEP)\n })\n\n it('Should return FOURTH_STEP since there are packages that do not have courierStatus.data with length greater than 1', () => {\n const packages = [\n {\n package: {\n trackingNumber: '423243423',\n trackingUrl: 'http://ufcg.edu.br',\n type: 'Output',\n courierStatus: {\n status: 'unknown',\n finished: false,\n data: [\n {\n lastChange: '2015-06-23T00:00:00.0000000+00:00',\n city: 'Rio de Janeiro',\n state: 'RJ',\n description: 'Coletado pela transportadora',\n },\n ],\n },\n index: 0,\n },\n item: undefined,\n },\n {\n items: [[Object]],\n package: {\n invoiceNumber: '243433',\n trackingNumber: '423243423',\n trackingUrl: 'http://ufcg.edu.br',\n courierStatus: null,\n index: 0,\n },\n item: undefined,\n },\n ]\n\n const progress = getOrderProgress('invoiced', packages)\n\n expect(progress).toEqual(FOURTH_STEP)\n })\n})\n\n```" } ]
code_my-account-commons_b0d6ce85
[ { "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 my-account-commons/react/__tests__/getPackageProgress.test.ts from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {\n FIRST_STEP,\n SECOND_STEP,\n THIRD_STEP,\n} from '../components/ProgressBar/constants'\n\nimport getPackageProgress from '../components/ProgressBar/PackageProgressBar/getPackageProgress'\nimport deliveredOrder from '../mocks/DeliveredOrder'\nimport notDeliveredOrder from '../mocks/NotDeliveredOrder'\n\ndescribe('getPackageProgress', () => {\n it('Should return null when the order has less than 2 packages', () => {\n const pack = {\n courier: 'Teste CHECKOUT Sedex',\n trackingNumber: '4132244343',\n invoiceKey: null,\n trackingUrl: 'vtex.com.br',\n courierStatus: {\n status: 'unknown',\n finished: true,\n data: [],\n },\n }\n expect(getPackageProgress(pack, notDeliveredOrder.status, [pack])).toEqual(\n null\n )\n })\n\n it('Should return null when the order progress bar hasnt get to the third step yet', () => {\n expect(\n getPackageProgress(\n deliveredOrder.packageAttachment.packages[0],\n 'payment-pending',\n deliveredOrder.packageAttachment.packages\n )\n ).toEqual(null)\n })\n\n it('Should return FIRST_STEP when the package does not have courierStatus as finished, nor trackingUrl and trackingNumber ', () => {\n const pack = {\n items: [\n {\n itemIndex: 1,\n quantity: 1,\n price: 3300,\n description: null,\n },\n ],\n courier: 'Transportadora',\n trackingNumber: null,\n trackingUrl: null,\n courierStatus: {\n status: 'unknown',\n finished: false,\n data: [],\n },\n }\n expect(\n getPackageProgress(\n pack,\n deliveredOrder.status,\n deliveredOrder.packageAttachment.packages\n )\n ).toEqual(FIRST_STEP)\n })\n\n it('Should return SECOND_STEP when package has trackingUrl or trackingNumber', () => {\n const pack = {\n items: [\n {\n itemIndex: 1,\n quantity: 1,\n price: 3300,\n description: null,\n },\n ],\n courier: 'Transportadora',\n trackingUrl: 'jadlog.com.br',\n trackingNumber: '24343',\n courierStatus: {\n status: 'unknown',\n finished: false,\n data: [],\n },\n }\n expect(\n getPackageProgress(\n pack,\n deliveredOrder.status,\n deliveredOrder.packageAttachment.packages\n )\n ).toEqual(SECOND_STEP)\n })\n\n it('Should return THIRD_STEP when package has courierStatus as finished', () => {\n const pack = {\n items: [\n {\n itemIndex: 1,\n quantity: 1,\n price: 3300,\n description: null,\n },\n ],\n courier: 'Transportadora',\n trackingUrl: null,\n trackingNumber: null,\n courierStatus: {\n status: 'unknown',\n finished: true,\n data: [],\n },\n }\n\n expect(\n getPackageProgress(\n pack,\n deliveredOrder.status,\n deliveredOrder.packageAttachment.packages\n )\n ).toEqual(THIRD_STEP)\n })\n})\n\n```" } ]
code_my-account-commons_85e0ecea
[ { "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 my-account-commons/react/__tests__/transformStates.test.ts from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport transformStates from '../components/ProgressBar/transformStates'\n\ndescribe('transformStates', () => {\n it('Should return the right states when the number of input states is even', () => {\n const states = [\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n {\n todo: 'order.progress.approvePayment',\n done: 'order.progress.paymentApproved',\n doing: 'order.progress.approvingPayment',\n },\n ]\n\n const transformedStates = [\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n originalIndex: 0,\n },\n { isLine: true, originalIndex: 0 },\n {\n todo: 'order.progress.approvePayment',\n done: 'order.progress.paymentApproved',\n doing: 'order.progress.approvingPayment',\n originalIndex: 1,\n },\n ]\n expect(transformStates(states)).toEqual(transformedStates)\n })\n it('Should return the right states when the number of input states is odd', () => {\n const states = [\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n {\n todo: 'order.progress.approvePayment',\n done: 'order.progress.paymentApproved',\n doing: 'order.progress.approvingPayment',\n },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n ]\n\n const transformedStates = [\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n originalIndex: 0,\n },\n { isLine: true, originalIndex: 0 },\n {\n todo: 'order.progress.approvePayment',\n done: 'order.progress.paymentApproved',\n doing: 'order.progress.approvingPayment',\n originalIndex: 1,\n },\n { isLine: true, originalIndex: 1 },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n originalIndex: 2,\n },\n ]\n expect(transformStates(states)).toEqual(transformedStates)\n })\n\n it('Should return the right states when the the length of the input states is 7', () => {\n const states = [\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n {\n todo: 'order.progress.approvePayment',\n done: 'order.progress.paymentApproved',\n doing: 'order.progress.approvingPayment',\n },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n {\n todo: 'order.progress.approvePayment',\n done: 'order.progress.paymentApproved',\n doing: 'order.progress.approvingPayment',\n },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n ]\n\n const transformedStates = [\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n originalIndex: 0,\n },\n { isLine: true, originalIndex: 0 },\n {\n todo: 'order.progress.approvePayment',\n done: 'order.progress.paymentApproved',\n doing: 'order.progress.approvingPayment',\n originalIndex: 1,\n },\n { isLine: true, originalIndex: 1 },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n originalIndex: 2,\n },\n { isLine: true, originalIndex: 2 },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n originalIndex: 3,\n },\n { isLine: true, originalIndex: 3 },\n {\n todo: 'order.progress.approvePayment',\n done: 'order.progress.paymentApproved',\n doing: 'order.progress.approvingPayment',\n originalIndex: 4,\n },\n { isLine: true, originalIndex: 4 },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n originalIndex: 5,\n },\n { isLine: true, originalIndex: 5 },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n originalIndex: 6,\n },\n ]\n expect(transformStates(states)).toEqual(transformedStates)\n })\n\n it('Should return the right states when the the length of the input states is 10', () => {\n const states = [\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n {\n todo: 'order.progress.approvePayment',\n done: 'order.progress.paymentApproved',\n doing: 'order.progress.approvingPayment',\n },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n {\n todo: 'order.progress.approvePayment',\n done: 'order.progress.paymentApproved',\n doing: 'order.progress.approvingPayment',\n },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n ]\n\n const transformedStates = [\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n originalIndex: 0,\n },\n { isLine: true, originalIndex: 0 },\n {\n todo: 'order.progress.approvePayment',\n done: 'order.progress.paymentApproved',\n doing: 'order.progress.approvingPayment',\n originalIndex: 1,\n },\n { isLine: true, originalIndex: 1 },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n originalIndex: 2,\n },\n { isLine: true, originalIndex: 2 },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n originalIndex: 3,\n },\n { isLine: true, originalIndex: 3 },\n {\n todo: 'order.progress.approvePayment',\n done: 'order.progress.paymentApproved',\n doing: 'order.progress.approvingPayment',\n originalIndex: 4,\n },\n { isLine: true, originalIndex: 4 },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n originalIndex: 5,\n },\n { isLine: true, originalIndex: 5 },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n originalIndex: 6,\n },\n { isLine: true, originalIndex: 6 },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n originalIndex: 7,\n },\n { isLine: true, originalIndex: 7 },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n originalIndex: 8,\n },\n { isLine: true, originalIndex: 8 },\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n originalIndex: 9,\n },\n ]\n expect(transformStates(states)).toEqual(transformedStates)\n })\n})\n\n```" } ]
code_my-account-commons_7043f2a6
[ { "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 my-account-commons/react/__tests__/utils.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport utils from '../utils'\n\ndescribe('estimateShipping', () => {\n it('with unit as days should return the correct payload', () => {\n const currentDate = new Date()\n const mockDeliveryPackage = {\n shippingEstimate: '1d',\n shippingEstimateDate: currentDate,\n }\n\n const response = utils.estimateShipping(mockDeliveryPackage)\n\n expect(response.date).toBe(currentDate)\n expect(response.isEstimateInHoursOrMinutes).toBe(false)\n })\n\n it('with unit as hours should return the correct payload', () => {\n const currentDate = new Date()\n const mockDeliveryPackage = {\n shippingEstimate: '1h',\n shippingEstimateDate: currentDate,\n }\n\n const response = utils.estimateShipping(mockDeliveryPackage)\n\n expect(response.date).toBe(currentDate)\n expect(response.isEstimateInHoursOrMinutes).toBe(true)\n })\n\n it('with only shippingEstimate the correct payload', () => {\n const currentDate = new Date()\n const value = '1'\n const type = 'h'\n const mockDeliveryPackage = {\n shippingEstimate: `${value}${type}`,\n }\n\n const response = utils.estimateShipping(mockDeliveryPackage)\n\n expect(response.unit).toBe(parseInt(value))\n expect(response.type).toBe(type)\n expect(response.label).not.toBeNull()\n })\n\n it('with only shippingEstimateDate returns the correct payload', () => {\n const currentDate = new Date()\n const mockDeliveryPackage = {\n shippingEstimateDate: currentDate,\n }\n\n const response = utils.estimateShipping(mockDeliveryPackage)\n\n expect(response.date).toBe(currentDate)\n })\n\n it('without info returns null', () => {\n const mockedDeliveryPackage = {}\n\n const response = utils.estimateShipping(mockedDeliveryPackage)\n\n expect(response).toBeNull()\n })\n\n it('with empty shippingEstimate unit should return shippingEstimateDate', () => {\n const currentDate = new Date()\n const mockDeliveryPackage = {\n shippingEstimate: '1',\n shippingEstimateDate: currentDate,\n }\n\n const response = utils.estimateShipping(mockDeliveryPackage)\n\n expect(response.date).toBe(currentDate)\n })\n})\n\n```" } ]
code_my-account-commons_a98e0d87
[ { "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 my-account-commons/react/components/ProgressBar/getNamespace.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nexport default function getNamespace(isPackage) {\n return `myo-${isPackage ? 'package-' : ''}progress-bar`\n}\n\n```" } ]
code_my-account-commons_288a6d66
[ { "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 my-account-commons/react/components/ProgressBar/OrderStatus.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component, Fragment } from 'react'\nimport PropTypes from 'prop-types'\n\nimport getOrderProgress from './getOrderProgress'\n\nclass OrderStatus extends Component {\n render() {\n const { status, packages, render } = this.props\n return <Fragment>{render(getOrderProgress(status, packages))}</Fragment>\n }\n}\n\nOrderStatus.propTypes = {\n render: PropTypes.func.isRequired,\n status: PropTypes.string.isRequired,\n packages: PropTypes.arrayOf(PropTypes.object),\n}\n\nexport default OrderStatus\n\n```" } ]
code_my-account-commons_37561f78
[ { "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 my-account-commons/react/components/ProgressBar/ProgressBarSection.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport ProgressBar from './ProgressBar'\nimport { intlShape, injectIntl } from 'react-intl'\n\nclass ProgressBarSection extends Component {\n render() {\n const { currentState, states, intl, hasFinished } = this.props\n if (!currentState) return null\n return (\n <div className=\"myo-progress-bar w-100 h4-plus pb9 ph5 fl b--muted-5 bw1 ba\">\n <div className=\"myo-progress-bar__title-font c-on-base mt2 mb5 tracked-mega lh-solid ttu f6 pt5\">\n <span>\n {intl.formatMessage({\n id: 'progressBar.order.status',\n })}\n </span>\n </div>\n <div className=\"pt7\">\n <ProgressBar\n states={states}\n currentState={currentState}\n hasFinished={hasFinished}\n />\n </div>\n </div>\n )\n }\n}\n\nProgressBarSection.propTypes = {\n currentState: PropTypes.number,\n states: PropTypes.array.isRequired,\n intl: intlShape.isRequired,\n hasFinished: PropTypes.bool,\n}\n\nexport default injectIntl(ProgressBarSection)\n\n```" } ]
code_my-account-commons_999c7ccf
[ { "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 my-account-commons/react/components/ProgressBar/utils.ts from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { FIFTH_STEP, progressBarStates, THIRD_STEP } from './constants'\nimport getOrderProgress from './getOrderProgress'\n\nconst OutputPackageType = 'Output'\n\nexport function generateProgressBarStates(\n progressBarStates: any[],\n currentState: number,\n packages: any\n) {\n const wasDelivered = isDelivered(packages)\n const isPickup = isOrderPickUp(packages)\n\n return progressBarStates.map((_state, index) => {\n let label\n const state = _state.pickup\n ? isPickup\n ? _state.pickup\n : _state.shipping\n : _state\n\n if (index < currentState) {\n label = state.done\n } else if (index === currentState) {\n if (index === FIFTH_STEP && wasDelivered) {\n label = state.done\n } else {\n label = state.doing\n }\n } else {\n label = state.todo\n }\n\n return {\n ...state,\n label: label,\n }\n })\n}\n\nexport function getCurrentProgressBarState(status: string, packages: any) {\n const currentProgressIndex = getOrderProgress(status, packages)\n\n const generatedProgressBarStates = generateProgressBarStates(\n progressBarStates,\n currentProgressIndex,\n packages\n )\n\n return generatedProgressBarStates[currentProgressIndex]?.label\n}\n\nexport function isDelivered(packages: any) {\n if (packages == null || packages.length === 0) {\n return false\n }\n\n const isDelivered = !packages.some(\n (pack: any) => {\n if (!pack?.package) return true // In case you can't tell whether the invoice is input or output, the order as a whole should be considered as not delivered.\n\n return pack?.package?.type === OutputPackageType &&\n !pack?.package?.courierStatus?.finished\n })\n\n return isDelivered\n}\n\nexport function generatePackageProgressBarStates(\n states: any,\n currentState: any,\n pack: any\n) {\n return states.map((state: any, index: number) => {\n let label = null\n if (\n index === THIRD_STEP &&\n currentState === THIRD_STEP &&\n pack.courierStatus &&\n pack.courierStatus.finished === true\n ) {\n label = state.done\n } else if (currentState === index) {\n label = state.doing\n } else if (currentState > index) {\n label = state.done\n } else {\n label = state.todo\n }\n return {\n ...state,\n label: label,\n }\n })\n}\n\nexport function isOrderReadyToPickUp(packages: any) {\n if (packages == null || packages.length === 0) return false\n\n return packages.every((item: any) => {\n const isPickUp = item.deliveryChannel === 'pickup-in-point'\n const isReadyToPickUp =\n !item.shippingEstimateDate ||\n Date.now() >= new Date(item.shippingEstimateDate).getTime()\n return isPickUp && isReadyToPickUp\n })\n}\n\nexport function isOrderPickUp(packages: any) {\n if (packages == null || packages.length === 0) return false\n\n return packages.every((pck: any) => pck.deliveryChannel === 'pickup-in-point')\n}\n\n```" } ]
code_my-account-commons_62bf5f97
[ { "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 my-account-commons/react/components/ProgressBar/ConcludedLine.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nconst ConcludedLine = ({ isPackage }) => (\n <div\n className={`${\n isPackage\n ? 'myo-package-progress-bar__line w3-ns w-50'\n : 'myo-progress-bar__line w-20'\n } myo-progress-bar__height1 bt bw1 b--success mt5`}\n />\n)\n\nConcludedLine.propTypes = {\n isPackage: PropTypes.bool,\n}\n\nexport default ConcludedLine\n\n```" } ]
code_my-account-commons_1db75115
[ { "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 my-account-commons/react/components/ProgressBar/CurrentCircle.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { intlShape, injectIntl } from 'react-intl'\n\nimport getNamespace from './getNamespace'\n\nconst CurrentCircle = ({ label, intl, isPackage }) => (\n <div\n className={`relative z-0 ${getNamespace(\n isPackage\n )}__margin flex items-center flex-column ma3 br-100`}>\n <div\n className={`br-100 mb2 myo-progress-bar__height1 w1 relative ba b--white bw1 ${\n isPackage ? 'myo-package-progress-bar' : 'myo-progress-bar'\n }__ma-inner-circle c-success bg-success`}\n />\n <div className=\"absolute myo-progress-bar__highlighted-circle myo-progress-bar__subtitle mt5 pa3 tc f6\">\n <span className={`${getNamespace(isPackage)}__text c-on-base`}>\n {intl.formatMessage({\n id: label,\n })}\n </span>\n </div>\n </div>\n)\n\nCurrentCircle.propTypes = {\n label: PropTypes.string.isRequired,\n isPackage: PropTypes.bool,\n intl: intlShape.isRequired,\n}\n\nexport default injectIntl(CurrentCircle)\n\n```" } ]
code_my-account-commons_fbdd6b31
[ { "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 my-account-commons/react/components/ProgressBar/getOrderProgress.ts from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {\n FIRST_STEP,\n SECOND_STEP,\n THIRD_STEP,\n FOURTH_STEP,\n FIFTH_STEP,\n} from './constants'\nimport { isDelivered, isOrderPickUp, isOrderReadyToPickUp } from './utils'\n\ninterface StatusMap {\n 'order-created': number\n 'order-completed': number\n 'on-order-completed': number\n 'payment-pending': number\n 'window-to-cancel': number\n 'approve-payment': number\n 'payment-approved': number\n 'ready-for-handling': number\n 'authorize-fullfilment': number\n 'release-to-fulfillment': number\n handling: number\n invoice: number\n invoiced: number\n [key: string]: number\n}\n\nconst statusMap: StatusMap = {\n 'order-created': FIRST_STEP,\n 'order-completed': FIRST_STEP,\n 'on-order-completed': FIRST_STEP,\n 'payment-pending': SECOND_STEP,\n 'window-to-cancel': THIRD_STEP,\n 'approve-payment': SECOND_STEP,\n 'payment-approved': THIRD_STEP,\n 'ready-for-handling': THIRD_STEP,\n 'authorize-fullfilment': THIRD_STEP,\n 'release-to-fulfillment': THIRD_STEP,\n handling: THIRD_STEP,\n invoice: THIRD_STEP,\n invoiced: FOURTH_STEP,\n}\n\nfunction isCarrierHandling(packages: any) {\n if (packages == null || packages.length === 0) return false\n\n return packages.every(\n (pck: any) => pck.package?.courierStatus?.data?.length > 0\n )\n}\n\nexport default function getOrderProgress(status: string, packages: any) {\n let progress = statusMap[status]\n const isPickup = isOrderPickUp(packages)\n if (progress === FOURTH_STEP) {\n if (\n isDelivered(packages) ||\n (isPickup && isOrderReadyToPickUp(packages)) ||\n (!isPickup && isCarrierHandling(packages))\n ) {\n progress = FIFTH_STEP\n }\n }\n return progress\n}\n\n```" } ]
code_my-account-commons_e3d09cb7
[ { "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 my-account-commons/react/components/ProgressBar/transformStates.ts from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport default function transformStates(states: any) {\n const newStates = states.reduce((acc: any, state: any, index: number) => {\n return index === states.length - 1\n ? acc.concat({ ...state, originalIndex: index })\n : acc.concat(\n { ...state, originalIndex: index },\n { isLine: true, originalIndex: index }\n )\n }, [])\n\n return newStates\n}\n\n```" } ]
code_my-account-commons_b8a901ab
[ { "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 my-account-commons/react/components/ProgressBar/constants.ts from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport const ACTIVE = 'ACTIVE'\n\nexport const FIRST_STEP = 0\nexport const SECOND_STEP = 1\nexport const THIRD_STEP = 2\nexport const FOURTH_STEP = 3\nexport const FIFTH_STEP = 4\n\nexport const progressBarStates = [\n {\n todo: 'order.progress.confirmOrder',\n done: 'order.progress.orderConfirmed',\n doing: 'order.progress.confirmingOrder',\n },\n {\n todo: 'order.progress.approvePayment',\n done: 'order.progress.paymentApproved',\n doing: 'order.progress.approvingPayment',\n },\n {\n todo: 'order.progress.handleShipping',\n done: 'order.progress.shippingHandled',\n doing: 'order.progress.handlingShipping',\n },\n {\n shipping: {\n todo: 'order.progress.deliverToCarrier',\n done: 'order.progress.delivered',\n doing: 'order.progress.delivering',\n },\n pickup: {\n todo: 'order.progress.deliverToPickup',\n done: 'order.progress.deliveredToPickup',\n doing: 'order.progress.deliveringToPickup',\n },\n },\n {\n shipping: {\n todo: 'order.progress.ship',\n done: 'order.progress.shipped',\n doing: 'order.progress.shipping',\n },\n pickup: {\n todo: 'order.progress.pickup',\n done: 'order.state.pickedUp',\n doing: 'order.state.ready-for-pickup',\n },\n },\n]\n\nexport const packageProgressBarStates = [\n {\n todo: 'package.progress.handleShipping',\n done: 'package.progress.shippingHandled',\n doing: 'package.progress.handlingShipping',\n },\n {\n todo: 'package.progress.deliverToCarrier',\n done: 'package.progress.delivered',\n doing: 'package.progress.delivering',\n },\n {\n todo: 'package.progress.ship',\n done: 'package.progress.shipped',\n doing: 'package.progress.shipping',\n },\n]\n\n```" } ]
code_my-account-commons_4baa2132
[ { "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 my-account-commons/react/components/ProgressBar/ProgressBar.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\n\nimport UnconcludedLine from './UnconcludedLine'\nimport ConcludedLine from './ConcludedLine'\nimport CurrentCircle from './CurrentCircle'\nimport ConcludedCircle from './ConcludedCircle'\nimport UnconcludedCircle from './UnconcludedCircle'\nimport Caption from './Caption'\nimport transformStates from './transformStates'\nimport { FIFTH_STEP } from './constants'\n\nclass ProgressBar extends Component {\n render() {\n const { states, currentState, hasFinished } = this.props\n if (!currentState) return null\n const progressStates = transformStates(states)\n return (\n <div className=\"myo-progress-bar\">\n <div className=\"myo-progress-bar__mobile-text\">\n <Caption\n numberOfStates={states.length}\n currentState={currentState}\n progressStates={progressStates}\n />\n </div>\n <div className=\"flex justify-center\">\n {progressStates.map((state, index) => {\n if (state.isLine) {\n return currentState > state.originalIndex ? (\n <ConcludedLine key={index} />\n ) : (\n <UnconcludedLine key={index} />\n )\n }\n\n if (\n currentState > state.originalIndex ||\n (hasFinished && currentState === FIFTH_STEP)\n ) {\n return <ConcludedCircle key={index} label={state.label} />\n } else if (currentState === state.originalIndex) {\n return <CurrentCircle key={index} label={state.label} />\n }\n return <UnconcludedCircle key={index} label={state.label} />\n })}\n </div>\n </div>\n )\n }\n}\n\nProgressBar.propTypes = {\n currentState: PropTypes.number.isRequired,\n states: PropTypes.array.isRequired,\n hasFinished: PropTypes.bool,\n}\n\nexport default ProgressBar\n\n```" } ]
code_my-account-commons_e224a1a0
[ { "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 my-account-commons/react/components/ProgressBar/Caption.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport { intlShape, injectIntl } from 'react-intl'\nimport PropTypes from 'prop-types'\n\nclass Caption extends Component {\n render() {\n const { currentState, progressStates, numberOfStates, intl } = this.props\n return (\n <div className=\"flex\">\n <div style={{ width: `${(currentState / 2) * 100}%` }} />\n <div className=\"flex-grow-1 tc nowrap\">\n <span className=\"db b c-link hover-c-link c-link--visited\">\n {intl.formatMessage({\n id: progressStates.find(\n state => state.originalIndex === currentState\n ).label,\n })}\n </span>\n </div>\n <div\n style={{\n width: `${(1 - currentState / (numberOfStates - 1)) * 100}%`,\n }}\n />\n </div>\n )\n }\n}\n\nCaption.propTypes = {\n currentState: PropTypes.number,\n progressStates: PropTypes.array.isRequired,\n intl: intlShape.isRequired,\n numberOfStates: PropTypes.number.isRequired,\n}\n\nexport default injectIntl(Caption)\n\n```" } ]
code_my-account-commons_1f9ef5c9
[ { "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 my-account-commons/react/components/ProgressBar/UnconcludedLine.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nconst UnconcludedLine = ({ isPackage }) => {\n return (\n <div\n className={`${\n isPackage\n ? 'myo-package-progress-bar__line w3-ns w-50'\n : 'myo-progress-bar__line w-20'\n } myo-progress-bar__height1 bt bw1 b--muted-3 mt5`}\n />\n )\n}\n\nUnconcludedLine.propTypes = {\n isPackage: PropTypes.bool,\n}\n\nexport default UnconcludedLine\n\n```" } ]
code_my-account-commons_a716108c
[ { "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 my-account-commons/react/components/ProgressBar/ConcludedCircle.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { intlShape, injectIntl } from 'react-intl'\n\nimport getNamespace from './getNamespace'\n\nconst ConcludedCircle = ({ label, intl, isPackage }) => (\n <div\n className={`relative flex items-center flex-column br-100 myo-progress-bar__height1 ${\n isPackage\n ? 'myo-package-progress-bar__circle myo-package-progress-bar__margin'\n : 'myo-progress-bar__circle mh2'\n } w1 bg-success ba b--white bw1 mv3 `}>\n <div className=\"myo-progress-bar__subtitle mt5 pa3 tc f6\">\n <span className={`c-on-base ${getNamespace(isPackage)}__text`}>\n {intl.formatMessage({\n id: label,\n })}\n </span>\n </div>\n </div>\n)\n\nConcludedCircle.propTypes = {\n label: PropTypes.string.isRequired,\n intl: intlShape.isRequired,\n isPackage: PropTypes.bool,\n}\n\nexport default injectIntl(ConcludedCircle)\n\n```" } ]
code_my-account-commons_5b0ee223
[ { "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 my-account-commons/react/components/ProgressBar/UnconcludedCircle.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport { intlShape, injectIntl } from 'react-intl'\nimport PropTypes from 'prop-types'\n\nimport getNamespace from './getNamespace'\n\nconst UnconcludedCircle = ({ label, intl, isPackage }) => (\n <div\n className={`relative flex items-center flex-column br-100 myo-progress-bar__height1 w1 ${\n isPackage\n ? 'myo-package-progress-bar__circle myo-package-progress-bar__margin'\n : 'myo-progress-bar__circle'\n } bg-muted-3 ba b--white bw1 mv3 mh2`}>\n <div className=\"myo-progress-bar__subtitle mt5 pa3 tc f6\">\n <span className={`c-muted-3 ${getNamespace(isPackage)}__text`}>\n {intl.formatMessage({\n id: label,\n })}\n </span>\n </div>\n </div>\n)\n\nUnconcludedCircle.propTypes = {\n label: PropTypes.string.isRequired,\n intl: intlShape.isRequired,\n isPackage: PropTypes.bool,\n}\n\nexport default injectIntl(UnconcludedCircle)\n\n```" } ]
code_my-account-commons_423e97a3
[ { "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 my-account-commons/react/components/ProgressBar/PackageProgressBar/PackageProgressBarSection.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport { intlShape, injectIntl } from 'react-intl'\nimport transformStates from '../transformStates'\nimport PackageProgressBar from './PackageProgressBar'\n\nclass PackageProgressBarSection extends Component {\n render() {\n const { currentState, states } = this.props\n const progressStates = transformStates(states)\n if (currentState === null) return null\n return (\n <div className=\"myo-progress-bar pl6-l flex-column pt4-s pt0-l flex flex-row-l bl-l b--muted-5\">\n <div className=\"tl-m tl-s pr3 myo-package-progress-bar__line-height\">\n <span className=\"myo-package-progress-bar__maxWidth db f7 b--muted-3\">\n {this.props.intl.formatMessage({\n id: 'progressBar.package.progress',\n })}\n </span>\n <span className=\"myo-package-progress-bar__maxWidth db f7 b b--emphasis\">\n {this.props.intl.formatMessage({\n id: progressStates.find(\n state => state.originalIndex === currentState\n ).label,\n })}\n </span>\n </div>\n <PackageProgressBar currentState={currentState} states={states} />\n </div>\n )\n }\n}\n\nPackageProgressBarSection.propTypes = {\n currentState: PropTypes.number,\n states: PropTypes.array.isRequired,\n intl: intlShape.isRequired,\n}\n\nexport default injectIntl(PackageProgressBarSection)\n\n```" } ]
code_my-account-commons_8109c2f2
[ { "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 my-account-commons/react/components/ProgressBar/PackageProgressBar/PackageProgressBar.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component, Fragment } from 'react'\nimport PropTypes from 'prop-types'\nimport { intlShape, injectIntl } from 'react-intl'\n\nimport ConcludedCircle from '../ConcludedCircle'\nimport CurrentCircle from '../CurrentCircle'\nimport UnconcludedLine from '../UnconcludedLine'\nimport UnconcludedCircle from '../UnconcludedCircle'\nimport ConcludedLine from '../ConcludedLine'\nimport Caption from '../Caption'\nimport transformStates from '../transformStates'\n\nclass PackageProgressBar extends Component {\n render() {\n const { currentState, states } = this.props\n if (currentState == null) return null\n const progressStates = transformStates(states)\n return (\n <Fragment>\n <div className=\"myo-progress-bar flex w-100 mv2-s ml7-l\">\n {progressStates.map((state, index) => {\n if (state.isLine) {\n return currentState > state.originalIndex ? (\n <ConcludedLine isPackage key={index} />\n ) : (\n <UnconcludedLine isPackage key={index} />\n )\n }\n if (currentState === state.originalIndex) {\n return <CurrentCircle key={index} isPackage label={state.label} />\n }\n if (currentState > state.originalIndex) {\n return (\n <ConcludedCircle key={index} isPackage label={state.label} />\n )\n }\n return (\n <UnconcludedCircle key={index} isPackage label={state.label} />\n )\n })}\n </div>\n {currentState != null && (\n <div className=\"caption\">\n <Caption\n numberOfStates={states.length}\n currentState={currentState}\n progressStates={progressStates}\n />\n </div>\n )}\n </Fragment>\n )\n }\n}\n\nPackageProgressBar.propTypes = {\n currentState: PropTypes.number,\n states: PropTypes.array.isRequired,\n intl: intlShape.isRequired,\n}\n\nexport default injectIntl(PackageProgressBar)\n\n```" } ]
code_my-account-commons_f5a3b459
[ { "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 my-account-commons/react/components/ProgressBar/PackageProgressBar/getPackageProgress.ts from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { FIRST_STEP, SECOND_STEP, THIRD_STEP } from '../constants'\nimport getOrderProgress from '../getOrderProgress'\n\nexport default function getPackageProgress(\n pack: any,\n orderStatus: any,\n orderPackages: any\n) {\n if (\n getOrderProgress(orderStatus, orderPackages) < THIRD_STEP ||\n orderPackages.length < 2 ||\n !pack\n ) {\n return null\n }\n if (pack.courierStatus && pack.courierStatus.finished) {\n return THIRD_STEP\n }\n if (pack.trackingUrl || pack.trackingNumber) {\n return SECOND_STEP\n }\n return FIRST_STEP\n}\n\n```" } ]
code_my-account-commons_995641e9
[ { "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 my-account-commons/react/components/ProgressBar/PackageProgressBar/PackageStatus.js from the my-account-commons VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component, Fragment } from 'react'\nimport PropTypes from 'prop-types'\nimport getPackageProgress from './getPackageProgress'\n\nclass PackageStatus extends Component {\n render() {\n const { pack, status, packages, render } = this.props\n return (\n <Fragment>{render(getPackageProgress(pack, status, packages))}</Fragment>\n )\n }\n}\n\nPackageStatus.propTypes = {\n pack: PropTypes.any,\n render: PropTypes.func.isRequired,\n status: PropTypes.string.isRequired,\n packages: PropTypes.array.isRequired,\n}\n\nexport default PackageStatus\n\n```" } ]
code_glovo-integration_01abc629
[ { "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 glovo-integration/messages/en.json from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/glovo-integration.settings-title\": \"Glovo Integration\",\n \"admin/glovo-integration.settings.loading\": \"Loading application settings...\",\n \"admin/glovo-integration.settings.error\": \"Unable to retrieve application settings\",\n \"admin/glovo-integration.store-name\": \"Store name\",\n \"admin/glovo-integration.seller-id\": \"Seller ID\",\n \"admin/glovo-integration.seller-name\": \"Seller Name\",\n \"admin/glovo-integration.affiliate-id\": \"Affiliate ID\",\n \"admin/glovo-integration.sales-channel\": \"Sales Channel\",\n \"admin/glovo-integration.postal-code\": \"Postal Code\",\n \"admin/glovo-integration.country\": \"Country\",\n \"admin/glovo-integration.glovo-store-id\": \"Glovo Store ID\",\n\n \"admin/glovo-integration.table.title\": \"Stores\",\n \"admin/glovo-integration.table.subtitle\": \"List of stores integrated with the Glovo app\",\n \"admin/glovo-integration.table.edit-store\": \"Edit store\",\n \"admin/glovo-integration.table.remove-store\": \"Remove store\",\n \"admin/glovo-integration.table.empty\": \"There are no stores configured\",\n \"admin/glovo-integration.table.show-rows\": \"Show rows\",\n \"admin/glovo-integration.table.of\": \"of\",\n \"admin/glovo-integration.table.all\": \"All\",\n \"admin/glovo-integration.table.none\": \"None\",\n \"admin/glovo-integration.table.clear-all\": \"Clear all\",\n \"admin/glovo-integration.table.more-options\": \"more options\",\n \"admin/glovo-integration.table.apply\": \"Apply\",\n\n \"admin/glovo-integration.integration-settings.title\": \"Integration Settings\",\n \"admin/glovo-integration.integration-settings.subtitle\": \"Glovo integration settings\",\n \"admin/glovo-integration.integration-settings.glovo-token.description\": \"Token to perform calls to the Glovo API\",\n \"admin/glovo-integration.integration-settings.glovo-token\": \"Glovo Token *\",\n \"admin/glovo-integration.integration-settings.marketplace.description\": \"Toggle to use marketplace configuration\",\n \"admin/glovo-integration.integration-settings.marketplace.label\": \"Marketplace\",\n \"admin/glovo-integration.integration-settings.minimumStock.description\": \"Minimum stock to use for availability on Glovo store (Must be between 1 and 20).\",\n \"admin/glovo-integration.integration-settings.minimumStock.label\": \"Minimum Stock\",\n \"admin/glovo-integration.integration-settings.production.description\": \"Toggle between development and production environment\",\n \"admin/glovo-integration.integration-settings.production.label\": \"Production\",\n\n \"admin/glovo-integration.client-info.title\": \"Client Information\",\n \"admin/glovo-integration.client-info.subtitle\": \"Information about the client from Glovo\",\n \"admin/glovo-integration.client-info.email\": \"Email *\",\n \"admin/glovo-integration.client-info.first-name\": \"First name * (used only if name is not present in received orders)\",\n \"admin/glovo-integration.client-info.last-name\": \"Last name * (used only if name is not present in received orders)\",\n \"admin/glovo-integration.client-info.document-type\": \"Document type *\",\n \"admin/glovo-integration.client-info.document\": \"Document *\",\n \"admin/glovo-integration.client-info.phone-number\": \"Phone number * (used only if name is not present in received orders)\",\n \"admin/glovo-integration.client-info.corporate-name\": \"Corporate name *\",\n\n \"admin/glovo-integration.modal.title\": \"Store Configuration\",\n \"admin/glovo-integration.modal.store-name.description\": \"Display name associated to the store\",\n \"admin/glovo-integration.modal.seller-id.description\": \"Seller ID associated to this store\",\n \"admin/glovo-integration.modal.affiliate-id.description\": \"Three letters ID associated for the affiliate. Format 'XYZ'\",\n \"admin/glovo-integration.modal.sales-channel.description\": \"Sales Channel associated with the store ID\",\n \"admin/glovo-integration.modal.postal-code.description\": \"The postal code for the store in charge of fulfillment\",\n \"admin/glovo-integration.modal.country.description\": \"The country of the store\",\n \"admin/glovo-integration.modal.glovo-store-id.description\": \"Glovo Store ID registered in Glovo for the configured Store ID\",\n\n \"admin/glovo-integration.delete-store-dialog.title\": \"Are you sure you want to delete the affiliation?\",\n \"admin/glovo-integration.delete-store-dialog.subtitle\": \"This action is irreversible, you will delete de affiliation\",\n \"admin/glovo-integration.delete-store-dialog.confirmation\": \"Remove the store\",\n \"admin/glovo-integration.delete-store-dialog.cancel\": \"Cancel\",\n\n \"admin/glovo-integration.inputs.error-message\": \"This field is mandatory\",\n \"admin/glovo-integration.alert.success\": \"Settings saved successfully\",\n \"admin/glovo-integration.alert.error\": \"Something went wrong\",\n \"admin/glovo-integration.add-more\": \"ADD STORE\",\n \"admin/glovo-integration.save\": \"SAVE\"\n}\n\n```" } ]
code_glovo-integration_05dbe2a5
[ { "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 glovo-integration/messages/context.json from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/glovo-integration.settings-title\": \"Glovo Integration\",\n \"admin/glovo-integration.settings.loading\": \"Loading application settings...\",\n \"admin/glovo-integration.settings.error\": \"Unable to retrieve application settings\",\n \"admin/glovo-integration.store-name\": \"Store name\",\n \"admin/glovo-integration.seller-id\": \"Seller ID\",\n \"admin/glovo-integration.seller-name\": \"Seller Name\",\n \"admin/glovo-integration.affiliate-id\": \"Affiliate ID\",\n \"admin/glovo-integration.sales-channel\": \"Sales Channel\",\n \"admin/glovo-integration.postal-code\": \"Postal Code\",\n \"admin/glovo-integration.country\": \"Country\",\n \"admin/glovo-integration.glovo-store-id\": \"Glovo Store ID\",\n\n \"admin/glovo-integration.table.title\": \"Stores\",\n \"admin/glovo-integration.table.subtitle\": \"List of stores integrated with the Glovo app\",\n \"admin/glovo-integration.table.edit-store\": \"Edit store\",\n \"admin/glovo-integration.table.remove-store\": \"Remove store\",\n \"admin/glovo-integration.table.empty\": \"There are no stores configured\",\n \"admin/glovo-integration.table.show-rows\": \"Show rows\",\n \"admin/glovo-integration.table.of\": \"of\",\n \"admin/glovo-integration.table.all\": \"All\",\n \"admin/glovo-integration.table.none\": \"None\",\n \"admin/glovo-integration.table.clear-all\": \"Clear all\",\n \"admin/glovo-integration.table.more-options\": \"more options\",\n \"admin/glovo-integration.table.apply\": \"Apply\",\n\n \"admin/glovo-integration.integration-settings.title\": \"Integration Settings\",\n \"admin/glovo-integration.integration-settings.subtitle\": \"Glovo integration settings\",\n \"admin/glovo-integration.integration-settings.glovo-token.description\": \"Token to perform calls to the Glovo API\",\n \"admin/glovo-integration.integration-settings.glovo-token\": \"Glovo Token *\",\n \"admin/glovo-integration.integration-settings.marketplace.description\": \"Toggle to use marketplace configuration\",\n \"admin/glovo-integration.integration-settings.marketplace.label\": \"Marketplace\",\n \"admin/glovo-integration.integration-settings.minimumStock.description\": \"Minimum stock to use for availability on Glovo store (Must be between 1 and 20).\",\n \"admin/glovo-integration.integration-settings.minimumStock.label\": \"Minimum Stock\",\n \"admin/glovo-integration.integration-settings.production.description\": \"Toggle between development and production environment\",\n \"admin/glovo-integration.integration-settings.production.label\": \"Production\",\n\n \"admin/glovo-integration.client-info.title\": \"Client Information\",\n \"admin/glovo-integration.client-info.subtitle\": \"Information about the client from Glovo\",\n \"admin/glovo-integration.client-info.email\": \"Email *\",\n \"admin/glovo-integration.client-info.first-name\": \"First name * (used only if name is not present in received orders)\",\n \"admin/glovo-integration.client-info.last-name\": \"Last name * (used only if name is not present in received orders)\",\n \"admin/glovo-integration.client-info.document-type\": \"Document type *\",\n \"admin/glovo-integration.client-info.document\": \"Document *\",\n \"admin/glovo-integration.client-info.phone-number\": \"Phone number * (used only if name is not present in received orders)\",\n \"admin/glovo-integration.client-info.corporate-name\": \"Corporate name *\",\n\n \"admin/glovo-integration.modal.title\": \"Store Configuration\",\n \"admin/glovo-integration.modal.store-name.description\": \"Display name associated to the store\",\n \"admin/glovo-integration.modal.seller-id.description\": \"Seller ID associated to this store\",\n \"admin/glovo-integration.modal.affiliate-id.description\": \"Three letters ID associated for the affiliate. Format 'XYZ'\",\n \"admin/glovo-integration.modal.sales-channel.description\": \"Sales Channel associated with the store ID\",\n \"admin/glovo-integration.modal.postal-code.description\": \"The postal code for the store in charge of fulfillment\",\n \"admin/glovo-integration.modal.country.description\": \"The country of the store\",\n \"admin/glovo-integration.modal.glovo-store-id.description\": \"Glovo Store ID registered in Glovo for the configured Store ID\",\n\n \"admin/glovo-integration.delete-store-dialog.title\": \"Are you sure you want to delete the affiliation?\",\n \"admin/glovo-integration.delete-store-dialog.subtitle\": \"This action is irreversible, you will delete de affiliation\",\n \"admin/glovo-integration.delete-store-dialog.confirmation\": \"Remove the store\",\n \"admin/glovo-integration.delete-store-dialog.cancel\": \"Cancel\",\n\n \"admin/glovo-integration.inputs.error-message\": \"This field is mandatory\",\n \"admin/glovo-integration.alert.success\": \"Settings saved successfully\",\n \"admin/glovo-integration.alert.error\": \"Something went wrong\",\n \"admin/glovo-integration.add-more\": \"ADD STORE\",\n \"admin/glovo-integration.save\": \"SAVE\"\n}\n\n```" } ]
code_glovo-integration_0d956a53
[ { "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 glovo-integration/admin/navigation.json from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"section\": \"accountSettings\",\n \"titleId\": \"admin/glovo-integration.settings-title\",\n \"path\": \"/admin/glovo-integration\"\n}\n\n```" } ]
code_glovo-integration_4edc42c3
[ { "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 glovo-integration/admin/routes.json from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin.app.glovo-integration\": {\n \"component\": \"AdminPanel\",\n \"path\": \"/admin/app/glovo-integration\"\n }\n}\n\n```" } ]
code_glovo-integration_09df5185
[ { "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 glovo-integration/docs/README.md from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Glovo Integration\n\n## ⚠️ Maintenance ⚠️\n*Starting June 1st 2023, this application will no longer be maintained by VTEX.*\n\n---\n\nThe Glovo Integration allows European stores to be integrated with the Glovo Marketplace.\\\n_Note: Latin American stores are not supported_\n\n## Main Features\n\n- **Possibility to add multiple stores with independent catalogs**.\n- **Product catalog update for stores** - Updates to the store's catalogs can be scheduled to keep prices and product availability up to date.\n- **Order Integration** - The orders received from Glovo are integrated into VTEX.\n\n## Configuration\n\n_Prior to the following steps, you should have already reached out to Glovo to create the Catalog for the stores you will have available in Glovo, you should upload one catalog that includes all of the products you want to offer on the independent Glovo Stores. The App will take care of managing the availability for each store._\n\nTo configure the Glovo Integration you can follow these steps:\n\n1. Run the following command in your store's CLI: `vtex install vtex.glovo-integration@3.x`\n2. Make sure you have at least one (1) pick-up-point configured for each of the salesChannel where you want to offer the integration.\n3. In your store's admin dashboard, on the side menu browse to **Apps -> Glovo Integration** and then click on it to open the application settings.\\\n4. Add the stores that will integrate with Glovo:\n\n| Field | Description |\n| -------------- | ---------------------------------------------------------------------------------------------------------------------------------- |\n| Store name | Display name associated to the store |\n| Seller ID | Seller ID associated to the store (the dropdown displays the seller's name) |\n| Affiliate ID | Three letters ID associated for the affiliate (you can find this ID going to **Store settings -> Orders' settings -> Affiliates**) |\n| Sales channel | The sales channel associated to the store |\n| Postal code | The postal code for the store in charge of fulfilling the orders from Glovo |\n| Country | The country where the store is located |\n| Glovo Store ID | Glovo store ID assigned to the store by Glovo |\n\n5. Fill in the the integration settings and client information:\n\n| Field | Description | Default value |\n| ---------------------- | ------------------------------------------------------------------------- | ------------- |\n| Glovo Token | Glovo token (app key) provided by Glovo to connect to their APIs | |\n| Minimum stock | Minimum stock for a product to be marked as available on the Glovo store | 1 |\n| Marketplace | Toggle to use a marketplace configuration | `false` |\n| Production Environment | Toggle between Glovo's Test environment and production environment | `false` |\n| Client information | All orders will be created using this information for the customer fields | |\n\n6. Using the example shown below, upload the catalog of your store's products that will be available on Glovo (include all the products from every store) by making a POST request to the following endpoint.\n\n```\ncurl --request POST \\\n --url https://app.io.vtex.com/vtex.glovo-integration/v2/{{account}}/{{workspace}}/_v/glovo/glovo-menu/ \\\n --header 'VtexIdClientAutCookie: {authToken}' \\\n --data '\n [\n \"productId\",\n \"productId\",\n \"productId\",\n .\n .\n .\n \"productId\",\n ]\n '\n```\n\n7. The catalog of products offered on Glovo can be updated completely or partially by using the following endpoints:\n\n- **Complete update** - This endpoint will send a bulk update to every store for all the products in the menu.\n\n```\ncurl --request POST \\\n --url https://{{account}}.myvtex.com/_v/glovo/menu/update-all \\\n --header 'VtexIdClientAutCookie: {authToken}' \\\n```\n\n- **Partial update** - This endpoint will send a bulk update to every store only for products that have changed since the last update.\\\n _The partial update requires the affiliate configuration described on step 5_\n\n```\ncurl --request POST \\\n --url https://{{account}}.myvtex.com/_v/glovo/menu/update-partial \\\n --header 'VtexIdClientAutCookie: {authToken}' \\\n```\n\n8. Inside your store's admin dashboard, on the side menu go to _Orders Management -> Settings -> Affiliate_ and configure a new [affiliate](https://help.vtex.com/en/tutorial/integration-guide-consuming-catalog-information-for-use-in-an-external-service) as follows:\n\n - Name: Give the affiliate a name\n - ID: a three (3) letter key for the affiliate (not compatible with numbers or vocals)\n - Trade Policy: number of the trade policy (sales channel) that will be linked to the Glovo Store\n - e-mail: email for notifications\n - Search Enpoint: `https://{{account}}.myvtex.com/_v/glovo/products/update`\n\n## Store Menu\n\nIt is possible to see the current catalog offered in Glovo for any of the stores that have been added to the configuration. \\\nThe following endpoint will respond with the store's current catalog and generate a new updated record in the background.\n\n```\ncurl --request GET \\\n --url https://app.io.vtex.com/vtex.glovo-integration/v3/{{account}}/{{workspace}}/_v/glovo/get-menu/{{affiliateId}}' \\\n --header 'VtexIdClientAutCookie: {authToken} \\\n```\n\n_The response has a property called `lastUpdated` that shows you the last date in which the the record was generated._\n\n```" } ]
code_glovo-integration_acafda49
[ { "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 glovo-integration/common/utils.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ntype Inputs = Record<string, any>\n\nexport const validateInputs = (inputs: Inputs): boolean => {\n for (const key in inputs) {\n if (inputs[key] === '' || inputs[key] === undefined) {\n return false\n }\n\n if (typeof inputs[key] === 'object') {\n if (!validateInputs(inputs[key])) {\n return false\n }\n }\n }\n\n return true\n}\n\n```" } ]
code_glovo-integration_8c852a2a
[ { "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 glovo-integration/graphql/schema.graphql from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype Query {\n getGlovoIntegrationSettings: GlovoIntegrationSettings\n @cacheControl(scope: PUBLIC, maxAge: SHORT)\n\n getMaxItemsForSimulation: MaxItemsForSimulation\n @cacheControl(scope: PUBLIC, maxAge: SHORT)\n}\n\ntype Mutation {\n saveGlovoIntegrationSettings(settings: SaveGlovoIntegrationSettings): Boolean\n\n updateMaxItemsForSimulation(max: Int!): MaxItemsForSimulation\n}\n\n```" } ]
code_glovo-integration_447dfc1e
[ { "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 glovo-integration/node/service.json from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"memory\": 1024,\n \"ttl\": 60,\n \"timeout\": 30,\n \"minReplicas\": 2,\n \"maxReplicas\": 6,\n \"workers\": 1,\n \"routes\": {\n \"createOrder\": {\n \"path\": \"/_v/glovo/orders/create\",\n \"public\": true\n },\n \"updateProduct\": {\n \"path\": \"/_v/glovo/products/update\",\n \"public\": true\n },\n \"updateCompleteMenu\": {\n \"path\": \"/_v/glovo/menu/update-all\",\n \"public\": true\n },\n \"updatePartialMenu\": {\n \"path\": \"/_v/glovo/menu/update-partial\",\n \"public\": true\n },\n \"glovoMenu\": {\n \"path\": \"/_v/glovo/glovo-menu\",\n \"public\": false\n },\n \"getGlovoMenuByStore\": {\n \"path\": \"/_v/glovo/get-menu/:affiliateId\",\n \"public\": false\n },\n \"storeMenuUpdates\": {\n \"path\": \"/_v/glovo/store-menu-updates/:affiliateId\",\n \"public\": false\n },\n \"orderChange\": {\n \"path\": \"/pvt/orders/:orderId/changes\",\n \"public\": true\n }\n },\n \"events\": {\n \"updateGlovoOrder\": {\n \"sender\": \"vtex.orders-broadcast\",\n \"topics\": [\"invoiced\"]\n }\n }\n}\n\n```" } ]
code_glovo-integration_ac7ea4fa
[ { "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 glovo-integration/node/package.json from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"@vtex/clients\": \"^2.8.0\",\n \"co-body\": \"^6.0.0\",\n \"ramda\": \"^0.25.0\"\n },\n \"devDependencies\": {\n \"@types/co-body\": \"^0.0.3\",\n \"@types/jest\": \"^24.0.18\",\n \"@types/node\": \"^12.0.0\",\n \"@types/ramda\": \"types/npm-ramda#dist\",\n \"@vtex/api\": \"6.45.15\",\n \"@vtex/test-tools\": \"^1.0.0\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"typescript\": \"3.9.7\",\n \"vtex.glovo-integration\": \"https://glovo--ametllerorigenqa.myvtex.com/_v/private/typings/linked/v1/vtex.glovo-integration@3.5.0+build1679072072/public/@types/vtex.glovo-integration\",\n \"vtex.native-types\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.native-types@0.9.0/public/@types/vtex.native-types\",\n \"vtex.sellers-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.sellers-graphql@7.5.2/public/@types/vtex.sellers-graphql\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.146.3/public/@types/vtex.styleguide\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty\"\n },\n \"version\": \"3.5.3\"\n}\n\n```" } ]
code_glovo-integration_66cafbea
[ { "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 glovo-integration/node/index.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { ParamsContext } from '@vtex/api'\nimport { Service } from '@vtex/api'\n\nimport type { Clients } from './clients'\nimport { clientsConfig } from './clients'\nimport { events } from './middlewares/events'\nimport { routes } from './middlewares/routes'\nimport { resolvers } from './resolvers'\n\n// Export a service that defines route handlers and client options.\nexport default new Service<Clients, State, ParamsContext>({\n clients: clientsConfig,\n routes,\n events,\n graphql: {\n resolvers,\n },\n})\n\n```" } ]
code_glovo-integration_ead61ad9
[ { "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 glovo-integration/react/AdminPanel.tsx from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { AdminPanel } from './components/admin/AdminPanel'\n\nexport default AdminPanel\n\n```" } ]
code_glovo-integration_997ee72f
[ { "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 glovo-integration/react/package.json from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"glovo\",\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"country-iso-2-to-3\": \"^1.1.0\",\n \"country-iso-3-to-2\": \"^1.1.0\",\n \"graphql\": \"^15.3.0\",\n \"react-apollo\": \"^3.1.5\",\n \"react-intl\": \"^5.20.6\",\n \"react-super-responsive-table\": \"^5.2.0\",\n \"uuid\": \"^8.3.2\"\n },\n \"devDependencies\": {\n \"@types/babel__core\": \"^7.1.18\",\n \"@types/jest\": \"^26.0.4\",\n \"@types/node\": \"^14.0.14\",\n \"@types/react\": \"^16.9.41\",\n \"@types/react-intl\": \"^2.3.17\",\n \"@vtex/test-tools\": \"^3.1.0\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"vtex.glovo-integration\": \"https://glovo--ametllerorigenqa.myvtex.com/_v/private/typings/linked/v1/vtex.glovo-integration@3.5.0+build1679072072/public/@types/vtex.glovo-integration\",\n \"vtex.native-types\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.native-types@0.9.0/public/@types/vtex.native-types\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.132.4/public/@types/vtex.render-runtime\",\n \"vtex.sellers-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.sellers-graphql@7.5.2/public/@types/vtex.sellers-graphql\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.146.3/public/@types/vtex.styleguide\"\n },\n \"version\": \"3.5.3\"\n}\n\n```" } ]
code_glovo-integration_ba6f232a
[ { "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 glovo-integration/public/metadata/messages/es-AR.json from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"Integración Glovo Europa\",\n \"headline\": \"Solución nativa para integrar con Glovo Europa.\",\n \"overview\": \"¡La integración nativa de Glovo ahora está en VTEX!\\\\\\\\n Glovo es a día de hoy la mayor plataforma bajo demanda de Europa continental con más de 224 millones de pedidos entregados.\\\\\\\\n La integración de Glovo permitirá a sus clientes navegar por los productos de su tienda con la información de precios y stock más actualizada.\",\n \"features\": [\n \"Integración de Stock y Precio\",\n \"Integración de Ordenes\",\n \"Disponibilidad para integrar múltiples tiendas\"\n ],\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_glovo-integration_15825cf8
[ { "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 glovo-integration/public/metadata/messages/pt-BR.json from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"Glovo Europa Integration\",\n \"headline\": \"Solução nativa para integração com Glovo Europa.\",\n \"overview\": \"A integração nativa do Glovo está agora na VTEX!\\\\\\\\n Glovo é hoje a maior plataforma sob demanda da Europa continental, com mais de 224 milhões de pedidos entregues.\\\\\\\\n A integração do Glovo permitirá que seus clientes naveguem pelos produtos de sua loja com as informações de estoque e preços mais atualizadas.\",\n \"features\": [\n \"Integração de estoque e preço\",\n \"Integração de Pedidos\",\n \"Disponibilidade para integração de múltiplas lojas\"\n ],\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_glovo-integration_d271f799
[ { "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 glovo-integration/public/metadata/messages/en-US.json from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"Glovo Europe Integration\",\n \"headline\": \"Native solution to integrate with Glovo.\",\n \"overview\": \"Glovo native integration is now on VTEX!\\\\\\\\n Today, Glovo is the largest on-demand platform in continental Europe with more than 224 million orders delivered.\\\\\\\\n The Glovo integration will allow your clients to browse your store's products with the most up-to-date stock and price information.\",\n \"features\": [\n \"Integration of Stock and Prices\",\n \"Integration of Orders\",\n \"Multiple Store Capability\"\n ],\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_glovo-integration_0ce04e0b
[ { "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 glovo-integration/graphql/types/clientProfileData.graphql from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype ClientProfileData {\n email: String!\n firstName: String!\n lastName: String!\n documentType: String\n document: String\n phone: String\n corporateName: String\n tradeName: String\n corporateDocument: String\n stateInscription: String\n corporatePhone: String\n isCorporate: Boolean\n userProfileId: String\n}\n\ninput SaveClientProfileData {\n email: String!\n firstName: String!\n lastName: String!\n documentType: String\n document: String\n phone: String\n corporateName: String\n}\n\n```" } ]
code_glovo-integration_2696b64d
[ { "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 glovo-integration/graphql/types/store.graphql from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype Store {\n id: String!\n sellerId: String!\n sellerName: String!\n storeName: String!\n affiliateId: String!\n salesChannel: String!\n postalCode: String!\n country: String!\n glovoStoreId: String!\n}\n\ninput SaveStore {\n id: String!\n sellerId: String!\n sellerName: String!\n storeName: String!\n affiliateId: String!\n salesChannel: String!\n postalCode: String!\n country: String!\n glovoStoreId: String!\n}\n\n```" } ]
code_glovo-integration_7b6fac99
[ { "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 glovo-integration/graphql/types/appSettings.graphql from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype GlovoIntegrationSettings {\n glovoToken: String!\n production: Boolean!\n marketplace: Boolean!\n stores: [Store!]!\n clientProfileData: ClientProfileData!\n minimumStock: Int!\n}\n\ninput SaveGlovoIntegrationSettings {\n glovoToken: String!\n production: Boolean!\n marketplace: Boolean!\n stores: [SaveStore!]!\n clientProfileData: SaveClientProfileData!\n minimumStock: Int!\n}\n\n```" } ]
code_glovo-integration_1deb6026
[ { "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 glovo-integration/node/clients/recordManager.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { VBase } from '@vtex/api'\n\nimport {\n GLOVO,\n MENU,\n STORE_MENU,\n ORDERS,\n STORE_MENU_UPDATE,\n} from '../constants'\n\nexport default class RecordsManager extends VBase {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(context, {\n ...options,\n })\n }\n\n // Glovo Menu Records\n public saveGlovoMenu(data: GlovoMenu) {\n return this.saveJSON<GlovoMenu>(GLOVO, MENU, data)\n }\n\n public getGlovoMenu() {\n return this.getJSON<GlovoMenu>(GLOVO, MENU, true)\n }\n\n // Store's Menu Updates Records\n public saveStoreMenuUpdates(affiliateId: string, data: StoreMenuUpdates) {\n return this.saveJSON<StoreMenuUpdates>(affiliateId, MENU, data)\n }\n\n public getStoreMenuUpdates(affiliateId: string) {\n return this.getJSON<StoreMenuUpdates>(affiliateId, MENU, true)\n }\n\n // Product's Records\n public saveProductRecord(\n affiliateId: string,\n skuId: string,\n data: ProductRecord\n ) {\n return this.saveJSON<ProductRecord>(affiliateId, skuId, data)\n }\n\n public getProductRecord(affiliateId: string, skuId: string) {\n return this.getJSON<ProductRecord>(affiliateId, skuId, true)\n }\n\n // Store's catalog\n public saveStoreMenuRecord(affiliateId: string, data: StoreMenuRecord) {\n return this.saveJSON<StoreMenuRecord>(affiliateId, STORE_MENU, data)\n }\n\n public getStoreMenuRecord(affiliateId: string) {\n return this.getJSON<StoreMenuRecord>(affiliateId, STORE_MENU, true)\n }\n\n // Store's catalog update\n public saveStoreCompleteMenuUpdate(\n affiliateId: string,\n data: CompleteUpdateRecord\n ) {\n return this.saveJSON(affiliateId, STORE_MENU_UPDATE, data)\n }\n\n public getStoreCompleteMenuUpdate(affiliateId: string) {\n return this.getJSON<{ items: GlovoProductPatch[]; lastUpdated: string }>(\n affiliateId,\n STORE_MENU_UPDATE,\n true\n )\n }\n\n // Order's Records\n public saveOrderRecord(orderId: string, data: OrderRecord) {\n return this.saveJSON<OrderRecord>(ORDERS, orderId, data)\n }\n\n public getOrderRecord(orderId: string) {\n return this.getJSON<OrderRecord>(ORDERS, orderId, true)\n }\n}\n\n```" } ]
code_glovo-integration_b676fc4f
[ { "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 glovo-integration/node/clients/orders.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { JanusClient } from '@vtex/api'\n\nexport default class Orders extends JanusClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(context, {\n ...options,\n headers: {\n ...options?.headers,\n VtexIdclientAutCookie: context.authToken,\n },\n })\n }\n\n public getOrder(orderId: string): Promise<VTEXOrder> {\n return this.http.get(`/api/oms/pvt/orders/${orderId}`)\n }\n\n public createOrder(\n data: CreateOrderPayload,\n sc: string,\n affiliateId: string\n ): Promise<VTEXOrder[]> {\n return this.http.post('/api/fulfillment/pvt/orders', [data], {\n params: {\n sc,\n affiliateId,\n },\n })\n }\n\n public createMarketplaceOrder(\n data: CreateOrderPayload,\n sc: string,\n affiliateId: string\n ): Promise<CreateMarketplaceOrderResponse> {\n return this.http.put('/api/checkout/pvt/orders', data, {\n params: {\n sc,\n affiliateId,\n },\n })\n }\n\n // eslint-disable-next-line max-params\n public authorizeOrder(\n data: AuthorizeOrderPayload,\n orderId: string,\n sc: string,\n affiliateId: string\n ): Promise<VTEXAuthorizedOrder> {\n return this.http.post(\n `/api/fulfillment/pvt/orders/${orderId}/fulfill`,\n data,\n {\n params: {\n sc,\n affiliateId,\n },\n }\n )\n }\n\n public authorizeMarketplaceOrder(\n data: AuthorizeMarketplaceOrderPayload,\n marketplaceOrderId: string\n ): Promise<VTEXAuthorizedOrder> {\n return this.http.post(\n `/api/checkout/pvt/orders/${marketplaceOrderId}/receipts/marketplace-order-authorization`,\n data\n )\n }\n}\n\n```" } ]
code_glovo-integration_8b157e2c
[ { "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 glovo-integration/node/clients/index.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { Cached, ClientsConfig } from '@vtex/api'\nimport { IOClients, LRUCache } from '@vtex/api'\nimport { Checkout } from '@vtex/clients'\n\nimport { TIMEOUT_MS } from '../constants'\nimport Glovo from './glovo'\nimport Orders from './orders'\nimport RecordsManager from './recordManager'\n\n// Extend the default IOClients implementation with our own custom clients.\nexport class Clients extends IOClients {\n public get glovo() {\n return this.getOrSet('glovo', Glovo)\n }\n\n public get orders() {\n return this.getOrSet('orders', Orders)\n }\n\n public get recordsManager() {\n return this.getOrSet('recordsManager', RecordsManager)\n }\n\n public get checkout() {\n return this.getOrSet('checkout', Checkout)\n }\n}\n\nconst glovoCache = new LRUCache<string, Cached>({ max: 500 })\n\nmetrics.trackCache('glovo', glovoCache)\n\nexport const clientsConfig: ClientsConfig<Clients> = {\n implementation: Clients,\n options: {\n default: {\n retries: 2,\n timeout: TIMEOUT_MS,\n },\n glovo: {\n memoryCache: glovoCache,\n },\n },\n}\n\n```" } ]
code_glovo-integration_f956f382
[ { "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 glovo-integration/node/clients/glovo.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { PRODUCTION, ExternalClient } from '@vtex/api'\n\nexport default class Glovo extends ExternalClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super('glovoapp.com', context, {\n ...options,\n headers: {\n contentType: 'application/json',\n Accept: 'application/json',\n },\n })\n }\n\n private baseUrl() {\n return PRODUCTION\n ? 'https://api.glovoapp.com'\n : 'https://stageapi.glovoapp.com'\n }\n\n public async bulkUpdateProducts(\n data: GlovoProductBulkUpdate,\n glovoStoreId: string,\n glovoToken: string\n ) {\n return this.http.post<GlovoBulkUpdateResponse>(\n `${this.baseUrl()}/webhook/stores/${glovoStoreId}/menu/updates`,\n data,\n {\n headers: {\n Authorization: glovoToken,\n },\n }\n )\n }\n\n public async updateOrderStatus(\n { glovoStoreId, glovoOrderId, status }: GlovoUpdateOrderStatus,\n glovoToken: string\n ) {\n return this.http.put(\n `${this.baseUrl()}/webhook/stores/${glovoStoreId}/orders/${glovoOrderId}/status`,\n {\n status,\n },\n {\n headers: {\n Authorization: glovoToken,\n },\n }\n )\n }\n\n public async modifyOrder(\n {\n glovoStoreId,\n glovoOrderId,\n replacements,\n removed_purchases,\n added_products,\n }: GlovoModifyOrderPayload,\n glovoToken: string\n ): Promise<GlovoOrder> {\n return this.http.post(\n `${this.baseUrl()}/webhook/stores/${glovoStoreId}/orders/${glovoOrderId}/replace_products`,\n {\n replacements,\n removed_purchases,\n added_products,\n },\n {\n headers: {\n Authorization: glovoToken,\n },\n }\n )\n }\n}\n\n```" } ]
code_glovo-integration_11115975
[ { "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 glovo-integration/node/constants/index.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/naming-convention */\nexport const RESIDENTIAL = 'Residential'\nexport const HOME = 'Home'\nexport const APP_SETTINGS = 'app-settings'\nexport const AVAILABLE = 'available'\n\n/** VTEX Order status */\nexport const WAITING_SELLER_HANDLING = 'waiting-seller-handling'\nexport const READY_FOR_HANDLING = 'ready-for-handling'\nexport const HANDLING = 'handling'\nexport const INVOICED = 'invoiced'\n\n/** Glovo order status */\nexport const ACCEPTED = 'ACCEPTED'\nexport const READY_FOR_PICKUP = 'READY_FOR_PICKUP'\n\n/** Records Manager */\nexport const GLOVO = 'Glovo'\nexport const MENU = 'Menu'\nexport const ORDERS = 'orders'\nexport const STORE_MENU = 'store-menu'\nexport const STORE_MENU_UPDATE = 'store-menu-update'\nexport const MAX_ITEMS_FOR_SIMULATION = 'max-items-for-simulation'\n\n/** General */\nexport const TIMEOUT_MS = 10000\n\n```" } ]
code_glovo-integration_3633ff3c
[ { "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 glovo-integration/node/typings/general.d.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ninterface CatalogChange {\n IdSku: string\n ProductId: string\n An: string\n IdAffiliate: string\n Version: string\n DateModified: Date\n IsActive: boolean\n StockModified: boolean\n PriceModified: boolean\n HasStockKeepingUnitModified: boolean\n HasStockKeepingUnitRemovedFromAffiliate: boolean\n}\n\ninterface SimulationTotalsItem {\n id: string\n name: string\n value: number\n}\n\ninterface SimulationItem {\n id: string\n quantity: number\n sellerId: string\n}\n\ninterface SimulatedItem {\n price: number\n available: boolean\n}\n\ninterface CreateSimulationArgs {\n items: PayloadItem[]\n postalCode?: string\n country?: string\n affiliateId: string\n salesChannel: string\n}\n\ninterface ProductRecord {\n id: string\n price?: number\n available?: boolean\n}\n\ninterface StoreMenuRecord {\n items: {\n [id: string]: ProductRecord\n }\n lastUpdated: string\n}\n\ninterface GlovoMenu {\n [key: string]: boolean\n}\n\ninterface StoreMenuUpdates {\n current: MenuUpdatesItem\n previous?: MenuUpdatesItem\n}\n\ninterface MenuUpdatesItem {\n responseId: string | null\n createdAt: number\n storeId: string\n storeName: string\n glovoStoreId: string\n items: ProductRecord[]\n}\n\ninterface CompleteUpdateRecord {\n items: GlovoProductPatch[]\n transactionId: string | null\n lastUpdated: string\n successful: boolean\n minimumStock: number\n}\n\n```" } ]
code_glovo-integration_7f4b6b0e
[ { "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 glovo-integration/node/typings/errors.d.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ninterface ErrorParams {\n message: string\n reason: string\n metric: ErrorMetric\n data?: unknown\n error?: unknown\n}\n\ntype ErrorMetric = 'menu' | 'orders' | 'products'\n\n```" } ]
code_glovo-integration_abf8e89d
[ { "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 glovo-integration/node/typings/glovo.d.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ninterface GlovoOrder {\n order_id: string\n store_id: string\n order_time: string\n estimated_pickup_time: string\n utc_offset_minutes: string\n payment_method: string\n currency: string\n courier: GlovoOrderCourier\n customer: GlovoCustomer\n /**\n * Alphanumeric identifier of the order used for historical identification or with Glovo support\n *\n * @type {string}\n * @memberOf GlovoOrder\n */\n order_code: string\n allergy_info: string\n /**\n * Estimated total price of the order products and attributes in cents. Delivery fee is not included\n *\n * @type {number}\n * @memberOf GlovoOrder\n */\n estimated_total_price: number\n /**\n * Marketplace partners: delivery price of the order in cents.\n * Normal partners: null\n *\n * @type {(number | null)}\n * @memberOf GlovoOrder\n */\n delivery_fee: number | null\n /**\n * Marketplace partners: minimum basket surcharge in cents.\n * Normal partners: null\n *\n * @type {(number | null)}\n * @memberOf GlovoOrder\n */\n minimum_basket_surcharge: number | null\n /**\n * Marketplace partners: cash amount that the customer will pay with. In cents or null if not informed.\n * Normal partners: null\n *\n * @type {(number | null)}\n * @memberOf GlovoOrder\n */\n customer_cash_payment_amount: number | null\n products: GlovoProduct[]\n /**\n * Marketplace partners: object containing information about the delivery address (Delivery address object)\n * Normal partners: null\n *\n * @type {(GlovoDeliveryAddress | null)}\n * @memberOf GlovoOrder\n */\n delivery_address: GlovoDeliveryAddress | null\n /**\n * Marketplace partners: empty array\n * Normal partners: array containing the list of the orders bundled with current order\n *\n * @type {string[]}\n * @memberOf GlovoOrder\n */\n bundled_orders: string[]\n /**\n * Non-sequential, non-unique 3 digit numerical code used to identify an order for pickup by the courier or customer.\n *\n * @type {string}\n * @memberOf GlovoOrder\n */\n pick_up_code: string\n /**\n * Boolean to indicate if the order will be picked up by a customer instead of by a courier\n *\n * @type {boolean}\n * @memberOf GlovoOrder\n */\n is_picked_up_by_customer: boolean\n cutlery_requested: boolean\n partner_discounts_products: number\n partner_discounted_products_total: number\n /**\n * Marketplace: Final amount to be paid in cents by customer including discounts, promotions, surcharges, fees and other adjustments\n * Normal partners: null\n *\n * @type {(number | null)}\n * @memberOf GlovoOrder\n */\n total_customer_to_pay: number | null\n}\n\ninterface GlovoOrderCourier {\n name: string\n phone_number: string\n}\n\ninterface GlovoCustomer {\n name: string\n phone_number: string\n hash: string\n /**\n * Object containing invoicing information. Null if the customer doesn't need invoice (Invoicing details object)\n *\n * @type {(GlovoCustomerInvoice | null)}\n * @memberOf GlovoCustomer\n */\n invoicing_details: GlovoCustomerInvoice | null\n}\n\ninterface GlovoCustomerInvoice {\n company_name: string\n company_address: string\n tax_id: string\n}\n\ninterface GlovoProduct {\n id: string\n quantity: number\n name?: string\n price?: number\n attributes: GlovoProductAttributes[]\n purchased_product_id: string\n}\n\ninterface GlovoProductAttributes {\n id: string\n quantity: number\n name?: string\n price?: number\n purchased_product_id?: string\n}\n\ninterface GlovoDeliveryAddress {\n label: string\n longitude: number\n latitude: number\n}\n\ninterface GlovoOrderCancellation {\n order_id: string\n store_id: string\n cancel_reason: string\n payment_strategy: string\n}\n\ninterface GlovoProductUpdate {\n skuId: string\n price?: number\n available?: boolean\n glovoStoreId: string\n}\n\ninterface GlovoProductPatch {\n available?: boolean\n id?: string\n price?: number\n}\n\ninterface GlovoProductBulkUpdate {\n products: GlovoProductPatch[]\n}\n\ninterface GlovoBulkUpdateResponse {\n transaction_id: string\n}\n\ninterface GlovoUpdatedProduct {\n purchased_product_id: string\n product: GlovoProduct\n}\n\ninterface GlovoUpdateOrderStatus {\n glovoStoreId: string\n glovoOrderId: string\n status: string\n}\n\ninterface GlovoModifyOrderPayload {\n glovoStoreId: string\n glovoOrderId: string\n replacements: GlovoModifyReplacement[]\n removed_purchases: Array<string | undefined>\n added_products: GlovoModifiedProduct[]\n}\n\ninterface GlovoModifyReplacement {\n purchased_product_id: string\n product: GlovoModifiedProduct\n}\n\ninterface GlovoModifiedProduct {\n id: string\n quantity: number\n attributes: GlovoModifiedProductAttributes[]\n}\n\ninterface GlovoModifiedProductAttributes {\n id: string\n quantity: number\n}\n\n```" } ]
code_glovo-integration_f29a686e
[ { "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 glovo-integration/node/typings/global.d.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { EventContext, RecorderState, ServiceContext } from '@vtex/api'\nimport type { ClientProfileData, Store } from 'vtex.glovo-integration'\nimport type { Clients } from '../clients'\n\ndeclare global {\n type Context = ServiceContext<Clients, State>\n\n interface State extends RecorderState {\n vtexAuthOrder: VTEXAuthorizedOrder\n vtexOrder: VTEXOrder | VTEXMarketplaceOrder\n glovoOrder: GlovoOrder\n glovoToken: string\n catalogUpdate: CatalogChange\n marketplace: boolean\n stores: Store[]\n storeInfo: Store\n clientProfileData: ClientProfileData\n orderSimulation: SimulationOrderForm\n }\n\n interface StatusChangeContext extends EventContext<Clients, State> {\n body: {\n domain: string\n orderId: string\n currentState: string\n lastState: string\n currentChangeDate: string\n lastChangeDate: string\n }\n }\n}\n\n```" } ]
code_glovo-integration_a23d7f9d
[ { "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 glovo-integration/node/typings/vtex.orders.d.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { ClientProfileData } from 'vtex.glovo-integration'\n\ndeclare global {\n interface VTEXOrder {\n marketplaceOrderId: string\n orderId: string\n followUpEmail: string\n items: VTEXOrderItem[]\n clientProfileData: ClientProfileData\n shippingData: {\n address: ShippingAddress\n logisticsInfo: ItemLogistics\n isFOB: boolean\n selectedAddresses: ShippingAddress[]\n trackingHints: any[]\n }\n paymentData: any\n customData: any\n orders?: any\n changesAttachment: ChangesAttachment\n }\n\n interface CreateOrderPayload {\n marketplaceOrderId: string\n marketplaceServicesEndpoint: string\n marketplacePaymentValue: number\n marketplaceOrderGroup: string\n isCreatedAsync: boolean\n items: VTEXOrderItem[]\n clientProfileData: ClientProfileData\n shippingData: ShippingData\n paymentData?: PaymentData\n marketingData?: MarketingData\n openTextField?: string\n savePersonalData: boolean\n }\n\n interface CreateMarketplaceOrderResponse {\n orderForm?: any\n transactionData: any\n orders: VTEXMarketplaceOrder[]\n }\n\n interface AuthorizeOrderPayload {\n marketplaceOrderId: string\n }\n\n interface AuthorizeMarketplaceOrderPayload {\n marketplaceOrderGroup: string\n authorizationReceipt: {\n date: string\n receipt: string\n }\n }\n\n interface VTEXAuthorizedOrder extends VTEXAuthorizedMarketplaceOrder {\n orderId: string\n marketplaceOrderId: string\n }\n\n interface OrderRecord {\n orderId: string\n glovoOrder: GlovoOrder\n invoiced: any | null\n hasChanged: boolean\n createdAt?: number\n startHandlingAt?: string\n invoicedAt?: number\n }\n\n interface OrderChangeBody {\n requestId: string\n reason: string\n discountValue: number\n incrementValue: number\n itemsRemoved: OrderChangeItem[]\n itemsAdded: OrderChangeItem[]\n }\n\n interface VTEXMarketplaceOrder {\n orderId: string\n orderGroup: string\n state: string | null\n isCheckedIn: boolean\n sellerOrderId: string\n storeId: string | null\n }\n\n interface VTEXAuthorizedMarketplaceOrder {\n receipt: string\n date: string\n items: [{ id: string }]\n shippingData: {\n logisticsInfo: [\n {\n itemIndex: number\n selectedSLAId: string\n selectedDeliveryChannel: string\n shippingEstimateDate: string\n }\n ]\n }\n }\n\n interface OrderChangeItem {\n id: string\n price: number\n quantity: number\n }\n\n interface VTEXOrderItem {\n id: string\n quantity: number\n seller: string\n priceTable: any\n commission: number\n freightCommission: number\n price: number\n bundleItems: any[]\n priceTags: any[]\n measurementUnit: string\n unitMultiplier: number\n isGift: boolean\n manufacturerCode: string\n catalogProvider: string\n }\n\n interface ShippingAddress {\n addressType: string\n receiverName: string\n addressId: string\n postalCode: string\n city: string | null\n state: string | null\n country: string\n street: string\n number: string | null\n neighborhood: string | null\n complement: string | null\n reference: string | null\n geoCoordinates: number[] | []\n }\n\n interface ItemLogistics {\n itemIndex: number\n selectedSla: string\n addressId?: string\n selectedDeliveryChannel: string\n name?: string\n deliveryIds?: ItemLogisticsDeliveryId[]\n lockTTL: string\n deliveryWindow: {\n startDateUtc: string\n endDateUtc: string\n price: number\n lisPrice: number\n tax: number\n }\n shippingEstimate: string\n price: number\n }\n\n interface ChangesAttachment {\n id: string\n changesData: ChangesData[]\n }\n\n interface ChangesData {\n reason: string\n discountvalue: number\n incrementValue: number\n itemsAdded: ChangesAttachmentItem[]\n itemsRemoved: ChangesAttachmentItem[]\n receipt: {\n date: string\n orderId: string\n receipt: string\n }\n }\n\n interface ChangesAttachmentItem {\n id: string\n name: string\n quantity: number\n price: number\n unitMultiplier: number\n }\n\n interface ShippingData {\n address: ShippingAddress\n logisticsInfo: ItemLogistics[]\n }\n\n interface ItemLogisticsDeliveryId {\n warehouseId: string\n dockId: string\n accountCarrierName: string\n }\n\n interface PaymentData {\n id?: 'paymentData'\n payments: [\n {\n paymentSystem: string\n paymentSystemName?: string\n value: number\n installments: number\n referenceValue: number\n }\n ]\n }\n\n interface MarketingData {\n utmSource: string\n utmMedium: string\n utmCampaign: string\n utmiPage: string\n utmiPart: string\n utmiCampaign: string\n }\n}\n\n```" } ]
code_glovo-integration_9cc26ecd
[ { "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 glovo-integration/node/utils/requests.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/**\n * Utility function to delay execution of your current process\n * @param milliseconds Milliseconds to delay the resolve\n */\nexport function delayFor(milliseconds: number) {\n return new Promise<void>((resolve) => {\n setTimeout(() => {\n resolve()\n }, milliseconds)\n })\n}\n\n/**\n * Utility function to retry the request passed.\n *\n * @param request Request to be made\n * @param retries Number of retries to be made. Defaults to 2\n * @param delay Delay in milliseconds to wait between retries. Defaults to 500 milliseconds\n * @returns request response or request error\n */\nexport async function requestWithRetries<T>(\n request: unknown,\n retries = 2,\n delay = 500\n): Promise<T> {\n try {\n const response = (await request) as T\n\n return response\n } catch (error) {\n if (retries === 0) {\n throw error\n }\n\n await delayFor(delay)\n\n return requestWithRetries(request, retries - 1)\n }\n}\n\n```" } ]
code_glovo-integration_60d8d3c8
[ { "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 glovo-integration/node/utils/errors.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport class ServiceError extends Error {\n constructor({ message, reason, metric, data, error }: ErrorParams) {\n super(message)\n this.reason = reason\n this.metric = metric\n this.data = data ?? 'No data provided'\n this.error = error ?? 'No error information'\n }\n\n public reason: string\n public metric: ErrorMetric\n public data: unknown\n public error: unknown\n}\n\n```" } ]
code_glovo-integration_61519d2a
[ { "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 glovo-integration/node/utils/utils.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/naming-convention */\nimport type { OrderFormItem, PayloadItem } from '@vtex/clients'\nimport type { Store } from 'vtex.glovo-integration'\n\nimport { createSimulationItem } from './simulation'\n\nexport const isSkuAvailable = (item: OrderFormItem | undefined): boolean => {\n if (!item) {\n return false\n }\n\n return item.availability === 'available'\n}\n\nexport const getStoreInfoFormGlovoStoreId = (\n id: string,\n stores: Store[]\n): Store | undefined => stores.find(({ glovoStoreId }) => glovoStoreId === id)\n\nexport const getStoreInfoFromStoreId = (id: string, stores: Store[]) =>\n stores.find(({ affiliateId }) => affiliateId === id) as Store\n\nexport const convertGlovoProductToItems = (\n sellerId: string,\n glovoProducts: GlovoProduct[] = []\n): PayloadItem[] => {\n const items = []\n const attributesCollection = []\n\n for (const product of glovoProducts) {\n const { id, quantity, attributes = [] } = product\n const item = createSimulationItem({ id, quantity, sellerId })\n\n items.push(item)\n attributesCollection.push(...attributes)\n }\n\n for (const attribute of attributesCollection) {\n const { id, quantity } = attribute\n const item = createSimulationItem({ id, quantity, sellerId })\n\n items.push(item)\n }\n\n return items\n}\n\ntype ProductsToCompare = {\n id: string\n quantity: number\n purchased_product_id: string\n}\n\nexport const convertGlovoProductsToCompare = (\n glovoProducts: GlovoProduct[]\n) => {\n const items: ProductsToCompare[] = []\n const attributesCollection = []\n\n for (const product of glovoProducts) {\n const { id, quantity, attributes = [], purchased_product_id } = product\n const item = {\n id,\n quantity,\n purchased_product_id,\n }\n\n items.push(item)\n attributesCollection.push(...attributes)\n }\n\n for (const attribute of attributesCollection) {\n if (attribute.purchased_product_id) {\n const { id, quantity } = attribute\n\n const updatedItems = items.map((item) => {\n if (item.id === id) {\n item.quantity += quantity\n }\n\n return item\n })\n\n items.push(...updatedItems)\n }\n }\n\n return items\n}\n\nexport const isValidAffiliateId = (\n affiliateId: string,\n stores: Store[]\n): boolean => {\n if (Number(affiliateId)) {\n return false\n }\n\n return stores.some((store) => store.affiliateId === affiliateId)\n}\n\n```" } ]
code_glovo-integration_db736508
[ { "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 glovo-integration/node/utils/orders.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* eslint-disable max-params */\n\nimport type { ClientProfileData } from 'vtex.glovo-integration'\n\nimport { RESIDENTIAL, HOME } from '../constants'\nimport { isSkuAvailable } from './utils'\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport const createVtexOrderData = (\n glovoOrder: GlovoOrder,\n orderSimulation: any,\n clientProfileData: ClientProfileData,\n marketplace: boolean,\n account: string\n): CreateOrderPayload => {\n const {\n order_id,\n customer: { name, phone_number },\n } = glovoOrder\n\n const { items, pickupPoints, postalCode, logisticsInfo, totals } =\n orderSimulation\n\n const {\n email,\n firstName,\n lastName,\n documentType,\n document,\n phone,\n corporateName,\n } = clientProfileData\n\n /** Check if Glovo sends customer name */\n const customerName = name ?? `${firstName} ${lastName}`\n\n /** Re-Index items array */\n let counter = 0\n const updatedItems = items.reduce((reIndexedItems: any, item: any) => {\n if (isSkuAvailable(item)) {\n const updatedItem = {\n ...item,\n itemIndex: 0,\n }\n\n counter++\n\n return [...reIndexedItems, updatedItem]\n }\n\n return reIndexedItems\n }, [])\n\n /** Re-Index logisticsInfo array */\n counter = 0\n const updatedLogisticsInfo = logisticsInfo.reduce(\n (reIndexedItems: any[], item: any, index: number) => {\n if (items[index].availability === 'available') {\n const updatedItem = {\n itemIndex: counter,\n selectedSla: item.slas[0].id,\n selectedDeliveryChannel: item.slas[0].deliveryChannel,\n name: item.slas[0].name,\n lockTTL: '1d',\n deliveryWindow: item.slas[0].availableDeliveryWindows[0],\n shippingEstimate: item.slas[0].shippingEstimate,\n price: item.slas[0].price,\n }\n\n counter++\n\n return [...reIndexedItems, updatedItem]\n }\n\n return reIndexedItems\n },\n []\n )\n\n const totalValue = totals.reduce(\n (total: number, item: SimulationTotalsItem) => (total += item.value),\n 0\n )\n\n const vtexOrderData: CreateOrderPayload = {\n marketplaceOrderId: order_id,\n marketplaceServicesEndpoint: `https://${account}.myvtex.com`,\n marketplacePaymentValue: totalValue,\n marketplaceOrderGroup: order_id,\n isCreatedAsync: true,\n items: updatedItems,\n savePersonalData: false,\n clientProfileData: {\n email: getEmail(customerName, phone_number, email),\n firstName: getFirstName(customerName) ?? firstName,\n lastName: getLastName(customerName) ?? lastName,\n documentType,\n document,\n phone: phone_number ?? phone,\n corporateName,\n tradeName: null,\n corporateDocument: null,\n stateInscription: null,\n corporatePhone: null,\n isCorporate: false,\n userProfileId: null,\n },\n shippingData: {\n address: {\n addressType: RESIDENTIAL,\n receiverName: getReceiverName(customerName, phone_number),\n addressId: HOME,\n postalCode,\n city: pickupPoints[0].address.city,\n state: pickupPoints[0].address.state,\n country: pickupPoints[0].address.country,\n street: pickupPoints[0].address.street,\n number: null,\n neighborhood: null,\n complement: null,\n reference: null,\n geoCoordinates: [],\n },\n logisticsInfo: updatedLogisticsInfo,\n },\n }\n\n if (marketplace) {\n vtexOrderData.paymentData = {\n payments: [\n {\n installments: 1,\n paymentSystem: glovoOrder.payment_method,\n referenceValue: totalValue,\n value: totalValue,\n },\n ],\n }\n }\n\n return vtexOrderData\n}\n\nexport const createAuthorizationPayload = (\n orderIdentifier: string,\n marketplace: boolean,\n glovoOrder: GlovoOrder\n): AuthorizeOrderPayload | AuthorizeMarketplaceOrderPayload => {\n const payload = marketplace\n ? {\n marketplaceOrderGroup: orderIdentifier,\n authorizationReceipt: {\n date: glovoOrder.order_time,\n receipt: glovoOrder.order_code,\n },\n }\n : {\n marketplaceOrderId: orderIdentifier,\n }\n\n return payload\n}\n\nfunction getEmail(name: string, phone_number: string, email: string) {\n return (\n `${name.replace(/\\W/g, '').toLowerCase()}_${phone_number.replace(\n /\\W/g,\n ''\n )}@glovointegration.com` ?? email\n )\n}\n\nfunction getFirstName(name: string) {\n return name.split(' ')[0]\n}\n\nfunction getLastName(name: string) {\n return name.split(' ')[1]\n}\n\nfunction getReceiverName(name: string, phone_number: string) {\n return `${name} - ${phone_number}`\n}\n\n/**\n * Function to get the items that were changed in an order\n *\n * @param changesData Order modification event changesAttachements\n * @returns changedItems Object with the items that were changed { itemId: { quantity: number } }\n */\nexport function getChangedItems(changesData: ChangesData[]) {\n const changedItems: Record<string, { quantity: number }> = {}\n\n for (const change of changesData) {\n for (const item of change.itemsAdded) {\n if (!changedItems[item.id]) {\n changedItems[item.id] = { quantity: item.quantity }\n } else {\n changedItems[item.id].quantity += item.quantity\n }\n }\n\n for (const item of change.itemsRemoved) {\n if (!changedItems[item.id]) {\n changedItems[item.id] = { quantity: -item.quantity }\n } else {\n changedItems[item.id].quantity -= item.quantity\n }\n }\n }\n\n return changedItems\n}\n\n```" } ]
code_glovo-integration_39d421f2
[ { "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 glovo-integration/node/utils/records.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ServiceError } from './errors'\n\nexport const generateStoreMenuRecord = async (\n ctx: Context,\n affiliateId: string\n) => {\n const {\n clients: { recordsManager },\n } = ctx\n\n try {\n const glovoMenu = await recordsManager.getGlovoMenu()\n\n if (!glovoMenu) {\n throw new Error('Unable to get Glovo Menu')\n }\n\n const storeMenuRecord: StoreMenuRecord = {\n items: {},\n lastUpdated: '',\n }\n\n const itemIds = Object.keys(glovoMenu)\n\n for await (const item of itemIds) {\n const recordItem = await recordsManager.getProductRecord(\n affiliateId,\n item\n )\n\n if (recordItem) {\n storeMenuRecord.items[item] = recordItem\n }\n }\n\n storeMenuRecord.lastUpdated = Date()\n\n recordsManager.saveStoreMenuRecord(affiliateId, storeMenuRecord)\n } catch (error) {\n throw new ServiceError({\n message: error.message,\n reason: `There was a problem creating the store menu record for ${affiliateId}`,\n metric: 'menu',\n })\n }\n}\n\n```" } ]
code_glovo-integration_5fb096b4
[ { "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 glovo-integration/node/utils/index.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport * from './errors'\nexport * from './glovo'\nexport * from './orders'\nexport * from './simulation'\nexport * from './utils'\nexport * from './records'\nexport * from './requests'\n\n```" } ]
code_glovo-integration_fe7d16b5
[ { "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 glovo-integration/node/utils/glovo.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { OrderFormItem, SimulationOrderForm } from '@vtex/clients'\nimport type {\n GlovoIntegrationSettings,\n MaxItemsForSimulation,\n} from 'vtex.glovo-integration'\n\nimport {\n ACCEPTED,\n INVOICED,\n READY_FOR_PICKUP,\n GLOVO,\n APP_SETTINGS,\n READY_FOR_HANDLING,\n WAITING_SELLER_HANDLING,\n MAX_ITEMS_FOR_SIMULATION,\n} from '../constants'\nimport { ServiceError } from './errors'\nimport { requestWithRetries } from './requests'\nimport {\n createGlovoBulkUpdatePayload,\n createSimulationItems,\n createSimulationPayload,\n iterationLimits,\n simulateItem,\n} from './simulation'\n\nexport const setGlovoStatus = (state: string) => {\n if (state === WAITING_SELLER_HANDLING) return ACCEPTED\n if (state === READY_FOR_HANDLING) return ACCEPTED\n if (state === INVOICED) return READY_FOR_PICKUP\n\n return ''\n}\n\nexport const updateGlovoProduct = async (\n ctx: Context,\n catalogUpdate: CatalogChange\n) => {\n const {\n clients: { vbase, recordsManager },\n vtex: { logger },\n } = ctx\n\n const appSettings: GlovoIntegrationSettings = await vbase.getJSON(\n GLOVO,\n APP_SETTINGS,\n true\n )\n\n if (!appSettings.glovoToken) {\n logger.error({\n message: 'Missing Glovo token. Please check app settings',\n })\n\n return\n }\n\n const { stores } = appSettings\n const { IdSku, IsActive } = catalogUpdate\n\n if (!stores) {\n logger.error({\n message: 'Missing or invalid store information',\n catalogUpdate,\n })\n\n return\n }\n\n const glovoMenu = await recordsManager.getGlovoMenu()\n\n if (!glovoMenu[IdSku]) {\n return\n }\n\n for await (const store of stores) {\n const { id, storeName, glovoStoreId } = store\n\n const simulation = await simulateItem(IdSku, store, ctx)\n\n if (!simulation) {\n logger.warn({\n message: `Simulation failed for product with sku ${IdSku} for store ${storeName}`,\n catalogUpdate,\n })\n\n continue\n }\n\n const { price, available } = simulation\n\n let newProduct = false\n let productRecord = await recordsManager.getProductRecord(\n glovoStoreId,\n IdSku\n )\n\n if (!productRecord) {\n if (!IsActive) {\n continue\n }\n\n newProduct = true\n\n const newProductRecord: ProductRecord = {\n id: IdSku,\n available,\n price,\n }\n\n productRecord = newProductRecord\n }\n\n let glovoPayload: GlovoProductUpdate = {\n skuId: IdSku,\n glovoStoreId,\n }\n\n if (IsActive && price) {\n glovoPayload = {\n ...glovoPayload,\n price,\n available,\n }\n } else {\n glovoPayload.available = false\n }\n\n if (\n !newProduct &&\n productRecord.price === glovoPayload.price &&\n productRecord.available === glovoPayload.available\n ) {\n continue\n }\n\n try {\n const updatedProductRecord: ProductRecord = {\n id: IdSku,\n price: glovoPayload.price,\n available: glovoPayload.available,\n }\n\n recordsManager.saveProductRecord(\n glovoStoreId,\n IdSku,\n updatedProductRecord\n )\n\n let storeMenuUpdates = await recordsManager.getStoreMenuUpdates(\n glovoStoreId\n )\n\n if (!storeMenuUpdates) {\n // If the Store Menu Updates Record does not exist already, it is created.\n storeMenuUpdates = {\n current: {\n responseId: null,\n createdAt: Date.now(),\n storeId: id,\n storeName,\n glovoStoreId,\n items: [],\n },\n }\n }\n\n const currentUpdateItemsIds = storeMenuUpdates.current.items.map(\n (item) => item.id\n )\n\n if (!currentUpdateItemsIds.includes(IdSku)) {\n storeMenuUpdates.current.items.push(updatedProductRecord)\n } else {\n storeMenuUpdates.current.items.map((item) => {\n if (item.id === IdSku) {\n item.id = IdSku\n item.price = updatedProductRecord.price\n item.available = updatedProductRecord.available\n }\n\n return item\n })\n }\n\n recordsManager.saveStoreMenuUpdates(glovoStoreId, storeMenuUpdates)\n\n logger.info({\n message: `Product with sku ${IdSku} from store ${glovoStoreId} has been updated`,\n updatedProductRecord,\n })\n } catch (error) {\n logger.error({\n message: `Product with sku ${IdSku} from store ${glovoStoreId} could not be updated`,\n data: error.response,\n })\n\n return error\n }\n }\n}\n\nexport const updateGlovoCompleteMenu = async (ctx: Context) => {\n const {\n clients: { vbase, checkout, glovo, recordsManager },\n vtex: { logger },\n } = ctx\n\n try {\n const appSettings: GlovoIntegrationSettings = await vbase.getJSON(\n GLOVO,\n APP_SETTINGS,\n true\n )\n\n if (!appSettings?.glovoToken) {\n logger.error({\n message: 'Menu update for stores failed',\n reason: 'Missing or invalid Glovo token. Please check app settings',\n })\n\n return\n }\n\n const { glovoToken, stores, minimumStock } = appSettings\n\n if (!stores?.length) {\n logger.error({\n message: 'Menu update for stores failed',\n reason: 'Missing or invalid stores information',\n })\n\n return\n }\n\n const glovoMenu = await recordsManager.getGlovoMenu()\n\n const { max }: MaxItemsForSimulation = await vbase.getJSON(\n GLOVO,\n MAX_ITEMS_FOR_SIMULATION,\n true\n )\n\n const maxItemsForSimulation = max ?? 300\n\n const iterations = Math.ceil(\n Object.keys(glovoMenu).length / maxItemsForSimulation\n )\n\n for await (const store of stores) {\n logger.info({\n message: `Updating menu for store ${store.storeName}`,\n })\n\n const {\n affiliateId,\n sellerId,\n salesChannel,\n glovoStoreId,\n storeName,\n postalCode,\n country,\n } = store\n\n let payloadItems: OrderFormItem[] = []\n\n for (let i = 0; i < iterations; i++) {\n const [from, to] = iterationLimits(i, maxItemsForSimulation)\n\n const itemsForSimulation = Object.keys(glovoMenu).slice(from, to)\n\n const simulationItems = createSimulationItems(\n itemsForSimulation,\n sellerId,\n minimumStock\n )\n\n const [simulationPayload, querystring] = createSimulationPayload({\n items: simulationItems,\n affiliateId,\n salesChannel,\n postalCode,\n country,\n })\n\n let simulation: SimulationOrderForm\n\n try {\n // eslint-disable-next-line no-await-in-loop\n simulation = await requestWithRetries(\n checkout.simulation(simulationPayload, querystring)\n )\n } catch (error) {\n logger.warn({\n message: `Catalog update for store ${storeName} - ${glovoStoreId} failed`,\n reason: `Simulation for items failed`,\n })\n\n continue\n }\n\n if (!simulation.items.length) {\n logger.warn({\n message: `Catalog update for store ${storeName} - ${glovoStoreId} failed`,\n reason: `Simulation returned no items`,\n })\n\n continue\n }\n\n payloadItems = [...payloadItems, ...simulation.items]\n }\n\n const glovoPayload = createGlovoBulkUpdatePayload(\n payloadItems,\n minimumStock\n )\n\n try {\n const glovoResponse = await requestWithRetries<GlovoBulkUpdateResponse>(\n glovo.bulkUpdateProducts(glovoPayload, glovoStoreId, glovoToken)\n )\n\n logger.info({\n message: `Catalog for store ${storeName} - ${glovoStoreId} has been updated. (${payloadItems.length} items)`,\n glovoResponse,\n })\n\n recordsManager.saveStoreCompleteMenuUpdate(glovoStoreId, {\n items: [...glovoPayload.products],\n transactionId: glovoResponse.transaction_id,\n lastUpdated: Date(),\n successful: true,\n minimumStock,\n })\n } catch (error) {\n logger.error({\n message: `Catalog for store ${storeName} - ${glovoStoreId} could not be updated`,\n reason: `Bulk update request failed`,\n })\n\n recordsManager.saveStoreCompleteMenuUpdate(glovoStoreId, {\n items: [...glovoPayload.products],\n transactionId: null,\n lastUpdated: Date(),\n successful: false,\n minimumStock,\n })\n\n continue\n }\n }\n } catch (error) {\n throw new ServiceError({\n message: error.message,\n reason: error.reason ?? 'Catalog update for stores failed',\n metric: 'menu',\n data: error.response?.data,\n })\n }\n}\n\nexport const updateGlovoPartialMenu = async (ctx: Context) => {\n const {\n clients: { vbase, glovo, recordsManager },\n vtex: { logger },\n } = ctx\n\n const appSettings: GlovoIntegrationSettings = await vbase.getJSON(\n GLOVO,\n APP_SETTINGS,\n true\n )\n\n if (!appSettings.glovoToken) {\n logger.error({\n message: 'Missing or invalid Glovo token. Please check app settings',\n })\n\n return\n }\n\n const { stores, glovoToken } = appSettings\n\n if (!stores?.length) {\n logger.error({\n message: 'Missing or invalid stores information',\n })\n\n return\n }\n\n // Send a partial bulk product update for each store\n for await (const store of stores) {\n const { id, storeName, glovoStoreId } = store\n\n try {\n const menuUpdates = await recordsManager.getStoreMenuUpdates(glovoStoreId)\n\n const { current: currentUpdate } = menuUpdates\n\n const glovoPayload: GlovoProductBulkUpdate = {\n products: currentUpdate.items,\n }\n\n const newUpdate: MenuUpdatesItem = {\n responseId: null,\n createdAt: new Date().getTime(),\n storeId: id,\n storeName,\n glovoStoreId,\n items: [],\n }\n\n const glovoResponse = await glovo.bulkUpdateProducts(\n glovoPayload,\n glovoStoreId,\n glovoToken\n )\n\n currentUpdate.responseId = glovoResponse.transaction_id\n menuUpdates.previous = currentUpdate\n menuUpdates.current = newUpdate\n\n recordsManager.saveStoreMenuUpdates(glovoStoreId, menuUpdates)\n\n logger.info({\n message: `Menu for store ${storeName} with id ${id} was updated`,\n data: menuUpdates,\n })\n } catch (error) {\n logger.error({\n message: `Partial Catalog for store ${storeName} with ${id} could not be updated`,\n data: error.response,\n })\n }\n }\n}\n\n```" } ]
code_glovo-integration_88a1d67d
[ { "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 glovo-integration/node/utils/simulation.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type {\n OrderFormItem,\n PayloadItem,\n SimulationPayload,\n} from '@vtex/clients'\nimport type { Store } from 'vtex.glovo-integration'\n\nimport { AVAILABLE } from '../constants'\nimport { isSkuAvailable } from './utils'\n\nexport const createSimulationItem = ({\n id,\n quantity,\n sellerId,\n}: SimulationItem): PayloadItem => {\n return {\n id,\n quantity,\n seller: sellerId,\n }\n}\n\nexport const createSimulationItems = (\n items: string[],\n sellerId: string,\n quantity = 1\n): PayloadItem[] => {\n const simulationItems: PayloadItem[] = []\n\n for (const item of items) {\n const payloadItem: PayloadItem = {\n id: item,\n quantity,\n seller: sellerId,\n }\n\n simulationItems.push(payloadItem)\n }\n\n return simulationItems\n}\n\nexport function iterationLimits(step: number, maxItemsForSimulation: number) {\n return [\n maxItemsForSimulation * step,\n maxItemsForSimulation * step + maxItemsForSimulation - 1,\n ]\n}\n\nexport const createSimulationPayload = ({\n items,\n affiliateId,\n salesChannel,\n postalCode,\n country,\n}: CreateSimulationArgs): [SimulationPayload, string] => {\n const simulationPayload = {\n items,\n postalCode,\n country,\n }\n\n const queryString = `?affiliateId=${affiliateId}&sc=${salesChannel}`\n\n return [simulationPayload, queryString]\n}\n\nexport const createGlovoBulkUpdatePayload = (\n items: OrderFormItem[],\n minimumStock = 1\n): GlovoProductBulkUpdate => {\n const payload: GlovoProductBulkUpdate = {\n products: [],\n }\n\n for (const item of items) {\n const { id, price, listPrice, unitMultiplier, availability, quantity } =\n item\n\n const available = availability === AVAILABLE && quantity >= minimumStock\n\n const payloadProduct: GlovoProductPatch = {\n id,\n available,\n }\n\n if (available) {\n payloadProduct.price = (Math.max(price, listPrice) * unitMultiplier) / 100\n }\n\n payload.products.push(payloadProduct)\n }\n\n return payload\n}\n\nexport const simulateItem = async (\n IdSku: string,\n store: Store,\n ctx: Context\n): Promise<SimulatedItem | null> => {\n const {\n clients: { checkout },\n vtex: { logger },\n } = ctx\n\n const { affiliateId, sellerId, salesChannel, postalCode, country } = store\n const simulationItem = createSimulationItem({\n id: IdSku,\n quantity: 1,\n sellerId,\n })\n\n const simulationPayload = createSimulationPayload({\n items: [simulationItem],\n affiliateId,\n salesChannel,\n postalCode,\n country,\n })\n\n try {\n const simulation = await checkout.simulation(...simulationPayload)\n\n const {\n items: [item],\n } = simulation\n\n let itemInfo = {\n price: 0,\n available: false,\n }\n\n if (isSkuAvailable(item)) {\n const { price, listPrice, unitMultiplier } = item\n\n itemInfo = {\n price: (Math.max(price, listPrice) * unitMultiplier) / 100,\n available: true,\n }\n }\n\n return itemInfo\n } catch (error) {\n logger.error({\n message:\n error.message ?? `Simulation for product with skuId ${IdSku} failed`,\n data: error.response,\n })\n\n return null\n }\n}\n\n```" } ]
code_glovo-integration_71cee02f
[ { "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 glovo-integration/node/resolvers/getAppSettings.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { GlovoIntegrationSettings } from 'vtex.glovo-integration'\n\nimport { APP_SETTINGS, GLOVO } from '../constants'\n\nexport const getGlovoIntegrationSettings = async (\n _: unknown,\n __: unknown,\n ctx: Context\n): Promise<GlovoIntegrationSettings> => {\n const {\n clients: { vbase },\n } = ctx\n\n const appSettings: GlovoIntegrationSettings = await vbase.getJSON(\n GLOVO,\n APP_SETTINGS,\n true\n )\n\n return appSettings\n}\n\n```" } ]
code_glovo-integration_1f83a77c
[ { "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 glovo-integration/node/resolvers/maxItemsForSimulation.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { MaxItemsForSimulation } from 'vtex.glovo-integration'\n\nimport { GLOVO, MAX_ITEMS_FOR_SIMULATION } from '../constants'\n\nexport async function getMaxItemsForSimulation(\n _root: unknown,\n _args: unknown,\n ctx: Context\n): Promise<MaxItemsForSimulation | null> {\n const {\n clients: { vbase },\n } = ctx\n\n try {\n const maxItemsForSimulation: MaxItemsForSimulation = await vbase.getJSON(\n GLOVO,\n MAX_ITEMS_FOR_SIMULATION,\n true\n )\n\n return maxItemsForSimulation\n } catch (error) {\n return null\n }\n}\n\nexport async function updateMaxItemsForSimulation(\n _root: unknown,\n { max }: { max: number },\n ctx: Context\n): Promise<MaxItemsForSimulation | null> {\n const {\n clients: { vbase },\n } = ctx\n\n try {\n await vbase.saveJSON(GLOVO, MAX_ITEMS_FOR_SIMULATION, { max })\n\n return { max }\n } catch (error) {\n return null\n }\n}\n\n```" } ]
code_glovo-integration_b38d0b5f
[ { "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 glovo-integration/node/resolvers/saveAppSettings.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { SaveGlovoIntegrationSettings } from 'vtex.glovo-integration'\n\nimport { validateInputs } from '../../common/utils'\nimport { APP_SETTINGS, GLOVO } from '../constants'\n\nexport const saveGlovoIntegrationSettings = async (\n _: unknown,\n { settings }: { settings: SaveGlovoIntegrationSettings },\n ctx: Context\n): Promise<boolean> => {\n const {\n clients: { vbase },\n vtex: { logger },\n } = ctx\n\n if (!validateInputs(settings)) {\n return false\n }\n\n const validatedSettings: SaveGlovoIntegrationSettings = {\n ...settings,\n minimumStock: settings.minimumStock > 20 ? 20 : settings.minimumStock,\n }\n\n try {\n await vbase.saveJSON(GLOVO, APP_SETTINGS, validatedSettings)\n\n return true\n } catch (error) {\n logger.error({\n message: `Unable to save apps settings`,\n error: error.response,\n })\n\n return false\n }\n}\n\n```" } ]
code_glovo-integration_b6b71998
[ { "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 glovo-integration/node/resolvers/index.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { getGlovoIntegrationSettings } from './getAppSettings'\nimport { saveGlovoIntegrationSettings } from './saveAppSettings'\nimport {\n getMaxItemsForSimulation,\n updateMaxItemsForSimulation,\n} from './maxItemsForSimulation'\n\nconst queries = {\n getGlovoIntegrationSettings,\n getMaxItemsForSimulation,\n}\n\nconst mutations = {\n saveGlovoIntegrationSettings,\n updateMaxItemsForSimulation,\n}\n\nexport const resolvers = {\n Query: {\n ...queries,\n },\n Mutation: {\n ...mutations,\n },\n}\n\n```" } ]
code_glovo-integration_7c7c7a8c
[ { "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 glovo-integration/node/middlewares/events/updateGlovoOrderStatus.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {\n getStoreInfoFromStoreId,\n ServiceError,\n setGlovoStatus,\n} from '../../utils'\n\nexport async function updateGlovoOrderStatus(ctx: StatusChangeContext) {\n const {\n body,\n clients: { glovo },\n state: { glovoToken, stores },\n vtex: { logger },\n } = ctx\n\n const { orderId, currentState } = body\n const [orderIdAffiliate, glovoOrderId] = orderId.split('-')\n\n const storeInfo = getStoreInfoFromStoreId(orderIdAffiliate, stores)\n\n const { glovoStoreId } = storeInfo\n const status = setGlovoStatus(currentState)\n\n if (!status) {\n logger.warn({\n message: `The status is required for order modification for order ${orderId}`,\n data: body,\n })\n\n return\n }\n\n const glovoPayload: GlovoUpdateOrderStatus = {\n glovoStoreId,\n glovoOrderId,\n status,\n }\n\n try {\n await glovo.updateOrderStatus(glovoPayload, glovoToken)\n\n logger.info({\n message: `Glovo order ${glovoPayload.glovoOrderId} status updated`,\n glovoPayload,\n })\n } catch (error) {\n throw new ServiceError({\n message: error.message,\n reason:\n error.reason ??\n `Glovo order ${glovoPayload.glovoOrderId} status update failed`,\n metric: 'orders',\n data: {\n body,\n },\n error: error.response?.data,\n })\n }\n}\n\n```" } ]
code_glovo-integration_444677bb
[ { "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 glovo-integration/node/middlewares/events/modifyGlovoOrder.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/naming-convention */\nimport { getChangedItems, isValidAffiliateId, ServiceError } from '../../utils'\n\nexport async function modifyGlovoOrder(\n ctx: StatusChangeContext,\n next: () => Promise<void>\n) {\n const {\n body,\n clients: { glovo, orders, recordsManager },\n state: { glovoToken, stores },\n vtex: { logger },\n } = ctx\n\n const { orderId } = body\n const [orderIdAffiliate] = orderId.split('-')\n\n /**\n * Check if the order comes from Glovo and remove the affiliateId (i.e. 'TST') from the VTEX orderId to get the glovoOrderId.\n */\n if (!isValidAffiliateId(orderIdAffiliate, stores)) {\n return\n }\n\n try {\n let order: VTEXOrder\n\n try {\n order = await orders.getOrder(orderId)\n } catch (error) {\n throw new Error(`Error fetching order ${orderId}`)\n }\n\n if (!order.changesAttachment) {\n return\n }\n\n let orderRecord: OrderRecord\n\n try {\n orderRecord = await recordsManager.getOrderRecord(orderId)\n } catch (error) {\n throw new Error(`The record for the order ${orderId} was not found`)\n }\n\n const {\n glovoOrder: { order_id, store_id, products },\n } = orderRecord\n\n const {\n changesAttachment: { changesData },\n } = order\n\n const replacements: GlovoModifyReplacement[] = []\n const removedProducts: string[] = []\n const addedProducts: GlovoModifiedProduct[] = []\n const changedItems = getChangedItems(changesData)\n\n if (Object.keys(changedItems).length <= 0) {\n return\n }\n\n // Replacements and removed products\n for (const product of products) {\n const { id } = product\n\n if (!changedItems[id]) {\n continue\n }\n\n const updatedQuantity = product.quantity + changedItems[id].quantity\n\n if (updatedQuantity <= 0) {\n removedProducts.push(product.purchased_product_id)\n } else {\n replacements.push({\n purchased_product_id: product.purchased_product_id,\n product: {\n id,\n quantity: updatedQuantity,\n attributes: product.attributes,\n },\n })\n }\n }\n\n // Added products\n const itemsInOrder = products.map((product) => product.id)\n\n for (const [id, item] of Object.entries(changedItems)) {\n if (!itemsInOrder.includes(id)) {\n addedProducts.push({\n id,\n quantity: item.quantity,\n attributes: [],\n })\n }\n }\n\n const payload: GlovoModifyOrderPayload = {\n glovoStoreId: store_id,\n glovoOrderId: order_id,\n replacements,\n removed_purchases: removedProducts,\n added_products: addedProducts,\n }\n\n logger.info({\n message: `Glovo order ${order_id} payload for modification`,\n data: payload,\n })\n\n let modifiedGlovoOrder\n\n try {\n modifiedGlovoOrder = await glovo.modifyOrder(payload, glovoToken)\n } catch (error) {\n throw new Error(`Unable to modify Glovo order for order ${orderId}`)\n }\n\n const data: OrderRecord = {\n ...orderRecord,\n invoiced: order,\n hasChanged: true,\n invoicedAt: new Date().getTime(),\n }\n\n await recordsManager.saveOrderRecord(orderId, data)\n\n logger.info({\n message: `Glovo order ${order_id} was modified successfully`,\n data: modifiedGlovoOrder,\n })\n\n await next()\n } catch (error) {\n throw new ServiceError({\n message: `Order modification for order ${orderId} failed`,\n reason: error.message,\n metric: 'orders',\n data: { body },\n })\n }\n}\n\n```" } ]
code_glovo-integration_b8aa9ee4
[ { "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 glovo-integration/node/middlewares/events/validateEventSettings.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { UserInputError } from '@vtex/api'\nimport type { GlovoIntegrationSettings } from 'vtex.glovo-integration'\n\nimport { APP_SETTINGS, GLOVO } from '../../constants'\n\nexport async function validateEventSettings(\n ctx: StatusChangeContext,\n next: () => Promise<void>\n) {\n const {\n clients: { vbase },\n } = ctx\n\n const appSettings: GlovoIntegrationSettings = await vbase.getJSON(\n GLOVO,\n APP_SETTINGS,\n true\n )\n\n if (!appSettings.glovoToken) {\n throw new UserInputError(\n 'Missing or invalid Glovo token. Please check app settings'\n )\n }\n\n ctx.state.stores = appSettings.stores\n ctx.state.glovoToken = appSettings.glovoToken\n\n await next()\n}\n\n```" } ]
code_glovo-integration_847f43fd
[ { "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 glovo-integration/node/middlewares/events/eventsErrorHandler.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport async function eventsErrorHandler(\n ctx: StatusChangeContext,\n next: () => Promise<void>\n) {\n const {\n vtex: { logger },\n } = ctx\n\n try {\n await next()\n } catch (error) {\n logger.error({\n orderId: ctx.body.orderId ?? 'No orderId information',\n message: error.message,\n reason: error.reason,\n metric: error.metric,\n data: error.data,\n error: error.error,\n })\n\n ctx.body = error.reason\n }\n}\n\n```" } ]
code_glovo-integration_f8c3861a
[ { "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 glovo-integration/node/middlewares/events/index.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { eventsErrorHandler } from './eventsErrorHandler'\nimport { modifyGlovoOrder } from './modifyGlovoOrder'\nimport { updateGlovoOrderStatus } from './updateGlovoOrderStatus'\nimport { validateEventSettings } from './validateEventSettings'\n\nexport const events = {\n updateGlovoOrder: [\n eventsErrorHandler,\n validateEventSettings,\n modifyGlovoOrder,\n updateGlovoOrderStatus,\n ],\n}\n\n```" } ]
code_glovo-integration_00bc0ff7
[ { "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 glovo-integration/node/middlewares/routes/glovoMenuCompleteUpdate.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { updateGlovoCompleteMenu } from '../../utils'\n\nexport async function glovoMenuCompleteUpdate(\n ctx: Context,\n next: () => Promise<void>\n) {\n const {\n vtex: { logger },\n } = ctx\n\n // Send response to VTEX Notificator to avoid retries\n await next()\n\n try {\n updateGlovoCompleteMenu(ctx)\n } catch (error) {\n logger.error({\n message: `There was a problem updating the Glovo menu`,\n data: error.response?.data,\n })\n\n return error\n }\n}\n\n```" } ]
code_glovo-integration_0b57603f
[ { "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 glovo-integration/node/middlewares/routes/saveOrderRecord.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ServiceError } from '../../utils'\n\nexport async function saveOrderRecord(ctx: Context) {\n const {\n clients: { recordsManager },\n state: { glovoOrder, vtexOrder },\n } = ctx\n\n const { orderId } = vtexOrder\n const currentDate = new Date()\n const data: OrderRecord = {\n orderId,\n glovoOrder,\n invoiced: null,\n hasChanged: false,\n createdAt: currentDate.getTime(),\n }\n\n try {\n await recordsManager.saveOrderRecord(orderId, data)\n\n ctx.status = 201\n } catch (error) {\n throw new ServiceError({\n message: error.message,\n reason: `Unable to save order record for order ${vtexOrder}`,\n metric: 'orders',\n data: { orderId, orderRecord: data },\n error: error.response?.data,\n })\n }\n}\n\n```" } ]
code_glovo-integration_03d6ab6a
[ { "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 glovo-integration/node/middlewares/routes/errorHandler.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport async function errorHandler(ctx: Context, next: () => Promise<void>) {\n const {\n vtex: { logger },\n } = ctx\n\n try {\n await next()\n } catch (error) {\n logger.error({\n glovoOrder: ctx.state?.glovoOrder ?? 'No Glovo order information',\n message: error.message,\n reason: error.reason,\n metric: error.metric,\n data: error.data,\n error: error.error,\n })\n\n ctx.body = error.reason\n ctx.app.emit('error', error, ctx)\n }\n}\n\n```" } ]
code_glovo-integration_a490fcf6
[ { "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 glovo-integration/node/middlewares/routes/createOrder.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ServiceError, createVtexOrderData } from '../../utils'\n\nexport async function createOrder(ctx: Context, next: () => Promise<void>) {\n const {\n state: {\n glovoOrder,\n orderSimulation,\n storeInfo,\n marketplace,\n clientProfileData,\n },\n clients: { orders },\n vtex: { account },\n } = ctx\n\n const { salesChannel, affiliateId, sellerId } = storeInfo\n\n try {\n const vtexOrderData = createVtexOrderData(\n glovoOrder,\n orderSimulation,\n clientProfileData,\n marketplace,\n account\n )\n\n let createdOrder\n\n switch (marketplace && sellerId !== '1') {\n case true:\n createdOrder = await orders.createMarketplaceOrder(\n vtexOrderData,\n salesChannel,\n affiliateId\n )\n\n ctx.state.vtexOrder = createdOrder.orders[0]\n break\n\n default:\n createdOrder = await orders.createOrder(\n vtexOrderData,\n salesChannel,\n affiliateId\n )\n\n ctx.state.vtexOrder = createdOrder[0]\n break\n }\n\n await next()\n } catch (error) {\n throw new ServiceError({\n message: error.message,\n reason:\n error.reason ??\n `Order creation for order Glovo Order ${glovoOrder.order_id} failed`,\n metric: 'orders',\n data: error.data ?? { glovoOrder },\n error: error.error ?? error.response?.data,\n })\n }\n}\n\n```" } ]
code_glovo-integration_e67d4c0e
[ { "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 glovo-integration/node/middlewares/routes/storeMenuUpdate.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ServiceError } from '../../utils'\n\nexport async function storeMenuUpdates(ctx: Context) {\n const {\n clients: { recordsManager },\n params: { affiliateId },\n } = ctx\n\n try {\n const storeMenuUpdatesRecord =\n await recordsManager.getStoreCompleteMenuUpdate(affiliateId)\n\n ctx.body = storeMenuUpdatesRecord ?? 'Store menu updates record not found'\n } catch (error) {\n throw new ServiceError({\n message: error.message,\n reason:\n error.reason ??\n `There was a problem getting the Glovo menu updates for the specified store`,\n metric: 'menu',\n error: error.response?.data,\n })\n }\n}\n\n```" } ]
code_glovo-integration_0423c4ea
[ { "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 glovo-integration/node/middlewares/routes/saveGlovoMenu.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { json } from 'co-body'\nimport type { GlovoIntegrationSettings, Store } from 'vtex.glovo-integration'\n\nimport { APP_SETTINGS, GLOVO } from '../../constants'\nimport { ServiceError } from '../../utils'\n\nexport async function saveGlovoMenu(ctx: Context) {\n const {\n clients: { vbase, recordsManager },\n } = ctx\n\n try {\n // Create/update Glovo Menu record\n const glovoMenuItems: number[] | string[] = await json(ctx.req)\n const glovoMenu: GlovoMenu = {}\n\n for (const skuId of glovoMenuItems) {\n glovoMenu[skuId] = true\n }\n\n await recordsManager.saveGlovoMenu(glovoMenu)\n\n // Create initial Store Menu Updates record\n const appSettings: GlovoIntegrationSettings = await vbase.getJSON(\n GLOVO,\n APP_SETTINGS,\n true\n )\n\n const { stores }: { stores: Store[] } = appSettings\n\n const newStores: StoreMenuUpdates[] = []\n\n for await (const store of stores) {\n const menuUpdatesRecord = await recordsManager.getStoreMenuUpdates(\n store.glovoStoreId\n )\n\n if (!menuUpdatesRecord) {\n const { id, storeName, glovoStoreId } = store\n const storeMenuUpdates: StoreMenuUpdates = {\n current: {\n responseId: null,\n createdAt: new Date().getTime(),\n storeId: id,\n storeName,\n glovoStoreId,\n items: [],\n },\n }\n\n newStores.push(storeMenuUpdates)\n await recordsManager.saveStoreMenuUpdates(\n glovoStoreId,\n storeMenuUpdates\n )\n }\n }\n\n ctx.status = 200\n ctx.body = { glovoMenu, newStores }\n } catch (error) {\n throw new ServiceError({\n message: error.message,\n reason: `There was a problem saving the Glovo menu`,\n metric: 'menu',\n data: ctx.req,\n error: error.response?.data,\n })\n }\n}\n\n```" } ]
code_glovo-integration_0fc3e9a0
[ { "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 glovo-integration/node/middlewares/routes/getGlovoMenuByStore.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ServiceError, generateStoreMenuRecord } from '../../utils'\n\nexport async function getGlovoMenuByStore(ctx: Context) {\n const {\n clients: { recordsManager },\n params: { affiliateId },\n } = ctx\n\n try {\n const storeMenuRecord = await recordsManager.getStoreMenuRecord(affiliateId)\n\n ctx.body = storeMenuRecord ?? 'Store menu record will be generated shortly'\n\n generateStoreMenuRecord(ctx, affiliateId)\n } catch (error) {\n throw new ServiceError({\n message: error.message,\n reason:\n error.reason ??\n `There was a problem getting the Glovo menu for the specified store`,\n metric: 'menu',\n error: error.response?.data,\n })\n }\n}\n\n```" } ]
code_glovo-integration_59abba7c
[ { "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 glovo-integration/node/middlewares/routes/authorizeOrder.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { createAuthorizationPayload, ServiceError } from '../../utils'\n\nexport async function authorizeOrder(ctx: Context, next: () => Promise<void>) {\n const {\n state: { vtexOrder, storeInfo, marketplace, glovoOrder },\n clients: { orders },\n vtex: { logger },\n } = ctx\n\n const { salesChannel, affiliateId, sellerId } = storeInfo\n let orderIdentifier: string\n\n switch (marketplace) {\n case true:\n orderIdentifier = vtexOrder.orderId\n break\n\n default:\n // eslint-disable-next-line no-case-declarations\n const orderInfo = vtexOrder as VTEXOrder\n\n orderIdentifier = orderInfo.marketplaceOrderId\n break\n }\n\n const payload = createAuthorizationPayload(\n orderIdentifier,\n marketplace,\n glovoOrder\n )\n\n let order\n\n try {\n switch (marketplace && sellerId !== '1') {\n case true:\n order = await orders.authorizeMarketplaceOrder(\n payload as AuthorizeMarketplaceOrderPayload,\n orderIdentifier\n )\n break\n\n default:\n order = await orders.authorizeOrder(\n payload as AuthorizeOrderPayload,\n vtexOrder.orderId,\n salesChannel,\n affiliateId\n )\n break\n }\n\n logger.info({\n message: `Order ${orderIdentifier} has been placed.`,\n order,\n })\n\n ctx.state.vtexOrder = vtexOrder\n\n await next()\n } catch (error) {\n throw new ServiceError({\n message: error.message,\n reason:\n error.reason ?? `Authorization for order ${orderIdentifier} failed`,\n metric: 'orders',\n data: { glovoOrder, vtexOrder },\n error: error.response?.data,\n })\n }\n}\n\n```" } ]
code_glovo-integration_48e6049c
[ { "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 glovo-integration/node/middlewares/routes/glovoProductUpdate.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { json } from 'co-body'\n\nimport { updateGlovoProduct } from '../../utils'\n\nexport async function glovoProductUpdate(\n ctx: Context,\n next: () => Promise<void>\n) {\n const {\n vtex: { logger },\n } = ctx\n\n const catalogUpdate: CatalogChange = await json(ctx.req)\n\n // Send response to VTEX Notificator to avoid retries.\n await next()\n\n try {\n updateGlovoProduct(ctx, catalogUpdate)\n } catch (error) {\n logger.error({\n message: `There was a problem updating ${catalogUpdate.IdSku} for affiliate ${catalogUpdate.IdAffiliate}`,\n data: error.response?.data,\n })\n\n return error\n }\n}\n\n```" } ]
code_glovo-integration_a679396f
[ { "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 glovo-integration/node/middlewares/routes/glovoMenuPartialUpdate.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { updateGlovoPartialMenu } from '../../utils'\n\nexport async function glovoMenuPartialUpdate(\n ctx: Context,\n next: () => Promise<void>\n) {\n const {\n vtex: { logger },\n } = ctx\n\n // Send response to VTEX Notificator to avoid retries\n await next()\n\n try {\n updateGlovoPartialMenu(ctx)\n } catch (error) {\n logger.error({\n message: `There was a problem updating the Glovo menu`,\n data: error.response?.data,\n })\n\n return error\n }\n}\n\n```" } ]
code_glovo-integration_fc4581c5
[ { "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 glovo-integration/node/middlewares/routes/getGlovoMenu.ts from the glovo-integration VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ServiceError } from '../../utils'\n\nexport async function getGlovoMenu(ctx: Context) {\n const {\n clients: { recordsManager },\n } = ctx\n\n try {\n const glovoMenu = await recordsManager.getGlovoMenu()\n\n ctx.body = glovoMenu\n } catch (error) {\n throw new ServiceError({\n message: error.message,\n reason: `There was a problem getting the Glovo menu`,\n metric: 'menu',\n error: error.response?.data,\n })\n }\n}\n\n```" } ]