id
stringlengths 12
53
| messages
listlengths 3
3
|
|---|---|
code_buybox-resolver_c92b18b2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of buybox-resolver/node/typings/Catalog.ts from the buybox-resolver VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface SearchProduct {\n productId: string\n productName: string\n brand: string\n brandId: number\n linkText: string\n productReference: string\n categoryId: string\n productTitle: string\n metaTagDescription: string\n clusterHighlights: Record<string, string>\n productClusters: Record<string, string>\n searchableClusters: Record<string, string>\n categories: string[]\n categoriesIds: string[]\n link: string\n description: string\n items: SearchItem[]\n itemMetadata: {\n items: SearchMetadataItem[]\n }\n titleTag: string\n Specifications?: string[]\n allSpecifications?: string[]\n allSpecificationsGroups?: string[]\n completeSpecifications?: CompleteSpecification[]\n skuSpecifications?: SkuSpecification[]\n}\n\ninterface SearchItem {\n itemId: string\n name: string\n nameComplete: string\n complementName: string\n ean: string\n referenceId: Array<{ Key: string; Value: string }>\n measurementUnit: string\n unitMultiplier: number\n modalType: any | null\n images: SearchImage[]\n Videos: string[]\n variations: string[]\n sellers: Seller[]\n attachments: Array<{\n id: number\n name: string\n required: boolean\n domainValues: string\n }>\n isKit: boolean\n kitItems?: Array<{\n itemId: string\n amount: number\n }>\n}\n\ninterface CompleteSpecification {\n Values: Array<{\n Id: string\n Position: number\n Value: string\n }>\n Name: string\n Position: number\n IsOnProductDetails: boolean\n FieldId: string\n}\n\ninterface SkuSpecification {\n field: SKUSpecificationField\n values: SKUSpecificationValue[]\n}\n\ninterface SKUSpecificationField {\n name: string\n id: string\n}\n\ninterface SKUSpecificationValue {\n name: string\n id: string\n fieldId: string\n}\n\ninterface SearchImage {\n imageId: string\n imageLabel: string | null\n imageTag: string\n imageUrl: string\n imageText: string\n}\n\ninterface SearchInstallment {\n Value: number\n InterestRate: number\n TotalValuePlusInterestRate: number\n NumberOfInstallments: number\n PaymentSystemName: string\n PaymentSystemGroupName: string\n Name: string\n}\n\ninterface CommertialOffer {\n DeliverySlaSamplesPerRegion: Record<\n string,\n { DeliverySlaPerTypes: any[]; Region: any | null }\n >\n Installments: SearchInstallment[]\n DiscountHighLight: any[]\n GiftSkuIds: string[]\n Teasers: any[]\n BuyTogether: any[]\n ItemMetadataAttachment: any[]\n Price: number\n ListPrice: number\n PriceWithoutDiscount: number\n RewardValue: number\n PriceValidUntil: string\n AvailableQuantity: number\n Tax: number\n DeliverySlaSamples: Array<{\n DeliverySlaPerTypes: any[]\n Region: any | null\n }>\n GetInfoErrorMessage: any | null\n CacheVersionUsedToCallCheckout: string\n}\n\ninterface Seller {\n sellerId: string\n sellerName: string\n addToCartLink: string\n sellerDefault: boolean\n commertialOffer: CommertialOffer\n}\n\n```"
}
] |
code_buybox-resolver_6bcabb23
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of buybox-resolver/node/utils/index.ts from the buybox-resolver VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { AxiosError } from 'axios'\nimport { AuthenticationError, ForbiddenError, UserInputError } from '@vtex/api'\n\nexport function statusToError(e: AxiosError) {\n if (!e.response) {\n throw e\n }\n\n const { response } = e\n const { status } = response\n\n if (status === 401) {\n throw new AuthenticationError(e)\n }\n\n if (status === 403) {\n throw new ForbiddenError(e)\n }\n\n if (status === 400) {\n throw new UserInputError(e)\n }\n\n throw e\n}\n\n```"
}
] |
code_buybox-resolver_4deb3dc3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of buybox-resolver/node/resolvers/index.ts from the buybox-resolver VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { queries as sellersQueries } from './search'\n\nexport const resolvers = {\n Query: {\n ...sellersQueries,\n },\n}\n\n```"
}
] |
code_buybox-resolver_6c1f6ff7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of buybox-resolver/node/resolvers/search/index.ts from the buybox-resolver VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { NotFoundError, UserInputError } from '@vtex/api'\nimport { head } from 'ramda'\n\ninterface ProductArgs {\n skuId?: string\n salesChannel?: number\n country?: string\n postalCode?: string\n}\n\nexport const queries = {\n sortSellers: async (_: unknown, rawArgs: ProductArgs, ctx: Context) => {\n const {\n clients: { search, checkout },\n vtex: { segment },\n } = ctx\n\n const { skuId, country, postalCode } = rawArgs\n const salesChannel = rawArgs.salesChannel ?? segment?.channel\n\n if (!skuId) {\n throw new UserInputError('No product identifier provided')\n }\n\n const products = await search.productBySku(skuId, salesChannel)\n\n let product: SearchProduct | undefined\n\n if (products.length > 0) {\n product = head(products)\n } else {\n throw new NotFoundError(\n `No product was found with requested ${skuId} ${JSON.stringify(\n rawArgs\n )}`\n )\n }\n\n const item = product?.items.find((i) => i.itemId === skuId)\n\n const requestBody = {\n country,\n postalCode,\n items: item?.sellers.map((s) => {\n return {\n id: item.itemId,\n quantity: 1,\n seller: s.sellerId,\n }\n }),\n } as SimulationPayload\n\n const { logisticsInfo } = await checkout.simulation(requestBody)\n\n const sellerLogisticsInfo = item?.sellers.map((seller, index) => {\n return {\n seller,\n logisticsInfo: logisticsInfo[index],\n }\n })\n\n sellerLogisticsInfo?.sort(\n (a, b) => a.seller.commertialOffer.Price - b.seller.commertialOffer.Price\n )\n\n return { sellers: sellerLogisticsInfo?.map((sli) => sli.seller.sellerId) }\n },\n}\n\n```"
}
] |
code_flex-layout_6dacb9d8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/messages/it-IT.json from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.row.title\": \"Riga\",\n \"admin/editor.column.title\": \"Colonna\",\n \"admin/editor.row.description\": \"Componente a riga della struttura di Flex Layout\",\n \"admin/editor.column.description\": \"Componente a colonna della struttura di Flex Layout\"\n}\n```"
}
] |
code_flex-layout_d90323c8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/messages/bs-BA.json from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.row.title\": \"crwdns90648:0crwdne90648:0\",\n \"admin/editor.column.title\": \"crwdns90650:0crwdne90650:0\",\n \"admin/editor.row.description\": \"crwdns90652:0crwdne90652:0\",\n \"admin/editor.column.description\": \"crwdns90654:0crwdne90654:0\"\n}\n```"
}
] |
code_flex-layout_778af0ea
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/messages/ko-KR.json from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.row.title\": \"행\",\n \"admin/editor.column.title\": \"열\",\n \"admin/editor.row.description\": \"플렉스 레이아웃 구조의 행 구성 요소\",\n \"admin/editor.column.description\": \"플렉스 레이아웃 구조의 열 구성 요소\"\n}\n```"
}
] |
code_flex-layout_ff0eceee
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/messages/ja-JP.json from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.row.title\": \"行\",\n \"admin/editor.column.title\": \"列\",\n \"admin/editor.row.description\": \"フレックスレイアウト構造の行コンポーネント\",\n \"admin/editor.column.description\": \"フレックスレイアウト構造の列コンポーネント\"\n}\n```"
}
] |
code_flex-layout_fff4e319
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/messages/bg-BG.json from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.row.title\": \"Ред\",\n \"admin/editor.column.title\": \"Колона\",\n \"admin/editor.row.description\": \"Редови компонент от гъвкава структура на оформление\",\n \"admin/editor.column.description\": \"Компонент от колона от гъвкава структура на оформление\"\n}\n```"
}
] |
code_flex-layout_82b0c5cf
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/messages/pt.json from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{ \n \"admin/editor.row.title\": \"Linha\",\n \"admin/editor.column.title\": \"Coluna\",\n \"admin/editor.row.description\": \"Componente de Linha para estrutura de layout flex\",\n \"admin/editor.column.description\": \"Componente de Coluna para estrutura de layout flex\",\n \"store/flex-layout.flexLayout-row.aria-label\": \"Linha {sectionId, select, row {de sessão} other {#}}\"\n}\n```"
}
] |
code_flex-layout_0f1cc795
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/messages/en.json from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{ \n \"admin/editor.row.title\": \"Row\",\n \"admin/editor.column.title\": \"Column\",\n \"admin/editor.row.description\": \"Row component of flex layout structure\",\n \"admin/editor.column.description\": \"Column component of flex layout structure\",\n \"store/flex-layout.flexLayout-row.aria-label\": \"Section {sectionId, select, row {row} other {#}}\"\n}\n```"
}
] |
code_flex-layout_5e54be60
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/messages/ro-RO.json from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.row.title\": \"Rând\",\n \"admin/editor.column.title\": \"Coloană\",\n \"admin/editor.row.description\": \"Componenta de rânduri a structurii modului de afișare flexibil\",\n \"admin/editor.column.description\": \"Componenta de coloane a structurii modului de afișare flexibil\"\n}\n```"
}
] |
code_flex-layout_c902825a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/messages/context.json from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{ \n \"admin/editor.row.title\": \"Row\",\n \"admin/editor.column.title\": \"Column\",\n \"admin/editor.row.description\": \"Row component of flex layout structure\",\n \"admin/editor.column.description\": \"Column component of flex layout structure\",\n \"store/flex-layout.flexLayout-row.aria-label\": \"Section {sectionId, select, row {row} other {#}}\"\n}\n```"
}
] |
code_flex-layout_dd00a696
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/messages/de-DE.json from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.row.title\": \"Zeile\",\n \"admin/editor.column.title\": \"Spalte\",\n \"admin/editor.row.description\": \"Zeilenkomponente der Flex-Layoutstruktur\",\n \"admin/editor.column.description\": \"Spaltenkomponente der Flex-Layoutstruktur\"\n}\n```"
}
] |
code_flex-layout_b1fb4ba3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/messages/fr-FR.json from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.row.title\": \"Ligne\",\n \"admin/editor.column.title\": \"Colonne\",\n \"admin/editor.row.description\": \"Composant de la ligne pour l’aménagement de la mise en page flexible\",\n \"admin/editor.column.description\": \"Composant de la colonne pour l’aménagement de la mise en page flexible\"\n}\n```"
}
] |
code_flex-layout_61bbfeb0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/messages/nl-NL.json from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.row.title\": \"Rij\",\n \"admin/editor.column.title\": \"Kolom\",\n \"admin/editor.row.description\": \"Rijcomponent van flex layoutstructuur\",\n \"admin/editor.column.description\": \"Kolomcomponent van flex layoutstructuur\"\n}\n```"
}
] |
code_flex-layout_a04d6a1f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/messages/es.json from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.row.title\": \"Fila\",\n \"admin/editor.column.title\": \"Columna\",\n \"admin/editor.row.description\": \"Componente de Fila para la estructura de layout flex\",\n \"admin/editor.column.description\": \"Componente de Columna para la estructura de layout flex\"\n}\n```"
}
] |
code_flex-layout_0c954c69
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/docs/README.md from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n📢 Don't fork this project. Use, [contribute](https://github.com/vtex-apps/flex-layout), or open issues through [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n\n[](#contributors-)\n\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\n# Flex Layout\n\nFlex Layout is a **layout structure** built within VTEX IO Store Framework. It allows building complex custom layouts using the concept of **rows** and **columns**, setting the desired block structure and positioning in a page.\n\n _Example of a page layout built using Flex Layout, following the one row with two columns model_\n\n## Configuration\n\n**Flex Layout has two basic building blocks**: `flex-layout.row` and `flex-layout.col`. You should **never** use `flex-layout`.\n\nIf you are already familiar with the [`flexbox`](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) layout used in CSS, Flex Layout should be easy to grasp since this is what `flex-layout.row` and `flex-layout.col` are using under the hood.\n\nYou can use **any** array of blocks as children for `flex-layout.row` and `flex-layout.col`.\n\nThe props below support [`responsive-values`](https://github.com/vtex-apps/responsive-values), meaning that you can define different values for the same prop based on device screen size, such as mobile and desktop.\n\n### `flex-layout.row`\n\n| Prop name | Type | Description | Default value |\n| -------------------------- | -------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |\n| `blockClass` | `String` | Block container class. The set value of this prop functions as a block identifier for CSS customizations. ( | `\"\"` |\n| `borderColor` | `String` | The color of the border. | `undefined` |\n| `borderWidth` | `0...5` | A `number` or `string` magnitude for applying the `bw` Tachyons token to the row. | `undefined` |\n| `border` | `String \\| String[]` | An array to define on which sides of the row a border should apply (`top`, `right`, `bottom`, `left`, or `all`). | `undefined` |\n| `colGap` | `0...10` | A `number` or `string` magnitude for applying the `pr` Tachyons token to the columns in the `flex-layout.row`. | `undefined` |\n| `colSizing` | `equal`|`auto` | Controls the width of the columns in the `flex-layout.row`. | `equal` |\n| `fullWidth` | `Boolean` | Whether the component should occupy all the available width from its parent. | `false` |\n| `horizontalAlign` | `left`|`right`|`center`|`between`|`around` | Controls horizontal alignment for the items in the `flex-layout.row`. It defaults to `between` if `colSizing` is `auto` and to `left` otherwise. | `left` |\n| `colJustify` | `enum` | Controls the space between columns and borders of the `flex-layout.row`, following the `justify-content` CSS property. Possible values are `between` (no space added between borders and columns) and `around` (space added). | `between` |\n| `marginBottom` | `0...10` | A `number` or `string` magnitude for applying the `mb` Tachyons token to the row. | `undefined` |\n| `marginTop` | `0...10` | A `number` or `string` magnitude for applying the `mt` Tachyons token to the row. | `undefined` |\n| `paddingBottom` | `0...10` | A `number` or `string` magnitude for applying the `pb` Tachyons token to the row. | `undefined` |\n| `paddingTop` | `0...10` | A `number` or `string` magnitude for applying the `pt` Tachyons token to the row. | `undefined` |\n| `preserveLayoutOnMobile` | `Boolean` | Whether the `flex-layout.row` should break into a column layout on mobile. | `false` |\n| `preventHorizontalStretch` | `Boolean` | Prevents the row from stretching horizontally to fill its parent's width. | `false` |\n| `preventVerticalStretch` | `Boolean` | Prevents the row from stretching vertically to fill its parent's height with the `items-stretch` token. | `false` |\n| `rowGap` | `0...10` | A `number` or `string` magnitude for applying the `pb` Tachyons token to columns in the `flex-layout.row`. | `undefined` |\n| `htmlId` | `String` | This prop adds an HTML id to `flexRow`. This allows accessing a page section using links. | `undefined` |\n| `arialabel` | `string` | Aria-label to be included for accessibility purposes | `undefined` |\n\n### `flex-layout.col`\n\n| Prop name | Type | Description | Default value |\n| ------------------------ | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------------- |\n| `blockClass` | `String` | Block container class. The set value of this prop functions as a block identifier for CSS customizations | `\"\"` |\n| `borderColor` | `String` | The color of the border. | `undefined` |\n| `borderWidth` | `0...5` | A `number` or `string` magnitude for applying the `bw` Tachyons token to the column. | `undefined` |\n| `border` | `String \\| String[]` | An array to define on which sides of the row a border should apply (`top`, `right`, `bottom`, `left`, or `all`). | `undefined` |\n| `horizontalAlign` | `left`|`right`|`center` | Controls horizontal alignment for the items in the `flex-layout.col`. | `left` |\n| `marginLeft` | `0...10` | A `number` or `string` magnitude for applying the `ml` Tachyons token to the column. | `undefined` |\n| `marginRight` | `0...10` | A `number` or `string` magnitude for applying the `mr` Tachyons token to the column. | `undefined` |\n| `paddingLeft` | `0...10` | A `number` or `string` magnitude for applying the `pl` Tachyons token to the column. | `undefined` |\n| `paddingRight` | `0...10` | A `number` or `string` magnitude for applying the `pr` Tachyons token to the column. | `undefined` |\n| `preventVerticalStretch` | `Boolean` | Prevents the row from stretching vertically to fill its parent's height with `height: 100%`, using `height: \"auto\"` instead. | `false` |\n| `rowGap` | `0...10` | A `number` or `string` magnitude for applying the `pb` Tachyons token to rows in the `flex-layout.col`. | `undefined` |\n| `verticalAlign` | `top`|`middle`|`bottom` | Controls vertical alignment for the items in the `flex-layout.col`. | `top` |\n| `width` | `\"0...100%\"`|`\"grow\"` | Sets the width of the column. Accepts either a percentage or `\"grow\"`. | `undefined` |\n| `arialabel` | `string` | Aria-label to be included for accessibility purposes | `undefined` |\n\n## App behavior\n\n- The highest level in a flex layout is **always** a row. Therefore, you can only add a `flex-layout.col` inside a `flex-layout.row` — never as a first-level block.\n- Every row and column can have as **many levels as needed**.\n- When creating levels, you have to **alternate between rows and columns**. You can only place columns within a row and rows within a column.\n- Keep in mind that the structure that you set in your flex layout does not only affect your code organization, but will also reflect in the way that blocks will be shown and managed through the Site Editor admin. Therefore, it is always important to **take the organization of both code and Site Editor into account when planning to apply the flex layout** to a page.\n\nTo better understand Flex Layout's practical operation, you can access the recipe for [Using Flex Layout](https://developers.vtex.com/docs/guides/vtex-io-documentation-using-flex-layout)\n\n## Customization\n\nTo apply CSS customizations to this and other blocks, follow the instructions given in the recipe for [Using CSS Handles for store customization](https://developers.vtex.com/docs/guides/vtex-io-documentation-using-css-handles-for-store-customization).\n\n| CSS Handles |\n| ---------------- |\n| `flexColChild` |\n| `flexCol` |\n| `flexRowContent` |\n| `flexRow` |\n\n## Contributors ✨\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!\n\n\n\n\n```"
}
] |
code_flex-layout_c0fbbe50
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/react/Col.tsx from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { defineMessages } from 'react-intl'\nimport { useResponsiveValues } from 'vtex.responsive-values'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport {\n FlexLayoutTypes,\n useFlexLayoutContext,\n FlexLayoutContextProvider,\n} from './components/FlexLayoutContext'\nimport {\n TachyonsScaleInput,\n parseTachyonsGroup,\n parseMargins,\n parsePaddings,\n parseBorders,\n} from './modules/valuesParser'\n\nenum VerticalAlign {\n top = 'top',\n middle = 'middle',\n bottom = 'bottom',\n}\n\nenum HorizontalAlign {\n left = 'left',\n right = 'right',\n center = 'center',\n}\n\ninterface Props extends Flex, Gap, Border {\n blockClass?: string\n height?: string\n marginLeft: TachyonsScaleInput\n marginRight: TachyonsScaleInput\n paddingLeft: TachyonsScaleInput\n paddingRight: TachyonsScaleInput\n preventVerticalStretch?: boolean\n verticalAlign?: VerticalAlign\n horizontalAlign?: HorizontalAlign\n}\n\nconst parseVerticalAlign = (input?: string) => {\n switch (input) {\n case VerticalAlign.middle:\n return 'justify-center'\n case VerticalAlign.bottom:\n return 'justify-end'\n }\n return ''\n}\n\nconst parseHorizontalAlign = (input?: string) => {\n switch (input) {\n case HorizontalAlign.center:\n return 'items-center'\n case HorizontalAlign.right:\n return 'items-end'\n }\n return ''\n}\n\nconst CSS_HANDLES = ['flexCol', 'flexColChild'] as const\n\nconst Col: StorefrontFunctionComponent<Props> = ({ children, ...props }) => {\n const {\n colGap,\n rowGap,\n marginLeft,\n marginRight,\n paddingLeft,\n paddingRight,\n border,\n borderWidth,\n borderColor,\n grow,\n preventVerticalStretch,\n verticalAlign,\n horizontalAlign\n } = useResponsiveValues(props) as Props\n\n const context = useFlexLayoutContext()\n const handles = useCssHandles(CSS_HANDLES)\n\n const gaps = parseTachyonsGroup({\n colGap: colGap != null ? colGap : context.colGap,\n rowGap: rowGap != null ? rowGap : context.rowGap,\n })\n\n const margins = parseMargins({\n marginLeft,\n marginRight,\n })\n\n const paddings = parsePaddings({\n paddingLeft,\n paddingRight,\n })\n\n const borders = parseBorders({\n border,\n borderWidth,\n borderColor,\n })\n\n if (context.parent === FlexLayoutTypes.NONE) {\n return null\n }\n\n const vertical = parseVerticalAlign(verticalAlign)\n const horizontal = parseHorizontalAlign(horizontalAlign)\n\n const rowsNum = React.Children.count(children)\n\n return (\n <FlexLayoutContextProvider parent={FlexLayoutTypes.COL} {...gaps}>\n <div \n className={`${handles.flexCol} ${\n grow ? 'flex-grow-1' : ''\n } ${margins} ${paddings} ${borders} ${vertical} ${horizontal} flex flex-column h-100 w-100`}\n >\n {React.Children.map(children, (row, i) => {\n const isLast = i === rowsNum - 1\n const rowGap = isLast ? 0 : gaps.rowGap\n\n return (\n <div\n key={i}\n className={`${handles.flexColChild} pb${rowGap}`}\n style={{\n height:\n preventVerticalStretch || verticalAlign ? 'auto' : '100%',\n }}\n >\n {row}\n </div>\n )\n })}\n </div>\n </FlexLayoutContextProvider>\n )\n}\n\nconst messages = defineMessages({\n title: {\n defaultMessage: '',\n id: 'admin/editor.column.title',\n },\n description: {\n defaultMessage: '',\n id: 'admin/editor.column.description',\n },\n})\n\nCol.schema = {\n title: messages.title.id,\n description: messages.description.id,\n}\n\nexport default Col\n\n```"
}
] |
code_flex-layout_6eb73b9d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/react/package.json from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"@vtex/css-handles\": \"^1.1.3\",\n \"ramda\": \"^0.26.1\",\n \"react\": \"^16.8.6\",\n \"react-intl\": \"^3.12.1\"\n },\n \"devDependencies\": {\n \"@types/jest\": \"^24.0.11\",\n \"@types/node\": \"^11.13.2\",\n \"@types/ramda\": \"^0.26.8\",\n \"@types/react\": \"^16.8.13\",\n \"@types/react-intl\": \"^2.3.17\",\n \"@vtex/test-tools\": \"^1.2.0\",\n \"eslint\": \"^6.5.1\",\n \"eslint-config-vtex-react\": \"^5.0.1\",\n \"prettier\": \"^1.18.2\",\n \"tslint-eslint-rules\": \"^5.4.0\",\n \"typescript\": \"3.9.7\"\n },\n \"resolutions\": {\n \"@types/graphql\": \"14.0.7\"\n },\n \"version\": \"0.21.5\"\n}\n\n```"
}
] |
code_flex-layout_30b81d10
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/react/Row.tsx from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { defineMessages } from 'react-intl'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport {\n FlexLayoutTypes,\n FlexLayoutContextProvider,\n useFlexLayoutContext,\n} from './components/FlexLayoutContext'\n\nimport { useResponsiveWidth } from './hooks/responsiveWidth'\nimport {\n parseTachyonsGroup,\n TachyonsScaleInput,\n parseMargins,\n parsePaddings,\n parseBorders,\n} from './modules/valuesParser'\n\nimport styles from './Row.css'\n\nenum ColSizing {\n equal = 'equal',\n auto = 'auto',\n}\n\nenum ColJustify {\n between = 'between',\n around = 'around',\n left = 'left',\n right = 'right',\n center = 'center',\n}\n\nconst HorizontalAlignments = {\n [ColJustify.between]: 'justify-between',\n [ColJustify.around]: 'justify-around',\n [ColJustify.left]: 'justify-start',\n [ColJustify.center]: 'justify-center',\n [ColJustify.right]: 'justify-end',\n}\n\nconst CSS_HANDLES = ['flexRowContent'] as const\n\nexport interface Props extends Flex, Gap, Border {\n blockClass?: string\n marginTop: TachyonsScaleInput\n marginBottom: TachyonsScaleInput\n paddingTop: TachyonsScaleInput\n paddingBottom: TachyonsScaleInput\n preserveLayoutOnMobile?: boolean\n preventHorizontalStretch?: boolean\n preventVerticalStretch?: boolean\n colSizing?: ColSizing\n horizontalAlign?: ColJustify\n colJustify?: ColJustify\n experimentalHideEmptyCols?: boolean\n htmlId?: string\n}\n\nconst Row: StorefrontFunctionComponent<Props> = ({\n children,\n colGap,\n rowGap,\n marginTop,\n marginBottom,\n paddingTop,\n paddingBottom,\n border,\n borderWidth,\n borderColor,\n preserveLayoutOnMobile,\n preventHorizontalStretch,\n preventVerticalStretch,\n horizontalAlign,\n colSizing,\n colJustify = ColJustify.between,\n experimentalHideEmptyCols = false,\n}) => {\n const context = useFlexLayoutContext()\n const handles = useCssHandles(CSS_HANDLES)\n\n const gaps = parseTachyonsGroup({\n colGap: colGap != null ? colGap : context.colGap,\n rowGap: rowGap != null ? rowGap : context.rowGap,\n })\n\n const margins = parseMargins({\n marginTop,\n marginBottom,\n })\n\n const paddings = parsePaddings({\n paddingTop,\n paddingBottom,\n })\n\n const borders = parseBorders({\n border,\n borderWidth,\n borderColor,\n })\n\n const { cols, breakOnMobile } = useResponsiveWidth(children, {\n preserveLayoutOnMobile,\n hideEmptyCols: experimentalHideEmptyCols,\n })\n\n const isSizingAuto = colSizing === ColSizing.auto\n\n let horizontalAlignClass = isSizingAuto\n ? HorizontalAlignments[colJustify]\n : HorizontalAlignments.left\n\n if (horizontalAlign != null) {\n horizontalAlignClass = HorizontalAlignments[horizontalAlign]\n }\n\n return (\n <FlexLayoutContextProvider parent={FlexLayoutTypes.ROW} {...gaps}>\n <div\n className={`${\n breakOnMobile ? 'flex-none flex-ns' : 'flex'\n } ${margins} ${paddings} ${borders} ${horizontalAlignClass} ${\n handles.flexRowContent\n } items-stretch w-100`}\n >\n {cols.map((col, i) => {\n const isLast = i === cols.length - 1\n const colGap = isLast ? 0 : gaps.colGap\n const rowGap = isLast ? 0 : gaps.rowGap\n\n return (\n <div\n key={i}\n className={`${\n /** If it breaks line on mobile, use the rowGap as bottom padding */\n breakOnMobile\n ? `pr${colGap}-ns pb${rowGap} pb0-ns`\n : `pr${colGap}`\n } ${preventVerticalStretch ? '' : 'items-stretch'} ${\n preventHorizontalStretch ? '' : styles.stretchChildrenWidth\n } ${col.width === 'grow' ? 'flex-grow-1' : ''} ${\n experimentalHideEmptyCols ? styles.col : ''\n } flex`}\n style={{\n width:\n preventHorizontalStretch ||\n (isSizingAuto && !col.hasDefinedWidth)\n ? 'auto'\n : breakOnMobile\n ? '100%'\n : col.width,\n }}\n >\n {col.element}\n </div>\n )\n })}\n </div>\n </FlexLayoutContextProvider>\n )\n}\n\nconst messages = defineMessages({\n title: {\n defaultMessage: '',\n id: 'admin/editor.row.title',\n },\n description: {\n defaultMessage: '',\n id: 'admin/editor.row.description',\n },\n})\n\nRow.schema = {\n title: messages.title.id,\n description: messages.description.id,\n}\n\nexport default Row\n\n```"
}
] |
code_flex-layout_b42bd65d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/react/Row.css from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n/** Stretches the width of the children to 100% (except images, which would be distorted. They are then centered)\n * This is done because the direct parent of the children of the Row component is flex now, which changes the\n * way children blocks are rendered (children with display: block of non-flex elements have 100% width, and\n * children of flex elements have the minimum possible width in respect of their content).\n * This can be cancelled with the prop `preventHorizontalStretch`\n */\n\n.stretchChildrenWidth {\n justify-content: center;\n}\n.stretchChildrenWidth > *:not(img) {\n width: 100%;\n}\n\n/** Used for hiding empty columns */\n.col:empty {\n display: none;\n}\n```"
}
] |
code_flex-layout_ee5163a4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/react/FlexLayout.tsx from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { defineMessages, useIntl } from 'react-intl'\nimport { useCssHandles } from 'vtex.css-handles'\nimport Container from 'vtex.store-components/Container'\nimport { useResponsiveValues } from 'vtex.responsive-values'\n\nimport {\n FlexLayoutTypes,\n useFlexLayoutContext,\n} from './components/FlexLayoutContext'\nimport Row, { Props as RowProps } from './Row'\n\ninterface Props extends RowProps {\n fullWidth?: boolean,\n arialabel?: string\n}\n\nconst CSS_HANDLES = ['flexRow'] as const\n\nconst FlexLayout: StorefrontFunctionComponent<Props> = props => {\n const responsiveProps = useResponsiveValues(props) as Props\n const arialabel = responsiveProps.arialabel\n const { fullWidth, htmlId } = responsiveProps\n const context = useFlexLayoutContext()\n const handles = useCssHandles(CSS_HANDLES)\n\n const intl = useIntl()\n\n const content = <Row {...responsiveProps} />\n\n const isTopLevel = context.parent === FlexLayoutTypes.NONE\n\n const shouldUseContainer = !fullWidth && isTopLevel\n \n const wrappedContent = shouldUseContainer ? <Container>{content}</Container> : content\n\n return (\n <div className={handles.flexRow} id={htmlId} aria-label={arialabel ? arialabel : intl.formatMessage(\n { id: 'store/flex-layout.flexLayout-row.aria-label' }, { sectionId: htmlId ?? 'row'})}>\n {wrappedContent}\n </div>\n )\n}\n\nconst messages = defineMessages({\n title: {\n defaultMessage: '',\n id: 'admin/editor.row.title',\n },\n description: {\n defaultMessage: '',\n id: 'admin/editor.row.description',\n },\n})\n\nFlexLayout.schema = {\n title: messages.title.id,\n description: messages.description.id,\n}\n\nexport default FlexLayout\n\n```"
}
] |
code_flex-layout_19e7cdef
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/react/FlexLayoutDummy.js from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\n\nconst FlexLayoutDummy = () => {\n console.warn(\n 'You are inserting the `flex-layout` block directly. Please use `flex-layout.row` instead.'\n )\n\n return <span />\n}\n\nexport default FlexLayoutDummy\n\n```"
}
] |
code_flex-layout_5e06e4cc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/store/interfaces.json from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"flex-layout\": {\n \"component\": \"FlexLayoutDummy\"\n },\n \"flex-layout.row\": {\n \"component\": \"FlexLayout\",\n \"composition\": \"children\",\n \"allowed\": \"*\"\n },\n \"flex-layout.col\": {\n \"component\": \"Col\",\n \"composition\": \"children\",\n \"allowed\": \"*\"\n }\n}\n```"
}
] |
code_flex-layout_97ac4a5a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/react/typings/global.d.ts from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { FunctionComponent } from 'react'\nimport { TachyonsScaleInput } from '../modules/valuesParser'\n\ndeclare global {\n interface StorefrontFunctionComponent<P = {}> extends FunctionComponent<P> {\n schema?: object\n getSchema?(props?: P): object\n }\n\n interface StorefrontComponent<P = {}, S = {}> extends Component<P, S> {\n schema?: object\n getSchema?(props: P): object\n }\n\n interface StorefrontElement extends ReactElement {\n schema?: object\n getSchema?(props: P): object\n }\n\n interface Gap {\n colGap: TachyonsScaleInput\n rowGap: TachyonsScaleInput\n }\n\n interface Flex {\n stretchContent: boolean\n grow: boolean\n }\n\n type BorderBase = 'top' | 'right' | 'bottom' | 'left' | 'all'\n\n interface Border {\n border: BorderBase | BorderBase[]\n borderWidth: TachyonsScaleInput\n borderColor: string\n }\n}\n\n```"
}
] |
code_flex-layout_a06230be
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/react/typings/css.d.ts from the flex-layout 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_flex-layout_998aec0b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/react/components/FlexLayoutContext.tsx from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FunctionComponent, useContext, useMemo } from 'react'\n\nexport enum FlexLayoutTypes {\n NONE = 'none',\n ROW = 'row',\n COL = 'col',\n}\n\nexport interface FlexLayoutContextProps {\n parent: FlexLayoutTypes\n colGap: number\n rowGap: number\n}\n\nexport type FlexLayoutContextValue = number | FlexLayoutTypes\n\nexport type FlexLayoutContext = FlexLayoutContextProps & {\n [key: string]: FlexLayoutContextValue\n}\n\nconst FlexLayoutContext = React.createContext<FlexLayoutContext>({\n parent: FlexLayoutTypes.NONE,\n colGap: 0,\n rowGap: 0,\n})\n\nexport const FlexLayoutContextProvider: FunctionComponent<\n FlexLayoutContextProps\n> = ({ parent, colGap, rowGap, children }) => {\n const value = useMemo(\n () => ({\n parent,\n colGap,\n rowGap,\n }),\n [parent, colGap, rowGap]\n )\n\n return (\n <FlexLayoutContext.Provider value={value}>\n {children}\n </FlexLayoutContext.Provider>\n )\n}\n\nexport const useFlexLayoutContext = () => useContext(FlexLayoutContext)\n\n```"
}
] |
code_flex-layout_25acf21d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/react/__tests__/valuesParser.test.js from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { parseBorders } from '../modules/valuesParser'\n\ndescribe('parseBorders', () => {\n it('should work with border as array', () => {\n const input = {\n border: ['left', 'bottom', 'right', 'top', 'all'],\n borderWidth: 1,\n borderColor: 'red',\n }\n\n const border = parseBorders(input)\n\n expect(border).toBe('bl bb br bt ba bw1 b--red')\n })\n it('should work with border as string', () => {\n const input = {\n border: 'all',\n borderWidth: 1,\n borderColor: 'red',\n }\n\n const border = parseBorders(input)\n\n expect(border).toBe('ba bw1 b--red')\n })\n})\n\n```"
}
] |
code_flex-layout_07f87b3c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/react/hooks/responsiveWidth.ts from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport React, { ReactElement } from 'react'\nimport { useDevice } from 'vtex.device-detector'\nimport { parseWidth } from '../modules/valuesParser'\n\ninterface DistributedWidthOptions {\n preserveLayoutOnMobile?: boolean\n hideEmptyCols?: boolean\n}\n\ninterface ColWithWidth {\n element: React.ReactNode\n width: number | string\n hasDefinedWidth: boolean\n isResponsive: boolean\n}\n\n/** Distributes the available width--width that remains after subtracting\n * the widths of the columns the user has set--between the columns that do\n * not have their widths set by the user.\n *\n * For example:\n * There are 3 columns. The user sets the width for the first one to 50%.\n * This function will set the widths of the second and third columns to 25%.\n */\nconst distributeAvailableWidth = (\n cols: ColWithWidth[],\n { hideEmptyCols = false } = {}\n) => {\n const { availableWidth, remainingColsNum, hasAnyWidthGrow } = cols.reduce(\n (acc, col) => {\n const isGrow = col.width === 'grow'\n const width =\n typeof col.width === 'number' ? acc.availableWidth - col.width : 0\n\n return {\n availableWidth: isGrow ? 0 : width,\n remainingColsNum: acc.remainingColsNum + (col.hasDefinedWidth ? 0 : 1),\n hasAnyWidthGrow: acc.hasAnyWidthGrow || isGrow,\n }\n },\n {\n availableWidth: 100,\n remainingColsNum: 0,\n hasAnyWidthGrow: false,\n }\n )\n\n if (availableWidth < 0 && !hasAnyWidthGrow) {\n const normalization = -(100 / availableWidth)\n cols = cols.map(col => ({\n ...col,\n width:\n typeof col.width === 'number' ? col.width * normalization : col.width,\n }))\n }\n\n return cols.map(col => {\n const definedWidth =\n typeof col.width === 'number' ? `${col.width}%` : col.width\n\n return {\n element: col.element,\n width: col.hasDefinedWidth\n ? definedWidth\n : `${Math.floor(\n Math.max(0, availableWidth) / (hideEmptyCols ? 1 : remainingColsNum)\n )}%`,\n hasDefinedWidth: col.hasDefinedWidth,\n }\n })\n}\n\nfunction isReactElement(element: any): element is ReactElement {\n return !!element && element.props\n}\n\nexport const useResponsiveWidth = (\n children: React.ReactNode,\n options: DistributedWidthOptions\n) => {\n const { device } = useDevice()\n\n const isPhone = device === 'phone'\n\n const { preserveLayoutOnMobile = false, hideEmptyCols = false } =\n options || {}\n\n const cols: ColWithWidth[] = React.Children.toArray(children).map(col => {\n if (!isReactElement(col)) {\n return {\n element: col,\n width: 0,\n hasDefinedWidth: false,\n isResponsive: true,\n }\n }\n\n const width = parseWidth(\n col.props.width || (col.props.blockProps && col.props.blockProps.width)\n )\n\n if (width && typeof width === 'object') {\n return {\n element: col,\n width: isPhone ? width.mobile || 0 : width.desktop || 0,\n hasDefinedWidth: true,\n isResponsive: true,\n }\n }\n\n if (!preserveLayoutOnMobile && isPhone) {\n return {\n element: col,\n width: 0,\n hasDefinedWidth: false,\n isResponsive: false,\n }\n }\n\n if (typeof width === 'number' || typeof width === 'string') {\n return {\n element: col,\n width,\n hasDefinedWidth: true,\n isResponsive: false,\n }\n }\n\n return {\n element: col,\n width: 0,\n hasDefinedWidth: false,\n isResponsive: true,\n }\n })\n\n const isAnyColResponsive = cols.some(col => col.isResponsive)\n const breakOnMobile =\n !preserveLayoutOnMobile && isPhone && !isAnyColResponsive\n\n return {\n cols: distributeAvailableWidth(cols, { hideEmptyCols }),\n breakOnMobile,\n }\n}\n\n```"
}
] |
code_flex-layout_386a888f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flex-layout/react/modules/valuesParser.ts from the flex-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { fromPairs, pick, range, toPairs } from 'ramda'\n\nexport type TachyonsScaleInput = string | number | undefined\ntype Group<T, U> = { [key in keyof T]: U }\ntype TachyonsInputGroup<T> = Group<T, TachyonsScaleInput>\ninterface ResponsiveInput<T> {\n mobile: T\n desktop: T\n}\n\nconst MAX_TACHYONS_SCALE = 11\n\n//eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst isResponsiveInput = <T>(value: any): value is ResponsiveInput<T> =>\n value && value.mobile != null && value.desktop != null\n\n/** Takes a parser of units, and returns a parser that accepts either a\n * value or a responsive input of that same type of value\n * (i.e. {mobile: ..., desktop: ...}), and returns an object of the same\n * format of the input.\n */\nexport const parseResponsive = <T, U>(parse: (value: T) => U) => (\n value: T | ResponsiveInput<T>\n): null | U | { mobile: U; desktop: U } => {\n if (isResponsiveInput(value)) {\n return {\n mobile: parse(value.mobile),\n desktop: parse(value.desktop),\n }\n }\n\n return parse(value)\n}\n\n/** Verifies if the input is a valid Tachyons scale value (i.e. a number\n * between 0 to 11) and converts to number if necessary\n */\nconst parseTachyonsValue = (value: TachyonsScaleInput, name?: string) => {\n if (!value) {\n return 0\n }\n\n const supportedValues = range(0, MAX_TACHYONS_SCALE + 1).map(String)\n\n if (!supportedValues.includes(String(value))) {\n if (name) {\n console.warn(\n `Invalid ${name} value (\"${value}\"). It should be an integer between 0 and ${MAX_TACHYONS_SCALE}.`\n )\n }\n\n return 0\n }\n\n return typeof value === 'string' ? parseInt(value, 10) : value\n}\n\nexport const parseTachyonsGroup = <T>(group: TachyonsInputGroup<T>) => {\n const pairs = toPairs<TachyonsScaleInput>(group)\n\n const parsedValues = pairs.map<[string, number]>(([key, value]) => [\n key,\n parseTachyonsValue(value, key),\n ])\n\n return fromPairs(parsedValues) as Group<T, number>\n}\n\nconst parseDimension = (input: string): null | number | string => {\n if (typeof input !== 'string') {\n return null\n }\n\n if (input === 'grow') {\n return 'grow'\n }\n\n const supportedUnits = ['%']\n const match = input.match(new RegExp(`(\\\\d*)(${supportedUnits.join('|')})`))\n\n if (!match) {\n return null\n }\n\n const value = match[1]\n // TODO: support multiple units\n // const unit = match[2]\n\n if (value == null) {\n return null\n }\n\n const parsedValue = parseInt(value, 10)\n\n return parsedValue\n}\n\nexport const parseWidth = parseResponsive(parseDimension)\n\n/** TODO: allow responsive values on height\n * (and verify height usage overall)\n **/\nexport const parseHeight = parseDimension\n\n/** Maps objects keys to Tachyons classes, and returns a function\n * that parses Tachyons scale values to the mapped classes,\n * which in turn returns a string of classNames.\n **/\nconst mapToClasses = <T>(map: { [key in keyof T]: string }) => (\n props: { [key in keyof T]?: TachyonsScaleInput }\n) => {\n const pickedProps = pick(Object.keys(map), props)\n\n const parsedProps = parseTachyonsGroup(pickedProps)\n\n const mappedProps = toPairs(parsedProps).map(\n ([key, value]) => `${map[key as (keyof T)] as string}${value}`\n )\n\n return mappedProps.join(' ')\n}\n\n// TODO: allow responsive values on paddings and margins\nexport const parsePaddings = mapToClasses({\n paddingTop: 'pt',\n paddingBottom: 'pb',\n paddingLeft: 'pl',\n paddingRight: 'pr',\n})\n\nexport const parseMargins = mapToClasses({\n marginTop: 'mt',\n marginBottom: 'mb',\n marginLeft: 'ml',\n marginRight: 'mr',\n})\n\nconst borderMap = {\n top: 'bt',\n right: 'br',\n bottom: 'bb',\n left: 'bl',\n all: 'ba',\n}\n\nexport const parseBorders = ({ border, borderWidth, borderColor }: Border) => {\n const borders = border\n ? ([] as BorderBase[])\n .concat(border)\n .map(base => borderMap[base])\n .join(' ')\n : ''\n const width = borderWidth ? `bw${parseTachyonsValue(borderWidth, 'bw')}` : ''\n const color = borderColor ? `b--${borderColor.split(' ')[0]}` : ''\n\n return `${borders} ${width} ${color}`\n}\n\n```"
}
] |
code_pwa-gtm-pixel_e3e0f659
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pwa-gtm-pixel/docs/README.md from the pwa-gtm-pixel VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# PWA Google Tag Manager Pixel\n\nThis app is an extension of the [Google Tag Manager App](https://github.com/vtex-apps/google-tag-manager) to add PWA Events for your store.\n\n## How to install\n\nFirst, you need to have the [Google Tag Manager App](https://github.com/vtex-apps/google-tag-manager) installed and configured on your store.\n\nThen open the VTEX App Store and install the app on your store.\n\nor\n\nRun the following command:\n\n```sh\nvtex install vtex.pwa-gtm-pixel@1.x\n```\n\n## Google Tag Manager Setup\n\nThis guide provides instructions to setup all the necessary Tags, Triggers, Variables, and configurations to Google Tag Manager and Google Analytics, so at the end of it you will have all the PWA analytics available in your Google Analytics dashboard.\n\nOpen the Google Tag Manager dashboard at https://tagmanager.google.com/.\n\n### Create Variables\n\n#### Data Layer Variables\n\n1. Click in Variable Configuration\n2. Choose \"Data Layer Variable\"\n3. Type \"installWebApp\" in \"Data Layer Variable Name\"\n4. Click Save, and save as \"Data Layer Variable - installWebApp\"\n\nDo the same thing for the variables: \"userChoice\".\n\n### Creating Triggers\n\nTo create a Trigger, click on \"Trigger\" on the menu on the left and then on the button New.\n\n#### Custom Events\n\n1. Click in Trigger Configuration\n2. Choose \"Custom Event\"\n3. Type \"installWebApp\" in Event Name\n4. Click Save, and save as \"Custom Event - installWebApp\"\n\n### Creating Tags\n\nTo create a Tag, click on \"Tags\" on the menu on the left and then on the button New.\n\n#### Google Analytics - PWA\n\n1. Click in Tag Configuration\n2. Choose \"Google Analytics - PWA\"\n3. Choose Track Type as \"Event\"\n4. Type \"PWA\" in Category\n5. Type \"{{Data Layer Variable - userChoice}}\" in Action\n6. Type \"{{Event}}\" in Label\n7. In Google Analytics Settings choose \"{{Google Analytics}}\"\n8. Choose the Triggers:\n 1. \"Custom Event - installWebApp\"\n9. Save as \"Google Analytics - PWA\"\n\n```"
}
] |
code_pwa-gtm-pixel_03d3cc1b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pwa-gtm-pixel/react/index.tsx from the pwa-gtm-pixel VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { canUseDOM } from 'vtex.render-runtime'\nimport { PixelMessage } from './typings/events'\n\nimport push from './modules/push'\n\nexport function handleEvents(e: PixelMessage) {\n switch (e.data.eventName) {\n case 'vtex:installWebApp': {\n push({\n event: 'installWebApp',\n userChoice: e.data.userChoice\n })\n return\n }\n default: {\n return\n }\n }\n}\n\nif (canUseDOM) {\n window.addEventListener('message', handleEvents)\n}\n\n```"
}
] |
code_pwa-gtm-pixel_a51bb003
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pwa-gtm-pixel/react/package.json from the pwa-gtm-pixel 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.5.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 \"graphql\": \"^14.5.4\",\n \"prettier\": \"^1.18.2\",\n \"tslint-eslint-rules\": \"^5.4.0\",\n \"typescript\": \"3.5.2\"\n },\n \"version\": \"1.0.0\"\n}\n\n```"
}
] |
code_pwa-gtm-pixel_0fc8e8d3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pwa-gtm-pixel/store/interfaces.json from the pwa-gtm-pixel VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"pixel.pwaGtm\": {\n \"component\": \"index\"\n }\n}\n```"
}
] |
code_pwa-gtm-pixel_c6f533de
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pwa-gtm-pixel/react/typings/events.d.ts from the pwa-gtm-pixel 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 | HomePageInfo\n | ProductPageInfoData\n | SearchPageInfoData\n | InstallWebAppData\n}\n\nexport interface EventData {\n event: string\n eventName: string\n currency: string\n}\n\nexport interface PageInfoData extends EventData {\n event: 'pageInfo'\n eventName: 'vtex:pageInfo'\n accountName: string\n pageTitle: string\n pageUrl: string\n}\n\nexport interface HomePageInfo extends PageInfoData {\n eventType: 'homeView'\n}\n\nexport interface ProductPageInfoData extends PageInfoData {\n eventType: 'productView'\n}\n\nexport interface SearchPageInfoData extends PageInfoData {\n eventType:\n | 'internalSiteSearchView'\n | 'categoryView'\n | 'departmentView'\n | 'emptySearchView'\n category?: CategoryMetaData\n department?: DepartmentMetaData\n search?: SearchMetaData\n}\n\ninterface CategoryMetaData {\n id: string\n name: string\n}\n\ninterface DepartmentMetaData {\n id: string\n name: string\n}\n\ninterface SearchMetaData {\n term: string\n category: CategoryMetaData\n results: number\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: ProductDetail\n}\n\nexport interface ProductClickData extends EventData {\n event: 'productClick'\n eventName: 'vtex:productClick'\n product: ProductSummary\n}\n\nexport interface ProductImpressionData extends EventData {\n event: 'productImpression'\n eventName: 'vtex:productImpression'\n impressions: Impression[]\n product?: ProductSummary // deprecated, use impressions list!\n position?: number // deprecated, use impressions list!\n list: string\n}\n\nexport interface InstallWebAppData extends EventData {\n event: 'installWebApp',\n eventName: 'vtex:installWebApp'\n userChoice:\n | 'accepted'\n | 'dismissed'\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: ProductSummary\n position: number\n}\n\nexport interface PaymentType {\n group: string\n paymentSystemName: string\n installments: number\n value: number\n}\n\nexport interface ShippingMethod {\n itemId: string\n selectedSla: string\n}\n\nexport interface 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\nexport interface PriceTag {\n identifier: string\n isPercentual: boolean\n value: number\n}\n\ninterface Product {\n brand: string\n brandId: string\n categories: string[]\n productId: string\n productName: string\n productReference: string\n linkText: string\n items: Item[]\n}\n\nexport interface ProductSummary extends Product {\n sku: Item\n}\n\nexport interface ProductDetail extends Product {\n categoryId: string\n categoryTree: { id: string; name: string }[]\n selectedSku: Item\n}\n\nexport interface Item {\n itemId: string\n name: string\n ean?: string // TODO: provide this info at productImpression\n referenceId: { Key: string; Value: string }\n seller?: Seller\n sellers: Seller[]\n}\n\nexport interface Seller {\n commertialOffer: CommertialOffer\n sellerId: string\n}\n\nexport interface CommertialOffer {\n Price: number\n ListPrice: number\n AvailableQuantity: number\n}\n\n```"
}
] |
code_pwa-gtm-pixel_fa339872
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pwa-gtm-pixel/react/typings/vtex.render-runtime.d.ts from the pwa-gtm-pixel VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.render-runtime' {\n export const canUseDOM: boolean\n}\n\n```"
}
] |
code_pwa-gtm-pixel_97b44b71
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pwa-gtm-pixel/react/typings/global.d.ts from the pwa-gtm-pixel VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface Window extends Window {\n dataLayer: any[]\n}\n\n```"
}
] |
code_pwa-gtm-pixel_2b2efafb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of pwa-gtm-pixel/react/modules/push.ts from the pwa-gtm-pixel VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nwindow.dataLayer = window.dataLayer || []\n\nexport default function push(event: any) {\n window.dataLayer.push(event)\n}\n```"
}
] |
code_order-configuration_cf8047c2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/messages/pt.json from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/form.error.required\": \"Este campo é necessário\",\n \"store/form.error.maxLength\": \"Este campo deve ter até {value} caracteres\",\n \"store/form.error.minLength\": \"Este campo deve ter no mínimo {value} caracteres\",\n \"store/form.error.maxValue\": \"O valor máximo aceito neste campo é {value}\",\n \"store/form.error.minValue\": \"O valor mínimo aceito neste campo é {value}\",\n \"store/form.error.notFloat\": \"Deve ser um número\",\n \"store/form.error.notInteger\": \"Deve ser um número inteiro\",\n \"store/form.error.pattern\": \"Este texto não corresponde com o padrão esperado\",\n \"store/form.error.notInEnum\": \"Deve ser algum dos seguintes valores: {values}\",\n \"store/form.error.multipleOf\": \"Este campo deve ser um mútiplo de {value}\",\n \"store/form.error.undefinedError\": \"Valor inválido.\",\n \"store/form.submit.buttonLabel\": \"Salvar\",\n \"store/form.submit.error.userInputError\": \"Foram encontrados alguns erros nos dados fornecidos, revise os campos indicados e tente novamente.\",\n \"store/form.submit.error.serverError\": \"Erro interno do servidor! Por favor, tente novamente mais tarde!\",\n \"store/form.schema.loading\": \"Carregando o formulário...\",\n \"store/form.schema.error\": \"Erro carregando o formulário, tente de novo mais tarde!\",\n \"store/form.submit.success\": \"Preços atualizados com base na nova configuração de pedido\",\n \"admin/editor.custom-price-selector.title\": \"Configuração da ordem\",\n \"admin/editor.custom-price-selector.description\": \"Configuração de pedidos para usuários B2B\",\n \"admin/editor.custom-price-selector.formTitle.title\": \"Título do formulário\",\n \"admin/editor.custom-price-selector.formFields.title\": \"Campos do formulário\",\n \"admin/editor.custom-price-selector.formFields.name\": \"Nome do campo\",\n \"admin/editor.custom-price-selector.formFields.type\": \"Tipo de campo\",\n \"admin/editor.custom-price-selector.formFields.fieldType\": \"Tipo de entrada do campo\",\n \"admin/editor.custom-price-selector.formFields.label\": \"Legenda do campo\",\n \"admin/editor.custom-price-selector.formFields.required\": \"Requeridos\",\n \"admin/editor.custom-price-selector.formFields.showInTitle\": \"Mostrar no título\",\n \"admin/editor.custom-price-selector.formFields.format\": \"Formato de entrada\",\n \"admin/editor.custom-price-selector.formFields.options\": \"Opções de entrada\",\n \"admin/editor.custom-price-selector.formFields.options.description\": \"Opções em caso de seleção, rádio ou caixa de seleção\",\n \"admin/editor.custom-price-selector.formFields.options.label\": \"Etiqueta da opção\",\n \"admin/editor.custom-price-selector.formFields.options.value\": \"Valor da opção\"\n}\n\n```"
}
] |
code_order-configuration_e01845c1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/messages/ar-SA.json from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/form.error.required\": \"هذا الحقل مطلوب\",\n \"store/form.error.maxLength\": \"هذا الحقل له حد أقصى من الطول هو: {value}\",\n \"store/form.error.minLength\": \"هذا الحقل له حد أدنى من الطول هو: {value}\",\n \"store/form.error.maxValue\": \"القيمة القصوى المقبولة من هذا الحقل هي {value}\",\n \"store/form.error.minValue\": \"القيمة الدنيا المقبولة من هذا الحقل هي {value}\",\n \"store/form.error.notFloat\": \"يجب أن يكون رقماً\",\n \"store/form.error.notInteger\": \"يجب أن يكون عدد صحيح\",\n \"store/form.error.pattern\": \"هذا النص لا يتطابق مع النمط المتوقع\",\n \"store/form.error.notInEnum\": \"يجب أن تكون واحدة من القيم التالية: {values}\",\n \"store/form.error.multipleOf\": \"يجب أن يكون من مضاعفات {value}\",\n \"store/form.error.undefinedError\": \"قيمة غير صالحة.\",\n \"store/form.submit.buttonLabel\": \"حفظ\",\n \"store/form.submit.error.userInputError\": \"تم العثور على بعض الأخطاء في البيانات المقدمة، يرجى مراجعة الحقول المشار إليها حاول مرة أخرى!\",\n \"store/form.submit.error.serverError\": \"خطأ داخلي في الخادم! الرجاء المحاولة مرة أخرى لاحقاً!\",\n \"store/form.schema.loading\": \"تحميل الاستمارة...\",\n \"store/form.schema.error\": \"خطأ في تحميل الاستمارة، حاول مرة أخرى لاحقاً!\",\n \"store/form.submit.success\": \"تم تحديث الأسعار على أساس إعداد الطلب الجديد\",\n \"admin/editor.custom-price-selector.title\": \"إعداد الطلب\",\n \"admin/editor.custom-price-selector.description\": \"إعداد الطلب لمستخدمي B2B\",\n \"admin/editor.custom-price-selector.formTitle.title\": \"عنوان الاستمارة\",\n \"admin/editor.custom-price-selector.formFields.title\": \"من الحقول\",\n \"admin/editor.custom-price-selector.formFields.name\": \"اسم الحقل\",\n \"admin/editor.custom-price-selector.formFields.type\": \"نوع الحقل\",\n \"admin/editor.custom-price-selector.formFields.fieldType\": \"نوع إدخال الحقل\",\n \"admin/editor.custom-price-selector.formFields.label\": \"تسمية الحقل\",\n \"admin/editor.custom-price-selector.formFields.required\": \"مطلوب\",\n \"admin/editor.custom-price-selector.formFields.showInTitle\": \"عرض في العنوان\",\n \"admin/editor.custom-price-selector.formFields.format\": \"تنسيق الإدخال\",\n \"admin/editor.custom-price-selector.formFields.options\": \"خيارات الإدخال\",\n \"admin/editor.custom-price-selector.formFields.options.description\": \"خيارات في حالة الاختيار أو اللاسلكي أو مربع الاختيار\",\n \"admin/editor.custom-price-selector.formFields.options.label\": \"تسمية الخيار\",\n \"admin/editor.custom-price-selector.formFields.options.value\": \"قيمة الخيار\"\n}\n\n```"
}
] |
code_order-configuration_d3f594a3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/messages/en.json from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/form.error.required\": \"This field is required\",\n \"store/form.error.maxLength\": \"This field has a max length of: {value}\",\n \"store/form.error.minLength\": \"This field has a min length of: {value}\",\n \"store/form.error.maxValue\": \"The maximum value accepted by this field is {value}\",\n \"store/form.error.minValue\": \"The minimum value accepted by this field is {value}\",\n \"store/form.error.notFloat\": \"Must be a number\",\n \"store/form.error.notInteger\": \"Must be an integer\",\n \"store/form.error.pattern\": \"This text does not match the expected pattern\",\n \"store/form.error.notInEnum\": \"Must one of the following values: {values}\",\n \"store/form.error.multipleOf\": \"Must be a multiple of {value}\",\n \"store/form.error.undefinedError\": \"Invalid value.\",\n \"store/form.submit.buttonLabel\": \"Save\",\n \"store/form.submit.error.userInputError\": \"Found some errors in the data provided, please review the indicated fields try again!\",\n \"store/form.submit.error.serverError\": \"Internal Server Error! Please, try again later!\",\n \"store/form.schema.loading\": \"Loading form...\",\n \"store/form.schema.error\": \"Error loading form, try again later!\",\n \"store/form.submit.success\": \"Prices updated based on new order configuration\",\n \"admin/editor.custom-price-selector.title\": \"Order Configuration\",\n \"admin/editor.custom-price-selector.description\": \"Order configuration for B2B users\",\n \"admin/editor.custom-price-selector.formTitle.title\": \"Form Title\",\n \"admin/editor.custom-price-selector.formFields.title\": \"Form Fields\",\n \"admin/editor.custom-price-selector.formFields.name\": \"Field Name\",\n \"admin/editor.custom-price-selector.formFields.type\": \"Field Type\",\n \"admin/editor.custom-price-selector.formFields.fieldType\": \"Field Input Type\",\n \"admin/editor.custom-price-selector.formFields.label\": \"Field Label\",\n \"admin/editor.custom-price-selector.formFields.required\": \"Required\",\n \"admin/editor.custom-price-selector.formFields.showInTitle\": \"Show in Title\",\n \"admin/editor.custom-price-selector.formFields.format\": \"Input Format\",\n \"admin/editor.custom-price-selector.formFields.options\": \"Input Options\",\n \"admin/editor.custom-price-selector.formFields.options.description\": \"Options in case of select, radio or checkbox\",\n \"admin/editor.custom-price-selector.formFields.options.label\": \"Option Label\",\n \"admin/editor.custom-price-selector.formFields.options.value\": \"Option Value\"\n}\n\n```"
}
] |
code_order-configuration_cf2eee6e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/messages/context.json from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/form.error.required\": \"This field is required\",\n \"store/form.error.maxLength\": \"This field has a max length of: {value}\",\n \"store/form.error.minLength\": \"This field has a min length of: {value}\",\n \"store/form.error.maxValue\": \"The maximum value accepted by this field is {value}\",\n \"store/form.error.minValue\": \"The minimum value accepted by this field is {value}\",\n \"store/form.error.notFloat\": \"Must be a number\",\n \"store/form.error.notInteger\": \"Must be an integer\",\n \"store/form.error.pattern\": \"This text does not match the expected pattern\",\n \"store/form.error.notInEnum\": \"Must one of the following values: {values}\",\n \"store/form.error.multipleOf\": \"Must be a multiple of {value}\",\n \"store/form.error.undefinedError\": \"Invalid value.\",\n \"store/form.submit.buttonLabel\": \"Save\",\n \"store/form.submit.error.userInputError\": \"Found some errors in the data provided, please review the indicated fields try again!\",\n \"store/form.submit.error.serverError\": \"Internal Server Error! Please, try again later!\",\n \"store/form.schema.loading\": \"Loading form...\",\n \"store/form.schema.error\": \"Error loading form, try again later!\",\n \"store/form.submit.success\": \"Prices updated based on new order configuration\",\n \"admin/editor.custom-price-selector.title\": \"Order Configuration\",\n \"admin/editor.custom-price-selector.description\": \"Order configuration for B2B users\",\n \"admin/editor.custom-price-selector.formTitle.title\": \"Form Title\",\n \"admin/editor.custom-price-selector.formFields.title\": \"Form Fields\",\n \"admin/editor.custom-price-selector.formFields.name\": \"Field Name\",\n \"admin/editor.custom-price-selector.formFields.type\": \"Field Type\",\n \"admin/editor.custom-price-selector.formFields.fieldType\": \"Field Input Type\",\n \"admin/editor.custom-price-selector.formFields.label\": \"Field Label\",\n \"admin/editor.custom-price-selector.formFields.required\": \"Required\",\n \"admin/editor.custom-price-selector.formFields.showInTitle\": \"Show in Title\",\n \"admin/editor.custom-price-selector.formFields.format\": \"Input Format\",\n \"admin/editor.custom-price-selector.formFields.options\": \"Input Options\",\n \"admin/editor.custom-price-selector.formFields.options.description\": \"Options in case of select, radio or checkbox\",\n \"admin/editor.custom-price-selector.formFields.options.label\": \"Option Label\",\n \"admin/editor.custom-price-selector.formFields.options.value\": \"Option Value\"\n}\n\n```"
}
] |
code_order-configuration_1be38d97
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/messages/es.json from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/form.error.required\": \"Este campo es requerido\",\n \"store/form.error.maxLength\": \"Este campo tiene una longitud máxima de: {value}\",\n \"store/form.error.minLength\": \"Este campo tiene una longitud mínima de: {value}\",\n \"store/form.error.maxValue\": \"El valor máximo aceptado por este campo es {value}\",\n \"store/form.error.minValue\": \"El valor mínimo aceptado por este campo es {value}\",\n \"store/form.error.notFloat\": \"Debe ser un número\",\n \"store/form.error.notInteger\": \"Debe ser un entero\",\n \"store/form.error.pattern\": \"Este texto no coincide con el patrón esperado\",\n \"store/form.error.notInEnum\": \"Debe ser uno de los siguientes valores: {values}\",\n \"store/form.error.multipleOf\": \"Debe ser un mútiplo de {value}\",\n \"store/form.error.undefinedError\": \"Valor no válido.\",\n \"store/form.submit.buttonLabel\": \"Salvar\",\n \"store/form.submit.error.userInputError\": \"Encontrado algunos errores en los datos, revise los campos indicados e intente nuevamente.\",\n \"store/form.submit.error.serverError\": \"¡Error interno de servidor! ¡Por favor, inténtelo de nuevo más tarde!\",\n \"store/form.schema.loading\": \"Cargando formulario...\",\n \"store/form.schema.error\": \"Error al cargar el formulario¡Inténtalo de nuevo más tarde!\",\n \"store/form.submit.success\": \"Precios actualizados en función de la nueva configuración del pedido\",\n \"admin/editor.custom-price-selector.title\": \"Configuración de pedido\",\n \"admin/editor.custom-price-selector.description\": \"Configuración de pedidos para usuarios B2B\",\n \"admin/editor.custom-price-selector.formTitle.title\": \"Título del formulario\",\n \"admin/editor.custom-price-selector.formFields.title\": \"Campos de formulario\",\n \"admin/editor.custom-price-selector.formFields.name\": \"Nombre del campo\",\n \"admin/editor.custom-price-selector.formFields.type\": \"Tipo de campo\",\n \"admin/editor.custom-price-selector.formFields.fieldType\": \"Tipo de entrada de campo\",\n \"admin/editor.custom-price-selector.formFields.label\": \"Etiqueta de campo\",\n \"admin/editor.custom-price-selector.formFields.required\": \"Necesario\",\n \"admin/editor.custom-price-selector.formFields.showInTitle\": \"Mostrar en el título\",\n \"admin/editor.custom-price-selector.formFields.format\": \"Formato de entrada\",\n \"admin/editor.custom-price-selector.formFields.options\": \"Opciones de entrada\",\n \"admin/editor.custom-price-selector.formFields.options.description\": \"Opciones en caso de seleccionar, radio o casilla de verificación\",\n \"admin/editor.custom-price-selector.formFields.options.label\": \"Etiqueta de opción\",\n \"admin/editor.custom-price-selector.formFields.options.value\": \"Valor de la opción\"\n}\n\n```"
}
] |
code_order-configuration_2c26a786
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/docs/README.md from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/vtex-apps/order-configuration) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# Order Configuration\n\n<!-- DOCS-IGNORE:start -->\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n<!-- DOCS-IGNORE:end -->\n\nThe **Order Configuration** app, designed for B2B scenarios, displays a form responsible for collecting order data in a modal.\n\n\n\n\nOnce the form is submitted, the order data collected will be available at Master Data and saved in the current VTEX session.\n\n> ℹ This app can be used to enable customization of all kinds of behaviors, such as custom prices, custom products, etc. Keep in mind the Order Configuration app does not offer these functionalities, it only enables other apps to do so.\n\nFollow the steps below to install and set up the **Order Configuration** app in your store.\n\n### Step 1: Install the app\n\n First, you must add the `order-configuration` app to your theme's dependencies in the `manifest.json` file:\n\n```json\ndependencies: {\n \"vtex.order-configuration\": \"2.x\"\n}\n```\n\nThis will enable you to use the blocks exported by the `order-configuration` app. Check out the full list below:\n\n| Block name | Description |\n| -------------- | ----------------------------------------------- |\n| `order-config` | Parent block only responsible for rendering its children blocks, that in turn build the Order Configuration component. |\n| `order-config.title` | Renders the component title, that is, the message text displayed for users to present the component. On the image above, the component title is `Order Configuration`. |\n| `order-config.modal` | Renders the modal responsible for displaying the component content. |\n| `order-config.form` | Renders the component content, that is, a form to be filled out by users. |\n\n\n### Step 2: Declare the required blocks\n\nAdd the `order-config` block in the Header component, as shown in the example below.\n\n```json\n{\n \"header-layout.desktop\": {\n \"children\": [\n \"flex-layout.row#1-desktop\",\n \"flex-layout.row#2-desktop\",\n \"flex-layout.row#3-desktop\",\n \"sticky-layout#4-desktop\"\n ]\n },\n \"flex-layout.row#3-desktop\": {\n \"props\": {\n \"blockClass\": \"menu-link\",\n \"horizontalAlign\": \"center\",\n \"preventHorizontalStretch\": true,\n \"preventVerticalStretch\": true,\n \"fullWidth\": true\n },\n \"children\": [\n \"vtex.menu@2.x:menu#websites\",\n \"flex-layout.col#spacer\",\n+ \"order-config#header\",\n \"vtex.menu@2.x:menu#institutional\"\n ]\n },\n```\n\nThen, declare the `order-config#header` block and its children blocks: `order-config.title` and `order-config.modal`. Example:\n\n```json\n{\n \"order-config#header\": {\n \"children\": [\n \"order-config.title#header\",\n \"order-config.modal#header\"\n ],\n \"props\": {\n \"blockClass\": \"header\",\n \"formFields\": [\n {\n \"name\": \"orderType\",\n \"type\": \"string\",\n \"fieldType\": \"radio\",\n \"label\": \"Order Type\",\n \"defaultValue\": \"resale\",\n \"options\": [\n {\n \"label\": \"Resale\",\n \"value\": \"resale\"\n },\n {\n \"label\": \"Consumption\",\n \"value\": \"consumption\"\n }\n ]\n },\n {\n \"name\": \"state\",\n \"type\": \"string\",\n \"fieldType\": \"select\",\n \"label\": \"State\",\n \"showInTitle\": true,\n \"options\": [\n {\n \"label\": \"ES\",\n \"value\": \"ES\"\n },\n {\n \"label\": \"SP\",\n \"value\": \"SP\"\n }\n ]\n }\n ]\n }\n },\n \"order-config.modal#header\": {\n \"children\": [\n \"order-config.form\"\n ]\n },\n \"order-config.title#header\": {\n \"props\": {\n \"formTitle\": \"Order Configuration for Header\"\n }\n },\n}\n```\n\n> ℹ If the `order-config.form` block does not have any children configured, a default form will be rendered automatically based on the [React Hook Form JSON Schema](https://github.com/vtex/react-hook-form-jsonschema) library. To declare children blocks according to your business needs, check out the [Advanced configuration](#advanced-configuration) section below.\n\n### Step 3: Create `main` schema in Master Data\n\nYou must create a schema named `main` in Master Data, using the `order_configuration` data entity.\n\nYou can place a request using the Save schema by name endpoint of the [Master Data API - v2](https://developers.vtex.com/vtex-rest-api/reference/schemas#saveschemabyname) to do so.\n\nThe schema should contain all the data that you added in the form above, otherwise the data will not be persisted.\n\n#### Request body example\n\n```json\n{\n \"v-cache\": false,\n \"properties\": {\n \"clientId\": {\n \"type\": \"string\"\n },\n \"orderType\": {\n \"type\": \"string\"\n },\n \"state\": {\n \"type\": \"string\"\n }\n },\n \"v-default-fields\": [\n \"clientId\",\n \"orderType\",\n \"state\"\n ],\n \"v-indexed\": [\n \"clientId\",\n \"orderType\",\n \"state\"\n ]\n}\n```\n\nRefer to [Master Data API - v2 documentation](https://developers.vtex.com/vtex-rest-api/reference/schemas#saveschemabyname) for more details.\n\n### Step 4: Update orderForm configuration\n\nIt is also necessary to configure a new app in the `orderForm`.\n\nFirst, place a `GET` [Get orderForm configuration](https://developers.vtex.com/vtex-developer-docs/reference/getorderformconfiguration) request to retrieve the current `orderForm` settings before updating them. By doing so you ensure that you will only change the properties you want in the next step.\n\nThen, place a `POST` [Update orderForm configuration](https://developers.vtex.com/vtex-developer-docs/reference/updateorderformconfiguration) request, setting the following object inside the `apps` object in the request body:\n\n```json\n {\n \"fields\": [\n \"values\"\n ],\n \"id\": \"orderconfig\",\n \"major\": 1\n }\n```\n\n#### Request body example\n\n```json\n{\n \"paymentConfiguration\": {\n \"requiresAuthenticationForPreAuthorizedPaymentOption\": false,\n \"allowInstallmentsMerge\": null,\n \"blockPaymentSession\": null,\n \"paymentSystemToCheckFirstInstallment\": null,\n \"defaultPaymentSystemToApplyOnUserOrderForm\": null\n },\n \"taxConfiguration\": null,\n \"minimumQuantityAccumulatedForItems\": 1,\n \"decimalDigitsPrecision\": 2,\n \"minimumValueAccumulated\": null,\n \"apps\": [\n {\n \"fields\": [\n \"quoteId\"\n ],\n \"id\": \"b2b-quotes-graphql\",\n \"major\": 1\n },\n {\n \"fields\": [\n \"values\"\n ],\n \"id\": \"orderconfig\",\n \"major\": 1\n }\n ],\n \"allowMultipleDeliveries\": true,\n \"allowManualPrice\": true,\n \"maxNumberOfWhiteLabelSellers\": null,\n \"maskFirstPurchaseData\": null,\n \"recaptchaValidation\": \"vtexcriteria\",\n \"maskStateOnAddress\": true\n}\n```\n\nYou can refer to [Checkout API documentation](https://developers.vtex.com/vtex-developer-docs/reference/updateorderformconfiguration) for more information.\n\n\n### Advanced configuration\n\nIf desired, you can declare the `order-config.form` block by adding and configuring the `formFields` prop and an array of form children blocks (whose descriptions you can find below).\n\n```json\n{\n \"order-config#static-page\": {\n \"props\": {\n \"formFields\": [\n {\n \"name\": \"orderType\",\n \"type\": \"string\",\n \"fieldType\": \"select\",\n \"label\": \"Order Type\",\n \"defaultValue\": \"res\",\n \"showInTitle\": true,\n \"options\": [\n {\n \"label\": \"Resale\",\n \"value\": \"res\"\n },\n {\n \"label\": \"Consumption\",\n \"value\": \"cons\"\n }\n ]\n },\n {\n \"name\": \"state\",\n \"type\": \"string\",\n \"fieldType\": \"select\",\n \"label\": \"State\",\n \"showInTitle\": true,\n \"required\": true,\n \"options\": [\n {\n \"label\": \"ES\",\n \"value\": \"ES\"\n },\n {\n \"label\": \"SP\",\n \"value\": \"SP\"\n }\n ]\n },\n {\n \"name\": \"someTextInput\",\n \"label\": \"Some Text Input\",\n \"fieldType\": \"input\",\n \"type\": \"string\",\n \"required\": true,\n \"showInTitle\": true\n }\n ]\n },\n \"children\": [\n \"order-config.title#static-page\",\n \"order-config.form#static-page\"\n ]\n },\n \"order-config.form#static-page\": {\n \"children\": [\n \"flex-layout.row#state-and-payment-method\",\n \"order-config.text#some-text-input\",\n \"order-config.submit\"\n ]\n },\n \"flex-layout.row#state-and-payment-method\": {\n \"children\": [\n \"order-config.dropdown#state\",\n \"order-config.radiogroup#payment-method\"\n ],\n \"props\": {\n \"blockClass\": \"stateAndPaymentMethod\"\n }\n },\n \"order-config.dropdown#state\": {\n \"props\": {\n \"pointer\": \"#/properties/state\"\n }\n },\n \"order-config.radiogroup#payment-method\": {\n \"props\": {\n \"pointer\": \"#/properties/paymentMethod\"\n }\n },\n \"order-config.text#some-text-input\": {\n \"props\": {\n \"pointer\": \"#/properties/someTextInput\"\n }\n },\n \"order-config.title#static-page\": {\n \"props\": {\n \"formTitle\": \"Order Configuration for Static Page\"\n }\n }\n}\n```\n\n| Block name | Description |\n| -------------- | ----------------------------------------------- |\n| `order-config.submit` | Renders a `Submit` button. |\n| `order-config.dropdown` | Renders the a dropdown field. |\n| `order-config.radiogroup` | Renders a radiogroup field. |\n| `order-config.text` | Renders a text field. |\n| `order-config.textarea` | Renders a text field with a wider range of available characters. |\n| `order-config.checkbox` | Renders a checkbox field. |\n\n#### Props\n\nCheck out the description of the available props below.\n\n| Prop name | Type | Description | Default Value | Block name |\n| --------- | -------- | ------------| ----------------- | -------- | \n| `pointer` | `string` | Path to which the block must point in the `formFields` prop in order to properly work. | `undefined` | `order-config.dropdown`, `order-config.radiogroup`, `order-config.text`, `order-config.textarea`, and `order-config.checkbox` |\n| `formFields` | `object` | Object responsible for defining the form fields. | `undefined` | `order-config.form` |\n\nThe `formFields` object contains the following props:\n\n| Prop name | Type | Description | Default Value |\n| --------| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- |\n| `name` | `string` | Name of the field (only used as an identifier in your code). | `undefined` |\n| `type` | `enum` | Value type accepted by the field. Possible values are `string` and `number`. | `string` |\n| `fieldType` | `enum` | Input type accepted by the field. Possible values are: `text`, `textarea`, `select`, `radio`, and `checkbox`. | `text` |\n| `label` | `string` | Field name shown to users. | `undefined` |\n| `showInTitle` | `boolean` | Whether to display the value type accepted by the field on its name (`true`) or not (`false`). | `false` |\n| `options` | `object` | Field options to be defined in case `select`, `radio`, or `checkbox` values were declared in the `fieldType` prop. | `undefined` |\n\nThe `options` object contains the following props:\n\n| Prop name | Type | Description | Default Value |\n| ----------- | ----------------------------------------- | -------------------------------------------------------------------------------------- | ----------------- |\n| `label` | `string` | Option name shown to users. | `undefined` |\n| `value` | `string` | Option value. | `undefined` |\n\n## Customization\n\nIn order to apply CSS customizations in this and other blocks, follow the instructions given in the recipe on [Using CSS Handles for store customization](https://vtex.io/docs/recipes/style/using-css-handles-for-store-customization).\n\n| CSS Handles |\n| ----------- |\n| `formSubmitButton` |\n| `formSubmitContainer` |\n| `formErrorServer` |\n| `formErrorUserInput` |\n| `loader` |\n| `orderConfigFormWrapper` |\n| `formObject` |\n| `title` |\n| `titleValues` |\n| `titleWrapper` |\n| `wrapper` |\n\n<!-- DOCS-IGNORE:start -->\n## Contributors ✨\n\nThanks goes to these wonderful people:\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!\n\n<!-- DOCS-IGNORE:end -->\n\n```"
}
] |
code_order-configuration_6c65d8d0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/graphql/schema.graphql from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ntype Query {\n\n \"\"\"\n Get orderConfiguration from our backend\n \"\"\"\n orderConfiguration: OrderConfig @cacheControl(scope: PRIVATE, maxAge: SHORT)\n}\n\ninput FieldInput {\n Key: String!\n Value: String!\n}\n\ninput OrderConfigInput {\n fields: [FieldInput]\n}\n\ntype Mutation {\n \"\"\"\n Save an order configuration\n \"\"\"\n saveOrderConfiguration(orderConfig: OrderConfigInput): Boolean @cacheControl(scope: PRIVATE, maxAge: SHORT)\n}\n\n```"
}
] |
code_order-configuration_7c13ebaa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/package.json from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"@vtex/clients\": \"^1.0.4\",\n \"axios\": \"^0.21.0\",\n \"co-body\": \"^6.0.0\",\n \"cookie\": \"^0.4.1\",\n \"jsonwebtoken\": \"^8.5.1\",\n \"ramda\": \"^0.27.0\"\n },\n \"devDependencies\": {\n \"@types/chai\": \"^4.2.14\",\n \"@types/co-body\": \"0.0.3\",\n \"@types/cookie\": \"^0.4.0\",\n \"@types/jsonwebtoken\": \"^8.3.3\",\n \"@types/mocha\": \"^8.2.0\",\n \"@types/node\": \"^14.14.11\",\n \"@types/ramda\": \"^0.27.11\",\n \"@vtex/api\": \"6.37.0\",\n \"@vtex/tsconfig\": \"^0.3.0\",\n \"chai\": \"^4.2.0\",\n \"dotenv\": \"^8.2.0\",\n \"mocha\": \"^8.2.1\",\n \"ts-mockito\": \"^2.6.1\",\n \"ts-node\": \"^9.1.1\",\n \"tslint\": \"^5.14.0\",\n \"tslint-config-vtex\": \"^2.1.0\",\n \"typescript\": \"3.9.7\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty && tslint -c tslint.json --fix './**/*.ts'\",\n \"test\": \"mocha --require ts-node/register --require=dotenv/config --timeout 5000 --exit \\\"test/**/*.test.ts\\\"\"\n },\n \"version\": \"3.3.1\"\n}\n\n```"
}
] |
code_order-configuration_03e0bc51
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/globals.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {\n IOContext,\n MetricsAccumulator,\n ParamsContext,\n RecorderState,\n SegmentData,\n ServiceContext\n} from \"@vtex/api\";\n\nimport { Clients } from \"./clients\";\n\nif (!global.metrics) {\n console.error(\"No global.metrics at require time\");\n global.metrics = new MetricsAccumulator();\n}\n\nexport type Context = ServiceContext<Clients, RecorderState, CustomContext>;\n\ndeclare global {\n type Context = ServiceContext<Clients, RecorderState, CustomContext>;\n\n interface CustomContext extends ParamsContext {\n cookie: string;\n originalPath: string;\n vtex: CustomIOContext;\n }\n\n interface CustomIOContext extends IOContext {\n segment?: SegmentData;\n orderFormId?: string;\n }\n\n interface KeyValue {\n key: string;\n value: string;\n }\n\n interface Property {\n name: string;\n values: [string];\n }\n}\n\n```"
}
] |
code_order-configuration_96fcea53
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/index.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport \"./globals\";\n\nimport { LRUCache, RecorderState, Service } from \"@vtex/api\";\n\nimport { Clients } from \"./clients\";\n// import { dataSources } from './dataSources'\n// import { schemaDirectives } from './directives'\nimport { resolvers } from \"./resolvers\";\n\nconst TWO_SECONDS_MS = 2 * 1000;\nconst THREE_SECONDS_MS = 3 * 1000;\n// const SIX_SECONDS_MS = 6 * 1000\nconst TEN_SECONDS_MS = 10 * 1000;\nconst THIRTY_SECONDS_MS = 30 * 1000;\n\n// Segments are small and immutable.\nconst MAX_SEGMENT_CACHE = 10000;\nconst segmentCache = new LRUCache<string, any>({ max: MAX_SEGMENT_CACHE });\n// const catalogCache = new LRUCache<string, any>({max: 3000})\nconst messagesCache = new LRUCache<string, any>({ max: 3000 });\n\nexport default new Service<Clients, RecorderState, CustomContext>({\n clients: {\n implementation: Clients,\n options: {\n checkout: {\n concurrency: 10,\n timeout: THIRTY_SECONDS_MS\n },\n default: {\n retries: 2,\n timeout: THREE_SECONDS_MS\n },\n messagesGraphQL: {\n concurrency: 5,\n memoryCache: messagesCache,\n timeout: TWO_SECONDS_MS\n },\n session: {\n concurrency: 10,\n timeout: TEN_SECONDS_MS\n },\n segment: {\n concurrency: 10,\n memoryCache: segmentCache,\n timeout: THREE_SECONDS_MS\n }\n }\n },\n graphql: {\n // dataSources,\n resolvers\n // schemaDirectives,\n }\n});\n\n```"
}
] |
code_order-configuration_11083e4c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/OrderConfigurationModal.tsx from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useCallback } from 'react'\nimport { pathOr } from 'ramda'\n\nimport { ButtonWithIcon, IconEdit, Modal } from 'vtex.styleguide'\nimport {\n useOrderConfigurationDispatch,\n useOrderConfiguration,\n} from './OrderConfigurationContext'\n\nconst OrderConfigurationModal = (props: { title: string; children: any }) => {\n const dispatch = useOrderConfigurationDispatch()\n const {\n modal: { isOpen },\n } = useOrderConfiguration()\n const onModalOpen = useCallback(() => {\n dispatch({ type: 'SET_MODAL_OPEN', args: { isModalOpen: true } })\n }, [dispatch])\n const onModalClose = useCallback(() => {\n dispatch({ type: 'SET_MODAL_CLOSED', args: { isModalOpen: false } })\n }, [dispatch])\n\n return (\n <div className=\"tc\">\n <div className=\"h-100\">\n <div className=\"h-100 flex items-center\">\n <ButtonWithIcon\n icon={<IconEdit />}\n iconPosition=\"right\"\n variation=\"secondary\"\n onClick={onModalOpen}\n />\n </div>\n\n <Modal\n centered\n isOpen={isOpen}\n onClose={onModalClose}\n title={pathOr('Order Configuration', ['title'], props)}\n >\n {props.children}\n </Modal>\n </div>\n </div>\n )\n}\n\nexport default OrderConfigurationModal\n\n```"
}
] |
code_order-configuration_e13f2b10
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/Title.tsx from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useCallback } from 'react'\nimport { filter, pick, values } from 'ramda'\nimport { useCssHandles } from 'vtex.css-handles'\nimport {\n useOrderConfigurationDispatch,\n useOrderConfiguration,\n} from './OrderConfigurationContext'\nconst CSS_HANDLES = ['title', 'titleValues', 'titleWrapper'] as const\n\nconst Title: StorefrontFunctionComponent<{\n formTitle: string\n}> = props => {\n const handles = useCssHandles(CSS_HANDLES)\n const { selectedValues, formFields } = useOrderConfiguration()\n const dispatch = useOrderConfigurationDispatch()\n const { formTitle } = props\n const onModalOpen = useCallback(() => {\n dispatch({ type: 'SET_MODAL_OPEN', args: { isModalOpen: true } })\n }, [dispatch])\n\n return (\n <div\n onClick={onModalOpen}\n aria-hidden=\"true\"\n className={`flex items-center shadow-hover ${handles.titleWrapper}`}\n >\n <span className={`mr4 ${handles.title}`}>{formTitle}</span>\n <span className={`mr4 fw6 ${handles.titleValues}`}>\n {values(\n pick(\n filter(field => field.showInTitle, formFields).map(\n field => field.name\n ),\n selectedValues\n )\n ).join(', ')}\n </span>\n </div>\n )\n}\n\nTitle.defaultProps = {\n formTitle: 'Order Configuration',\n}\n\nexport default Title\n\n```"
}
] |
code_order-configuration_8bc16fcd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/OrderConfigurationContext.tsx from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { createContext, useReducer, useContext, FC } from 'react'\nimport { FormField } from './typings/FormProps'\nimport { OrderConfiguration } from './typings/global'\n\nconst OrderConfigurationContext = createContext<State | undefined>(undefined)\nconst OrderConfigurationDispatchContext = createContext<Dispatch | undefined>(\n undefined\n)\n\ninterface State {\n isLoading: boolean\n modal: {\n isOpen: boolean\n }\n selectedValues: OrderConfiguration\n formFields: FormField[]\n}\n\ntype Dispatch = (action: Action) => void\n\ninterface SetLoadingAction {\n type: 'SET_LOADING'\n args: {\n isLoading: boolean\n }\n}\n\ninterface SetModalOpenAction {\n type: 'SET_MODAL_OPEN'\n args: {\n isModalOpen: boolean\n }\n}\n\ninterface SetModalClosedAction {\n type: 'SET_MODAL_CLOSED'\n args: {\n isModalOpen: boolean\n }\n}\n\ntype Action = SetLoadingAction | SetModalOpenAction | SetModalClosedAction\n\nexport const reducer = (state: State, action: Action) => {\n switch (action.type) {\n case 'SET_LOADING': {\n return {\n ...state,\n isLoading: action.args.isLoading,\n }\n }\n case 'SET_MODAL_OPEN': {\n return {\n ...state,\n modal: {\n ...state.modal,\n isOpen: action.args.isModalOpen,\n },\n }\n }\n case 'SET_MODAL_CLOSED': {\n return {\n ...state,\n modal: {\n ...state.modal,\n isOpen: action.args.isModalOpen,\n },\n }\n }\n default:\n return state\n }\n}\n\ninterface Props {\n selectedValues: OrderConfiguration\n formFields: FormField[]\n}\n\nexport const OrderConfigurationContextProvider: FC<Props> = ({\n selectedValues,\n formFields,\n children,\n}) => {\n const initialState = {\n selectedValues,\n formFields,\n isLoading: true,\n modal: {\n isOpen: false,\n },\n }\n const [state, dispatch] = useReducer(reducer, initialState)\n return (\n <OrderConfigurationContext.Provider value={state}>\n <OrderConfigurationDispatchContext.Provider value={dispatch}>\n {children}\n </OrderConfigurationDispatchContext.Provider>\n </OrderConfigurationContext.Provider>\n )\n}\n\nexport function useOrderConfigurationDispatch() {\n const context = useContext(OrderConfigurationDispatchContext)\n\n if (context === undefined) {\n throw new Error(\n 'useOrderConfigurationDispatch must be used within a OrderConfigurationContextProvider'\n )\n }\n\n return context\n}\n\nexport function useOrderConfiguration() {\n const context = useContext(OrderConfigurationContext)\n\n if (context === undefined) {\n throw new Error(\n 'useOrderConfiguration must be used within a OrderConfigurationContextProvider'\n )\n }\n\n return context\n}\n\n```"
}
] |
code_order-configuration_059085b2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/FormInputRadiogroup.tsx from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { RadioGroupInput } from './components/RadioGroup'\n\nexport default RadioGroupInput\n\n```"
}
] |
code_order-configuration_50708797
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/FormSubmit.tsx from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useContext } from 'react'\nimport { defineMessages } from 'react-intl'\nimport { Button, Alert } from 'vtex.styleguide'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { IOMessage } from 'vtex.native-types'\n\nimport { SubmitContext } from './logic/formState'\n\nexport interface FormSubmitProps {\n label?: string\n}\n\nconst CSS_HANDLES = [\n 'formSubmitContainer',\n 'formSubmitButton',\n 'formErrorServer',\n 'formErrorUserInput',\n] as const\n\nconst messages = defineMessages({\n submitButton: {\n id: 'store/form.submit.buttonLabel',\n defaultMessage: '',\n },\n userInputError: {\n id: 'store/form.submit.error.userInputError',\n defaultMessage: '',\n },\n serverError: {\n id: 'store/form.submit.error.serverError',\n defaultMessage: '',\n },\n})\n\nexport default function FormSubmit({\n label = messages.submitButton.id,\n}: FormSubmitProps) {\n const { loading, userInputError, serverError } = useContext(SubmitContext)\n const handles = useCssHandles(CSS_HANDLES)\n\n return (\n <div className={handles.formSubmitContainer}>\n <div className={handles.formSubmitButton}>\n <Button type=\"submit\" isLoading={loading}>\n <IOMessage id={label} />\n </Button>\n </div>\n <div className={handles.formErrorUserInput}>\n {userInputError && (\n <Alert type=\"error\">\n <IOMessage id={messages.userInputError.id} />\n </Alert>\n )}\n </div>\n <div className={handles.formErrorServer}>\n {serverError && (\n <Alert type=\"error\">\n <IOMessage id={messages.serverError.id} />\n </Alert>\n )}\n </div>\n </div>\n )\n}\n\n```"
}
] |
code_order-configuration_8543cb82
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/OrderConfigurationSelector.tsx from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { useQuery } from 'react-apollo'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport orderConfiguration from './queries/orderConfiguration.graphql'\nimport { OrderConfigurationContextProvider } from './OrderConfigurationContext'\nimport { FormField } from './typings/FormProps'\nimport { fromFieldArrayFormat } from './logic/fromFieldArrayFormat'\n\nconst CSS_HANDLES = ['loader', 'wrapper'] as const\n\ninterface Props {\n formFields: FormField[]\n}\n\nconst OrderConfigurationSelector: StorefrontFunctionComponent<Props> = props => {\n const { data, loading } = useQuery(orderConfiguration, {\n ssr: false,\n })\n const orderConfigurationFields =\n data && data.orderConfiguration && data.orderConfiguration.fields\n const orderConfigurationLoading = loading\n\n const handles = useCssHandles(CSS_HANDLES)\n\n if (orderConfigurationLoading) {\n return (\n <div className={`h-100 flex items-center ${handles.loader}`}>\n Loading...\n </div>\n )\n }\n\n const selectedValues = orderConfigurationFields\n ? fromFieldArrayFormat(orderConfigurationFields)\n : {}\n\n return (\n <OrderConfigurationContextProvider\n selectedValues={selectedValues}\n formFields={props.formFields}\n >\n <div className={`mw9 center flex flex-column ${handles.wrapper}`}>\n {props.children}\n </div>\n </OrderConfigurationContextProvider>\n )\n}\n\nOrderConfigurationSelector.schema = {\n title: 'admin/editor.custom-price-selector.title',\n description: 'admin/editor.custom-price-selector.description',\n type: 'object',\n properties: {\n formTitle: {\n title: 'admin/editor.custom-price-selector.formTitle.title',\n type: 'string',\n default: 'Order Configuration',\n },\n formFields: {\n title: 'admin/editor.custom-price-selector.formFields.title',\n type: 'array',\n items: {\n title: 'admin/editor.custom-price-selector.formFields.title',\n type: 'object',\n properties: {\n name: {\n title: 'admin/editor.custom-price-selector.formFields.name',\n type: 'string',\n },\n type: {\n title: 'admin/editor.custom-price-selector.formFields.type',\n type: 'string',\n enum: ['string', 'number'],\n enumNames: ['String', 'Number'],\n widget: {\n 'ui:widget': 'radio',\n },\n default: 'string',\n },\n fieldType: {\n title: 'admin/editor.custom-price-selector.formFields.fieldType',\n type: 'string',\n enum: ['text', 'textarea', 'select', 'radio', 'checkbox'],\n enumNames: ['Text', 'Textarea', 'Select', 'Radio', 'Checkbox'],\n default: 'text',\n },\n label: {\n title: 'admin/editor.custom-price-selector.formFields.label',\n type: 'string',\n },\n required: {\n title: 'admin/editor.custom-price-selector.formFields.required',\n type: 'boolean',\n },\n showInTitle: {\n title: 'admin/editor.custom-price-selector.formFields.showInTitle',\n type: 'boolean',\n default: false,\n },\n format: {\n title: 'admin/editor.custom-price-selector.formFields.format',\n type: 'string',\n enum: ['', 'email', 'date-time', 'hostname', 'ipv4', 'ipv6', 'uri'],\n enumNames: [\n 'Not specified',\n 'Email',\n 'Date/time in ISO format',\n 'Internet host name',\n 'IPv4 address',\n 'IPv6 address',\n 'A universal resource identifier',\n ],\n },\n options: {\n title: 'admin/editor.custom-price-selector.formFields.options',\n description:\n 'admin/editor.custom-price-selector.formFields.options.description',\n type: 'array',\n items: {\n title: 'admin/editor.custom-price-selector.formFields.options',\n type: 'object',\n properties: {\n label: {\n title:\n 'admin/editor.custom-price-selector.formFields.options.label',\n type: 'string',\n },\n value: {\n title:\n 'admin/editor.custom-price-selector.formFields.options.value',\n type: 'string',\n },\n },\n },\n },\n },\n },\n },\n },\n}\n\nexport default OrderConfigurationSelector\n\n```"
}
] |
code_order-configuration_132a5a23
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/FormInputText.tsx from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport { RawInput, HiddenInput, PasswordInput } from './components/Input'\nimport { FormRawInputProps, InputTypes } from './typings/InputProps'\n\nexport default function FormInput(props: FormRawInputProps) {\n const { inputType = InputTypes.input, ...rest } = props\n\n const INPUT_TYPES = {\n [InputTypes.input]: <RawInput {...rest} pointer={props.pointer} />,\n [InputTypes.hidden]: <HiddenInput {...rest} pointer={props.pointer} />,\n [InputTypes.password]: <PasswordInput {...rest} pointer={props.pointer} />,\n }\n\n return INPUT_TYPES[inputType]\n}\n\n```"
}
] |
code_order-configuration_6b7b7ca1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/package.json from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"custom-price-selector\",\n \"version\": \"3.3.1\",\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 \"apollo-cache-inmemory\": \"^1.6.6\",\n \"apollo-client\": \"^2.6.8\",\n \"apollo-link-http\": \"^1.5.17\",\n \"classnames\": \"^2.2.6\",\n \"ramda\": \"^0.26.1\",\n \"react\": \"^16.8.3\",\n \"react-apollo\": \"^3.1.3\",\n \"react-dom\": \"^16.8.3\",\n \"react-hook-form-jsonschema\": \"0.2.0-beta.11\",\n \"react-intl\": \"^4.5.3\",\n \"unfetch\": \"^4.2.0\"\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.9.7\"\n }\n}\n\n```"
}
] |
code_order-configuration_51696891
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/OrderConfigurationForm.tsx from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { contains, pathOr } from 'ramda'\nimport { FormattedMessage } from 'react-intl'\nimport { UITypes } from 'react-hook-form-jsonschema'\n\nimport { CustomPriceSelectorProps, FormField } from './typings/FormProps'\nimport { TOAST_DURATION_MS } from './utils/toast'\nimport { ObjectMapper } from './components/Object'\nimport { FormHandler } from './components/FormHandler'\nimport FormSubmit from './FormSubmit'\nimport { useOrderConfiguration } from './OrderConfigurationContext'\nimport { ToastConsumer } from 'vtex.styleguide'\nimport { ToastRenderProps } from './typings/global'\n\ninterface CustomPriceSchema {\n type: string\n properties: Record<string, object>\n required: string[]\n}\n\ninterface FormFieldOption {\n value: string\n}\n\nconst UI_TYPES = {\n text: UITypes.input,\n select: UITypes.select,\n radio: UITypes.radio,\n checkbox: UITypes.checkbox,\n}\n\nconst generatePriceSchema = (formFields: FormField[]) =>\n formFields.reduce(\n (acc: CustomPriceSchema, formField) => {\n const hasEnum = contains(pathOr('text', ['fieldType'], formField), [\n 'select',\n 'radio',\n ])\n\n const fieldProps = {\n type: formField.type || 'string',\n title: formField.label || formField.name,\n enum: hasEnum\n ? (formField.options || []).map(\n (option: FormFieldOption) => option.value\n )\n : undefined,\n format: formField.format ?? '',\n }\n\n return {\n ...acc,\n properties: {\n ...acc.properties,\n [formField.name]: fieldProps,\n },\n required: formField.required\n ? [...acc.required, formField.name]\n : acc.required,\n }\n },\n {\n type: 'object',\n properties: {},\n required: [],\n }\n )\n\nconst generateUISchema = (formFields: FormField[]) => {\n const properties = formFields.reduce((acc: object, formField) => {\n const fieldType: keyof typeof UI_TYPES = formField.fieldType || 'text'\n return {\n ...acc,\n [formField.name]: {\n type: UI_TYPES[fieldType],\n },\n }\n }, {})\n return { type: UITypes.default, properties }\n}\n\nconst OrderConfigurationForm: StorefrontFunctionComponent<CustomPriceSelectorProps> = props => {\n const { selectedValues, formFields } = useOrderConfiguration()\n\n const customPriceSchema: CustomPriceSchema = generatePriceSchema(formFields)\n const UISchema = generateUISchema(formFields)\n\n return (\n <ToastConsumer>\n {({ showToast }: ToastRenderProps) => {\n const onSuccessfulSubmit = () => {\n window.location.reload()\n showToast({\n message: <FormattedMessage id=\"store/form.submit.success\" />,\n duration: TOAST_DURATION_MS,\n })\n }\n if (!React.Children.count(props.children)) {\n return (\n <FormHandler\n schema={customPriceSchema}\n formProps={props}\n onSuccessfulSubmit={onSuccessfulSubmit}\n >\n <ObjectMapper\n pointer=\"#\"\n uiSchema={UISchema}\n formFields={formFields}\n defaultValues={selectedValues}\n />\n <FormSubmit label=\"Submit\" />\n </FormHandler>\n )\n }\n return (\n <FormHandler\n schema={customPriceSchema}\n formProps={props}\n onSuccessfulSubmit={onSuccessfulSubmit}\n >\n {props.children}\n </FormHandler>\n )\n }}\n </ToastConsumer>\n )\n}\n\nOrderConfigurationForm.defaultProps = {\n onSuccessfulSubmit: () => {\n window.location.reload()\n },\n}\n\nexport default OrderConfigurationForm\n\n```"
}
] |
code_order-configuration_5913dc2c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/FormInputDropdown.tsx from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { DropdownInput } from './components/Dropdown'\n\nexport default DropdownInput\n\n```"
}
] |
code_order-configuration_e2a99dcc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/store/blocks.json from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"order-config\": {\n \"props\": {\n \"formFields\": [\n {\n \"name\": \"orderType\",\n \"type\": \"string\",\n \"fieldType\": \"radio\",\n \"label\": \"Order Type\",\n \"defaultValue\": \"resale\",\n \"options\": [\n {\n \"label\": \"Resale\",\n \"value\": \"resale\"\n },\n {\n \"label\": \"Consumption\",\n \"value\": \"consumption\"\n }\n ]\n },\n {\n \"name\": \"paymentMethod\",\n \"type\": \"string\",\n \"fieldType\": \"select\",\n \"label\": \"Payment Method\",\n \"defaultValue\": \"promissory_note\",\n \"options\": [\n {\n \"label\": \"Promissory Note\",\n \"value\": \"promissory_note\"\n },\n {\n \"label\": \"Credit Card\",\n \"value\": \"credit_card\"\n }\n ]\n }\n ]\n },\n \"children\": [\n \"order-config.title\",\n \"order-config.form\"\n ]\n },\n \"order-config.title\": {\n \"props\": {\n \"formTitle\": \"Order Configuration Default\"\n }\n }\n}\n\n```"
}
] |
code_order-configuration_a8c78c66
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/store/interfaces.json from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"order-config\": {\n \"component\": \"OrderConfigurationSelector\",\n \"composition\": \"children\",\n \"allowed\": [\n \"order-config.modal\",\n \"order-config.form\",\n \"order-config.title\",\n \"flex-layout\"\n ]\n },\n \"order-config.modal\": {\n \"component\": \"OrderConfigurationModal\",\n \"composition\": \"children\",\n \"allowed\": [\n \"order-config.form\",\n \"order-config.title\"\n ]\n },\n \"order-config.form\": {\n \"component\": \"OrderConfigurationForm\",\n \"composition\": \"children\"\n },\n \"order-config.text\": {\n \"component\": \"FormInputText\"\n },\n \"order-config.dropdown\": {\n \"component\": \"FormInputDropdown\"\n },\n \"order-config.radiogroup\": {\n \"component\": \"FormInputRadiogroup\"\n },\n \"order-config.submit\": {\n \"component\": \"FormSubmit\"\n },\n \"order-config.title\": {\n \"component\": \"Title\"\n }\n}\n\n```"
}
] |
code_order-configuration_1e7ee099
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/graphql/types/OrderConfiguration.graphql from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ntype Field {\n Key: String!\n Value: String!\n}\n\ntype OrderConfig {\n fields: [Field]\n}\n\n```"
}
] |
code_order-configuration_7247cd0c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/clients/index.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from \"@vtex/api\";\nimport { Checkout } from \"@vtex/clients\";\n\nimport { CustomPrice } from \"./customPrice\";\n\n// Extend the default IOClients implementation with our own custom clients.\nexport class Clients extends IOClients {\n public get customPrice() {\n return this.getOrSet(\"customPrice\", CustomPrice);\n }\n\n public get checkout() {\n return this.getOrSet(\"checkout\", Checkout);\n }\n}\n\n```"
}
] |
code_order-configuration_a527c375
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/clients/customPrice.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {\n ExternalClient,\n InstanceOptions,\n IOContext,\n RequestConfig\n} from \"@vtex/api\";\n\nimport { statusToError } from \"../utils\";\n\nexport class CustomPrice extends ExternalClient {\n public constructor(ctx: IOContext, options?: InstanceOptions) {\n super(`https://${ctx.account}.myvtex.com/_v/custom-prices`, ctx, {\n ...options,\n headers: {\n ...(options && options.headers),\n ...{ Accept: \"application/vnd.vtex.ds.v10+json\" },\n ...(ctx.adminUserAuthToken\n ? { VtexIdclientAutCookie: ctx.adminUserAuthToken }\n : null),\n ...(ctx.storeUserAuthToken\n ? { VtexIdclientAutCookie: ctx.storeUserAuthToken }\n : null)\n }\n });\n }\n\n public getSchemas = <T>() =>\n this.get<T>(this.routes.schemas(), {\n metric: \"customPrices-getSchemas\"\n });\n\n protected get = <T>(url: string, config?: RequestConfig) => {\n return this.http.get<T>(url, config).catch(statusToError);\n };\n\n private get routes() {\n return {\n schema: (acronym: string, schema: string) =>\n `${acronym}/schemas/${schema}`,\n schemas: () => \"session/schema\"\n };\n }\n}\n\n```"
}
] |
code_order-configuration_2bc1a740
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/typings/Checkout.d.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface CheckoutAddress {\n addressType: string\n receiverName: string | null\n addressId: string\n postalCode: string\n city: string\n state: string\n country: string\n street: string\n number: string\n neighborhood: string\n complement: string\n reference: string | null\n geoCoordinates: [number, number]\n}\n\n```"
}
] |
code_order-configuration_1b31d058
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/typings/global.d.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface GithubAuthHeader {\n Authorization: string,\n 'X-Vtex-Use-Https': string\n}\n\ninterface DocsBotConfigs {\n pem: string,\n reposWithoutReadMe: string[]\n}\n\n```"
}
] |
code_order-configuration_ad9cf8a3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/utils/fromFieldArrayFormat.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const fromFieldArrayFormat = (fieldArray: { Key: string; Value: string }[]): Record<string, string> => {\n const recordToReturn: Record<string, string> = {};\n for(let item of fieldArray) {\n recordToReturn[item.Key] = item.Value;\n }\n return recordToReturn;\n}\n```"
}
] |
code_order-configuration_84f39604
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/utils/toFieldArrayFormat.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const toFieldArrayFormat = (\n dictionary: Record<string, string>\n): { Key: string; Value: string }[] => {\n const toReturn: { Key: string; Value: string }[] = [];\n for (let key of Object.keys(dictionary)) {\n toReturn.push({\n Key: key,\n Value: dictionary[key],\n })\n }\n return toReturn;\n};\n\n```"
}
] |
code_order-configuration_65c2aca1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/utils/vtexId.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nconst vtexIdAccount = (account: string) => `VtexIdclientAutCookie_${account}`;\nconst VTEX_ID = \"VtexIdclientAutCookie\";\n\nexport const vtexIdCookies = (ctx: Context) => {\n const {\n cookies,\n vtex: { account }\n } = ctx;\n const vtexIdAccountCookieValue = cookies.get(vtexIdAccount(account));\n const vtexIdValue = cookies.get(VTEX_ID);\n\n return {\n account: vtexIdAccountCookieValue\n ? `${vtexIdAccount(account)}=${vtexIdAccountCookieValue}`\n : null,\n id: vtexIdValue ? `${VTEX_ID}=${vtexIdValue}` : null\n };\n};\n\n```"
}
] |
code_order-configuration_92bc6e93
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/utils/getOrderFormIdFromCookie.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nconst CHECKOUT_COOKIE = \"checkout.vtex.com\";\n\nexport const getOrderFormIdFromCookie = (cookies: Context[\"cookies\"]) => {\n const cookie = cookies.get(CHECKOUT_COOKIE);\n return cookie && cookie.split(\"=\")[1];\n};\n\n```"
}
] |
code_order-configuration_e43228b2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/utils/index.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { AxiosError } from \"axios\";\nimport { AuthenticationError, ForbiddenError, UserInputError } from \"@vtex/api\";\n\nexport * from \"./getOrderFormIdFromCookie\";\n\nexport function statusToError(e: any) {\n if (!e.response) {\n throw e;\n }\n\n const { response } = e as AxiosError;\n const { status } = response!;\n\n if (status === 401) {\n throw new AuthenticationError(e);\n }\n if (status === 403) {\n throw new ForbiddenError(e);\n }\n if (status === 400) {\n throw new UserInputError(e);\n }\n\n throw e;\n}\n\n```"
}
] |
code_order-configuration_c3741445
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/repositories/Repository.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {DataEntity} from \"../resolvers/orderConfiguration/enums/DataEntity\";\nimport {MasterData} from \"@vtex/api\";\nimport {Schema} from \"../models/Schema\";\nimport {Schemas} from \"../resolvers/orderConfiguration/enums/Schemas\";\n\nexport class Repository<T> {\n\n public constructor(private readonly masterData: MasterData,\n private readonly dataEntity: DataEntity,\n private readonly schema: Schemas,\n private readonly shouldEnforceSchema: boolean) {\n }\n\n public async delete(id: string): Promise<void> {\n await this.masterData.deleteDocument({\n dataEntity: this.dataEntity,\n id,\n });\n }\n\n public async get(id: string): Promise<T> {\n const document = await this.masterData.getDocument({\n dataEntity: this.dataEntity,\n id,\n fields: [\"_all\"]\n });\n if (document === \"\") {\n return {} as T;\n }\n const conformingToSchemaDocument = await this.onlyInSchema(document as Record<string, string | number>);\n return {...conformingToSchemaDocument, id: (document as Record<string, string | number>).id} as unknown as T;\n }\n\n public async save(fields: Record<string, string | number>): Promise<string> {\n const fieldsInSchema = await this.onlyInSchema(fields);\n const documentResponse = await this.masterData.createDocument({\n dataEntity: this.dataEntity,\n schema: this.schema,\n fields: fieldsInSchema,\n });\n return documentResponse.DocumentId;\n }\n\n public async update(id: string, fields: Record<string, string | number>): Promise<void> {\n const fieldsInSchema = await this.onlyInSchema(fields);\n return await this.masterData.updatePartialDocument({\n dataEntity: this.dataEntity,\n id,\n fields: fieldsInSchema,\n schema: this.schema,\n });\n }\n\n public async find(fields: Record<string, string | number>,\n pagination: { page: number; pageSize: number} = { page: 1, pageSize: 20 }): Promise<T[]> {\n const whereClause = Repository.buildWhereClause(fields);\n const documents: Record<string, string | number>[] = await this.masterData.searchDocuments({\n dataEntity: this.dataEntity,\n schema: this.schema,\n fields: [\"_all\"],\n where: whereClause,\n pagination\n });\n if (documents.length === 0) {\n return [];\n }\n const conformingDocuments: T[] = [];\n for (let document of documents) {\n conformingDocuments.push({...await this.onlyInSchema(document), id: document.id } as unknown as T);\n }\n return conformingDocuments;\n }\n\n public async findOne(fields: Record<string, string | number>): Promise<T | null> {\n const documents = await this.find(fields);\n if (documents.length === 0) {\n return null;\n }\n return documents[0];\n }\n\n private async getSchema(): Promise<Schema> {\n return await this.masterData.getSchema({\n dataEntity: this.dataEntity,\n schema: this.schema,\n });\n }\n\n private async onlyInSchema(document: Record<string, string | number>): Promise<Record<string, string | number>> {\n if (!this.shouldEnforceSchema) {\n return document;\n }\n const schema = await this.getSchema();\n const conformingToSchema: Record<string, string | number> = {};\n for (let key of Object.keys(document)) {\n if (schema.properties[key]) {\n conformingToSchema[key] = document[key];\n }\n }\n return conformingToSchema;\n }\n\n private static buildWhereClause(fields: Record<string, string | number>): string {\n const separateClauses = []\n for(let field of Object.keys(fields)) {\n separateClauses.push(`${field}=${fields[field]}`)\n }\n return separateClauses.join(\" AND \");\n }\n}\n```"
}
] |
code_order-configuration_04740956
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/repositories/OrderConfigurationRepository.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {Repository} from \"./Repository\";\nimport {OrderConfig} from \"../models/OrderConfig\";\nimport {MasterData} from \"@vtex/api\";\nimport {Schemas} from \"../resolvers/orderConfiguration/enums/Schemas\";\nimport {DataEntity} from \"../resolvers/orderConfiguration/enums/DataEntity\";\n\nexport class OrderConfigurationRepository extends Repository<OrderConfig> {\n public constructor(masterData: MasterData) {\n super(masterData, DataEntity.ORDER_CONFIG, Schemas.ORDER_CONFIGURATION, true);\n }\n}\n```"
}
] |
code_order-configuration_1bc31dce
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/repositories/RepositoryFactory.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {Repository} from \"./Repository\";\nimport {MasterData} from \"@vtex/api\";\nimport {ClientRepository} from \"./ClientRepository\";\nimport {OrderConfig} from \"../models/OrderConfig\";\nimport {Client} from \"../models/Client\";\nimport {OrderConfigurationRepository} from \"./OrderConfigurationRepository\";\n\nexport class RepositoryFactory {\n public static getClientRepository(masterData: MasterData): Repository<Client> {\n return new ClientRepository(masterData);\n }\n\n public static getOrderConfigurationRepository(masterData: MasterData): Repository<OrderConfig> {\n return new OrderConfigurationRepository(masterData);\n }\n}\n\n```"
}
] |
code_order-configuration_ca759fce
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/repositories/ClientRepository.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {Repository} from \"./Repository\";\nimport {MasterData} from \"@vtex/api\";\nimport {DataEntity} from \"../resolvers/orderConfiguration/enums/DataEntity\";\nimport {Schemas} from \"../resolvers/orderConfiguration/enums/Schemas\";\nimport {Client} from \"../models/Client\";\n\nexport class ClientRepository extends Repository<Client> {\n public constructor(masterData: MasterData) {\n super(masterData, DataEntity.CLIENT, Schemas.CLIENT, false);\n }\n}\n```"
}
] |
code_order-configuration_3c31380a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/models/Schema.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport interface Schema {\n 'v-cache': boolean;\n properties: Record<string, { type: string}>;\n 'v-default-fields': string[];\n 'v-indexed': string[];\n}\n\n```"
}
] |
code_order-configuration_62468881
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/models/OrderConfig.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n\nexport interface OrderConfig {\n id: string;\n [key: string]: string;\n}\n\n```"
}
] |
code_order-configuration_d8f77802
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/resolvers/index.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { mutations as orderConfigurationMutations, queries as orderConfigurationQueries } from \"./orderConfiguration\";\n\nexport const resolvers = {\n Mutation: {\n ...orderConfigurationMutations\n },\n Query: {\n ...orderConfigurationQueries,\n }\n};\n\n```"
}
] |
code_order-configuration_79075696
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/test/utils/fromFieldArrayFormat.unit.test.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {fromFieldArrayFormat} from \"../../utils/fromFieldArrayFormat\";\nimport { expect } from \"chai\";\n\ndescribe(\"fromFieldArrayFormat\", () => {\n it('should convert from field array format correctly', () => {\n const fieldFormatArray = [\n {\n Key: \"a\",\n Value: \"123\",\n },\n {\n Key: \"b\",\n Value: \"asd\",\n }\n ];\n const converted = fromFieldArrayFormat(fieldFormatArray);\n expect(converted).to.be.deep.equal({\n a: \"123\",\n b: \"asd\"\n });\n });\n});\n```"
}
] |
code_order-configuration_a4c85495
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/test/utils/TokenUtils.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport axios from \"axios\";\n\nexport interface TokenResponse {\n authStatus: string;\n token: string;\n expires: number;\n}\n\nexport class TokenUtils {\n public static async getAuthToken(store: string, appKey: string, appToken: string): Promise<string> {\n const tokenUrl = `https://${store}.vtexcommercestable.com.br/api/vtexid/apptoken/login`;\n const data = {\n appkey: appKey,\n apptoken: appToken,\n };\n const response = await axios.post<TokenResponse>(tokenUrl, data);\n return response.data.token;\n }\n}\n\n```"
}
] |
code_order-configuration_1cc3b479
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/test/utils/toFieldArrayFormat.unit.test.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {expect} from \"chai\";\nimport {toFieldArrayFormat} from \"../../utils/toFieldArrayFormat\";\n\ndescribe(\"toFieldArrayFormat\", () => {\n it('should convert to field array format correctly', () => {\n const object = {\n a: \"123\",\n b: \"asd\"\n };\n const converted = toFieldArrayFormat(object);\n expect(converted).to.be.deep.equal([\n {\n Key: \"a\",\n Value: \"123\",\n },\n {\n Key: \"b\",\n Value: \"asd\",\n }\n ]);\n });\n});\n```"
}
] |
code_order-configuration_3d374fa0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/test/repositories/Repository.integration.test.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {Repository} from \"../../repositories/Repository\";\nimport {DataEntity} from \"../../resolvers/orderConfiguration/enums/DataEntity\";\nimport {Schemas} from \"../../resolvers/orderConfiguration/enums/Schemas\";\nimport {expect} from \"chai\";\nimport {MasterDataFactory} from \"../factories/MasterDataFactory\";\nimport {TokenUtils} from \"../utils/TokenUtils\";\n\ndescribe(\"Repository\", function () {\n let repository: Repository<any>;\n before( async () => {\n const store = process.env.STORE as string;\n const workspace = process.env.WORKSPACE as string;\n const appKey = process.env.APP_KEY as string;\n const appToken = process.env.APP_TOKEN as string;\n const authToken = await TokenUtils.getAuthToken(store, appKey, appToken);\n const masterData = MasterDataFactory.buildMockMasterData(store, authToken, workspace)\n repository = new Repository(masterData, \"integration_test\" as DataEntity, \"repository_test_schema\" as Schemas, true);\n });\n\n describe(\"get & save\", () => {\n it(\"should fetch a record properly\", async () => {\n const id = await repository.save({\n a: \"123\",\n b: \"asd\"\n });\n const document = await repository.get(id);\n expect(document).to.deep.equal({\n a: \"123\",\n b: \"asd\",\n id,\n });\n await repository.delete(id);\n });\n });\n\n describe(\"delete\", () => {\n it('should return an empty record after deletion', async () => {\n const id = await repository.save({\n a: \"123\",\n b: \"asd\"\n });\n await repository.delete(id);\n const document = await repository.get(id);\n expect(document).to.deep.equal({});\n });\n });\n\n describe(\"update\", () => {\n it('should update the record properly', async () => {\n const id = await repository.save({\n a: \"123\",\n b: \"asd\"\n });\n await repository.update(id, {\n a: \"456\"\n })\n const document = await repository.get(id);\n expect(document).to.deep.equal({\n a: \"456\",\n b: \"asd\",\n id,\n });\n await repository.delete(id);\n });\n });\n\n describe(\"find\", () => {\n it('should find the document properly', async () => {\n const document = await repository.find({\n a: \"iHopeThisStringIsNotCopied\",\n });\n expect(document).to.deep.equal([{\n a: \"iHopeThisStringIsNotCopied\",\n b: \"asd\",\n id: \"222db4a1-3a2d-11eb-82ac-0a58a8d158d9\",\n }]);\n });\n });\n\n describe(\"findOne\", () => {\n it('should find the document properly', async () => {\n const document = await repository.findOne({\n a: \"iHopeThisStringIsNotCopied\",\n });\n expect(document).to.deep.equal({\n a: \"iHopeThisStringIsNotCopied\",\n b: \"asd\",\n id: \"222db4a1-3a2d-11eb-82ac-0a58a8d158d9\",\n });\n });\n });\n});\n```"
}
] |
code_order-configuration_1217c805
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/test/factories/MasterDataFactory.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {anything, instance, mock, when} from \"ts-mockito\";\nimport {UserLandTracer} from \"@vtex/api/lib/tracing/UserLandTracer\";\nimport {IOContext, Logger, MasterData, Span} from \"@vtex/api\";\nimport {SpanContext} from \"opentracing\";\nimport {ParsedUrlQuery} from \"querystring\";\n\nexport class MasterDataFactory{\n public static buildMockMasterData(store: string, authToken: string, workspace: string): MasterData {\n const tracerMock = mock(UserLandTracer);\n const spanMock = mock(Span);\n when(spanMock.context()).thenReturn(instance(mock(SpanContext)));\n when(tracerMock.startSpan(anything(), anything())).thenReturn(instance(spanMock));\n when(tracerMock.startSpan(anything())).thenReturn(instance(spanMock));\n const masterData = new MasterData(new class implements IOContext {\n account = store;\n authToken = authToken;\n logger = null as unknown as Logger;\n operationId = \"\";\n platform = \"\";\n product = \"\";\n production = false;\n region = \"\";\n requestId = \"\";\n route = {\n id: \"\",\n params: {\n fakeString: \"bogus\",\n } as ParsedUrlQuery,\n type: \"private\",\n declarer: undefined,\n } as {\n declarer?: string;\n id: string;\n params: ParsedUrlQuery;\n type: 'public' | 'private' | 'event';\n };\n tracer = instance(tracerMock);\n userAgent = \"test\";\n workspace = workspace;\n } as unknown as IOContext);\n return masterData;\n }\n}\n```"
}
] |
code_order-configuration_860b3646
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/test/resolvers/orderConfiguration/orderConfiguration.unit.test.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {orderConfiguration} from \"../../../resolvers/orderConfiguration/orderConfiguration\";\nimport {MasterData, Session} from \"@vtex/api\";\nimport {anything, instance, mock, when} from \"ts-mockito\";\nimport * as Cookies from 'cookies';\nimport {expect} from \"chai\";\nimport {Clients} from \"../../../clients\";\nimport * as globals from \"../../../globals\";\n\ndescribe(\"orderConfiguration\", () => {\n let masterdata: MasterData;\n let session: Session;\n let cookies: Cookies;\n beforeEach( () => {\n masterdata = mock<MasterData>();\n session = mock<Session>();\n cookies = mock<Cookies>();\n })\n\n it('should return null when the user email is not present', async () => {\n when(session.getSession(anything(), anything())).thenResolve({\n sessionData: {},\n sessionToken: \"\"\n });\n const result = await orderConfiguration(null, null as unknown as void, {\n clients: { masterdata: instance(masterdata), session: instance(session), customPrice: null, checkout: null } as unknown as Clients,\n cookies: instance(cookies)\n } as globals.Context);\n expect(result).to.be.null;\n });\n\n it('should return null when no client was found', async () => {\n when(session.getSession(anything(), anything())).thenResolve({\n sessionData: {\n namespaces: {\n profile: {\n email: {\n value: \"fakeEmail\"\n }\n }\n }\n },\n sessionToken: \"\"\n });\n when(masterdata.searchDocuments(anything())).thenResolve([]);\n const result = await orderConfiguration(null, null as unknown as void, {\n clients: { masterdata: instance(masterdata), session: instance(session), customPrice: null, checkout: null } as unknown as Clients,\n cookies: instance(cookies)\n } as globals.Context);\n expect(result).to.be.null;\n });\n\n it('should return null when no order configuration was found', async () => {\n when(session.getSession(anything(), anything())).thenResolve({\n sessionData: {\n namespaces: {\n profile: {\n email: {\n value: \"fakeEmail\"\n }\n }\n }\n },\n sessionToken: \"\"\n });\n when(masterdata.searchDocuments(anything())).thenResolve([{\n a: \"asd\",\n b: \"123\"\n }]).thenResolve([]);\n const result = await orderConfiguration(null, null as unknown as void, {\n clients: { masterdata: instance(masterdata), session: instance(session), customPrice: null, checkout: null } as unknown as Clients,\n cookies: instance(cookies)\n } as globals.Context);\n expect(result).to.be.null;\n });\n\n it('should return the order configuration correctly', async () => {\n when(session.getSession(anything(), anything())).thenResolve({\n sessionData: {\n namespaces: {\n profile: {\n email: {\n value: \"fakeEmail\"\n }\n }\n }\n },\n sessionToken: \"\"\n });\n when(masterdata.getSchema(anything())).thenResolve({\n 'v-cache': false,\n properties: {\n order: {\n type: \"string\"\n },\n whatever: {\n type: \"string\"\n }\n },\n 'v-default-fields': [],\n 'v-indexed': []\n });\n when(masterdata.searchDocuments(anything())).thenResolve([{\n a: \"asd\",\n b: \"123\"\n }]).thenResolve([{\n order: \"123\",\n whatever: \"asd\",\n id: \"fakeId\"\n }]);\n const result = await orderConfiguration(null, null as unknown as void, {\n clients: { masterdata: instance(masterdata), session: instance(session), customPrice: null, checkout: null } as unknown as Clients,\n cookies: instance(cookies)\n } as globals.Context);\n expect(result).to.be.deep.equal({\n fields: [\n { Key: \"order\", Value: \"123\"},\n { Key: \"whatever\", Value: \"asd\"},\n { Key: \"id\", Value: \"fakeId\"}\n ]\n });\n });\n});\n\n```"
}
] |
code_order-configuration_243bbee8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/test/resolvers/orderConfiguration/saveOrderConfiguration.unit.test.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {MasterData, Session} from \"@vtex/api\";\nimport {anything, capture, instance, mock, verify, when} from \"ts-mockito\";\nimport * as Cookies from 'cookies';\nimport {expect} from \"chai\";\nimport {Clients} from \"../../../clients\";\nimport * as globals from \"../../../globals\";\nimport {saveOrderConfiguration} from \"../../../resolvers/orderConfiguration/saveOrderConfiguration\";\nimport {Checkout} from \"@vtex/clients\";\nimport {DataEntity} from \"../../../resolvers/orderConfiguration/enums/DataEntity\";\nimport {Schemas} from \"../../../resolvers/orderConfiguration/enums/Schemas\";\n\ndescribe(\"saveOrderConfiguration\", () => {\n let masterdata: MasterData;\n let session: Session;\n let cookies: Cookies;\n let checkout: Checkout;\n let orderConfig: { fields: { Key: string; Value: string; }[]};\n beforeEach( () => {\n masterdata = mock<MasterData>();\n session = mock<Session>();\n cookies = mock<Cookies>();\n checkout = mock<Checkout>();\n orderConfig = {\n fields: [\n { Key: \"a\", Value: \"asd\"},\n { Key: \"b\", Value: \"123\"}\n ]\n };\n })\n\n it('should return null when the user email is not present', async () => {\n when(session.getSession(anything(), anything())).thenResolve({\n sessionData: {},\n sessionToken: \"\"\n });\n const result = await saveOrderConfiguration(null, {\n orderConfig\n }, {\n clients: { masterdata: instance(masterdata), session: instance(session), customPrice: null, checkout } as unknown as Clients,\n cookies: instance(cookies),\n } as globals.Context);\n expect(result).to.be.false;\n });\n\n it('should return null when no client was found', async () => {\n when(session.getSession(anything(), anything())).thenResolve({\n sessionData: {\n namespaces: {\n profile: {\n email: {\n value: \"fakeEmail\"\n }\n }\n }\n },\n sessionToken: \"\"\n });\n when(masterdata.searchDocuments(anything())).thenResolve([]);\n const result = await saveOrderConfiguration(null, {\n orderConfig\n }, {\n clients: { masterdata: instance(masterdata), session: instance(session), customPrice: null, checkout } as unknown as Clients,\n cookies: instance(cookies)\n } as globals.Context);\n expect(result).to.be.false;\n });\n\n it('should save a new order configuration when no order configuration was found', async () => {\n when(session.getSession(anything(), anything())).thenResolve({\n sessionData: {\n namespaces: {\n profile: {\n email: {\n value: \"fakeEmail\"\n }\n }\n }\n },\n sessionToken: \"\"\n });\n when(masterdata.getSchema(anything())).thenResolve({\n 'v-cache': false,\n properties: {\n a: {\n type: \"string\"\n },\n b: {\n type: \"string\"\n }\n },\n 'v-default-fields': [],\n 'v-indexed': []\n });\n when(masterdata.searchDocuments(anything())).thenResolve([{\n id: \"fakeId\",\n }]).thenResolve([]);\n when(masterdata.createDocument(anything())).thenResolve({\n DocumentId: \"asdasd\",\n Id: \"asasdasd\",\n Href: \"as\"\n });\n const result = await saveOrderConfiguration(null, {\n orderConfig\n }, {\n clients: { masterdata: instance(masterdata), session: instance(session), customPrice: null, checkout } as unknown as Clients,\n cookies: instance(cookies)\n } as globals.Context);\n expect(result).to.be.true;\n verify(masterdata.createDocument(anything())).once();\n const [arg] = capture(masterdata.createDocument).last();\n expect(arg).to.be.deep.equal({\n dataEntity: DataEntity.ORDER_CONFIG,\n schema: Schemas.ORDER_CONFIGURATION,\n fields: { a: \"asd\", b: \"123\" },\n });\n });\n\n it('should return the order configuration correctly', async () => {\n when(session.getSession(anything(), anything())).thenResolve({\n sessionData: {\n namespaces: {\n profile: {\n email: {\n value: \"fakeEmail\"\n }\n }\n }\n },\n sessionToken: \"\"\n });\n when(masterdata.getSchema(anything())).thenResolve({\n 'v-cache': false,\n properties: {\n a: {\n type: \"string\"\n },\n b: {\n type: \"string\"\n }\n },\n 'v-default-fields': [],\n 'v-indexed': []\n });\n when(masterdata.searchDocuments(anything())).thenResolve([{\n id: \"fakeId\",\n }]).thenResolve([{\n a: \"uuu\",\n b: \"aaa\",\n id: \"fakeId\"\n }]);\n when(masterdata.createDocument(anything())).thenResolve({\n DocumentId: \"asdasd\",\n Id: \"asasdasd\",\n Href: \"as\"\n });\n const result = await saveOrderConfiguration(null, {\n orderConfig\n }, {\n clients: { masterdata: instance(masterdata), session: instance(session), customPrice: null, checkout } as unknown as Clients,\n cookies: instance(cookies)\n } as globals.Context);\n expect(result).to.be.true;\n verify(masterdata.updatePartialDocument(anything())).once();\n const [arg] = capture(masterdata.updatePartialDocument).last();\n expect(arg).to.be.deep.equal({\n dataEntity: DataEntity.ORDER_CONFIG,\n schema: Schemas.ORDER_CONFIGURATION,\n fields: { a: \"asd\", b: \"123\" },\n id: \"fakeId\"\n });\n });\n});\n\n```"
}
] |
code_order-configuration_760cd56a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/resolvers/orderConfiguration/orderConfiguration.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {toFieldArrayFormat} from \"../../utils/toFieldArrayFormat\";\nimport {RepositoryFactory} from \"../../repositories/RepositoryFactory\";\n\nexport const VTEX_SESSION = \"vtex_session\";\n\nexport const orderConfiguration = async (_: any, __: void, ctx: Context) => {\n const {\n clients: { masterdata, session },\n cookies\n } = ctx;\n\n const sessionCookie = cookies.get(VTEX_SESSION);\n const { sessionData } = await session.getSession(sessionCookie!, [\n \"profile.email\"\n ]);\n const clientRepository = RepositoryFactory.getClientRepository(masterdata);\n const orderConfigRepository = RepositoryFactory.getOrderConfigurationRepository(masterdata);\n\n const userEmail = sessionData.namespaces?.profile?.email?.value;\n\n if(!userEmail) {\n return null;\n }\n\n const client = await clientRepository.findOne({\n email: userEmail,\n });\n\n if(!client) {\n return null;\n }\n\n const clientId = client.id;\n\n const orderConfig = await orderConfigRepository.findOne({\n clientId,\n });\n\n if (!orderConfig) {\n return null;\n }\n\n return {\n fields: toFieldArrayFormat(orderConfig)\n };\n};\n\n```"
}
] |
code_order-configuration_e41983dc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/resolvers/orderConfiguration/saveOrderConfiguration.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {getOrderFormIdFromCookie} from \"../../utils\";\nimport {fromFieldArrayFormat} from \"../../utils/fromFieldArrayFormat\";\nimport {RepositoryFactory} from \"../../repositories/RepositoryFactory\";\n\ninterface Args {\n orderConfig: {\n fields: { Key: string; Value: string }[];\n };\n}\n\nconst CUSTOM_SESSION_KEY = \"customSessionKeys\";\nconst VTEX_SESSION = \"vtex_session\";\n\nexport const saveOrderConfiguration = async (\n _: any,\n { orderConfig }: Args,\n ctx: Context\n) => {\n const {\n clients: { masterdata, session, checkout },\n cookies\n } = ctx;\n\n const adaptedOrderConfig = fromFieldArrayFormat(orderConfig.fields);\n\n const sessionCookie = cookies.get(VTEX_SESSION);\n const { sessionData } = await session.getSession(sessionCookie!, [\n \"profile.email\"\n ]);\n const clientRepository = RepositoryFactory.getClientRepository(masterdata);\n const orderConfigRepository = RepositoryFactory.getOrderConfigurationRepository(masterdata);\n\n await session.updateSession(\n CUSTOM_SESSION_KEY,\n orderConfig,\n [],\n sessionCookie\n );\n\n await checkout.setSingleCustomData(getOrderFormIdFromCookie(cookies)!, {\n appId: \"orderConfig\",\n appFieldName: \"values\",\n value: JSON.stringify(adaptedOrderConfig)\n });\n\n const userEmail = sessionData.namespaces?.profile?.email?.value;\n\n if(!userEmail) {\n return false;\n }\n\n const client = await clientRepository.findOne({\n email: userEmail,\n });\n\n if(!client) {\n return false;\n }\n\n const orderConfigResult = await orderConfigRepository.findOne({\n clientId: client.id,\n });\n\n if (!orderConfigResult) {\n await orderConfigRepository.save({ clientId: client.id, ...adaptedOrderConfig});\n }\n else {\n await orderConfigRepository.update(orderConfigResult.id, { ...adaptedOrderConfig });\n }\n\n return true;\n};\n\n```"
}
] |
code_order-configuration_2a3e0a93
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/resolvers/orderConfiguration/index.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { saveOrderConfiguration } from \"./saveOrderConfiguration\";\nimport {orderConfiguration} from \"./orderConfiguration\";\n\nexport const mutations = {\n saveOrderConfiguration\n};\n\nexport const queries = {\n /**\n * Get user session custom keys\n * @return String\n */\n orderConfiguration\n};\n```"
}
] |
code_order-configuration_602bd4da
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/resolvers/orderConfiguration/enums/DataEntity.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport enum DataEntity {\n CLIENT = \"CL\",\n ORDER_CONFIG = \"order_configuration\",\n}\n```"
}
] |
code_order-configuration_42aeaa1e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/node/resolvers/orderConfiguration/enums/Schemas.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport enum Schemas {\n CLIENT = \"v1\",\n ORDER_CONFIGURATION = \"main\"\n}\n```"
}
] |
code_order-configuration_dd5a6228
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/mutations/saveOrderConfig.graphql from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation saveOrderConfig($orderConfig: OrderConfigInput!){\n saveOrderConfiguration(orderConfig: $orderConfig)\n}\n\n```"
}
] |
code_order-configuration_8d4a9fed
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/mutations/setOrderFormCustomData.graphql from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation setOrderFormCustomData ($appId: String, $field: String, $value: String) {\n setOrderFormCustomData(appId: $appId, field: $field, value: $value) {\n orderFormId\n customData {\n customApps {\n fields\n id\n major\n }\n }\n }\n}\n\n```"
}
] |
code_order-configuration_8c5954f4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/typings/storefront.d.ts from the order-configuration 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_order-configuration_2edb6335
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/typings/FormProps.d.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport type FormProps = {\n // schema: string\n}\n\nexport type CustomPriceSelectorProps = {\n formTitle: string\n formFields: FormField[]\n onSuccessfulSubmit: () => void\n children: any\n}\n\nexport type FormField =\n | InputField\n | SelectField\n | CheckboxField\n | RadioGroupField\n\nexport type InputField = {\n name: string\n type?: 'string' | 'number'\n fieldType?: 'text' | 'textarea' | 'select' | 'radio' | 'checkbox'\n label?: string\n defaultValue?: string\n required?: boolean\n format?: string\n showInTitle?: boolean\n}\n\nexport type SelectField = FormField & {\n options: {\n label: string\n value: string\n }[]\n}\n\nexport type RadioGroupField = SelectField\n\nexport type CheckboxField = RadioGroupField & {\n defaultValues?: string[]\n}\n\n```"
}
] |
code_order-configuration_54458bc2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/typings/vtex.render-runtime.d.ts from the order-configuration 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_order-configuration_95cf94ae
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/typings/vtex.native-types.d.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.native-types' {\n export const IOMessage\n}\n```"
}
] |
code_order-configuration_23784939
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/typings/global.d.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport interface ShowToastParams {\n message: string | JSX.Element\n duration: number\n}\n\nexport interface ToastRenderProps {\n showToast: (params: ShowToastParams) => void\n}\n\nexport type OrderConfiguration = Record<string, string | number>\n\n```"
}
] |
code_order-configuration_08ba7477
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/typings/css.d.ts from the order-configuration 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_order-configuration_6c533696
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/typings/graphql.d.ts from the order-configuration 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_order-configuration_f9a4a39b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-configuration/react/typings/InputProps.ts from the order-configuration VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { UISchemaType } from 'react-hook-form-jsonschema'\nimport { FormField } from './FormProps'\n\nexport interface BaseInputProps {\n pointer: string\n label?: string\n}\n\nexport interface FormFieldGroupProps extends Omit<BaseInputProps, 'label'> {\n uiSchema?: UISchemaType\n formFields: FormField[]\n defaultValues: Record<string, string | number>\n}\n\nexport enum InputTypes {\n input = 'input',\n hidden = 'hidden',\n password = 'password',\n}\n\nexport interface FormRawInputProps extends BaseInputProps {\n inputType?: InputTypes\n}\n\n```"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.