id
stringlengths 12
53
| messages
listlengths 3
3
|
|---|---|
code_admin-ley-gondolas-arg_a404416e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/node/clients/catalogClient.ts from the admin-ley-gondolas-arg 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 CatalogClient extends ExternalClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(\n `http://${context.account}.vtexcommercestable.com.br/api/catalog_system`,\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 getCategoryTree() {\n return this.http.getRaw(`/pub/category/tree/20`)\n }\n\n public async getProductsOfCategory(categoryTree: string, from: number, to: number, params: string | null = null) {\n return this.http.getRaw(`/pub/products/search?_from=${from}&_to=${to}&fq=C:/${categoryTree}/${params ? `&ft=${params}` : ''}`)\n }\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_904e9402
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/node/clients/index.ts from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\n\nimport MasterDataClient from './masterDataClient'\nimport CatalogClient from './catalogClient'\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 catalogClient() {\n return this.getOrSet('catalogClient', CatalogClient)\n }\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_240b25ff
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/node/middlewares/configSchema.ts from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { BodySchema } from '../interfaces'\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function configSchema(ctx: Context, next: () => Promise<any>) {\n const {\n clients: { masterDataClient },\n } = ctx\n\n const bodySchema: BodySchema = {\n properties: {\n categorieCatalog: {\n type: 'string',\n maxLength: 1000,\n title: 'categorieCatalog',\n },\n idCategory: {\n type: 'number',\n maxLength: 50,\n title: 'idCategory',\n },\n categorieLaw: {\n type: 'string',\n maxLength: 1000,\n title: 'categorieLaw',\n },\n idBestLowerProduct: {\n type: 'string',\n maxLength: 50,\n title: 'idBestLowerProduct',\n },\n nameBestLowerProduct: {\n type: 'string',\n maxLength: 1000,\n title: 'nameBestLowerProduct',\n },\n },\n required: [\n 'categorieLaw',\n 'categorieCatalog',\n 'idCategory',\n 'idBestLowerProduct',\n 'nameBestLowerProduct',\n ],\n 'v-indexed': [\n 'categorieLaw',\n 'categorieCatalog',\n 'idCategory',\n 'idBestLowerProduct',\n 'nameBestLowerProduct',\n ],\n 'v-security': {\n publicJsonSchema: true,\n allowGetAll: false,\n publicRead: [\n 'categorieLaw',\n 'categorieCatalog',\n 'idCategory',\n 'idBestLowerProduct',\n 'nameBestLowerProduct',\n ],\n publicWrite: [\n 'categorieLaw',\n 'categorieCatalog',\n 'idCategory',\n 'idBestLowerProduct',\n 'nameBestLowerProduct',\n ],\n publicFilter: [\n 'categorieLaw',\n 'categorieCatalog',\n 'idCategory',\n 'idBestLowerProduct',\n 'nameBestLowerProduct',\n ],\n },\n }\n\n try {\n const response = await masterDataClient.createSchema(bodySchema)\n\n const { data } = response\n\n ctx.body = data\n } catch (error) {\n ctx.status = 500\n ctx.body = {\n Message: 'Hubo un error, intente nuevamente despues.',\n }\n }\n\n await next()\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_d37f3965
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/node/resolvers/index.ts from the admin-ley-gondolas-arg 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 catalogQueries } from './catalog'\n\nexport const resolvers = {\n Query: {\n ...masterDataQueries,\n ...catalogQueries,\n },\n Mutation: {\n ...masterDataMutations,\n },\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_de441e16
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/node/interfaces/BodySchema.ts from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport interface BodySchema {\n properties: Properties\n required: string[]\n 'v-indexed': string[]\n 'v-security': VSecurity\n}\n\nexport interface Properties {\n categorieCatalog: CategorieCatalog\n idCategory: CategorieCatalog\n categorieLaw: CategorieCatalog\n idBestLowerProduct: CategorieCatalog\n nameBestLowerProduct: CategorieCatalog\n}\n\nexport interface CategorieCatalog {\n type: string\n maxLength: number\n title: string\n}\n\nexport interface VSecurity {\n publicJsonSchema: boolean\n allowGetAll: boolean\n publicRead: string[]\n publicWrite: string[]\n publicFilter: string[]\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_fe798ed1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/node/interfaces/ResponseCreateSchema.ts from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport interface ResponseCreateSchema {\n config: Config\n request: Request\n response: Response\n isAxiosError: boolean\n errorReportMetadata: ErrorReportMetadata\n name: string\n message: string\n stack: string\n code: string\n}\n\nexport interface Config {\n baseURL: string\n data: string\n headers: ConfigHeaders\n method: string\n timeout: number\n url: string\n params: Params\n}\n\nexport interface ConfigHeaders {\n Accept: string\n 'Content-Type': string\n 'accept-encoding': string\n 'user-agent': string\n 'x-forwarded-host': string\n 'x-vtex-operation-id': string\n 'Content-Length': number\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface Params {}\n\nexport interface ErrorReportMetadata {\n errorId: string\n reportCount: number\n}\n\nexport interface Request {\n finished: boolean\n method: string\n path: string\n}\n\nexport interface Response {\n data: string\n headers: ResponseHeaders\n status: number\n}\n\nexport interface ResponseHeaders {\n date: string\n server: string\n 'cache-control': string\n pragma: string\n expires: string\n 'set-cookie': string[]\n 'x-aspnet-version': string\n 'x-powered-by': string\n 'x-vtex-janus-router-backend-app': string\n 'x-vtex-took': string\n 'x-request-id': string\n 'x-vtex-router-version': string\n 'x-vtex-backend-status-code': string\n 'x-vtex-backend-elapsed-time': string\n 'x-vtex-router-elapsed-time': string\n 'x-vtex-io-cluster-id': string\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_7b84aaf9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/node/interfaces/index.ts from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport { ResponseCreateSchema } from './ResponseCreateSchema'\nexport { BodySchema } from './BodySchema'\n\n```"
}
] |
code_admin-ley-gondolas-arg_14dcc7f7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/node/resolvers/catalog/index.ts from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const queries = {\n getCategoryTree: async (\n _: unknown,\n __: unknown,\n ctx: Context\n ): Promise<any> => {\n return ctx.clients.catalogClient.getCategoryTree()\n },\n getProductsOfCategory: async (\n _: unknown,\n { categoryTree, from, to, params }: any,\n ctx: Context\n ): Promise<any> => {\n return ctx.clients.catalogClient.getProductsOfCategory(categoryTree, from, to, params)\n },\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_65c59cac
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/node/resolvers/masterData/index.ts from the admin-ley-gondolas-arg 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 createDocument: async (\n _: unknown,\n { body }: any,\n ctx: Context\n ): Promise<any> => {\n return ctx.clients.masterDataClient.createDocument(body)\n },\n\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_admin-ley-gondolas-arg_ee7d7854
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/typings/gql.d.ts from the admin-ley-gondolas-arg 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_admin-ley-gondolas-arg_440b17a5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/typings/global.d.ts from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type { NumberElement } from '@formatjs/icu-messageformat-parser'\nimport { string } from 'prop-types'\nimport type { ReactNode, SetStateAction, Dispatch } from 'react'\n\ndeclare global {\n export interface CategorieCatalog {\n idRow: number\n id: number\n name: string\n }\n\n export interface Product {\n idRow: number\n id: string\n name: string\n }\n\n export interface CategoriesRow {\n id: number\n idDocument: string\n categorieLaw: string\n categorieCatalog: CategorieCatalog\n bestLowerProduct: Product\n }\n\n export interface CategoriesTableProps {\n categoriesList: CategoriesRow[]\n }\n\n export interface DocumentCategorie {\n id: string\n categorieLaw: string\n categorieCatalog: string\n idCategory: number\n nameBestLowerProduct: string\n idBestLowerProduct: string\n }\n\n export interface CategoriesTreeProps {\n idRow: number\n nameCategory: string\n items: CategoriesRow[]\n setItems: (items: CategoriesRow[]) => void\n closeModal: ({ id, idRow, name }: CategorieCatalog) => void\n }\n\n export interface CategoryChildenListProps {\n id: number\n name: string\n hasChildren: boolean\n children: CategoryChildenListProps[]\n }\n\n export interface RecursiveChildenListProps {\n category: CategoryChildenListProps[]\n selectedCategory: string\n setSelectedCategory: (category: string) => void\n setSelectedIdCategory: (id: number) => void\n }\n\n export interface ProductSearchProps {\n idRow: number\n nameProduct: string\n idProduct: string\n items: CategoriesRow[]\n setItems: (items: CategoriesRow[]) => void\n closeModal: ({ id, idRow, name }: Product) => void\n }\n export interface Image {\n imageId: string\n imageUrl: string\n imageText: string\n }\n\n export interface Item {\n itemId: string\n name: string\n images: Image[]\n }\n\n export interface ProductFromQuery {\n productId: string\n productName: string\n brand: string\n categoryId: string\n pricePerUnit: number[]\n leyDeGondolas: string[]\n linkText: string\n items: Item[]\n }\n export interface Catalog {\n idRow: number\n productId: string\n name: string\n }\n export interface ProductToTable {\n id: number\n catalog: Catalog\n productId: string\n productName: {\n name: string\n link: string\n }\n brand: string\n categoryId: string\n pricePerUnit: number\n bestLowerPrice: string[]\n pymes: string[]\n linkText: string\n items: Item[]\n }\n\n export interface ProductTableProps {\n listOfProducts: ProductToTable[]\n setListOfProducts: (listOfProducts: ProductToTable[]) => void\n items: CategoriesRow[]\n setItems: (items: CategoriesRow[]) => void\n }\n\n export interface BodySaveDocumentMasterData {\n categorieLaw: string\n categorieCatalog: string\n idCategory: number\n nameBestLowerProduct: string\n idBestLowerProduct: string\n }\n\n interface ProductContext {\n totalItems: number,\n from: number\n to: number\n currentPage: number\n totalPages: number\n limit: number\n params: string\n statements: any[]\n }\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_96f0830d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/typings/css.d.ts from the admin-ley-gondolas-arg 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_admin-ley-gondolas-arg_6148e0ba
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/typings/vtex.styleguide.d.ts from the admin-ley-gondolas-arg 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_admin-ley-gondolas-arg_f4c59cf2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/utils/listOfLawCategories.tsx from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nexport const listOfLawCategories: string[] = [\n 'Leches',\n 'Cremas de leche, mantecas y margarinas',\n 'Quesos untables y ricotas',\n 'Postres lácteos y yogures',\n 'Masas frescas y levaduras',\n 'Fiambres, embutidos y encurtidos',\n 'Quesos excepto untables y ricotas',\n 'Hamburguesas, milanesas y bocaditos de carne, pollo, cerdo y/o pescado congelados',\n 'Vegetales congelados, milanesas y medallones sin carne congelados',\n 'Comidas preparadas y panificados congelados',\n 'Helados y postres congelados',\n 'Frutas y verduras',\n 'Salsas y aderezos',\n 'Especias y condimentos',\n 'Polvo para postres y repostería, y productos de repostería',\n 'Conservas y salsas de tomate',\n 'Otras conservas',\n 'Pastas secas',\n 'Arroz',\n 'Sopas, caldos y puré',\n 'Legumbres secas, otras harinas, granos y semillas',\n 'Aceites',\n 'Panes rallados y rebozadores',\n 'Harinas de trigo y premezclas',\n 'Golosinas, alfajores y chocolates',\n 'Panificados y cereales',\n 'Galletitas',\n 'Infusiones',\n 'Mermeladas, dulces y miel',\n 'Dulce de leche',\n 'Endulzantes',\n 'Snacks',\n 'Jugos',\n 'Aguas saborizadas',\n 'Gaseosas',\n 'Aguas',\n 'Bebidas sin alcohol refrigeradas',\n 'Cervezas y aperitivos',\n 'Vinos y espumantes',\n 'Espirituosas, destilados y licores',\n 'Bebidas con alcohol refrigeradas',\n 'Afeitado y depilación',\n 'Colonias y desodorantes corporales, polvos pédicos y talcos',\n 'Jabones de tocador, geles y sales de baño, artículos de baño',\n 'Cremas decolorantes y coloración para el cabello',\n 'Champúes, Acondicionadores, fijadores y productos para el tratamiento capilar',\n 'Cuidado facial y artículos de farmacia',\n 'Cremas corporales',\n 'Protectores solares y bronceadores',\n 'Cuidado oral',\n 'Productos para la higiene del bebé, accesorios para el bebé y alimentación infantil',\n 'Pañales y ropa interior descartable',\n 'Productos de gestión menstrual, toallas para la incontinencia y cuidado materno',\n 'Accesorios de limpieza',\n 'Accesorios de cocina',\n 'Jabón en pan, prelavado, quitamanchas y perfumes para la ropa',\n 'Jabones en polvo, jabones líquidos y suavizantes para la ropa',\n 'Desodorantes y desinfectantes ambientales',\n 'Lavandinas',\n 'Lavavajillas',\n 'Limpieza de pisos y muebles',\n 'Limpiadores cremosos, de cocina, de baño y multiuso',\n 'Insecticidas y repelentes',\n 'Papeles',\n 'Alimentos y accesorios para mascotas',\n]\n\n```"
}
] |
code_admin-ley-gondolas-arg_d1d2b5e2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/utils/intl.ts from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { defineMessages } from 'react-intl'\n\nconst prefix = 'admin/admin.app.ley-gondolas-arg.'\n\nexport const titlesIntl = defineMessages({\n pageTitle: { id: `${prefix}pageTitle` },\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 categoriesTableCategorieLaw: { id: `${prefix}categoriesTableCategorieLaw` },\n categoriesTableCategorieCatalog: {\n id: `${prefix}categoriesTableCategorieCatalog`,\n },\n categoriesTableBestLowerProduct: {\n id: `${prefix}categoriesTableBestLowerProduct`,\n },\n selectCategory: {\n id: `${prefix}selectCategory`,\n },\n changeCategory: {\n id: `${prefix}changeCategory`,\n },\n currentCategory: {\n id: `${prefix}currentCategory`,\n },\n cancel: {\n id: `${prefix}cancel`,\n },\n saveSelectedCategory: {\n id: `${prefix}saveSelectedCategory`,\n },\n productsTableImage: {\n id: `${prefix}productsTableImage`,\n },\n productsTableProductId: {\n id: `${prefix}productsTableProductId`,\n },\n productsTableProductName: {\n id: `${prefix}productsTableProductName`,\n },\n productsTableBrand: {\n id: `${prefix}productsTableBrand`,\n },\n productsTablePricePerUnit: {\n id: `${prefix}productsTablePricePerUnit`,\n },\n productsTablePyMEs: {\n id: `${prefix}productsTablePyMEs`,\n },\n productsTableMejorMenorPrecio: {\n id: `${prefix}productsTableMejorMenorPrecio`,\n },\n currentProduct: {\n id: `${prefix}currentProduct`,\n },\n showProduct: {\n id: `${prefix}showProduct`,\n },\n lastSeen: {\n id: `${prefix}lastSeen`,\n },\n showInCatalog: {\n id: `${prefix}showInCatalog`,\n },\n warningSelectCategory: {\n id: `${prefix}warningSelectCategory`,\n },\n tryLater: {\n id: `${prefix}tryLater`,\n },\n noProducts: {\n id: `${prefix}noProducts`,\n },\n})\n\n```"
}
] |
code_admin-ley-gondolas-arg_fb83f759
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/style/Loading.global.css from the admin-ley-gondolas-arg 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_admin-ley-gondolas-arg_ccdf5db8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/components/ProductSearch.tsx from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/prefer-optional-chain */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useState, useEffect, useContext } from 'react'\nimport { Modal /* , Tag */ } from 'vtex.styleguide'\nimport { useQuery, useLazyQuery } from 'react-apollo'\nimport { useIntl } from 'react-intl'\n\nimport { titlesIntl } from '../utils/intl'\nimport getCategoryTree from '../graphql/getCategoryTree.gql'\nimport getProductsOfCategory from '../graphql/getProductsOfCategory.gql'\nimport getPaginationData from '../graphql/getPaginationData.gql'\nimport LoadingSpinner from './LoadingSpinner'\nimport ProductsTable from './ProductsTable'\nimport '../style/Modal.global.css'\nimport { ProductContext } from '../store/context/ProductContext'\n\nexport default function ProductSearch({\n idRow,\n // nameProduct,\n items,\n setItems,\n closeModal,\n}: ProductSearchProps) {\n const intl = useIntl()\n const [categoryTree, setCategoryTree] = useState('')\n const [listOfProducts, setListOfProducts] = useState<ProductToTable[]>([])\n const { state, dispatch } = useContext(ProductContext)\n\n const [\n getProductsOfCategoryQuery,\n { data: dataProducts, loading: loadingProducts, error: errorProducts },\n ] = useLazyQuery(getProductsOfCategory)\n\n const [\n getPaginationDataQuery,\n { data: dataPagination },\n ] = useLazyQuery(getPaginationData)\n\n useEffect(() => {\n if (categoryTree) {\n getProductsOfCategoryQuery({ variables: { categoryTree, from: state.from, to: state.to, params: state.params } })\n getPaginationDataQuery({\n variables: {\n filters: { categoryId: categoryTree },\n page: state.currentPage,\n pageSize: state.limit,\n term: state.params,\n }\n })\n }\n\n }, [state.to, state.from, state.limit, state.params, categoryTree, getProductsOfCategoryQuery])\n\n const responseFromGetCategoryTree = useQuery(getCategoryTree, {\n ssr: false,\n })\n\n const idCategoryOfRow = items[idRow].categorieCatalog.id\n\n const dataFromGetCategoryTree: CategoryChildenListProps[] =\n responseFromGetCategoryTree.data?.getCategoryTree?.data\n\n dataFromGetCategoryTree?.forEach(\n (c: CategoryChildenListProps) => !categoryTree && findCategoryTree(c)\n )\n\n function findCategoryTree(\n categoryToCheck: CategoryChildenListProps,\n parents = ''\n ): any {\n if (categoryToCheck.children.some((c) => c.id === idCategoryOfRow)) {\n setCategoryTree(\n `${!parents ? categoryToCheck.id : parents}/${idCategoryOfRow}`\n )\n } else if (categoryToCheck.id === idCategoryOfRow) {\n setCategoryTree(`${!parents ? categoryToCheck.id : parents}`)\n } else {\n return categoryToCheck.children.some(\n (c) =>\n c.id === idCategoryOfRow ||\n findCategoryTree(\n c,\n `${!parents ? categoryToCheck.id : parents}/${c.id}`\n )\n )\n }\n }\n\n /* useEffect(() => {\n if (categoryTree) {\n getProductsOfCategoryQuery({ variables: { categoryTree } })\n }\n }, [categoryTree, getProductsOfCategoryQuery]) */\n\n useEffect(() => {\n if (dataPagination) {\n dispatch({ type: \"SET_TOTAL_ITEMS\", payload: dataPagination.products.paging.total })\n dispatch({ type: \"SET_TOTAL_PAGES\", payload: dataPagination.products.paging.pages })\n dispatch({ type: \"SET_CURRENT_PAGE\", payload: dataPagination.products.paging.page })\n }\n }, [dataPagination])\n\n useEffect(() => {\n if (errorProducts) {\n console.info('errorProducts', errorProducts)\n }\n\n // eslint-disable-next-line vtex/prefer-early-return\n if (dataProducts) {\n const listOfProductsTemp: ProductToTable[] =\n dataProducts.getProductsOfCategory.data.map(\n (p: ProductFromQuery, index: number) => {\n return {\n id: index,\n catalog: {\n idRow,\n productId: p.productId,\n name: p.productName,\n },\n image: {\n imageId: p.items[0].images[0].imageId,\n imageUrl: p.items[0].images[0].imageUrl,\n imageText: p.items[0].images[0].imageText,\n },\n productId: p.productId,\n productName: {\n name: p.productName,\n link: p.linkText,\n },\n brand: p.brand,\n categoryId: p.categoryId,\n pricePerUnit: p.pricePerUnit && p.pricePerUnit[0],\n bestLowerPrice: p.leyDeGondolas,\n pymes: p.leyDeGondolas,\n }\n }\n )\n\n listOfProductsTemp.sort(\n (a, b) =>\n (a.pricePerUnit != null ? a.pricePerUnit : Infinity) -\n (b.pricePerUnit != null ? b.pricePerUnit : Infinity)\n )\n\n setListOfProducts(listOfProductsTemp)\n }\n }, [dataProducts, loadingProducts, errorProducts, idRow])\n return (\n <Modal\n centered\n isOpen\n onClose={() => closeModal({ id: '', idRow: -1, name: '' })}\n >\n <div>\n {idCategoryOfRow !== -1 &&\n dataProducts && (\n <ProductsTable\n listOfProducts={listOfProducts}\n setListOfProducts={setListOfProducts}\n items={items}\n setItems={setItems}\n />\n )}\n {loadingProducts && <LoadingSpinner />}\n {errorProducts && (\n <div className=\"w-100\">\n <p className=\"f3 fw3 gray\">\n {intl.formatMessage(titlesIntl.tryLater)}\n </p>\n </div>\n )}\n {idCategoryOfRow === -1 && (\n <div className=\"w-100\">\n <p className=\"f3 fw3 gray\">\n {intl.formatMessage(titlesIntl.warningSelectCategory)}\n </p>\n </div>\n )}\n </div>\n </Modal>\n )\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_c481bb42
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/components/RecurviseChildenList.tsx from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/prefer-optional-chain */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useState, useEffect } from 'react'\n\nimport Expandable from './Expandable'\n\nexport default function RecursiveChildenList({\n category,\n selectedCategory,\n setSelectedCategory,\n setSelectedIdCategory,\n}: RecursiveChildenListProps) {\n const [checked, setChecked] = useState<string>(selectedCategory)\n\n useEffect(() => {\n setSelectedCategory(checked)\n }, [checked, setSelectedCategory])\n\n function createRecursiveChildenList(\n categoryRecursive: CategoryChildenListProps[]\n ) {\n function doCheckOpen(categoryToCheck: CategoryChildenListProps): boolean {\n return categoryToCheck.children.some(\n (c) => c.name === checked || doCheckOpen(c)\n )\n }\n\n return categoryRecursive.map((categoryOfList: CategoryChildenListProps) => (\n <Expandable\n key={`${categoryOfList.id}`}\n id={`${categoryOfList.id}`}\n title={categoryOfList.name}\n checked={checked}\n setChecked={setChecked}\n setCheckedId={setSelectedIdCategory}\n open={doCheckOpen(categoryOfList)}\n content={\n categoryOfList.children.length > 0 &&\n createRecursiveChildenList(categoryOfList.children)\n }\n />\n ))\n }\n\n return <div>{createRecursiveChildenList(category)}</div>\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_9ec337db
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/components/CategorieTree.tsx from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/prefer-optional-chain */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useState } from 'react'\nimport { Button, Modal, Tag } from 'vtex.styleguide'\nimport { useQuery, useMutation } from 'react-apollo'\nimport { useIntl } from 'react-intl'\n\nimport { titlesIntl } from '../utils/intl'\nimport getCategoryTree from '../graphql/getCategoryTree.gql'\nimport RecurviseChildenList from './RecurviseChildenList'\nimport LoadingSpinner from './LoadingSpinner'\nimport SaveInMasterdata from './SaveInMasterdata'\nimport updateDocument from '../graphql/updateDocument.gql'\nimport createDocument from '../graphql/createDocument.gql'\n\nexport default function CategoriesTree({\n idRow,\n nameCategory,\n items,\n setItems,\n closeModal,\n}: CategoriesTreeProps) {\n const intl = useIntl()\n const [selectedCategory, setSelectedCategory] = useState('')\n const [selectedIdCategory, setSelectedIdCategory] = useState(-1)\n const [updateDocumentMutation] = useMutation(updateDocument)\n\n const [createDocumentMutation] = useMutation(createDocument)\n\n const responseFromGetCategoryTree = useQuery(getCategoryTree, {\n ssr: false,\n })\n\n const dataFromGetCategoryTree: CategoryChildenListProps[] =\n responseFromGetCategoryTree.data?.getCategoryTree?.data\n\n const handleChangeCategory = async () => {\n closeModal({ id: -1, idRow: -1, name: '' })\n\n const tempItems: CategoriesRow[] = items\n\n tempItems[idRow].categorieCatalog.name = selectedCategory\n tempItems[idRow].categorieCatalog.id = selectedIdCategory\n\n const response = await SaveInMasterdata(\n tempItems,\n idRow,\n updateDocumentMutation,\n createDocumentMutation\n )\n\n if (response.data.createDocument) {\n tempItems[idRow].idDocument = response.data.createDocument.data.DocumentId\n }\n\n setItems(tempItems)\n }\n\n return (\n <Modal\n centered\n isOpen\n onClose={() => closeModal({ id: -1, idRow: -1, name: '' })}\n bottomBar={\n <div className=\"nowrap\">\n {nameCategory && (\n <span className=\"mr4\">\n <Tag bgColor=\"#F71963\">{`${intl.formatMessage(\n titlesIntl.currentCategory\n )}: ${nameCategory}`}</Tag>\n </span>\n )}\n <span className=\"mr4\">\n <Button\n variation=\"tertiary\"\n onClick={() => closeModal({ id: -1, idRow: -1, name: '' })}\n >\n {`${intl.formatMessage(titlesIntl.cancel)}`}\n </Button>\n </span>\n <span>\n <Button\n variation=\"primary\"\n size=\"small\"\n onClick={() => handleChangeCategory()}\n >\n {`${intl.formatMessage(titlesIntl.saveSelectedCategory)}`}\n </Button>\n </span>\n </div>\n }\n >\n <div>\n {dataFromGetCategoryTree && (\n <RecurviseChildenList\n category={dataFromGetCategoryTree}\n selectedCategory={nameCategory}\n setSelectedCategory={setSelectedCategory}\n setSelectedIdCategory={setSelectedIdCategory}\n />\n )}\n {!dataFromGetCategoryTree && <LoadingSpinner />}\n </div>\n </Modal>\n )\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_9fcf92de
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/components/ProductsTable.tsx from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n EXPERIMENTAL_Table as Table,\n Input,\n Link,\n ButtonWithIcon,\n} from 'vtex.styleguide'\nimport Edit from '@vtex/styleguide/lib/icon/Edit'\nimport Check from '@vtex/styleguide/lib/icon/Check'\nimport useTableMeasures from '@vtex/styleguide/lib/EXPERIMENTAL_Table/hooks/useTableMeasures'\nimport React, { useState, useEffect, useCallback, useContext } from 'react'\nimport { useIntl } from 'react-intl'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { useMutation } from 'react-apollo'\n\nimport updateDocument from '../graphql/updateDocument.gql'\nimport createDocument from '../graphql/createDocument.gql'\nimport { titlesIntl } from '../utils/intl'\nimport SaveInMasterdata from './SaveInMasterdata'\nimport { ProductContext } from '../store/context/ProductContext'\n\nexport default function ProductsTable({\n listOfProducts,\n items,\n setItems,\n}: ProductTableProps) {\n const intl = useIntl()\n const { workspace, account } = useRuntime()\n const { state, dispatch } = useContext(ProductContext)\n\n const [updateDocumentMutation] = useMutation(updateDocument)\n\n const [createDocumentMutation] = useMutation(createDocument)\n const columns = [\n {\n id: 'image',\n title: intl.formatMessage(titlesIntl.productsTableImage),\n cellRenderer: ({ data }: any) => {\n return (\n <img id={data.imageId} src={data.imageUrl} alt={data.imageText} />\n )\n },\n },\n {\n id: 'catalog',\n title: intl.formatMessage(titlesIntl.showInCatalog),\n cellRenderer: ({ data }: any) => {\n const editIcon = <Edit />\n\n return (\n <div className=\"flex justify-center\">\n <ButtonWithIcon\n href={`/admin/Site/ProdutoForm.aspx?id=${data.productId}`}\n target=\"_blank\"\n variation=\"secondary\"\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n onClick={() => handleClickSeeCatalog(data)}\n icon={editIcon}\n />\n </div>\n )\n },\n },\n {\n id: 'productName',\n title: intl.formatMessage(titlesIntl.productsTableProductName),\n cellRenderer: ({ data }: any) => {\n const domain =\n workspace === 'master'\n ? `https://${account}.myvtex.com/`\n : `https://${workspace}--${account}.myvtex.com/`\n\n return (\n <Link href={`${domain}${data.link}/p`} target=\"_blank\" mediumWeigth>\n {data.name}\n </Link>\n )\n },\n },\n {\n id: 'pricePerUnit',\n title: intl.formatMessage(titlesIntl.productsTablePricePerUnit),\n },\n {\n id: 'bestLowerPrice',\n title: intl.formatMessage(titlesIntl.productsTableMejorMenorPrecio),\n cellRenderer: ({ data }: any) => {\n const checkIcon = <Check />\n\n const checkData = data ? data.includes('Mejor Menor Precio') : false\n\n return (\n <div className=\"flex justify-center\">\n {checkData && (\n <div className=\"flex pa2 br2 bg-action-primary c-on-action-primary active-c-on-action-primary dib\">\n {checkIcon}\n </div>\n )}\n {!checkData && (\n <div className=\"flex pa2 br2 c-action-primary active-c-action-primary dib mv0 ba b--action-primary\">\n <svg\n viewBox=\"0 0 12 12\"\n width=\"16\"\n height=\"16\"\n className=\"vtex__icon-check\"\n />\n </div>\n )}\n </div>\n )\n },\n },\n {\n id: 'pymes',\n title: intl.formatMessage(titlesIntl.productsTablePyMEs),\n cellRenderer: ({ data }: any) => {\n const checkIcon = <Check />\n\n const checkData = data ? data.includes('PyMEs') : false\n\n return (\n <div className=\"flex justify-center\">\n {checkData && (\n <div className=\"flex pa2 br2 bg-action-primary c-on-action-primary active-c-on-action-primary dib\">\n {checkIcon}\n </div>\n )}\n {!checkData && (\n <div className=\"flex pa2 br2 c-action-primary active-c-action-primary dib mv0 ba b--action-primary\">\n <svg\n viewBox=\"0 0 12 12\"\n width=\"16\"\n height=\"16\"\n className=\"vtex__icon-check\"\n />\n </div>\n )}\n </div>\n )\n },\n },\n {\n id: 'brand',\n title: intl.formatMessage(titlesIntl.productsTableBrand),\n },\n ]\n\n const handleClickSeeCatalog = async (product: Catalog) => {\n const tempItems: CategoriesRow[] = items\n\n tempItems[product.idRow].bestLowerProduct.id = product.productId\n tempItems[product.idRow].bestLowerProduct.name = product.name\n setItems(tempItems)\n SaveInMasterdata(\n tempItems,\n product.idRow,\n updateDocumentMutation,\n createDocumentMutation\n )\n\n const response = await SaveInMasterdata(\n tempItems,\n product.idRow,\n updateDocumentMutation,\n createDocumentMutation\n )\n\n if (response.data.createDocument) {\n tempItems[product.idRow].idDocument =\n response.data.createDocument.data.DocumentId\n }\n\n setItems(tempItems)\n }\n\n const [filteredItems, setFilteredItems] = useState(listOfProducts)\n\n useEffect(() => {\n setFilteredItems(listOfProducts)\n }, [listOfProducts])\n\n // const [filterStatements, setFilterStatements] = useState(state.statements)\n const { state: paginationState } = useContext(ProductContext)\n const ITEMS_PER_PAGE = paginationState.limit\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: paginationState.totalItems,\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 = listOfProducts.slice()\n if (statements.length === 0) {\n dispatch({ type: 'SET_STATEMENTS', payload: statements })\n dispatch({ type: 'SET_PARAMS', payload: \"\" })\n }\n\n statements.forEach((st: any) => {\n if (!st || !st.object) return\n const { subject, verb, object } = st\n\n switch (subject) {\n case 'productName':\n if (verb === 'contains') {\n dispatch({ type: 'SET_STATEMENTS', payload: statements })\n dispatch({ type: 'SET_PARAMS', payload: object })\n }\n\n break\n\n default:\n break\n }\n })\n setFilteredItems(newData)\n }\n\n const filterClear = intl.formatMessage(titlesIntl.filterClear)\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: [/* 'productId', */ 'productName'],\n statements: state.statements,\n onChangeStatements: handleFiltersChange,\n clearAllFiltersButtonLabel: filterClear,\n collapseLeft: true,\n submitFilterLabel: filterApply,\n options: {\n productName: {\n label: intl.formatMessage(titlesIntl.productsTableProductName),\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 `${st.verb === '='\n ? filterIs\n : st.verb === '!='\n ? filterIsNot\n : filterContains\n } ${st.object}`\n },\n verbs: [\n {\n label: filterContains,\n value: 'contains',\n object: {\n renderFn: simpleInputObject,\n extraParams: {},\n },\n },\n ],\n }\n }\n\n const density = {\n label: 'Line density',\n compactLabel: 'Compact',\n regularLabel: 'Regular',\n comfortableLabel: 'Comfortable',\n }\n\n const customEmptyState = {\n label: intl.formatMessage(titlesIntl.noProducts),\n\n }\n\n return (\n <div>\n <Table\n measures={measures}\n columns={columns}\n items={slicedItems}\n empty={slicedItems.length === 0}\n emptyState={customEmptyState}\n >\n <Table.Pagination {...pagination} />\n <Table.Toolbar>\n <Table.FilterBar {...filters} />\n <Table.Toolbar.ButtonGroup>\n <Table.Toolbar.ButtonGroup.Density {...density} />\n </Table.Toolbar.ButtonGroup>\n </Table.Toolbar>\n </Table>\n </div>\n )\n}\n\n\nfunction usePagination(initialSize: number, itemsToPaginate: any) {\n const { dispatch, state: paginationState } = useContext(ProductContext)\n const state = ({\n tableSize: initialSize,\n currentPage: paginationState.currentPage,\n currentItemFrom: paginationState.from,\n currentItemTo: paginationState.to,\n selectedOption: paginationState.limit,\n slicedItems: [...itemsToPaginate]\n })\n\n /** gets the next page */\n const onNextClick = useCallback(() => {\n dispatch({ type: 'INCREASE_PAGE' })\n }, [state, itemsToPaginate])\n\n /** gets the previous page */\n const onPrevClick = useCallback(() => {\n\n if (state.currentPage === 0) return\n dispatch({ type: 'DECREASE_PAGE' })\n\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 dispatch({ type: 'SET_LIMIT', payload: rowValue })\n },\n [state, itemsToPaginate]\n )\n\n return {\n onNextClick,\n onPrevClick,\n onRowsChange,\n ...state,\n }\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_4d5c3fd3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/components/Expandable.tsx from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */\nimport React, { useState } from 'react'\nimport useCollapse from 'react-collapsed'\nimport { Checkbox } from 'vtex.styleguide'\n\n// import arrow from '../../assets/categoryTree/arrowCategoryTree.svg'\n\nconst Expandable = ({\n id,\n title,\n content,\n checked,\n setChecked,\n setCheckedId,\n open,\n}: // eslint-disable-next-line @typescript-eslint/no-explicit-any\nany) => {\n const { getCollapseProps, getToggleProps } = useCollapse({\n defaultExpanded: open,\n })\n\n const [rotation, setRotation] = useState<number>(open ? 90 : 0)\n const [isRotate, setIsRotate] = useState<boolean>(open)\n\n const rotate = () => {\n const angle = !isRotate ? 90 : -90\n let newRotation = rotation + angle\n\n if (newRotation >= 360) {\n newRotation = -360\n }\n\n setIsRotate(!isRotate)\n setRotation(newRotation)\n }\n\n const titleElement = (\n <li className=\"flex items-center\">\n <span className=\"flex mb1 pa3 br2 c-emphasis hover-c-emphasis active-c-emphasis dib mr5 mv0 ba b--emphasis hover-b-emphasis active-b-emphasis\">\n <div className=\"mr3 mt1\">\n <Checkbox\n id={title}\n checked={checked === title}\n onChange={() => {\n setChecked(title)\n setCheckedId(parseInt(id, 0))\n }}\n />\n </div>\n <div aria-hidden=\"true\" onClick={() => rotate()}>\n <div {...getToggleProps()}>{title}</div>\n </div>\n </span>\n <div {...getToggleProps()}>\n {content && (\n <div\n tabIndex={id}\n role=\"button\"\n id={title}\n style={{ transform: `rotate(${rotation}deg)` }}\n onClick={() => rotate()}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 477.175 477.175\"\n width=\"1rem\"\n >\n <path d=\"M360.731 229.075l-225.1-225.1c-5.3-5.3-13.8-5.3-19.1 0s-5.3 13.8 0 19.1l215.5 215.5-215.5 215.5c-5.3 5.3-5.3 13.8 0 19.1 2.6 2.6 6.1 4 9.5 4 3.4 0 6.9-1.3 9.5-4l225.1-225.1c5.3-5.2 5.3-13.8.1-19z\" />\n </svg>\n </div>\n )}\n </div>\n </li>\n )\n\n const contentUl = <ul {...getCollapseProps()}>{content}</ul>\n\n return (\n <>\n {title && titleElement}\n {content && contentUl}\n </>\n )\n}\n\nexport default Expandable\n\n```"
}
] |
code_admin-ley-gondolas-arg_7b9bcf12
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/components/LoadingSpinner.tsx from the admin-ley-gondolas-arg 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_admin-ley-gondolas-arg_7e6f5753
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/components/CategoriesTable.tsx from the admin-ley-gondolas-arg 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 Input,\n Button,\n Tag,\n} from 'vtex.styleguide'\nimport useTableMeasures from '@vtex/styleguide/lib/EXPERIMENTAL_Table/hooks/useTableMeasures'\nimport React, { useState, useEffect, useCallback } from 'react'\nimport { useIntl } from 'react-intl'\n\nimport { titlesIntl } from '../utils/intl'\nimport CategoriesTree from './CategorieTree'\nimport ProductSearch from './ProductSearch'\nimport { ProductProvider } from '../store/context/ProductContext'\n\nexport default function CategoriesTable({\n categoriesList,\n}: CategoriesTableProps) {\n const intl = useIntl()\n const [items, setItems] = useState<CategoriesRow[]>(categoriesList)\n const [isCategoryModalOpen, setIsCategoryModalOpen] = useState(false)\n const [nameCategoryClick, setNameCategoryClick] = useState('')\n const [rowCategoryClick, setRowCategoryClick] = useState(-1)\n const [isProductModalOpen, setIsProductModalOpen] = useState(false)\n const [nameProductClick, setNameProductClick] = useState('')\n const [idProductClick, setIdProductClick] = useState('')\n const [rowProductClick, setRowProductClick] = useState(-1)\n const columns = [\n {\n id: 'categorieLaw',\n title: intl.formatMessage(titlesIntl.categoriesTableCategorieLaw),\n },\n {\n id: 'categorieCatalog',\n title: intl.formatMessage(titlesIntl.categoriesTableCategorieCatalog),\n cellRenderer: ({ data }: any) => {\n return (\n <div>\n <div className=\"flex justify-left\">\n {data.name && <Tag bgColor=\"#F71963\">{data.name}</Tag>}\n </div>\n <div className=\"mt1\">\n <Button\n variation=\"secondary\"\n size=\"small\"\n onClick={() => handleModalCategorieCatalog(data)}\n >\n {!data.name &&\n `${intl.formatMessage(titlesIntl.selectCategory)}`}\n {data.name &&\n `${intl.formatMessage(titlesIntl.changeCategory)}`}\n </Button>\n </div>\n </div>\n )\n },\n },\n {\n id: 'bestLowerProduct',\n title: intl.formatMessage(titlesIntl.categoriesTableBestLowerProduct),\n cellRenderer: ({ data }: any) => {\n return (\n <div>\n <div className=\"flex justify-left\">\n {data.name && (\n <Tag bgColor=\"#F71963\">{`${intl.formatMessage(\n titlesIntl.lastSeen\n )}: ${data.name}`}</Tag>\n )}\n </div>\n <div className=\"mt1\">\n <Button\n variation=\"secondary\"\n size=\"small\"\n onClick={() => handleModalProducts(data)}\n >\n {intl.formatMessage(titlesIntl.showProduct)}\n </Button>\n </div>\n </div>\n )\n },\n },\n ]\n\n const handleModalCategorieCatalog = (categorieCatalog: any) => {\n setRowCategoryClick(categorieCatalog.idRow)\n setNameCategoryClick(categorieCatalog.name)\n setIsCategoryModalOpen(!isCategoryModalOpen)\n }\n\n const handleModalProducts = (product: any) => {\n setRowProductClick(product.idRow)\n setIdProductClick(product.id)\n setNameProductClick(product.name)\n setIsProductModalOpen(!isProductModalOpen)\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 'categorieLaw':\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 default:\n break\n }\n })\n setFilteredItems(newData)\n setFilterStatements(statements)\n }\n\n const filterClear = intl.formatMessage(titlesIntl.filterClear)\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: ['categorieLaw'],\n statements: filterStatements,\n onChangeStatements: handleFiltersChange,\n clearAllFiltersButtonLabel: filterClear,\n collapseLeft: true,\n submitFilterLabel: filterApply,\n options: {\n categorieLaw: {\n label: intl.formatMessage(titlesIntl.categoriesTableCategorieLaw),\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 `${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 const density = {\n label: 'Line density',\n compactLabel: 'Compact',\n regularLabel: 'Regular',\n comfortableLabel: 'Comfortable',\n }\n\n useEffect(() => {\n const filterBar = document.getElementById('vtex-table-v2__filter-bar')\n\n filterBar?.classList.remove('mb5')\n }, [])\n\n return (\n <div>\n <Table measures={measures} columns={columns} items={slicedItems}>\n <Table.Pagination {...pagination} />\n <Table.Toolbar>\n <Table.FilterBar {...filters} />\n <Table.Toolbar.ButtonGroup>\n <Table.Toolbar.ButtonGroup.Density {...density} />\n </Table.Toolbar.ButtonGroup>\n </Table.Toolbar>\n </Table>\n {isCategoryModalOpen && (\n <CategoriesTree\n idRow={rowCategoryClick}\n nameCategory={nameCategoryClick}\n items={items}\n setItems={setItems}\n closeModal={handleModalCategorieCatalog}\n />\n )}\n\n {isProductModalOpen && (\n <ProductProvider>\n <ProductSearch\n idRow={rowProductClick}\n nameProduct={nameProductClick}\n idProduct={idProductClick}\n items={items}\n setItems={setItems}\n closeModal={handleModalProducts}\n />\n </ProductProvider>\n )}\n </div>\n )\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_admin-ley-gondolas-arg_b8d79eff
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/components/SaveInMasterdata.tsx from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\n// import { useIntl } from 'react-intl'\n\n// import { titlesIntl } from '../utils/intl'\n/* import { useState, useEffect } from 'react'\nimport { useMutation } from 'react-apollo'\n\nimport updateDocument from '../graphql/updateDocument.gql'\nimport createDocument from '../graphql/createDocument.gql' */\n\n// eslint-disable-next-line max-params\nexport default async function SaveInMasterdata(\n items: CategoriesRow[],\n rowId: number,\n updateDocumentMutation: any,\n createDocumentMutation: any\n) {\n const { idDocument, categorieLaw, categorieCatalog, bestLowerProduct } =\n items[rowId]\n\n const { id: idCategory, name: nameCategorieCatalog } = categorieCatalog\n\n const { id: idBestLowerProduct, name: nameBestLowerProduct } =\n bestLowerProduct\n\n const bodyMasterdata: BodySaveDocumentMasterData = {\n categorieLaw,\n categorieCatalog: nameCategorieCatalog,\n idCategory,\n nameBestLowerProduct,\n idBestLowerProduct,\n }\n\n let response\n\n try {\n if (idDocument) {\n response = await updateDocumentMutation({\n variables: { documentId: idDocument, body: bodyMasterdata },\n })\n } else {\n response = await createDocumentMutation({\n variables: { body: bodyMasterdata },\n })\n }\n\n return response\n } catch (error) {\n console.error(error)\n }\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_1dced03c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/graphql/getPaginationData.gql from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery getPaginationData($term: String!, $page: Int!, $pageSize: Int!, $filters: ProductFilter) {\n products(pageSize: $pageSize, page: $page, term: $term, filters: $filters)\n @context(provider: \"vtex.catalog-graphql\") {\n paging{\n page\n perPage\n total\n pages\n }\n }\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_9dc1bca8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/graphql/updateDocument.gql from the admin-ley-gondolas-arg 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_admin-ley-gondolas-arg_9c703e7c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/graphql/createDocument.gql from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation createDocument($body: BodyCreateDocumentMasterData) {\n createDocument(body: $body) {\n status\n data {\n Id\n Href\n DocumentId\n }\n }\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_e78c2f3d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/graphql/getProductsOfCategory.gql from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery getProductsOfCategory($categoryTree: String, $from: Int!, $to: Int!, $params: String ) {\n getProductsOfCategory(categoryTree: $categoryTree, from: $from, to: $to, params: $params) {\n status\n data {\n productId\n productName\n brand\n categoryId\n pricePerUnit\n leyDeGondolas\n linkText\n items {\n itemId\n name\n images {\n imageId\n imageUrl\n imageText\n }\n }\n }\n }\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_b851a08d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/graphql/getCategoryTree.gql from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery getCategoryTree {\n getCategoryTree {\n status\n data {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n children {\n id\n name\n hasChildren\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_8d458629
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/graphql/getData.gql from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery getData {\n getData {\n status\n data {\n id\n categorieCatalog\n idCategory\n categorieLaw\n idBestLowerProduct\n nameBestLowerProduct\n }\n }\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_61805838
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/store/context/ProductContext.tsx from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { createContext, useReducer } from 'react';\nimport { ProductReducer } from './../reducers/ProductReducer';\n\nconst initialState = {\n from: 1,\n to: 5,\n currentPage: 1,\n totalPages: 1,\n totalItems: 1,\n limit: 5,\n params: \"\",\n statements: []\n}\n\nexport const ProductContext = createContext<{\n state: ProductContext;\n dispatch: React.Dispatch<any>;\n}>({\n state: initialState,\n dispatch: () => null\n});\n\nexport const ProductProvider: React.FC = ({ children }: any) => {\n const [state, dispatch] = useReducer(ProductReducer, initialState);\n return (\n <ProductContext.Provider value={{ state, dispatch }}>\n {children}\n </ProductContext.Provider>\n )\n}\n\n```"
}
] |
code_admin-ley-gondolas-arg_9b1606d6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of admin-ley-gondolas-arg/react/store/reducers/ProductReducer.ts from the admin-ley-gondolas-arg VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const ProductReducer = (state: ProductContext, action: any) => {\n\n switch (action.type) {\n case 'INCREASE_PAGE':\n return {\n ...state,\n from: state.from + state.limit,\n to: state.to + state.limit,\n currentPage: state.currentPage + 1,\n }\n case 'DECREASE_PAGE':\n return {\n ...state,\n from: state.from - state.limit,\n currentPage: state.currentPage - 1,\n }\n case 'SET_LIMIT':\n return {\n ...state,\n limit: action.payload,\n from: 1,\n to: action.payload,\n }\n case 'SET_TOTAL_ITEMS':\n return {\n ...state,\n totalItems: action.payload,\n }\n case 'SET_TOTAL_PAGES':\n return {\n ...state,\n totalPages: action.payload,\n }\n case 'SET_PARAMS':\n return {\n ...state,\n params: action.payload,\n currentPage: 1,\n from: 1,\n to: state.limit\n }\n case 'RESET_PAGINATION':\n return {\n ...state,\n params: \"\",\n from: 1,\n to: state.limit,\n currentPage: 1,\n }\n case 'SET_STATEMENTS':\n return {\n ...state,\n statements: action.payload,\n }\n default:\n return state;\n }\n}\n\n```"
}
] |
code_blocks-inspector_ee9e6140
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blocks-inspector/messages/pt.json from the blocks-inspector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"editor.base-store-component.title\": \"IO Base App\",\n \"editor.base-store-component.description\": \"Um componente de demonstração para apps do VTEX IO\",\n \"editor.base-store-component.title.title\": \"Título\",\n \"editor.base-store-component.title.description\": \"Especifique um título personalizado\",\n \"base.title\": \"Olá, Mundo!!\",\n \"base.change-value\": \"Troque seu valor: {value}\",\n \"example\": \"Isto é um exemplo\"\n}\n```"
}
] |
code_blocks-inspector_6eb0d787
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blocks-inspector/messages/en.json from the blocks-inspector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"editor.base-store-component.title\": \"IO Base App\",\n \"editor.base-store-component.description\": \"A demo component for IO apps\",\n \"editor.base-store-component.title.title\": \"Title\",\n \"editor.base-store-component.title.description\": \"Specify a custom title\",\n \"base.title\": \"Hello, World!!\",\n \"base.change-value\": \"Change your value: {value}\",\n \"example\": \"This is an example\"\n}\n```"
}
] |
code_blocks-inspector_974fad5d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blocks-inspector/messages/context.json from the blocks-inspector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"editor.base-store-component.title\": \"Title of IO Base App component\",\n \"editor.base-store-component.description\": \"Description of IO Base App component\",\n \"editor.base-store-component.title.title\": \"Title of title property\",\n \"editor.base-store-component.title.description\": \"Description of title property\",\n \"base.title\": \"Base title message to be shown when title is not provided via CMS\",\n \"base.change-value\": \"Text to be shown beside input component typed value\"\n}\n```"
}
] |
code_blocks-inspector_a41222a6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blocks-inspector/messages/es.json from the blocks-inspector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"editor.base-store-component.title\": \"IO Base App\",\n \"editor.base-store-component.description\": \"Un componente de demostración para aplicaciones IO.\",\n \"editor.base-store-component.title.title\": \"Título\",\n \"editor.base-store-component.title.description\": \"Especifique un título personalizado\",\n \"base.title\": \"¡Hola Mundo!\",\n \"base.change-value\": \"Cambia tu valor: {value}\",\n \"example\": \"Esto es un ejemplo\"\n}\n```"
}
] |
code_blocks-inspector_00ee5783
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blocks-inspector/docs/README.md from the blocks-inspector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# VTEX IO Store Component Template\n\nThis demo component shows you how to make a simple yet complete VTEX IO store component.\n\nIt shows a simple demonstration of the following features:\n\n- Declaring a component interface in `store/interfaces.json`.\n- Declaring a schema to receive props via Storefront.\n- Using the `messages` feature to have localized strings.\n- Using an NPM package like `react-intl`\n- Using another VTEX IO App like `vtex.styleguide`.\n- Using CSS Modules to make your component customizable via CSS on a store theme.\n- Using tachyons tokens to quickly style your components.\n- Creating tests for your VTEX IO app.\n\n```"
}
] |
code_blocks-inspector_a15d5050
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blocks-inspector/react/package.json from the blocks-inspector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"test\": \"vtex-test-tools test\",\n \"lint\": \"tsc --noEmit && eslint --ext ts,tsx .\"\n },\n \"dependencies\": {\n \"@vtex/css-handles\": \"^1.0.0\",\n \"classnames\": \"^2.2.6\",\n \"ramda\": \"^0.26.1\",\n \"react\": \"^16.8.3\",\n \"react-dom\": \"^16.8.3\",\n \"react-intl\": \"^2.7.2\"\n },\n \"devDependencies\": {\n \"@types/classnames\": \"^2.2.7\",\n \"@types/jest\": \"^24.0.18\",\n \"@types/node\": \"^12.7.5\",\n \"@types/prop-types\": \"^15.7.0\",\n \"@types/ramda\": \"^0.26.5\",\n \"@types/react\": \"^16.9.2\",\n \"@vtex/test-tools\": \"^1.1.0\",\n \"apollo-client\": \"^2.5.1\",\n \"eslint\": \"^5.16.0\",\n \"eslint-config-vtex-react\": \"^4.1.0\",\n \"prettier\": \"^1.18.2\",\n \"tslint-eslint-rules\": \"^5.4.0\",\n \"typescript\": \"3.5.2\"\n },\n \"version\": \"0.2.1\"\n}\n\n```"
}
] |
code_blocks-inspector_340540c4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blocks-inspector/react/Example.tsx from the blocks-inspector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useState } from 'react'\nimport { Input } from 'vtex.styleguide'\nimport { FormattedMessage } from 'react-intl'\n\nimport TranslatedTitle from './components/TranslatedTitle'\n\nimport styles from './styles.css'\n\nconst Example: StorefrontFunctionComponent<ExampleProps> = ({ title }) => {\n const [inputValue, setValue] = useState<string | null>(null)\n\n return (\n <div className={`${styles.container} flex flex-column pv6 ph4`}>\n <TranslatedTitle title={title} />\n <div className=\"t-body pv4\">\n <FormattedMessage\n id=\"base.change-value\"\n values={{ value: inputValue || '' }}\n />\n </div>\n <Input\n value={inputValue}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) =>\n setValue(e.target.value)\n }\n />\n </div>\n )\n}\n\ninterface ExampleProps {\n title?: string\n}\n\nExample.schema = {\n title: 'editor.base-store-component.title',\n description: 'editor.base-store-component.description',\n type: 'object',\n properties: {\n title: {\n title: 'editor.base-store-component.title.title',\n description: 'editor.base-store-component.title.description',\n type: 'string',\n default: null,\n },\n },\n}\n\nexport default Example\n\n```"
}
] |
code_blocks-inspector_8eacd0af
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blocks-inspector/store/interfaces.json from the blocks-inspector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"base-store-component\": {\n \"component\": \"Example\"\n }\n}\n```"
}
] |
code_blocks-inspector_b18a5e65
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blocks-inspector/react/typings/storefront.d.ts from the blocks-inspector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { FunctionComponent } from 'react'\n\ndeclare global {\n interface StorefrontFunctionComponent<P = {}> extends FunctionComponent<P> {\n getSchema?(props: P): object\n schema?: object\n }\n\n interface StorefrontComponent<P = {}, S = {}> extends Component<P, S> {\n getSchema?(props: P): object\n schema: object\n }\n}\n\n```"
}
] |
code_blocks-inspector_db588657
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blocks-inspector/react/typings/vtex.render-runtime.d.ts from the blocks-inspector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* Typings for `render-runtime` */\ndeclare module 'vtex.render-runtime' {\n import { Component, ComponentType, ReactElement, ReactType } from 'react'\n\n export interface NavigationOptions {\n page: string\n params?: any\n }\n\n export interface RenderContextProps {\n runtime: {\n navigate: (options: NavigationOptions) => void\n }\n }\n\n interface ExtensionPointProps {\n id: string\n [key: string]: any\n }\n\n export const ExtensionPoint: ComponentType<ExtensionPointProps>\n\n interface ChildBlockProps {\n id: string\n }\n\n export const ChildBlock: ComponentType<ChildBlockProps>\n export const useChildBlock = function({ id: string }): object {}\n\n export const Helmet: ReactElement\n export const Link: ReactType\n export const NoSSR: ReactElement\n export const RenderContextConsumer: ReactElement\n export const canUseDOM: boolean\n export const withRuntimeContext: <TOriginalProps extends {}>(\n Component: ComponentType<TOriginalProps & RenderContextProps>\n ) => ComponentType<TOriginalProps>\n}\n\n```"
}
] |
code_blocks-inspector_520a2a2c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blocks-inspector/react/typings/css.d.ts from the blocks-inspector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const css: any\n export default css\n}\n\n```"
}
] |
code_blocks-inspector_aea5dc19
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blocks-inspector/react/typings/graphql.d.ts from the blocks-inspector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.graphql' {\n import { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\n```"
}
] |
code_blocks-inspector_f405e4a8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blocks-inspector/react/typings/vtex.styleguide.d.ts from the blocks-inspector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide' {\n import { ComponentType } from 'react'\n\n export const Input: ComponentType<InputProps>\n\n interface InputProps {\n [key: string]: any\n }\n}\n\n```"
}
] |
code_blocks-inspector_e765188b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blocks-inspector/react/components/index.tsx from the blocks-inspector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FunctionComponent } from 'react'\nimport { FormattedMessage } from 'react-intl'\n\nconst HelloWorld: FunctionComponent = () => {\n return (\n <div>\n <FormattedMessage id=\"example\" />\n </div>\n )\n}\n\nexport default HelloWorld\n\n```"
}
] |
code_blocks-inspector_712f208b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blocks-inspector/react/components/TranslatedTitle.tsx from the blocks-inspector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FunctionComponent } from 'react'\nimport { FormattedMessage } from 'react-intl'\n\n// The b-s token makes the `b` class be applied only on mobile devices.\nconst TranslatedTile: FunctionComponent<TranslatedTileProps> = ({ title }) => {\n const titleText = title || <FormattedMessage id=\"base.title\" />\n return (\n <div className=\"flex flex-grow-1 justify-center b-s\">\n <span className=\"t-heading-4\">{titleText}</span>\n </div>\n )\n}\n\ninterface TranslatedTileProps {\n title?: string\n}\n\nexport default TranslatedTile\n\n```"
}
] |
code_blocks-inspector_be928a52
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of blocks-inspector/react/__tests__/index.test.tsx from the blocks-inspector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { render } from '@vtex/test-tools/react'\nimport Component from '../components/index'\n\ndescribe('HelloWorld Component', () => {\n const { getByText } = render(<Component />)\n\n it('should render the example in TypeScript', () => {\n expect(getByText(/This is an example/)).toBeDefined()\n })\n})\n\n```"
}
] |
code_outbrain_a3ec2ad9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of outbrain/docs/README.md from the outbrain VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# Outbrain\n\nOutbrain helps over 1 billion people discover content, products and services that may be of interest to them.\nFor more information please visit, [Outbrain](https://www.outbrain.com/) website.\n\n## App Installation\nOpen the VTEX APP Store and install the Outbrain app on your store.\n\nor\n\nRun the following command:\n\n```sh\nvtex install vtex.outbrain@0.x\n```\n\nNext, open the app settings on your admin and fill the form with your Outbrain information.\n```"
}
] |
code_outbrain_2b8f6f17
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of outbrain/react/index.tsx from the outbrain 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 function handleEvents(e: PixelMessage) {\n switch (e.data.eventName) {\n case 'vtex:pageView': {\n\n }\n default: {\n return\n }\n }\n}\n\nif (canUseDOM) {\n window.addEventListener('message', handleEvents)\n}\n\n```"
}
] |
code_outbrain_ec956226
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of outbrain/react/package.json from the outbrain VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"ramda\": \"^0.26.1\"\n },\n \"devDependencies\": {\n \"@types/graphql\": \"^14.2.0\",\n \"@types/jest\": \"^24.0.11\",\n \"@types/node\": \"^11.13.0\",\n \"@types/ramda\": \"^0.26.5\",\n \"@vtex/test-tools\": \"^1.1.0\",\n \"eslint\": \"^5.16.0\",\n \"eslint-config-vtex-react\": \"^4.1.0\",\n \"prettier\": \"^1.18.2\",\n \"tslint-eslint-rules\": \"^5.4.0\",\n \"typescript\": \"3.5.2\"\n },\n \"version\": \"0.1.0\"\n}\n\n```"
}
] |
code_outbrain_41ad2f46
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of outbrain/store/interfaces.json from the outbrain VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"pixel.outbrain\": {\n \"component\": \"index\"\n }\n}\n\n```"
}
] |
code_outbrain_57d2ba21
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of outbrain/react/typings/events.d.ts from the outbrain VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport interface PixelMessage extends MessageEvent {\n data:\n | ProductViewData\n | ProductClickData\n | OrderPlacedData\n | PageViewData\n | ProductImpressionData\n | AddToCartData\n | 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\nexport interface ProductViewData extends EventData {\n event: 'productView'\n eventName: 'vtex:productView'\n product: Product\n}\n\nexport interface ProductClickData extends EventData {\n event: 'productClick'\n eventName: 'vtex:productClick'\n product: Product\n}\n\nexport interface ProductImpressionData extends EventData {\n event: 'productImpression'\n eventName: 'vtex:productImpression'\n impressions: Impression[]\n product?: Product // deprecated, use impressions list!\n position?: number // deprecated, use impressions list!\n list: string\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_outbrain_7581bc7a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of outbrain/react/typings/vtex.render-runtime.d.ts from the outbrain 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_outbrain_81dfd641
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of outbrain/react/typings/global.d.ts from the outbrain VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface Window extends Window {\n dataLayer: any[]\n}\n\n```"
}
] |
code_calling-commerce-apis-example_e82b229e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of calling-commerce-apis-example/docs/README.md from the calling-commerce-apis-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# Service Example\n\nService Example used in Partner Training Session.\n```"
}
] |
code_calling-commerce-apis-example_7f63553d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of calling-commerce-apis-example/node/service.json from the calling-commerce-apis-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"memory\": 256,\n \"ttl\": 10,\n \"timeout\": 2,\n \"minReplicas\": 2,\n \"maxReplicas\": 4,\n \"workers\": 1,\n \"routes\": {\n \"validateSku\": {\n \"path\": \"/_v/validate-sku/:id\",\n \"public\": true\n },\n \"validateCollection\": {\n \"path\": \"/_v/validate-collection/:id\",\n \"public\": true\n }\n }\n}\n\n```"
}
] |
code_calling-commerce-apis-example_682378f9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of calling-commerce-apis-example/node/package.json from the calling-commerce-apis-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"@vtex/clients\": \"^2.18.0\",\n \"co-body\": \"^6.0.0\",\n \"ramda\": \"^0.25.0\"\n },\n \"devDependencies\": {\n \"@types/co-body\": \"^0.0.3\",\n \"@types/jest\": \"^24.0.18\",\n \"@types/node\": \"^12.0.0\",\n \"@types/ramda\": \"types/npm-ramda#dist\",\n \"@vtex/api\": \"6.45.6\",\n \"@vtex/test-tools\": \"^1.0.0\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"typescript\": \"3.9.7\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty\"\n },\n \"version\": \"0.2.0\"\n}\n\n```"
}
] |
code_calling-commerce-apis-example_c3081fa3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of calling-commerce-apis-example/node/index.ts from the calling-commerce-apis-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { ClientsConfig, ServiceContext, RecorderState } from '@vtex/api'\nimport { method, Service } from '@vtex/api'\n\nimport { Clients } from './clients'\nimport { validateCollectionProps } from './middlewares/validateCollection'\nimport { validateProductTitle } from './middlewares/validateProductTitle'\n\nconst TIMEOUT_MS = 800\n\n// This is the configuration for clients available in `ctx.clients`.\nconst clients: ClientsConfig<Clients> = {\n // We pass our custom implementation of the clients bag, containing the Status client.\n implementation: Clients,\n options: {\n // All IO Clients will be initialized with these options, unless otherwise specified.\n default: {\n retries: 2,\n timeout: TIMEOUT_MS,\n },\n },\n}\n\ndeclare global {\n // We declare a global Context type just to avoid re-writing ServiceContext<Clients, State> in every handler and resolver\n type Context = ServiceContext<Clients, State>\n\n // The shape of our State object found in `ctx.state`. This is used as state bag to communicate between middlewares.\n interface State extends RecorderState {\n id: number\n }\n}\n\n// Export a service that defines route handlers and client options.\nexport default new Service({\n clients,\n routes: {\n validateSku: method({\n GET: [validateProductTitle],\n }),\n validateCollection: method({\n GET: [validateCollectionProps],\n }),\n },\n})\n\n```"
}
] |
code_calling-commerce-apis-example_490576b8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of calling-commerce-apis-example/node/clients/collection.ts from the calling-commerce-apis-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { JanusClient } from '@vtex/api'\n\nimport type { Collection } from '../typings/collection'\n\nexport class CollectionClient extends JanusClient {\n public async getCollection(collectionId: string) {\n const collection = await this.http.get<Collection>(\n `/api/catalog/pvt/collection/${collectionId}`,\n {\n headers: { VtexIdclientAutCookie: this.context.authToken },\n }\n )\n\n return collection\n }\n}\n\n```"
}
] |
code_calling-commerce-apis-example_0d53e8df
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of calling-commerce-apis-example/node/clients/index.ts from the calling-commerce-apis-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\nimport { Catalog } from '@vtex/clients'\n\nimport { CollectionClient } from './collection'\n\n// Extend the default IOClients implementation with our own custom clients.\nexport class Clients extends IOClients {\n public get catalog() {\n return this.getOrSet('catalog', Catalog)\n }\n\n public get collection() {\n return this.getOrSet('collection', CollectionClient)\n }\n}\n\n```"
}
] |
code_calling-commerce-apis-example_1b406b1a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of calling-commerce-apis-example/node/typings/collection.d.ts from the calling-commerce-apis-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport interface Collection {\n Id: number\n Name: string\n Description: string\n Searchable: boolean\n Highlight: boolean\n DateFrom: string\n DateTo: string\n TotalProducts: number\n Type: string\n}\n\n```"
}
] |
code_calling-commerce-apis-example_ea6259f3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of calling-commerce-apis-example/node/middlewares/validateProductTitle.ts from the calling-commerce-apis-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { validateSku } from '../utils/validateSku'\n\nexport async function validateProductTitle(\n ctx: Context,\n next: () => Promise<unknown>\n) {\n const {\n vtex: {\n route: {\n params: { id },\n },\n },\n clients: { catalog },\n } = ctx\n\n console.info('Received sku id:', id)\n\n const sku = await catalog.getSkuById(id.toString())\n\n if (!sku) {\n ctx.status = 404\n\n return\n }\n\n console.info('Sku:', sku)\n\n ctx.status = 200\n ctx.body = {\n skuId: sku.Id,\n name: sku.Name,\n result: validateSku(sku),\n }\n ctx.set('Cache-Control', 'no-cache')\n\n await next()\n}\n\n```"
}
] |
code_calling-commerce-apis-example_d7c3bfe3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of calling-commerce-apis-example/node/middlewares/validateCollection.ts from the calling-commerce-apis-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { validateCollection } from '../utils/validateCollection'\n\nexport async function validateCollectionProps(\n ctx: Context,\n next: () => Promise<unknown>\n) {\n const {\n vtex: {\n route: {\n params: { id },\n },\n },\n clients: { collection },\n } = ctx\n\n console.info('Received collection id:', id)\n\n const col = await collection.getCollection(id.toString())\n\n if (!col) {\n ctx.status = 404\n\n return\n }\n\n console.info('Collection:', col)\n\n ctx.status = 200\n ctx.body = {\n id: col.Id,\n description: col.Description,\n result: validateCollection(col),\n }\n ctx.set('Cache-Control', 'no-cache')\n\n await next()\n}\n\n```"
}
] |
code_calling-commerce-apis-example_26b13816
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of calling-commerce-apis-example/node/utils/validateCollection.ts from the calling-commerce-apis-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { Collection } from '../typings/collection'\n\nexport const validateCollection = (collection: Collection) => {\n if (collection.TotalProducts < 5) {\n return `A coleção é muito pequena, possui menos de 5 produtos! (${collection.TotalProducts} produtos).`\n }\n\n return 'A coleção está otimizada!'\n}\n\n```"
}
] |
code_calling-commerce-apis-example_94bc0155
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of calling-commerce-apis-example/node/utils/validateSku.ts from the calling-commerce-apis-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { GetSkuResponse } from '@vtex/clients'\n\nexport const validateSku = (sku: GetSkuResponse) => {\n if (sku.Name.length < 20) {\n return `O nome do Sku está muito curto! (${sku.Name.length} characteres). O nome deve possuir entre 20 e 80 caracteres.`\n }\n\n if (sku.Name.length > 80) {\n return `O nome do Sku está muito longo! (${sku.Name.length} characteres). O nome deve possuir entre 20 e 80 caracteres.`\n }\n\n return 'O nome do Sku está otimizado!'\n}\n\n```"
}
] |
code_calling-commerce-apis-example_10811c96
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of calling-commerce-apis-example/node/__tests__/simple.test.ts from the calling-commerce-apis-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n// You can import your files here for testing them\n//\n// More info: https://github.com/sapegin/jest-cheat-sheet\n\ndescribe('simpleTest', () => {\n it('one test case', async () => {\n expect(0.2 + 0.1).not.toBe(0.3)\n })\n})\n\n```"
}
] |
code_graphql-example_60be7715
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/docs/README.md from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# GraphQL Example\n\nA reference app implementing a VTEX IO service with GraphQL resolvers.\n\n\n\nWe use [**Apollo Server**](https://www.apollographql.com/docs/apollo-server/) as the underlying framework along with some tweaks for our platform.\n\nFor communicating with external services or other VTEX IO apps, we use the [**node-vtex-api**](https://github.com/vtex/node-vtex-api), a VTEX set of utilities for Node services. You can import this package using NPM from `@vtex/api` (already imported on this project)\n\n**Start from `graphq/schema.graphql` and `node/index.ts` and follow the comments and imports!**\n\nWhen _linking_ a GraphQL app, our CLI will automatically provide you a **[GraphiQL](https://github.com/graphql/graphiql) endpoint**, for you to test the functionalities. You can also access a specific app's GraphiQL through the **GraphQL IDE** section on the admin site (as long as the [admin-graphql-ide](https://github.com/vtex-apps/admin-graphql-ide) app is installed on that account).\n\nQueries, mutations and types defined on the `schema.graphql` will have theirs implementation on the `Service` object exported on `node/index.ts`.\n\n> For more information about our GraphQL services, check [**graphql-server**](https://github.com/vtex/graphql-server) and its _Wiki_ (VTEX internal only).\n\n## About GraphQL\n\nIt's important to understand what GraphQL is and how it compares with other popular API standards, such as REST.\n\nThere are many resources out there that can help understand the basics, so let's list a few of them here:\n\n- [GraphQL website](http://graphql.org/learn/)\n- [How to GraphQL](https://www.howtographql.com/basics/1-graphql-is-the-better-rest/)\n\n## Recipes\n\n### Configuring cache for specific queries\n\nCaching is one of the most important strategies for making applications **fast and responsive**. This is achieved by setting **cache control hints** in the GraphQL schema. Our GraphQL Server computes a cache expiration date by combining `@cacheControl` declarations from the fields returned by a specific request, whereas the props `maxAge` and `scope` can be defined. It errs on the safe side for requests with multiple `@cacheControl` declarations, so shorter `maxAge` results override longer, and `PRIVATE` scope overrides `PUBLIC`.\n\n- There are currently tree possible `maxAge`s _(LONG, MEDIUM and SHORT)_ and two possible `scope`s _(PRIVATE and PUBLIC)_.\n\nSuppose that we want to create a simple catalog app that has two types, `type Product` and `type Order`. Since products don't change quickly throughout the day and anyone can see them, they can be cached with a maxAge `LONG` in a `PUBLIC` scope. Order, on the other hand, is a per user entity and should have a PRIVATE scope. To achieve this behavior, the following annotations must be included to the schema\n\n```graphql\ntype Product @cacheControl(maxAge: LONG, scope: PUBLIC) {\n id: ID!\n name: String\n description: String\n}\n\ntype Order @cacheControl(scope: PRIVATE) {\n id: ID!\n statusDescription: String\n description: String\n}\n\ntype Query {\n listOrders: [Order]\n listProducts: [Product]\n}\n```\n\n> **Note** to know more on how these cache hints work, take a look at the [Apollo Server docs for caching](https://www.apollographql.com/docs/apollo-server/performance/caching/)\n\nSince our GraphQL implementation uses a CDN (Cloud-Front) to cache query responses, `PRIVATE` queries should land in a different endpoint from `PUBLIC` ones. Each endpoint have some configurations tweaks in the CDN and may lead to different behaviors. For example, to receive cookies in the backend, you need to be in a private route.\n\n### Caching requests when using public endpoint\n\nRequests to `graphql-server` using public endpoints are not cacheable, so they are given `cache-control` with `no-cache`. The way to override this behavior is to send the header `'x-vtex-cacheable': 'true'` on request.\n\n### Resolving conflicts (`@context` directive)\n\nLet's say that another app called `rewards-graphql` also defines a field named `products` inside the `Query` type. If both apps live on the same workspace/account it will cause some requests to fail, since our GraphQL server won't be able to automatically figure out which app should resolve that query.\n\nFor this use case we support a special directive called `@context`, which GraphQL clients can use to provide additional information to resolve these kind of conflicts.\n\n#### Specifying provider\n\nIf the client knows about a conflict (or in any case, for precaution), it can specify which app defined the field it's requesting. In the example we've mentioned above, with that new `rewards-graphql` app, the client could send the query like this:\n\n```graphql\nquery getProducts {\n products @context(provider: \"vtex.products-graphql\") {\n name\n }\n}\n```\n\nThis declares that we want to use the definition of `products` from `products-graphql`, not from `rewards-graphql`, so that it can properly rename and execute it.\n\n#### Specifying sender\n\nIn some cases it might be hard for a client to know that a conflict can happen, since an app doesn't know about all other apps that may be running on a workspace, it only knows about its own direct dependencies. At the same time, we'd like to restrict apps so that they can only access types/fields defined by apps they directly depend on.\n\nBoth these problems can be solved by using the `@context` directive again, but this time using the `sender` argument. Basically, apps sending requests to `graphql-server` should include this directive announcing their names, so that it can restrict which parts of the schema can be accessed. Note that restricting the access also makes it easier for apps to know exactly when they'd need to specify a `provider`, since conflicts with apps they don't know about will never happen.\n\nSo, let's say that an app called `client-app`, that depends only on `products-graphql` is sending a GraphQL request. Even if `rewards-graphql` is running in the current workspace it won't need to specify the provider anymore, just set the `sender`.\n\n```graphql\n{\n products @context(sender: \"vtex.client-app@1.2.3\") {\n name\n }\n}\n```\n\n**Note:** If you are requesting GraphQL data from React apps that uses the `react` builder the `sender` argument **is already baked** into every request it makes.\n\n## 🗎 GraphQL documentation\n\nThis project use as dependency the [graphql-markdown](https://github.com/exogen/graphql-markdown) project, to generate markdown documentation based on GraphQL schema.\n\nDo you need run this command below, in your terminal, to generate the documentation:\n\n```bash\nyarn graphql-markdown\n```\n\n## Splunk Dashboard\n\nWe have an (for now, VTEX-only, internal) Splunk dashboard to show all metrics related to your app. You can find it at:\n\nhttps://splunk72.vtex.com/en-US/app/vtex_io_apps/node_app_metrics\n\nAfter linking this app and making some requests, you can select `vtex.graphql-example` and see the metrics for your app. **Don't forget to check the box Development, as you are linking your app in a development workspace**.\n\n```"
}
] |
code_graphql-example_5ab3da6c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/graphql/schema.graphql from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\n# To really understand GraphQL, go to https://graphql.org/learn/\n\ntype Book {\n authors: [String!]\n cacheId: ID!\n id: ID!\n name: String\n}\n\n# It is necessary to generate input types for creating books\n# ref: http://graphql.org/graphql-js/mutations-and-input-types/\ninput BookInput {\n authors: [String!]\n cacheId: ID\n id: ID\n name: String\n}\n\ntype Query {\n # Cache control can only be set at root fields\n book(id: ID!): Book\n @auth(scope: PUBLIC)\n books(from: Int = 0, to: Int = 4): [Book] @cacheControl(scope: PUBLIC, maxAge: SHORT)\n @auth(scope: PUBLIC)\n total: Int\n @auth(scope: PUBLIC)\n\n \"\"\"\n Returns a markdown source given an id\n \"\"\"\n source(id: ID!): String\n @auth(scope: PUBLIC)\n}\n\ntype Mutation {\n # You should always return the whole object in a mutation, not only a boolean. This will help in browser caching\n delete(id: String): Boolean\n @auth(scope: PUBLIC)\n editBook(id: ID!, book: BookInput!): Book\n @auth(scope: PUBLIC)\n newBook(book: BookInput!): Book\n @auth(scope: PUBLIC)\n}\n\n```"
}
] |
code_graphql-example_e0ea717e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/service.json from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"memory\": 256,\n \"ttl\": 10,\n \"timeout\": 1,\n \"minReplicas\": 2,\n \"maxReplicas\": 5\n}\n\n```"
}
] |
code_graphql-example_2326b36b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/package.json from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"ramda\": \"^0.26.1\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^20.0.0\",\n \"@types/ramda\": \"types/npm-ramda#dist\",\n \"@vtex/api\": \"^7.0.0\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"typescript\": \"5.5.3\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit && tslint -c tslint.json './**/*.ts'\"\n },\n \"version\": \"0.4.0\"\n}\n\n```"
}
] |
code_graphql-example_85c27a77
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/index.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { ParamsContext, RecorderState, ServiceContext } from '@vtex/api'\nimport { Service } from '@vtex/api'\nimport { prop } from 'ramda'\n\nimport { Clients } from './clients'\nimport { book } from './resolvers/book'\nimport { books } from './resolvers/books'\nimport { deleteBook } from './resolvers/delete'\nimport { editBook } from './resolvers/editBook'\nimport { newBook } from './resolvers/newBook'\nimport { source } from './resolvers/source'\nimport { total } from './resolvers/total'\n\nconst MEDIUM_TIMEOUT_MS = 2 * 1000\n\ndeclare global {\n // We declare a global Context type just to avoid re-writing ServiceContext<Clients, State> in every handler and resolver\n type Context = ServiceContext<Clients>\n}\n\n// Export a service that defines resolvers and clients' options\nexport default new Service<Clients, RecorderState, ParamsContext>({\n clients: {\n implementation: Clients,\n options: {\n default: {\n timeout: MEDIUM_TIMEOUT_MS,\n },\n },\n },\n graphql: {\n resolvers: {\n Book: {\n cacheId: prop('id'),\n },\n Mutation: {\n delete: deleteBook,\n editBook,\n newBook,\n },\n Query: {\n book,\n books,\n source,\n total,\n },\n },\n },\n})\n\n```"
}
] |
code_graphql-example_6ae2bb81
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/index.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\n\nimport { BookClient } from './book'\nimport { MarkdownClient } from './markdown'\n\nexport class Clients extends IOClients {\n public get book() {\n return this.getOrSet('book', BookClient)\n }\n\n public get markdown() {\n return this.getOrSet('markdown', MarkdownClient)\n }\n}\n\n```"
}
] |
code_graphql-example_4c577b83
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/typings/markdown.d.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.md' {\n const content = ''\n\n export default content\n}\n\n```"
}
] |
code_graphql-example_6026b475
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/typings/custom.d.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport interface Book {\n authors: string[]\n cacheId?: string\n id: string\n name: string\n}\n\nexport interface BookInput {\n name: Book['name']\n authors: Book['authors']\n}\n\nexport type Maybe<T> = T | void\n\n```"
}
] |
code_graphql-example_ef2758ea
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/resolvers/source.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface Args {\n id: string\n}\n\nexport const source = (\n _: any,\n { id }: Args,\n { clients: { markdown } }: Context\n) => markdown.get(id)\n\n```"
}
] |
code_graphql-example_8b763338
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/resolvers/book.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const book = async (\n _: any,\n { id }: { id: string },\n { clients: { book: bookClient } }: Context\n) => bookClient.book(id)\n\n```"
}
] |
code_graphql-example_a8c740c5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/resolvers/total.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const total = (\n _: any,\n __: any,\n { clients: { book: booksClient } }: Context\n) => booksClient.total()\n\n```"
}
] |
code_graphql-example_4778aaa0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/resolvers/books.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface Args {\n from: number\n to: number\n}\n\nexport const books = (\n _: any,\n args: Args,\n { clients: { book: booksClient } }: Context\n) => booksClient.books(args)\n\n```"
}
] |
code_graphql-example_3c583e01
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/resolvers/newBook.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { BookInput } from '../typings/custom'\n\ninterface Args {\n book: BookInput\n}\n\nexport const newBook = (\n _: any,\n { book }: Args,\n { clients: { book: booksClient } }: Context\n) => booksClient.newBook(book)\n\n```"
}
] |
code_graphql-example_9f1e5a43
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/resolvers/editBook.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { BookInput } from '../typings/custom'\n\ninterface EditBookArg {\n id: string\n book: BookInput\n}\n\nexport const editBook = (\n _: any,\n { id, book }: EditBookArg,\n { clients: { book: booksClient } }: Context\n) => booksClient.editBook(id, book)\n\n```"
}
] |
code_graphql-example_e67bcced
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/resolvers/delete.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface Args {\n id: string\n}\n\nexport const deleteBook = (\n _: any,\n { id }: Args,\n { clients: { book: booksClient } }: Context\n) => booksClient.delete(id)\n\n```"
}
] |
code_graphql-example_5cc9af2a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/markdown/mock.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport automaticCacheUpdates from './docs/automaticCacheUpdates'\nimport dynamicPagination from './docs/dynamicPagination'\nimport home from './docs/home'\nimport previewWithCachedData from './docs/previewWithCachedData'\nimport staticPagination from './docs/staticPagination'\nimport styleguide from './docs/styleguide'\n\ninterface MarkdownData {\n [key: string]: string\n}\n\nconst mock: MarkdownData = {\n 'automatic-cache-updates/after': automaticCacheUpdates.after,\n 'automatic-cache-updates/before': automaticCacheUpdates.before,\n 'dynamic-pagination/after': dynamicPagination.after,\n 'dynamic-pagination/before': dynamicPagination.before,\n 'home/main': home.main,\n 'preview-with-cached-data/after': previewWithCachedData.after,\n 'preview-with-cached-data/before': previewWithCachedData.before,\n 'static-pagination/after': staticPagination.after,\n 'static-pagination/before': staticPagination.before,\n 'styleguide/after': styleguide.after,\n 'styleguide/before': styleguide.before,\n}\n\nexport default mock\n\n```"
}
] |
code_graphql-example_b1b826bf
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/markdown/index.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { ExternalClient } from '@vtex/api'\n\nimport mock from './mock'\n\nexport class MarkdownClient extends ExternalClient {\n private db = mock\n\n constructor(context: IOContext, options?: InstanceOptions) {\n super('http://example.com', context, options)\n }\n\n public get = (id: string) => this.db[id]\n}\n\n```"
}
] |
code_graphql-example_9235328e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/book/mock.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { Book } from '../../typings/custom'\n\nconst mock: Book[] = [\n {\n authors: ['Default Author 1'],\n id: '0',\n name: 'Default Book 1',\n },\n {\n authors: ['Default Author 2'],\n id: '1',\n name: 'Default Book 2',\n },\n {\n authors: ['Default Author 3'],\n id: '2',\n name: 'Default Book 3',\n },\n {\n authors: ['Default Author 4'],\n id: '3',\n name: 'Default Book 4',\n },\n {\n authors: ['Default Author 5'],\n id: '4',\n name: 'Default Book 5',\n },\n {\n authors: ['Default Author 11'],\n id: '10',\n name: 'Default Book 11',\n },\n {\n authors: ['Default Author 12'],\n id: '11',\n name: 'Default Book 12',\n },\n {\n authors: ['Default Author 13'],\n id: '12',\n name: 'Default Book 13',\n },\n {\n authors: ['Default Author 14'],\n id: '13',\n name: 'Default Book 14',\n },\n {\n authors: ['Default Author 15'],\n id: '14',\n name: 'Default Book 15',\n },\n {\n authors: ['Default Author 21'],\n id: '20',\n name: 'Default Book 21',\n },\n {\n authors: ['Default Author 22'],\n id: '21',\n name: 'Default Book 22',\n },\n {\n authors: ['Default Author 23'],\n id: '22',\n name: 'Default Book 23',\n },\n {\n authors: ['Default Author 24'],\n id: '23',\n name: 'Default Book 24',\n },\n {\n authors: ['Default Author 25'],\n id: '24',\n name: 'Default Book 25',\n },\n]\n\nexport default mock\n\n```"
}
] |
code_graphql-example_dbb852a8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/book/index.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { ExternalClient } from '@vtex/api'\nimport { find, findIndex, propEq } from 'ramda'\n\nimport type { Book, BookInput, Maybe } from '../../typings/custom'\nimport mock from './mock'\n\nexport class BookClient extends ExternalClient {\n private db = mock\n\n constructor(context: IOContext, options?: InstanceOptions) {\n super('http://example.com', context, options)\n }\n\n public book = (id: string) => find(propEq('id', id), this.db)\n\n public books = ({ from, to }: { from: number; to: number }) =>\n this.db.slice(Math.max(from, 0), Math.min(to, this.db.length))\n\n public delete = (id: string) => {\n const foundIndex = findIndex(propEq('id', id), this.db)\n\n if (foundIndex >= 0 && foundIndex < this.db.length) {\n const newDb = [\n ...this.db.slice(0, foundIndex),\n ...this.db.slice(foundIndex + 1),\n ]\n\n this.db = newDb\n\n return true\n }\n\n return false\n }\n\n public editBook = (id: string, book: BookInput): Maybe<Book> => {\n const foundIndex = findIndex(propEq('id', id), this.db)\n\n if (foundIndex >= 0 && foundIndex < this.db.length) {\n const foundBook = this.db[foundIndex]\n\n this.db[foundIndex] = { ...foundBook, ...book }\n\n return this.db[foundIndex]\n }\n }\n\n public newBook = (book: BookInput): Book => {\n const newBook = {\n ...book,\n id: this.db.length.toString(),\n }\n\n const newDb = [newBook, ...this.db]\n\n this.db = newDb\n\n return newBook\n }\n\n public total = () => this.db.length\n}\n\n```"
}
] |
code_graphql-example_96df3432
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/markdown/docs/home/main.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport default `\n # VTEX IO Web Framework Best-Practices\n\n ## Welcome\n While coding apps, developers face common problems and patterns that are not strictly related to their business logic, like pagination and editing entities. To help you focuss more on your business logic, and less on reinventing the wheel, this repo was created aimming to contain all common patterns, all while respecting **VTEX IO Web Framework's** best practices and performance.\n\n ## What can I learn in this code base ?\n In this repo you will learn how to:\n\n - Use [VTEX Styleguide](https://styleguide.vtex.com/)\n - Internationalize your app\n - GraphQL (Back-End):\n - Architecture a GraphQL Schema\n - Create resolvers\n - Use Datasources\n - Front-End\n - Use extension points\n - Automatic cache updates\n - Preview with GraphQL cache\n - Pagination\n\n ## Can I use this repo in my projects ?\n Sure! this repository was designed with this goal in mind. If you are not able to easily port this code into your app, feel free to make a PR and start [contributing](https://github.com/vtex-apps/awesome-io#contributing).\n\n ## Getting Started\n This repo is an IO app like any other, so getting started is easy, just clone it, open your terminal, and type:\n\n \\`\\`\\`sh\n vtex link\n \\`\\`\\`\n\n just enter the \\`/guide\\` route and play a little\n\n ## How to read this repo\n An antipattern present in this repo is that the front and back-end code are in the same app. Usually they are split into different apps, given their differences in development cycle. Also, if your project is big enought, it's suggested you split your front-end app into a components app and a **Pages** app (app that places and instanciates these components). For the sake of simplicity and example efficiency, all these apps are joined into this one\n\n ### Basic architecture\n Since *web-framework-guide* is a VTEX IO app like any other, its folder structure is well known. In the root folder you can find a \\`manifest.json\\`, containing all of the app's metadata, like name, vendor, version etc. Also, you will find the following folders, each one matching it's corresponding builder\n\n - node - *where you actually implement your back-end app*\n - graphql - *where you define your graphql schema*\n - react - *where you write your react components*\n - pages - *where you place and instanciate the components*\n\n ### What if I didn't understand something ?\n If you didn't understand something or if you think this doc is incomplete, please open an issue in GitHub!\n`\n\n```"
}
] |
code_graphql-example_f7b430ac
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/markdown/docs/home/index.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport main from './main'\n\nexport default {\n main,\n}\n\n```"
}
] |
code_graphql-example_461142f4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/markdown/docs/staticPagination/after.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport default `\n The most important part of the pagination implementation is coded in the \\`PaginationController\\` component.\n\n The pagination starts by querying the total number of items and the first 5 items of the list.\n\n When the \\`next page\\` button is clicked, the same query used for listing the first 5 elements is reused with the [fetchMore](https://www.apollographql.com/docs/react/features/pagination.html#fetch-more) function. The \\`fetchMore\\` function will then make a new query, bringing 5 more elements.\n\n After the loading state is finished, the \\`updateQuery\\` function is run, updating the Apollo Client's InMemory cache and concatenating the result into a single list.\n`\n\n```"
}
] |
code_graphql-example_521ed6a1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/markdown/docs/staticPagination/index.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport after from './after'\nimport before from './before'\n\nexport default {\n after,\n before,\n}\n\n```"
}
] |
code_graphql-example_3b45b1c7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/markdown/docs/staticPagination/before.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport default `\n # Static Pagination\n\n In this example you will learn how to create a static, offset-based, pagination, i.e. how to paginate a list of items that DO NOT support adding or removing an element from the list. If you want to know how to handle a list that do support adding and removing elements, please check the \\`Dynamic Pagination\\` topic\n\n This example is a classical list-detail problem, where there is a list rendered in rows. Each row, when clicked, takes the user to a details page where more info can be seen about the element.\n\n In this topic, we use the detail component of the prior topic and focus on the list pagination.\n`\n\n```"
}
] |
code_graphql-example_f1933ce3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/markdown/docs/dynamicPagination/after.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport default `\n The most important components in this example are the \\`DeleteButton\\` and \\`NewElement\\`, that handle deletion and creation of a list element respectively.\n\n Their code is really similar and takes advantage of the React Apollo Mutation's \\`update\\` method for updating the list in Apollo Client's InMemory cache.\n\n Basically, the these components make the deletion/creation mutation. In case of the mutation completing successfully, the book list is updated in the cache, removing or adding the altered element.\n\n When going back to the list view. The pagination component will render the list with the correct mutation applied and the element will be created/deleted.\n`\n\n```"
}
] |
code_graphql-example_45fe022c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/markdown/docs/dynamicPagination/index.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport after from './after'\nimport before from './before'\n\nexport default {\n after,\n before,\n}\n\n```"
}
] |
code_graphql-example_1696b305
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/markdown/docs/dynamicPagination/before.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport default `\n # Dynamic Pagination\n\n In this example you will learn how to create a dinamic, offset-based, pagination, i.e. how to paginate a list of items that DO support adding and removing an elements from the list.\n\n This example is a continuation of the *Static Pagination* topic and understanding the \\`PaginationController\\` component is a pre-requisite.\n\n As in the *Static Pagination* topic, we won't focuss on the detail, but rather on adding and removing and element from the list.\n`\n\n```"
}
] |
code_graphql-example_a4b86653
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/markdown/docs/previewWithCachedData/after.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport default `\n Cool! But how is it coded?\n\n The implementation can be seen in \\`PreviewWithCachedData\\` component.\n\n The main ideia is to use the book query's loading state as a switcher between using the cached data or reading from the incoming query data.\n\n If the query is in loading state, the function \\`readFromApolloCache\\` is executed. It reads a Fragment from the Apollo Client's InMemory cache and the renderization occurs as usual.\n\n One important hint is using the \\`buildCacheLocator\\` function exported by \\`render\\`. This function takes as input the app id, the type and id of the fragment,and generates the Apollo Client's InMemory cache ID of the object we want to read the fragment from.\n\n When the book's query finishes loading, its data is used for rendering the final component.\n`\n\n```"
}
] |
code_graphql-example_d9f643f3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/markdown/docs/previewWithCachedData/index.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport after from './after'\nimport before from './before'\n\nexport default {\n after,\n before,\n}\n\n```"
}
] |
code_graphql-example_29e197cd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/markdown/docs/previewWithCachedData/before.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport default `\n # Preview with Cached Data\n\n In this example you will learn how to\n [Reuse Cached Data](https://www.apollographql.com/docs/react/advanced/caching.html#readfragment).\n\n This technique uses [Apollo Client's InMemory cache](https://www.apollographql.com/docs/react/advanced/caching.html#smooth-scroll-top) and enables a greater user experience by reusing the data already present in the browser's local cache for making content preview.\n\n This example shows how this feature can improve the user's experience. It starts by querying a book list, which is shown below.\n\n Clicking in a row will take you to the detail page. The detail page needs more data than the available in the list, like the author's name.\n\n We can deliver a better user experience by previewing the edition component with the already present book's name in the browser's cache.\n\n To make our code more simple, we do not allow the edition of any of the book's properties before the query bringing the whole book info is completed, so the preview info is shown with the input disabled.\n`\n\n```"
}
] |
code_graphql-example_11c1922d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/markdown/docs/styleguide/after.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport default `\n To know more about the available components, visit the [**Styleguide** page](styleguide.vtex.com).\n`\n\n```"
}
] |
code_graphql-example_68f37060
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/markdown/docs/styleguide/index.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport after from './after'\nimport before from './before'\n\nexport default {\n after,\n before,\n}\n\n```"
}
] |
code_graphql-example_dac0c024
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of graphql-example/node/clients/markdown/docs/styleguide/before.ts from the graphql-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport default `\n # Using VTEX Styleguide\n\n To use **VTEX Styleguide**, you first need to add it as a dependency in your app's \\`manifest.json\\`\n\n \\`\\`\\`json\n {\n \"dependencies\": {\n \"vtex.styleguide\": \"8.x\"\n }\n }\n \\`\\`\\`\n\n after adding it as a dependency, you can import components from **Styleguide** in React components like so:\n\n \\`\\`\\`tsx\n import React from 'react'\n import { Button } from 'vtex.styleguide'\n\n const MyAwesomeComponent: React.SFC = () => (\n <Button>Click me</Button>\n )\n \\`\\`\\`\n\n The code above is shown running below:\n`\n\n```"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.