id
stringlengths
12
53
messages
listlengths
3
3
code_collections_51753b2e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/graphql/schema.graphql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype Query {\n collections(\n searchKey: String\n page: Int\n pageSize: Int\n ): CollectionsList\n\n collection(\n id: Int\n page: Int\n pageSize: Int\n ): Collection\n\n collectionContains(\n collectionId: Int\n skus: [SkuContainsInput]\n ): ContainsResult\n\n categoriesAutocomplete(\n name: String\n ): [Category]\n\n brandsAutocomplete(\n name: String\n ): [Brand]\n\n getBrands(\n ids: [Int]\n ): [Brand]\n\n getCategories(\n ids: [Int]\n ): [Category]\n\n getProductsBySku(\n ids: [Int]\n from: Int = 0\n to: Int = 9\n ): ProductResult\n\n getProducts(\n query: String = \"\",\n category: String = \"\",\n specificationFilters: [String],\n priceRange: String = \"\",\n collection: String = \"\",\n salesChannel: String = \"\",\n orderBy: String = \"OrderByPriceDESC\",\n from: Int = 0,\n to: Int = 9\n ): ProductResult\n}\n\ntype Mutation {\n createCollection(\n name: String\n searchable: Boolean\n highlight: Boolean\n dateFrom: String\n dateTo: String\n groups: [GroupInput]\n ) : Int\n\n updateGroup(\n collectionId: Int\n name: String\n type: String\n preSale: Boolean\n release: Boolean\n brands: [Int]\n categories: [Int]\n skus: [Int]\n ) : Boolean\n}\n\n```" } ]
code_collections_20a45aa9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/node/package.json from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.collections\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"dependencies\": {\n \"axios\": \"^0.17.1\",\n \"cookie\": \"^0.3.1\",\n \"debug\": \"^3.1.0\",\n \"follow-redirects\": \"^1.4.0\",\n \"is-buffer\": \"^1.1.6\",\n \"lodash\": \"^4.17.4\",\n \"ms\": \"^2.0.0\"\n },\n \"devDependencies\": {\n \"@types/koa\": \"^2.0.44\",\n \"@types/node\": \"^9.4.7\",\n \"tslint\": \"^5.9.1\",\n \"tslint-config-vtex\": \"^2.0.0\"\n },\n \"scripts\": {\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n },\n \"author\": \"\",\n \"license\": \"ISC\"\n}\n\n```" } ]
code_collections_7024ae58
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/pages/pages.json from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"pages\": {\n \"admin-collections\": {\n \"path\": \"/admin/collections\",\n \"auth\": true,\n \"theme\": \"theme\"\n },\n \"admin-collections-collection\": {\n \"path\": \"/admin/collections/new/\",\n \"auth\": true,\n \"theme\": \"theme\"\n },\n \"admin-collections-collection-edit\": {\n \"path\": \"/admin/collections/:id/\",\n \"auth\": true,\n \"theme\": \"theme\"\n }\n },\n \"extensions\": {\n \"admin-collections\": {\n \"component\": \"ListPage\"\n },\n \"admin-collections-collection\": {\n \"component\": \"Collection\"\n },\n \"admin-collections-collection-edit\": {\n \"component\": \"Collection\"\n }\n }\n}\n\n```" } ]
code_collections_22656fad
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/theme.css from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n@import \"./components/DatePicker/react-dates.css\";\n@import \"./components/DatePicker/custom.css\";\n@import \"./components/TimePicker/rc-time-picker.css\";\n@import \"./components/TimePicker/custom.css\";\n\nbody {\n background-color: #f7f9fa;\n height: 100%;\n}\n\n```" } ]
code_collections_22ec619b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/package.json from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.collections\",\n \"version\": \"0.0.0\",\n \"dependencies\": {\n \"@vtex/styleguide\": \"^2.0.0-rc.32\",\n \"debounce\": \"^1.1.0\",\n \"downshift\": \"^1.30.0\",\n \"lodash\": \"^4.17.5\",\n \"moment\": \"^2.21.0\",\n \"rc-time-picker\": \"^3.3.1\",\n \"react\": \"^16.2.0\",\n \"react-autocomplete-tags\": \"^1.0.13-alpha\",\n \"react-dates\": \"^16.3.6\",\n \"react-dom\": \"^16.2.0\"\n }\n}\n\n```" } ]
code_collections_f0cf7052
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/ListPage.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport { FormattedDate } from 'react-intl'\nimport { graphql, compose } from 'react-apollo'\nimport withNavigate from './components/withNavigate'\n\nimport SearchCollections from './graphql/SearchCollections.gql'\n\nimport Button from '@vtex/styleguide/lib/Button'\nimport Input from '@vtex/styleguide/lib/Input'\n\nimport Pagination from './components/Pagination/index'\nimport Badge from './components/Badge'\nimport Card from './components/Card'\nimport Status from './components/Status'\nimport Loading from './components/Loading'\nimport EmptyCollectionSearch\n from './components/EmptyStates/EmptyCollectionSearch'\n\nclass ListPage extends Component {\n handleChangePage = page => {\n this.props.navigate({\n to: '/admin/collections',\n query: `?q=${this.props.query.q || ''}&page=${page}`,\n })\n };\n\n handleChangeSearchKey = e => {\n const value = e.target.value\n this.props.navigate({\n to: '/admin/collections',\n query: `?q=${value}&page=1`,\n })\n };\n\n handleOpenCollection = id => {\n this.props.navigate({ to: `/admin/collections/${id}` })\n };\n\n handleClickNewCollection = () => {\n this.props.navigate({ to: '/admin/collections/new' })\n };\n\n render() {\n return (\n <div className=\"pv8 ph3 near-black bg-near-white w-100 h-100\">\n <div className=\"w-90 center\">\n <div\n className=\"flex justify-between items-center bb b--light-gray pb6\"\n >\n <div className=\"fw7 f2\">\n Collections\n </div>\n <div>\n <Button primary onClick={this.handleClickNewCollection}>\n New collection\n </Button>\n </div>\n </div>\n <div className=\"flex justify-between pt6 w-100 mb7 items-center\">\n <div className=\"w-80\">\n <Input\n type=\"search\"\n placeholder=\"Search by collection's name or ID…\"\n value={this.props.query.q}\n onChange={this.handleChangeSearchKey}\n />\n </div>\n <Pagination\n onChange={this.handleChangePage}\n currentPage={parseInt(this.props.query.page, 10) || 1}\n pages={\n this.props.data.collections &&\n this.props.data.collections.paging\n ? parseInt(this.props.data.collections.paging.pages, 10)\n : Infinity\n }\n />\n </div>\n {this.props.data.loading\n ? <Card>\n <div className=\"flex flex-column items-center pa10\">\n <Loading />\n </div>\n </Card>\n : this.props.data.collections &&\n this.props.data.collections.items.length === 0\n ? <Card><EmptyCollectionSearch /></Card>\n : <Card>\n <table className=\"tl pt4 w-90 center\" cellSpacing=\"0\">\n <thead className=\"\">\n <tr>\n <th\n className=\"fw3 gray pb4 ttu f7 w-40-l w-30-ns mt6 pl6\"\n >\n Name\n </th>\n <th className=\"fw3 gray pb4 ttu f7 w-20 mt6\">\n Start\n </th>\n <th className=\"fw3 gray pb4 ttu f7 w-20 mt6\">\n End\n </th>\n <th className=\"fw3 gray pb4 ttu f7 w-10 mt6\">\n Highlight\n </th>\n <th className=\"fw3 gray pb4 ttu f7 w-10 mt6\">\n Searchable\n </th>\n </tr>\n </thead>\n <tbody>\n {this.props.data.collections &&\n this.props.data.collections.items.length > 0 &&\n this.props.data.collections.items.map(collection => {\n return (\n <tr\n key={collection.id}\n className=\"pointer hover-bg-near-white\"\n onClick={() =>\n this.handleOpenCollection(collection.id)}\n >\n <td className=\"fw7 pv6 bt b--light-gray pl4\">\n <div className=\"flex items-center\">\n <div>\n <Status type=\"active\" />\n </div>\n <div className=\"pl3\">\n {collection.name}\n </div>\n </div>\n </td>\n <td className=\"fw4 pv6 bt b--light-gray\">\n <FormattedDate\n value={new Date(collection.dateFrom)}\n day=\"2-digit\"\n month=\"2-digit\"\n year=\"2-digit\"\n hour=\"2-digit\"\n minute=\"2-digit\"\n />\n </td>\n <td className=\"fw4 pv6 bt b--light-gray\">\n <FormattedDate\n value={new Date(collection.dateTo)}\n day=\"2-digit\"\n month=\"2-digit\"\n year=\"2-digit\"\n hour=\"2-digit\"\n minute=\"2-digit\"\n />\n </td>\n <td className=\"fw4 pv6 bt b--light-gray\">\n <Badge\n type={\n collection.highlight\n ? 'active'\n : 'inactive'\n }\n >\n {collection.highlight\n ? 'Active'\n : 'Inactive'}\n </Badge>\n </td>\n <td className=\"fw4 pv6 bt b--light-gray\">\n <Badge\n type={\n collection.searchable\n ? 'active'\n : 'inactive'\n }\n >\n {collection.searchable\n ? 'Active'\n : 'Inactive'}\n </Badge>\n </td>\n </tr>\n )\n })}\n </tbody>\n </table>\n </Card>}\n </div>\n </div>\n )\n }\n}\n\nListPage.propTypes = {\n query: PropTypes.object,\n data: PropTypes.object,\n navigate: PropTypes.func.isRequired,\n}\n\nconst options = {\n options: ({ query }) => ({\n variables: {\n searchKey: query.q,\n page: parseInt(query.page, 10),\n pageSize: 10,\n },\n }),\n}\n\nexport default compose(graphql(SearchCollections, options), withNavigate())(\n ListPage\n)\n\n```" } ]
code_collections_92608bb8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/Collection.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport { compose, graphql } from 'react-apollo'\n\nimport CreateCollection from './graphql/CreateCollection.gql'\nimport GetCollection from './graphql/GetCollection.gql'\nimport UpdateGroup from './graphql/UpdateGroup.gql'\n\nimport Button from '@vtex/styleguide/lib/Button'\nimport Config from './components/Config'\nimport withNavigate from './components/withNavigate'\nimport Alert from '@vtex/styleguide/lib/Alert'\nimport Loading from './components/Loading'\nimport Group from './components/Group'\nimport NewGroupButton from './components/NewGroupButton'\n\nclass Collection extends Component {\n constructor(props) {\n super(props)\n\n this.state = {\n currentPage: 1,\n searchQuery: props.searchQuery,\n selections: { product: {} },\n groups: this.getGroups(props),\n config: this.mapCollectionConfig(props),\n }\n }\n\n getGroups(props) {\n return !props.collectionData.loading && props.collectionData.collection && props.collectionData.collection.id\n ? props.collectionData.collection.groups\n : { items: [{\n name: '',\n type: 'I',\n preSale: false,\n release: false,\n brands: [],\n categories: [],\n skus: [],\n }] }\n }\n\n componentWillReceiveProps(nextProps) {\n this.setState({\n config: this.mapCollectionConfig(nextProps),\n groups: this.getGroups(nextProps),\n })\n }\n\n mapCollectionConfig(props) {\n const collection = props.collectionData && !props.collectionData.loading\n ? props.collectionData.collection || {}\n : {}\n\n return {\n name: collection.name || '',\n dateFrom: collection.dateFrom || new Date().toISOString(),\n dateTo: collection.dateTo || new Date().toISOString(),\n highlight: collection.highlight !== undefined && collection.highlight !== null\n ? collection.highlight\n : false,\n searchable: collection.searchable !== undefined && collection.searchable !== null\n ? collection.searchable\n : false,\n }\n }\n\n handleChangeConfig = ({ field, value }) => {\n this.setState(prevState => ({\n config: {\n ...prevState.config,\n [field]: value,\n },\n }))\n };\n\n handleCancel = () => {\n this.props.navigate({ to: '/admin/collections' })\n };\n\n handleSave = () => {\n if (!this.props.params.id) {\n this.props\n .createCollection({\n variables: {\n ...this.state.config,\n groups: this.state.groups.items,\n },\n })\n .then(() => {\n this.props.navigate({ to: '/admin/collections/' })\n })\n } else {\n // TODO update\n this.props.navigate({ to: '/admin/collections' })\n }\n };\n\n hasNoGroup = () => {\n return !(this.props.collectionData && this.props.collectionData.collection && this.props.collectionData.collection.groups && this.props.collectionData.collection.groups.items.length > 0)\n }\n\n handleChangeGroup = (groupIndex, data) => {\n this.setState(prevState => ({\n groups: {\n ...prevState.groups,\n items: prevState.groups.items.map((group, index) => {\n if (index === groupIndex) {\n return data\n }\n return group\n }),\n },\n }), () => {\n const group = this.state.groups.items.find((group, index) => {\n if (index === groupIndex) return group\n })\n\n if (!group || !this.props.params.id) {\n console.log('Opa')\n return\n }\n\n this.props\n .updateGroup({\n variables: {\n collectionId: this.props.params.id,\n ...group,\n },\n })\n .then(() => {\n this.props.navigate({ to: '/admin/collections' })\n })\n })\n }\n\n render() {\n return (\n <div className=\"pv8 ph3 near-black bg-near-white w-100 h-100\">\n <div className=\"w-90 center\">\n <div\n className=\"flex justify-between items-center bb b--light-gray pb6 mb6\"\n >\n <div className=\"fw7 f2\">\n Collections\n </div>\n <div>\n <div className=\"pr5 dib\">\n <Button onClick={this.handleCancel}>\n cancel\n </Button>\n </div>\n <Button primary onClick={this.handleSave}>\n save collection\n </Button>\n </div>\n </div>\n\n <div className=\"flex justify-between\">\n <div className=\"w-25\">\n {this.props.collectionData.loading\n ? null\n : <Config\n collection={this.state.config}\n onChange={this.handleChangeConfig}\n />}\n </div>\n <div className=\"w-75 ml5 mb5\">\n {this.props.collectionData.loading\n ? <div className=\"flex flex-column items-center pa10\">\n <Loading />\n </div>\n : <div>\n {this.hasNoGroup() && <div className=\"mb5 ba b--blue br2\">\n <Alert>\n Products are added to a collection by groups of conditions.\n </Alert>\n </div>}\n {this.state.groups.items.map(\n (group, index) => (\n <Group\n key={group.id || index}\n index={index}\n data={group}\n collectionId={\n this.props.collectionData.collection && this.props.collectionData.collection.id || null\n }\n onChange={this.handleChangeGroup}\n />\n )\n )}\n <NewGroupButton onClick={() => {}} />\n </div>}\n </div>\n </div>\n </div>\n </div>\n )\n }\n}\n\nCollection.propTypes = {\n searchQuery: PropTypes.string,\n collectionData: PropTypes.object,\n products: PropTypes.object,\n params: PropTypes.object.isRequired,\n navigate: PropTypes.func.isRequired,\n createCollection: PropTypes.func.isRequired,\n}\n\nconst CollectionContainer = compose(\n graphql(GetCollection, {\n name: 'collectionData',\n options({ params }) {\n return {\n errorPolicy: params.id ? 'all' : 'none',\n variables: {\n id: parseInt(params.id, 10),\n page: 1,\n pageSize: 10,\n },\n }\n },\n }),\n graphql(CreateCollection, { name: 'createCollection' }),\n graphql(UpdateGroup, { name: 'updateGroup' }),\n withNavigate()\n)(Collection)\n\nCollectionContainer.defaultProps = {\n collectionFrom: 0,\n collectionTo: 9,\n searchQuery: '',\n queryFrom: 0,\n queryTo: 9,\n}\n\nexport default CollectionContainer\n\n```" } ]
code_collections_98b3ff9d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/graphql/types/Groups.graphql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype GroupsList {\n paging: Paging!,\n items: [Group]!\n}\n\ntype Group {\n id: ID\n collectionId: Int\n name: String\n type: String\n preSale: Boolean\n release: Boolean\n brands: [Int]\n categories: [Int]\n skus: [Int]\n}\n\ninput GroupInput {\n collectionId: Int,\n name: String\n type: String\n preSale: Boolean\n release: Boolean\n brands: [Int]\n categories: [Int]\n skus: [Int]\n}\n\n```" } ]
code_collections_03103c76
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/graphql/types/Paging.graphql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype Paging {\n page: Int\n perPage: Int\n total: Int\n pages: Int\n _from: Int\n _to: Int\n}\n\n```" } ]
code_collections_e0083a01
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/graphql/types/ProductResult.graphql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype ProductResult {\n paging: Paging\n items: [Product]\n}\n\n```" } ]
code_collections_15530ed5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/graphql/types/Contains.graphql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype ContainsResult {\n skus: [SkuContains]\n}\n\ntype SkuContains {\n id: Int\n contains: Boolean\n}\n\ninput SkuContainsInput {\n id: String\n}\n\n```" } ]
code_collections_0109553a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/graphql/types/Product.graphql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype Product {\n brand: String\n categoryId: ID\n categories: [String]\n categoriesIds: [String]\n clusterHighlights: [ClusterHighlight]\n description: String\n items: [SKU]\n link: String\n linkText: String\n productId: ID\n productName: String\n properties: [Property]\n propertyGroups: [PropertyGroup]\n productReference: String\n recommendations: Recommendation\n}\n\ntype ClusterHighlight {\n id: ID\n name: String\n}\n\ntype Seller {\n sellerId: ID\n sellerName: String\n addToCartLink: String\n sellerDefault: Boolean\n commertialOffer: Offer\n}\n\ntype Recommendation {\n buy: [Product]\n view: [Product]\n}\n\ntype SKU {\n itemId: ID\n name: String\n nameComplete: String\n complementName: String\n ean: String\n referenceId: [Reference]\n measurementUnit: String\n unitMultiplier: Float\n images: [Image]\n sellers: [Seller]\n variations: [Property]\n attachments: [Attachment]\n}\n\ntype Attachment {\n id: ID\n name: String\n required: Boolean\n domainValues: [DomainValues]\n}\n\ntype DomainValues {\n FieldName: String\n MaxCaracters: String\n DomainValues: String\n}\n\ntype Offer {\n Installments: [Installment]\n Price: Float\n ListPrice: Float\n PriceWithoutDiscount: Float\n RewardValue: Float\n PriceValidUntil: String\n AvailableQuantity: Float\n Tax: Float\n CacheVersionUsedToCallCheckout: String\n DeliverySlaSamples: [DeliverySlaSamples]\n}\n\ntype DeliverySlaSamples {\n DeliverySlaPerTypes: [DeliverySlaPerTypes]\n Region: Region\n}\n\ntype DeliverySlaPerTypes {\n TypeName: String\n Price: Float\n EstimatedTimeSpanToDelivery: String\n}\n\ntype Region {\n IsPersisted: Boolean\n IsRemoved: Boolean\n Id: ID\n Name: String\n CountryCode: String\n ZipCode: String\n CultureInfoName: String\n}\n\ntype Image {\n imageId: ID\n imageLabel: String\n imageTag: String\n imageUrl: String\n imageText: String\n}\n\ntype Property {\n name: String\n values: [String]\n}\n\ntype PropertyGroup {\n name: String\n properties: [String]\n}\n\ntype Installment {\n Value: Float\n InterestRate: Float\n TotalValuePlusInterestRate: Float\n NumberOfInstallments: Int\n PaymentSystemName: String\n PaymentSystemGroupName: String\n Name: String\n}\n\ntype Reference {\n Key: String\n Value: String\n}\n\n```" } ]
code_collections_25ce01f0
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/graphql/types/Collection.graphql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype CollectionsList {\n paging: Paging!\n items: [Collection]!\n}\n\ntype Collection {\n id: ID\n name: String\n searchable: Boolean\n highlight: Boolean\n dateFrom: String\n dateTo: String\n groups: GroupsList\n}\n\n\n\n```" } ]
code_collections_b943fcfc
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/node/typings/colossus.d.ts from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'colossus' {\n import {Context as KoaContext} from 'koa'\n\n export interface IOContext {\n account: string\n workspace: string\n authToken: string\n params: {\n [param: string]: string\n }\n region: string\n route: string\n }\n\n export interface ColossusContext extends KoaContext {\n vtex: IOContext\n }\n}\n\n```" } ]
code_collections_74c35112
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/node/graphql/axios.ts from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport axios from 'axios'\n\nclass ResolverError extends Error {\n public statusCode: number\n\n constructor (message: string, statusCode: number = 500) {\n super(message)\n this.name = 'ResolverError'\n this.statusCode = statusCode\n }\n}\n\nconst instance = axios.create()\n\ninstance.interceptors.response.use(\n response => response,\n error => {\n if (!error.response) {\n throw error\n }\n\n const {config: { method, url }, status, data} = error.response\n const message = JSON.stringify({ method, status, url, data }, null, 2)\n throw new ResolverError(message, status)\n },\n)\n\nexport default instance\n\n```" } ]
code_collections_0a12573b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/node/graphql/package.json from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"axios\": \"^0.17.1\",\n \"lodash\": \"^4.17.4\"\n }\n}\n\n```" } ]
code_collections_e1ed1e43
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/node/graphql/index.ts from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {\n Query as CollectionsQuery,\n Mutation as CollectionsMutation,\n} from './collections';\nimport { Query as CatalogQuery } from './catalog';\n\nexport const resolvers = {\n Query: {\n ...CollectionsQuery,\n ...CatalogQuery,\n },\n Mutation: {\n ...CollectionsMutation,\n },\n};\n\n```" } ]
code_collections_9f4a0a67
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/node/graphql/catalog/index.ts from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ColossusContext } from 'colossus';\nimport {\n getCategoryByName,\n getBrandByName,\n getProducts,\n getProductsBySku,\n getBrand,\n getCategory,\n} from './api';\n\nexport const Query = {\n categoriesAutocomplete: async function(\n _,\n data,\n { vtex: ioContext }: ColossusContext\n ) {\n const categories = await getCategoryByName({\n ioContext,\n name: data.name || '',\n });\n\n return categories;\n },\n\n brandsAutocomplete: async function(\n _,\n data,\n { vtex: ioContext }: ColossusContext\n ) {\n const brands = await getBrandByName({\n ioContext,\n name: data.name || '',\n });\n\n return brands;\n },\n\n getCategories: async (_, data, { vtex: ioContext }: ColossusContext) => {\n const resolvedCategories = await Promise.all(\n data.ids.map(id => getCategory({\n ioContext,\n id,\n }))\n );\n\n return resolvedCategories;\n },\n\n getBrands: async (\n _,\n data,\n { vtex: ioContext, request: { headers: { cookie } } }: ColossusContext\n ) => {\n try {\n const resolvedBrands = await Promise.all(\n data.ids.map(id => getBrand({\n ioContext,\n cookie,\n id,\n }))\n );\n\n return resolvedBrands;\n } catch (e) {\n console.log(e);\n }\n },\n\n getProductsBySku: async (_, data, { vtex: ioContext }: ColossusContext) => {\n const response = await getProductsBySku({\n ioContext,\n ids: data.ids,\n from: data.from,\n to: data.to,\n });\n\n return response;\n },\n\n getProducts: async (_, data, { vtex: ioContext }: ColossusContext) => {\n const response = await getProducts({\n ioContext,\n query: data.query,\n category: data.category,\n specificationFilters: data.specificationFilters,\n priceRange: data.priceRange,\n collection: data.collection,\n salesChannel: data.salesChannel,\n orderBy: data.orderBy,\n from: data.from,\n to: data.to,\n });\n\n return response;\n },\n};\n\n```" } ]
code_collections_08612953
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/node/graphql/catalog/api.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport { parse as parseCookie } from 'cookie'\nimport axios from '../axios'\n\nexport function getCategoryByName({ ioContext, name }) {\n return axios({\n url: `http://${ioContext.account}.vtexcommercebeta.com.br/api/catalog_system/pub/category/list?filter=${encodeURIComponent(name)}&parent=`,\n method: 'get',\n headers: {\n Authorization: ioContext.authToken,\n },\n }).then(({ data }) => data)\n}\n\nexport function getCategory({ ioContext, id }) {\n return axios({\n url: `http://${ioContext.account}.vtexcommercestable.com.br/api/catalog_system/pub/category/${id}`,\n method: 'get',\n headers: {\n Authorization: ioContext.authToken,\n },\n }).then(({ data }) => data)\n}\n\nexport function getBrandByName({ ioContext, name }) {\n return axios({\n url: `http://${ioContext.account}.vtexcommercebeta.com.br/api/catalog_system/pvt/brand/list/${encodeURIComponent(name)}`,\n method: 'get',\n headers: {\n Authorization: ioContext.authToken,\n },\n }).then(({ data }) => data)\n}\n\nexport function getBrand({ ioContext, cookie, id }) {\n const parsedCookie = parseCookie(cookie)\n\n return axios({\n url: `http://${ioContext.account}.vtexcommercebeta.com.br/api/catalog_system/pvt/brand/${id}`,\n method: 'get',\n headers: {\n Authorization: ioContext.authToken,\n 'Proxy-Authorization': ioContext.authToken,\n VtexIdclientAutCookie: parsedCookie.VtexIdclientAutCookie,\n },\n }).then(({ data }) => data)\n}\n\nexport function getProductsBySku({ ioContext, ids, from, to }) {\n const idsQuery = ids\n ? ids.reduce((acc, id) => `${acc ? '&' : ''}fq=skuId:${id}`, '')\n : ''\n const fromQuery = from > -1 ? `&_from=${from}` : ''\n const toQuery = to > -1 ? `&_to=${to}` : ''\n\n return axios({\n url: `http://${ioContext.account}.vtexcommercestable.com.br/api/catalog_system/pub/products/search?${idsQuery}${fromQuery}${toQuery}`,\n method: 'get',\n headers: {\n Authorization: ioContext.authToken,\n },\n }).then(response => {\n return {\n items: response.data,\n paging: getPaging(from, to, response),\n }\n })\n}\n\nexport function getProducts(\n {\n ioContext,\n query = '',\n category = '',\n specificationFilters,\n priceRange = '',\n collection = '',\n salesChannel = '',\n orderBy = '',\n from = 0,\n to = 9,\n }\n) {\n const categoryQuery = category ? `&fq=C:/${category}/` : ''\n const specificationFiltersQuery = specificationFilters\n ? `&${specificationFilters}`\n : ''\n const priceRangeQuery = priceRange ? `&fq=P:[${priceRange}]` : ''\n const collectionQuery = collection\n ? `&fq=productClusterIds:${collection}`\n : ''\n const salesChannelQuery = salesChannel\n ? `&fq=isAvailablePerSalesChannel_${salesChannel}:1`\n : ''\n const orderByQuery = orderBy ? `&O=${orderBy}` : ''\n const fromQuery = from > -1 ? `&_from=${from}` : ''\n const toQuery = to > -1 ? `&_to=${to}` : ''\n\n return axios({\n url: `http://${ioContext.account}.vtexcommercestable.com.br/api/catalog_system/pub/products/search/${encodeURIComponent(query)}?${categoryQuery}${specificationFiltersQuery}${priceRangeQuery}${collectionQuery}${salesChannelQuery}${orderByQuery}${fromQuery}${toQuery}`,\n method: 'get',\n headers: {\n Authorization: ioContext.authToken,\n 'Proxy-Authorization': ioContext.authToken,\n },\n }).then(response => {\n return {\n items: response.data,\n paging: getPaging(from, to, response),\n }\n })\n}\n\nfunction getPaging(from, to, response) {\n const resources = response.headers.resources.split('/')\n const total = resources[1]\n const perPage = to - from + 1\n\n return {\n total,\n perPage,\n pages: Math.ceil(total / perPage),\n page: Math.ceil(from / perPage) + 1,\n _from: from,\n _to: to,\n }\n}\n\n```" } ]
code_collections_0001e8a5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/node/graphql/collections/index.ts from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ColossusContext } from 'colossus'\nimport {\n getCollection,\n getGroups,\n getCollections,\n collectionContains,\n createCollection,\n createGroup,\n updateGroup,\n} from './api'\n\nexport const Query = {\n collection: async function(_, data, { vtex: ioContext }: ColossusContext) {\n if (!data.id) return {}\n\n const collection = await getCollection({ ioContext, id: data.id })\n const groups = await getGroups({\n ioContext,\n collectionId: data.id,\n page: data.page,\n pageSize: data.pageSize,\n })\n\n return {\n ...collection,\n groups,\n }\n },\n\n collections: async function(\n _,\n info,\n { vtex: ioContext }: ColossusContext,\n query\n ) {\n let collections\n try {\n collections = await getCollections({\n ioContext,\n searchKey: query.variableValues.searchKey,\n page: query.variableValues.page,\n pageSize: query.variableValues.pageSize,\n })\n } catch (e) {\n console.log({\n statusText: e.response.statusText,\n headers: e.response.headers,\n request: {\n method: e.request.method,\n path: e.request.path,\n },\n })\n return e\n }\n\n return collections\n },\n\n collectionContains: async function(\n _,\n data,\n { vtex: ioContext }: ColossusContext\n ) {\n if (!data.collectionId) return {}\n\n const result = await collectionContains({\n ioContext,\n collectionId: data.collectionId,\n skus: data.skus,\n })\n\n return result\n },\n}\n\nexport const Mutation = {\n createCollection: async function(\n _,\n data,\n { vtex: ioContext }: ColossusContext\n ) {\n const collectionId = await createCollection({\n ioContext,\n name: data.name,\n searchable: data.searchable,\n highlight: data.searchable,\n dateFrom: data.dateFrom,\n dateTo: data.dateTo,\n })\n\n await Promise.all(\n data.groups.map(group => createGroup({\n ioContext,\n collectionId: collectionId,\n name: group.name,\n type: group.type,\n preSale: group.preSale,\n release: group.release,\n brands: group.brands,\n categories: group.categories,\n skus: group.skus,\n }))\n )\n\n return collectionId\n },\n\n updateGroup: async function(_, data, { vtex: ioContext }: ColossusContext) {\n const groupId = await updateGroup({\n ioContext,\n collectionId: data.collectionId,\n name: data.name,\n type: data.type,\n preSale: data.preSale,\n release: data.release,\n brands: data.brands,\n categories: data.categories,\n skus: data.skus,\n })\n\n return true\n },\n}\n\n```" } ]
code_collections_1ea546ff
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/node/graphql/collections/api.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport axios from '../axios'\n\nexport function getCollection({ ioContext, id }) {\n return axios({\n url: `http://${ioContext.account}.vtexcommercebeta.com.br/api/catalog_system/pvt/collection/${id}`,\n method: 'get',\n headers: {\n Authorization: `${ioContext.authToken}`,\n },\n }).then(({ data }) => data)\n}\n\nexport function getGroups({ ioContext, collectionId, page, pageSize }) {\n return axios({\n url: `http://${ioContext.account}.vtexcommercebeta.com.br/api/catalog_system/pvt/collection/${collectionId}/groups`,\n method: 'get',\n headers: {\n Authorization: `${ioContext.authToken}`,\n },\n params: {\n page: page == null ? 1 : page,\n pageSize: pageSize == null ? 20 : pageSize,\n },\n }).then(({ data }) => data)\n}\n\nexport function getCollections({ ioContext, searchKey = '', page, pageSize }) {\n return axios({\n url: `http://${ioContext.account}.vtexcommercebeta.com.br/api/catalog_system/pvt/collection/search/${searchKey}`,\n method: 'get',\n headers: {\n Authorization: ioContext.authToken,\n },\n params: {\n page: page == null ? 1 : page,\n pageSize: pageSize == null ? 20 : pageSize,\n },\n }).then(({ data }) => data)\n}\n\nexport function createCollection(\n { ioContext, name, searchable, highlight, dateFrom, dateTo }\n) {\n return axios({\n url: `http://${ioContext.account}.vtexcommercebeta.com.br/api/catalog_system/pvt/collection/`,\n method: 'post',\n headers: {\n Authorization: ioContext.authToken,\n },\n data: {\n name,\n searchable,\n highlight,\n dateFrom,\n dateTo,\n },\n }).then(({ data }) => data)\n}\n\nexport function createGroup(\n {\n ioContext,\n collectionId,\n name,\n type,\n preSale,\n release,\n brands,\n categories,\n skus,\n }\n) {\n return axios({\n url: `http://${ioContext.account}.vtexcommercebeta.com.br/api/catalog_system/pvt/collection/group`,\n method: 'post',\n headers: {\n Authorization: ioContext.authToken,\n },\n data: {\n collectionId,\n name,\n type,\n preSale,\n release,\n brands,\n categories,\n skus,\n },\n }).then(({ data }) => data)\n}\n\nexport function updateGroup(\n {\n ioContext,\n collectionId,\n name,\n type,\n preSale,\n release,\n brands,\n categories,\n skus,\n }\n) {\n return axios({\n url: `http://${ioContext.account}.vtexcommercebeta.com.br/api/catalog_system/pvt/collection/group`,\n method: 'put',\n headers: {\n Authorization: ioContext.authToken,\n },\n data: {\n collectionId,\n name,\n type,\n preSale,\n release,\n brands,\n categories,\n skus,\n },\n }).then(({ data }) => data)\n}\n\nexport function collectionContains({ ioContext, collectionId, skus }) {\n return axios({\n url: `http://${ioContext.account}.vtexcommercebeta.com.br/api/catalog_system/pvt/collection/${collectionId}/contains`,\n method: 'post',\n headers: {\n Authorization: ioContext.authToken,\n },\n data: {\n skus,\n },\n }).then(({ data }) => data)\n}\n\n```" } ]
code_collections_65c12e30
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/locales/es-AR.json from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"getting-started.greeting\": \"Bienvenido al Primero Tutorial del VTEX Render!\",\n \"getting-started.description\": \"Ese es un tutorial interactivo. La idea es descubrir las features del Render editando una app.\",\n \"getting-started.first-steps-header\": \"Primeros pasos\",\n \"getting-started.toolbelt\": \"Instale el toolbelt, nuestra herramienta de línea de comando para desarrollar la plataforma VTEX\",\n \"getting-started.workspace-creation\": \"Ahora vamos hacer login en su cuenta y crear un workspace, que es su personal area de trabajo.\",\n \"getting-started.workspace-description\": \"Un workspace sirve para que vos pueda hacer cambios aislado en su tienda. Nada que haga en un workspaces publicado hasta que promova su workspace. Mientra tanto, no se preocupe con eso.\",\n \"getting-started.clone\": \"Ahora, haga un clon del repositorio de esa app:\",\n \"getting-started.synchronize\": \"Por fin, para alterar una app y mirar sus cambios necesitamos sincronizar los archivos locales con la plataforma. Así, todos nuestras ediciones quedarán reflejadas en tiempo real.\",\n \"getting-started.watch\": \"Para hacer esto, instalamos el builder-hub e utilizamos el comando <i>link</i>\",\n \"getting-started.online\": \"Cool! Después de unos segundos, los archivos ya están sincronizados y puede hacer clic en la URL que aparece en su terminal para ver el su workspace en línea!\",\n \"getting-started.edit-file\": \"Ahora, abra su editor de texto preferido para editar el archivo {fileName}\",\n \"getting-started.change-css\": \"Busque el seguinte trecho de código y cambie la classe “dn” para “green”:\",\n \"getting-started.save\": \"Ahora grabe su archivo. Si todo estuviera correcto, el cambio se exhibirá acá abajo!\",\n \"getting-started.congrats\": \"Que bueno! Su primer modificación en una app!\",\n \"getting-started.mobile\": \"(Ei 📱! Es mejor acceder a este tutorial directo de su entorno de desarrollo, pero bienvenido. 😊)\"\n}\n\n```" } ]
code_collections_d6baa4ea
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/locales/pt-BR.json from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"getting-started.greeting\": \"Bem-vindo ao Primeiro Tutorial do VTEX Render!\",\n \"getting-started.description\": \"Esse é um tutorial interativo. A idéia é você descobrir as funcionalidades do Render editando uma app.\",\n \"getting-started.first-steps-header\": \"Primeiros passos\",\n \"getting-started.toolbelt\": \"Primeiro, instale o <strong>toolbelt</strong>, nossa ferramenta de linha de comando para desenvolver na plataforma VTEX:\",\n \"getting-started.workspace-creation\": \"Agora vamos fazer <i>login</i> na sua conta e criar um <strong>workspace</strong>, que é a sua área de trabalho pessoal.\",\n \"getting-started.workspace-description\": \"Um workspace serve para que você possa fazer mudanças isoladas na sua loja. Nada que você faz em um workspace é publicado até que você <strong>promova</strong> seu workspace. Por enquanto, não se preocupe com isso.\",\n \"getting-started.clone\": \"Agora, clone o repositório dessa app:\",\n \"getting-started.synchronize\": \"Finalmente, para podermos alterar uma app e ver suas mudanças precisamos sincronizar os arquivos locais com a plataforma. Assim, todas as nossas edições serão refletidas em tempo real!\",\n \"getting-started.watch\": \"Pra fazer isso, vamos instalar o builder-hub e usar o comando <i>link</i>\",\n \"getting-started.online\": \"Legal! Após alguns segundos, seus arquivos já estão sendo sincronizados e você pode clicar na URL que apareceu no seu terminal para ver o <i>seu workspace online!</i>\",\n \"getting-started.edit-file\": \"Agora, abra seu editor de texto preferido para editar o arquivo {fileName}.\",\n \"getting-started.change-css\": \"Procure o seguinte trecho de código e troque a classe 'dn' por 'green':\",\n \"getting-started.save\": \"Agora <strong>salve</strong> o arquivo. Se tudo der certo, a mudança vai aparecer aqui embaixo!\",\n \"getting-started.congrats\": \"Woohoo! Você fez sua primeira mudança numa app!\",\n \"getting-started.mobile\": \"(Ei 📱! É melhor acessar esse tutorial direto do seu ambiente de desenvolvimento, mas bem-vindo mesmo assim. 😊)\"\n}\n\n```" } ]
code_collections_9b7882e3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/locales/en-US.json from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"getting-started.greeting\": \"Bem-vindo ao Primeiro Tutorial do VTEX Render!\",\n \"getting-started.description\": \"Esse é um tutorial interativo. A idéia é você descobrir as funcionalidades do Render editando uma app.\",\n \"getting-started.first-steps-header\": \"Primeiros passos\",\n \"getting-started.toolbelt\": \"Primeiro, instale o <strong>toolbelt</strong>, nossa ferramenta de linha de comando para desenvolver na plataforma VTEX:\",\n \"getting-started.workspace-creation\": \"Agora vamos fazer <i>login</i> na sua conta e criar um <strong>workspace</strong>, que é a sua área de trabalho pessoal.\",\n \"getting-started.workspace-description\": \"Um workspace serve para que você possa fazer mudanças isoladas na sua loja. Nada que você faz em um workspace é publicado até que você <strong>promova</strong> seu workspace. Por enquanto, não se preocupe com isso.\",\n \"getting-started.clone\": \"Agora, clone o repositório dessa app:\",\n \"getting-started.synchronize\": \"Finalmente, para podermos alterar uma app e ver suas mudanças precisamos sincronizar os arquivos locais com a plataforma. Assim, todas as nossas edições serão refletidas em tempo real!\",\n \"getting-started.watch\": \"Pra fazer isso, vamos usar o comando <i>link</i>\",\n \"getting-started.online\": \"Legal! Após alguns segundos, seus arquivos já estão sendo sincronizados e você pode clicar na URL que apareceu no seu terminal para ver o <i>seu workspace online!</i>\",\n \"getting-started.edit-file\": \"Agora, abra seu editor de texto preferido para editar o arquivo {fileName}.\",\n \"getting-started.change-css\": \"Procure o seguinte trecho de código e troque a classe 'dn' por 'green':\",\n \"getting-started.save\": \"Agora <strong>salve</strong> o arquivo. Se tudo der certo, a mudança vai aparecer aqui embaixo!\",\n \"getting-started.congrats\": \"Woohoo! Você fez sua primeira mudança numa app!\",\n \"getting-started.mobile\": \"(Ei 📱! É melhor acessar esse tutorial direto do seu ambiente de desenvolvimento, mas bem-vindo mesmo assim. 😊)\"\n}\n\n```" } ]
code_collections_38d859de
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Badge.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nconst types = {\n active: 'bg-washed-blue blue',\n inactive: 'bg-near-white mid-gray',\n}\n\nclass Badge extends PureComponent {\n render() {\n return (\n <div className={`br-pill ${types[this.props.type]} f6 pv2 ph3 dib fw5`}>\n {this.props.children}\n </div>\n )\n }\n}\n\nBadge.propTypes = {\n type: 'active',\n}\n\nBadge.propTypes = {\n children: PropTypes.node.isRequired,\n type: PropTypes.oneOf(['active', 'inactive']),\n}\n\nexport default Badge\n\n```" } ]
code_collections_ceba070d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Config.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport 'react-dates/initialize'\nimport moment from 'moment'\n\nimport Toggle from './Toggle/index'\nimport DatePicker from './DatePicker/index'\nimport TimePicker from './TimePicker/index'\nimport Card from './Card'\n\nclass Config extends Component {\n handleChangeName = e => {\n this.props.onChange({ field: 'name', value: e.target.value })\n };\n\n handleChangeDateFrom = date => {\n const dateFrom = moment(new Date(date))\n const timeFrom = moment(new Date(this.props.collection.dateFrom))\n\n const newDate = dateFrom\n .hour(timeFrom.hour())\n .minute(timeFrom.minute())\n .toDate()\n .toISOString()\n\n this.props.onChange({ field: 'dateFrom', value: newDate })\n };\n\n handleChangeDateTo = date => {\n const dateTo = moment(new Date(date))\n const timeTo = moment(new Date(this.props.collection.dateTo))\n\n const newDate = dateTo\n .hour(timeTo.hour())\n .minute(timeTo.minute())\n .toDate()\n .toISOString()\n\n this.props.onChange({ field: 'dateTo', value: newDate })\n };\n\n handleChangeTimeFrom = time => {\n const dateFrom = moment(new Date(this.props.collection.dateFrom))\n const timeFrom = moment(new Date(time))\n\n const newDate = dateFrom\n .hour(timeFrom.hour())\n .minute(timeFrom.minute())\n .toDate()\n .toISOString()\n\n this.props.onChange({ field: 'dateFrom', value: newDate })\n };\n\n handleChangeTimeTo = time => {\n const dateTo = moment(new Date(this.props.collection.dateTo))\n const timeTo = moment(new Date(time))\n\n const newDate = dateTo\n .hour(timeTo.hour())\n .minute(timeTo.minute())\n .toDate()\n .toISOString()\n\n this.props.onChange({ field: 'dateTo', value: newDate })\n };\n\n handleChangeActive = () => {\n this.props.onChange({\n field: 'active',\n value: !this.props.collection.active,\n })\n };\n\n handleChangeHighlight = () => {\n this.props.onChange({\n field: 'highlight',\n value: !this.props.collection.highlight,\n })\n };\n\n handleChangeSearchable = () => {\n this.props.onChange({\n field: 'searchable',\n value: !this.props.collection.searchable,\n })\n };\n\n render() {\n const collection = this.props.collection || {}\n\n return (\n <Card>\n <div className=\"center\">\n <div className=\"mb6\">\n <div>\n <input\n className=\"w-auto bn f3 fw7 near-black\"\n type=\"text\"\n placeholder=\"Name your collection\"\n defaultValue={collection.name}\n style={{ width: '10em' }}\n onChange={this.handleChangeName}\n />\n </div>\n </div>\n <div>\n <div>\n <span className=\"f6 fw7 near-black\">Start</span>\n <div className=\"pt2 pb3\">\n <DatePicker\n value={collection.dateFrom}\n onChange={this.handleChangeDateFrom}\n />\n <TimePicker\n value={collection.dateFrom}\n onChange={this.handleChangeTimeFrom}\n />\n </div>\n <div>\n <span className=\"f6 fw7 near-black pr5 \">End</span>\n <div className=\"pt2\">\n <DatePicker\n value={collection.dateTo}\n onChange={this.handleChangeDateTo}\n />\n <TimePicker\n value={collection.dateTo}\n onChange={this.handleChangeTimeTo}\n />\n </div>\n </div>\n </div>\n <div className=\"flex pt6 pb4\">\n <Toggle\n secondary\n id=\"active-toggle\"\n onClick={this.handleChangeActive}\n checked={collection.active}\n />\n <span className=\"pl3 f6\">Active</span>\n </div>\n <div className=\"flex dib pb4\">\n <Toggle\n secondary\n id=\"hightlight-toggle\"\n onClick={this.handleChangeHighlight}\n checked={collection.highlight}\n />\n <span className=\"pl3 f6 pr6\">Highlight</span>\n </div>\n <div className=\"flex dib\">\n <Toggle\n secondary\n id=\"searchable-toggle\"\n onClick={this.handleChangeSearchable}\n checked={collection.searchable}\n />\n <span className=\"pl3 f6\">Searchable</span>\n </div>\n </div>\n </div>\n </Card>\n )\n }\n}\n\nConfig.propTypes = {\n collection: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n}\n\nexport default Config\n\n```" } ]
code_collections_4cbf1d34
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/BaseGroup.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport Card from './Card'\nimport Button from '@vtex/styleguide/lib/Button'\n\nclass BaseGroup extends Component {\n render() {\n return (\n <Card>\n <div className=\"w-100 center\">\n <div>\n <div className=\"f3 fw7 w-50\">\n <input\n className=\"w-auto bn f3 fw7 near-black\"\n type=\"text\"\n placeholder=\"Name this group\"\n value={this.props.name}\n style={{ width: '10em' }}\n onChange={this.props.onChangeName}\n />\n </div>\n </div>\n {this.props.children}\n <div className=\"pt6 nl5\">\n <div>\n <Button onClick={this.props.onSave}>Save group</Button>\n <Button onClick={this.props.onCancel}>Cancel</Button>\n </div>\n </div>\n </div>\n </Card>\n )\n }\n}\n\nBaseGroup.propTypes = {\n name: PropTypes.string,\n children: PropTypes.node.isRequired,\n onChangeName: PropTypes.func.isRequired,\n onSave: PropTypes.func.isRequired,\n onCancel: PropTypes.func.isRequired,\n}\n\nexport default BaseGroup\n\n```" } ]
code_collections_878ce635
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Status.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nconst types = {\n active: 'bg-green',\n inactive: 'bg-silver',\n error: 'bg-red',\n}\n\nclass Status extends PureComponent {\n render() {\n return <div className={`${types[this.props.type]} dib pa2 br-100`} />\n }\n}\n\nStatus.defaultProps = {\n type: 'active',\n}\n\nStatus.propTypes = {\n type: PropTypes.oneOf(['active', 'inactive', 'error']),\n}\n\nexport default Status\n\n```" } ]
code_collections_876216d8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Card.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nclass Card extends PureComponent {\n render() {\n return (\n <div\n className=\"w-100 bg-white pa6 br2\"\n style={{ boxShadow: '0 3px 9px 0 rgba(61, 62, 64, 0.2)' }}\n >\n {this.props.children}\n </div>\n )\n }\n}\n\nCard.propTypes = {\n children: PropTypes.node.isRequired,\n}\n\nexport default Card\n\n```" } ]
code_collections_53698145
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/withNavigate.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\n\nexport default function withNavigate() {\n return WrappedComponent => {\n class WithNavigateWrapper extends Component {\n render() {\n return (\n <WrappedComponent {...this.props} navigate={this.context.navigate} />\n )\n }\n }\n\n WithNavigateWrapper.contextTypes = {\n navigate: PropTypes.func,\n }\n\n return WithNavigateWrapper\n }\n}\n\n```" } ]
code_collections_d54b28e6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/graphql/CreateCollection.gql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation CreateCollection(\n $name: String\n $searchable: Boolean\n $highlight: Boolean\n $dateFrom: String\n $dateTo: String\n $groups: [GroupInput]\n) {\n createCollection(\n name: $name\n searchable: $searchable\n highlight: $highlight\n dateFrom: $dateFrom\n dateTo: $dateTo\n groups: $groups\n )\n}\n\n```" } ]
code_collections_bb7bd025
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/graphql/UpdateGroup.gql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation UpdateGroup(\n $collectionId: Int\n $name: String\n $type: String\n $preSale: Boolean\n $release: Boolean\n $brands: [Int]\n $categories: [Int]\n $skus: [Int]\n) {\n updateGroup(\n collectionId: $collectionId\n name: $name\n type: $type\n preSale: $preSale\n release: $release\n brands: $brands\n categories: $categories\n skus: $skus\n )\n}\n\n```" } ]
code_collections_79e01a41
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/graphql/GetCollection.gql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery Collection(\n $id: Int,\n $page: Int,\n $pageSize: Int,\n) {\n collection(\n id: $id,\n page: $page,\n pageSize: $pageSize,\n ) {\n id\n name\n searchable\n highlight\n dateFrom\n dateTo\n groups {\n paging {\n page\n perPage\n total\n pages\n }\n items {\n id\n name\n type\n preSale\n release\n brands\n categories\n skus\n }\n }\n }\n}\n\n```" } ]
code_collections_d5a462ea
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/graphql/SearchCollections.gql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery Collections(\n $searchKey: String\n $page: Int\n $pageSize: Int\n) {\n collections(\n searchKey: $searchKey\n page: $page\n pageSize: $pageSize\n ) {\n paging {\n page\n perPage\n total\n pages\n }\n items {\n id,\n name,\n searchable,\n highlight,\n dateFrom,\n dateTo,\n }\n }\n}\n\n```" } ]
code_collections_34c7b015
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Pagination/IconArrowLeft.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport config from 'vtex-tachyons/config.json'\n\nclass IconArrowLeft extends Component {\n render() {\n return (\n <svg\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n x=\"0px\"\n y=\"0px\"\n viewBox=\"0 0 16 16\"\n xmlSpace=\"preserve\"\n width=\"16\"\n height=\"16\"\n >\n <g className=\"nc-icon-wrapper\" fill=\"#368df7\">\n <polygon\n fill={this.props.fill}\n points=\"10,13.4 4.6,8 10,2.6 11.4,4 7.4,8 11.4,12 \"\n />\n </g>\n </svg>\n )\n }\n}\n\nIconArrowLeft.defaultProps = {\n fill: config.colors.blue,\n}\n\nIconArrowLeft.propTypes = {\n fill: PropTypes.string,\n}\n\nexport default IconArrowLeft\n\n```" } ]
code_collections_f9d2bee6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Pagination/IconArrowRight.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport config from 'vtex-tachyons/config.json'\n\nclass IconArrowLeft extends Component {\n render() {\n return (\n <svg\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n x=\"0px\"\n y=\"0px\"\n viewBox=\"0 0 16 16\"\n xmlSpace=\"preserve\"\n width=\"16\"\n height=\"16\"\n >\n <g className=\"nc-icon-wrapper\" fill={this.props.fill}>\n <polygon\n fill={this.props.fill}\n points=\"6,13.4 4.6,12 8.6,8 4.6,4 6,2.6 11.4,8 \"\n />\n </g>\n </svg>\n )\n }\n}\n\nIconArrowLeft.defaultProps = {\n fill: config.colors.blue,\n}\n\nIconArrowLeft.propTypes = {\n fill: PropTypes.string,\n}\n\nexport default IconArrowLeft\n\n```" } ]
code_collections_baf05b88
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Pagination/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\nimport IconArrowLeft from './IconArrowLeft'\nimport IconArrowRight from './IconArrowRight'\nimport config from 'vtex-tachyons/config.json'\n\nclass Pagination extends PureComponent {\n constructor(props) {\n super(props)\n\n this.state = {\n currentPage: props.currentPage,\n error: props.pages < props.currentPage || props.currentPage < 1,\n }\n }\n\n componentWillReceiveProps(nextProps) {\n this.setState({\n currentPage: nextProps.currentPage,\n error: nextProps.pages < nextProps.currentPage ||\n nextProps.currentPage < 1,\n })\n }\n\n handlePreviousPage = () => {\n const newValue = this.props.currentPage - 1\n this.props.onChange.apply(this, this.getNewState(newValue))\n this.setState({ currentPage: newValue })\n };\n\n handleNextPage = () => {\n const newValue = this.props.currentPage + 1\n this.props.onChange.apply(this, this.getNewState(newValue))\n this.setState({ currentPage: newValue })\n };\n\n getNewState = newCurrentPage => {\n if (this.props.from !== null && this.props.to !== null) {\n const pageSize = this.props.to - this.props.from + 1\n const from = (newCurrentPage - 1) * pageSize\n const to = from + pageSize - 1\n return [newCurrentPage, from, to]\n }\n return [newCurrentPage]\n };\n\n handleInputChange = e => {\n const value = e.target.value.replace(/[^0-9]/gi, '')\n\n this.setState({\n currentPage: value,\n error: this.props.pages < value || value < 1,\n })\n };\n\n handleBlur = () => {\n this.setState({ currentPage: this.props.currentPage, error: false })\n };\n\n handleKeyDown = ({ key }) => {\n if (key === 'Enter' && !this.state.error) {\n this.props.onChange.apply(this, this.getNewState(this.state.currentPage))\n }\n };\n\n render() {\n const { currentPage, pages } = this.props\n const previousDisabled = parseInt(currentPage, 10) === 1\n const nextDisabled = parseInt(pages, 10) === parseInt(currentPage, 10)\n\n return (\n <div className=\"flex\">\n <div className=\"flex bt bl bb b--light-gray bw1 br2 br--left\">\n <button\n onClick={this.handlePreviousPage}\n disabled={previousDisabled}\n className={\n `bn f6 pv4 ph4 flex items-center ${previousDisabled ? '' : 'pointer hover-bg-washed-blue'}`\n }\n >\n <IconArrowLeft\n fill={previousDisabled ? config.colors.silver : undefined}\n />\n </button>\n </div>\n <div className=\"dib\">\n <input\n className={\n `ba ${this.state.error ? 'b--washed-red' : 'b--light-gray'} f6 pa4 bw1 dib w2 tc`\n }\n value={this.state.currentPage}\n onBlur={this.handleBlur}\n onKeyDown={this.handleKeyDown}\n onChange={this.handleInputChange}\n />\n </div>\n <div className=\"flex bt br bb b--light-gray bw1 br2 br--right\">\n <button\n onClick={this.handleNextPage}\n disabled={nextDisabled}\n className={\n `bn f6 pv4 ph4 flex items-center ${nextDisabled ? '' : 'pointer hover-bg-washed-blue'}`\n }\n >\n <IconArrowRight\n fill={nextDisabled ? config.colors.silver : undefined}\n />\n </button>\n </div>\n </div>\n )\n }\n}\n\nPagination.defaultProps = {\n currentPage: 1,\n pages: Infinity,\n}\n\nPagination.propTypes = {\n from: PropTypes.number,\n to: PropTypes.number,\n currentPage: PropTypes.number.isRequired,\n pages: PropTypes.number.isRequired,\n onChange: PropTypes.func.isRequired,\n}\n\nexport default Pagination\n\n```" } ]
code_collections_1744235f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/TimePicker/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport RcTimePicker from 'rc-time-picker'\nimport moment from 'moment'\n\nclass TimePicker extends Component {\n constructor(props) {\n super(props)\n\n this.state = {\n focused: false,\n value: props.value\n ? moment(moment.utc(props.value).local().format())\n : moment(),\n }\n }\n\n componentWillReceiveProps(nextProps) {\n this.setState({\n value: nextProps.value\n ? moment(moment.utc(nextProps.value).local().format())\n : moment(),\n })\n }\n\n handleChange = date => {\n this.props.onChange(date.toISOString())\n };\n\n render() {\n return (\n <RcTimePicker\n showSecond={false}\n minuteStep={10}\n value={this.state.value}\n onChange={this.handleChange}\n />\n )\n }\n}\n\nTimePicker.propTypes = {\n value: PropTypes.string,\n onChange: PropTypes.func.isRequired,\n}\n\nexport default TimePicker\n\n```" } ]
code_collections_3f501b4d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/TimePicker/custom.css from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.rc-time-picker input[type=text] {\n padding: 8px;\n font-size: 14px;\n top: 2px;\n height: 38px;\n border: 2px solid #e3e4e6;\n letter-spacing: -0.4px;\n}\n\n.rc-time-picker .rc-time-picker-panel-inner {\n width: 10em;\n display: inline-block;\n top: 55px;\n position: relative;\n outline: none;\n list-style: none;\n font-size: 12px;\n text-align: left;\n background-color: #fff;\n border-radius: 4px;\n background-clip: padding-box;\n border: 1px solid #e3e4e6;\n line-height: 1.5;\n box-shadow: none;\n}\n\n.rc-time-picker-input {\n width: 5em;\n text-align: center;\n}\n\n.rc-time-picker .rc-time-picker-panel-input-wrap {\n box-sizing: border-box;\n position: relative;\n padding: 8px;\n border-bottom: 1px solid #e3e4e6;\n}\n\n```" } ]
code_collections_a3534b1e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/TimePicker/rc-time-picker.css from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.rc-time-picker {\n display: inline-block;\n box-sizing: border-box;\n}\n.rc-time-picker * {\n box-sizing: border-box;\n}\n.rc-time-picker-input {\n width: 100%;\n position: relative;\n display: inline-block;\n padding: 4px 7px;\n height: 28px;\n cursor: text;\n font-size: 12px;\n line-height: 1.5;\n color: #666;\n background-color: #fff;\n background-image: none;\n border: 1px solid #d9d9d9;\n border-radius: 4px;\n transition: border 0.2s cubic-bezier(0.645, 0.045, 0.355, 1), background 0.2s cubic-bezier(0.645, 0.045, 0.355, 1), box-shadow 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);\n}\n.rc-time-picker-input[disabled] {\n color: #ccc;\n background: #f7f7f7;\n cursor: not-allowed;\n}\n.rc-time-picker-panel {\n z-index: 1070;\n width: 170px;\n position: absolute;\n box-sizing: border-box;\n}\n.rc-time-picker-panel * {\n box-sizing: border-box;\n}\n.rc-time-picker-panel-inner {\n display: inline-block;\n position: relative;\n outline: none;\n list-style: none;\n font-size: 12px;\n text-align: left;\n background-color: #fff;\n border-radius: 4px;\n box-shadow: 0 1px 5px #ccc;\n background-clip: padding-box;\n border: 1px solid #ccc;\n line-height: 1.5;\n}\n.rc-time-picker-panel-narrow {\n max-width: 113px;\n}\n.rc-time-picker-panel-input {\n margin: 0;\n padding: 0;\n width: 100%;\n cursor: auto;\n line-height: 1.5;\n outline: 0;\n border: 1px solid transparent;\n}\n.rc-time-picker-panel-input-wrap {\n box-sizing: border-box;\n position: relative;\n padding: 6px;\n border-bottom: 1px solid #e9e9e9;\n}\n.rc-time-picker-panel-input-invalid {\n border-color: red;\n}\n.rc-time-picker-panel-clear-btn {\n position: absolute;\n right: 6px;\n cursor: pointer;\n overflow: hidden;\n width: 20px;\n height: 20px;\n text-align: center;\n line-height: 20px;\n top: 6px;\n margin: 0;\n}\n.rc-time-picker-panel-clear-btn:after {\n content: \"x\";\n font-size: 12px;\n color: #aaa;\n display: inline-block;\n line-height: 1;\n width: 20px;\n transition: color 0.3s ease;\n}\n.rc-time-picker-panel-clear-btn:hover:after {\n color: #666;\n}\n.rc-time-picker-panel-select {\n float: left;\n font-size: 12px;\n border: 1px solid #e9e9e9;\n border-width: 0 1px;\n margin-left: -1px;\n box-sizing: border-box;\n width: 56px;\n max-height: 144px;\n overflow-y: auto;\n position: relative;\n}\n.rc-time-picker-panel-select-active {\n overflow-y: auto;\n}\n.rc-time-picker-panel-select:first-child {\n border-left: 0;\n margin-left: 0;\n}\n.rc-time-picker-panel-select:last-child {\n border-right: 0;\n}\n.rc-time-picker-panel-select ul {\n list-style: none;\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n width: 100%;\n}\n.rc-time-picker-panel-select li {\n list-style: none;\n box-sizing: content-box;\n margin: 0;\n padding: 0 0 0 16px;\n width: 100%;\n height: 24px;\n line-height: 24px;\n text-align: left;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n.rc-time-picker-panel-select li:hover {\n background: #edfaff;\n}\nli.rc-time-picker-panel-select-option-selected {\n background: #f7f7f7;\n font-weight: bold;\n}\nli.rc-time-picker-panel-select-option-disabled {\n color: #ccc;\n}\nli.rc-time-picker-panel-select-option-disabled:hover {\n background: transparent;\n cursor: not-allowed;\n}\n\n```" } ]
code_collections_7b221988
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Loading/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport config from 'vtex-tachyons/config.json'\nimport style from './style.css'\n\nclass Loading extends Component {\n render() {\n return (\n <svg\n className={style.spinner}\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n x=\"0px\"\n y=\"0px\"\n viewBox=\"0 0 64 64\"\n xmlSpace=\"preserve\"\n width={this.props.width}\n height={this.props.height}\n >\n <g fill={this.props.fill}>\n <g transform=\"rotate(43.102857129914426 32 32)\">\n <path\n className={style.path}\n opacity=\"0.4\"\n fill={this.props.fill}\n d=\"M32,64C14.35498,64,0,49.64453,0,32C0,14.35498,14.35498,0,32,0s32,14.35498,32,32 C64,49.64453,49.64502,64,32,64z M32,6C17.66357,6,6,17.66357,6,32c0,14.33691,11.66357,26,26,26s26-11.66309,26-26 C58,17.66357,46.33643,6,32,6z\"\n />\n <path\n className={style.path}\n data-color=\"color-2\"\n fill={this.props.fill}\n d=\"M64,32h-6C58,17.66357,46.33643,6,32,6V0C49.64502,0,64,14.35498,64,32z\"\n />\n </g>\n </g>\n </svg>\n )\n }\n}\n\nLoading.defaultProps = {\n fill: config.colors.blue,\n width: 64,\n height: 64,\n}\n\nLoading.propTypes = {\n fill: PropTypes.string.isRequired,\n width: PropTypes.number.isRequired,\n height: PropTypes.number.isRequired,\n}\n\nexport default Loading\n\n```" } ]
code_collections_3530d7eb
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Loading/style.css from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.spinner {\n animation: rotator 1.4s linear infinite;\n}\n\n@keyframes rotator {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(270deg);\n }\n}\n\n.path {\n stroke-dasharray: 187;\n stroke-dashoffset: 0;\n transform-origin: center;\n animation: dash 1.4s ease-in-out infinite;\n}\n\n@keyframes dash {\n 0% {\n stroke-dashoffset: 187;\n }\n 50% {\n stroke-dashoffset: 47.75;\n transform: rotate(135deg);\n }\n 100% {\n stroke-dashoffset: 187;\n transform: rotate(450deg);\n }\n}\n\n```" } ]
code_collections_c70fdac4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Autocomplete/Badge.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\nimport Deny from '@vtex/styleguide/lib/icon/Deny'\nimport config from 'vtex-tachyons/config.json'\n\nclass Badge extends PureComponent {\n constructor(props) {\n super(props)\n this.state = { hover: false }\n }\n\n handleMouseEnter = () => this.setState({ hover: true });\n handleMouseLeave = () => this.setState({ hover: false });\n\n render() {\n return (\n <span\n className=\"dib bg-washed-blue blue br-pill pv3 ph4 hover-bg-light-silver pointer\"\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n onClick={this.props.onClick}\n >\n {this.props.children}\n {' '}\n <span className=\"pt2\">\n <Deny\n color={this.state.hover ? config.colors.red : config.colors.blue}\n />\n </span>\n </span>\n )\n }\n}\n\nBadge.propTypes = {\n children: PropTypes.node.isRequired,\n onClick: PropTypes.func,\n}\n\nexport default Badge\n\n```" } ]
code_collections_30c72076
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Autocomplete/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport AutocompleteSuggestion from './AutocompleteSuggestion'\nimport Autocomplete from './Autocomplete'\n\nfunction createAutocomplete({ graphql: { suggestion, name } }) {\n const AutocompleteSugestionContainer = suggestion(AutocompleteSuggestion)\n const AutocompleteContainer = name(Autocomplete)\n\n class AutocompleteWrapper extends Component {\n render() {\n return (\n <AutocompleteContainer\n values={this.props.values}\n DataSource={AutocompleteSugestionContainer}\n onChange={this.props.onChange}\n />\n )\n }\n }\n\n AutocompleteWrapper.propTypes = {\n values: PropTypes.array,\n onChange: PropTypes.func,\n }\n\n return AutocompleteWrapper\n}\n\nexport default createAutocomplete\n\n```" } ]
code_collections_35f63b19
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Autocomplete/AutocompleteSuggestion.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\n\nclass AutocompleteSuggestion extends Component {\n render() {\n const { data: { suggestions = [], loading } } = this.props\n const { highlightedIndex, getItemProps } = this.props\n\n const optionsClasses = 'absolute bl br bb bw1 br2 br--bottom bg-white flex-column z-max overflow-y-auto b--light-gray '\n const optionClasses = 'w-100 pointer flex near-black tl bb-0 bl-0 br-0 bt b--near-white b--silver pv4 ph3 '\n\n return (\n <div className={optionsClasses} style={{ width: '100%' }}>\n {loading\n ? <div className={`${optionClasses} i-s`}>Loading...</div>\n : suggestions.length === 0\n ? <div className={optionClasses}>\n No results for \"{this.props.inputValue}\".\n </div>\n : suggestions.map((suggestion, index) => {\n const isActive = highlightedIndex === index\n const selected = this.props.values.find(\n c => parseInt(suggestion.id) === c\n )\n\n const props = selected\n ? {}\n : getItemProps({\n index,\n item: suggestion.id,\n })\n\n return (\n <div\n key={suggestion.id}\n {...props}\n className={\n `${optionClasses} ${isActive ? 'bg-near-white' : 'bg-white'} ${selected ? 'fwb' : ''}`\n }\n >\n {selected && 'OK - '}{suggestion.name}\n </div>\n )\n })}\n </div>\n )\n }\n}\n\nAutocompleteSuggestion.propTypes = {\n values: PropTypes.array,\n data: PropTypes.object,\n inputValue: PropTypes.string,\n selectedItem: PropTypes.any,\n highlightedIndex: PropTypes.number,\n getItemProps: PropTypes.func,\n}\n\nexport default AutocompleteSuggestion\n\n```" } ]
code_collections_c4234e7e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Autocomplete/Autocomplete.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport Downshift from 'downshift'\nimport AutocompleteInput from './AutocompleteInput'\n\nclass Autocomplete extends Component {\n constructor(props) {\n super(props)\n\n this.state = { value: '', isMenuOpen: false }\n }\n\n handleChangeValue = e => {\n const value = e.target.value\n this.setState({ value, isMenuOpen: value.length >= 3 })\n };\n\n handleOuterClick = () => {\n this.setState({ isMenuOpen: false })\n };\n\n handleKeyDown = e => {\n const { values } = this.props\n if (\n values.length && this.state.value.length === 0 && e.key === 'Backspace'\n ) {\n this.props.onChange(values.slice(0, values.length - 1))\n }\n };\n\n handleChange = item => {\n this.setState({ value: '', isMenuOpen: false })\n this.props.onChange([...this.props.values, parseInt(item)])\n };\n\n render() {\n const { DataSource, values, data: { loading, names } } = this.props\n\n if (loading) return null\n\n return (\n <Downshift\n selectedItem={values}\n inputValue={this.state.value}\n onChange={this.handleChange}\n onOuterClick={this.handleOuterClick}\n isOpen={this.state.isMenuOpen}\n render={(\n {\n getInputProps,\n getItemProps,\n inputValue,\n selectedItem,\n highlightedIndex,\n isOpen,\n }\n ) => (\n <div className=\"relative\">\n <AutocompleteInput\n {...getInputProps({\n id: 'autocomplete-category',\n value: this.state.value,\n onChange: this.handleChangeValue,\n onKeyDown: this.handleKeyDown,\n })}\n block\n open={isOpen}\n values={names}\n />\n {isOpen\n ? <DataSource\n {...{\n values,\n inputValue,\n getItemProps,\n selectedItem,\n highlightedIndex,\n }}\n />\n : null}\n </div>\n )}\n />\n )\n }\n}\n\nAutocomplete.propTypes = {\n values: PropTypes.array,\n data: PropTypes.object,\n DataSource: PropTypes.any.isRequired,\n onChange: PropTypes.func.isRequired,\n}\n\nexport default Autocomplete\n\n```" } ]
code_collections_9c179717
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Autocomplete/AutocompleteInput.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport Badge from './Badge'\n\nclass AutocompleteInput extends Component {\n constructor(props) {\n super(props)\n\n this.state = {\n active: false,\n }\n }\n\n handleFocus = event => {\n this.setState({ active: true })\n this.props.onFocus && this.props.onFocus(event)\n };\n\n handleBlur = event => {\n this.setState({ active: false })\n this.props.onBlur && this.props.onBlur(event)\n };\n\n render() {\n const {\n error,\n block,\n large,\n xLarge,\n short,\n long,\n token,\n disabled,\n open,\n } = this.props\n const { active } = this.state\n\n const size = 'w-100'\n const box = 'ma0 border-box'\n const border = `bw1 br2 ${open ? 'br--top bb-0' : ''} b--solid outline-0`\n const typography = 'near-black'\n let classes = `${size} ${box} ${border} ${typography} `\n\n if (token) {\n classes += 'code '\n }\n\n if (active) {\n classes += 'b--gray '\n } else {\n classes += 'b--light-gray '\n if (!disabled) {\n classes += 'hover-b--silver '\n }\n }\n\n if (error) {\n classes += 'b--red hover-b--red '\n }\n\n if (disabled) {\n classes += 'bg-light-gray bg-light-silver b--light-silver silver '\n } else {\n classes += 'bg-white '\n }\n\n let width = '100%'\n\n if (large) {\n classes += 'f5 pv4 ph6 '\n // iconSize = 18\n if (!block) {\n if (short) {\n width = '130px'\n } else if (long) {\n width = '420px'\n } else {\n width = '250px'\n }\n }\n } else if (xLarge) {\n classes += 'f4 pv5 ph7 '\n // iconSize = 22\n if (!block) {\n if (short) {\n width = '180px'\n } else if (long) {\n width = '520px'\n } else {\n width = '320px'\n }\n }\n } else {\n classes += 'f6 pv3 ph5 '\n // iconSize = 16\n if (!block) {\n if (short) {\n width = '110px'\n } else if (long) {\n width = '350px'\n } else {\n width = '200px'\n }\n }\n }\n\n const style = { width: width }\n\n return (\n <div style={style} className={classes}>\n {this.props.values.map(value => (\n <Badge key={value.id}>{value.name}</Badge>\n ))}\n <input\n className=\"ml3 bw0 dib outline-transparent\"\n disabled={this.props.disabled}\n id={this.props.id}\n name={this.props.name}\n placeholder={this.props.placeholder}\n tabIndex={this.props.tabIndex}\n type={this.props.type}\n value={this.props.value}\n onBlur={this.handleBlur}\n onChange={this.props.onChange}\n onFocus={this.handleFocus}\n onKeyDown={this.props.onKeyDown}\n />\n </div>\n )\n }\n}\n\nAutocompleteInput.defaultProps = {\n type: 'text',\n}\n\nAutocompleteInput.propTypes = {\n disabled: PropTypes.bool,\n id: PropTypes.string,\n name: PropTypes.string,\n placeholder: PropTypes.string,\n tabIndex: PropTypes.number,\n type: PropTypes.string.isRequired,\n value: PropTypes.string,\n\n values: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.any,\n name: PropTypes.string,\n })\n ),\n\n block: PropTypes.bool,\n error: PropTypes.bool,\n large: PropTypes.bool,\n long: PropTypes.bool,\n open: PropTypes.bool.isRequired,\n short: PropTypes.bool,\n token: PropTypes.bool,\n xLarge: PropTypes.bool,\n\n onBlur: PropTypes.func,\n onChange: PropTypes.func.isRequired,\n onFocus: PropTypes.func,\n onKeyDown: PropTypes.func,\n}\n\nexport default AutocompleteInput\n\n```" } ]
code_collections_3816456a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Group/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport ManualGroup from '../ManualGroup'\nimport DynamicGroup from '../DynamicGroup'\n\nclass Group extends Component {\n handleSave = data => {\n this.props.onChange(this.props.index, data)\n };\n\n render() {\n const { data, collectionId } = this.props\n\n return data.skus.length > 0\n ? <ManualGroup\n collectionId={collectionId}\n name={data.name}\n skus={data.skus}\n onSave={this.handleSave}\n />\n : <DynamicGroup\n collectionId={collectionId}\n name={data.name}\n categories={data.categories}\n brands={data.brands}\n onSave={this.handleSave}\n />\n }\n}\n\nGroup.propTypes = {\n index: PropTypes.number.isRequired,\n data: PropTypes.object,\n collectionId: PropTypes.string,\n onChange: PropTypes.func.isRequired,\n}\n\nexport default Group\n\n```" } ]
code_collections_2ce070c9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/DatePicker/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport moment from 'moment'\nimport { SingleDatePicker } from 'react-dates'\n\nclass DatePicker extends Component {\n constructor(props) {\n super(props)\n\n this.state = {\n focused: false,\n value: moment(props.value || new Date()),\n }\n }\n\n componentWillReceiveProps(nextProps) {\n this.setState({\n value: moment(nextProps.value || new Date()),\n })\n }\n\n handleFocusChange = ({ focused }) => {\n this.setState({ focused })\n };\n\n handleChange = date => {\n this.props.onChange(date.toISOString())\n };\n\n render() {\n return (\n <SingleDatePicker\n showDefaultInputIcon\n numberOfMonths={1}\n date={this.state.value}\n focused={this.state.focused}\n onDateChange={this.handleChange}\n onFocusChange={this.handleFocusChange}\n />\n )\n }\n}\n\nDatePicker.propTypes = {\n value: PropTypes.string,\n onChange: PropTypes.func.isRequired,\n}\n\nexport default DatePicker\n\n```" } ]
code_collections_09e5e90f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/DatePicker/custom.css from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.SingleDatePicker {\n padding-right: 16px;\n}\n\n.SingleDatePicker_picker__directionLeft {\n top: 50px !important;\n}\n\n.SingleDatePickerInput_calendarIcon {\n padding: 0 0 6px 5px;\n}\n\n.SingleDatePickerInput{\n border-radius: 4px;\n border: 2px solid #e3e4e6;\n}\n\n.DateInput {\n width: 100px;\n}\n\n.DateInput_input {\n border-bottom: 0;\n}\n\n.DateInput input[type=text] {\n font-size: 14px;\n letter-spacing: -0.4px;\n font-weight: 400;\n padding: 5px 8px;\n}\n\n.CalendarDay__selected, .CalendarDay__selected:active, .CalendarDay__selected:hover {\n background: #3193F5;\n border: 1px solid #3193F5;\n color: #fff;\n}\n\n.DayPickerKeyboardShortcuts_show__bottomRight {\n border-right: none;\n}\n\n.DateInput_fang{\n display: none;\n}\n\n```" } ]
code_collections_7e8ecff6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/DatePicker/react-dates.css from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.PresetDateRangePicker_panel {\n padding: 0 22px 11px\n}\n.PresetDateRangePicker_button {\n position: relative;\n height: 100%;\n text-align: center;\n background: 0 0;\n border: 2px solid #00a699;\n color: #00a699;\n padding: 4px 12px;\n margin-right: 8px;\n font: inherit;\n font-weight: 700;\n line-height: normal;\n overflow: visible;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n cursor: pointer\n}\n.PresetDateRangePicker_button:active {\n outline: 0\n}\n.PresetDateRangePicker_button__selected {\n color: #fff;\n background: #00a699\n}\n.SingleDatePickerInput {\n display: inline-block;\n background-color: #fff\n}\n.SingleDatePickerInput__withBorder {\n border: 1px solid #dbdbdb\n}\n.SingleDatePickerInput__rtl {\n direction: rtl\n}\n.SingleDatePickerInput__disabled {\n background-color: #f2f2f2\n}\n.SingleDatePickerInput__block {\n display: block\n}\n.SingleDatePickerInput__showClearDate {\n padding-right: 30px\n}\n.SingleDatePickerInput_clearDate {\n background: 0 0;\n border: 0;\n color: inherit;\n font: inherit;\n line-height: normal;\n overflow: visible;\n cursor: pointer;\n padding: 10px;\n margin: 0 10px 0 5px;\n position: absolute;\n right: 0;\n top: 50%;\n -webkit-transform: translateY(-50%);\n -ms-transform: translateY(-50%);\n transform: translateY(-50%)\n}\n.SingleDatePickerInput_clearDate__default:focus,\n.SingleDatePickerInput_clearDate__default:hover {\n background: #dbdbdb;\n border-radius: 50%\n}\n.SingleDatePickerInput_clearDate__small {\n padding: 6px\n}\n.SingleDatePickerInput_clearDate__hide {\n visibility: hidden\n}\n.SingleDatePickerInput_clearDate_svg {\n fill: #82888a;\n height: 12px;\n width: 15px;\n vertical-align: middle\n}\n.SingleDatePickerInput_clearDate_svg__small {\n height: 9px\n}\n.SingleDatePickerInput_calendarIcon {\n background: 0 0;\n border: 0;\n color: inherit;\n font: inherit;\n line-height: normal;\n overflow: visible;\n cursor: pointer;\n display: inline-block;\n vertical-align: middle;\n padding: 10px;\n margin: 0 5px 0 10px\n}\n.SingleDatePickerInput_calendarIcon_svg {\n fill: #82888a;\n height: 15px;\n width: 14px;\n vertical-align: middle\n}\n.SingleDatePicker {\n position: relative;\n display: inline-block\n}\n.SingleDatePicker__block {\n display: block\n}\n.SingleDatePicker_picker {\n z-index: 1;\n background-color: #fff;\n position: absolute\n}\n.SingleDatePicker_picker__rtl {\n direction: rtl\n}\n.SingleDatePicker_picker__directionLeft {\n left: 0\n}\n.SingleDatePicker_picker__directionRight {\n right: 0\n}\n.SingleDatePicker_picker__portal {\n background-color: rgba(0,0,0,.3);\n position: fixed;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%\n}\n.SingleDatePicker_picker__fullScreenPortal {\n background-color: #fff\n}\n.SingleDatePicker_closeButton {\n background: 0 0;\n border: 0;\n color: inherit;\n font: inherit;\n line-height: normal;\n overflow: visible;\n cursor: pointer;\n position: absolute;\n top: 0;\n right: 0;\n padding: 15px;\n z-index: 2\n}\n.SingleDatePicker_closeButton:focus,\n.SingleDatePicker_closeButton:hover {\n color: darken(#cacccd,10%);\n text-decoration: none\n}\n.SingleDatePicker_closeButton_svg {\n height: 15px;\n width: 15px;\n fill: #cacccd\n}\n.DayPickerKeyboardShortcuts_buttonReset {\n background: 0 0;\n border: 0;\n border-radius: 0;\n color: inherit;\n font: inherit;\n line-height: normal;\n overflow: visible;\n padding: 0;\n cursor: pointer;\n font-size: 14px\n}\n.DayPickerKeyboardShortcuts_buttonReset:active {\n outline: 0\n}\n.DayPickerKeyboardShortcuts_show {\n width: 22px;\n position: absolute;\n z-index: 2\n}\n.DayPickerKeyboardShortcuts_show__bottomRight {\n border-top: 26px solid transparent;\n border-right: 33px solid #00a699;\n bottom: 0;\n right: 0\n}\n.DayPickerKeyboardShortcuts_show__bottomRight:hover {\n border-right: 33px solid #008489\n}\n.DayPickerKeyboardShortcuts_show__topRight {\n border-bottom: 26px solid transparent;\n border-right: 33px solid #00a699;\n top: 0;\n right: 0\n}\n.DayPickerKeyboardShortcuts_show__topRight:hover {\n border-right: 33px solid #008489\n}\n.DayPickerKeyboardShortcuts_show__topLeft {\n border-bottom: 26px solid transparent;\n border-left: 33px solid #00a699;\n top: 0;\n left: 0\n}\n.DayPickerKeyboardShortcuts_show__topLeft:hover {\n border-left: 33px solid #008489\n}\n.DayPickerKeyboardShortcuts_showSpan {\n color: #fff;\n position: absolute\n}\n.DayPickerKeyboardShortcuts_showSpan__bottomRight {\n bottom: 0;\n right: -28px\n}\n.DayPickerKeyboardShortcuts_showSpan__topRight {\n top: 1px;\n right: -28px\n}\n.DayPickerKeyboardShortcuts_showSpan__topLeft {\n top: 1px;\n left: -28px\n}\n.DayPickerKeyboardShortcuts_panel {\n overflow: auto;\n background: #fff;\n border: 1px solid #dbdbdb;\n border-radius: 2px;\n position: absolute;\n top: 0;\n bottom: 0;\n right: 0;\n left: 0;\n z-index: 2;\n padding: 22px;\n margin: 33px\n}\n.DayPickerKeyboardShortcuts_title {\n font-size: 16px;\n font-weight: 700;\n margin: 0\n}\n.DayPickerKeyboardShortcuts_list {\n list-style: none;\n padding: 0;\n font-size: 14px\n}\n.DayPickerKeyboardShortcuts_close {\n position: absolute;\n right: 22px;\n top: 22px;\n z-index: 2\n}\n.DayPickerKeyboardShortcuts_close:active {\n outline: 0\n}\n.DayPickerKeyboardShortcuts_closeSvg {\n height: 15px;\n width: 15px;\n fill: #cacccd\n}\n.DayPickerKeyboardShortcuts_closeSvg:focus,\n.DayPickerKeyboardShortcuts_closeSvg:hover {\n fill: #82888a\n}\n.CalendarDay {\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n cursor: pointer;\n font-size: 14px;\n text-align: center\n}\n.CalendarDay:active {\n outline: 0\n}\n.CalendarDay__defaultCursor {\n cursor: default\n}\n.CalendarDay__default {\n border: 1px solid #e4e7e7;\n color: #565a5c;\n background: #fff\n}\n.CalendarDay__default:hover {\n background: #e4e7e7;\n border: 1px double #e4e7e7;\n color: inherit\n}\n.CalendarDay__hovered_offset {\n background: #f4f5f5;\n border: 1px double #e4e7e7;\n color: inherit\n}\n.CalendarDay__outside {\n border: 0;\n background: #fff;\n color: #565a5c\n}\n.CalendarDay__blocked_minimum_nights {\n background: #fff;\n border: 1px solid #eceeee;\n color: #cacccd\n}\n.CalendarDay__blocked_minimum_nights:active,\n.CalendarDay__blocked_minimum_nights:hover {\n background: #fff;\n color: #cacccd\n}\n.CalendarDay__highlighted_calendar {\n background: #ffe8bc;\n color: #565a5c\n}\n.CalendarDay__highlighted_calendar:active,\n.CalendarDay__highlighted_calendar:hover {\n background: #ffce71;\n color: #565a5c\n}\n.CalendarDay__selected_span {\n background: #66e2da;\n border: 1px solid #33dacd;\n color: #fff\n}\n.CalendarDay__selected_span:active,\n.CalendarDay__selected_span:hover {\n background: #33dacd;\n border: 1px solid #33dacd;\n color: #fff\n}\n.CalendarDay__last_in_range {\n border-right: #00a699\n}\n.CalendarDay__selected,\n.CalendarDay__selected:active,\n.CalendarDay__selected:hover {\n background: #00a699;\n border: 1px solid #00a699;\n color: #fff\n}\n.CalendarDay__hovered_span,\n.CalendarDay__hovered_span:hover {\n background: #b2f1ec;\n border: 1px solid #80e8e0;\n color: #007a87\n}\n.CalendarDay__hovered_span:active {\n background: #80e8e0;\n border: 1px solid #80e8e0;\n color: #007a87\n}\n.CalendarDay__blocked_calendar,\n.CalendarDay__blocked_calendar:active,\n.CalendarDay__blocked_calendar:hover {\n background: #cacccd;\n border: 1px solid #cacccd;\n color: #82888a\n}\n.CalendarDay__blocked_out_of_range,\n.CalendarDay__blocked_out_of_range:active,\n.CalendarDay__blocked_out_of_range:hover {\n background: #fff;\n border: 1px solid #e4e7e7;\n color: #cacccd\n}\n.CalendarMonth {\n background: #fff;\n text-align: center;\n padding: 0 13px;\n vertical-align: top;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none\n}\n.CalendarMonth_table {\n border-collapse: collapse;\n border-spacing: 0\n}\n.CalendarMonth_caption {\n color: #565a5c;\n font-size: 18px;\n text-align: center;\n padding-top: 22px;\n padding-bottom: 37px;\n caption-side: initial\n}\n.CalendarMonth_caption__verticalScrollable {\n padding-top: 12px;\n padding-bottom: 7px\n}\n.CalendarMonthGrid {\n background: #fff;\n text-align: left;\n z-index: 0\n}\n.CalendarMonthGrid__animating {\n z-index: 1\n}\n.CalendarMonthGrid__horizontal {\n position: absolute;\n left: 9px\n}\n.CalendarMonthGrid__vertical {\n margin: 0 auto\n}\n.CalendarMonthGrid__vertical_scrollable {\n margin: 0 auto;\n overflow-y: scroll\n}\n.CalendarMonthGrid_month__horizontal {\n display: inline-block;\n vertical-align: top;\n min-height: 100%\n}\n.CalendarMonthGrid_month__hideForAnimation {\n position: absolute;\n z-index: -1;\n opacity: 0;\n pointer-events: none\n}\n.CalendarMonthGrid_month__hidden {\n visibility: hidden\n}\n.DayPickerNavigation_container {\n position: relative;\n z-index: 2\n}\n.DayPickerNavigation_container__vertical {\n background: #fff;\n box-shadow: 0 0 5px 2px rgba(0,0,0,.1);\n position: absolute;\n bottom: 0;\n left: 0;\n height: 52px;\n width: 100%\n}\n.DayPickerNavigation_container__verticalScrollable {\n position: relative\n}\n.DayPickerNavigation_button {\n cursor: pointer;\n line-height: .78;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none\n}\n.DayPickerNavigation_button__default {\n border: 1px solid #e4e7e7;\n background-color: #fff;\n color: #757575\n}\n.DayPickerNavigation_button__default:focus,\n.DayPickerNavigation_button__default:hover {\n border: 1px solid #c4c4c4\n}\n.DayPickerNavigation_button__default:active {\n background: #f2f2f2\n}\n.DayPickerNavigation_button__horizontal {\n border-radius: 3px;\n padding: 6px 9px;\n top: 18px;\n position: absolute\n}\n.DayPickerNavigation_leftButton__horizontal {\n left: 22px\n}\n.DayPickerNavigation_rightButton__horizontal {\n right: 22px\n}\n.DayPickerNavigation_button__vertical {\n display: inline-block;\n position: relative;\n height: 100%;\n width: 50%\n}\n.DayPickerNavigation_button__vertical__default {\n padding: 5px\n}\n.DayPickerNavigation_nextButton__vertical__default {\n border-left: 0\n}\n.DayPickerNavigation_nextButton__verticalScrollable {\n width: 100%\n}\n.DayPickerNavigation_svg__horizontal {\n height: 19px;\n width: 19px;\n fill: #82888a\n}\n.DayPickerNavigation_svg__vertical {\n height: 42px;\n width: 42px;\n fill: #565a5c\n}\n.DayPicker {\n background: #fff;\n position: relative;\n text-align: left\n}\n.DayPicker__horizontal {\n background: #fff\n}\n.DayPicker__verticalScrollable {\n height: 100%\n}\n.DayPicker__hidden {\n visibility: hidden\n}\n.DayPicker__withBorder {\n box-shadow: 0 2px 6px rgba(0,0,0,.05),0 0 0 1px rgba(0,0,0,.07);\n border-radius: 3px\n}\n.DayPicker_portal__horizontal {\n box-shadow: none;\n position: absolute;\n left: 50%;\n top: 50%\n}\n.DayPicker_portal__vertical {\n position: initial\n}\n.DayPicker_focusRegion {\n outline: 0\n}\n.DayPicker_calendarInfo__horizontal,\n.DayPicker_wrapper__horizontal {\n display: inline-block;\n vertical-align: top\n}\n.DayPicker_weekHeaders {\n position: relative\n}\n.DayPicker_weekHeaders__horizontal {\n margin-left: 9px\n}\n.DayPicker_weekHeader {\n color: #757575;\n position: absolute;\n top: 62px;\n z-index: 2;\n padding: 0 13px;\n text-align: left\n}\n.DayPicker_weekHeader__vertical {\n left: 50%\n}\n.DayPicker_weekHeader__verticalScrollable {\n top: 0;\n display: table-row;\n border-bottom: 1px solid #dbdbdb;\n background: #fff;\n margin-left: 0;\n left: 0;\n width: 100%;\n text-align: center\n}\n.DayPicker_weekHeader_ul {\n list-style: none;\n margin: 1px 0;\n padding-left: 0;\n padding-right: 0;\n font-size: 14px\n}\n.DayPicker_weekHeader_li {\n display: inline-block;\n text-align: center\n}\n.DayPicker_transitionContainer {\n position: relative;\n overflow: hidden;\n border-radius: 3px\n}\n.DayPicker_transitionContainer__horizontal {\n -webkit-transition: height .2s ease-in-out;\n -moz-transition: height .2s ease-in-out;\n transition: height .2s ease-in-out\n}\n.DayPicker_transitionContainer__vertical {\n width: 100%\n}\n.DayPicker_transitionContainer__verticalScrollable {\n padding-top: 20px;\n height: 100%;\n position: absolute;\n top: 0;\n bottom: 0;\n right: 0;\n left: 0;\n overflow-y: scroll\n}\n.DateInput {\n margin: 0;\n padding: 0;\n background: #fff;\n position: relative;\n display: inline-block;\n width: 130px;\n vertical-align: middle\n}\n.DateInput__small {\n width: 90px\n}\n.DateInput__block {\n width: 100%\n}\n.DateInput__disabled {\n background: #f2f2f2;\n color: #dbdbdb\n}\n.DateInput_input {\n font-weight: 200;\n font-size: 18px;\n line-height: 24px;\n color: #565a5c;\n background-color: #fff;\n width: 100%;\n padding: 13px 12px 11px;\n border: 0;\n border-top: 0;\n border-right: 0;\n border-bottom: 2px solid transparent;\n border-left: 0\n}\n.DateInput_input__small {\n font-size: 14px;\n line-height: 18px;\n padding: 8px 8px 6px\n}\n.DateInput_input__regular {\n font-weight: auto\n}\n.DateInput_input__readOnly {\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none\n}\n.DateInput_input__focused {\n outline: 0;\n background: #fff;\n border: 0;\n border-top: 0;\n border-right: 0;\n border-bottom: 2px solid #008489;\n border-left: 0\n}\n.DateInput_input__disabled {\n background: #f2f2f2;\n font-style: italic\n}\n.DateInput_screenReaderMessage {\n border: 0;\n clip: rect(0,0,0,0);\n height: 1px;\n margin: -1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n width: 1px\n}\n.DateInput_fang {\n position: absolute;\n width: 20px;\n height: 10px;\n left: 22px;\n z-index: 2\n}\n.DateInput_fangShape {\n fill: #fff\n}\n.DateInput_fangStroke {\n stroke: #dbdbdb;\n fill: transparent\n}\n.DateRangePickerInput {\n background-color: #fff;\n display: inline-block\n}\n.DateRangePickerInput__disabled {\n background: #f2f2f2\n}\n.DateRangePickerInput__withBorder {\n border: 1px solid #cacccd\n}\n.DateRangePickerInput__rtl {\n direction: rtl\n}\n.DateRangePickerInput__block {\n display: block\n}\n.DateRangePickerInput__showClearDates {\n padding-right: 30px\n}\n.DateRangePickerInput_arrow {\n display: inline-block;\n vertical-align: middle\n}\n.DateRangePickerInput_arrow_svg {\n vertical-align: middle;\n fill: #565a5c;\n height: 24px;\n width: 24px\n}\n.DateRangePickerInput_arrow_svg__small {\n height: 19px;\n width: 19px\n}\n.DateRangePickerInput_clearDates {\n background: 0 0;\n border: 0;\n color: inherit;\n font: inherit;\n line-height: normal;\n overflow: visible;\n cursor: pointer;\n padding: 10px;\n margin: 0 10px 0 5px;\n position: absolute;\n right: 0;\n top: 50%;\n -webkit-transform: translateY(-50%);\n -ms-transform: translateY(-50%);\n transform: translateY(-50%)\n}\n.DateRangePickerInput_clearDates__small {\n padding: 6px\n}\n.DateRangePickerInput_clearDates_default:focus,\n.DateRangePickerInput_clearDates_default:hover {\n background: #dbdbdb;\n border-radius: 50%\n}\n.DateRangePickerInput_clearDates__hide {\n visibility: hidden\n}\n.DateRangePickerInput_clearDates_svg {\n fill: #82888a;\n height: 12px;\n width: 15px;\n vertical-align: middle\n}\n.DateRangePickerInput_clearDates_svg__small {\n height: 9px\n}\n.DateRangePickerInput_calendarIcon {\n background: 0 0;\n border: 0;\n color: inherit;\n font: inherit;\n line-height: normal;\n overflow: visible;\n cursor: pointer;\n display: inline-block;\n vertical-align: middle;\n padding: 10px;\n margin: 0 5px 0 10px\n}\n.DateRangePickerInput_calendarIcon_svg {\n fill: #82888a;\n height: 15px;\n width: 14px;\n vertical-align: middle\n}\n.DateRangePicker {\n position: relative;\n display: inline-block\n}\n.DateRangePicker__block {\n display: block\n}\n.DateRangePicker_picker {\n z-index: 1;\n background-color: #fff;\n position: absolute\n}\n.DateRangePicker_picker__rtl {\n direction: rtl\n}\n.DateRangePicker_picker__directionLeft {\n left: 0\n}\n.DateRangePicker_picker__directionRight {\n right: 0\n}\n.DateRangePicker_picker__portal {\n background-color: rgba(0,0,0,.3);\n position: fixed;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%\n}\n.DateRangePicker_picker__fullScreenPortal {\n background-color: #fff\n}\n.DateRangePicker_closeButton {\n background: 0 0;\n border: 0;\n color: inherit;\n font: inherit;\n line-height: normal;\n overflow: visible;\n cursor: pointer;\n position: absolute;\n top: 0;\n right: 0;\n padding: 15px;\n z-index: 2\n}\n.DateRangePicker_closeButton:focus,\n.DateRangePicker_closeButton:hover {\n color: darken(#cacccd,10%);\n text-decoration: none\n}\n.DateRangePicker_closeButton_svg {\n height: 15px;\n width: 15px;\n fill: #cacccd\n}\n\n```" } ]
code_collections_4bedf641
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Checkbox/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport style from './style.css'\n\nclass Checkbox extends Component {\n render() {\n return (\n <label className={style.container}>\n <input\n type=\"checkbox\"\n checked={this.props.checked}\n onChange={this.props.onChange}\n />\n <span\n className={\n `${style.checkmark} ba bw1 ${this.props.semiChecked ? 'b--blue' : 'b--light-gray'}`\n }\n style={{ width: '12px', height: '12px' }}\n />\n </label>\n )\n }\n}\n\nCheckbox.propTypes = {\n id: PropTypes.string,\n checked: PropTypes.bool,\n semiChecked: PropTypes.bool,\n defaultChecked: PropTypes.bool,\n onChange: PropTypes.func.isRequired,\n}\n\nexport default Checkbox\n\n```" } ]
code_collections_b19f9249
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Checkbox/style.css from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.checkmark {\n position: absolute;\n top: 0;\n left: 0;\n height: 25px;\n width: 25px;\n background-color: #FFF;\n border-radius: 2px;\n}\n\n.container {\n display: block;\n position: relative;\n padding-left: 1rem;\n margin-right: 1rem;\n font-size: 1.25rem;\n margin-bottom: .75rem;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\n.container input {\n position: absolute;\n opacity: 0;\n cursor: pointer;\n margin-right: 1rem;\n}\n\n.container:hover input ~ .checkmark {\n background-color: #e3e4e6;\n}\n\n.container input:checked ~ .checkmark {\n background-color: #368df7;\n border: solid #368df7 2px;\n}\n\n.checkmark:after {\n content: \"\";\n position: absolute;\n display: none;\n}\n\n.container input:checked ~ .checkmark:after {\n display: block;\n}\n\n.container .checkmark:after {\n left: 3px;\n top: -1px;\n width: 4px;\n height: 8px;\n border: solid white;\n border-width: 0 2px 2px 0;\n -webkit-transform: rotate(45deg);\n -ms-transform: rotate(45deg);\n transform: rotate(45deg);\n}\n\n```" } ]
code_collections_0c473adc
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Toggle/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\n\nconst noop = () => {}\n\nclass Toggle extends Component {\n render() {\n const { semantic, disabled, id, checked } = this.props\n\n let classes = 'flex items-center relative h1 w2 ph1 br4 bg-animate '\n let circleClasses = 'absolute br-100 pa3 '\n\n // Background\n if (semantic) {\n if (!disabled && !checked) {\n classes += 'bg-red '\n }\n\n if (!disabled && checked) {\n classes += 'bg-green '\n }\n } else if (disabled) {\n classes += 'bg-near-white '\n } else {\n if (!checked) {\n classes += 'bg-gray '\n }\n\n if (checked) {\n classes += 'bg-blue '\n }\n }\n\n // Circle\n if (checked) {\n circleClasses += 'left-1 '\n } else {\n circleClasses += 'left-0 '\n }\n\n if (disabled) {\n circleClasses += 'bg-light-gray '\n } else {\n circleClasses += 'bg-white '\n }\n\n const eventHandlers = {\n onClick: this.props.onClick ? this.props.onClick : noop,\n onChange: this.props.onChange ? this.props.onChange : noop,\n }\n\n return (\n <label\n htmlFor={`${id}`}\n className={`flex flex-row items-center ${!disabled && 'pointer'}`}\n >\n {this.props.children ? this.props.children : ''}\n <div className={`${classes}`}>\n <div\n style={{\n height: '0.8rem',\n width: '0.8rem',\n transition: 'all .2s ease-out',\n boxShadow: disabled ? 'none' : '0 0 10px rgba(0,0,0,0.2)',\n }}\n className={`${circleClasses}`}\n />\n </div>\n <input\n id={`${id}`}\n type=\"checkbox\"\n className=\"dn\"\n disabled={disabled}\n checked={checked}\n {...eventHandlers}\n />\n </label>\n )\n }\n}\n\nToggle.defaultProps = {\n checked: false,\n disabled: false,\n semantic: false,\n}\n\nToggle.propTypes = {\n checked: PropTypes.bool,\n semantic: PropTypes.bool,\n disabled: PropTypes.bool,\n id: PropTypes.string,\n children: PropTypes.node,\n onChange: PropTypes.func,\n onClick: PropTypes.func,\n}\n\nexport default Toggle\n\n```" } ]
code_collections_9249a15f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/Toggle/README.md from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\nDefault\n\n```js\nclass ToggleExample extends React.Component {\n constructor() {\n super()\n this.state = { checked: true }\n\n this.onClick = this.onClick.bind(this)\n }\n\n onClick() {\n this.setState((prevState) => ({\n checked: !prevState.checked\n }))\n }\n\n render() {\n return (\n <Toggle id='toggle1'\n checked={this.state.checked}\n onClick={this.onClick}/>\n )\n }\n};\n<ToggleExample />\n```\n\nSemantic\n\n```js\nclass ToggleSemanticExample extends React.Component {\n constructor() {\n super()\n this.state = { checked: false }\n\n this.onClick = this.onClick.bind(this)\n }\n\n onClick() {\n this.setState((prevState) => ({\n checked: !prevState.checked\n }))\n }\n\n render() {\n return (\n <Toggle id='toggle2'\n semantic\n checked={this.state.checked}\n onClick={this.onClick}/>\n )\n }\n};\n<ToggleSemanticExample />\n```\n\nDisabled\n\n```js\n<div> \n <Toggle disabled id='toggle3'/>\n</div>\n```\n\nSide by side\n\n```js\nclass ToggleExample extends React.Component {\n constructor() {\n super()\n this.state = { checked: true }\n\n this.onClick = this.onClick.bind(this)\n }\n\n onClick() {\n this.setState((prevState) => ({\n checked: !prevState.checked\n }))\n }\n\n render() {\n return (\n <Toggle id='toggle4'\n checked={this.state.checked}\n onClick={this.onClick}/>\n )\n }\n};\nclass ToggleSemanticExample extends React.Component {\n constructor() {\n super()\n this.state = { checked: false }\n\n this.onClick = this.onClick.bind(this)\n }\n\n onClick() {\n this.setState((prevState) => ({\n checked: !prevState.checked\n }))\n }\n\n render() {\n return (\n <Toggle id='toggle5'\n semantic\n checked={this.state.checked}\n onClick={this.onClick}/>\n )\n }\n};\n<div>\n <ToggleExample />\n <br />\n <ToggleSemanticExample />\n <br />\n <Toggle disabled id='toggle6'/>\n <br />\n</div>\n```\n\n```" } ]
code_collections_447ac6a8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/EmptyStates/EmptyCollectionSearch.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport EmptySearchIcon from './EmptySearchIcon'\n\nclass EmptyCollectionSearch extends Component {\n render() {\n return (\n <div\n className=\"pa10 tc flex flex-column items-center justify-center mw7 center\"\n >\n <EmptySearchIcon />\n <div className=\"pt5 f4\">\n There's no collection with that name or ID\n </div>\n </div>\n )\n }\n}\n\nexport default EmptyCollectionSearch\n\n```" } ]
code_collections_675164f3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/EmptyStates/EmptyStateIcon.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport config from 'vtex-tachyons/config.json'\n\nclass EmptyStateIcon extends Component {\n render() {\n return (\n <svg\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n x=\"0px\"\n y=\"0px\"\n viewBox=\"0 0 64 64\"\n xmlSpace=\"preserve\"\n width=\"64\"\n height=\"64\"\n >\n <g className=\"nc-icon-wrapper\" fill=\"#368df7\">\n <polyline\n data-cap=\"butt\"\n fill=\"none\"\n stroke={this.props.stroke}\n strokeWidth=\"2\"\n strokeMiterlimit=\"10\"\n points=\"48,18 48,11 24,11 18,5 2,5 2,59 49,59 61,23 14,23 2,59 \"\n transform=\"translate(0, 0)\"\n strokeLinejoin=\"round\"\n strokeLinecap=\"round\"\n />\n </g>\n </svg>\n )\n }\n}\n\nEmptyStateIcon.defaultProps = {\n stroke: config.colors['rebel-pink'],\n}\n\nEmptyStateIcon.propTypes = {\n stroke: PropTypes.string.isRequired,\n fill: PropTypes.string,\n width: PropTypes.number,\n height: PropTypes.number,\n}\n\nexport default EmptyStateIcon\n\n```" } ]
code_collections_45ecac86
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/EmptyStates/EmptyCollection.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport EmptyStateIcon from './EmptyStateIcon'\n\nclass EmptyCollection extends Component {\n render() {\n return (\n <div\n className=\"pa10 tc flex flex-column items-center justify-center mw7 center\"\n >\n <EmptyStateIcon />\n <div className=\"pt5 f4\">\n Your collection is empty!\n </div>\n <div className=\"pt4 f6\">\n Search and select some products to compose your collection\n </div>\n </div>\n )\n }\n}\n\nexport default EmptyCollection\n\n```" } ]
code_collections_ce45e863
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/EmptyStates/EmptySearch.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport EmptySearchIcon from './EmptySearchIcon'\n\nclass EmptySearch extends Component {\n render() {\n return (\n <div\n className=\"pa10 tc flex flex-column items-center justify-center mw7 center\"\n >\n <EmptySearchIcon />\n <div className=\"pt5 f4\">\n There's no product or SKU with that name\n </div>\n <div className=\"pt4 f6\">\n Try another name or check if your product is in your catalog\n </div>\n </div>\n )\n }\n}\n\nexport default EmptySearch\n\n```" } ]
code_collections_7e07ac5a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/EmptyStates/EmptySearchIcon.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport config from 'vtex-tachyons/config.json'\n\nclass EmptySearchIcon extends Component {\n render() {\n return (\n <svg\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n x=\"0px\"\n y=\"0px\"\n viewBox=\"0 0 64 64\"\n xmlSpace=\"preserve\"\n width=\"64\"\n height=\"64\"\n >\n <g fill=\"#368df7\">\n <line\n data-cap=\"butt\"\n data-color=\"color-2\"\n fill=\"none\"\n stroke={this.props.stroke}\n strokeWidth=\"2\"\n strokeMiterlimit=\"10\"\n x1=\"60\"\n y1=\"60\"\n x2=\"43\"\n y2=\"43\"\n strokeLinejoin=\"round\"\n strokeLinecap=\"round\"\n />\n <circle\n fill=\"none\"\n stroke={this.props.stroke}\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeMiterlimit=\"10\"\n cx=\"26\"\n cy=\"26\"\n r=\"24\"\n strokeLinejoin=\"round\"\n />\n <line\n data-color=\"color-2\"\n fill=\"none\"\n stroke={this.props.stroke}\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeMiterlimit=\"10\"\n transform=\"rotate(45 26 26)\"\n x1=\"26\"\n y1=\"18\"\n x2=\"26\"\n y2=\"34\"\n strokeLinejoin=\"round\"\n />\n <line\n data-color=\"color-2\"\n fill=\"none\"\n stroke={this.props.stroke}\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeMiterlimit=\"10\"\n transform=\"rotate(45 26 26)\"\n x1=\"34\"\n y1=\"26\"\n x2=\"18\"\n y2=\"26\"\n strokeLinejoin=\"round\"\n />\n </g>\n </svg>\n )\n }\n}\n\nEmptySearchIcon.defaultProps = {\n stroke: config.colors['rebel-pink'],\n}\n\nEmptySearchIcon.propTypes = {\n stroke: PropTypes.string.isRequired,\n fill: PropTypes.string,\n width: PropTypes.number,\n height: PropTypes.number,\n}\n\nexport default EmptySearchIcon\n\n```" } ]
code_collections_96517b1d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/CollapsedGroup/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\n\nimport Card from '../Card'\nimport Button from '@vtex/styleguide/lib/Button'\nimport Badge from '../Badge'\n\nclass CollapsedGroup extends Component {\n render() {\n return (\n <Card>\n <div>\n <div className=\"flex justify-between items-center\">\n <div className=\"f3 fw7 w-50\">\n GroupName\n </div>\n <div>\n <Badge type=\"active\">Manual</Badge>\n </div>\n </div>\n <div className=\"w-100 pt4\">\n <div className=\"f6\">\n <span className=\"fw7\">6 skus</span> manually selected\n </div>\n </div>\n </div>\n <div className=\"pt6 nl5\">\n <div>\n <Button>Edit</Button>\n <Button>Delete group</Button>\n </div>\n </div>\n </Card>\n )\n }\n}\n\nexport default CollapsedGroup\n\n```" } ]
code_collections_56e975f3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/ManualGroup/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\n\nimport BaseGroup from '../BaseGroup'\nimport Items from './Items'\n\nclass ManualGroup extends Component {\n constructor(props) {\n super(props)\n\n this.state = {\n group: {\n name: props.name,\n skus: props.skus,\n type: 'I',\n preSale: false,\n release: false,\n brands: [],\n categories: [],\n },\n currentPage: 1,\n queryFrom: 0,\n queryTo: 9,\n query: '',\n }\n }\n\n handleChangeName = e => {\n const name = e.target.value\n this.setState(prevState => ({ group: {...prevState.group, name} }))\n };\n\n handleSave = () => {\n this.props.onSave(this.state.group)\n };\n\n handleCancel = () => {};\n\n handleChangeSkus = changes => {\n const skus = changes.reduce(\n (acc, change) => {\n if (change.checked && !acc.includes(change.skuId)) {\n return this.addSku(acc, change.skuId)\n }\n if (!change.checked && acc.includes(change.skuId)) {\n return this.removeSku(acc, change.skuId)\n }\n return acc\n },\n this.state.group.skus\n )\n\n this.setState(prevState => ({ group: {...prevState.group, skus} }))\n };\n\n handleChangeSearch = newState => {\n this.setState(newState)\n }\n\n removeSku(skus, skuId) {\n return skus.filter(sku => sku !== skuId)\n }\n\n addSku(skus, skuId) {\n return skus.concat(skuId)\n }\n\n render() {\n return (\n <BaseGroup\n name={this.state.name}\n onChangeName={this.handleChangeName}\n onSave={this.handleSave}\n onCancel={this.handleCancel}\n >\n <Items\n query={this.state.query}\n currentPage={this.state.currentPage}\n queryFrom={this.state.queryFrom}\n queryTo={this.state.queryTo}\n collectionId={this.props.collectionId}\n skus={this.state.group.skus}\n onChange={this.handleChangeSearch}\n onChangeSkus={this.handleChangeSkus}\n />\n </BaseGroup>\n )\n }\n}\n\nManualGroup.propTypes = {\n collectionId: PropTypes.string,\n name: PropTypes.string,\n skus: PropTypes.array.isRequired,\n onSave: PropTypes.func.isRequired,\n}\n\nexport default ManualGroup\n\n```" } ]
code_collections_ffd665be
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/NewGroup/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\n\nimport Card from '../Card'\nimport Button from '@vtex/styleguide/lib/Button'\n\nclass NewGroup extends Component {\n render() {\n return (\n <Card>\n <div>\n <div className=\"f3 fw7 w-50\">\n <input\n className=\"w-auto bn f3 fw7 near-black\"\n type=\"text\"\n placeholder=\"Name your collection\"\n defaultValue=\"Type a name\"\n style={{ width: '10em' }}\n onChange={()=>{}}\n />\n </div>\n <form className=\"pt6\">\n <div className=\"f6 pb3\">\n <input type=\"radio\" name=\"grouptype\" id=\"manual\" />\n <label className=\"pl3\" htmlFor=\"manual\">Add products manually</label>\n </div>\n <div className=\"f6\">\n <input type=\"radio\" name=\"grouptype\" id=\"dynamic\" />\n <label className=\"pl3\" htmlFor=\"dynamic\">Add products dynamically based on conditions</label>\n </div>\n </form>\n <div>\n <div className=\"pt6 nl5\">\n <Button>Start group</Button>\n <Button>Cancel</Button>\n </div>\n </div>\n </div>\n </Card>\n )\n }\n}\n\nexport default NewGroup\n\n```" } ]
code_collections_2794eeef
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/NewGroupButton/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\nimport Button from '@vtex/styleguide/lib/Button'\nimport AddIcon from './AddIcon'\nimport config from 'vtex-tachyons/config.json'\n\nclass NewGroupButon extends PureComponent {\n constructor(props) {\n super(props)\n this.state = { hover: false }\n }\n\n handleMouseEnter = () => {\n this.setState({ hover: true })\n };\n\n handleMouseLeave = () => {\n this.setState({ hover: false })\n };\n render() {\n return (\n <div className=\"tc mt7\">\n <Button\n secondary\n onClick={this.props.onClick}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n >\n <div className=\"flex items-center\">\n <AddIcon\n color={\n this.state.hover ? config.colors.white : config.colors.blue\n }\n />\n {' '}\n <span className=\"ml2\">Add new group</span>\n </div>\n </Button>\n </div>\n )\n }\n}\n\nNewGroupButon.propTypes = {\n onClick: PropTypes.func,\n}\n\nexport default NewGroupButon\n\n```" } ]
code_collections_6fbd0aa9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/NewGroupButton/AddIcon.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport config from 'vtex-tachyons/config.json'\n\nclass AddIcon extends Component {\n render() {\n return (\n <svg\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n x=\"0px\"\n y=\"0px\"\n viewBox=\"0 0 16 16\"\n xmlSpace=\"preserve\"\n width=\"16\"\n height=\"16\"\n >\n <g className=\"nc-icon-wrapper\" fill={this.props.color}>\n <circle\n fill=\"none\"\n stroke={this.props.color}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeMiterlimit=\"10\"\n cx=\"8.5\"\n cy=\"8.5\"\n r=\"7\"\n />\n {' '}\n <line\n data-color=\"color-2\"\n fill=\"none\"\n stroke={this.props.color}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeMiterlimit=\"10\"\n x1=\"8.5\"\n y1=\"4.5\"\n x2=\"8.5\"\n y2=\"12.5\"\n />\n <line\n data-color=\"color-2\"\n fill=\"none\"\n stroke={this.props.color}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeMiterlimit=\"10\"\n x1=\"4.5\"\n y1=\"8.5\"\n x2=\"12.5\"\n y2=\"8.5\"\n />\n </g>\n </svg>\n )\n }\n}\n\nAddIcon.defaultProps = {\n color: config.colors.blue,\n}\n\nAddIcon.propTypes = {\n color: PropTypes.string.isRequired,\n width: PropTypes.number,\n height: PropTypes.number,\n}\n\nexport default AddIcon\n\n```" } ]
code_collections_5ace940e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/DynamicGroup/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport Button from '@vtex/styleguide/lib/Button'\nimport Card from '../Card'\nimport CategoryAutocomplete from './CategoryAutocomplete'\nimport BrandAutocomplete from './BrandAutocomplete'\n\nclass DynamicGroup extends Component {\n constructor(props) {\n super(props)\n\n this.state = { ...this.mapPropsToState(props) }\n }\n\n componentWillReceiveProps(nextProps) {\n this.setState({ ...this.mapPropsToState(nextProps) })\n }\n\n mapPropsToState(props) {\n return {\n name: props.name,\n brands: props.brands,\n categories: props.categories,\n }\n }\n\n handleChangeName = e => {\n this.setState({ name: e.target.value })\n };\n\n handleChangeCategories = categories => {\n this.setState({ categories })\n };\n\n handleChangeBrands = brands => {\n this.setState({ brands })\n };\n\n render() {\n return (\n <Card>\n <div>\n <div className=\"f3 fw7 w-50\">\n <input\n className=\"w-auto bn f3 fw7 near-black\"\n type=\"text\"\n placeholder=\"Name your collection\"\n value={this.state.name}\n style={{ width: '10em' }}\n onChange={this.handleChangeName}\n />\n </div>\n\n <div className=\"w-100 pt7\">\n <div className=\"f6 pb3\">\n Include products from the following brands:\n </div>\n <BrandAutocomplete\n values={this.state.brands}\n onChange={this.handleChangeBrands}\n />\n </div>\n\n <div className=\"w-100 pt5\">\n <div className=\"f6 pb3\">\n Include products from the following categories:\n </div>\n <CategoryAutocomplete\n values={this.state.categories}\n onChange={this.handleChangeCategories}\n />\n </div>\n\n <div>\n <div className=\"pt6 nl5\">\n <Button>Save group</Button>\n <Button>Cancel</Button>\n </div>\n </div>\n </div>\n </Card>\n )\n }\n}\n\nDynamicGroup.propTypes = {\n collectionId: PropTypes.string,\n name: PropTypes.string,\n categories: PropTypes.arrayOf(PropTypes.number),\n brands: PropTypes.arrayOf(PropTypes.number),\n onSave: PropTypes.func.isRequired,\n}\n\nexport default DynamicGroup\n\n```" } ]
code_collections_3f217a7b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/ManualGroup/Items/SearchCollectionSkus.gql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\n#import './ProductInfoFragment.gql'\n\nquery SearchCollectionSkus(\n $ids: [Int],\n) {\n products: getProductsBySku(\n ids: $ids,\n from: 0,\n to: 9,\n ) {\n items {\n ...ProductInfo\n }\n }\n}\n\n```" } ]
code_collections_f1fee7ae
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/ManualGroup/Items/IconArrowDown.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport config from 'vtex-tachyons/config.json'\n\nclass IconArrowDown extends Component {\n render() {\n return (\n <svg\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n x=\"0px\"\n y=\"0px\"\n viewBox=\"0 0 16 16\"\n xmlSpace=\"preserve\"\n width={this.props.width}\n height={this.props.height}\n >\n <g className=\"nc-icon-wrapper\" fill=\"#368df7\">\n <polygon\n fill={this.props.fill}\n points=\"8,11.4 2.6,6 4,4.6 8,8.6 12,4.6 13.4,6 \"\n />\n </g>\n </svg>\n )\n }\n}\n\nIconArrowDown.defaultProps = {\n fill: config.colors.blue,\n}\n\nIconArrowDown.propTypes = {\n fill: PropTypes.string,\n width: PropTypes.number,\n height: PropTypes.number,\n}\n\nexport default IconArrowDown\n\n```" } ]
code_collections_017e1ac8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/ManualGroup/Items/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport { graphql, compose } from 'react-apollo'\n\nimport SearchProducts from './SearchProducts.gql'\nimport SearchCollectionSkus from './SearchCollectionSkus.gql'\nimport CollectionContains from './CollectionContains.gql'\n\nimport Search from './Search'\nimport Result from './Result/index'\nimport Pagination from '../../Pagination/index'\n\nimport EmptyCollection from '../../EmptyStates/EmptyCollection'\nimport EmptySearch from '../../EmptyStates/EmptySearch'\nimport Loading from '../../Loading'\n\nclass Items extends Component {\n getCurrentPage() {\n return this.hasData()\n ? this.props.query\n ? this.props.search.products.paging.pages\n : Math.ceil(this.props.queryFrom / 10) + 1\n : 1\n }\n\n getPages() {\n return this.hasData()\n ? this.props.query\n ? this.props.search.products.paging.pages\n : Math.ceil(this.props.skus.length / 10) === 0\n ? 1\n : Math.ceil(this.props.skus.length / 10)\n : Infinity\n }\n\n getFrom() {\n return this.hasData()\n ? this.props.query\n ? this.props.search.products.paging._from\n : this.props.queryFrom\n : null\n }\n\n getTo() {\n return this.hasData()\n ? this.props.query\n ? this.props.search.products.paging._to\n : this.props.queryTo\n : null\n }\n\n hasData() {\n return (this.props.query && !this.props.search.loading) ||\n (!this.props.query && !this.props.collection.loading)\n }\n\n handleChangeSearch = e => {\n const query = e.target.value\n const newState = { query, queryFrom: 0, queryTo: 9 }\n this.props.onChange(newState)\n };\n\n handleChangePage = (page, from, to) => {\n this.props.onChange({ currentPage: page, queryFrom: from, queryTo: to })\n };\n\n render() {\n return (\n <div>\n <div className=\"flex items-end w-100 justify-between pt6\">\n <div className=\"flex-auto\">\n <Search\n value={this.props.query}\n placeholder=\"Search by product or sku name…\"\n onChange={this.handleChangeSearch}\n />\n </div>\n <div className=\"ml4\">\n <Pagination\n pages={this.getPages()}\n from={this.getFrom()}\n to={this.getTo()}\n currentPage={this.getCurrentPage()}\n onChange={this.handleChangePage}\n />\n </div>\n </div>\n <div className=\"pt6\">\n {this.props.query\n ? this.props.search.loading\n ? <div className=\"flex flex-column items-center pa10\">\n <Loading />\n </div>\n : this.props.search.products.items.length === 0\n ? <EmptySearch />\n : <Result\n isSearch\n products={this.props.search.products.items}\n selectedSkus={this.props.skus}\n onChange={this.props.onChangeSkus}\n />\n : this.props.collection.loading\n ? <div className=\"flex flex-column items-center pa10\">\n <Loading />\n </div>\n : this.props.skus.length === 0\n ? <EmptyCollection />\n : <Result\n isCollection\n products={this.props.collection.products.items}\n selectedSkus={this.props.skus}\n onChange={this.props.onChangeSkus}\n />}\n </div>\n </div>\n )\n }\n}\n\nItems.defaultProps = {\n skus: [],\n}\n\nItems.propTypes = {\n currentPage: PropTypes.number.isRequired,\n query: PropTypes.string,\n queryFrom: PropTypes.number.isRequired,\n queryTo: PropTypes.number.isRequired,\n collection: PropTypes.object,\n skus: PropTypes.array.isRequired,\n contains: PropTypes.object,\n search: PropTypes.object,\n onChangeSkus: PropTypes.func.isRequired,\n onChange: PropTypes.func.isRequired,\n}\n\nconst ItemsContainer = compose(\n graphql(SearchProducts, {\n name: 'search',\n options(\n {\n query = '',\n queryFrom = 0,\n queryTo = 9,\n }\n ) {\n return {\n variables: {\n query,\n queryFrom,\n queryTo,\n },\n }\n },\n }),\n graphql(CollectionContains, {\n name: 'contains',\n options({ collectionId, search }) {\n return {\n variables: {\n collectionId,\n skus: search.loading\n ? []\n : search.products.items.reduce(\n (acc, product) =>\n product.items.reduce(\n (skuIds, sku) =>\n skuIds.concat({ id: parseInt(sku.itemId) }),\n acc\n ),\n []\n ),\n },\n }\n },\n }),\n graphql(SearchCollectionSkus, {\n name: 'collection',\n options({ skus = [], queryFrom, queryTo }) {\n return {\n variables: {\n ids: skus.slice(queryFrom, queryTo),\n },\n }\n },\n })\n)(Items)\n\nexport default ItemsContainer\n\n```" } ]
code_collections_d191c088
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/ManualGroup/Items/IconArrowUp.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport config from 'vtex-tachyons/config.json'\n\nclass IconArrowUp extends Component {\n render() {\n return (\n <svg\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n x=\"0px\"\n y=\"0px\"\n viewBox=\"0 0 16 16\"\n xmlSpace=\"preserve\"\n width={this.props.width}\n height={this.props.height}\n >\n <g className=\"nc-icon-wrapper\" fill=\"#368df7\">\n <polygon\n fill={this.props.fill}\n points=\"12,11.4 8,7.4 4,11.4 2.6,10 8,4.6 13.4,10 \"\n />\n </g>\n </svg>\n )\n }\n}\n\nIconArrowUp.defaultProps = {\n fill: config.colors.blue,\n}\n\nIconArrowUp.propTypes = {\n fill: PropTypes.string,\n width: PropTypes.number,\n height: PropTypes.number,\n}\n\nexport default IconArrowUp\n\n```" } ]
code_collections_1e83aa9c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/ManualGroup/Items/Search.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\n\nclass Search extends Component {\n render() {\n return (\n <div className=\"\">\n <label htmlFor=\"search\" className=\"f7 fw3\">Search</label>\n <div className=\"pt3 flex flex-auto\">\n <input placeholder={this.props.placeholder} id=\"search\" value={this.props.value} onChange={this.props.onChange} className=\"flex flex-auto ba b--light-gray bw1 pa4 f6 br2 ma0 border-box outline-0 near-black bg-white\" />\n </div>\n </div>\n )\n }\n}\n\nSearch.propTypes = {\n value: PropTypes.string,\n placeholder: PropTypes.string,\n onChange: PropTypes.func.isRequired,\n}\n\nexport default Search\n\n```" } ]
code_collections_72957d60
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/ManualGroup/Items/ProductInfoFragment.gql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nfragment ProductInfo on Product @context(provider: \"vtex.collections\") {\n productId\n productName\n productReference\n items {\n images {\n imageUrl\n }\n itemId\n name\n nameComplete\n complementName\n referenceId {\n Key\n Value\n }\n }\n}\n\n```" } ]
code_collections_deb44c4e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/ManualGroup/Items/SearchProducts.gql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\n#import './ProductInfoFragment.gql'\n\nquery SearchProducts(\n $query: String,\n $queryFrom: Int,\n $queryTo: Int,\n) {\n products: getProducts(\n query: $query,\n from: $queryFrom,\n to: $queryTo,\n ) {\n items {\n ...ProductInfo\n }\n paging {\n pages\n perPage\n total\n page\n _to\n _from\n }\n }\n}\n\n```" } ]
code_collections_8e46ef76
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/ManualGroup/Items/CollectionContains.gql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery CollectionContains(\n $collectionId: Int\n $skus: [SkuContainsInput]\n) {\n collectionContains(\n collectionId: $collectionId\n skus: $skus\n ) {\n skus {\n id\n contains\n }\n }\n}\n\n```" } ]
code_collections_c9f42f39
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/ManualGroup/Items/Result/Sku.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport Checkbox from '../../../Checkbox'\n\nclass Sku extends Component {\n handleChange = () => {\n this.props.onChange({\n skuId: this.props.sku.itemId,\n checked: !this.props.inCollection,\n })\n };\n\n render() {\n const { sku, inCollection } = this.props\n\n return (\n <div className=\"flex items-center\" style={{ paddingLeft: '3.75rem' }}>\n <Checkbox checked={inCollection} onChange={this.handleChange} />\n <div\n className=\"bl br b--light-gray ph4 pv5 flex items-center f6 flex-grow-1 justify-between bg-near-white\"\n >\n <div className=\"flex items-center\">\n <div className=\"ml2\">{sku.nameComplete}</div>\n </div>\n <div className=\"flex items-center fw3 justify-end pr7 f6\">\n <div className=\"tl pr9\">REF: {sku.referenceId[0].Value}</div>\n <div className=\"tl\">ID: {sku.itemId}</div>\n </div>\n </div>\n </div>\n )\n }\n}\n\nSku.propTypes = {\n sku: PropTypes.object.isRequired,\n inCollection: PropTypes.bool.isRequired,\n onChange: PropTypes.func.isRequired,\n}\n\nexport default Sku\n\n```" } ]
code_collections_5dad23b1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/ManualGroup/Items/Result/IconArrowDown.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport config from 'vtex-tachyons/config.json'\n\nclass IconArrowDown extends Component {\n render() {\n return (\n <svg\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n x=\"0px\"\n y=\"0px\"\n viewBox=\"0 0 16 16\"\n xmlSpace=\"preserve\"\n width={this.props.width}\n height={this.props.height}\n >\n <g className=\"nc-icon-wrapper\" fill=\"#368df7\">\n <polygon\n fill={this.props.fill}\n points=\"8,11.4 2.6,6 4,4.6 8,8.6 12,4.6 13.4,6 \"\n />\n </g>\n </svg>\n )\n }\n}\n\nIconArrowDown.defaultProps = {\n fill: config.colors.blue,\n}\n\nIconArrowDown.propTypes = {\n fill: PropTypes.string,\n width: PropTypes.number,\n height: PropTypes.number,\n}\n\nexport default IconArrowDown\n\n```" } ]
code_collections_02aab1f1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/ManualGroup/Items/Result/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport Product from './Product'\n\nclass Result extends Component {\n render() {\n const {\n selectedSkus,\n products,\n onChange,\n } = this.props\n\n return (\n <div>\n {products.map(product => {\n const productSelectedSkus = selectedSkus.filter(\n skuId =>\n product.items.find(\n item => parseInt(item.itemId) === parseInt(skuId)\n )\n )\n\n return (\n <Product\n key={\n `${product.productId}-${JSON.stringify(productSelectedSkus) || ''}`\n }\n product={product}\n selectedSkus={productSelectedSkus}\n onChange={onChange}\n />\n )\n })}\n </div>\n )\n }\n}\n\nResult.propTypes = {\n selectedSkus: PropTypes.array,\n products: PropTypes.array.isRequired,\n onChange: PropTypes.func.isRequired,\n}\n\nexport default Result\n\n```" } ]
code_collections_a8b31d93
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/ManualGroup/Items/Result/IconArrowUp.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport config from 'vtex-tachyons/config.json'\n\nclass IconArrowUp extends Component {\n render() {\n return (\n <svg\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n x=\"0px\"\n y=\"0px\"\n viewBox=\"0 0 16 16\"\n xmlSpace=\"preserve\"\n width={this.props.width}\n height={this.props.height}\n >\n <g className=\"nc-icon-wrapper\" fill=\"#368df7\">\n <polygon\n fill={this.props.fill}\n points=\"12,11.4 8,7.4 4,11.4 2.6,10 8,4.6 13.4,10 \"\n />\n </g>\n </svg>\n )\n }\n}\n\nIconArrowUp.defaultProps = {\n fill: config.colors.blue,\n}\n\nIconArrowUp.propTypes = {\n fill: PropTypes.string,\n width: PropTypes.number,\n height: PropTypes.number,\n}\n\nexport default IconArrowUp\n\n```" } ]
code_collections_b8057306
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/ManualGroup/Items/Result/Product.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component, Fragment } from 'react'\nimport PropTypes from 'prop-types'\nimport filter from 'lodash/filter'\n\nimport IconArrowDown from './IconArrowDown'\nimport IconArrowUp from './IconArrowUp'\nimport Sku from './Sku'\nimport Checkbox from '../../../Checkbox'\n\nclass Product extends Component {\n constructor(props) {\n super(props)\n\n this.state = {\n open: false,\n allSkusChecked: this.areAllSkusSelected(props),\n hasOneChecked: this.hasOneChecked(props),\n }\n }\n\n componentWillReceiveProps(nextProps) {\n this.setState({\n allSkusChecked: this.areAllSkusSelected(nextProps),\n hasOneChecked: this.hasOneChecked(nextProps),\n })\n }\n\n areAllSkusSelected = props => {\n return props.selectedSkus.length === props.product.items.length\n };\n\n hasOneChecked = props => {\n return props.selectedSkus.length > 0\n };\n\n handleClickArrow = () => {\n this.setState(prevState => ({ open: !prevState.open }))\n };\n\n handleChangeSkuSelection = ({ skuId, checked }) => {\n this.props.onChange([{ skuId, checked }])\n };\n\n handleChangeProductSelection = () => {\n this.props.onChange(\n this.props.product.items.map(item => ({\n skuId: item.itemId,\n checked: !this.state.allSkusChecked,\n }))\n )\n };\n\n render() {\n const { product, productState, selectedSkus } = this.props\n const { open, allSkusChecked, hasOneChecked } = this.state\n\n return (\n <Fragment>\n <div className=\"flex items-center\">\n <Checkbox\n checked={allSkusChecked}\n semiChecked={hasOneChecked}\n onChange={this.handleChangeProductSelection}\n />\n <div\n className={\n `bt bl bb br b--light-gray pa4 flex items-center f6 flex-grow-1 justify-between relative ${open ? 'bg-near-white' : ''}`\n }\n >\n <div className=\"flex items-center\">\n <img\n src={product.items[0].images[0].imageUrl}\n style={{ width: '3rem', height: '3rem' }}\n />\n <div className=\"ml5\">{product.productName}</div>\n </div>\n <div className=\"flex items-center fw3 justify-end pr7 f6\">\n <div className=\"tl pr9\">REF: {product.productReference}</div>\n <div className=\"tl\">ID: {product.productId}</div>\n </div>\n <button\n className=\"bg-serious-black pa2 br-100 absolute flex items-center bn pointer dim\"\n style={{ right: '-0.75rem' }}\n onClick={this.handleClickArrow}\n >\n {open\n ? <IconArrowUp fill=\"#FFFFFF\" width={14} height={14} />\n : <IconArrowDown fill=\"#FFFFFF\" width={14} height={14} />}\n </button>\n </div>\n </div>\n {open\n ? product.items.map(item => (\n <Sku\n key={item.itemId}\n sku={item}\n onChange={this.handleChangeSkuSelection}\n inCollection={selectedSkus.includes(item.itemId) || selectedSkus.includes(parseInt(item.itemId))}\n />\n ))\n : null}\n </Fragment>\n )\n }\n}\n\nProduct.defaultProps = {\n selectedSkus: [],\n}\n\nProduct.propTypes = {\n product: PropTypes.object.isRequired,\n selectedSkus: PropTypes.array.isRequired,\n onChange: PropTypes.func.isRequired,\n}\n\nexport default Product\n\n```" } ]
code_collections_81970c8c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/DynamicGroup/CategoryAutocomplete/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport { graphql } from 'react-apollo'\nimport createAutocomplete from '../../Autocomplete'\nimport CategoryName from './CategoryName.graphql'\nimport CategoriesAutocomplete from './CategoriesAutocomplete.graphql'\n\nconst CategoryAutocomplete = createAutocomplete({\n graphql: {\n suggestion: graphql(CategoriesAutocomplete, {\n options({ inputValue = '' }) {\n return {\n variables: {\n name: inputValue,\n },\n }\n },\n }),\n name: graphql(CategoryName, {\n options({ values }) {\n return {\n variables: {\n categories: values,\n },\n }\n },\n }),\n },\n})\n\nexport default CategoryAutocomplete\n\n```" } ]
code_collections_31dfe07c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/DynamicGroup/CategoryAutocomplete/CategoriesAutocomplete.graphql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery CategoriesAutocomplete(\n $name: String!\n) {\n suggestions: categoriesAutocomplete(name: $name) {\n id,\n name\n }\n}\n\n```" } ]
code_collections_3bd52a10
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/DynamicGroup/CategoryAutocomplete/CategoryName.graphql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery CategoryName(\n $categories: [Int]\n) {\n names: getCategories(\n ids: $categories\n ) {\n id\n name\n }\n}\n\n```" } ]
code_collections_a7884cbd
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/DynamicGroup/BrandAutocomplete/BrandsAutocomplete.graphql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery BrandsAutocomplete(\n $name: String!\n) {\n suggestions: brandsAutocomplete(name: $name) {\n id,\n name\n }\n}\n\n```" } ]
code_collections_90d46847
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/DynamicGroup/BrandAutocomplete/index.js from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport { graphql } from 'react-apollo'\nimport createAutocomplete from '../../Autocomplete'\nimport BrandName from './BrandName.graphql'\nimport BrandsAutocomplete from './BrandsAutocomplete.graphql'\n\nconst BrandAutocomplete = createAutocomplete({\n graphql: {\n suggestion: graphql(BrandsAutocomplete, {\n options({ inputValue = '' }) {\n return {\n variables: {\n name: inputValue,\n },\n }\n },\n }),\n name: graphql(BrandName, {\n options({ values }) {\n return {\n variables: {\n brands: values,\n },\n }\n },\n }),\n },\n})\n\nexport default BrandAutocomplete\n\n```" } ]
code_collections_c46b9023
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of collections/react/components/DynamicGroup/BrandAutocomplete/BrandName.graphql from the collections VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery BrandName(\n $brands: [Int]\n) {\n names: getBrands(\n ids: $brands\n ) {\n id\n name\n }\n}\n\n```" } ]
code_checkout-ui-settings_601a5206
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-ui-settings/checkout-ui-custom/checkout5-custom.css from the checkout-ui-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n/* /files/checkout5-custom.css */\n\n/* Displays the option to enter a foreign document */\n.document-box { display: block; }\n\n/* Displays the option to enter an international phone */\n.phone-box { display: block; }\n\n```" } ]
code_checkout-ui-settings_25752029
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-ui-settings/checkout-ui-custom/checkout6-custom.js from the checkout-ui-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\n// WARNING: THE USAGE OF CUSTOM SCRIPTS IS NOT SUPPORTED. VTEX IS NOT LIABLE FOR ANY DAMAGES THIS MAY CAUSE. THIS MAY BREAK YOUR STORE AND STOP SALES. IN CASE OF ERRORS, PLEASE DELETE THE CONTENT OF THIS SCRIPT.\n\n```" } ]
code_checkout-ui-settings_3c143045
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-ui-settings/checkout-ui-custom/checkout-confirmation-custom.js from the checkout-ui-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\n// WARNING: THE USAGE OF CUSTOM SCRIPTS IS NOT SUPPORTED. VTEX IS NOT LIABLE FOR ANY DAMAGES THIS MAY CAUSE.\n// THIS MAY BREAK YOUR STORE AND STOP SALES. IN CASE OF ERRORS, PLEASE DELETE THE CONTENT OF THIS SCRIPT.\n\n```" } ]
code_checkout-ui-settings_e6004918
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-ui-settings/checkout-ui-custom/checkout5-custom.js from the checkout-ui-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\n// WARNING: THE USAGE OF CUSTOM SCRIPTS IS NOT SUPPORTED. VTEX IS NOT LIABLE FOR ANY DAMAGES THIS MAY CAUSE. THIS MAY BREAK YOUR STORE AND STOP SALES. IN CASE OF ERRORS, PLEASE DELETE THE CONTENT OF THIS SCRIPT.\n\n```" } ]
code_checkout-ui-settings_9321b7de
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-ui-settings/checkout-ui-custom/checkout6-custom.css from the checkout-ui-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n/* Content copied from \"checkout5-custom.css\" at 2019-03-01T05:12:59.334Z */\n\n/* /files/checkout5-custom.css */\n\n/* Displays the option to enter a foreign document */\n.document-box { display: block; }\n\n/* Displays the option to enter an international phone */\n.phone-box { display: block; }\n\n```" } ]
code_checkout-ui-settings_0299d871
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-ui-settings/docs/README.md from the checkout-ui-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Checkout UI Settings\n\nThe Checkout UI Settings app is responsible for **customizing your store's Checkout UI through scripts**.\n\nThe main advantage of using the app instead of the [store's admin](https://help.vtex.com/tutorial/configure-template-in-smartcheckout-update--ToTE5XB39t0SwtHgpgwSv?locale=en) for this customization is that your Checkout scripts will behave as configurations for platform apps.\n\nIn practice, it means that Checkout UI Settings allows A/B testing in your store's scripts, in addition to the possibility of quick rollbacks for old scripts (i.e. scripts pertaining to older Checkout UI Settings app's versions).\n\n## Configuration\n\n1. Using your terminal and the [VTEX IO Toolbelt](https://vtex.io/docs/recipes/development/vtex-io-cli-installment-and-command-reference), log into the desired account;\n2. Run `vtex list` to access the list of apps that are already installed on the account you're working on. If the Checkout UI Settings option already exists, you can skip to step 7 of this step-by-step;\n3. If the Checkout UI Settings app was not found in the list of installed apps, run the `vtex init` command;\n4. Select the `checkout-ui-settings` option;\n5. Open the `checkout-ui-settings` app in whichever code editor you prefer;\n6. In the `manifest.json` file, change the predefined default value `vendor` to the name of the account in which you want to install the app;\n7. In the `checkout-ui-custom` folder, create the files in which the scripts will be included, just as you would do in the [admin's interface](https://help.vtex.com/tutorial/configure-template-in-smartcheckout-update--ToTE5XB39t0SwtHgpgwSv?locale=en#configure-code). Notice that a few defaults files already exist in the `checkout-ui-custom` folder, files which you can use to insert the scripts;\n8. According to the Checkout customization you are looking for, open the most suitable file and insert the desired scripts;\n9. Save your changes. Then, [publish](https://vtex.io/docs/recipes/development/publishing-an-app) the app's new version;\n10. Still logged into the desired account, [create a production workspace](https://vtex.io/docs/recipes/development/creating-a-production-workspace) and [install the app](https://vtex.io/docs/recipes/development/installing-an-app);\n10. If everything is working as expected, [promote the workspace to master](https://vtex.io/docs/recipes/development/promoting-a-workspace-to-master).\n\n## Modus Operandi \n\nOnce the app is deployed and installed in the account, every scripts contained in it will be automatically linked to your store and used to [build the templates](https://help.vtex.com/tutorial/configure-template-in-smartcheckout-update--ToTE5XB39t0SwtHgpgwSv?locale=en#configuring-templates-from-the-code-menu) to customize your Checkout.\n\n\n:warning: **Scripts used by Checkout are linked to the Checkout UI Settings version that's installed in your store**. If a prior app version was already installed and your want to change the scripts linked to it, you'll need to repeat the already existing code and thereafter launch the app's new version containing the changes you just did. Housekeeper is responsible for updating app versions in the accounts it's installed in.\n\n```" } ]
code_store-indexer_fb8d9086
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-indexer/docs/README.md from the store-indexer VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Store Indexer\n\nThe Store Indexer is a VTEX IO app designed to listen to IO broadcasters and index data based on catalog changes. It enhances your store’s catalog indexing and search functionality by responding to system events and automating key tasks:\n\n\n\n- **Translations:** Updates translations whenever translatable fields set as messages are modified.\n\n- **Route management:** Updates internal routes by saving the correct page type and canonical route ID, and flags deactivated products as \"not found\".\n\n\n- **Search indexing:**Indexes the canonical URLs of top searches.\n\n- **Brand search as full text:** Enhances [Intelligent Search](https://help.vtex.com/pt/tracks/vtex-intelligent-search--19wrbB7nEQcmwzDPl1l4Cb) by resolving brand search queries as full text. This configuration enables search results to include products where the brand name appears in fields like the product title or description, rather than limiting results to a brand filter. For detailed instructions, refer to [Setting up brand search queries as full text](https://developers.vtex.com/docs/guides/setting-up-brand-search-queries-as-full-text).\n\n## Manual event testing\n\nSince the Store Indexer is not part of the store's rendering pipeline, testing can be complex. This section outlines how to manually generate an event from the broadcasting system to facilitate testing.\n\n> The example below focuses on testing the product pipeline. Extending it to test other pipelines follows a similar approach.\n\n### Step 1: Retrieving the event body\n\nUse **catalog-graphql** to fetch the body of the event. The following `curl` command retrieves the necessary data:\n\n```sh\ncurl --location --request POST 'https://app.io.vtex.com/vtex.catalog-graphql/v1/{account}/{workspace}/_v/graphql' \\\n--header 'Authorization: {auth}' \\\n--header 'x-vtex-locale: {locale}' \\\n--header 'x-vtex-tenant: {locale}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n\t\"query\": \"query GetProduct ($identifier: ProductUniqueIdentifier!) { product (identifier: $identifier) { id brandId categoryId departmentId name linkId refId isVisible description shortDescription releaseDate keywords title isActive taxCode metaTagDescription supplierId showWithoutStock score salesChannel { id } }}\",\n\t\"variables\": {\n\t\t\"identifier\": {\n \t\t\"field\": \"id\",\n \t\t\"value\": {productId}\n\t\t}\n\t}\n}'\n```\n\n### Step 2: Triggering an event for Store Indexer\n\nAfter retrieving the event body, copy the value of the `product` key from the response. Use this data to create an event for the **Store Indexer**. Here's an example `curl` command with a mocked product:\n\n```sh\ncurl --location --request POST 'https://app.io.vtex.com/vtex.store-indexer/v0/{account}/{workspace}/_events' \\\n--header 'Authorization: {auth}' \\\n--header 'x-event-handler-id: broadcasterProduct' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n \"id\": \"2000185\",\n \"brandId\": \"2000010\",\n \"categoryId\": \"48\",\n \"departmentId\": \"25\",\n \"name\": \"Jumper Best Friend\",\n \"linkId\": \"jumper-best-friend\",\n \"refId\": \"\",\n \"isVisible\": true,\n \"description\": \"\",\n \"shortDescription\": \"\",\n \"releaseDate\": \"2019-11-19T00:00:00\",\n \"keywords\": [\n \"Hoodie\",\n \"Best\",\n \"Friend\",\n \"blouse\",\n \"t-shirt\",\n \"jumper\"\n ],\n \"title\": \"Jumper Best Friend\",\n \"isActive\": true,\n \"taxCode\": \"\",\n \"metaTagDescription\": \"\",\n \"supplierId\": null,\n \"showWithoutStock\": true,\n \"score\": null,\n \"salesChannel\": [\n {\n \"id\": \"1\"\n }\n ]\n}'\n```\n\n```" } ]
code_store-indexer_71b0ef7e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-indexer/node/service.json from the store-indexer VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"memory\": 256,\n \"ttl\": 10,\n \"timeout\": 2,\n \"minReplicas\": 2,\n \"maxReplicas\": 4,\n \"workers\": 1,\n \"events\": {\n \"broadcasterProduct\": {\n \"keys\": [\"broadcaster.product\"]\n },\n \"broadcasterBrand\": {\n \"keys\": [\"broadcaster.brand\"]\n },\n \"broadcasterCategory\": {\n \"keys\": [\"broadcaster.category\"]\n },\n \"searchUrlsCountIndex\": {\n \"sender\": \"vtex.search-graphql\",\n \"keys\": [\"searchUrlsCountIndex\"]\n }\n }\n}\n\n```" } ]
code_store-indexer_a67a3036
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-indexer/node/package.json from the store-indexer VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"crypto\": \"^1.0.1\",\n \"koa-compose\": \"^4.0.0\",\n \"ramda\": \"^0.26.1\",\n \"route-parser\": \"^0.0.5\"\n },\n \"devDependencies\": {\n \"@types/koa-compose\": \"^3.2.0\",\n \"@types/node\": \"^12.12.17\",\n \"@types/ramda\": \"^0.26.38\",\n \"@types/route-parser\": \"^0.1.3\",\n \"@vtex/api\": \"6.48.0\",\n \"tslint\": \"^5.14.0\",\n \"tslint-config-vtex\": \"^2.1.0\",\n \"typescript\": \"3.9.7\",\n \"vtex.catalog-api-proxy\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.catalog-api-proxy@0.9.0/public/_types/react\",\n \"vtex.catalog-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.catalog-graphql@1.79.2/public/@types/vtex.catalog-graphql\",\n \"vtex.messages\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.messages@1.60.2/public/@types/vtex.messages\",\n \"vtex.rewriter\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.rewriter@1.45.2/public/@types/vtex.rewriter\",\n \"vtex.search-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.search-graphql@0.27.2/public/_types/react\",\n \"vtex.store-indexer\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-indexer@0.15.2/public/_types/react\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty && tslint -c tslint.json --fix './**/*.ts'\"\n },\n \"version\": \"0.18.0\"\n}\n\n```" } ]
code_store-indexer_4882447c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-indexer/node/index.ts from the store-indexer VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {\n Cached,\n ClientsConfig,\n LRUCache,\n ParamsContext,\n Service,\n} from '@vtex/api'\n\nimport { Clients } from './clients'\nimport { brandInternals } from './middlewares/internals/brand'\nimport { categoryInternals } from './middlewares/internals/category'\nimport { deleteOldRoutes } from './middlewares/internals/delete'\nimport { productInternals } from './middlewares/internals/product'\nimport { saveInternals } from './middlewares/internals/save'\nimport { createCanonicals } from './middlewares/search/createCanonicals'\nimport { getSearchStats } from './middlewares/search/getSearchStats'\nimport { indexCanonicals } from './middlewares/search/indexCanonicals'\nimport { settings } from './middlewares/settings'\nimport { tenant } from './middlewares/tenant'\nimport { throttle } from './middlewares/throttle'\nimport { State } from './typings/global'\n\nconst TIMEOUT_MS = 3000\nconst TRANSLATION_CONCURRENCY = 10\nconst TRANSLATION_RETRIES = 3\nconst CONCURRENCY = 10\n\nconst tenantCacheStorage = new LRUCache<string, Cached>({\n max: 3000,\n})\n\nconst appsCacheStorage = new LRUCache<string, Cached>({\n max: 3000,\n})\n\nmetrics.trackCache('tenant', tenantCacheStorage)\nmetrics.trackCache('apps', appsCacheStorage)\n\nconst clients: ClientsConfig<Clients> = {\n implementation: Clients,\n options: {\n apps: {\n memoryCache: appsCacheStorage,\n },\n default: {\n concurrency: CONCURRENCY,\n retries: 2,\n timeout: TIMEOUT_MS,\n },\n messages: {\n concurrency: TRANSLATION_CONCURRENCY,\n retries: TRANSLATION_RETRIES,\n timeout: TIMEOUT_MS,\n },\n tenant: {\n memoryCache: tenantCacheStorage,\n timeout: TIMEOUT_MS,\n },\n },\n}\n\nexport default new Service<Clients, State, ParamsContext>({\n clients,\n events: {\n broadcasterBrand: [\n throttle,\n settings,\n tenant,\n brandInternals,\n saveInternals,\n deleteOldRoutes,\n ],\n broadcasterCategory: [\n throttle,\n settings,\n tenant,\n categoryInternals,\n saveInternals,\n deleteOldRoutes,\n ],\n broadcasterProduct: [\n throttle,\n settings,\n tenant,\n productInternals,\n saveInternals,\n deleteOldRoutes,\n ],\n searchUrlsCountIndex: [\n throttle,\n settings,\n getSearchStats,\n tenant,\n createCanonicals,\n indexCanonicals,\n ],\n },\n})\n\n```" } ]
code_store-indexer_9da8cd2e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-indexer/node/clients/messages.ts from the store-indexer VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { MessagesGraphQL } from '@vtex/api'\nimport { Query, TranslateArgs } from 'vtex.messages'\n\ninterface Response {\n translate: Query['translate']\n}\n\ninterface Variables {\n args: TranslateArgs\n}\n\nexport class Messages extends MessagesGraphQL {\n public async translateNoCache(args: TranslateArgs) {\n const response = await this.graphql.query<Response, Variables>(\n {\n query: `query Translate($args: TranslateArgs!) {\n translate(args: $args)\n }`,\n variables: { args },\n },\n {\n headers: {\n 'cache-control': 'no-cache',\n },\n metric: 'messages-translate-v2',\n }\n )\n return response.data!.translate as string[]\n }\n}\n\n```" } ]
code_store-indexer_5bce679d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-indexer/node/clients/rewriter.ts from the store-indexer VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { AppGraphQLClient, InstanceOptions, IOContext } from '@vtex/api'\nimport {\n EntityLocator,\n Internal,\n InternalInput,\n RedirectInput,\n RouteLocator,\n RoutesByBinding,\n} from 'vtex.rewriter'\n\nconst rewriterSaveManyInternalMutation = `mutation SaveMany($routes: [InternalInput!]!) {\n internal {\n saveMany(routes: $routes)\n }\n}`\n\nconst rewriterSaveInternalMutation = `mutation Save($route: InternalInput!) {\n internal {\n save(route: $route) {\n type\n }\n }\n}`\n\nconst rewriterSaveRedirectMutation = `mutation Save($route: RedirectInput!) {\n redirect {\n save(route: $route) {\n type\n }\n }\n}`\n\nconst rewriterGetInternal = `query Internal($path: String!) {\n internal {\n get(path: $path) {\n id\n }\n }\n}`\n\nconst rewriterDeleteInternalMutation = `mutation Delete($path: String!, $locator: RouteLocator) {\n internal {\n delete(path: $path, locator: $locator) {\n id\n }\n }\n}`\n\nconst rewriterRoutesById = `query Routes($locator: EntityLocator!) {\n internal {\n routes(locator: $locator) {\n route\n binding\n }\n }\n}\n`\n\nconst rewriterDeleteManyInternalMutation = `mutation DeleteMany($paths: [String!]!, $locators: [RouteLocator!]) {\n internal {\n deleteMany(paths: $paths, locators: $locators)\n }\n}`\n\nexport class Rewriter extends AppGraphQLClient {\n constructor(ctx: IOContext, opts?: InstanceOptions) {\n super('vtex.rewriter@1.x', ctx, opts)\n }\n\n public async saveManyInternals(internals: InternalInput[]) {\n const { tenant } = this.context\n return this.graphql.mutate<boolean, { routes: InternalInput[] }>(\n {\n mutate: rewriterSaveManyInternalMutation,\n variables: { routes: internals },\n },\n {\n headers: {\n ...(this.options && this.options.headers),\n 'Proxy-Authorization': this.context.authToken,\n VtexIdclientAutCookie: this.context.authToken,\n 'x-vtex-tenant': tenant,\n },\n metric: 'rewriter-save-many-internal',\n }\n )\n }\n\n public async saveInternal(internal: InternalInput) {\n const { tenant } = this.context\n return this.graphql.mutate<\n { internal: { type: string } },\n { route: InternalInput }\n >(\n {\n mutate: rewriterSaveInternalMutation,\n variables: { route: internal },\n },\n {\n headers: {\n ...(this.options && this.options.headers),\n 'Proxy-Authorization': this.context.authToken,\n VtexIdclientAutCookie: this.context.authToken,\n 'x-vtex-tenant': tenant,\n },\n metric: 'rewriter-save-internal',\n }\n )\n }\n\n public async saveRedirect(redirect: RedirectInput) {\n const { tenant } = this.context\n return this.graphql.mutate<boolean, { route: RedirectInput }>(\n {\n mutate: rewriterSaveRedirectMutation,\n variables: { route: redirect },\n },\n {\n headers: {\n ...(this.options && this.options.headers),\n 'Proxy-Authorization': this.context.authToken,\n 'x-vtex-tenant': tenant,\n },\n metric: 'rewriter-save-redirect',\n }\n )\n }\n\n public async getInternal(path: string) {\n const { tenant } = this.context\n return this.graphql\n .query<{ internal: { get: Internal } }, { path: string }>(\n {\n query: rewriterGetInternal,\n variables: { path },\n },\n {\n headers: {\n ...(this.options && this.options.headers),\n 'Proxy-Authorization': this.context.authToken,\n 'x-vtex-tenant': tenant,\n },\n metric: 'rewriter-get-internal',\n }\n )\n .then(res => res.data?.internal.get)\n }\n\n public routesById(locator: EntityLocator): Promise<RoutesByBinding[]> {\n return this.graphql\n .query<\n { internal: { routes: RoutesByBinding[] } },\n { locator: EntityLocator }\n >(\n {\n query: rewriterRoutesById,\n variables: { locator },\n },\n {\n metric: 'rewriter-get-routes-by-id',\n }\n )\n .then(res => res.data?.internal?.routes) as Promise<RoutesByBinding[]>\n }\n\n public async deleteInternal(locator: RouteLocator) {\n return this.graphql.mutate<\n { internal: { id: string } },\n { path: string; locator: RouteLocator }\n >(\n {\n mutate: rewriterDeleteInternalMutation,\n variables: { path: locator.from, locator },\n },\n {\n headers: {\n ...(this.options && this.options.headers),\n 'Proxy-Authorization': this.context.authToken,\n VtexIdclientAutCookie: this.context.authToken,\n },\n metric: 'rewriter-delete-internal',\n }\n )\n }\n\n public async deleteManyInternals(locators: RouteLocator[]) {\n const { tenant } = this.context\n const paths = locators.map(locator => locator.from)\n return this.graphql.mutate<\n boolean,\n { locators: RouteLocator[]; paths: string[] }\n >(\n {\n mutate: rewriterDeleteManyInternalMutation,\n variables: { locators, paths },\n },\n {\n headers: {\n ...(this.options && this.options.headers),\n 'Proxy-Authorization': this.context.authToken,\n VtexIdclientAutCookie: this.context.authToken,\n 'x-vtex-tenant': tenant,\n },\n metric: 'rewriter-delete-many-internal',\n }\n )\n }\n}\n\n```" } ]
code_store-indexer_399677a7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-indexer/node/clients/index.ts from the store-indexer VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\n\nimport { Catalog } from './catalog'\nimport { Messages } from './messages'\nimport { Rewriter } from './rewriter'\nimport { SearchGraphql } from './searchGraphql'\n\n/* eslint-disable @typescript-eslint/explicit-member-accessibility */\nexport class Clients extends IOClients {\n get searchGraphql() {\n return this.getOrSet('searchGraphql', SearchGraphql)\n }\n\n get catalog() {\n return this.getOrSet('catalog', Catalog)\n }\n\n get rewriter() {\n return this.getOrSet('rewriter', Rewriter)\n }\n\n get messages() {\n return this.getOrSet('messages', Messages)\n }\n}\n\n```" } ]
code_store-indexer_9ade8845
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-indexer/node/clients/searchGraphql.ts from the store-indexer VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { AppGraphQLClient, InstanceOptions, IOContext } from '@vtex/api'\n\nconst searchUrlsCountQuery = `query SearchURLsCount($limit: Int){\n searchURLsCount(limit: $limit){\n path\n }\n}`\n\nexport class SearchGraphql extends AppGraphQLClient {\n constructor(ctx: IOContext, opts?: InstanceOptions) {\n super('vtex.search-graphql@0.x', ctx, opts)\n }\n\n public async getSearchURLsCount(limit: number) {\n return this.graphql\n .query<any, any>(\n {\n query: searchUrlsCountQuery,\n variables: {\n limit,\n },\n },\n {\n metric: 'search-urls-count',\n }\n )\n .then(({ data: { searchURLsCount } }) => {\n return searchURLsCount\n })\n }\n}\n\n```" } ]
code_store-indexer_7616e2f4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-indexer/node/clients/catalog.ts from the store-indexer VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { AppClient, InstanceOptions, IOContext, RequestConfig } from '@vtex/api'\n\nexport type PageType =\n | 'Category'\n | 'Department'\n | 'Product'\n | 'FullText'\n | 'SubCategory'\n | 'Brand'\n | 'Search'\n | 'NotFound'\n\nexport interface CatalogPageTypeResponse {\n pageType: PageType\n id: string\n url: string\n}\n\nexport interface FieldResponseAPI {\n Name: string\n CategoryId: number | null\n FieldId: number\n IsActive: boolean\n IsRequired: boolean\n FieldTypeId: number\n FieldTypeName: string\n FieldValueId: string | null\n Description: string | null\n IsStockKeepingUnit: boolean\n IsFilter: boolean\n IsOnProductDetails: boolean\n Position: number\n IsWizard: boolean\n IsTopMenuLinkActive: boolean\n IsSideMenuLinkActive: boolean\n DefaultValue: string | null\n FieldGroupId: number\n FieldGroupName: string\n}\n\nexport class Catalog extends AppClient {\n constructor(ctx: IOContext, opts?: InstanceOptions) {\n super('vtex.catalog-api-proxy@0.x', ctx, opts)\n }\n\n public pageType = (path: string, query?: Record<string, string>) =>\n this.get<CatalogPageTypeResponse>(`/pub/portal/pagetype${path}`, {\n headers: {\n ...(this.options && this.options.headers),\n 'Proxy-Authorization': this.context.authToken,\n 'x-vtex-locale': this.context.locale,\n 'x-vtex-tenant': this.context.tenant,\n },\n metric: 'catalog-pagetype',\n params: query,\n })\n\n public getField = (id: number) =>\n this.get<FieldResponseAPI>(`/pub/specification/fieldGet/${id}`, {\n headers: {\n ...(this.options && this.options.headers),\n 'Proxy-Authorization': this.context.authToken,\n 'x-vtex-locale': this.context.locale,\n 'x-vtex-tenant': this.context.tenant,\n },\n metric: 'catalog-get-field-by-id',\n })\n\n private get = <T = any>(url: string, config: RequestConfig = {}) =>\n this.http.get<T>(`/proxy/catalog${url}`, config)\n}\n\n```" } ]