id
stringlengths
12
53
messages
listlengths
3
3
code_admin-catalog-translations_3ba0e0e8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/SKUTranslation/graphql/uploadSkuTranslation.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation uploadSkuTranslations($locale: String!, $skus: Upload!) {\n uploadSkuTranslations(locale: $locale, skus: $skus)\n @context(provider: \"vtex.admin-catalog-translation\")\n}\n\n```" } ]
code_admin-catalog-translations_5d114a64
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/SKUTranslation/graphql/translateSKU.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation TranslateSKU($sku: SKUInputTranslation!, $locale: Locale!) {\n translateSKU(sku: $sku, locale: $locale)\n @context(provider: \"vtex.catalog-graphql\")\n}\n\n```" } ]
code_admin-catalog-translations_76180c91
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/SKUTranslation/graphql/startSkuTranslations.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery startSkuTranslations($locale: String!, $categoryId: String!) {\n skuTranslations(locale: $locale, categoryId: $categoryId)\n @context(provider: \"vtex.admin-catalog-translation\") {\n requestId\n }\n}\n\n```" } ]
code_admin-catalog-translations_57abbc87
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/SKUTranslation/graphql/skuUploadRequests.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery skuTranslationsUploadRequests {\n skuTranslationsUploadRequests\n @context(provider: \"vtex.admin-catalog-translation\")\n}\n\n```" } ]
code_admin-catalog-translations_0bdcd212
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/SKUTranslation/graphql/getSKU.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery GetSKU($identifier: SKUUniqueIdentifier) {\n sku(identifier: $identifier) @context(provider: \"vtex.catalog-graphql\") {\n id\n name\n }\n}\n\n```" } ]
code_admin-catalog-translations_03b93d31
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/CollectionsTranslation/graphql/uploadCollectionTranslation.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation uploadCollectionTranslations(\n $locale: String!\n $collections: Upload!\n $xVtexTenant: String!\n) {\n uploadCollectionTranslations(\n locale: $locale\n collections: $collections\n xVtexTenant: $xVtexTenant\n ) @context(provider: \"vtex.admin-catalog-translation\")\n}\n\n```" } ]
code_admin-catalog-translations_da1bd68b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/CollectionsTranslation/graphql/collectionUploadRequests.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery collectionTranslationsUploadRequests {\n collectionTranslationsUploadRequests\n @context(provider: \"vtex.admin-catalog-translation\")\n}\n\n```" } ]
code_admin-catalog-translations_ebdd8ef2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/CollectionsTranslation/graphql/translateMessages.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation translateMessages($saveArgs: SaveArgsV2!) {\n saveV2(args: $saveArgs) @context(provider: \"vtex.messages\")\n}\n\n```" } ]
code_admin-catalog-translations_53953bb8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/CollectionsTranslation/graphql/getAllCollections.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery getAllCollections(\n $locale: String!\n $active: Boolean\n $xVtexTenant: String!\n) {\n collectionTranslations(\n locale: $locale\n active: $active\n xVtexTenant: $xVtexTenant\n ) @context(provider: \"vtex.admin-catalog-translation\") {\n id\n name\n locale\n }\n}\n\n```" } ]
code_admin-catalog-translations_bde1ce00
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/CollectionsTranslation/graphql/messages.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery messages($args: IndexedMessages!) {\n userTranslations(args: $args) @context(provider: \"vtex.messages\") {\n context\n srcLang\n translations {\n lang\n translation\n }\n }\n}\n\n```" } ]
code_admin-catalog-translations_49b89e75
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/CollectionsTranslation/graphql/getCollections.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery GetCollection($fieldId: ID!) {\n collection(id: $fieldId) @context(provider: \"vtex.catalog-graphql\") {\n id\n name\n }\n}\n\n```" } ]
code_admin-catalog-translations_89923a50
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/ProductTranslation/graphql/productUploadRequests.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery productTranslationsUploadRequests {\n productTranslationsUploadRequests\n @context(provider: \"vtex.admin-catalog-translation\")\n}\n\n```" } ]
code_admin-catalog-translations_2801522a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/ProductTranslation/graphql/uploadProductTranslation.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation uploadProductTranslations($locale: String!, $products: Upload!) {\n uploadProductTranslations(locale: $locale, products: $products)\n @context(provider: \"vtex.admin-catalog-translation\")\n}\n\n```" } ]
code_admin-catalog-translations_ca9fc62a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/ProductTranslation/graphql/getProductTranslationRequests.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery getProdTranslationRequests {\n productTranslationRequests\n @context(provider: \"vtex.admin-catalog-translation\")\n}\n\n```" } ]
code_admin-catalog-translations_986d9dd1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/ProductTranslation/graphql/startProductTranslations.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery startProductTranslations($locale: String!, $categoryId: String!) {\n productTranslations(locale: $locale, categoryId: $categoryId)\n @context(provider: \"vtex.admin-catalog-translation\") {\n requestId\n }\n}\n\n```" } ]
code_admin-catalog-translations_719a7fb7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/ProductTranslation/graphql/translateProduct.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation TranslateProduct(\n $product: ProductInputTranslation!\n $locale: Locale!\n) {\n translateProduct(product: $product, locale: $locale)\n @context(provider: \"vtex.catalog-graphql\")\n}\n\n```" } ]
code_admin-catalog-translations_62341b90
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/ProductTranslation/graphql/getProduct.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery GetProduct($identifier: ProductUniqueIdentifier) {\n product(identifier: $identifier) @context(provider: \"vtex.catalog-graphql\") {\n id\n name\n description\n shortDescription\n metaTagDescription\n title\n linkId\n }\n}\n\n```" } ]
code_admin-catalog-translations_53fac6d7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of admin-catalog-translations/react/components/ProductTranslation/graphql/downloadProductTranslations.gql from the admin-catalog-translations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery downloadProductTranslations($requestId: String!) {\n downloadProductTranslation(requestId: $requestId)\n @context(provider: \"vtex.admin-catalog-translation\") {\n id\n name\n description\n shortDescription\n title\n locale\n linkId\n }\n}\n\n```" } ]
code_marketplace-financial-commission-cron_7f289f37
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/docs/README.md from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Marketplace Financial Commission Cron\n\nApplication used exclusively for the Financial Commission project and installed together with the `vtex.marketplace-financial-commission` app. For more information [click here](https://github.com/vtex-apps/marketplace-financial-commission).\n\nThe application has the function of calling the endpoints responsible for generating the dashboard and generating invoices. \n\n > 1. Call the `dashboard/generate` endpoint, from the `vtex.marketplace-financial-commission` app, to generate the dashboard data. The cron job is triggered in the middle of the night.\n > 2. Call the `invoice/generate` endpoint, from the `vtex.marketplace-financial-commission` app, to generate the invoice data. The cron job is triggered in the middle of the night.\n\n## Install\n\n```powershell\nvtex install vtex.marketplace-financial-commission-cron@1.1.x\n```\n\nIn order for it to work correctly in the account to be installed, it must have been previously installed `vtex.marketplace-financial-commission` app.\n\nWhen the app is installed it automatically triggers the `dashboard/generate` enpoint and generates the information of the last 30 days.\n\n\n## External Invoice\n\nIf the integration type configuration used in the marketplace of the `vtex.marketplace-financial-commission` app is set to `external`, the calls to the above mentioned `dashboard/generate` and `invoice/generate` endpoints will not be triggered.\n\n## Events\n\nThe `events` directory contains the schedulers to be created, which are activated when the application is installed. The `setupScheduleDashboard` file contains the process of sending the request for the generation of the last 30 days.\n\n![image](https://user-images.githubusercontent.com/14004558/186959432-d1287f28-5f2c-4d97-9ba8-c9687467743d.png)\n\n\nEn el directorio `configs\\schedulerTemplate` se encuentra la configuracion de los scheduler.\n\n![image](https://user-images.githubusercontent.com/14004558/186959391-72b98072-a9ba-4859-aed1-46c9028c7f9a.png)\n\n\n```" } ]
code_marketplace-financial-commission-cron_ebce0eb0
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/routes.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { method } from '@vtex/api'\n\nimport { generateDashboard } from './middlewares/dashboard/generateDashboard'\nimport { generateInvoice } from './middlewares/invoice/generateInvoice'\nimport { schedulerAuthenticationDashboard } from './middlewares/scheduler/schedulerAuthenticationDashboard'\nimport { schedulerAuthenticationInvoice } from './middlewares/scheduler/schedulerAuthenticationInvoice'\n\nconst routes = {\n dashboardGenerate: method({\n POST: [schedulerAuthenticationDashboard, generateDashboard],\n }),\n invoiceGenerate: method({\n POST: [schedulerAuthenticationInvoice, generateInvoice],\n }),\n}\n\nexport { routes }\n\n```" } ]
code_marketplace-financial-commission-cron_c69d9170
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/service.json from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"memory\": 256,\n \"ttl\": 10,\n \"timeout\": 60,\n \"minReplicas\": 2,\n \"maxReplicas\": 4,\n \"workers\": 1,\n \"routes\": {\n \"dashboardGenerate\": {\n \"path\": \"/_v/scheduler/dashboard/generate\",\n \"public\": true\n },\n \"invoiceGenerate\": {\n \"path\": \"/_v/scheduler/invoice/generate\",\n \"public\": true\n }\n },\n \"events\": {\n \"setupSchedulerDashboard\": {\n \"sender\": \"apps\",\n \"topics\": [\"setup\"]\n },\n \"setupSchedulerInvoice\": {\n \"sender\": \"apps\",\n \"topics\": [\"setup\"]\n }\n }\n}\n\n```" } ]
code_marketplace-financial-commission-cron_54ab5c02
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/utils.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport const generateToken = async (length: number): Promise<string> => {\n const characters =\n 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'.split('')\n\n const token = []\n\n for (let i = 0; i < length; i++) {\n const j: any = (Math.random() * (characters.length - 1)).toFixed(0)\n\n token[i] = characters[j]\n }\n\n return token.join('')\n}\n\n```" } ]
code_marketplace-financial-commission-cron_12c07511
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/package.json from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"co-body\": \"^6.0.0\",\n \"ramda\": \"^0.25.0\"\n },\n \"devDependencies\": {\n \"@types/co-body\": \"^0.0.3\",\n \"@types/jest\": \"^24.0.18\",\n \"@types/node\": \"^12.0.0\",\n \"@types/ramda\": \"types/npm-ramda#dist\",\n \"@vtex/api\": \"6.45.10\",\n \"@vtex/test-tools\": \"^3.4.3\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"typescript\": \"3.9.7\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty\"\n },\n \"version\": \"0.2.0\"\n}\n\n```" } ]
code_marketplace-financial-commission-cron_1b97e4da
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/constants.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport const constants = {\n SCHEDULER_CONFIGURATIONS_BUCKET: 'configs',\n SCHEDULER_KEY: 'bearerToken',\n SCHEDULER_KEY_INVOICE: 'bearerTokenInvoice',\n}\n\n```" } ]
code_marketplace-financial-commission-cron_f2af6e91
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/index.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { ParamsContext, RecorderState } from '@vtex/api'\nimport { Service } from '@vtex/api'\n\nimport type { Clients } from './clients'\nimport { clients } from './clients'\nimport { events } from './events'\nimport { routes } from './routes'\n\nexport default new Service<Clients, RecorderState, ParamsContext>({\n clients,\n events,\n routes,\n})\n\n```" } ]
code_marketplace-financial-commission-cron_a8f24724
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/clients/scheduler.ts from the marketplace-financial-commission-cron 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 Scheduler 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 setInitialScheduler = async (\n appName: string,\n schedulerData: SchedulerRequest\n ): Promise<void> => {\n await this.http.put(\n `/api/scheduler/master/${appName}/?version=4`,\n schedulerData,\n {\n metric: `schedulerMFC-setup`,\n }\n )\n }\n\n public deleteScheduler = async (\n appName: string,\n id: string\n ): Promise<void> => {\n await this.http.delete(`/api/scheduler/master/${appName}/${id}?version=4`, {\n metric: `schedulerMFC-delete`,\n })\n }\n}\n\n```" } ]
code_marketplace-financial-commission-cron_000653ed
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/clients/invoiceFinancialComission.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { AppClient } from '@vtex/api'\n\nexport default class InvoiceFinancialCommission extends AppClient {\n private routes: Routes = {\n generateInvoice: {\n endpoint: 'invoice/generate',\n metric: 'GenerateInvoice',\n },\n }\n\n constructor(context: IOContext, options?: InstanceOptions) {\n // TODO: update the app version\n super('vtex.marketplace-financial-commission@0.x', context, options)\n }\n\n private generateInvoiceFinancialCommission = async (\n route: Route,\n retries = 3\n ): Promise<any> => {\n const response = await this.http\n .get(route.endpoint, {\n metric: `marketplaceFinancialCommission-${route.metric}`,\n headers: {\n VtexIdclientAutCookie: this.context.authToken,\n },\n // TODO: update the app version\n baseURL: `http://app.io.vtex.com/vtex.marketplace-financial-commission/v0/${this.context.account}/${this.context.workspace}`,\n })\n .catch((error) => {\n console.error({\n msj: `Error to generate invoice - Endpoint ${route.endpoint}`,\n messageError: error.message,\n statusError: error.status,\n })\n\n this.context.logger.error({\n message: 'generateInvoiceError',\n error,\n route: route.endpoint,\n })\n\n if (retries > 0) {\n console.info(`Starting retry Invoices --------> ${retries}`)\n\n return this.generateInvoiceFinancialCommission(route, retries - 1)\n }\n\n const resultError = {\n msj: `Error to generate invoice - Endpoint ${route.endpoint}`,\n messageError: error.message,\n statusError: error.status,\n }\n\n return resultError\n })\n\n return response\n }\n\n public generateInvoice = async (): Promise<any> => {\n try {\n const response = await this.generateInvoiceFinancialCommission(\n this.routes.generateInvoice\n )\n\n return response\n } catch (error) {\n this.context.logger.error({\n message: 'generateInvoiceError',\n error,\n })\n\n throw new Error('generateInvoice error')\n }\n }\n}\n\n```" } ]
code_marketplace-financial-commission-cron_13194b05
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/clients/index.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { ClientsConfig } from '@vtex/api'\nimport { IOClients, LRUCache } from '@vtex/api'\n\nimport InvoiceFinancialCommission from './invoiceFinancialComission'\nimport MarketFinancialCommission from './marketplaceFinancialCommission'\nimport Scheduler from './scheduler'\nimport TypeIntegration from './typeIntegration'\n\nexport class Clients extends IOClients {\n public get marketFinancialCommission() {\n return this.getOrSet('marketFinancialCommission', MarketFinancialCommission)\n }\n\n public get scheduler() {\n return this.getOrSet('scheduler', Scheduler)\n }\n\n public get invoiceFinancialComission() {\n return this.getOrSet(\n 'invoiceFinancialComission',\n InvoiceFinancialCommission\n )\n }\n\n public get typeIntegration() {\n return this.getOrSet('typeIntegration', TypeIntegration)\n }\n}\n\nconst TIMEOUT_MS = 60000\nconst CONCURRENCY = 2\nconst memoryCache = new LRUCache<string, any>({ max: 5000 })\n\nmetrics.trackCache('financial-commission-cron', memoryCache)\n\nexport const clients: ClientsConfig<Clients> = {\n implementation: Clients,\n options: {\n default: {\n retries: 2,\n timeout: TIMEOUT_MS,\n memoryCache,\n },\n events: {\n exponentialTimeoutCoefficient: 2,\n exponentialBackoffCoefficient: 2,\n initialBackoffDelay: 50,\n retries: 1,\n timeout: TIMEOUT_MS,\n concurrency: CONCURRENCY,\n },\n },\n}\n\n```" } ]
code_marketplace-financial-commission-cron_9d6db88d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/clients/typeIntegration.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { AppClient } from '@vtex/api'\n\nexport default class TypeIntegration extends AppClient {\n private baseURL = `http://app.io.vtex.com/vtex.marketplace-financial-commission/v0/${this.context.account}/${this.context.workspace}`\n\n constructor(context: IOContext, options?: InstanceOptions) {\n // TODO: update the app version\n super('vtex.marketplace-financial-commission@0.x', context, options)\n }\n\n private getTypeIntegration = async (route: string) => {\n const response = await this.http.get(route, {\n headers: {\n VtexIdclientAutCookie: this.context.authToken,\n },\n baseURL: this.baseURL,\n })\n\n return response\n }\n\n public typeIntegration = async (): Promise<any> => {\n try {\n const response = await this.getTypeIntegration(\n this.routes.typeIntegration()\n )\n\n return response\n } catch (error) {\n this.context.logger.error({\n message: 'Get Type Integration Error',\n error,\n })\n\n throw new Error('Get Type Integration Error')\n }\n }\n\n private get routes() {\n const baseRoute = `_v/policy/financial-commission`\n\n return {\n typeIntegration: () => `/${baseRoute}/typeIntegration`,\n }\n }\n}\n\n```" } ]
code_marketplace-financial-commission-cron_321386d4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/clients/marketplaceFinancialCommission.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { AppClient } from '@vtex/api'\n\nexport default class MarketFinancialCommission extends AppClient {\n private routes: Routes = {\n dashboardGenerate: {\n endpoint: 'dashboard/generate',\n metric: 'dashboardGenerate',\n },\n }\n\n constructor(context: IOContext, options?: InstanceOptions) {\n // TODO: update the app version\n super('vtex.marketplace-financial-commission@0.x', context, options)\n }\n\n private getMarketplaceFinancialCommission = async (\n route: Route,\n retries = 3\n ): Promise<any> => {\n const response = await this.http\n .post(route.endpoint, {\n metric: `marketplaceFinancialCommission-${route.metric}`,\n headers: {\n VtexIdclientAutCookie: this.context.authToken,\n },\n // TODO: update the app version\n baseURL: `http://app.io.vtex.com/vtex.marketplace-financial-commission/v0/${this.context.account}/${this.context.workspace}`,\n })\n .catch((error) => {\n console.error({\n msj: `Error to generate dashboard - Endpoint ${route.endpoint}`,\n messageError: error.message,\n statusError: error.status,\n })\n\n this.context.logger.error({\n message: 'dashboardGenerateError',\n error,\n route: route.endpoint,\n })\n\n if (retries > 0) {\n console.info(`Starting retry --------> ${retries}`)\n\n return this.getMarketplaceFinancialCommission(route, retries - 1)\n }\n\n const resultError = {\n msj: `Error to generate dashboard - Endpoint ${route.endpoint}`,\n messageError: error.message,\n statusError: error.status,\n }\n\n return resultError\n })\n\n return response\n }\n\n public dashboardGenerate = async (params?: any): Promise<any> => {\n try {\n if (params) {\n const route: Route = {\n endpoint: `${this.routes.dashboardGenerate.endpoint}?${params}`,\n metric: 'dashboardGenerate',\n }\n\n const reponse = await this.getMarketplaceFinancialCommission(route)\n\n return reponse\n }\n\n const reponse = await this.getMarketplaceFinancialCommission(\n this.routes.dashboardGenerate\n )\n\n return reponse\n } catch (error) {\n this.context.logger.error({\n message: 'dashboardGenerateError',\n error,\n })\n\n throw new Error('dashboardGenerate error')\n }\n }\n}\n\n```" } ]
code_marketplace-financial-commission-cron_25f7e949
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/typings/marketplaceFinancialCommission.d.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ninterface Routes {\n [k: string]: Route\n}\n\ninterface Route {\n endpoint: string\n metric: string\n}\n\n```" } ]
code_marketplace-financial-commission-cron_b9bec9f0
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/typings/scheduler.d.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ninterface SchedulerRequest {\n id: string\n scheduler: {\n expression: string\n endDate: string\n }\n retry: {\n delay: {\n addMinutes: number\n addHours: number\n addDays: number\n }\n times: number\n backOffRate: number\n }\n request: {\n uri: string\n method: string\n headers: { [k: string]: unknown }\n body: { [k: string]: unknown }\n }\n}\n\n```" } ]
code_marketplace-financial-commission-cron_568a66bc
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/typings/global.d.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { ServiceContext } from '@vtex/api'\nimport type { Clients } from '../clients'\n\ndeclare global {\n type Context = ServiceContext<Clients>\n}\n\nexport {}\n\n```" } ]
code_marketplace-financial-commission-cron_8729b607
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/configs/schedulerTemplate.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport const schedulerTemplate = {\n id: 'TO_BE_REPLACED',\n scheduler: {\n expression: '1 0 * * *',\n endDate: '2029-12-30T23:29:00',\n },\n retry: {\n delay: {\n addMinutes: 5,\n addHours: 0,\n addDays: 0,\n },\n times: 2,\n backOffRate: 1,\n },\n request: {\n uri: '',\n method: 'POST',\n headers: {},\n body: {},\n },\n}\n\n```" } ]
code_marketplace-financial-commission-cron_9c1ec513
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/events/setupSchedulerInvoice.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* eslint-disable no-await-in-loop */\nimport type { EventContext } from '@vtex/api'\n\nimport type { Clients } from '../clients'\nimport { schedulerTemplate } from '../configs/schedulerTemplate'\nimport { constants } from '../constants'\nimport { generateToken } from '../utils'\n\nconst setupSchedulerInvoice = async (ctx: EventContext<Clients>) => {\n const {\n clients: { scheduler, vbase },\n body: { to, from },\n vtex: { logger, production },\n } = ctx\n\n if (production !== true) {\n logger.info({\n message: 'setupSchedulerInvoice-notProduction',\n data: `production: ${production}`,\n })\n\n return true\n }\n\n if (to) {\n const [appName] = to?.id?.split('@')\n\n if (\n appName.length &&\n `${process.env.VTEX_APP_VENDOR}.${process.env.VTEX_APP_NAME}` === appName\n ) {\n const bearerToken = await generateToken(256)\n\n logger.info({\n message: 'setupSchedulerInvoice-bearerToken',\n data: bearerToken,\n })\n\n await vbase.saveJSON(\n constants.SCHEDULER_CONFIGURATIONS_BUCKET,\n constants.SCHEDULER_KEY_INVOICE,\n bearerToken\n )\n\n logger.info({\n message: 'setupSchedulerInvoice-savedOnVbase',\n })\n\n const schedulerRequest: SchedulerRequest = schedulerTemplate\n\n schedulerRequest.id = 'invoice-generate'\n schedulerRequest.request.uri = `https://${ctx.vtex.workspace}--${ctx.vtex.account}.myvtex.com/_v/scheduler/invoice/generate`\n schedulerRequest.request.headers = {\n 'cache-control': 'no-cache',\n Authorization: `Bearer ${bearerToken}`,\n }\n\n try {\n await scheduler.setInitialScheduler(appName, schedulerRequest)\n logger.info({\n message: 'setupSchedulerInvoice-setInvoiceGenerate',\n })\n } catch (error) {\n logger.error({\n message: 'setupSchedulerInvoice-setInvoiceGenerateError',\n error,\n })\n }\n\n return true\n }\n } else if (from) {\n const [appName] = from?.id?.split('@')\n\n if (\n appName.length &&\n `${process.env.VTEX_APP_VENDOR}.${process.env.VTEX_APP_NAME}` === appName\n ) {\n await vbase.deleteFile(\n constants.SCHEDULER_CONFIGURATIONS_BUCKET,\n constants.SCHEDULER_KEY_INVOICE\n )\n\n logger.info({\n message: 'setupSchedulerInvoice-deleteBearerTokenVBase',\n })\n\n const idName = 'invoice-generate'\n\n try {\n await scheduler.deleteScheduler(appName, idName)\n logger.info({\n message: 'setupSchedulerInvoice-deleteInvoiceGenerate',\n })\n } catch (error) {\n logger.error({\n message: 'setupSchedulerInvoice-deleteInvoiceGenerateError',\n error,\n })\n }\n\n return true\n }\n }\n\n return null\n}\n\nexport { setupSchedulerInvoice }\n\n```" } ]
code_marketplace-financial-commission-cron_046d3162
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/events/setupSchedulerDashboard.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* eslint-disable no-await-in-loop */\nimport type { EventContext } from '@vtex/api'\n\nimport type { Clients } from '../clients'\nimport { schedulerTemplate } from '../configs/schedulerTemplate'\nimport { constants } from '../constants'\nimport { generateToken } from '../utils'\n\nconst setupSchedulerDashboard = async (ctx: EventContext<Clients>) => {\n const {\n clients: { scheduler, vbase, marketFinancialCommission },\n body: { to, from },\n vtex: { logger, production },\n } = ctx\n\n if (production !== true) {\n logger.info({\n message: 'setupScheduler-notProduction',\n data: `production: ${production}`,\n })\n\n return true\n }\n\n if (to) {\n const [appName] = to?.id?.split('@')\n\n if (\n appName.length &&\n `${process.env.VTEX_APP_VENDOR}.${process.env.VTEX_APP_NAME}` === appName\n ) {\n const bearerToken = await generateToken(256)\n\n logger.info({\n message: 'setupScheduler-bearerToken',\n data: bearerToken,\n })\n\n await vbase.saveJSON(\n constants.SCHEDULER_CONFIGURATIONS_BUCKET,\n constants.SCHEDULER_KEY,\n bearerToken\n )\n\n logger.info({\n message: 'setupScheduler-savedOnVbase',\n })\n\n const schedulerRequest: SchedulerRequest = schedulerTemplate\n\n schedulerRequest.id = 'dashboard-generate'\n schedulerRequest.request.uri = `https://${ctx.vtex.workspace}--${ctx.vtex.account}.myvtex.com/_v/scheduler/dashboard/generate`\n schedulerRequest.request.headers = {\n 'cache-control': 'no-cache',\n Authorization: `Bearer ${bearerToken}`,\n }\n\n try {\n await scheduler.setInitialScheduler(appName, schedulerRequest)\n logger.info({\n message: 'setupScheduler-setDashboardGenerate',\n })\n } catch (error) {\n logger.error({\n message: 'setupScheduler-setDashboardGenerateError',\n error,\n })\n }\n\n try {\n const dayYesterday = new Date(\n new Date().setDate(new Date().getDate() - 1)\n )\n\n const dateOneMonthAgo = new Date(\n dayYesterday.getTime() - 30 * 24 * 60 * 60 * 1000\n )\n\n const result: any[] = []\n\n let loop = dateOneMonthAgo\n const endLoop = dayYesterday\n\n const processGenerate = async () => {\n while (loop <= endLoop) {\n const [dayToProcess] = loop.toISOString().split('T')\n let params = ''\n\n params = `dateStart=${dayToProcess}&dateEnd=${dayToProcess}`\n\n const responseSer =\n await marketFinancialCommission.dashboardGenerate(params)\n\n result.push(responseSer)\n\n logger.info({\n message: `setupScheduler-setDashboardGenerateFor30Days`,\n params,\n generate: JSON.stringify(responseSer),\n })\n\n const newDate = loop.setDate(loop.getDate() + 1)\n\n loop = new Date(newDate)\n console.info({ loop })\n\n await delay(2000)\n }\n\n logger.info({\n message: `DashboardGenerateFor30Days`,\n generate: JSON.stringify(result),\n })\n }\n\n processGenerate()\n } catch (error) {\n logger.error({\n message: 'setupScheduler-setDashboardGenerateFor30Days',\n error,\n })\n }\n\n return true\n }\n } else if (from) {\n const [appName] = from?.id?.split('@')\n\n if (\n appName.length &&\n `${process.env.VTEX_APP_VENDOR}.${process.env.VTEX_APP_NAME}` === appName\n ) {\n await vbase.deleteFile(\n constants.SCHEDULER_CONFIGURATIONS_BUCKET,\n constants.SCHEDULER_KEY\n )\n\n logger.info({\n message: 'setupScheduler-deleteBearerTokenVBase',\n })\n\n const idName = 'dashboard-generate'\n\n try {\n await scheduler.deleteScheduler(appName, idName)\n logger.info({\n message: 'setupScheduler-deleteDashboardGenerate',\n })\n } catch (error) {\n logger.error({\n message: 'setupScheduler-deleteDashboardGenerateError',\n error,\n })\n }\n\n return true\n }\n }\n\n return null\n}\n\nexport { setupSchedulerDashboard }\n\nfunction delay(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n\n```" } ]
code_marketplace-financial-commission-cron_bfe55373
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/events/index.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { setupSchedulerDashboard } from './setupSchedulerDashboard'\nimport { setupSchedulerInvoice } from './setupSchedulerInvoice'\n\nconst events = {\n setupSchedulerDashboard,\n setupSchedulerInvoice,\n}\n\nexport { events }\n\n```" } ]
code_marketplace-financial-commission-cron_e59daccd
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/middlewares/scheduler/schedulerAuthenticationInvoice.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { AuthenticationError } from '@vtex/api'\n\nimport { constants } from '../../constants'\n\nexport async function schedulerAuthenticationInvoice(\n ctx: Context,\n next: () => Promise<any>\n) {\n const {\n clients: { vbase },\n request: { header },\n vtex: { logger },\n } = ctx\n\n const autheticationToken = await vbase.getJSON(\n constants.SCHEDULER_CONFIGURATIONS_BUCKET,\n constants.SCHEDULER_KEY_INVOICE\n )\n\n const verifyToken = async (): Promise<void> => {\n const bearerHeader = header.authorization\n\n if (bearerHeader) {\n const bearer = bearerHeader.split(' ')\n\n if (autheticationToken !== bearer[1]) {\n logger.warn({\n message: 'incoming-wrongApiKey',\n })\n throw new AuthenticationError('Unauthorized')\n }\n } else {\n logger.warn({\n message: 'incoming-missingApiKey',\n })\n throw new AuthenticationError('Unauthorized')\n }\n }\n\n await verifyToken()\n\n await next()\n}\n\n```" } ]
code_marketplace-financial-commission-cron_5b684663
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/middlewares/scheduler/schedulerAuthenticationDashboard.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { AuthenticationError } from '@vtex/api'\n\nimport { constants } from '../../constants'\n\nexport async function schedulerAuthenticationDashboard(\n ctx: Context,\n next: () => Promise<any>\n) {\n const {\n clients: { vbase },\n request: { header },\n vtex: { logger },\n } = ctx\n\n const autheticationToken = await vbase.getJSON(\n constants.SCHEDULER_CONFIGURATIONS_BUCKET,\n constants.SCHEDULER_KEY\n )\n\n const verifyToken = async (): Promise<void> => {\n const bearerHeader = header.authorization\n\n if (bearerHeader) {\n const bearer = bearerHeader.split(' ')\n\n if (autheticationToken !== bearer[1]) {\n logger.warn({\n message: 'incoming-wrongApiKey',\n })\n throw new AuthenticationError('Unauthorized')\n }\n } else {\n logger.warn({\n message: 'incoming-missingApiKey',\n })\n throw new AuthenticationError('Unauthorized')\n }\n }\n\n await verifyToken()\n\n await next()\n}\n\n```" } ]
code_marketplace-financial-commission-cron_a4b360bb
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/middlewares/dashboard/generateDashboard.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport async function generateDashboard(\n ctx: Context,\n next: () => Promise<any>\n) {\n const {\n clients: { marketFinancialCommission, typeIntegration },\n vtex: { logger },\n } = ctx\n\n try {\n const { integration } = await typeIntegration.typeIntegration()\n\n if (\n integration === '1' ||\n integration === undefined ||\n integration === null\n ) {\n const response = await marketFinancialCommission.dashboardGenerate()\n\n logger.info({\n message: 'outgoing-dashboardGenerateResponse',\n data: response,\n })\n } else {\n logger.info({\n message:\n 'The Dashboard does not perform the automatic generation since the financial-commission app is configured as external integration.',\n })\n }\n\n ctx.status = 200\n ctx.body = 'ok'\n } catch (error) {\n logger.error({\n message: 'outgoing-dashboardGenerateResponseError',\n error,\n })\n ctx.status = 500\n }\n\n await next()\n}\n\n```" } ]
code_marketplace-financial-commission-cron_d5bbcbe3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of marketplace-financial-commission-cron/node/middlewares/invoice/generateInvoice.ts from the marketplace-financial-commission-cron VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport async function generateInvoice(ctx: Context, next: () => Promise<any>) {\n const {\n clients: { invoiceFinancialComission, typeIntegration },\n vtex: { logger },\n } = ctx\n\n try {\n const { integration } = await typeIntegration.typeIntegration()\n\n if (\n integration === '1' ||\n integration === undefined ||\n integration === null\n ) {\n const response = await invoiceFinancialComission.generateInvoice()\n\n logger.info({\n message: 'outgoing-generateInvoice',\n data: response,\n })\n } else {\n logger.info({\n message:\n 'The Invoice does not perform the automatic generation since the financial-commission app is configured as external integration.',\n })\n }\n\n ctx.status = 200\n ctx.body = 'ok'\n } catch (error) {\n logger.error({\n message: 'outgoing-generateInvoiceError',\n error,\n })\n ctx.status = 500\n }\n\n await next()\n}\n\n```" } ]
code_product-summary-context_0db70c89
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-summary-context/docs/README.md from the product-summary-context VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Product Summary Context\n\n> Provides the product context to the product-summary child blocks.\n\n```" } ]
code_product-summary-context_c85baac7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-summary-context/react/ProductSummaryTypes.ts from the product-summary-context VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport interface State {\n product: Product\n isHovering: boolean\n isLoading: boolean\n isPriceLoading: boolean\n selectedItem: SingleSKU,\n selectedQuantity: number,\n inView: boolean\n productQuery?: string\n listName?: string\n query?: string\n position?: number\n sponsoredBadge?: SponsoredBadgeOptions\n\n}\n\nexport interface Product {\n advertisement: Advertisement;\n brand: string;\n brandId: number;\n categoryId: string;\n categoryTree: Category[];\n description: string;\n items: SKU[];\n linkText: string;\n metaTagDescription: string;\n priceRange: PriceRangeOptions;\n productName: string;\n productId: string;\n productReference?: string;\n productClusters: Array<{name: string;}>;\n selectedProperties: SelectedProperty[];\n skuSpecifications: SkuSpecification[];\n sku: SingleSKU;\n titleTag: string;\n deliveryPromisesBadges?: BadgeItem[];\n}\n\ninterface BadgeItem {\n typeName: String;\n pickupId: String;\n pickupName: String;\n}\n\ninterface Advertisement {\n adId: string;\n campaignId: string;\n adRequestId: string;\n adResponseId: string;\n actionCost: number;\n}\n\ninterface Image {\n cacheId: string\n imageId: string\n imageLabel: string\n imageTag: string\n imageText: string\n imageUrl: string\n}\n\nexport interface SKU {\n name: string\n itemId: string\n ean: string\n referenceId: [{ Value: string }]\n sellers: Seller[]\n images: Image[]\n}\n\nexport interface SingleSKU extends SKU {\n image: Image\n seller: Seller\n}\n\ninterface Category {\n id: string\n name: string\n}\n\ninterface PriceRangeOptions {\n listPrice: PriceRange\n sellingPrice: PriceRange\n}\n\ninterface PriceRange {\n highPrice: number\n lowPrice: number\n}\n\nexport interface Seller {\n commertialOffer: CommertialOffer\n sellerId: string\n sellerDefault: boolean\n}\n\ninterface CommertialOffer {\n AvailableQuantity: number\n Installments: Installment[]\n ListPrice: number\n Price: number\n}\n\ninterface Installment {\n InterestRate: number\n Name: string\n NumberOfInstallments: number\n PaymentSystemName: string\n Value: number\n}\n\ninterface SkuSpecification {\n field: SkuSpecificationField\n values: SkuSpecificationValues[]\n}\n\ninterface SkuSpecificationField {\n name: string\n}\n\ninterface SkuSpecificationValues {\n name: string\n}\n\ninterface SelectedProperty {\n key: string;\n value: string\n}\n\nexport type SponsoredBadgeOptions = {\n label?: string;\n position?: SponsoredBadgePosition\n}\n\nexport type SponsoredBadgePosition = \"titleTop\" | \"containerTopLeft\" | \"none\";\n\n```" } ]
code_product-summary-context_69cc9e4b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-summary-context/react/package.json from the product-summary-context VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"devDependencies\": {\n \"@types/node\": \"^11.13.4\",\n \"@types/query-string\": \"5\",\n \"@types/react\": \"^16.8.13\",\n \"vtex.product-group-context\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.product-group-context@0.1.0/public/@types/vtex.product-group-context\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.111.0/public/@types/vtex.render-runtime\"\n },\n \"dependencies\": {\n \"query-string\": \"5\",\n \"ramda\": \"^0.26.1\"\n },\n \"version\": \"0.13.0\"\n}\n\n```" } ]
code_product-summary-context_56a0e342
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-summary-context/react/ProductSummaryContext.tsx from the product-summary-context VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useReducer, useEffect, PropsWithChildren } from 'react'\nimport { createContext, useContext } from 'react'\nimport querystring from 'query-string'\nimport { ProductGroupContext } from 'vtex.product-group-context'\n\nimport { Product, SingleSKU, SKU, SponsoredBadgeOptions, State } from './ProductSummaryTypes'\n\nconst { useProductGroup } = ProductGroupContext\n\nconst ProductSummaryContext = createContext<State | undefined>(undefined)\nconst ProductDispatchContext = createContext<Dispatch | undefined>(undefined)\n\ntype Dispatch = (action: Action) => void\n\ntype SetProductAction = {\n type: 'SET_PRODUCT',\n args: {\n product: Product\n selectedItem?: SingleSKU\n }\n}\n\ntype SetProductQueryAction = {\n type: 'SET_PRODUCT_QUERY',\n args: {\n query: string\n }\n}\n\ntype SetHoverAction = {\n type: 'SET_HOVER'\n args: {\n isHovering: boolean\n }\n}\n\ntype SetLoadingAction = {\n type: 'SET_LOADING'\n args: {\n isLoading: boolean\n }\n}\n\ntype SetPriceLoadingAction = {\n type: 'SET_PRICE_LOADING'\n args: {\n isPriceLoading: boolean\n }\n}\n\ntype SetProductQuantity = {\n type: 'SET_QUANTITY'\n args: {\n quantity: number\n }\n}\n\ntype SetInView = {\n type: 'SET_IN_VIEW'\n args: {\n inView: boolean\n }\n}\n\ntype SetPosition = {\n type: 'SET_POSITION'\n args: {\n position: number\n }\n}\n\ntype Action =\n | SetProductAction\n | SetHoverAction\n | SetLoadingAction\n | SetPriceLoadingAction\n | SetProductQuantity\n | SetProductQueryAction\n | SetInView\n | SetPosition\n\nexport function reducer(state: State, action: Action): State {\n switch (action.type) {\n case 'SET_PRODUCT': {\n const product = action.args.product\n return {\n ...state,\n product: product,\n //TODO: STOP USING PRODUCT.SKU https://app.clubhouse.io/vtex/story/18547/productsummarycontext-refactor\n selectedItem: action.args.selectedItem ?? product.sku\n }\n }\n case 'SET_HOVER': {\n return {\n ...state,\n isHovering: action.args.isHovering\n }\n }\n case 'SET_LOADING': {\n return {\n ...state,\n isLoading: action.args.isLoading\n }\n }\n case 'SET_PRICE_LOADING': {\n return {\n ...state,\n isPriceLoading: action.args.isPriceLoading,\n }\n }\n case 'SET_QUANTITY': {\n return {\n ...state,\n selectedQuantity: action.args.quantity,\n }\n }\n case 'SET_PRODUCT_QUERY':\n return {\n ...state,\n query: action.args.query,\n }\n case 'SET_IN_VIEW':\n return {\n ...state,\n inView: action.args.inView,\n }\n case 'SET_POSITION':\n return {\n ...state,\n position: action.args.position,\n }\n\n default:\n return state\n }\n}\n\ninterface BuildProductQueryParams {\n product: Product\n}\n\nconst buildProductQuery = (({ product }: BuildProductQueryParams) => {\n const selectedProperties = product?.selectedProperties\n\n if (!selectedProperties) {\n return\n }\n\n const query = {}\n\n selectedProperties.forEach(property => {\n const {key, value} = property\n query[`property__${key}`] = value\n })\n\n return querystring.stringify(query)\n})\n\ninterface ProviderProps {\n product: Product\n selectedItem?: SingleSKU\n isLoading?: boolean\n isPriceLoading?: boolean\n listName?: string\n sponsoredBadge?: SponsoredBadgeOptions\n}\n\nfunction ProductSummaryProvider({\n product,\n selectedItem,\n isLoading = false,\n isPriceLoading = false,\n listName = null,\n sponsoredBadge = {},\n children,\n}: PropsWithChildren<ProviderProps>) {\n const initialState = {\n product,\n isHovering: false,\n isLoading,\n isPriceLoading,\n selectedItem: selectedItem ?? null,\n selectedQuantity: 1,\n listName,\n sponsoredBadge,\n query: buildProductQuery({ product }),\n inView: false,\n position: null,\n }\n\n const [state, dispatch] = useReducer(reducer, initialState)\n\n const productGroupContext = useProductGroup()\n\n useEffect(() => {\n if (!productGroupContext) {\n return\n }\n\n const { addItemToGroup } = productGroupContext\n const removeItemFromGroup = addItemToGroup(state.product, state.selectedItem ?? state.product.items[0])\n\n return () => removeItemFromGroup()\n }, [state.selectedItem, state.product])\n\n return (\n <ProductSummaryContext.Provider value={state}>\n <ProductDispatchContext.Provider value={dispatch}>\n {children}\n </ProductDispatchContext.Provider>\n </ProductSummaryContext.Provider>\n )\n}\n\nfunction useProductSummaryDispatch() {\n return useContext(ProductDispatchContext)\n}\n\nfunction useProductSummary() {\n return useContext(ProductSummaryContext)\n}\n\nexport default {\n ProductSummaryProvider,\n useProductSummary,\n useProductSummaryDispatch,\n}\n\n```" } ]
code_product-identifier_f255318b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/messages/pt.json from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/product-identifier.productReference\": \"Referência\",\n \"store/product-identifier.productId\": \"ID\",\n \"store/product-identifier.skuEan\": \"EAN\",\n \"store/product-identifier.skuReferenceId\": \"Referência\",\n \"store/product-identifier.itemId\": \"Item ID\",\n \"admin/editor.product-identifier.title\": \"Identificador do Produto\",\n \"admin/editor.product-identifier.type.title\": \"Campo identificador\",\n \"admin/editor.product-identifier.type.itemId\": \"Item ID\",\n \"admin/editor.product-identifier.type.productReference\": \"Código de referência do produto\",\n \"admin/editor.product-identifier.type.productId\": \"Id do produto\",\n \"admin/editor.product-identifier.type.skuEan\": \"EAN do SKU\",\n \"admin/editor.product-identifier.type.skuReferenceId\": \"Código de referência do SKU\",\n \"admin/editor.product-identifier.label.title\": \"Texto identificador\",\n \"admin/editor.product-identifier.label.default\": \"Padrão\",\n \"admin/editor.product-identifier.label.custom\": \"Customizado\",\n \"admin/editor.product-identifier.label.hide\": \"Esconder\",\n \"admin/editor.product-identifier.customLabel.title\": \"Texto customizado\"\n}\n\n```" } ]
code_product-identifier_33424273
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/messages/en.json from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/product-identifier.productReference\": \"Reference\",\n \"store/product-identifier.productId\": \"ID\",\n \"store/product-identifier.skuEan\": \"EAN\",\n \"store/product-identifier.skuReferenceId\": \"Reference\",\n \"store/product-identifier.itemId\": \"Item ID\",\n \"admin/editor.product-identifier.title\": \"Product Identifier\",\n \"admin/editor.product-identifier.type.title\": \"Identifier Field\",\n \"admin/editor.product-identifier.type.itemId\": \"Item ID\",\n \"admin/editor.product-identifier.type.productReference\": \"Product Reference\",\n \"admin/editor.product-identifier.type.productId\": \"Product ID\",\n \"admin/editor.product-identifier.type.skuEan\": \"SKU EAN\",\n \"admin/editor.product-identifier.type.skuReferenceId\": \"SKU Reference ID\",\n \"admin/editor.product-identifier.label.title\": \"Label\",\n \"admin/editor.product-identifier.label.default\": \"Default\",\n \"admin/editor.product-identifier.label.custom\": \"Custom\",\n \"admin/editor.product-identifier.label.hide\": \"Hide\",\n \"admin/editor.product-identifier.customLabel.title\": \"Custom Label\"\n}\n\n```" } ]
code_product-identifier_5fb3d40d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/messages/fr.json from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/product-identifier.productReference\": \"Référence\",\n \"store/product-identifier.productId\": \"ID\",\n \"store/product-identifier.skuEan\": \"EAN\",\n \"store/product-identifier.skuReferenceId\": \"Référence\",\n \"store/product-identifier.itemId\": \"ID de l’article\",\n \"admin/editor.product-identifier.title\": \"Identifiant du produit\",\n \"admin/editor.product-identifier.type.title\": \"Champ Identificateur\",\n \"admin/editor.product-identifier.type.itemId\": \"ID de l’article\",\n \"admin/editor.product-identifier.type.productReference\": \"Référence du produit\",\n \"admin/editor.product-identifier.type.productId\": \"ID du produit\",\n \"admin/editor.product-identifier.type.skuEan\": \"EAN de SKU\",\n \"admin/editor.product-identifier.type.skuReferenceId\": \"ID de référence de SKU\",\n \"admin/editor.product-identifier.label.title\": \"Étiquette\",\n \"admin/editor.product-identifier.label.default\": \"Par défaut\",\n \"admin/editor.product-identifier.label.custom\": \"Personnaliser\",\n \"admin/editor.product-identifier.label.hide\": \"Masquer\",\n \"admin/editor.product-identifier.customLabel.title\": \"Étiquette personnalisée\"\n}\n\n```" } ]
code_product-identifier_b503e634
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/messages/context.json from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/product-identifier.productReference\": \"Reference\",\n \"store/product-identifier.productId\": \"ID\",\n \"store/product-identifier.skuEan\": \"EAN\",\n \"store/product-identifier.skuReferenceId\": \"Reference\",\n \"store/product-identifier.itemId\": \"Item ID\",\n \"admin/editor.product-identifier.title\": \"Product Identifier\",\n \"admin/editor.product-identifier.type.title\": \"Identifier field\",\n \"admin/editor.product-identifier.type.itemId\": \"Item ID\",\n \"admin/editor.product-identifier.type.productReference\": \"Product Reference\",\n \"admin/editor.product-identifier.type.productId\": \"Product ID\",\n \"admin/editor.product-identifier.type.skuEan\": \"SKU EAN\",\n \"admin/editor.product-identifier.type.skuReferenceId\": \"SKU Reference ID\",\n \"admin/editor.product-identifier.label.title\": \"Label\",\n \"admin/editor.product-identifier.label.default\": \"Default\",\n \"admin/editor.product-identifier.label.custom\": \"Custom\",\n \"admin/editor.product-identifier.label.hide\": \"Hide\",\n \"admin/editor.product-identifier.customLabel.title\": \"Custom Label\"\n}\n\n```" } ]
code_product-identifier_4434e8e0
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/messages/id.json from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/product-identifier.productReference\": \"Referensi\",\n \"store/product-identifier.productId\": \"ID\",\n \"store/product-identifier.skuEan\": \"EAN\",\n \"store/product-identifier.skuReferenceId\": \"Referensi\",\n \"store/product-identifier.itemId\": \"ID Item\",\n \"admin/editor.product-identifier.title\": \"Pengenal Produk\",\n \"admin/editor.product-identifier.type.title\": \"Bidang Pengenal\",\n \"admin/editor.product-identifier.type.itemId\": \"ID Item\",\n \"admin/editor.product-identifier.type.productReference\": \"Referensi Produk\",\n \"admin/editor.product-identifier.type.productId\": \"ID Produk\",\n \"admin/editor.product-identifier.type.skuEan\": \"EAN SKU\",\n \"admin/editor.product-identifier.type.skuReferenceId\": \"ID Referensi SKU\",\n \"admin/editor.product-identifier.label.title\": \"Label\",\n \"admin/editor.product-identifier.label.default\": \"Default\",\n \"admin/editor.product-identifier.label.custom\": \"Kustom\",\n \"admin/editor.product-identifier.label.hide\": \"Sembunyikan\",\n \"admin/editor.product-identifier.customLabel.title\": \"Label Kustom\"\n}\n\n```" } ]
code_product-identifier_de8b857c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/messages/th.json from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/product-identifier.productReference\": \"ข้อมูลอ้างอิง\",\n \"store/product-identifier.productId\": \"รหัส\",\n \"store/product-identifier.skuEan\": \"EAN\",\n \"store/product-identifier.skuReferenceId\": \"ข้อมูลอ้างอิง\",\n \"store/product-identifier.itemId\": \"รหัสสินค้า\",\n \"admin/editor.product-identifier.title\": \"รหัสผลิตภัณฑ์\",\n \"admin/editor.product-identifier.type.title\": \"ฟิลด์รหัส\",\n \"admin/editor.product-identifier.type.itemId\": \"รหัสสินค้า\",\n \"admin/editor.product-identifier.type.productReference\": \"ข้อมูลอ้างอิงผลิตภัณฑ์\",\n \"admin/editor.product-identifier.type.productId\": \"รหัสผลิตภัณฑ์\",\n \"admin/editor.product-identifier.type.skuEan\": \"SKU EAN\",\n \"admin/editor.product-identifier.type.skuReferenceId\": \"รหัสอ้างอิง SKU\",\n \"admin/editor.product-identifier.label.title\": \"ป้ายชื่อ\",\n \"admin/editor.product-identifier.label.default\": \"ค่าเริ่มต้น\",\n \"admin/editor.product-identifier.label.custom\": \"กำหนดเอง\",\n \"admin/editor.product-identifier.label.hide\": \"ซ่อน\",\n \"admin/editor.product-identifier.customLabel.title\": \"ป้ายที่กำหนดเอง\"\n}\n\n```" } ]
code_product-identifier_cb14c730
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/messages/es.json from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/product-identifier.productReference\": \"Referencia\",\n \"store/product-identifier.productId\": \"ID\",\n \"store/product-identifier.skuEan\": \"EAN\",\n \"store/product-identifier.skuReferenceId\": \"Referencia\",\n \"store/product-identifier.itemId\": \"Item ID\",\n \"admin/editor.product-identifier.title\": \"Identificador de Producto\",\n \"admin/editor.product-identifier.type.title\": \"Campo identificador\",\n \"admin/editor.product-identifier.type.itemId\": \"Item ID\",\n \"admin/editor.product-identifier.type.productReference\": \"Código de referencia del producto\",\n \"admin/editor.product-identifier.type.productId\": \"Id de producto\",\n \"admin/editor.product-identifier.type.skuEan\": \"EAN de SKU\",\n \"admin/editor.product-identifier.type.skuReferenceId\": \"Código de referencia de SKU\",\n \"admin/editor.product-identifier.label.title\": \"Texto identificador\",\n \"admin/editor.product-identifier.label.default\": \"Estándar\",\n \"admin/editor.product-identifier.label.custom\": \"Personalizado\",\n \"admin/editor.product-identifier.label.hide\": \"Ocultar\",\n \"admin/editor.product-identifier.customLabel.title\": \"Texto personalizado\"\n}\n\n```" } ]
code_product-identifier_f569bf84
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/messages/ar.json from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/product-identifier.productReference\": \"المرجع\",\n \"store/product-identifier.productId\": \"المعرّف\",\n \"store/product-identifier.skuEan\": \"رمز EAN\",\n \"store/product-identifier.skuReferenceId\": \"المرجع\",\n \"store/product-identifier.itemId\": \"معرّف العنصر\",\n \"admin/editor.product-identifier.title\": \"معرف المنتج\",\n \"admin/editor.product-identifier.type.title\": \"حقل المعرف\",\n \"admin/editor.product-identifier.type.itemId\": \"معرّف العنصر\",\n \"admin/editor.product-identifier.type.productReference\": \"مرجع المنتج\",\n \"admin/editor.product-identifier.type.productId\": \"معرّف المُنتج\",\n \"admin/editor.product-identifier.type.skuEan\": \"SKU EAN\",\n \"admin/editor.product-identifier.type.skuReferenceId\": \"معرف مرجع SKU\",\n \"admin/editor.product-identifier.label.title\": \"التسمية\",\n \"admin/editor.product-identifier.label.default\": \"العنوان الرئيسي\",\n \"admin/editor.product-identifier.label.custom\": \"مخصص\",\n \"admin/editor.product-identifier.label.hide\": \"إخفاء\",\n \"admin/editor.product-identifier.customLabel.title\": \"تسمية مخصصة\"\n}\n\n```" } ]
code_product-identifier_fd5af848
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/docs/README.md from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/vtex-apps/product-identifier) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# Product Identifier\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\nThe Product Identifier app is responsible for showing a product identifier, such as a product reference, product ID, SKU EAN, or SKU reference.\n\n![reference](https://user-images.githubusercontent.com/60782333/90151384-0abbd380-dd5d-11ea-9022-69ba4685e1d0.png)\n\n## Configuration\n\n1. Add the `vtex.product-identifier` app to your Store Theme's dependencies in the `manifest.json` file:\n \n ```json\n \"dependencies\": {\n \"vtex.product-identifier\": \"0.x\"\n }\n ```\n\n2. Add `product-identifier.product` block as a child of `product-summary.shelf`.\n\n ```json\n \"product-identifier.product\": {\n \"props\": {\n \"label\": \"default\", //'default' | 'custom' | 'hide'\n \"customLabel\": \"teste\", // text if label is custom\n \"idField\": \"skuReferenceId\" //'itemId' | 'productId' | 'productReference' | 'skuEan' | 'skuReferenceId'\n }\n },\n ```\n\nThe `product-identifier` interface can also be configured in the [Site Editor](https://developers.vtex.com/docs/guides/store-framework-working-with-site-editor). You can choose to display the following identifiers:\n\n- Product Reference\n- Product ID\n- SKU EAN\n- SKU Reference ID\n- Item ID\n\nIt's also possible to customize or hide the label text. In the following example, the \"Reference\" text was substituted by \"Foo.\"\n\n![foo](https://user-images.githubusercontent.com/60782333/90145130-004a0b80-dd56-11ea-9cbd-5ee621da4d69.png)\n\n## Customization\n\nTo apply CSS customization to this and other blocks, follow the instructions in the [Using CSS Handles for store customization](https://vtex.io/docs/recipes/style/using-css-handles-for-store-customization) guide.\n\n| CSS Handles |\n| ----------- |\n| `product-identifier` | \n| `product-identifier__label` | \n| `product-identifier__separator`| \n| `product-identifier__value` | \n\n## Contributors ✨\n\nThanks goes to these wonderful people:\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n <tr>\n <td align=\"center\"><a href=\"http://carafizi.com/\"><img src=\"https://avatars3.githubusercontent.com/u/51974587?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Gabriel Carafizi</b></sub></a><br /><a href=\"https://github.com/vtex-apps/product-identifier/commits?author=carafizi1\" title=\"Code\">💻</a></td>\n </tr>\n</table>\n\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n```" } ]
code_product-identifier_84eb5154
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/react/styles.css from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.product-identifier {\n}\n.product-identifier__label {\n}\n.product-identifier__separator {\n}\n.product-identifier__value {\n}\n\n```" } ]
code_product-identifier_5cdb1400
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/react/ProductIdentifierSummary.tsx from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { path } from 'ramda'\nimport BaseProductIdentifier, {\n IdField,\n} from './components/BaseProductIdentifier'\nimport {\n useProductSummary,\n ProductSummaryContext,\n} from 'vtex.product-summary-context/ProductSummaryContext'\n\nconst allowedIdFields: Record<\n IdField,\n (contex: ProductSummaryContext) => string | null | undefined\n> = {\n itemId: context => {\n return path(['selectedItem', 'itemId'], context)\n },\n productId: context => {\n return path(['product', 'productId'], context)\n },\n productReference: context => {\n return path(['product', 'productReference'], context)\n },\n skuEan: context => {\n // TODO: Add `selectedSku` to ProductSummaryContext instead of using `sku`\n return path(['product', 'sku', 'ean'], context)\n },\n skuReferenceId: context => {\n // TODO: Add `selectedSku` to ProductSummaryContext instead of using `sku`\n const refId =\n context &&\n context.product &&\n context.product.sku &&\n context.product.sku.referenceId\n ? context.product.sku.referenceId\n : null\n\n if (!refId) {\n return null\n }\n\n const { Value } = refId\n\n if (!Value) {\n return null\n }\n\n return Value\n },\n}\n\nconst sanitizeId = (idField: string): IdField => {\n const valid = idField in allowedIdFields\n return valid ? (idField as IdField) : 'productId'\n}\n\nconst ProductIdentifierSummary: StorefrontFunctionComponent<\n ProductIdentifierProductProps\n> = ({ idField, customLabel, label }) => {\n const context = useProductSummary()\n\n const sanitizedId = sanitizeId(idField) as IdField\n\n if (\n (sanitizedId.indexOf('sku') === 0 && !context.product) ||\n !context.product.items\n ) {\n return null\n }\n\n if (sanitizedId.indexOf('product') === 0 && !context.product) {\n return null\n }\n\n const value = allowedIdFields[sanitizedId](context)\n\n return (\n <BaseProductIdentifier\n idField={idField}\n value={value}\n customLabel={customLabel}\n label={label}\n />\n )\n}\n\ninterface ProductIdentifierProductProps {\n idField: IdField\n customLabel: string\n label: 'default' | 'custom' | 'hide'\n}\n\nProductIdentifierSummary.schema = {\n title: 'admin/editor.product-identifier.title',\n type: 'object',\n}\n\nexport default ProductIdentifierSummary\n\n```" } ]
code_product-identifier_22504713
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/react/ProductIdentifierProduct.tsx from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport useProduct, { ProductContext } from 'vtex.product-context/useProduct'\nimport { path } from 'ramda'\nimport BaseProductIdentifier, {\n IdField,\n} from './components/BaseProductIdentifier'\n\nconst allowedIdFields: Record<\n IdField,\n (contex: ProductContext) => string | null | undefined\n> = {\n itemId: context => {\n return path(['selectedItem', 'itemId'], context)\n },\n productId: context => {\n return path(['product', 'productId'], context)\n },\n productReference: context => {\n return path(['product', 'productReference'], context)\n },\n skuEan: context => {\n return path(['selectedItem', 'ean'], context)\n },\n skuReferenceId: context => {\n const refIds =\n context && context.selectedItem && context.selectedItem.referenceId\n ? context.selectedItem.referenceId\n : null\n if (!refIds) {\n return null\n }\n\n const refId = refIds.find(({ Key }) => Key === 'RefId')\n\n if (!refId) {\n return null\n }\n\n return refId.Value\n },\n}\n\nconst sanitizeId = (idField: string): IdField => {\n const valid = idField in allowedIdFields\n return valid ? (idField as IdField) : 'productId'\n}\n\nconst ProductIdentifierProduct: StorefrontFunctionComponent<\n ProductIdentifierProductProps\n> = ({ idField, customLabel, label }) => {\n const context = useProduct()\n\n const sanitizedId = sanitizeId(idField) as IdField\n\n if (sanitizedId.indexOf('sku') === 0 && !context.selectedItem) {\n return null\n }\n\n if (sanitizedId.indexOf('product') === 0 && !context.product) {\n return null\n }\n\n const value = allowedIdFields[sanitizedId](context)\n\n return (\n <BaseProductIdentifier\n idField={idField}\n value={value}\n customLabel={customLabel}\n label={label}\n />\n )\n}\n\ninterface ProductIdentifierProductProps {\n idField: IdField\n customLabel: string\n label: 'default' | 'custom' | 'hide'\n}\n\nProductIdentifierProduct.schema = {\n title: 'admin/editor.product-identifier.title',\n type: 'object',\n}\n\nexport default ProductIdentifierProduct\n\n```" } ]
code_product-identifier_8e668ac5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/react/package.json from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"test\": \"vtex-test-tools test\",\n \"lint\": \"tsc --noEmit && eslint --ext ts,tsx .\"\n },\n \"dependencies\": {\n \"@vtex/css-handles\": \"^1.0.0\",\n \"classnames\": \"^2.2.6\",\n \"ramda\": \"^0.26.1\",\n \"react\": \"^16.8.3\",\n \"react-dom\": \"^16.8.3\",\n \"react-intl\": \"^2.7.2\"\n },\n \"devDependencies\": {\n \"@types/classnames\": \"^2.2.7\",\n \"@types/graphql\": \"^14.2.0\",\n \"@types/jest\": \"^24.0.11\",\n \"@types/node\": \"^11.13.0\",\n \"@types/prop-types\": \"^15.7.0\",\n \"@types/ramda\": \"^0.26.5\",\n \"@types/react\": \"^16.8.10\",\n \"@types/react-intl\": \"^2.3.17\",\n \"@vtex/test-tools\": \"^0.2.0\",\n \"apollo-client\": \"^2.5.1\",\n \"eslint\": \"^5.16.0\",\n \"eslint-config-vtex-react\": \"^4.1.0\",\n \"prettier\": \"^1.18.2\",\n \"tslint-eslint-rules\": \"^5.4.0\",\n \"typescript\": \"3.9.7\"\n },\n \"version\": \"0.5.1\"\n}\n\n```" } ]
code_product-identifier_51294210
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/store/interfaces.json from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"product-identifier\": {\n \"component\": \"*\"\n },\n \"product-identifier.product\": {\n \"component\": \"ProductIdentifierProduct\",\n \"preview\": {\n \"type\": \"grid\",\n \"height\": 20\n },\n \"content\": {\n \"dependencies\": {\n \"label\": {\n \"oneOf\": [\n {\n \"properties\": {\n \"label\": {\n \"enum\": [\"default\", \"hide\"]\n }\n }\n },\n {\n \"properties\": {\n \"label\": {\n \"enum\": [\"custom\"]\n },\n \"customLabel\": {\n \"title\": \"admin/editor.product-identifier.customLabel.title\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n }\n }\n }\n ]\n }\n },\n \"properties\": {\n \"idField\": {\n \"title\": \"admin/editor.product-identifier.type.title\",\n \"type\": \"string\",\n \"enum\": [\"productReference\", \"productId\", \"skuEan\", \"skuReferenceId\", \"itemId\"],\n \"enumNames\": [\n \"admin/editor.product-identifier.type.productReference\",\n \"admin/editor.product-identifier.type.productId\",\n \"admin/editor.product-identifier.type.skuEan\",\n \"admin/editor.product-identifier.type.skuReferenceId\",\n \"admin/editor.product-identifier.type.itemId\"\n ],\n \"default\": \"productReference\"\n },\n \"label\": {\n \"title\": \"admin/editor.product-identifier.label.title\",\n \"type\": \"string\",\n \"enum\": [\"default\", \"custom\", \"hide\"],\n \"enumNames\": [\n \"admin/editor.product-identifier.label.default\",\n \"admin/editor.product-identifier.label.custom\",\n \"admin/editor.product-identifier.label.hide\"\n ],\n \"default\": \"default\"\n }\n }\n }\n },\n \"product-identifier.summary\": {\n \"component\": \"ProductIdentifierSummary\",\n \"preview\": {\n \"type\": \"grid\",\n \"height\": 20\n },\n \"content\": {\n \"dependencies\": {\n \"label\": {\n \"oneOf\": [\n {\n \"properties\": {\n \"label\": {\n \"enum\": [\"default\", \"hide\"]\n }\n }\n },\n {\n \"properties\": {\n \"label\": {\n \"enum\": [\"custom\"]\n },\n \"customLabel\": {\n \"title\": \"admin/editor.product-identifier.customLabel.title\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n }\n }\n }\n ]\n }\n },\n \"properties\": {\n \"idField\": {\n \"title\": \"admin/editor.product-identifier.type.title\",\n \"type\": \"string\",\n \"enum\": [\"productReference\", \"productId\", \"skuEan\", \"skuReferenceId\", \"itemId\"],\n \"enumNames\": [\n \"admin/editor.product-identifier.type.productReference\",\n \"admin/editor.product-identifier.type.productId\",\n \"admin/editor.product-identifier.type.skuEan\",\n \"admin/editor.product-identifier.type.skuReferenceId\",\n \"admin/editor.product-identifier.type.itemId\"\n ],\n \"default\": \"productReference\"\n },\n \"label\": {\n \"title\": \"admin/editor.product-identifier.label.title\",\n \"type\": \"string\",\n \"enum\": [\"default\", \"custom\", \"hide\"],\n \"enumNames\": [\n \"admin/editor.product-identifier.label.default\",\n \"admin/editor.product-identifier.label.custom\",\n \"admin/editor.product-identifier.label.hide\"\n ],\n \"default\": \"default\"\n }\n }\n }\n }\n}\n\n```" } ]
code_product-identifier_e762b40a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/react/typings/storefront.d.ts from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { FunctionComponent } from 'react'\n\ndeclare global {\n interface StorefrontFunctionComponent<P = {}> extends FunctionComponent<P> {\n getSchema?(props: P): object\n schema?: object\n }\n\n interface StorefrontComponent<P = {}, S = {}> extends Component<P, S> {\n getSchema?(props: P): object\n schema: object\n }\n}\n\n```" } ]
code_product-identifier_09e2283e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/react/typings/vtex.product-context.d.ts from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.product-context/useProduct' {\n const useProduct: () => ProductContext\n export default useProduct\n\n export interface ProductContext {\n product: {\n productId: string\n productReference: string\n }\n selectedItem: {\n itemId: string\n ean: string\n referenceId: ReferenceId[]\n }\n }\n\n interface ReferenceId {\n Key: string\n Value: string\n }\n}\n\n```" } ]
code_product-identifier_58bbc191
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/react/typings/vtex.render-runtime.d.ts from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* Typings for `render-runtime` */\ndeclare module 'vtex.render-runtime' {\n import { Component, ComponentType, ReactElement, ReactType } from 'react'\n\n export interface NavigationOptions {\n page: string\n params?: any\n }\n\n export interface RenderContextProps {\n runtime: {\n navigate: (options: NavigationOptions) => void\n }\n }\n\n interface ExtensionPointProps {\n id: string\n [key: string]: any\n }\n\n export const ExtensionPoint: ComponentType<ExtensionPointProps>\n\n interface ChildBlockProps {\n id: string\n }\n\n export const ChildBlock: ComponentType<ChildBlockProps>\n export const useChildBlock = function({ id: string }): object {}\n\n export const Helmet: ReactElement\n export const Link: ReactType\n export const NoSSR: ReactElement\n export const RenderContextConsumer: ReactElement\n export const canUseDOM: boolean\n export const withRuntimeContext: <TOriginalProps extends {}>(\n Component: ComponentType<TOriginalProps & RenderContextProps>\n ) => ComponentType<TOriginalProps>\n}\n\n```" } ]
code_product-identifier_5ed66923
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/react/typings/vtex.native-types.d.ts from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.native-types' {\n import { ComponentType } from 'react'\n import { InjectedIntl, InjectedIntlProps } from 'react-intl'\n\n interface FormatIOMessageParams {\n id: string\n intl: InjectedIntl\n }\n\n export const formatIOMessage: (params: FormatIOMessageParams) => string\n\n interface IOMessageProps extends InjectedIntlProps {\n id: string\n }\n\n export const IOMessage: ComponentType<IOMessageProps>\n}\n\n```" } ]
code_product-identifier_38a9f1eb
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/react/typings/css.d.ts from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const css: any\n export default css\n}\n\n```" } ]
code_product-identifier_10d96dd3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/react/typings/vtex.product-summary-context.d.ts from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.product-summary-context/ProductSummaryContext' {\n interface ProductSummaryContext {\n product: {\n productId: string\n productReference: string\n items: Item[]\n sku: Item\n }\n }\n\n interface Item {\n itemId: string\n referenceId: Reference\n }\n\n interface Reference {\n Value: string\n }\n\n export const useProductSummary = () => ProductSummaryContext\n}\n\n```" } ]
code_product-identifier_640ecbad
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/react/typings/graphql.d.ts from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.graphql' {\n import { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\n```" } ]
code_product-identifier_2973a6a2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/react/typings/vtex.styleguide.d.ts from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide' {\n import { ComponentType } from 'react'\n\n export const Input: ComponentType<InputProps>\n\n interface InputProps {\n [key: string]: any\n }\n}\n\n```" } ]
code_product-identifier_db529d4b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/react/components/BaseProductIdentifier.tsx from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { IOMessage } from 'vtex.native-types'\nimport styles from '../styles.css'\nimport {\n defineMessages,\n FormattedMessage,\n injectIntl,\n InjectedIntlProps,\n} from 'react-intl'\n\nconst messages = defineMessages({\n productReference: {\n id: 'store/product-identifier.productReference',\n defaultMessage: '',\n },\n productId: {\n id: 'store/product-identifier.productId',\n defaultMessage: '',\n },\n skuEan: {\n id: 'store/product-identifier.skuEan',\n defaultMessage: '',\n },\n skuReferenceId: {\n id: 'store/product-identifier.skuReferenceId',\n defaultMessage: '',\n },\n itemId: {\n id: 'store/product-identifier.itemId',\n defaultMessage: '',\n },\n})\n\nconst ProductIdentifier: StorefrontFunctionComponent<\n ProductIdentifierProps & InjectedIntlProps\n> = ({ idField, value, customLabel, label, intl }) => {\n return (\n <span\n className={`${styles['product-identifier']} ${styles['product-identifier']}--${idField} c-muted-1`}\n >\n {label !== 'hide' && (\n <span className={styles['product-identifier__label']}>\n {label === 'custom' && <IOMessage id={customLabel} intl={intl} />}\n {label === 'default' && (\n <FormattedMessage id={messages[idField].id} />\n )}\n </span>\n )}\n {label !== 'hide' && (\n <span className={styles['product-identifier__separator']}>: </span>\n )}\n <span className={styles['product-identifier__value']}>{value}</span>\n </span>\n )\n}\n\nexport type IdField =\n | 'productReference'\n | 'productId'\n | 'skuEan'\n | 'skuReferenceId'\n | 'itemId'\n\ninterface ProductIdentifierProps {\n idField: IdField\n value: string | undefined | null\n customLabel: string\n label: 'default' | 'custom' | 'hide'\n}\n\nexport default injectIntl(ProductIdentifier)\n\n```" } ]
code_product-identifier_f53466eb
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of product-identifier/react/modules/sanitize.tsx from the product-identifier VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { IdField } from '../components/BaseProductIdentifier'\n\nconst allowedIdFields = [\n 'productId',\n 'productReference',\n 'skuEan',\n 'skuReferenceId',\n 'itemId',\n]\n\nexport const sanitizeId = (idField: string): IdField => {\n const valid = idField in allowedIdFields\n return valid ? (idField as IdField) : 'productId'\n}\n\n```" } ]
code_cookiebot_6de12a3c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cookiebot/messages/en.json from the cookiebot VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/cookiebot.declaration\": \"Cookie declaration\"\n}\n\n```" } ]
code_cookiebot_de63258f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cookiebot/docs/README.md from the cookiebot VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/vtex-apps/cookiebot) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# Cookiebot\n\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n\nThis is a Cookiebot first party integration app. The [solution](https://www.cookiebot.com/) helps make your use of cookies and online tracking compliant.\n\n![Cookie dialog](https://user-images.githubusercontent.com/284515/77015180-d92c1100-6952-11ea-97e6-f2b94b900399.png)\n\n## Configuration\n\n1. [Install](https://vtex.io/docs/recipes/development/installing-an-app/) the `vtex.cookiebot` app;\n2. In your VTEX account's admin, open the **App** section and select the Cookiebot App box;\n3. Fill in your **Domain Group ID**. You can find yours at the [Cookiebot Settings page](https://manage.cookiebot.com/en/manage);\n\n![Cookiebot Domain ID](https://user-images.githubusercontent.com/284515/77793196-6acd0a00-7048-11ea-9de5-0da4eb1c1917.png)\n\n4. On the [Settings page](https://manage.cookiebot.com/en/manage), make sure you use **Active Consent**; \n\n<br/> <img width=\"500\" src=\"https://user-images.githubusercontent.com/284515/78317146-de36b600-7537-11ea-885e-5b8a39d1db8c.png\" />\n\n5. On the [Cookies page](https://manage.cookiebot.com/en/cookies), run a Scan. After the scan is complete, make sure the following cookies are categorized as **Necessary**: `ASPXAUTH`, `checkout.vtex.com`, `CookieConsent`, `device`, `vtex_segment`, `vtex_session`, `VtexFingerPrint`, `VtexRCMacIdv7`, `VtexRCRequestCounter`, `VtexRCSessionIdv7`, `VtexWorkspace`;\n6. Save your changes.\n \nThis pixel app also creates the page `/cookie-declaration` in your store with Cookiebot's Cookie declaration:\n\n![Cookie declaration page](https://user-images.githubusercontent.com/284515/78317698-61a4d700-7539-11ea-9429-1a6275be1123.png)\n\nYou can edit the new page using the admin's Site Editor.\n\n<!-- DOCS-IGNORE:start -->\n\n## Contributors ✨\n\nThanks goes to these wonderful people:\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!\n\n<!-- DOCS-IGNORE:end -->\n\n\n```" } ]
code_cookiebot_3b3a871d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cookiebot/react/styles.css from the cookiebot VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.declaration {\n max-width: 960px;\n margin: 0 auto;\n}\n\n.declarationHeader {}\n\n```" } ]
code_cookiebot_44b1931a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cookiebot/react/CookieDeclaration.tsx from the cookiebot VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FC, useCallback } from 'react'\nimport { FormattedMessage } from 'react-intl'\n\nimport styles from './styles.css'\n\nconst CookieDeclaration: FC = () => {\n const ref = useCallback(node => {\n if (!node) {\n return\n }\n const cbid = window.__cookiebot_id\n const script = document.createElement('script')\n script.id = 'CookieDeclaration'\n script.type = 'text/javascript'\n script.async = true\n script.src = `https://consent.cookiebot.com/${cbid}/cd.js`\n node.appendChild(script)\n }, [])\n\n return (\n <div className={`${styles.declaration} lh-copy`}>\n <h1 className={`${styles.declarationHeader} heading-2`}>\n <FormattedMessage id=\"store/cookiebot.declaration\" />\n </h1>\n <div ref={ref} id=\"CookiebotDeclaration\" />\n </div>\n )\n}\n\nexport default CookieDeclaration\n\n```" } ]
code_cookiebot_9a5b0290
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cookiebot/react/package.json from the cookiebot VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"ramda\": \"^0.26.1\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^3.1.3\",\n \"@types/graphql\": \"^14.5.0\",\n \"@types/jest\": \"^24.9.0\",\n \"@types/node\": \"^13.1.8\",\n \"@types/ramda\": \"^0.26.5\",\n \"@types/react\": \"^16.9.19\",\n \"@types/react-intl\": \"^3.0.0\",\n \"@vtex/test-tools\": \"^3.0.1\",\n \"apollo-cache-inmemory\": \"^1.6.5\",\n \"apollo-client\": \"^2.6.8\",\n \"eslint\": \"^5.16.0\",\n \"eslint-config-vtex-react\": \"^4.1.0\",\n \"graphql\": \"^14.5.4\",\n \"prettier\": \"^1.18.2\",\n \"react-intl\": \"^3.11.0\",\n \"tslint-eslint-rules\": \"^5.4.0\",\n \"typescript\": \"3.9.7\"\n },\n \"version\": \"2.0.8\"\n}\n\n```" } ]
code_cookiebot_09e6c15b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cookiebot/store/blocks.json from the cookiebot VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store.cookie-declaration\": {\n \"blocks\": [\"cookie-declaration\"]\n }\n}\n\n```" } ]
code_cookiebot_5b567fc8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cookiebot/store/interfaces.json from the cookiebot VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store.cookie-declaration\": {},\n \"cookie-declaration\": {\n \"component\": \"CookieDeclaration\"\n }\n}\n\n```" } ]
code_cookiebot_0656c450
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cookiebot/store/routes.json from the cookiebot VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store.cookie-declaration\": {\n \"path\": \"/cookie-declaration\"\n }\n}\n\n```" } ]
code_cookiebot_c02e625d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cookiebot/public/metadata/messages/es-AR.json from the cookiebot VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"Cookiebot\",\n \"headline\": \"Con unos pocos clics, configure y obtenga una vista previa de su propia declaración de cookies y diálogo de consentimiento.\",\n \"overview\": \"Cookiebot trae tres funciones principales completamente automáticas y fáciles de implementar: consentimiento, monitoreo y control de cookies.\\nCookiebot permite el verdadero cumplimiento de las leyes de privacidad a través del intercambio de datos respetuoso y transparente, basado en el consentimiento entre los usuarios finales y los sitios web que visitan.\",\n \"features\": [\n \"Escaneo automatizado y declaración de cookies\",\n \"Banner de consentimiento de cookies\",\n \"Consentimiento masivo para varios dominios\",\n \"Soporte y detección automática de cualquier idioma\",\n \"Segmentación geográfica en tiempo real\",\n \"Estadísticas visuales sobre las elecciones de los visitantes de su sitio web\"\n ],\n \"additionalInformation\": \"Para usar el servicio, debe tener una cuenta de Cookiebot activa. Algunas funciones solo están disponibles para planes específicos.\",\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_cookiebot_d0ef7922
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cookiebot/public/metadata/messages/pt-BR.json from the cookiebot VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"Cookiebot\",\n \"headline\": \"Com apenas alguns cliques, configure e visualize sua própria declaração de cookie e caixa de diálogo de consentimento.\",\n \"overview\": \"O Cookiebot dá vida a três funções principais totalmente automáticas e fáceis de implementar: consentimento, monitoramento e controle de cookies.\\nO Cookiebot permite a verdadeira conformidade com as leis de privacidade por meio de troca de dados respeitosa e transparente, com base no consentimento entre os usuários finais e os sites que eles visitam.\",\n \"features\": [\n \"Varredura e declaração automatizadas de cookies\",\n \"Banner de consentimento de cookies\",\n \"Consentimento em massa para vários domínios\",\n \"Suporte e detecção automática de qualquer idioma\",\n \"Segmentação geográfica em tempo real\",\n \"Estatísticas visuais sobre as escolhas dos visitantes do seu site\"\n ],\n \"additionalInformation\": \"Para utilizar o serviço é preciso ter uma conta ativa do Cookiebot. Algumas funcionalidades só estão disponíveis para planos específicos.\",\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_cookiebot_bc83676e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cookiebot/public/metadata/messages/en-US.json from the cookiebot VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"Cookiebot\",\n \"headline\": \"With a few clicks configure and preview your own cookie declaration and consent dialog.\",\n \"overview\": \"Cookiebot brings this vision to life with three, fully automatic core functions that are easy to implement: cookie consent, cookie monitoring and cookie control.\\nCookiebot enables true compliance with privacy legislation through respectful and transparent data exchange, based on consent between end-users and the websites they visit.\",\n \"features\": [\n \"Automated cookie scan and declaration\",\n \"Cookie consent banner\",\n \"Bulk consent for multiple domains\",\n \"Support and auto-detect any language\",\n \"Real-time geographic targeting\",\n \"Visual statistics on the choices of your website visitors\"\n ],\n \"additionalInformation\": \"To use the service, you must have an active Cookiebot account. Some features are only available for specific plans.\",\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_cookiebot_d33360ca
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cookiebot/react/typings/vtex.render-runtime.d.ts from the cookiebot VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.render-runtime' {\n export const canUseDOM: boolean\n}\n\n```" } ]
code_cookiebot_2b3f7156
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cookiebot/react/typings/global.d.ts from the cookiebot VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ninterface Window extends Window {\n __cookiebot_id: string\n Cookiebot: Cookiebot\n}\n\ninterface Cookiebot {\n runScripts: () => void\n}\n\n```" } ]
code_checkout-coupon_fc9d85b7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-coupon/messages/pt.json from the checkout-coupon VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/coupon.Apply\": \"Aplicar\",\n \"store/coupon.ApplyPromoCode\": \"Aplicar cupom de desconto\",\n \"store/coupon.PromoCode\": \"Cupom de Desconto\",\n \"store/coupon.PromoCodeLabel\": \"Código do cupom\",\n \"store/coupon.couponNotFound\": \"Cupom inválido.\",\n \"store/coupon.couponExpired\": \"Cupom expirado.\"\n}\n\n```" } ]
code_checkout-coupon_e795e037
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-coupon/messages/en.json from the checkout-coupon VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/coupon.Apply\": \"Apply\",\n \"store/coupon.ApplyPromoCode\": \"Apply promo code\",\n \"store/coupon.PromoCode\": \"Promo Code\",\n \"store/coupon.PromoCodeLabel\": \"Promo code\",\n \"store/coupon.couponNotFound\": \"Invalid promo code.\",\n \"store/coupon.couponExpired\": \"This promo code has expired.\"\n}\n\n```" } ]
code_checkout-coupon_48e4db76
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-coupon/messages/id.json from the checkout-coupon VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/coupon.Apply\": \"Terapkan\",\n \"store/coupon.ApplyPromoCode\": \"Masukkan kode voucher\",\n \"store/coupon.PromoCode\": \"Kode promo\",\n \"store/coupon.PromoCodeLabel\": \"Kode promo\",\n \"store/coupon.couponNotFound\": \"Kode promo tidak valid.\",\n \"store/coupon.couponExpired\": \"Kode promo ini tidak berlaku.\"\n}\n```" } ]
code_checkout-coupon_1fcbed0c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-coupon/messages/es.json from the checkout-coupon VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/coupon.Apply\": \"Aplicar\",\n \"store/coupon.ApplyPromoCode\": \"Aplicar cupón de descuento\",\n \"store/coupon.PromoCode\": \"Cupón de Descuento\",\n \"store/coupon.PromoCodeLabel\": \"Código de cupón\",\n \"store/coupon.couponNotFound\": \"Este cupón no es válido.\",\n \"store/coupon.couponExpired\": \"Este cupón ha expirado.\"\n}\n\n```" } ]
code_checkout-coupon_5d59dc0b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-coupon/docs/README.md from the checkout-coupon VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# VTEX IO Base Component\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\nThis demo component shows you how to make a simple yet complete VTEX IO component.\n\nIt shows a simple demonstration of the following features:\n\n- Declaring a component interface in `store/interfaces.json`.\n- Declaring a schema to receive props via Storefront.\n- Using the `messages` feature to have localized strings.\n- Using an NPM package like `react-intl`\n- Using another VTEX IO App like `vtex.styleguide`.\n- Using CSS Modules to make your component customizable via CSS on a store theme.\n- Using tachyons tokens to quickly style your components.\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!\n\n```" } ]
code_checkout-coupon_2d9238e5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-coupon/react/package.json from the checkout-coupon VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"test\": \"vtex-test-tools test\",\n \"lint\": \"tsc --noEmit && eslint --ext ts,tsx .\"\n },\n \"dependencies\": {\n \"react\": \"^16.8.3\",\n \"react-dom\": \"^16.8.6\",\n \"react-intl\": \"^3.12.1\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^3.1.4\",\n \"@testing-library/dom\": \"^7.21.5\",\n \"@testing-library/jest-dom\": \"^5.11.1\",\n \"@types/graphql\": \"^14.2.0\",\n \"@types/jest\": \"^24.0.11\",\n \"@types/node\": \"^11.13.0\",\n \"@types/react\": \"^16.8.10\",\n \"@vtex/styleguide\": \"^9.125.0\",\n \"@vtex/test-tools\": \"^3.1.0\",\n \"vtex.order-coupon\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.order-coupon@0.7.1/public/@types/vtex.order-coupon\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.111.1/public/@types/vtex.render-runtime\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.125.0/public/@types/vtex.styleguide\"\n },\n \"version\": \"0.11.0\"\n}\n\n```" } ]
code_checkout-coupon_c4ba2137
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-coupon/react/Coupon.css from the checkout-coupon VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.inputForm :global(.vtex-input) input {\n min-width: 0;\n}\n\n```" } ]
code_checkout-coupon_a9e1332c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-coupon/react/Coupon.tsx from the checkout-coupon VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment, useState } from 'react'\nimport { defineMessages, FormattedMessage, useIntl } from 'react-intl'\nimport { ButtonPlain, InputButton, Tag } from 'vtex.styleguide'\nimport { OrderCoupon } from 'vtex.order-coupon'\n\nimport styles from './Coupon.css'\n\nconst { useOrderCoupon } = OrderCoupon\n\nconst NO_ERROR = ''\n\nconst messages = defineMessages({\n Apply: {\n id: 'store/coupon.Apply',\n defaultMessage: 'Apply',\n },\n ApplyPromoCode: {\n id: 'store/coupon.ApplyPromoCode',\n defaultMessage: 'Apply promo code',\n },\n couponNotFound: {\n id: 'store/coupon.couponNotFound',\n defaultMessage: `Invalid promo code.`,\n },\n couponExpired: {\n id: 'store/coupon.couponExpired',\n defaultMessage: `This promo code has expired.`,\n },\n PromoCode: {\n id: 'store/coupon.PromoCode',\n defaultMessage: 'Promo Code',\n },\n PromoCodeLabel: {\n id: 'store/coupon.PromoCode',\n defaultMessage: 'Promo code',\n },\n})\n\nconst Coupon: React.FC = () => {\n const { coupon, insertCoupon } = useOrderCoupon()\n const [showPromoButton, setShowPromoButton] = useState(true)\n const [errorKey, setErrorKey] = useState(NO_ERROR)\n const [currentCoupon, setCurrentCoupon] = useState('')\n const [loadingCoupon, setLoadingCoupon] = useState(false)\n const toggle = () => setShowPromoButton(!showPromoButton)\n const intl = useIntl()\n\n const handleBlur = (evt: React.FocusEvent<HTMLInputElement>) => {\n evt.preventDefault()\n const newCoupon = evt.target.value.trim()\n\n if (!newCoupon) {\n setErrorKey(NO_ERROR)\n toggle()\n }\n }\n\n const handleCouponChange = (evt: React.ChangeEvent<HTMLInputElement>) => {\n evt.preventDefault()\n const newCoupon = evt.target.value.trim()\n\n setCurrentCoupon(newCoupon)\n }\n\n const resetCouponInput = () => {\n insertCoupon('')\n setCurrentCoupon('')\n setShowPromoButton(false)\n }\n\n const submitCoupon = (evt: React.FormEvent<HTMLFormElement>) => {\n evt.preventDefault()\n setErrorKey(NO_ERROR)\n insertCoupon(currentCoupon).then(result => {\n setLoadingCoupon(false)\n if (result.success) {\n setErrorKey(NO_ERROR)\n setShowPromoButton(true)\n } else {\n setErrorKey(result.errorKey)\n }\n })\n setLoadingCoupon(true)\n }\n\n return (\n <Fragment>\n {showPromoButton ? (\n <Fragment>\n {!coupon && (\n <div>\n <ButtonPlain id=\"add-coupon\" onClick={toggle}>\n <FormattedMessage id=\"store/coupon.ApplyPromoCode\" />\n </ButtonPlain>\n </div>\n )}\n\n {coupon && (\n <div>\n <div className=\"c-on-base t-small mb3\">\n <FormattedMessage id=\"store/coupon.PromoCode\" />\n </div>\n <Tag id=\"coupon-code\" onClick={resetCouponInput}>\n {coupon}\n </Tag>\n </div>\n )}\n </Fragment>\n ) : (\n <form className={styles.inputForm} onSubmit={submitCoupon}>\n <InputButton\n id=\"coupon-input\"\n button={intl.formatMessage({ id: 'store/coupon.Apply' })}\n isLoading={loadingCoupon}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus\n onChange={handleCouponChange}\n onBlur={handleBlur}\n placeholder=\"\"\n errorMessage={\n errorKey\n ? intl.formatMessage(\n messages[errorKey as keyof typeof messages]\n )\n : NO_ERROR\n }\n label={<FormattedMessage id=\"store/coupon.PromoCodeLabel\" />}\n value={currentCoupon}\n />\n </form>\n )}\n </Fragment>\n )\n}\n\nexport default Coupon\n\n```" } ]
code_checkout-coupon_4740d850
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-coupon/react/typings/css.d.ts from the checkout-coupon VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const css: any\n export default css\n}\n\n```" } ]
code_checkout-coupon_8c281cbe
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-coupon/react/typings/vtex.styleguide.d.ts from the checkout-coupon VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ComponentType } from 'react'\n\ndeclare module 'vtex.styleguide' {\n export const Input: ComponentType<InputProps>\n\n interface InputProps {\n [key: string]: any\n }\n\n export const Tag: ComponentType<any>\n\n export const InputButton: ComponentType<any>\n}\n\n```" } ]
code_checkout-coupon_d109e0c9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-coupon/react/__tests__/Coupon.test.tsx from the checkout-coupon VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { render, fireEvent, wait } from '@vtex/test-tools/react'\nimport React, { useState } from 'react'\n\nimport Coupon from '../Coupon'\n\nconst {\n OrderCoupon: { OrderCouponProvider },\n} = jest.requireMock('vtex.order-coupon')\n\ndescribe('<Coupon />', () => {\n it('should show input after clicking to apply promotion code', () => {\n const { getByText, getByRole } = render(\n <OrderCouponProvider coupon=\"\" insertCoupon={jest.fn()}>\n <Coupon />\n </OrderCouponProvider>\n )\n\n const button = getByText(/apply promo code/i)\n\n fireEvent.click(button)\n\n const couponInput = getByRole('textbox')\n\n expect(couponInput).toBeInTheDocument()\n })\n\n it('should show coupon tag if coupon already applied', () => {\n const { getByText } = render(\n <OrderCouponProvider coupon=\"testcoupon\" insertCoupon={jest.fn()}>\n <Coupon />\n </OrderCouponProvider>\n )\n\n expect(getByText('testcoupon')).toBeInTheDocument()\n })\n\n it('should focus on the input after clicking on apply promo code button', () => {\n const { getByRole, getByText } = render(\n <OrderCouponProvider coupon=\"\" insertCoupon={jest.fn()}>\n <Coupon />\n </OrderCouponProvider>\n )\n\n const addPromoButton = getByText(/apply promo code/i)\n\n fireEvent.click(addPromoButton)\n\n const couponInput = getByRole('textbox')\n\n expect(document.activeElement).toBe(couponInput)\n })\n\n it('should be able to submit the coupon code', async () => {\n const Component: React.FC = () => {\n const [coupon, setCoupon] = useState('')\n\n const insertCoupon = (newCoupon: string) => {\n setCoupon(newCoupon)\n\n return Promise.resolve({ success: true, errorKey: '' })\n }\n\n return (\n <OrderCouponProvider coupon={coupon} insertCoupon={insertCoupon}>\n <Coupon />\n </OrderCouponProvider>\n )\n }\n\n const { getByRole, getByText } = render(<Component />)\n\n const addPromoButton = getByText(/apply promo code/i)\n\n fireEvent.click(addPromoButton)\n\n const couponInput = getByRole('textbox')\n\n fireEvent.change(couponInput, { target: { value: 'freeshipping' } })\n\n const submitCouponButton = getByRole('button')\n\n fireEvent.click(submitCouponButton)\n\n await wait(() => expect(getByText('freeshipping')).toBeInTheDocument())\n })\n\n it('should remove coupon after clicking on coupon tag', () => {\n const Component: React.FC = () => {\n const [coupon, setCoupon] = useState('freeshipping')\n\n const insertCoupon = (newCoupon: string) => {\n setCoupon(newCoupon)\n\n return Promise.resolve({ success: true, errorKey: '' })\n }\n\n return (\n <OrderCouponProvider coupon={coupon} insertCoupon={insertCoupon}>\n <Coupon />\n </OrderCouponProvider>\n )\n }\n\n const { getByText, getByRole } = render(<Component />)\n\n const couponTag = getByText('freeshipping')\n\n expect(couponTag).toBeInTheDocument()\n\n fireEvent.click(couponTag)\n\n const couponInput = getByRole('textbox')\n\n expect(couponInput).toBeInTheDocument()\n expect(couponInput).toHaveValue('')\n })\n\n it.each`\n couponName | errorKey | messageRegex\n ${'expired coupon'} | ${'couponExpired'} | ${/this promo code has expired/i}\n ${'invalid coupon'} | ${'couponNotFound'} | ${/invalid promo code/i}\n `(\n 'should handle $errorKey error when submitting the coupon',\n async ({\n couponName,\n errorKey,\n messageRegex,\n }: {\n couponName: string\n errorKey: string\n messageRegex: RegExp\n }) => {\n const Component: React.FC = () => {\n const [coupon, setCoupon] = useState('')\n\n const insertCoupon = (newCoupon: string) => {\n if (newCoupon === couponName) {\n return Promise.resolve({ success: false, errorKey })\n }\n\n setCoupon(newCoupon)\n\n return Promise.resolve({ success: true, errorKey: '' })\n }\n\n return (\n <OrderCouponProvider coupon={coupon} insertCoupon={insertCoupon}>\n <Coupon />\n </OrderCouponProvider>\n )\n }\n\n const { getByRole, getByText } = render(<Component />)\n\n const addPromoButton = getByText(/apply promo code/i)\n\n fireEvent.click(addPromoButton)\n\n const couponInput = getByRole('textbox')\n\n fireEvent.change(couponInput, { target: { value: couponName } })\n\n const applyButton = getByRole('button')\n\n fireEvent.click(applyButton)\n\n await wait(() => expect(getByText(messageRegex)).toBeInTheDocument())\n }\n )\n})\n\n```" } ]
code_sidecar-pixel_8c726ac1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of sidecar-pixel/docs/README.md from the sidecar-pixel VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Sidecar\n\n> getsidecar.com first party app\n\n## Setup\n\nOpen a terminal and type:\n\n```\nvtex install vtex.sidecar-pixel@1.x\n```\n\nOpen your admin in the Apps section:\n\nhttps://YOURSTORENAME.myvtex.com/admin/apps/\n\nClick in Sidecar and fill your Site Domain and Site ID.\n\n```" } ]
code_sidecar-pixel_cb37dc58
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of sidecar-pixel/react/package.json from the sidecar-pixel VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"devDependencies\": {\n \"@types/graphql\": \"^14.2.2\",\n \"@types/jest\": \"^24.0.15\",\n \"@types/node\": \"^12.6.4\",\n \"eslint\": \"5\",\n \"eslint-config-vtex-react\": \"^4.1.0\",\n \"prettier\": \"^1.18.2\",\n \"typescript\": \"3.5.2\"\n }\n}\n\n```" } ]
code_sidecar-pixel_113427bc
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of sidecar-pixel/react/index.ts from the sidecar-pixel VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { canUseDOM } from 'vtex.render-runtime'\nimport { PixelMessage, OrderPlacedData } from './typings/events'\n\nlet added = false\nfunction handleMessages(e: PixelMessage) {\n switch (e.data.eventName) {\n case 'vtex:pageView': {\n const { pageUrl } = e.data\n const isOrderPlaced = pageUrl.indexOf('checkout/orderPlaced') !== -1\n if (!isOrderPlaced && added === false) {\n addTrackingLib()\n }\n break\n }\n case 'vtex:orderPlaced': {\n const order = e.data\n addMetrics(order)\n addTrackingLib()\n break\n }\n default:\n break\n }\n}\n\nfunction addTrackingLib() {\n const a = document.createElement('script')\n a.async = true\n a.setAttribute('data-id', encodeURI(window.__sidecar_id))\n a.setAttribute('data-domain', encodeURI(window.__sidecar_domain))\n a.setAttribute('data-other', JSON.stringify({}))\n a.id = '_SCJS_'\n a.src = 'https://d3v27wwd40f0xu.cloudfront.net/js/tracking/sidecar.js'\n const r =\n document.getElementsByTagName('script')[0] ||\n document.getElementsByTagName('body')[0]\n r.parentNode!.insertBefore(a, r)\n}\n\nfunction addMetrics(order: OrderPlacedData) {\n window.sidecar = window.sidecar || {}\n\n type Promo = { name: string; amount: number }\n const promosMap = order.transactionProducts.reduce<Record<string, Promo>>(\n (promos, product) => {\n product.priceTags.forEach(priceTag => {\n // Not a discount, priceTag is increasing the price\n if (priceTag.value > 0) {\n return\n }\n\n if (!promos[priceTag.identifier]) {\n promos[priceTag.identifier] = {\n name: priceTag.identifier,\n amount: priceTag.value * -1,\n }\n }\n\n promos[priceTag.identifier].amount += priceTag.value * -1\n })\n\n return promos\n },\n {}\n )\n\n window.sidecar.transactions = {\n add: true,\n data: {\n order_id: order.transactionId,\n subtotal: order.transactionSubtotal,\n tax: order.transactionTax,\n shipping: order.transactionShipping,\n discounts: order.transactionDiscounts,\n total: order.transactionTotal,\n zipcode: order.visitorAddressPostalCode,\n },\n items: order.transactionProducts.map(product => ({\n product_id: product.sku,\n unit_price: product.price,\n quantity: product.quantity,\n })),\n discounts: Object.values(promosMap),\n }\n}\n\nif (canUseDOM) {\n window.addEventListener('message', handleMessages)\n}\n\n```" } ]
code_sidecar-pixel_e4bbf21e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of sidecar-pixel/store/interfaces.json from the sidecar-pixel VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"pixel.sidecar\": {\n \"component\": \"index\"\n }\n}\n\n```" } ]
code_sidecar-pixel_b7e84130
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of sidecar-pixel/react/typings/events.d.ts from the sidecar-pixel VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport interface PixelMessage extends MessageEvent {\n data: OrderPlacedData | PageViewData\n}\n\nexport interface EventData {\n event: string\n eventName: string\n currency: string\n}\n\nexport interface PageViewData extends EventData {\n event: 'pageView'\n eventName: 'vtex:pageView'\n pageTitle: string\n pageUrl: string\n referrer: string\n}\n\nexport interface OrderPlacedData extends Order, EventData {\n event: 'orderPlaced'\n eventName: 'vtex:orderPlaced'\n}\n\nexport interface Order {\n currency: string\n accountName: string\n orderGroup: string\n salesChannel: string\n coupon: string\n visitorCountry: string\n visitorState: string\n visitorType: string\n visitorContactInfo: string[]\n visitorAddressState: string\n visitorAddressCountry: string\n visitorAddressPostalCode: string\n transactionId: string\n transactionDate: string\n transactionAffiliation: string\n transactionTotal: number\n transactionSubtotal: number\n transactionDiscounts: number\n transactionShipping: number\n transactionTax: number\n transactionCurrency: string\n transactionPaymentType: PaymentType[]\n transactionShippingMethod: ShippingMethod[]\n transactionProducts: ProductOrder[]\n transactionPayment: {\n id: string\n }\n}\n\ninterface PaymentType {\n group: string\n paymentSystemName: string\n installments: number\n value: number\n}\n\ninterface ShippingMethod {\n itemId: string\n selectedSla: string\n}\n\ninterface ProductOrder {\n id: string\n name: string\n sku: string\n skuRefId: string\n skuName: string\n brand: string\n brandId: string\n seller: string\n sellerId: string\n category: string\n categoryId: string\n categoryTree: string[]\n categoryIdTree: string[]\n priceTags: PriceTag[]\n originalPrice: number\n price: number\n sellingPrice: number\n tax: number\n quantity: number\n components: any[]\n measurementUnit: string\n unitMultiplier: number\n}\n\ninterface PriceTag {\n identifier: string\n isPercentual: boolean\n value: number\n}\n\n```" } ]
code_sidecar-pixel_ceef1f32
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of sidecar-pixel/react/typings/vtex.render-runtime.d.ts from the sidecar-pixel VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.render-runtime' {\n export const canUseDOM: boolean\n}\n\n```" } ]
code_sidecar-pixel_66fa80ea
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of sidecar-pixel/react/typings/global.d.ts from the sidecar-pixel VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ninterface Window extends Window {\n __sidecar_domain: string\n __sidecar_id: string\n sidecar: any\n}\n\n```" } ]