id
stringlengths 12
53
| messages
listlengths 3
3
|
|---|---|
code_mycheckout-checkout-service_5418df68
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-checkout-service/src/assets/lang/en/responses.json from the mycheckout-checkout-service VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"resource_deleted\": \"Resource deleted correctly\",\n \"resource_updated\": \"Resource updated correctly\",\n \"resource_created_updated\": \"Resource created or updated correctly\",\n \"user_login_email_sent\": \"An email was sent to the user with the login code\",\n \"user_login_sent\": \"A notification was sent to the user with the login code\",\n \"authenticated\": \"Authenticated correctly\",\n \"sms_body\": \"Hello, {name}. Your access code is: {code}.\\n\\n@{origin} #{code}\"\n}\n```"
}
] |
code_mycheckout-checkout-service_e81eb259
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-checkout-service/src/base/base-inheritance/decorators-extends.ts from the mycheckout-checkout-service VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { applyDecorators } from '@nestjs/common';\nimport { ExtendTypes } from './extends-types.enum';\nimport { IBaseService } from '../base-service.interface';\n\nfunction DecoratorOmit<T, K extends keyof IBaseService<T>>(\n decorator,\n methods: K[],\n method: K,\n) {\n return methods.includes(method) ? applyDecorators() : decorator;\n}\n\nfunction DecoratorPick<T, K extends keyof IBaseService<T>>(\n decorator,\n methods: K[],\n method: K,\n) {\n return methods.includes(method) ? decorator : applyDecorators();\n}\n\nfunction DecoratorTotal<_, __ extends _>(decorator, _: __[], __: __) {\n return decorator;\n}\n\nexport function DecoratorExtendTypeSelector(type) {\n if (type == ExtendTypes.pick) {\n return DecoratorPick;\n } else if (type == ExtendTypes.omit) {\n return DecoratorOmit;\n } else {\n return DecoratorTotal;\n }\n}\n\n```"
}
] |
code_mycheckout-checkout-service_d0d49a1b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-checkout-service/src/base/base-inheritance/decorators-assing.ts from the mycheckout-checkout-service VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { applyDecorators } from '@nestjs/common';\nimport { IDecorators } from '../base-options.interface';\nimport { IBaseService } from '../base-service.interface';\n\nexport function DecoratorAssing<T, K extends keyof IBaseService<T>>(\n decorators: IDecorators<K>['decorators'],\n method: K,\n) {\n if (!decorators) return applyDecorators();\n const functions: any = [];\n decorators.forEach((decorator) => {\n if (decorator.in.includes(method)) functions.push(decorator.use);\n });\n return applyDecorators(...functions);\n}\n\n```"
}
] |
code_mycheckout-checkout-service_6a9351e1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-checkout-service/src/base/base-inheritance/extend-type-selector.ts from the mycheckout-checkout-service VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { OmitExtend } from './omit-extend';\nimport { PickExtend } from './pick-extend';\nimport { TotalExtend } from './total-extend';\nimport { ExtendTypes } from './extends-types.enum';\n\nexport function ExtendTypeSelector(type: ExtendTypes) {\n if (type == ExtendTypes.pick) {\n return PickExtend;\n } else if (type == ExtendTypes.omit) {\n return OmitExtend;\n } else {\n return TotalExtend;\n }\n}\n\n```"
}
] |
code_mycheckout-checkout-service_0de72e29
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-checkout-service/src/base/base-inheritance/pick-extend.ts from the mycheckout-checkout-service VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport function PickExtend<Class, K extends keyof Class>(_class, methods: K[]) {\n const prototype = _class.prototype;\n const properties = Object.getOwnPropertyNames(prototype);\n properties.shift();\n properties.forEach((method: any) => {\n if (!methods.includes(method)) delete prototype[method];\n });\n return _class;\n}\n\n```"
}
] |
code_mycheckout-checkout-service_785fb05c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-checkout-service/src/base/base-inheritance/extends-types.enum.ts from the mycheckout-checkout-service VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport enum ExtendTypes {\n 'omit' = 'omit',\n 'pick' = 'pick',\n}\n\n```"
}
] |
code_mycheckout-checkout-service_61f50961
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-checkout-service/src/base/base-inheritance/omit-extend.ts from the mycheckout-checkout-service VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport function OmitExtend<Class, K extends keyof Class>(_class, methods: K[]) {\n const prototype = _class.prototype;\n const properties = Object.getOwnPropertyNames(prototype);\n properties.shift();\n methods.forEach((method: any) => {\n delete prototype[method];\n });\n return _class;\n}\n\n```"
}
] |
code_mycheckout-checkout-service_e8973c2c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-checkout-service/src/base/base-inheritance/total-extend.ts from the mycheckout-checkout-service VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport function TotalExtend<Class, K extends keyof Class>(_class, _: K[]) {\n return _class;\n}\n\n```"
}
] |
code_mycheckout-checkout-service_2594b960
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-checkout-service/src/base/paginator/pagination-response.ts from the mycheckout-checkout-service VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport class PaginationResponse<T> {\n constructor(o: PaginationResponse<T>) {\n Object.assign(this, o);\n }\n\n count: number;\n total: number;\n current: number;\n prev: number;\n next: number;\n\n data: T[];\n}\n\n```"
}
] |
code_mycheckout-checkout-service_88c32d6c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-checkout-service/src/base/paginator/pagination.service.ts from the mycheckout-checkout-service VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { Repository } from 'typeorm';\nimport { ApiResponse } from '../../shared/responses/api-response';\nimport { PaginationResponse } from './pagination-response';\n\nexport class PaginationService<T> {\n paginate(\n limit: number,\n page: number,\n query: Object,\n genericRepository: Repository<T>,\n ): Promise<PaginationResponse<T>> {\n try {\n return new Promise<PaginationResponse<T>>((resolve, reject) => {\n genericRepository\n .findAndCount({\n where: query,\n take: limit,\n skip: (page - 1) * limit,\n })\n .then((response) => {\n try {\n const paginationResponse = new PaginationResponse<T>({\n total: response[1],\n current: page,\n next: this.nextPage(page, limit, response[1]),\n prev: this.prevPage(page),\n count: response[0].length,\n data: response[0],\n });\n\n resolve(paginationResponse);\n } catch {\n reject(ApiResponse.error('errors.bad_gateway'));\n }\n })\n .catch(() => reject(ApiResponse.error('errors.bad_gateway')));\n });\n } catch {\n throw ApiResponse.error('errors.bad_gateway');\n }\n }\n\n private nextPage(current: number, limit: number, total: number): number {\n return limit * current >= total ? current : current + 1;\n }\n\n private prevPage(current: number): number {\n return current == 1 ? current : current - 1;\n }\n}\n\n```"
}
] |
code_mycheckout-checkout-service_f1090478
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-checkout-service/src/base/paginator/index.ts from the mycheckout-checkout-service VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport * from './pagination.service';\nexport * from './pagination-response';\n\n```"
}
] |
code_mycheckout-checkout-service_6d8aa174
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-checkout-service/src/base/paginator/dto/pagination.dto.ts from the mycheckout-checkout-service VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { Type } from 'class-transformer';\nimport {\n IsInt,\n IsOptional,\n Max,\n Min,\n ValidationArguments,\n} from 'class-validator';\nimport { ApiError } from '../../../shared/responses/api-error';\n\nexport class PaginationDto {\n /*page arg*/\n //validations\n @IsOptional()\n @IsInt({\n message: (args: ValidationArguments) =>\n ApiError.parse('validations.field_integer', args),\n })\n @Min(1, {\n message: (args: ValidationArguments) =>\n ApiError.parse('validations.field_less', args),\n })\n @Type(() => Number)\n //field\n page?: number;\n\n /*limit arg*/\n //validations\n @IsOptional()\n @IsInt({\n message: (args: ValidationArguments) =>\n ApiError.parse('validations.field_integer', args),\n })\n @Max(100, {\n message: (args: ValidationArguments) =>\n ApiError.parse('validations.field_greater', args),\n })\n @Min(1, {\n message: (args: ValidationArguments) =>\n ApiError.parse('validations.field_less', args),\n })\n @Type(() => Number)\n //field\n limit?: number;\n}\n\n```"
}
] |
code_pharma-orders-admin_f7a43291
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/messages/pt.json from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/admin.app.navigation.title\": \"Pedidos Farmacêuticos\",\n \"admin/admin.app.navigation.search.kws\": \"pharma, orders, orderId\",\n \"admin/admin.app.pharma-orders.textOf\": \"do\",\n \"admin/admin.app.pharma-orders.textShowRows\": \"Exibir linhas\",\n \"admin/admin.app.pharma-orders.filterClear\": \"Filtros Claros\",\n \"admin/admin.app.pharma-orders.filterAll\": \"Tudo\",\n \"admin/admin.app.pharma-orders.filterNone\": \"Nenhum\",\n \"admin/admin.app.pharma-orders.filterAny\": \"Algum\",\n \"admin/admin.app.pharma-orders.filterIs\": \"igual\",\n \"admin/admin.app.pharma-orders.filterIsNot\": \"não igual\",\n \"admin/admin.app.pharma-orders.filterContains\": \"contém\",\n \"admin/admin.app.pharma-orders.filterApply\": \"Aplique\",\n \"admin/admin.app.pharma-orders.ordersTableOrderId\": \"OrderId\",\n \"admin/admin.app.pharma-orders.ordersTableStatus\": \"Status\",\n \"admin/admin.app.pharma-orders.ordersTableProducts\": \"Produtos\",\n \"admin/admin.app.pharma-orders.ordersTableFiles\": \"Prescrições\",\n \"admin/admin.app.pharma-orders.selectedOrders\": \"Pedidos selecionados:\",\n \"admin/admin.app.pharma-orders.selectAllOrders\": \"Selecionar Tudo\",\n \"admin/admin.app.pharma-orders.pageTitle\": \"Pedidos Farmacêuticos\",\n \"admin/admin.app.pharma-orders.approve\": \"Aprovar\",\n \"admin/admin.app.pharma-orders.confirm\": \"Confirme\",\n \"admin/admin.app.pharma-orders.cancel\": \"Cancelar\",\n \"admin/admin.app.pharma-orders.buttonShowProducts\": \"Mostrar Produtos\",\n \"admin/admin.app.pharma-orders.buttonShowFiles\": \"Mostrar Arquivos\",\n \"admin/admin.app.pharma-orders.productTableProductId\": \"ProductId\",\n \"admin/admin.app.pharma-orders.productTableQuantity\": \"Quantidade\",\n \"admin/admin.app.pharma-orders.productTableName\": \"Nome\",\n \"admin/admin.app.pharma-orders.prescription\": \"Prescrição\",\n \"admin/admin.app.pharma-orders.withoutPrescription\": \"Sem prescrições\",\n \"admin/admin.app.pharma-orders.theOrder\": \"O pedido\",\n \"admin/admin.app.pharma-orders.wasCanceled\": \"foi cancelado com sucesso.\",\n \"admin/admin.app.pharma-orders.wasNotCanceled\": \"não foi cancelado.\",\n \"admin/admin.app.pharma-orders.wasAlreadyCanceled\": \"já foi cancelado.\",\n \"admin/admin.app.pharma-orders.canceled\": \"Cancelado\",\n \"admin/admin.app.pharma-orders.created\": \"Criado\",\n \"admin/admin.app.pharma-orders.approved\": \"Aprovado\",\n \"admin/admin.app.pharma-orders.confirmed\": \"Confirmado\",\n \"admin/admin.app.pharma-orders.wasApproved\": \"foi aprovado com sucesso.\",\n \"admin/admin.app.pharma-orders.wasNotApproved\": \"não foi aprovado.\",\n \"admin/admin.app.pharma-orders.wasAlreadyApproved\": \"já foi aprovado.\",\n \"admin/admin.app.pharma-orders.wasConfirmed\": \"foi confirmado com sucesso.\",\n \"admin/admin.app.pharma-orders.isConfirmed\": \"está confirmado.\",\n \"admin/admin.app.pharma-orders.wasNotConfirmed\": \"não foi confirmado.\",\n \"admin/admin.app.pharma-orders.wasAlreadyConfirmed\": \"já foi confirmado.\",\n \"admin/admin.app.pharma-orders.approvedBeforeConfirming\": \"deve ser aprovado antes de confirmar.\",\n \"admin/admin.app.pharma-orders.isCanceled\": \"foi cancelado.\",\n \"admin/admin.app.pharma-orders.noOrdersYet\": \"Ainda não há pedidos farmacêuticos!\",\n \"admin/admin.app.pharma-orders.invoiceNumber\": \"Número da fatura\",\n \"admin/admin.app.pharma-orders.placeholderInvoiceNumber\": \"Digite se quiser confirmar\",\n \"admin/admin.app.pharma-orders.noInvoiceNumber\": \"Não possui o número da fatura.\"\n}\n\n```"
}
] |
code_pharma-orders-admin_903d5ceb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/messages/en.json from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/admin.app.navigation.title\": \"Pharma Orders\",\n \"admin/admin.app.navigation.search.kws\": \"pharma, orders, orderId, order\",\n \"admin/admin.app.pharma-orders.textOf\": \"of\",\n \"admin/admin.app.pharma-orders.textShowRows\": \"Show rows\",\n \"admin/admin.app.pharma-orders.filterClear\": \"Clear Filters\",\n \"admin/admin.app.pharma-orders.filterAll\": \"All\",\n \"admin/admin.app.pharma-orders.filterNone\": \"None\",\n \"admin/admin.app.pharma-orders.filterAny\": \"Any\",\n \"admin/admin.app.pharma-orders.filterIs\": \"is\",\n \"admin/admin.app.pharma-orders.filterIsNot\": \"is not\",\n \"admin/admin.app.pharma-orders.filterContains\": \"contains\",\n \"admin/admin.app.pharma-orders.filterApply\": \"Apply\",\n \"admin/admin.app.pharma-orders.ordersTableOrderId\": \"OrderId\",\n \"admin/admin.app.pharma-orders.ordersTableStatus\": \"Status\",\n \"admin/admin.app.pharma-orders.ordersTableProducts\": \"Products\",\n \"admin/admin.app.pharma-orders.ordersTableFiles\": \"Prescriptions\",\n \"admin/admin.app.pharma-orders.selectedOrders\": \"Selected orders:\",\n \"admin/admin.app.pharma-orders.selectAllOrders\": \"Select All\",\n \"admin/admin.app.pharma-orders.pageTitle\": \"Pharma Orders\",\n \"admin/admin.app.pharma-orders.approve\": \"Approve\",\n \"admin/admin.app.pharma-orders.confirm\": \"Confirm\",\n \"admin/admin.app.pharma-orders.cancel\": \"Cancel\",\n \"admin/admin.app.pharma-orders.buttonShowProducts\": \"Show Products\",\n \"admin/admin.app.pharma-orders.buttonShowFiles\": \"Show Files\",\n \"admin/admin.app.pharma-orders.productTableProductId\": \"ProductId\",\n \"admin/admin.app.pharma-orders.productTableQuantity\": \"Quantity\",\n \"admin/admin.app.pharma-orders.productTableName\": \"Name\",\n \"admin/admin.app.pharma-orders.prescription\": \"Prescription\",\n \"admin/admin.app.pharma-orders.withoutPrescription\": \"Without prescriptions\",\n \"admin/admin.app.pharma-orders.theOrder\": \"The order\",\n \"admin/admin.app.pharma-orders.wasCanceled\": \"was successfully canceled.\",\n \"admin/admin.app.pharma-orders.wasNotCanceled\": \"was not canceled.\",\n \"admin/admin.app.pharma-orders.wasAlreadyCanceled\": \"was already canceled.\",\n \"admin/admin.app.pharma-orders.canceled\": \"Canceled\",\n \"admin/admin.app.pharma-orders.created\": \"Created\",\n \"admin/admin.app.pharma-orders.approved\": \"Approved\",\n \"admin/admin.app.pharma-orders.confirmed\": \"Confirmed\",\n \"admin/admin.app.pharma-orders.wasApproved\": \"was successfully approved.\",\n \"admin/admin.app.pharma-orders.wasNotApproved\": \"was not approved.\",\n \"admin/admin.app.pharma-orders.wasAlreadyApproved\": \"was already approved.\",\n \"admin/admin.app.pharma-orders.wasConfirmed\": \"was successfully confirmed.\",\n \"admin/admin.app.pharma-orders.isConfirmed\": \"is confirmed.\",\n \"admin/admin.app.pharma-orders.wasNotConfirmed\": \"was not confirmed.\",\n \"admin/admin.app.pharma-orders.wasAlreadyConfirmed\": \"was already confirmed.\",\n \"admin/admin.app.pharma-orders.approvedBeforeConfirming\": \"must be approved before confirming.\",\n \"admin/admin.app.pharma-orders.noOrdersYet\": \"No pharma orders yet!\",\n \"admin/admin.app.pharma-orders.invoiceNumber\": \"Invoice Number\",\n \"admin/admin.app.pharma-orders.placeholderInvoiceNumber\": \"Enter it if you want to confirm\",\n \"admin/admin.app.pharma-orders.noInvoiceNumber\": \"It does not have invoice number.\"\n}\n\n```"
}
] |
code_pharma-orders-admin_316219a0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/messages/es.json from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/admin.app.navigation.title\": \"Ordenes Farmacéuticas\",\n \"admin/admin.app.navigation.search.kws\": \"orden, ordenes, farma, farmaceuticas, orderId\",\n \"admin/admin.app.pharma-orders.textOf\": \"de\",\n \"admin/admin.app.pharma-orders.textShowRows\": \"Mostrar filas\",\n \"admin/admin.app.pharma-orders.filterClear\": \"Limpiar Filtros\",\n \"admin/admin.app.pharma-orders.filterAll\": \"Todos\",\n \"admin/admin.app.pharma-orders.filterNone\": \"Ninguno\",\n \"admin/admin.app.pharma-orders.filterAny\": \"Cualquiera\",\n \"admin/admin.app.pharma-orders.filterIs\": \"igual\",\n \"admin/admin.app.pharma-orders.filterIsNot\": \"no igual\",\n \"admin/admin.app.pharma-orders.filterContains\": \"contiene\",\n \"admin/admin.app.pharma-orders.filterApply\": \"Aplicar\",\n \"admin/admin.app.pharma-orders.ordersTableOrderId\": \"Id Orden\",\n \"admin/admin.app.pharma-orders.ordersTableStatus\": \"Estado\",\n \"admin/admin.app.pharma-orders.ordersTableProducts\": \"Productos\",\n \"admin/admin.app.pharma-orders.ordersTableFiles\": \"Recetas\",\n \"admin/admin.app.pharma-orders.selectedOrders\": \"Ordenes Selecionadas:\",\n \"admin/admin.app.pharma-orders.selectAllOrders\": \"Seleccione Todas\",\n \"admin/admin.app.pharma-orders.pageTitle\": \"Ordenes Farmacéuticas\",\n \"admin/admin.app.pharma-orders.approve\": \"Aprobar\",\n \"admin/admin.app.pharma-orders.confirm\": \"Confirmar\",\n \"admin/admin.app.pharma-orders.cancel\": \"Cancelar\",\n \"admin/admin.app.pharma-orders.buttonShowProducts\": \"Mostrar Productos\",\n \"admin/admin.app.pharma-orders.buttonShowFiles\": \"Mostrar Archivos\",\n \"admin/admin.app.pharma-orders.productTableProductId\": \"Id Producto\",\n \"admin/admin.app.pharma-orders.productTableQuantity\": \"Cantidad\",\n \"admin/admin.app.pharma-orders.productTableName\": \"Nombre\",\n \"admin/admin.app.pharma-orders.prescription\": \"Receta\",\n \"admin/admin.app.pharma-orders.withoutPrescription\": \"Sin recetas\",\n \"admin/admin.app.pharma-orders.theOrder\": \"La orden\",\n \"admin/admin.app.pharma-orders.wasCanceled\": \"fue cancelada con exito.\",\n \"admin/admin.app.pharma-orders.wasNotCanceled\": \"no fue cancelada.\",\n \"admin/admin.app.pharma-orders.wasAlreadyCanceled\": \"ya estaba cancelada.\",\n \"admin/admin.app.pharma-orders.canceled\": \"Cancelada\",\n \"admin/admin.app.pharma-orders.created\": \"Creada\",\n \"admin/admin.app.pharma-orders.approved\": \"Aprobada\",\n \"admin/admin.app.pharma-orders.confirmed\": \"Confirmada\",\n \"admin/admin.app.pharma-orders.wasApproved\": \"fue aprobada con exito.\",\n \"admin/admin.app.pharma-orders.wasNotApproved\": \"no fue aprobada.\",\n \"admin/admin.app.pharma-orders.wasAlreadyApproved\": \"ya estaba aprobada.\",\n \"admin/admin.app.pharma-orders.wasConfirmed\": \"fue confirmada con exito.\",\n \"admin/admin.app.pharma-orders.isConfirmed\": \"está confirmada.\",\n \"admin/admin.app.pharma-orders.wasNotConfirmed\": \"no fue confirmada.\",\n \"admin/admin.app.pharma-orders.wasAlreadyConfirmed\": \"ya fue confirmada.\",\n \"admin/admin.app.pharma-orders.approvedBeforeConfirming\": \"debe estar aprovada antes de confirmar.\",\n \"admin/admin.app.pharma-orders.isCanceled\": \"está cancelada.\",\n \"admin/admin.app.pharma-orders.noOrdersYet\": \"¡Aún no hay ordenes farmacéuticas!\",\n \"admin/admin.app.pharma-orders.invoiceNumber\": \"Numero de Factura\",\n \"admin/admin.app.pharma-orders.placeholderInvoiceNumber\": \"Ingrésalo si quieres confirmar\",\n \"admin/admin.app.pharma-orders.noInvoiceNumber\": \"No tiene número de factura.\"\n}\n\n```"
}
] |
code_pharma-orders-admin_8246b876
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/admin/navigation.json from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"section\": \"orders\",\n \"subSection\": \"delivery\",\n \"subSectionItems\": [\n {\n \"isNew\": true,\n \"labelId\": \"admin/admin.app.navigation.title\",\n \"path\": \"/admin/pharma-orders\"\n }\n ],\n \"searchKeyWordsHelpers\": \"admin/admin.app.navigation.search.kws\"\n}\n\n```"
}
] |
code_pharma-orders-admin_bcbe08ff
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/admin/routes.json from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin.app.pharma-orders\": {\n \"component\": \"PharmaOrders\",\n \"path\": \"/admin/app/pharma-orders\"\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_e9cff7b9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/docs/README.md from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n## ⚠️ Maintenance ⚠️\n*Starting September 1st 2022, this application will no longer be maintained by VTEX. Code is released for free under the GNU/PL Agreement for you to use and modify at your convenience. The VTEX repository shall remain unchanged with the original version. This app was not ended.*\n\n---\n\n# Pharma Orders Admin\n\nThe Pharma Orders Admin app will allow you to manage your Pharma Orders. You can:\n\n- See the orders with products of the category Medicamentos.\n- See the prescription of the orders.\n- See products of the orders\n- Aprove, Cancel and confirm the Orders.\n\n\n\n---\n\n## Configure\n\n1. Using your terminal and the [VTEX IO Toolbelt](https://vtex.io/docs/recipes/development/vtex-io-cli-installment-and-command-reference), log into the desired VTEX account.\n2. Run `vtex install vtexarg.pharma-orders-admin` on the account you're working on.\n\n### Create Entity and Schema\n\nDo a `[PUT]` on `https://:account.vtexcommercestable.com.br/api/dataentities/pharmaOrders/schemas/pharma-orders`\n\n`HEADER: VtexIdClientAutCookie`\n\n`BODY:`\n\n```json\n{\n \"properties\": {\n \"orderId\": {\n \"type\": \"string\",\n \"maxLength\": 50,\n \"title\": \"orderId\"\n },\n \"status\": {\n \"type\": \"string\",\n \"maxLength\": 50,\n \"title\": \"status\"\n },\n \"invoiceNumber\": {\n \"type\": \"string\",\n \"maxLength\": 50,\n \"title\": \"invoiceNumber\"\n }\n },\n \"required\": [\"orderId\", \"status\", \"invoiceNumber\"],\n \"v-indexed\": [\"orderId\", \"status\", \"invoiceNumber\"],\n \"v-security\": {\n \"publicJsonSchema\": true,\n \"allowGetAll\": false,\n \"publicRead\": [\"orderId\", \"status\", \"invoiceNumber\"],\n \"publicWrite\": [\"orderId\", \"status\", \"invoiceNumber\"],\n \"publicFilter\": [\"orderId\", \"status\", \"invoiceNumber\"]\n }\n}\n```\n\n### App Setup\n\n1. If you will work in a workspace, you need to redirect the orders flow to the workspace where you are working, you can do it here:\n `https://:account.myvtex.com/admin/apps/vtex.orders-broadcast/setup`\n \n\n2. You will need to add the `Id` of the `Category Medicamentos`, this is important because the app will only show the orders with products of this category.\n `https://:account.myvtex.com/admin/apps/vtexarg.pharma-orders-admin/setup`\n \n\n```"
}
] |
code_pharma-orders-admin_73990897
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/graphql/schema.graphql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ntype Query {\n getData: GetDataResponse\n getOrder(orderId: String): GetOrderResponse\n getOrderStatus(orderId: String): GetOrderStatusResponse\n getPaymentTransaction(orderId: String): GetPaymentTransactionResponse\n}\n\ntype Mutation {\n cancelOrder(orderId: String): CancelOrderResponse\n updateDocument(\n documentId: String\n body: BodyUpdateDocumentMasterData\n ): UpdateDocumentResponse\n paymentNotification(\n orderId: String\n paymentId: String\n ): PaymentNotificationResponse\n startHandlingOrder(orderId: String): StartHandlingOrderResponse\n invoiceOrder(\n orderId: String\n bodyInvoice: BodyInvoiceOrder\n ): InvoiceOrderResponse\n}\n\n```"
}
] |
code_pharma-orders-admin_f7da28b2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/node/service.json from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"memory\": 512,\n \"ttl\": 10,\n \"timeout\": 600,\n \"minReplicas\": 10,\n \"maxReplicas\": 40,\n \"workers\": 3,\n \"events\": {\n \"orderCreated\": {\n \"sender\": \"vtex.orders-broadcast\",\n \"topics\": [\"order-created\"]\n },\n \"orderCanceled\": {\n \"sender\": \"vtex.orders-broadcast\",\n \"topics\": [\"canceled\"]\n }\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_0e944963
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/node/package.json from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"@vtex/api\": \"6.45.3\",\n \"@vtex/clients\": \"^2.17.0\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^12.0.0\",\n \"@vtex/api\": \"6.45.3\",\n \"typescript\": \"3.9.7\"\n },\n \"resolutions\": {\n \"**/**/minimist\": \"^0.2.1\",\n \"**/**/lodash\": \"^4.17.17\"\n },\n \"version\": \"0.1.0\"\n}\n\n```"
}
] |
code_pharma-orders-admin_5466c658
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/node/globals.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable prettier/prettier */\n\nimport type {\n IOContext,\n ParamsContext,\n RecorderState,\n SegmentData,\n ServiceContext,\n MessagesLoaderV2,\n EventContext,\n} from '@vtex/api'\n\nimport type { Clients } from './clients'\n\ndeclare global {\n type Context = ServiceContext<Clients, State>\n\n interface State extends RecorderState {\n messagesTenantLanguage?: MessagesLoaderV2\n messagesBindingLanguage?: MessagesLoaderV2\n }\n\n interface StaleRevalidateData<T> {\n ttl: Date\n data: T\n }\n\n interface CustomContext extends ParamsContext {\n cookie: string\n originalPath: string\n vtex: CustomIOContext\n }\n\n interface CustomIOContext extends IOContext {\n segment?: SegmentData\n }\n\n interface Property {\n name: string\n values: [string]\n }\n\n interface TranslatableMessage {\n content: string\n from: string\n id: string\n }\n\n interface Reference {\n Key: string\n Value: string\n }\n\n interface StatusChangeContext extends EventContext<Clients> {\n body: {\n domain: string\n orderId: string\n currentState: string\n lastState: string\n currentChangeDate: string\n lastChangeDate: string\n }\n }\n\n interface SaveDataInMasterDataBody {\n orderId: string\n status: string\n invoiceNumber: string\n }\n interface DocumentOfOrder {\n id: string\n orderId: string\n status: string\n }\n interface State extends RecorderState {\n documentOfOrder: DocumentOfOrder\n }\n\n interface ItemsInvoice {\n id: string\n quantity: number\n price: number\n }\n\n interface InvoiceBody {\n type: string\n issuanceDate: string\n invoiceNumber: string\n invoiceValue: number\n items: [ItemsInvoice]\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_21d6d6b5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/node/index.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable prettier/prettier */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { RecorderState } from '@vtex/api'\nimport { LRUCache, Service } from '@vtex/api'\n\nimport { Clients } from './clients'\nimport { resolvers } from './resolvers'\nimport { getOrder } from './middlewares/getOrder'\nimport { saveDataCreated } from './middlewares/saveDataCreated'\nimport { findDataCanceled } from './middlewares/findDataCanceled'\nimport { saveDataCanceled } from './middlewares/saveDataCanceled'\n\nconst TIMEOUT_MS = 800\n\nconst memoryCache = new LRUCache<string, any>({ max: 20 })\n\nmetrics.trackCache('status', memoryCache)\n\nexport default new Service<Clients, RecorderState, Context>({\n clients: {\n implementation: Clients,\n options: {\n default: {\n retries: 2,\n timeout: TIMEOUT_MS,\n },\n status: {\n memoryCache,\n },\n },\n },\n graphql: {\n resolvers,\n },\n events: {\n orderCreated: [getOrder, saveDataCreated],\n orderCanceled: [findDataCanceled, saveDataCanceled],\n },\n})\n\n```"
}
] |
code_pharma-orders-admin_5da75ddf
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/package.json from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"pharma-orders-admin\",\n \"version\": \"0.0.12\",\n \"devDependencies\": {\n \"@types/node\": \"^11.12.1\",\n \"@types/react\": \"^16.8.10\",\n \"@types/react-intl\": \"^3.0.0\",\n \"@vtex/tsconfig\": \"^0.4.4\",\n \"apollo-client\": \"^2.4.7\",\n \"graphql\": \"^14.0.2\",\n \"prop-types\": \"^15.7.2\",\n \"react\": \"^17.0.1\",\n \"react-dom\": \"^17.0.1\",\n \"react-intl\": \"^5.20.10\",\n \"typescript\": \"3.9.7\"\n },\n \"dependencies\": {\n \"@types/faker\": \"^4.1.5\",\n \"@vtex/styleguide\": \"^9.145.1\",\n \"faker\": \"^4.1.0\",\n \"fix\": \"0.0.6\",\n \"react-apollo\": \"^3.1.5\",\n \"react-magnifier\": \"^3.0.4\"\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_56225407
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/PharmaOrders.tsx from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { Layout, PageHeader, PageBlock } from 'vtex.styleguide'\nimport { useIntl } from 'react-intl'\nimport { useQuery } from 'react-apollo'\n\nimport OrdersTable from './components/OrdersTable'\nimport { titlesIntl } from './utils/intl'\nimport getData from './graphql/getData.gql'\nimport LoadingSpinner from './components/LoadingSpinner'\n\nexport default function PharmaOrders() {\n const intl = useIntl()\n\n const responseFromGetData = useQuery(getData, {\n ssr: false,\n })\n\n const dataFromMasterData: OrderFromMasterData[] =\n responseFromGetData.data?.getData?.data\n\n const orderList: Order[] = dataFromMasterData?.map(\n (orderFromMasterData: OrderFromMasterData, index: number) => {\n const { id, orderId, status, invoiceNumber } = orderFromMasterData\n\n const newOrder: Order = {\n id: index,\n idMasterData: id,\n status,\n orderId,\n products: orderId,\n files: orderId,\n invoice: {\n rowId: index,\n invoiceNumber,\n },\n }\n\n return newOrder\n }\n )\n\n return (\n <Layout\n fullWidth\n pageHeader={\n <PageHeader title={intl.formatMessage(titlesIntl.pageTitle)} />\n }\n >\n <PageBlock variation=\"full\">\n {!orderList && <LoadingSpinner />}\n {orderList?.length > 0 && <OrdersTable orderList={orderList} />}\n {orderList?.length === 0 && intl.formatMessage(titlesIntl.noOrdersYet)}\n </PageBlock>\n </Layout>\n )\n}\n\n```"
}
] |
code_pharma-orders-admin_f7d9452c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/graphql/types/updateDocument.graphql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ninput BodyUpdateDocumentMasterData {\n orderId: String\n status: String\n invoiceNumber: String\n}\n\ntype UpdateDocumentResponse {\n status: Int\n}\n\n```"
}
] |
code_pharma-orders-admin_5f0a4d09
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/graphql/types/paymentNotification.graphql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ntype PaymentNotificationResponse {\n status: Int\n}\n\n```"
}
] |
code_pharma-orders-admin_4b803f3f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/graphql/types/cancelOrder.graphql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ntype DataCancelOrderResponse {\n date: String\n orderId: String\n receipt: String\n}\n\ntype CancelOrderResponse {\n status: Int\n data: DataCancelOrderResponse\n}\n\n```"
}
] |
code_pharma-orders-admin_1ed7ad5b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/graphql/types/getOrderStatus.graphql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ntype DataGetOrderStatusResponse {\n status: String\n}\n\ntype GetOrderStatusResponse {\n status: Int\n data: DataGetOrderStatusResponse\n}\n\n```"
}
] |
code_pharma-orders-admin_be1a9ff2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/graphql/types/getData.graphql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ntype DataGetDataResponse {\n id: String\n orderId: String\n status: String\n invoiceNumber: String\n}\n\ntype GetDataResponse {\n status: Int\n data: [DataGetDataResponse]\n}\n\n```"
}
] |
code_pharma-orders-admin_d7f4b621
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/graphql/types/getPaymentTransaction.graphql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ntype Payments {\n id: String\n paymentSystem: String\n paymentSystemName: String\n value: Int\n}\n\ntype DataGetPaymentTransactionResponse {\n status: String\n isActive: String\n transactionId: String\n merchantName: String\n payments: [Payments]\n}\n\ntype GetPaymentTransactionResponse {\n status: Int\n data: DataGetPaymentTransactionResponse\n}\n\n```"
}
] |
code_pharma-orders-admin_0ae814ae
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/graphql/types/getOrder.graphql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ntype OrderItems {\n id: String\n productId: String\n quantity: Int\n name: String\n price: Int\n}\n\ntype Fields {\n data: String\n}\n\ntype CustomApps {\n fields: Fields\n id: String\n major: Int\n}\n\ntype CustomData {\n customApps: [CustomApps]\n}\n\ntype Package {\n invoiceNumber: String\n}\n\ntype PackageAttachment {\n packages: [Package]\n}\n\ntype DataGetOrderResponse {\n items: [OrderItems]\n value: Int\n customData: CustomData\n packageAttachment: PackageAttachment\n}\n\ntype GetOrderResponse {\n status: Int\n data: DataGetOrderResponse\n}\n\n```"
}
] |
code_pharma-orders-admin_277a3f51
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/graphql/types/invoiceOrder.graphql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ninput ItemsInvoice {\n id: String\n quantity: Int\n price: Int\n}\n\ninput BodyInvoiceOrder {\n type: String\n issuanceDate: String\n invoiceNumber: String\n invoiceValue: Int\n items: [ItemsInvoice]\n}\n\ntype InvoiceOrderResponse {\n status: Int\n}\n\n```"
}
] |
code_pharma-orders-admin_b389257a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/node/clients/masterDataClient.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable prettier/prettier */\n\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { ExternalClient } from '@vtex/api'\n\nexport default class MasterDataClient extends ExternalClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(\n `http://${context.account}.vtexcommercestable.com.br/api/dataentities`,\n context,\n {\n ...options,\n headers: {\n VtexIdClientAutCookie:\n context.adminUserAuthToken ??\n context.storeUserAuthToken ??\n context.authToken,\n },\n }\n )\n }\n\n public async getData() {\n return this.http.getRaw(`/pharmaOrders/search?_fields=_all`)\n }\n\n public async saveData(body: SaveDataInMasterDataBody) {\n return this.http.postRaw(\n `/pharmaOrders/documents?_schema=pharma-orders`,\n body\n )\n }\n\n public async getIdOfOrder(orderId: string) {\n return this.http.getRaw(\n `/pharmaOrders/search?_schema=pharma-orders&_fields=id,orderId,status&_where=orderId=${orderId}`\n )\n }\n\n public async updateDocument(id: string, body: SaveDataInMasterDataBody) {\n await this.http.patch(\n `/pharmaOrders/documents/${id}?_schema=pharma-orders`,\n body\n )\n\n return { status: 200 }\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_ff052546
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/node/clients/omsClient.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable prettier/prettier */\n\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { ExternalClient } from '@vtex/api'\n\nexport default class OMS extends ExternalClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(\n `http://${context.account}.vtexcommercestable.com.br/api/oms/pvt/orders`,\n context,\n {\n ...options,\n headers: {\n VtexIdClientAutCookie:\n context.adminUserAuthToken ??\n context.storeUserAuthToken ??\n context.authToken,\n },\n }\n )\n }\n\n public async getOrder(orderId: string) {\n return this.http.getRaw(`/${orderId}`)\n }\n\n public async cancelOrder(orderId: string) {\n return this.http.postRaw(`/${orderId}/cancel`)\n }\n\n public async getPaymentTransaction(orderId: string) {\n return this.http.getRaw(`/${orderId}/payment-transaction`)\n }\n\n public async paymentNotification(orderId: string, paymentId: string) {\n return this.http.postRaw(\n `/${orderId}/payments/${paymentId}/payment-notification`\n )\n }\n\n public async startHandlingOrder(orderId: string) {\n try {\n await this.http.postRaw(`/${orderId}/start-handling`)\n } catch (error) {\n console.info('error', error)\n }\n\n return { status: 200 }\n }\n\n public async invoiceOrder(orderId: string, bodyInvoice: InvoiceBody) {\n try {\n console.info('orderId', orderId)\n console.info('bodyInvoice', bodyInvoice)\n const aux = await this.http.postRaw(`/${orderId}/invoice`, bodyInvoice)\n\n console.info('aux', aux)\n\n return aux\n } catch (error) {\n console.info('error', error)\n\n return error\n }\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_70eb031a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/node/clients/index.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\n\nimport MasterDataClient from './masterDataClient'\nimport OMS from './omsClient'\n\n// Extend the default IOClients implementation with our own custom clients.\nexport class Clients extends IOClients {\n public get masterDataClient() {\n return this.getOrSet('masterDataClient', MasterDataClient)\n }\n\n public get omsClient() {\n return this.getOrSet('omsClient', OMS)\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_af85ce9d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/node/middlewares/saveDataCreated.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport async function saveDataCreated(\n ctx: StatusChangeContext,\n next: () => Promise<any>\n) {\n const {\n clients: { masterDataClient },\n } = ctx\n\n try {\n const { orderId } = ctx.body\n\n const body: SaveDataInMasterDataBody = {\n orderId,\n status: 'created',\n invoiceNumber: '',\n }\n\n console.info('body', body)\n await masterDataClient.saveData(body)\n await next()\n } catch (error) {\n console.info('error', error)\n ctx.state = 500\n ctx.body = error\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_f9667688
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/node/middlewares/saveDataCanceled.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport async function saveDataCanceled(\n ctx: StatusChangeContext,\n next: () => Promise<any>\n) {\n const {\n clients: { masterDataClient },\n } = ctx\n\n try {\n const { documentOfOrder } = ctx.state\n\n const id = documentOfOrder[0]?.id\n const orderId = documentOfOrder[0]?.orderId\n const status = documentOfOrder[0]?.status\n\n if (status !== 'canceled') {\n const body: SaveDataInMasterDataBody = {\n orderId,\n status: 'canceled',\n invoiceNumber: '',\n }\n\n await masterDataClient.updateDocument(id, body)\n\n await next()\n }\n } catch (error) {\n console.info('error', error)\n ctx.state = 500\n ctx.body = error\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_9abad42b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/node/middlewares/getOrder.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport async function getOrder(\n ctx: StatusChangeContext,\n next: () => Promise<any>\n) {\n const {\n clients: { omsClient },\n } = ctx\n\n const { orderId } = ctx.body\n\n try {\n const order = await omsClient.getOrder(orderId)\n\n const { idCategoriaMedicamentos } = await ctx.clients.apps.getAppSettings(\n `${process.env.VTEX_APP_ID}`\n )\n\n let orderWithMedicamentos = false\n\n const { items } = order.data\n\n items.forEach((item: any) => {\n const { categories } = item.additionalInfo\n\n if (!orderWithMedicamentos) {\n orderWithMedicamentos = categories.some(\n (categorie: any) => categorie.id === idCategoriaMedicamentos\n )\n }\n })\n console.info('orderId', orderId)\n console.info('idCategoriaMedicamentos', idCategoriaMedicamentos)\n console.info('orderWithMedicamentos', orderWithMedicamentos)\n\n if (orderWithMedicamentos) {\n await next()\n } else {\n return\n }\n } catch (error) {\n console.info('error', error)\n ctx.state = 500\n ctx.body = error\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_96a7c2ad
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/node/middlewares/findDataCanceled.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport async function findDataCanceled(\n ctx: StatusChangeContext,\n next: () => Promise<any>\n) {\n const {\n clients: { masterDataClient },\n } = ctx\n\n try {\n const { orderId } = ctx.body\n\n const response = await masterDataClient.getIdOfOrder(orderId)\n\n if (response.data.length > 0) {\n ctx.state.documentOfOrder = response.data\n await next()\n }\n } catch (error) {\n console.info('error', error)\n ctx.state = 500\n ctx.body = error\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_1aa2f647
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/node/resolvers/index.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {\n queries as masterDataQueries,\n mutations as masterDataMutations,\n} from './masterData'\nimport { queries as omsQueries, mutations as omsMutations } from './oms'\n\nexport const resolvers = {\n Query: {\n ...masterDataQueries,\n ...omsQueries,\n },\n Mutation: {\n ...omsMutations,\n ...masterDataMutations,\n },\n}\n\n```"
}
] |
code_pharma-orders-admin_71f1b05a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/node/resolvers/oms/index.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nexport const queries = {\n getOrder: async (\n _: unknown,\n { orderId }: any,\n ctx: Context\n ): Promise<any> => {\n return ctx.clients.omsClient.getOrder(orderId)\n },\n getOrderStatus: async (\n _: unknown,\n { orderId }: any,\n ctx: Context\n ): Promise<any> => {\n return ctx.clients.omsClient.getOrder(orderId)\n },\n getPaymentTransaction: async (\n _: unknown,\n { orderId }: any,\n ctx: Context\n ): Promise<any> => {\n return ctx.clients.omsClient.getPaymentTransaction(orderId)\n },\n}\n\nexport const mutations = {\n cancelOrder: async (\n _: unknown,\n { orderId }: any,\n ctx: Context\n ): Promise<any> => {\n return ctx.clients.omsClient.cancelOrder(orderId)\n },\n paymentNotification: async (\n _: unknown,\n { orderId, paymentId }: any,\n ctx: Context\n ): Promise<any> => {\n return ctx.clients.omsClient.paymentNotification(orderId, paymentId)\n },\n startHandlingOrder: async (\n _: unknown,\n { orderId }: any,\n ctx: Context\n ): Promise<any> => {\n return ctx.clients.omsClient.startHandlingOrder(orderId)\n },\n invoiceOrder: async (\n _: unknown,\n { orderId, bodyInvoice }: any,\n ctx: Context\n ): Promise<any> => {\n return ctx.clients.omsClient.invoiceOrder(orderId, bodyInvoice)\n },\n}\n\n```"
}
] |
code_pharma-orders-admin_708ffeed
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/node/resolvers/masterData/index.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const queries = {\n getData: async (_: unknown, __: unknown, ctx: Context): Promise<any> => {\n return ctx.clients.masterDataClient.getData()\n },\n}\n\nexport const mutations = {\n updateDocument: async (\n _: unknown,\n { documentId, body }: any,\n ctx: Context\n ): Promise<any> => {\n return ctx.clients.masterDataClient.updateDocument(documentId, body)\n },\n}\n\n```"
}
] |
code_pharma-orders-admin_572f5df8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/typings/gql.d.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable prettier/prettier */\n\ndeclare module '*.gql' {\n import type { DocumentNode } from 'graphql'\n\n const Schema: DocumentNode\n\n export default Schema\n}\n\ndeclare module '*.graphql' {\n import type { DocumentNode } from 'graphql'\n\n const schema: DocumentNode\n\n export default Schema\n}\n\n```"
}
] |
code_pharma-orders-admin_1a564e98
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/typings/styleguide.d.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide'\ndeclare module 'vtex.store-icons'\n\ndeclare module '@vtex/styleguide/lib/*' {\n const Component: ComponentType<unknown>\n export default Component\n}\n\n```"
}
] |
code_pharma-orders-admin_4d503278
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/typings/global.d.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type { ReactNode, SetStateAction, Dispatch } from 'react'\n\ndeclare global {\n export interface Files {\n key: string\n fileName: string\n }\n\n export interface Order {\n id: number\n idMasterData: string\n status: string\n orderId: sting\n products: string\n files: string\n invoice: {\n rowId: number\n invoiceNumber: string\n }\n }\n\n export interface TableProps {\n orderList: Order[]\n }\n\n export interface OrderFromMasterData {\n id: string\n orderId: sting\n status: string\n invoiceNumber: string\n }\n\n export interface ProductTableProps {\n orderId: sting\n }\n\n export interface ImagePreviewProps {\n url: sting\n }\n export interface SuccessComponent {\n message: string\n onClose: () => void\n }\n\n export interface SuccessArrayComponent {\n messages: string[]\n onClose: () => void\n }\n\n export interface ErrorComponent {\n message: string\n onClose: () => void\n }\n\n export interface ErrorArrayComponent {\n messages: string[]\n onClose: () => void\n }\n\n interface BodyUpdateDocument {\n orderId: string\n status: string\n invoiceNumber: string\n }\n\n interface ItemsInvoice {\n id: string\n quantity: number\n price: number\n }\n\n interface InvoiceBody {\n type: string\n issuanceDate: string\n invoiceNumber: string\n invoiceValue: number\n items: [ItemsInvoice]\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_d2f26a24
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/typings/css.d.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n type Styles = {\n [selector: string]: string\n }\n\n const styles: Styles\n\n export default styles\n}\n\n```"
}
] |
code_pharma-orders-admin_3abafa29
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/utils/intl.ts from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { defineMessages } from 'react-intl'\n\nconst prefix = 'admin/admin.app.pharma-orders.'\n\nexport const titlesIntl = defineMessages({\n textOf: { id: `${prefix}textOf` },\n textShowRows: { id: `${prefix}textShowRows` },\n filterClear: { id: `${prefix}filterClear` },\n filterAll: { id: `${prefix}filterAll` },\n filterNone: { id: `${prefix}filterNone` },\n filterAny: { id: `${prefix}filterAny` },\n filterIs: { id: `${prefix}filterIs` },\n filterIsNot: { id: `${prefix}filterIsNot` },\n filterContains: { id: `${prefix}filterContains` },\n filterApply: { id: `${prefix}filterApply` },\n ordersTableOrderId: { id: `${prefix}ordersTableOrderId` },\n ordersTableStatus: { id: `${prefix}ordersTableStatus` },\n ordersTableProducts: { id: `${prefix}ordersTableProducts` },\n ordersTableFiles: { id: `${prefix}ordersTableFiles` },\n selectedOrders: { id: `${prefix}selectedOrders` },\n selectAllOrders: { id: `${prefix}selectAllOrders` },\n pageTitle: { id: `${prefix}pageTitle` },\n approve: { id: `${prefix}approve` },\n confirm: { id: `${prefix}confirm` },\n cancel: { id: `${prefix}cancel` },\n buttonShowProducts: { id: `${prefix}buttonShowProducts` },\n buttonShowFiles: { id: `${prefix}buttonShowFiles` },\n productTableProductId: { id: `${prefix}productTableProductId` },\n productTableQuantity: { id: `${prefix}productTableQuantity` },\n productTableName: { id: `${prefix}productTableName` },\n prescription: { id: `${prefix}prescription` },\n withoutPrescription: { id: `${prefix}withoutPrescription` },\n theOrder: { id: `${prefix}theOrder` },\n wasCanceled: { id: `${prefix}wasCanceled` },\n wasNotCanceled: { id: `${prefix}wasNotCanceled` },\n wasAlreadyCanceled: { id: `${prefix}wasAlreadyCanceled` },\n canceled: { id: `${prefix}canceled` },\n created: { id: `${prefix}created` },\n approved: { id: `${prefix}approved` },\n confirmed: { id: `${prefix}confirmed` },\n wasApproved: { id: `${prefix}wasApproved` },\n wasNotApproved: { id: `${prefix}wasNotApproved` },\n wasAlreadyApproved: { id: `${prefix}wasAlreadyApproved` },\n wasConfirmed: { id: `${prefix}wasConfirmed` },\n isConfirmed: { id: `${prefix}isConfirmed` },\n wasNotConfirmed: { id: `${prefix}wasNotConfirmed` },\n wasAlreadyConfirmed: { id: `${prefix}wasAlreadyConfirmed` },\n approvedBeforeConfirming: { id: `${prefix}approvedBeforeConfirming` },\n isCanceled: { id: `${prefix}isCanceled` },\n noOrdersYet: { id: `${prefix}noOrdersYet` },\n invoiceNumber: { id: `${prefix}invoiceNumber` },\n placeholderInvoiceNumber: { id: `${prefix}placeholderInvoiceNumber` },\n noInvoiceNumber: { id: `${prefix}noInvoiceNumber` },\n})\n\n```"
}
] |
code_pharma-orders-admin_927105d2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/style/Alert.global.css from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n.success-container {\n max-width: 1200px;\n margin: 20px auto;\n}\n\n.error-container {\n max-width: 1200px;\n margin: 20px auto;\n max-height: 8rem;\n overflow-y: scroll;\n scroll-behavior: smooth;\n}\n\n.error-container::-webkit-scrollbar {\n display: none;\n}\n\n```"
}
] |
code_pharma-orders-admin_b829185b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/style/ImagePreview.global.css from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n.magnifier-image {\n display: block;\n}\n\n.magnifier {\n width: inherit !important;\n}\n\n.wrapMagnifier {\n display: flex;\n justify-content: center;\n}\n\n```"
}
] |
code_pharma-orders-admin_38c27081
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/style/Loading.global.css from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n.loading-container {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n}\n\n```"
}
] |
code_pharma-orders-admin_0071c8c1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/components/SuccessMessage.tsx from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport '../style/Alert.global.css'\n\nimport React from 'react'\nimport { Alert } from 'vtex.styleguide'\n\nexport default function SuccessMessage({ message, onClose }: SuccessComponent) {\n return (\n <div className=\"success-container\">\n <Alert type=\"success\" onClose={onClose}>\n {message}\n </Alert>\n </div>\n )\n}\n\nexport function SuccessArrayMessage({\n messages,\n onClose,\n}: SuccessArrayComponent) {\n return (\n <div className=\"success-container\">\n <Alert type=\"success\" onClose={onClose}>\n <div>\n {messages.map((message: string, index: number) => (\n <p className=\"ma0\" key={index}>\n {message}\n </p>\n ))}\n </div>\n </Alert>\n </div>\n )\n}\n\n```"
}
] |
code_pharma-orders-admin_8b0c2f79
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/components/ErrorMessage.tsx from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport '../style/Alert.global.css'\n\nimport React from 'react'\nimport { Alert } from 'vtex.styleguide'\n\nexport function ErrorMessage({ message, onClose }: ErrorComponent) {\n return (\n <div className=\"error-container\">\n <Alert type=\"error\" onClose={onClose}>\n {message}\n </Alert>\n </div>\n )\n}\n\nexport function ErrorArrayMessage({ messages, onClose }: ErrorArrayComponent) {\n return (\n <div className=\"error-container\">\n <Alert type=\"error\" onClose={onClose}>\n <div>\n {messages.map((message: string, index: number) => (\n <p className=\"ma0\" key={index}>\n {message}\n </p>\n ))}\n </div>\n </Alert>\n </div>\n )\n}\n\n```"
}
] |
code_pharma-orders-admin_29c9f719
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/components/ProductsTable.tsx from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { EXPERIMENTAL_Table as Table } from 'vtex.styleguide'\nimport useTableMeasures from '@vtex/styleguide/lib/EXPERIMENTAL_Table/hooks/useTableMeasures'\nimport { useQuery } from 'react-apollo'\nimport { useIntl } from 'react-intl'\n\nimport getOrderItems from '../graphql/getOrderItems.gql'\nimport LoadingSpinner from './LoadingSpinner'\nimport { titlesIntl } from '../utils/intl'\n\nexport default function ProductsTable({ orderId }: ProductTableProps) {\n const intl = useIntl()\n\n const responseFromGetOrder = useQuery(getOrderItems, {\n variables: { orderId },\n ssr: false,\n })\n\n const items = responseFromGetOrder?.data?.getOrder?.data?.items\n\n const columns = [\n {\n id: 'productId',\n title: intl.formatMessage(titlesIntl.productTableProductId),\n },\n {\n id: 'quantity',\n title: intl.formatMessage(titlesIntl.productTableQuantity),\n },\n {\n id: 'name',\n title: intl.formatMessage(titlesIntl.productTableName),\n },\n ]\n\n const measures = useTableMeasures({ size: items?.length })\n\n return (\n <div className=\"mt7\">\n {!items && <LoadingSpinner />}\n {items && (\n <Table\n measures={measures}\n items={items}\n columns={columns}\n highlightOnHover\n />\n )}\n </div>\n )\n}\n\n```"
}
] |
code_pharma-orders-admin_6a6938a8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/components/FilesColumn.tsx from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useState } from 'react'\nimport { useQuery } from 'react-apollo'\nimport { ButtonWithIcon, Modal, Tag } from 'vtex.styleguide'\nimport Image from '@vtex/styleguide/lib/icon/Image'\nimport { useIntl } from 'react-intl'\n\nimport { titlesIntl } from '../utils/intl'\nimport getOrderCustomData from '../graphql/getOrderCustomData.gql'\nimport ImagePreview from './ImagePreview'\n\nexport default function FilesTable({ orderId }: ProductTableProps) {\n const intl = useIntl()\n\n const responseFromGetOrder = useQuery(getOrderCustomData, {\n variables: { orderId },\n ssr: false,\n })\n\n const customApps =\n responseFromGetOrder?.data?.getOrder?.data?.customData?.customApps\n\n const files = customApps?.find((app: any) => app.id === 'uploadfiles')?.fields\n .data\n\n const filesObject = files && JSON.parse(files.replace(/'/g, '\"'))\n\n const [isImagenPreviewModalOpen, setIsImagenPreviewModalOpen] =\n useState(false)\n\n const [fileUrlPreview, setfileUrlPreview] = useState('')\n\n const handleModalImagenPreviewToggle = () => {\n setIsImagenPreviewModalOpen(!isImagenPreviewModalOpen)\n }\n\n function handleOnClick(url: string) {\n setfileUrlPreview(url)\n handleModalImagenPreviewToggle()\n }\n\n const icon = <Image />\n const withoutPrescription = intl.formatMessage(titlesIntl.withoutPrescription)\n\n return (\n <div>\n {(!filesObject || filesObject.length === 0) && (\n <Tag color=\"#134CD8\" variation=\"low\">\n {withoutPrescription}\n </Tag>\n )}\n {filesObject && (\n <div>\n {filesObject.map((file: any, index: number) => (\n <span className=\"mr3\" key={`${file.name} ${index}`}>\n <ButtonWithIcon\n icon={icon}\n variation=\"secondary\"\n size=\"small\"\n onClick={() => handleOnClick(file.url)}\n >\n {`${intl.formatMessage(titlesIntl.prescription)} ${index + 1}`}\n </ButtonWithIcon>\n </span>\n ))}\n </div>\n )}\n <Modal\n centered\n isOpen={isImagenPreviewModalOpen}\n onClose={handleModalImagenPreviewToggle}\n >\n <ImagePreview url={fileUrlPreview} />\n </Modal>\n </div>\n )\n}\n\n```"
}
] |
code_pharma-orders-admin_aba139a9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/components/ImagePreview.tsx from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React from 'react'\nimport Magnifier from 'react-magnifier'\nimport '../style/ImagePreview.global.css'\n\nexport default function ImagePreview({ url }: ImagePreviewProps) {\n return (\n <div className=\"wrapMagnifier\">\n <Magnifier src={url} />\n </div>\n )\n}\n\n```"
}
] |
code_pharma-orders-admin_eab8c58d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/components/LoadingSpinner.tsx from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { Spinner } from 'vtex.styleguide'\nimport React from 'react'\nimport '../style/Loading.global.css'\n\nexport default function LoadingSpinner() {\n return (\n <div className=\"loading-container\">\n <Spinner />\n </div>\n )\n}\n\n```"
}
] |
code_pharma-orders-admin_f0eff6bc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/components/OrdersTable.tsx from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable react/jsx-handler-names */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n EXPERIMENTAL_Table as Table,\n Checkbox,\n Input,\n Button,\n Modal,\n Tag,\n} from 'vtex.styleguide'\nimport useTableMeasures from '@vtex/styleguide/lib/EXPERIMENTAL_Table/hooks/useTableMeasures'\nimport useCheckboxTree from '@vtex/styleguide/lib/EXPERIMENTAL_useCheckboxTree/index'\nimport React, { useState, useEffect, useCallback } from 'react'\nimport { useIntl } from 'react-intl'\nimport { useMutation, useQuery } from 'react-apollo'\n\nimport { titlesIntl } from '../utils/intl'\nimport ProductsTable from './ProductsTable'\nimport FilesColumn from './FilesColumn'\nimport { ErrorArrayMessage } from './ErrorMessage'\nimport { SuccessArrayMessage } from './SuccessMessage'\nimport LoadingSpinner from './LoadingSpinner'\nimport cancelOrder from '../graphql/cancelOrder.gql'\nimport updateDocument from '../graphql/updateDocument.gql'\nimport getPaymentTransaction from '../graphql/getPaymentTransaction.gql'\nimport paymentNotification from '../graphql/paymentNotification.gql'\nimport startHandlingOrder from '../graphql/startHandlingOrder.gql'\nimport invoiceOrder from '../graphql/invoiceOrder.gql'\nimport getOrderStatus from '../graphql/getOrderStatus.gql'\nimport getOrderDataToInvoice from '../graphql/getOrderDataToInvoice.gql'\n\nexport default function OrdersTable({ orderList }: TableProps) {\n const intl = useIntl()\n const [items, setItems] = useState(orderList)\n const [cancelOrderMutation] = useMutation(cancelOrder)\n const [updateDocumentMutation] = useMutation(updateDocument)\n const getPaymentTransactionQuery = useQuery(getPaymentTransaction)\n const [paymentNotificationMutation] = useMutation(paymentNotification)\n const [startHandlingOrderMutation] = useMutation(startHandlingOrder)\n const [invoiceOrderMutation] = useMutation(invoiceOrder)\n const getOrderStatusQuery = useQuery(getOrderStatus)\n const getOrderDataToInvoiceQuery = useQuery(getOrderDataToInvoice)\n\n // const [error, setError] = useState(false)\n const [errorArray, setErrorArray] = useState(false)\n // const [success, setSuccess] = useState(false)\n const [successArray, setSuccessArray] = useState(false)\n const [loading, setLoading] = useState(false)\n // const [message, setMessage] = useState('')\n const [messageArraySuccess, setMessageArraySuccess] = useState<string[]>([])\n const [messageArrayError, setMessageArrayError] = useState<string[]>([])\n const [textInvoice, setTextInvoice] = useState('')\n\n const clearAlerts = useCallback(() => {\n // setError(false)\n setErrorArray(false)\n // setSuccess(false)\n setSuccessArray(false)\n setLoading(false)\n // setMessage('')\n setMessageArraySuccess([])\n setMessageArrayError([])\n }, [])\n\n const loadingAlert = useCallback(() => {\n // setError(false)\n setErrorArray(false)\n // setSuccess(false)\n setSuccessArray(false)\n setLoading(true)\n // setMessage('')\n setMessageArraySuccess([])\n setMessageArrayError([])\n }, [])\n\n const canceled = intl.formatMessage(titlesIntl.canceled)\n const created = intl.formatMessage(titlesIntl.created)\n const approved = intl.formatMessage(titlesIntl.approved)\n const confirmed = intl.formatMessage(titlesIntl.confirmed)\n\n const columns = [\n {\n id: 'status',\n title: intl.formatMessage(titlesIntl.ordersTableStatus),\n cellRenderer: ({ data }: any) => {\n let tag\n\n switch (data) {\n case 'canceled':\n tag = <Tag bgColor=\"#F71963\">{canceled}</Tag>\n break\n\n case 'created':\n tag = <Tag bgColor=\"#E67E22\">{created}</Tag>\n break\n\n case 'approved':\n tag = <Tag bgColor=\"#7D3C98\">{approved}</Tag>\n break\n\n case 'confirmed':\n tag = <Tag bgColor=\"#16A085\">{confirmed}</Tag>\n break\n\n default:\n break\n }\n\n return <div>{tag}</div>\n },\n },\n {\n id: 'orderId',\n title: intl.formatMessage(titlesIntl.ordersTableOrderId),\n },\n {\n id: 'products',\n title: intl.formatMessage(titlesIntl.ordersTableProducts),\n cellRenderer: ({ data }: any) => {\n return (\n <div>\n <Button\n variation=\"secondary\"\n size=\"small\"\n onClick={() => handleModalProductsToggle(data)}\n >\n {intl.formatMessage(titlesIntl.buttonShowProducts)}\n </Button>\n </div>\n )\n },\n },\n {\n id: 'files',\n title: intl.formatMessage(titlesIntl.ordersTableFiles),\n cellRenderer: ({ data }: any) => {\n return <FilesColumn orderId={data} />\n },\n },\n {\n id: 'invoice',\n title: intl.formatMessage(titlesIntl.invoiceNumber),\n cellRenderer: ({ data }: any) => {\n const itemIsChecked = (item: any) =>\n item.id === data.rowId && item.status === 'approved'\n\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n const checked = checkboxes.checkedItems.some(itemIsChecked)\n const errorCondition = !textInvoice && checked\n\n return (\n <Input\n defaultValue={data.invoiceNumber}\n onChange={(e: any) => {\n const tempItems = items\n\n tempItems[data.rowId].invoice = {\n rowId: data.rowId,\n invoiceNumber: e.target.value,\n }\n setTextInvoice(e.target.value)\n setItems(tempItems)\n }}\n /*\n placeholder={intl.formatMessage(\n titlesIntl.placeholderInvoiceNumber\n )}\n */\n disabled={!checked}\n error={errorCondition}\n errorMessage={\n errorCondition &&\n intl.formatMessage(titlesIntl.placeholderInvoiceNumber)\n }\n />\n )\n },\n },\n ]\n\n const [isProductModalOpen, setIsProductModalOpen] = useState(false)\n\n const [orderIdToModal, setOrderIdToModal] = useState()\n\n const handleModalProductsToggle = (orderId: any) => {\n setOrderIdToModal(orderId)\n setIsProductModalOpen(!isProductModalOpen)\n }\n\n const [withCheckboxes, isRowActive, checkboxes] = useColumnsWithCheckboxes({\n columns,\n items,\n })\n\n const approveAction = {\n label: intl.formatMessage(titlesIntl.approve),\n onClick: () => handleApproveAction(checkboxes.checkedItems),\n }\n\n const confirmAction = {\n label: intl.formatMessage(titlesIntl.confirm),\n onClick: () => handleConfirmAction(checkboxes.checkedItems),\n }\n\n const cancelAction = {\n label: intl.formatMessage(titlesIntl.cancel),\n onClick: () => handleCancelAction(checkboxes.checkedItems),\n }\n\n async function handleApproveAction(selectedRows: any) {\n loadingAlert()\n const tempItems = items\n const successArrayTemp: string[] = []\n const errorArrayTemp: string[] = []\n\n for await (const row of selectedRows) {\n console.info('row', row)\n if (row.id === 'VTEX_CheckboxTreeRoot') {\n continue\n }\n\n if (row.status === 'created') {\n /*\n const dataFromUpdateDocumentMutation = await cancelOrderMutation({\n variables: {\n orderId: row.orderId,\n },\n })\n\n const { status } = dataFromUpdateDocumentMutation.data.cancelOrder\n */\n const statusFromSendNotification = 200\n\n if (statusFromSendNotification === 200) {\n const bodyToMasterData: BodyUpdateDocument = {\n orderId: row.orderId,\n status: 'approved',\n invoiceNumber: '',\n }\n\n const dataFromUpdateDocumentMutation = await updateDocumentMutation({\n variables: {\n documentId: row.idMasterData,\n body: bodyToMasterData,\n },\n })\n\n const { status: statusUpdateDocument } =\n dataFromUpdateDocumentMutation.data.updateDocument\n\n if (statusUpdateDocument === 200) {\n tempItems[row.id].status = 'approved'\n successArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.wasApproved)}`\n )\n } else {\n // aca habria que ver algo como intentar de actualizar el documento mas adelante\n errorArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.wasNotApproved)}`\n )\n }\n } else {\n errorArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.wasNotApproved)}`\n )\n }\n } else if (row.status === 'approved' || row.status === 'confirmed') {\n errorArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.wasAlreadyApproved)}`\n )\n } else {\n errorArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.isCanceled)}`\n )\n }\n }\n\n if (tempItems.length > 0) {\n setItems(tempItems)\n }\n\n if (successArrayTemp.length > 0) {\n setSuccessArray(true)\n setMessageArraySuccess(successArrayTemp)\n }\n\n if (errorArrayTemp.length > 0) {\n setErrorArray(true)\n setMessageArrayError(errorArrayTemp)\n }\n\n setLoading(false)\n }\n\n async function consult(orderId: string): Promise<any> {\n const dataFromGetOrderStatusQuery = await getOrderStatusQuery.refetch({\n orderId,\n })\n\n console.info('dataFromGetOrderStatusQuery', dataFromGetOrderStatusQuery)\n const statusOfOrder =\n dataFromGetOrderStatusQuery.data.getOrderStatus.data.status\n\n console.info('statusOfOrder inside', statusOfOrder)\n\n if (statusOfOrder === 'ready-for-handling') {\n return true\n }\n\n const awaitTimeout = (delay: number) =>\n new Promise((resolve) => setTimeout(resolve, delay * 1000))\n\n await awaitTimeout(2)\n\n return validarReintento(orderId)\n }\n\n async function validarReintento(orderId: string) {\n const response = await consult(orderId)\n\n return response\n }\n\n async function handleConfirmAction(selectedRows: any) {\n loadingAlert()\n const tempItems = items\n const successArrayTemp: string[] = []\n const errorArrayTemp: string[] = []\n\n for await (const row of selectedRows) {\n console.info('row', row)\n if (row.id === 'VTEX_CheckboxTreeRoot') {\n continue\n }\n\n if (row.status === 'approved') {\n const { invoiceNumber } = row.invoice\n\n if (invoiceNumber) {\n const dataFromGetPaymentTransactionQuery =\n await getPaymentTransactionQuery.refetch({\n orderId: row.orderId,\n })\n\n const { status: statusPaymentTransaction } =\n dataFromGetPaymentTransactionQuery.data.getPaymentTransaction\n\n if (statusPaymentTransaction === 200) {\n const { payments } =\n dataFromGetPaymentTransactionQuery.data.getPaymentTransaction.data\n\n const promiseInfo = payments.find(\n (p: any) => p.paymentSystemName === 'Promissory'\n )\n\n const paymentId = promiseInfo.id\n\n const dataFromPaymentNotificationMutation =\n await paymentNotificationMutation({\n variables: {\n orderId: row.orderId,\n paymentId,\n },\n })\n\n const { status: statusPaymentNotification } =\n dataFromPaymentNotificationMutation.data.paymentNotification\n\n if (await validarReintento(row.orderId)) {\n console.info('ok')\n if (statusPaymentNotification === 204) {\n console.info('statusPaymentNotification === 204')\n const dataFromStartHandlingOrderMutation =\n await startHandlingOrderMutation({\n variables: {\n orderId: row.orderId,\n },\n })\n\n console.info(\n 'dataFromStartHandlingOrderMutation',\n dataFromStartHandlingOrderMutation\n )\n const { status: statusStartHandlingOrder } =\n dataFromStartHandlingOrderMutation.data.startHandlingOrder\n\n console.info(\n 'statusStartHandlingOrder',\n statusStartHandlingOrder\n )\n\n const dataFromGetOrderStatusQuery =\n await getOrderStatusQuery.refetch({\n orderId: row.orderId,\n })\n\n console.info(\n 'dataFromGetOrderStatusQuery',\n dataFromGetOrderStatusQuery\n )\n const { status: statusOfOrder } =\n dataFromGetOrderStatusQuery.data.getOrderStatus.data\n\n console.info('statusOfOrder', statusOfOrder)\n\n if (\n statusStartHandlingOrder === 200 &&\n statusOfOrder === 'handling'\n ) {\n // Order invoice notification\n const issuanceDate = new Date(Date.now()).toISOString()\n\n console.info('datetime', issuanceDate)\n\n const dataFromGetOrderDataToInvoiceQuery =\n await getOrderDataToInvoiceQuery.refetch({\n orderId: row.orderId,\n })\n\n console.info(\n 'dataFromGetOrderDataToInvoiceQuery',\n dataFromGetOrderDataToInvoiceQuery\n )\n\n const { status: statusOfGetOrderDataToInvoice } =\n dataFromGetOrderDataToInvoiceQuery.data.getOrder\n\n if (statusOfGetOrderDataToInvoice === 200) {\n const { value: invoiceValue, items: itemsToInvoice } =\n dataFromGetOrderDataToInvoiceQuery.data.getOrder.data\n\n const itemsToInvoiceBody = itemsToInvoice.map(\n (item: any) => {\n const itemAux = {\n id: item.id,\n quantity: item.quantity,\n price: item.price,\n }\n\n return itemAux\n }\n )\n\n console.info('issuanceDate', issuanceDate)\n console.info('invoiceNumber', invoiceNumber)\n console.info('invoiceValue', invoiceValue)\n console.info('itemsToInvoiceBody', itemsToInvoiceBody)\n const bodyInvoice: InvoiceBody = {\n type: 'Output',\n issuanceDate,\n invoiceNumber,\n invoiceValue,\n items: itemsToInvoiceBody,\n }\n\n console.info('invoiceBody', bodyInvoice)\n const dataFromInvoiceOrderMutation =\n await invoiceOrderMutation({\n variables: {\n orderId: row.orderId,\n bodyInvoice,\n },\n })\n\n const { status: statusInvoiceOrder } =\n dataFromInvoiceOrderMutation.data.invoiceOrder\n\n console.info('statusInvoiceOrder', statusInvoiceOrder)\n\n const bodyToMasterData: BodyUpdateDocument = {\n orderId: row.orderId,\n status: 'confirmed',\n invoiceNumber,\n }\n\n const dataFromUpdateDocumentMutation =\n await updateDocumentMutation({\n variables: {\n documentId: row.idMasterData,\n body: bodyToMasterData,\n },\n })\n\n const { status: statusUpdateDocument } =\n dataFromUpdateDocumentMutation.data.updateDocument\n\n if (statusUpdateDocument === 200) {\n tempItems[row.id].status = 'confirmed'\n successArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.wasConfirmed)}`\n )\n } else {\n // aca habria que ver algo como intentar de actualizar el documento mas adelante\n errorArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.wasNotConfirmed)}`\n )\n }\n } else {\n errorArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.wasNotConfirmed)}`\n )\n }\n } else {\n errorArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.wasNotConfirmed)}`\n )\n }\n } else {\n errorArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.wasNotConfirmed)}`\n )\n }\n }\n } else {\n errorArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.wasNotConfirmed)}`\n )\n }\n } else {\n errorArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(\n titlesIntl.wasNotConfirmed\n )} ${intl.formatMessage(titlesIntl.noInvoiceNumber)}`\n )\n }\n } else if (row.status === 'confirmed') {\n errorArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.wasAlreadyConfirmed)}`\n )\n } else if (row.status === 'created') {\n errorArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.approvedBeforeConfirming)}`\n )\n } else {\n errorArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.isCanceled)}`\n )\n }\n }\n\n if (tempItems.length > 0) {\n setItems(tempItems)\n }\n\n if (successArrayTemp.length > 0) {\n setSuccessArray(true)\n setMessageArraySuccess(successArrayTemp)\n }\n\n if (errorArrayTemp.length > 0) {\n setErrorArray(true)\n setMessageArrayError(errorArrayTemp)\n }\n\n setLoading(false)\n }\n\n async function handleCancelAction(selectedRows: any) {\n loadingAlert()\n const tempItems = items\n const successArrayTemp: string[] = []\n const errorArrayTemp: string[] = []\n\n for await (const row of selectedRows) {\n if (row.id === 'VTEX_CheckboxTreeRoot') {\n continue\n }\n\n console.info('row', row)\n if (row.status === 'confirmed') {\n errorArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.isConfirmed)}`\n )\n } else if (row.status !== 'canceled') {\n const dataFromUpdateDocumentMutation = await cancelOrderMutation({\n variables: {\n orderId: row.orderId,\n },\n })\n\n const { status } = dataFromUpdateDocumentMutation.data.cancelOrder\n\n if (status === 200) {\n tempItems[row.id].status = 'canceled'\n successArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.wasCanceled)}`\n )\n } else {\n errorArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.wasNotCanceled)}`\n )\n }\n } else {\n errorArrayTemp.push(\n `${intl.formatMessage(titlesIntl.theOrder)} ${\n row.orderId\n } ${intl.formatMessage(titlesIntl.wasAlreadyCanceled)}`\n )\n }\n }\n\n if (tempItems.length > 0) {\n setItems(tempItems)\n }\n\n if (successArrayTemp.length > 0) {\n setSuccessArray(true)\n setMessageArraySuccess(successArrayTemp)\n }\n\n if (errorArrayTemp.length > 0) {\n setErrorArray(true)\n setMessageArrayError(errorArrayTemp)\n }\n\n setLoading(false)\n }\n\n const [filteredItems, setFilteredItems] = useState(items)\n const [filterStatements, setFilterStatements] = useState([])\n\n const ITEMS_PER_PAGE = 5\n\n const { slicedItems, ...paginationProps } = usePagination(\n ITEMS_PER_PAGE,\n filteredItems\n )\n\n const listOfRowsOptions: number[] = [5]\n\n if (filteredItems.length >= 5) {\n listOfRowsOptions.push(10)\n if (filteredItems.length >= 10) {\n listOfRowsOptions.push(15)\n }\n }\n\n const pagination = {\n ...paginationProps,\n textOf: intl.formatMessage(titlesIntl.textOf),\n rowsOptions: listOfRowsOptions,\n textShowRows: intl.formatMessage(titlesIntl.textShowRows),\n totalItems: filteredItems.length,\n }\n\n const measures = useTableMeasures({\n size:\n pagination.totalItems < pagination.tableSize\n ? pagination.totalItems\n : pagination.tableSize,\n density: 'comfortable',\n })\n\n function handleFiltersChange(statements = []) {\n let newData = items.slice()\n\n statements.forEach((st: any) => {\n if (!st || !st.object) return\n const { subject, verb, object } = st\n\n switch (subject) {\n case 'orderId':\n if (verb === 'contains') {\n newData = newData.filter((item: any) => {\n return item[subject].includes(object)\n })\n } else if (verb === '=') {\n newData = newData.filter((item: any) => item[subject] === object)\n } else if (verb === '!=') {\n newData = newData.filter((item: any) => item[subject] !== object)\n }\n\n break\n\n case 'status':\n if (!object) return\n // eslint-disable-next-line no-case-declarations\n const selectedStatus = Object.keys(object).reduce(\n (acc: any, item: any) => (object[item] ? [...acc, item] : acc),\n []\n )\n\n newData = newData.filter((item: any) => {\n let status\n\n switch (item[subject]) {\n case 'canceled':\n status = canceled\n break\n\n case 'created':\n status = created\n break\n\n case 'approved':\n status = approved\n break\n\n case 'confirmed':\n status = confirmed\n break\n\n default:\n break\n }\n\n return selectedStatus.includes(status)\n })\n break\n\n default:\n break\n }\n })\n setFilteredItems(newData)\n setFilterStatements(statements)\n }\n\n const filterClear = intl.formatMessage(titlesIntl.filterClear)\n const filterAll = intl.formatMessage(titlesIntl.filterAll)\n const filterNone = intl.formatMessage(titlesIntl.filterNone)\n const filterAny = intl.formatMessage(titlesIntl.filterAny)\n const filterIs = intl.formatMessage(titlesIntl.filterIs)\n const filterIsNot = intl.formatMessage(titlesIntl.filterIsNot)\n const filterContains = intl.formatMessage(titlesIntl.filterContains)\n const filterApply = intl.formatMessage(titlesIntl.filterApply)\n\n const filters = {\n alwaysVisibleFilters: ['status', 'orderId'],\n statements: filterStatements,\n onChangeStatements: handleFiltersChange,\n clearAllFiltersButtonLabel: filterClear,\n collapseLeft: true,\n submitFilterLabel: filterApply,\n options: {\n status: {\n label: intl.formatMessage(titlesIntl.ordersTableStatus),\n renderFilterLabel: (st: any) => {\n if (!st || !st.object) {\n return filterAll\n }\n\n const keys: any = st.object ? Object.keys(st.object) : {}\n const isAllTrue = !keys.some((key: any) => !st.object[key])\n const isAllFalse = !keys.some((key: any) => st.object[key])\n const trueKeys = keys.filter((key: any) => st.object[key])\n let trueKeysLabel = ''\n\n trueKeys.forEach((key: any, index: any) => {\n trueKeysLabel += `${key}${\n index === trueKeys.length - 1 ? '' : ', '\n }`\n })\n\n const labelsArray = trueKeysLabel\n .split(',')\n .map((item: any) => item.trim())\n\n return `${\n isAllTrue ? filterAll : isAllFalse ? filterNone : `${labelsArray}`\n }`\n },\n verbs: [\n {\n value: 'includes',\n object: {\n renderFn: statusSelectorObject,\n extraParams: {},\n },\n },\n ],\n },\n orderId: {\n label: intl.formatMessage(titlesIntl.ordersTableOrderId),\n ...simpleInputVerbsAndLabel(),\n },\n },\n }\n\n function simpleInputObject({ values, onChangeObjectCallback }: any) {\n return (\n <Input\n value={values || ''}\n onChange={(e: any) => onChangeObjectCallback(e.target.value)}\n />\n )\n }\n\n function simpleInputVerbsAndLabel() {\n return {\n renderFilterLabel: (st: any) => {\n if (!st || !st.object) {\n // you should treat empty object cases only for alwaysVisibleFilters\n return filterAny\n }\n\n return `${\n st.verb === '='\n ? filterIs\n : st.verb === '!='\n ? filterIsNot\n : filterContains\n } ${st.object}`\n },\n verbs: [\n {\n label: filterIs,\n value: '=',\n object: {\n renderFn: simpleInputObject,\n extraParams: {},\n },\n },\n {\n label: filterIsNot,\n value: '!=',\n object: {\n renderFn: simpleInputObject,\n extraParams: {},\n },\n },\n {\n label: filterContains,\n value: 'contains',\n object: {\n renderFn: simpleInputObject,\n extraParams: {},\n },\n },\n ],\n }\n }\n\n function statusSelectorObject({ values, onChangeObjectCallback }: any) {\n const initialValue = {\n [created]: true,\n [approved]: true,\n [confirmed]: true,\n [canceled]: true,\n ...(values || {}),\n }\n\n const toggleValueByKey = (key: any) => {\n const newValues = {\n ...(values || initialValue),\n [key]: values ? !values[key] : false,\n }\n\n return newValues\n }\n\n return (\n <div>\n {Object.keys(initialValue).map((opt, index) => {\n return (\n <div className=\"mb3\" key={`class-statment-object-${opt}-${index}`}>\n <Checkbox\n checked={values ? values[opt] : initialValue[opt]}\n label={opt}\n name=\"default-checkbox-group\"\n onChange={() => {\n const newValue = toggleValueByKey(`${opt}`)\n const newValueKeys = Object.keys(newValue)\n const isEmptyFilter = !newValueKeys.some(\n (key) => !newValue[key]\n )\n\n onChangeObjectCallback(isEmptyFilter ? null : newValue)\n }}\n value={opt}\n />\n </div>\n )\n })}\n </div>\n )\n }\n\n return (\n <div>\n <div className=\"messagesOrderTable\">\n {loading && <LoadingSpinner />}\n {successArray && (\n <SuccessArrayMessage\n onClose={clearAlerts}\n messages={messageArraySuccess}\n />\n )}\n {errorArray && (\n <ErrorArrayMessage\n onClose={clearAlerts}\n messages={messageArrayError}\n />\n )}\n </div>\n <Table\n measures={measures}\n columns={withCheckboxes}\n items={slicedItems}\n isRowActive={isRowActive}\n >\n <Table.Bulk active={checkboxes.someChecked}>\n <Table.Bulk.Actions>\n <Table.Bulk.Actions.Primary {...approveAction} />\n <Table.Bulk.Actions.Primary {...confirmAction} />\n <Table.Bulk.Actions.Primary {...cancelAction} />\n </Table.Bulk.Actions>\n <Table.Bulk.Tail>\n {!checkboxes.allChecked && (\n <Table.Bulk.Tail.Info>\n {intl.formatMessage(titlesIntl.selectedOrders)}{' '}\n {checkboxes.checkedItems?.length}\n </Table.Bulk.Tail.Info>\n )}\n <Table.Bulk.Tail.Toggle\n button={{\n text: intl.formatMessage(titlesIntl.selectAllOrders),\n onClick: checkboxes.checkAll,\n }}\n active={checkboxes.allChecked}\n >\n {intl.formatMessage(titlesIntl.selectedOrders)} {items.length}\n </Table.Bulk.Tail.Toggle>\n <Table.Bulk.Tail.Dismiss onClick={checkboxes.uncheckAll} />\n </Table.Bulk.Tail>\n </Table.Bulk>\n <Table.FilterBar {...filters} />\n <Table.Pagination {...pagination} />\n </Table>\n <Modal\n centered\n isOpen={isProductModalOpen}\n onClose={() => handleModalProductsToggle(null)}\n >\n <ProductsTable orderId={orderIdToModal} />\n </Modal>\n </div>\n )\n}\n\nfunction useColumnsWithCheckboxes({ columns, items }: any) {\n const checkboxes = useCheckboxTree({\n items,\n })\n\n const mappedCheckboxes = checkboxes.itemTree.children.map(\n (item: { id: any }) => {\n const id = `${item.id}`\n\n return (\n <Checkbox\n key={id}\n id={id}\n checked={checkboxes.isChecked(item)}\n partial={checkboxes.isPartiallyChecked(item)}\n disabled={checkboxes.isDisabled(item)}\n onChange={() => checkboxes.toggle(item)}\n />\n )\n }\n )\n\n const withCheckboxes = [\n {\n id: 'checkbox',\n title: (\n <Checkbox\n id={`${checkboxes.itemTree.id}`}\n checked={checkboxes.allChecked}\n partial={checkboxes.someChecked}\n onChange={checkboxes.toggleAll}\n />\n ),\n width: 32,\n extended: true,\n cellRenderer: ({ data }: any) => {\n return <div>{mappedCheckboxes[data.id]}</div>\n },\n },\n ...columns,\n ]\n\n return [withCheckboxes, (data: any) => checkboxes.isChecked(data), checkboxes]\n}\n\nfunction usePagination(initialSize: number, itemsToPaginate: any) {\n const [state, setState] = useState({\n tableSize: initialSize,\n currentPage: 1,\n currentItemFrom: 1,\n currentItemTo: initialSize,\n slicedItems: [...itemsToPaginate].slice(0, initialSize),\n })\n\n /** resets state on items change */\n useEffect(() => {\n setState({\n tableSize: initialSize,\n currentPage: 1,\n currentItemFrom: 1,\n currentItemTo: initialSize,\n slicedItems: [...itemsToPaginate].slice(0, initialSize),\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [itemsToPaginate])\n\n /** gets the next page */\n const onNextClick = useCallback(() => {\n const newPage = state.currentPage + 1\n const itemFrom = state.currentItemTo + 1\n const itemTo = state.tableSize * newPage\n const newItems = [...itemsToPaginate].slice(itemFrom - 1, itemTo)\n\n setState({\n ...state,\n currentPage: newPage,\n currentItemFrom: itemFrom,\n currentItemTo: itemTo,\n slicedItems: newItems,\n })\n }, [state, itemsToPaginate])\n\n /** gets the previous page */\n const onPrevClick = useCallback(() => {\n if (state.currentPage === 0) return\n const newPage = state.currentPage - 1\n const itemFrom = state.currentItemFrom - state.tableSize\n const itemTo = state.currentItemFrom - 1\n const newItems = [...itemsToPaginate].slice(itemFrom - 1, itemTo)\n\n setState({\n ...state,\n currentPage: newPage,\n currentItemFrom: itemFrom,\n currentItemTo: itemTo,\n slicedItems: newItems,\n })\n }, [state, itemsToPaginate])\n\n /** deals rows change of Pagination component */\n const onRowsChange = useCallback(\n (_, value) => {\n const rowValue = parseInt(value, 10)\n\n setState({\n ...state,\n tableSize: rowValue,\n currentItemTo: rowValue,\n slicedItems: [...itemsToPaginate].slice(\n state.currentItemFrom - 1,\n rowValue\n ),\n })\n },\n [state, itemsToPaginate]\n )\n\n return {\n onNextClick,\n onPrevClick,\n onRowsChange,\n ...state,\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_9447d286
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/graphql/invoiceOrder.gql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation invoiceOrder($orderId: String, $bodyInvoice: BodyInvoiceOrder) {\n invoiceOrder(orderId: $orderId, bodyInvoice: $bodyInvoice) {\n status\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_c6b00cd5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/graphql/updateDocument.gql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation updateDocument(\n $documentId: String\n $body: BodyUpdateDocumentMasterData\n) {\n updateDocument(documentId: $documentId, body: $body) {\n status\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_56f1baa0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/graphql/startHandlingOrder.gql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation startHandlingOrder($orderId: String) {\n startHandlingOrder(orderId: $orderId) {\n status\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_7289f49f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/graphql/paymentNotification.gql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation paymentNotification($orderId: String, $paymentId: String) {\n paymentNotification(orderId: $orderId, paymentId: $paymentId) {\n status\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_bd13a0b6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/graphql/getOrderStatus.gql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery getOrderStatus($orderId: String) {\n getOrderStatus(orderId: $orderId) {\n status\n data {\n status\n }\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_9af62172
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/graphql/getPaymentTransaction.gql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery getPaymentTransaction($orderId: String) {\n getPaymentTransaction(orderId: $orderId) {\n status\n data {\n status\n isActive\n transactionId\n merchantName\n payments {\n id\n paymentSystem\n paymentSystemName\n value\n }\n }\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_2eaac9e1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/graphql/getOrderCustomData.gql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery getOrderCustomData($orderId: String) {\n getOrder(orderId: $orderId) {\n status\n data {\n customData {\n customApps {\n fields {\n data\n }\n id\n }\n }\n }\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_92de7f1a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/graphql/cancelOrder.gql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation cancelOrder($orderId: String) {\n cancelOrder(orderId: $orderId) {\n status\n data {\n date\n orderId\n receipt\n }\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_9efc833f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/graphql/getOrderItems.gql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery getOrderItems($orderId: String) {\n getOrder(orderId: $orderId) {\n status\n data {\n items {\n id\n productId\n quantity\n name\n }\n }\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_f3c3448b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/graphql/getData.gql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery getData {\n getData {\n status\n data {\n id\n orderId\n status\n invoiceNumber\n }\n }\n}\n\n```"
}
] |
code_pharma-orders-admin_b999c886
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pharma-orders-admin/react/graphql/getOrderDataToInvoice.gql from the pharma-orders-admin VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery getOrderDataToInvoice($orderId: String) {\n getOrder(orderId: $orderId) {\n status\n data {\n value\n items {\n id\n quantity\n price\n }\n }\n }\n}\n\n```"
}
] |
code_service-worker-example_ff5e364b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of service-worker-example/docs/README.md from the service-worker-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# Service Worker Example\n\nService Workers (SWs) are a poweful tool to handle network requests separate from a web page, as scripts running in the background. They are well known to handle push notifications and background syncronization.\n\nWith `service-worker` builder, we can allow an app to expose its own implementation of a Service Worker, enabling VTEX stores to use such Service Worker into their scope.\n\nService Workers allow us to introduce 6 different event handlers, which can be implemented inside the `service-workers/` folder:\n\n1. [activate](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/activate_event) → `activate.js`\n2. [fetch](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/onfetch) → `fetch.js`\n3. [install](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/install_event) → `install.js`\n4. [message](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/message_event) → `message.js`\n5. [push](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/push_event) → `push.js`\n6. [sync](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/onsync) → `sync.js`\n\nWhatever is outside those 6 files, should be implemented in `header.js`. The implementation result in the VTEX store DevTools should be as follows:\n\n\n\n\nEach function can be tested according to the behavior of each event handler. When triggering such event handler, the function body will be executed as follows:\n\n\n\n\nAn example is provided in this app for exploration purposes.\n\n```"
}
] |
code_service-worker-example_5768301d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of service-worker-example/service-workers/message.js from the service-worker-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nfunction exampleSWMessage() {\n // eslint-disable-next-line no-console\n console.log('[example-sw] Message of service worker')\n}\n\nexport default exampleSWMessage\n\n```"
}
] |
code_service-worker-example_59ee24af
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of service-worker-example/service-workers/sync.js from the service-worker-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nfunction exampleSWSync() {\n // eslint-disable-next-line no-console\n console.log('[example-sw] Sync of service worker')\n}\n\nexport default exampleSWSync\n\n```"
}
] |
code_service-worker-example_11dd4e4d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of service-worker-example/service-workers/fetch.js from the service-worker-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nfunction exampleSWFetch() {\n // eslint-disable-next-line no-console\n console.log('[example-sw] Fetch of service worker')\n}\n\nexport default exampleSWFetch\n\n```"
}
] |
code_service-worker-example_a3aee5db
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of service-worker-example/service-workers/header.js from the service-worker-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nfunction exampleSWHeader() {\n // eslint-disable-next-line no-console\n console.log('[example-sw] Header of service worker')\n}\n\nexport default exampleSWHeader\n\n```"
}
] |
code_service-worker-example_f15c307b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of service-worker-example/service-workers/install.js from the service-worker-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nfunction exampleSWInstall() {\n // eslint-disable-next-line no-console\n console.log('[example-sw] Install of service worker')\n}\n\nexport default exampleSWInstall\n\n```"
}
] |
code_service-worker-example_d292988e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of service-worker-example/service-workers/push.js from the service-worker-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nfunction exampleSWPush() {\n // eslint-disable-next-line no-console\n console.log('[example-sw] Push of service worker')\n}\n\nexport default exampleSWPush\n\n```"
}
] |
code_service-worker-example_dc37e4fa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of service-worker-example/service-workers/activate.js from the service-worker-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nfunction exampleSWActivate() {\n // eslint-disable-next-line no-console\n console.log('[example-sw] Activate of service worker')\n}\n\nexport default exampleSWActivate\n\n```"
}
] |
code_bluecore_8dc51147
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of bluecore/docs/README.md from the bluecore VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# Bluecore\n\nVTEX Bluecore first-party app\n\n## How to install\n\nOpen the VTEX App Store and install this app on your store.\n\nNow, open the app settings on your admin and fill in your Bluecore's Site ID.\n\n```"
}
] |
code_bluecore_741cb350
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of bluecore/react/index.tsx from the bluecore VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { canUseDOM } from 'vtex.render-runtime'\nimport { PixelMessage } from './typings/events'\n\nexport interface Order {\n visitorContactInfo: string[]\n transactionId: string\n transactionTotal: number,\n transactionProducts: ProductOrder[]\n}\n\ninterface ProductOrder {\n productRefId: string,\n}\n\nfunction addPixelImage(order: Order) {\n const token = window.__bluecore_site_id\n\n const email = order.visitorContactInfo[0]\n const total = order.transactionTotal\n const orderId = order.transactionId\n const productsIds = order.transactionProducts.map(({ productRefId }) => productRefId).join(',')\n\n const img = document.createElement('img')\n const url = `https://www.bluecore.com/api/track/purchase_pixel?token=${token}&email=${email}&total=${total}&order_id=${orderId}&product_ids=${productsIds}`\n\n img.setAttribute('id', 'bluecore_purchase_pixel')\n img.setAttribute('src', url)\n\n document.body.appendChild(img)\n}\n\nfunction handleMessages(e: PixelMessage) {\n switch (e.data.eventName) {\n case 'vtex:orderPlaced': {\n const order = e.data as Order\n addPixelImage(order)\n break\n }\n case \"vtex:addToCart\": {\n const { items } = e.data\n\n items.forEach(item => {\n try {\n window.triggermail.Partner.dataReady({\n event_type: \"add_to_cart\",\n id: item.productRefId\n })\n } catch (e) {\n console.error(e)\n }\n })\n return\n }\n case \"vtex:removeFromCart\": {\n const { items } = e.data\n\n items.forEach(item => {\n try {\n window.triggermail.Partner.dataReady({\n event_type: \"remove_from_cart\",\n id: item.productRefId\n });\n } catch (e) {\n console.error(e)\n }\n })\n break\n }\n default:\n break\n }\n}\n\nif (canUseDOM) {\n window.addEventListener('message', handleMessages)\n}\n\n```"
}
] |
code_bluecore_6ff19111
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of bluecore/react/package.json from the bluecore VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"devDependencies\": {\n \"@types/node\": \"^10.12.18\",\n \"@types/prop-types\": \"^15.5.6\",\n \"@types/ramda\": \"types/npm-ramda#dist\",\n \"@types/react\": \"^16.4.14\",\n \"eslint\": \"5\",\n \"eslint-config-vtex-react\": \"4\",\n \"prettier\": \"^1.18.2\",\n \"typescript\": \"3.5.2\"\n },\n \"version\": \"1.1.2\"\n}\n\n```"
}
] |
code_bluecore_5318e7eb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of bluecore/store/interfaces.json from the bluecore VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"pixel.bluecorePixel\": {\n \"component\": \"index\"\n }\n}\n\n```"
}
] |
code_bluecore_1b9178a5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of bluecore/react/typings/events.d.ts from the bluecore VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport interface PixelMessage extends MessageEvent {\n data: OrderPlacedData | AddToCartData | RemoveToCartData;\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 AddToCartData extends EventData {\n event: \"addToCart\";\n eventName: \"vtex:addToCart\";\n items: CartItem[];\n}\n\nexport interface RemoveToCartData extends EventData {\n event: \"removeFromCart\";\n eventName: \"vtex:removeFromCart\";\n items: CartItem[];\n}\n\nexport interface OrderPlacedData extends Order, EventData {\n event: \"orderPlaced\";\n eventName: \"vtex:orderPlaced\";\n}\n\ninterface CartItem {\n skuId: string;\n variant: string;\n price: number;\n name: string;\n quantity: number;\n productRefId: string;\n brand: string;\n category: string;\n}\n\nexport interface Order {\n currency: string;\n accountName: string;\n orderGroup: string;\n salesChannel: string;\n coupon: 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 transactionShipping: number;\n transactionSubtotal: number;\n transactionDiscounts: number;\n transactionTax: number;\n transactionCurrency: string;\n transactionPaymentType: PaymentType[];\n transactionShippingMethod: ShippingMethod[];\n transactionProducts: ProductOrder[];\n transactionPayment: {\n id: string;\n };\n}\n\nexport interface Impression {\n product: Product;\n position: number;\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 productRefId: string;\n ean: string;\n slug: 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\ninterface Product {\n brand: string;\n categoryId?: string; // inconsistency\n categories: string[];\n productId: string;\n productName: string;\n selectedSku?: string; // inconsistency\n items: Item[];\n sku: Item;\n [key: string]: any;\n}\n\ninterface Item {\n itemId: string;\n name: string;\n seller?: Seller;\n [key: string]: any;\n}\n\ninterface Seller {\n commertialOffer: CommertialOffer;\n [key: string]: any;\n}\n\ninterface CommertialOffer {\n Price: number;\n [key: string]: any;\n}\n\n```"
}
] |
code_bluecore_5ebea9fb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of bluecore/react/typings/vtex.render-runtime.d.ts from the bluecore 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_bluecore_6469550c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of bluecore/react/typings/global.d.ts from the bluecore VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface Window extends Window {\n __bluecore_site_id: string;\n triggermail: Bluecore;\n}\n\ninterface Bluecore {\n Partner: {\n dataReady(params: AddToCart | RemoveFromCart): void;\n };\n}\n\ntype AddToCart = { event_type: \"add_to_cart\"; id: string };\ntype RemoveFromCart = { event_type: \"remove_from_cart\"; id: string };\n\n```"
}
] |
code_blog-interfaces_4893b0b9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blog-interfaces/docs/README.md from the blog-interfaces VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# Blog Interfaces\n\n> Interfaces for a blog integration app.\n\nThis app provides extensible interfaces that can be used by the `vtex.store` and a theme app. A blog app (either native or a third-party integration) would depend on this app and extend the interfaces provided to become available in the store.\n\nFor an example, see the [vtex.wordpress-integration](https://github.com/vtex-apps/wordpress-integration) app.\n\n## Use cases\n\n1. Create store pages for blog posts, blog categories, and blog search results.\n2. Add blog-related blocks to product pages and search pages.\n\n```"
}
] |
code_blog-interfaces_a3ca98cb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blog-interfaces/react/package.json from the blog-interfaces VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"test\": \"vtex-test-tools test\",\n \"lint\": \"eslint --ext js,jsx,ts,tsx .\"\n },\n \"dependencies\": {\n \"react\": \"^16.8.3\",\n \"react-dom\": \"^16.8.3\"\n },\n \"devDependencies\": {\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/react\": \"^16.8.10\",\n \"eslint\": \"^5.16.0\",\n \"eslint-config-vtex\": \"^10.1.0\",\n \"prettier\": \"^1.16.4\",\n \"tslint-eslint-rules\": \"^5.4.0\",\n \"typescript\": \"3.8.3\"\n },\n \"version\": \"0.2.0\"\n}\n\n```"
}
] |
code_blog-interfaces_55f625dc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blog-interfaces/react/Noop.tsx from the blog-interfaces VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FunctionComponent } from 'react'\n\nconst Noop: FunctionComponent = () => <></>\n\nexport default Noop\n\n```"
}
] |
code_blog-interfaces_3179ea39
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blog-interfaces/store/interfaces.json from the blog-interfaces VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"blog-all-posts\": {\n \"component\": \"Noop\",\n \"extensible\": \"public\"\n },\n \"blog-latest-posts-preview\": {\n \"component\": \"Noop\",\n \"extensible\": \"public\"\n },\n \"blog-category-preview\": {\n \"component\": \"Noop\",\n \"extensible\": \"public\"\n },\n \"blog-category-list\": {\n \"component\": \"Noop\",\n \"extensible\": \"public\"\n },\n \"blog-post-container\": {\n \"component\": \"Noop\",\n \"extensible\": \"public\",\n \"composition\": \"children\"\n },\n \"blog-post-details\": {\n \"component\": \"Noop\",\n \"extensible\": \"public\",\n \"composition\": \"children\",\n \"allowed\": [\n \"blog-related-products\"\n ]\n },\n \"blog-post-navigation\": {\n \"component\": \"Noop\",\n \"extensible\": \"public\"\n },\n \"blog-page-details\": {\n \"component\": \"Noop\",\n \"extensible\": \"public\",\n \"composition\": \"children\",\n \"allowed\": [\n \"blog-related-products\"\n ]\n },\n \"blog-search\": {\n \"component\": \"Noop\",\n \"extensible\": \"public\"\n },\n \"search-blog-articles-preview\": {\n \"component\": \"Noop\",\n \"extensible\": \"public\"\n },\n \"search-blog-articles-list\": {\n \"component\": \"Noop\",\n \"extensible\": \"public\"\n },\n \"blog-search-list\": {\n \"component\": \"Noop\",\n \"extensible\": \"public\"\n },\n \"blog-related-products\": {\n \"component\": \"Noop\",\n \"extensible\": \"public\"\n },\n \"blog-related-posts\": {\n \"component\": \"Noop\",\n \"extensible\": \"public\"\n },\n \"blog-breadcrumb\": {\n \"component\": \"Noop\",\n \"extensible\": \"public\"\n }\n}\n```"
}
] |
code_opencart_97136ed3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of opencart/system/library/shared/tcpdf/README.md from the opencart VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# TCPDF\n*PHP PDF Library*\n\n[](https://www.paypal.com/cgi-bin/webscr?cmd=_donations¤cy_code=GBP&business=paypal@tecnick.com&item_name=donation%20for%20TCPDF%20project)\n*Please consider supporting this project by making a donation via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations¤cy_code=GBP&business=paypal@tecnick.com&item_name=donation%20for%20TCPDF%20project)*\n\n* **category** Library\n* **author** Nicola Asuni <info@tecnick.com>\n* **copyright** 2002-2020 Nicola Asuni - Tecnick.com LTD\n* **license** http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)\n* **link** http://www.tcpdf.org\n* **source** https://github.com/tecnickcom/TCPDF\n\n\n## IMPORTANT\nA new version of this library is under development at https://github.com/tecnickcom/tc-lib-pdf and as a consequence this version will not receive any additional development or support.\nThis version should be considered obsolete, new projects should use the new version as soon it will become stable.\n\n\n\n## Description\n\nPHP library for generating PDF documents on-the-fly.\n\n### Main Features:\n* no external libraries are required for the basic functions;\n* all standard page formats, custom page formats, custom margins and units of measure;\n* UTF-8 Unicode and Right-To-Left languages;\n* TrueTypeUnicode, OpenTypeUnicode v1, TrueType, OpenType v1, Type1 and CID-0 fonts;\n* font subsetting;\n* methods to publish some XHTML + CSS code, Javascript and Forms;\n* images, graphic (geometric figures) and transformation methods;\n* supports JPEG, PNG and SVG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick (http://www.imagemagick.org/script/formats.php)\n* 1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extension, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, Datamatrix, QR-Code, PDF417;\n* JPEG and PNG ICC profiles, Grayscale, RGB, CMYK, Spot Colors and Transparencies;\n* automatic page header and footer management;\n* document encryption up to 256 bit and digital signature certifications;\n* transactions to UNDO commands;\n* PDF annotations, including links, text and file attachments;\n* text rendering modes (fill, stroke and clipping);\n* multiple columns mode;\n* no-write page regions;\n* bookmarks, named destinations and table of content;\n* text hyphenation;\n* text stretching and spacing (tracking);\n* automatic page break, line break and text alignments including justification;\n* automatic page numbering and page groups;\n* move and delete pages;\n* page compression (requires php-zlib extension);\n* XOBject Templates;\n* Layers and object visibility.\n* PDF/A-1b support.\n\n### Third party fonts:\n\nThis library may include third party font files released with different licenses.\n\nAll the PHP files on the fonts directory are subject to the general TCPDF license (GNU-LGPLv3),\nthey do not contain any binary data but just a description of the general properties of a particular font.\nThese files can be also generated on the fly using the font utilities and TCPDF methods.\n\nAll the original binary TTF font files have been renamed for compatibility with TCPDF and compressed using the gzcompress PHP function that uses the ZLIB data format (.z files).\n\nThe binary files (.z) that begins with the prefix \"free\" have been extracted from the GNU FreeFont collection (GNU-GPLv3).\nThe binary files (.z) that begins with the prefix \"pdfa\" have been derived from the GNU FreeFont, so they are subject to the same license.\nFor the details of Copyright, License and other information, please check the files inside the directory fonts/freefont-20120503\nLink : http://www.gnu.org/software/freefont/\n\nThe binary files (.z) that begins with the prefix \"dejavu\" have been extracted from the DejaVu fonts 2.33 (Bitstream) collection.\nFor the details of Copyright, License and other information, please check the files inside the directory fonts/dejavu-fonts-ttf-2.33\nLink : http://dejavu-fonts.org\n\nThe binary files (.z) that begins with the prefix \"ae\" have been extracted from the Arabeyes.org collection (GNU-GPLv2).\nLink : http://projects.arabeyes.org/\n\n### ICC profile:\n\nTCPDF includes the sRGB.icc profile from the icc-profiles-free Debian package:\nhttps://packages.debian.org/source/stable/icc-profiles-free\n\n\n## Developer(s) Contact\n\n* Nicola Asuni <info@tecnick.com>\n\n```"
}
] |
code_opencart_e181ea80
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of opencart/system/library/shared/tcpdf/composer.json from the opencart VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"tecnickcom/tcpdf\",\n \"version\": \"6.3.5\",\n \"homepage\": \"http://www.tcpdf.org/\",\n \"type\": \"library\",\n \"description\": \"TCPDF is a PHP class for generating PDF documents and barcodes.\",\n \"keywords\": [\n \"PDF\",\n \"tcpdf\",\n \"PDFD32000-2008\",\n \"qrcode\",\n \"datamatrix\",\n \"pdf417\",\n \"barcodes\"\n ],\n \"license\": \"LGPL-3.0-only\",\n \"authors\": [\n {\n \"name\": \"Nicola Asuni\",\n \"email\": \"info@tecnick.com\",\n \"role\": \"lead\"\n }\n ],\n \"require\": {\n \"php\": \">=5.3.0\"\n },\n \"autoload\": {\n \"classmap\": [\n \"config\",\n \"include\",\n \"tcpdf.php\",\n \"tcpdf_parser.php\",\n \"tcpdf_import.php\",\n \"tcpdf_barcodes_1d.php\",\n \"tcpdf_barcodes_2d.php\",\n \"include/tcpdf_colors.php\",\n \"include/tcpdf_filters.php\",\n \"include/tcpdf_font_data.php\",\n \"include/tcpdf_fonts.php\",\n \"include/tcpdf_images.php\",\n \"include/tcpdf_static.php\",\n \"include/barcodes/datamatrix.php\",\n \"include/barcodes/pdf417.php\",\n \"include/barcodes/qrcode.php\"\n ]\n }\n}\n\n```"
}
] |
code_react-portal_17e599f1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of react-portal/docs/README.md from the react-portal VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# React Portal\n\n# Basic Usage\n\nIt is possible to wrap a React element with [Overlay](https://github.com/vtex-apps/react-portal/blob/master/react/Overlay.tsx) to make use of its advantages such as making the block overlap any other block despite its z-index.\n\n## Example:\n\n```\n<Overlay>\n <div>Hello World!</div>\n</Overlay>\n```\n\n## Props\n\n| Prop name | Type | Description | Default value |\n| ------------ | ------------- | ------------------------------------------------------------ | ------------- |\n| `alignment` | `String` | Horizontal alignment | `left` |\n| `fullWindow` | `Boolean` | If true, the overlay will fill the whole window horizontally | - |\n| `target` | `HTMLElement` | Defines the container where the overlay will be created. | - |\n\nHere are the possible values of `HorizontalAlignment`\n\n| Value | Description |\n| -------- | ------------------- |\n| 'center' | Align to the center |\n| 'left' | Align to the left |\n| 'right' | Align to the right |\n\n```"
}
] |
code_react-portal_f1d7a401
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of react-portal/react/index.tsx from the react-portal VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport Overlay from './Overlay'\n\nexport { Overlay }\n\n```"
}
] |
code_react-portal_67bcc919
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of react-portal/react/package.json from the react-portal VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"@vtex/css-handles\": \"^1.1.3\",\n \"lodash.throttle\": \"^4.1.1\",\n \"react\": \"^16.8.6\",\n \"react-dom\": \"^16.8.6\"\n },\n \"devDependencies\": {\n \"@types/lodash.throttle\": \"^4.1.6\",\n \"@types/react\": \"^16.8.15\",\n \"@types/react-dom\": \"^16.8.4\",\n \"@vtex/test-tools\": \"^0.1.4\",\n \"vtex.css-handles\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.css-handles@0.4.4/public/@types/vtex.css-handles\"\n },\n \"version\": \"0.4.1\"\n}\n\n```"
}
] |
code_react-portal_b8ff115a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of react-portal/react/Overlay.tsx from the react-portal VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, {\n useRef,\n useEffect,\n useState,\n useCallback,\n PropsWithChildren,\n} from 'react'\nimport Portal, { Props as PortalProps } from './components/Portal'\nimport throttle from 'lodash.throttle'\n\ninterface Props extends PortalProps {\n fullWindow?: boolean\n alignment?: HorizontalAlignment\n}\n\ninterface Position {\n x: number\n y: number\n}\n\ntype HorizontalAlignment = 'right' | 'left' | 'center'\n\nconst getXPositionByHorizontalAlignment = (\n alignment: HorizontalAlignment,\n bounds: ClientRect | DOMRect\n) => {\n switch (alignment) {\n case 'left':\n return bounds.left\n case 'right':\n return bounds.right\n case 'center':\n return (bounds.right + bounds.left) / 2\n default:\n return bounds.left\n }\n}\n\nconst getJustifyTypeByHorizontalAlignment = (\n alignment: HorizontalAlignment\n) => {\n switch (alignment) {\n case 'left':\n return 'justify-start'\n case 'right':\n return 'justify-end'\n case 'center':\n return 'justify-center'\n default:\n return 'justify-start'\n }\n}\n\nfunction Overlay({\n children,\n fullWindow,\n target,\n alignment = 'left',\n}: PropsWithChildren<Props>) {\n const container = useRef<HTMLDivElement>(null)\n const [position, setPosition] = useState<Position>()\n\n /** updatePosition is throttled due to the use of getBoundingClientRect,\n * which triggers a recalculation of the entire page layout, which in\n * turn can be quite heavy */\n const updatePosition = useCallback(\n throttle(\n () => {\n if (!fullWindow && container.current) {\n const bounds = container.current.getBoundingClientRect()\n\n setPosition({\n x: getXPositionByHorizontalAlignment(alignment, bounds),\n y: bounds.top,\n })\n }\n /** Also, the throttling is set to leading: false (which means that\n * the function won't be called right away, but only after X ms),\n * to improve hydration performance */\n },\n 200,\n { leading: false }\n ),\n [alignment, fullWindow]\n )\n\n useEffect(() => {\n updatePosition()\n\n if (window) {\n window.addEventListener('scroll', updatePosition)\n window.addEventListener('load', updatePosition)\n window.addEventListener('resize', updatePosition)\n window.addEventListener('visibilitychange', updatePosition)\n }\n\n return () => {\n if (window) {\n window.removeEventListener('scroll', updatePosition)\n window.removeEventListener('load', updatePosition)\n window.removeEventListener('resize', updatePosition)\n window.removeEventListener('visibilitychange', updatePosition)\n }\n }\n }, [alignment, fullWindow, updatePosition, children])\n\n if (!fullWindow) {\n return (\n // Div used for anchoring the position of the overlay, for popovers etc\n <div\n ref={container}\n style={{\n width: 'auto',\n height: 1,\n marginTop: -1,\n }}\n >\n {position && (\n <Portal target={target}>\n <div\n className={`flex ${getJustifyTypeByHorizontalAlignment(\n alignment\n )}`}\n style={{\n position: 'absolute',\n left: position.x,\n top: position.y,\n }}\n >\n <div className=\"absolute\">{children}</div>\n </div>\n </Portal>\n )}\n </div>\n )\n }\n\n return (\n <Portal target={target} cover>\n {children}\n </Portal>\n )\n}\n\nexport default Overlay\n\n```"
}
] |
code_react-portal_fe03cd87
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of react-portal/react/components/Portal.tsx from the react-portal VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { FunctionComponent } from 'react'\nimport ReactDOM from 'react-dom'\n\nimport { useCssHandles } from 'vtex.css-handles'\n\nexport interface Props {\n cover?: boolean\n target?: HTMLElement\n zIndex?: number\n}\n\nconst CSS_HANDLES = ['portalContainer', 'portalWrapper'] as const\n\nconst Portal: FunctionComponent<Props> = ({\n children,\n target,\n zIndex = 2147483647,\n cover,\n}) => {\n const handles = useCssHandles(CSS_HANDLES)\n\n if (!target) {\n target = window && window.document && window.document.body\n }\n\n if (!target) {\n return null\n }\n\n return ReactDOM.createPortal(\n <div\n className={handles.portalContainer}\n style={{\n position: 'fixed',\n top: 0,\n left: 0,\n ...(cover\n ? {\n bottom: 0,\n right: 0,\n pointerEvents: 'none',\n }\n : {}),\n zIndex,\n }}\n >\n <div className={handles.portalWrapper} style={{ pointerEvents: 'auto' }}>\n {children}\n </div>\n </div>,\n target\n )\n}\n\nexport default Portal\n\n```"
}
] |
code_modal-layout_b01709f2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of modal-layout/messages/hu.json from the modal-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/modal-layout.close-button.default-label\": \"Mégse\",\n \"admin/editor.modal-layout.close-button.title\": \"Modális bezárása gomb\",\n \"admin/editor.modal-layout.close-button.label.title\": \"Gombcímke\",\n \"admin/editor.modal-layout.close-button.label.description\": \"Pl. „Modális bezárása”\"\n}\n\n```"
}
] |
code_modal-layout_7ca35d3f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of modal-layout/messages/th-TH.json from the modal-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/modal-layout.close-button.default-label\": \"ยกเลิก\",\n \"admin/editor.modal-layout.close-button.title\": \"ปุ่มปิดกล่องแสดงข้อความแบบโมดอล\",\n \"admin/editor.modal-layout.close-button.label.title\": \"ป้ายชื่อปุ่ม\",\n \"admin/editor.modal-layout.close-button.label.description\": \"เช่น \\\"ปิดกล่องแสดงข้อความแบบโมดอล\\\"\"\n}\n\n```"
}
] |
code_modal-layout_eb5feb8f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of modal-layout/messages/ja.json from the modal-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/modal-layout.close-button.default-label\": \"キャンセル\",\n \"admin/editor.modal-layout.close-button.title\": \"モーダルボタンを閉じる\",\n \"admin/editor.modal-layout.close-button.label.title\": \"ボタンラベル\",\n \"admin/editor.modal-layout.close-button.label.description\": \"例「モーダルを閉じる」\"\n}\n\n```"
}
] |
code_modal-layout_7f8b7065
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of modal-layout/messages/fi.json from the modal-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/modal-layout.close-button.default-label\": \"Peruuta\",\n \"admin/editor.modal-layout.close-button.title\": \"Sulje modaali -painike\",\n \"admin/editor.modal-layout.close-button.label.title\": \"Painikkeen selite\",\n \"admin/editor.modal-layout.close-button.label.description\": \"Esim.: ”Sulje modaali”\"\n}\n\n```"
}
] |
code_modal-layout_da25fba9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of modal-layout/messages/id-ID.json from the modal-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/modal-layout.close-button.default-label\": \"Batalkan\",\n \"admin/editor.modal-layout.close-button.title\": \"Tombol Tutup Modal\",\n \"admin/editor.modal-layout.close-button.label.title\": \"Label tombol\",\n \"admin/editor.modal-layout.close-button.label.description\": \"Mis. \\\"Tutup Modal\\\"\"\n}\n\n```"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.