id
stringlengths 12
53
| messages
listlengths 3
3
|
|---|---|
code_b2b-orders-history_b1322c4b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/PaymentConnectorResponses.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { FormattedMessage } from 'react-intl'\nimport { useCssHandles } from 'vtex.css-handles'\n\nconst CSS_HANDLES = ['font']\n\nconst getInnerPath = isOpen =>\n isOpen\n ? 'M73 158.497V123.58h136.078v34.917'\n : 'M123.98 209.078v-50.58H73V123.58h50.98V73h33.986v50.58h51.112v34.917h-51.112v50.58'\n\nconst PaymentConnectorResponses = ({ data = {}, isOpen, onClick }) => {\n const cssHandles = useCssHandles(CSS_HANDLES)\n return (\n <section>\n <button\n type=\"button\"\n onClick={onClick}\n className={`${\n isOpen ? 'mb5' : ''\n } dt mv3 pl0 bw0 bg-transparent input-reset c-muted-1 lh-solid f7 fw6`}\n >\n <svg\n className=\"dtr v-mid mr2 h-15px w-15px\"\n viewBox=\"0 0 283 283\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g fill=\"currentColor\" fillRule=\"evenodd\">\n <circle className=\"c-muted-1\" cx=\"141.5\" cy=\"141.5\" r=\"141.5\" />\n <path fill=\"#FFF\" d={getInnerPath(isOpen)} />\n </g>\n </svg>\n <span className={`dtr ${cssHandles.font} myo-font`}>\n <FormattedMessage id={'paymentData.additionalInfo'} />\n </span>\n </button>\n\n <ul\n className={`${\n isOpen ? 'o-100 max-h-999' : 'o-0 max-h-0'\n } pl0 ma0 transition-opacity-06s transition-max-height-06s list c-muted-1 overflow-y-hidden`}\n >\n {Object.keys(data).map(\n (key, index) =>\n data[key] &&\n data[key].length && (\n <li className={`${isOpen ? 'mb2' : ''} f7`} key={index}>\n <span className=\"mr3 fw5\">{key}:</span>\n <span>{data[key]}</span>\n </li>\n )\n )}\n </ul>\n </section>\n )\n}\nPaymentConnectorResponses.propTypes = {\n data: PropTypes.object,\n isOpen: PropTypes.bool,\n onClick: PropTypes.func,\n}\n\nexport default PaymentConnectorResponses\n\n```"
}
] |
code_b2b-orders-history_d08bd8ca
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/FormattedDate.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { FormattedDate } from 'react-intl'\n\nconst CustomDate = ({ date, style = '' }) => {\n let settings\n\n switch (style.toLowerCase()) {\n case 'short':\n settings = {}\n break\n default:\n settings = {\n year: 'numeric',\n month: 'long',\n day: '2-digit',\n }\n }\n\n return <FormattedDate value={date} {...settings} />\n}\n\nCustomDate.propTypes = {\n date: PropTypes.any.isRequired,\n style: PropTypes.string,\n}\n\nexport default CustomDate\n\n```"
}
] |
code_b2b-orders-history_ab2d7a49
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/OrderSummary.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { FormattedMessage } from 'react-intl'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport Price from './FormattedPrice'\nimport OrderSummaryHeader from './OrderSummaryHeader'\nimport ProductQuantity from './ProductQuantity'\nimport UnitPrice from './UnitPrice'\n\nconst CSS_HANDLES = [\n 'summary',\n 'summaryProduct',\n 'summaryProductQuantity',\n 'summaryProductValue',\n 'summaryProductName',\n 'summaryProductQuantityValue',\n]\n\nconst OrderSummary = ({ order }) => {\n const cssHandles = useCssHandles(CSS_HANDLES)\n\n if (!order || !order.orderId) {\n return null\n }\n\n const {\n value,\n totals,\n items,\n storePreferencesData: { currencyCode },\n shippingData: { address },\n } = order\n\n return (\n <article\n className={`${cssHandles.summary} myo-summary w-100 mv5 ba bw1 b--muted-5 overflow-hidden`}\n >\n <OrderSummaryHeader order={order} />\n <div className=\"pt3 bg-base bt-0\">\n {items.map((item, index) => (\n <div\n className={`${cssHandles.summaryProduct} myo-summary-product ph5 pv3 w-100 cf`}\n key={index}\n >\n <div className=\"dib h-auto w-25 fl\">\n <img src={item.imageUrl} alt=\"Imagem do Produto\" />\n </div>\n <div className=\"dib c-on-base w-75 fr pl2\">\n <h4\n className={`${cssHandles.summaryProductName} db c-on-base mb0 fw4 f6 mt0`}\n >\n {item.name}\n </h4>\n <p\n className={`${cssHandles.summaryProductQuantityValue} db mt0 fw4`}\n >\n <span className={`${cssHandles.summaryProductQuantity} pr3`}>\n <ProductQuantity\n unitMultiplier={item.unitMultiplier}\n quantity={item.quantity}\n measurementUnit={item.measurementUnit}\n />\n </span>\n <span className={cssHandles.summaryProductValue}>\n <UnitPrice\n currency={currencyCode}\n value={item.sellingPrice}\n unitMultiplier={item.unitMultiplier}\n measurementUnit={item.measurementUnit}\n />\n </span>\n </p>\n </div>\n </div>\n ))}\n\n <div className=\"bt bw1 b--muted-5 w-100\">\n <div className=\"pa5\">\n <div className=\"w-100 f6 fw4 c-on-base mb2 ttu\">\n <FormattedMessage id=\"order.shipsTo\" />\n </div>\n <div className=\"w-100 f6 fw6 c-on-base\">{address.receiverName}</div>\n <div className=\"w-100 f6 fw4 c-on-base\">\n {address.street}, {address.number}\n </div>\n <div className=\"w-100 f6 fw4 c-on-base\">\n {address.city} - {address.state}\n </div>\n <div className=\"w-100 f6 fw4 c-on-base\">{address.postalCode}</div>\n </div>\n </div>\n <div className=\"bt bw1 b--muted-5 w-100\">\n <div className=\"pa5\">\n <div className=\"w-100 f6 fw4 c-on-base mb2 ttu\">\n <FormattedMessage id=\"order.total\" />\n </div>\n\n {totals\n .filter(\n total => total.name && total.value !== 0 && total.value !== null\n )\n .map((total, index) => (\n <div className=\"cf w-100\" key={index}>\n <div className=\"dib f6 fw4 c-on-base w-60\">{total.name}</div>\n <div className=\"dib f6 fw4 c-on-base w-40 tr\">\n <Price value={total.value} currency={currencyCode} />\n </div>\n <hr className=\"bt-0 bb bw1 b--muted-5 w-100 mb2 mt2\" />\n </div>\n ))}\n\n <div className=\"cf w-100 mb7\">\n <div className=\"dib fl f6 fw5 c-on-base w-50\">\n <FormattedMessage id=\"order.total\" />\n </div>\n <div className=\"dib fr f6 fw5 c-on-base w-50 tr\">\n <Price value={value} currency={currencyCode} />\n </div>\n </div>\n </div>\n </div>\n </div>\n </article>\n )\n}\n\nOrderSummary.propTypes = {\n order: PropTypes.object.isRequired,\n}\n\nexport default OrderSummary\n\n```"
}
] |
code_b2b-orders-history_0ab5c620
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/ProductQuantity.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\nimport React from 'react'\nimport { FormattedNumber, FormattedMessage } from 'react-intl'\n\nconst ProductQuantity = ({ quantity, unitMultiplier, measurementUnit }) => {\n const qtd = (quantity || 0) * (unitMultiplier || 1)\n const showMeasurementUnit = measurementUnit !== 'un'\n\n return (\n <>\n {showMeasurementUnit ? (\n <>\n <FormattedNumber value={qtd} maximumFractionDigits={3} />{' '}\n {measurementUnit}\n </>\n ) : (\n <>\n <FormattedNumber value={qtd} maximumFractionDigits={3} />{' '}\n <FormattedMessage id=\"product.quantity\" values={{ qtd }} />\n </>\n )}\n </>\n )\n}\n\nProductQuantity.propTypes = {\n quantity: PropTypes.number,\n unitMultiplier: PropTypes.number,\n measurementUnit: PropTypes.string,\n}\n\nexport default ProductQuantity\n\n```"
}
] |
code_b2b-orders-history_eb0edf12
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/TrackingProgress.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport MediaQuery from 'react-responsive'\nimport { FormattedDate, FormattedTime, intlShape, injectIntl } from 'react-intl'\nimport orderBy from 'lodash/orderBy'\n\nconst PAGE_SIZE = 3\n\nclass TrackingProgress extends Component {\n constructor(props) {\n super(props)\n\n this.state = {\n visible: PAGE_SIZE,\n }\n }\n\n handleViewMore = () => {\n this.setState(prevState => ({ visible: prevState.visible + PAGE_SIZE }))\n }\n\n render() {\n const { courierStatus } = this.props\n const data = orderBy(\n courierStatus.data,\n date => new Date(date.lastChange),\n ['desc']\n )\n const visibleColumns = data.slice(0, this.state.visible)\n const isViewMoreVisible = this.state.visible < data.length\n\n if (courierStatus == null || data.length === 0) return null\n\n return (\n <div className=\"pv5 f6\">\n <MediaQuery minWidth={640}>\n <table\n className=\"pa3 ba b--muted-5 bw1 w-100 collapse\"\n style={{ borderCollapse: 'collapse', borderSpacing: 0 }}\n >\n <thead>\n <tr>\n <th className=\"pa3 tl\">\n <span className=\"pl3 ttu\">\n {this.props.intl.formatMessage({\n id: 'order.tracking.date',\n })}\n </span>\n </th>\n <th className=\"pa3 tl ttu\">\n {this.props.intl.formatMessage({ id: 'order.tracking.time' })}\n </th>\n <th className=\"pa3 tl ttu\">\n {this.props.intl.formatMessage({\n id: 'order.tracking.status',\n })}\n </th>\n </tr>\n </thead>\n <tbody>\n {visibleColumns.map(info => {\n return (\n <tr className=\"pa3 bt b--muted-5 bw1\" key={info.date}>\n <td className=\"pa3 w-10\">\n <span className=\"pl3\">\n {this.props.intl.formatDate(info.lastChange, {\n timeZone: 'UTC',\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n })}\n </span>\n </td>\n <td className=\"pa3 w-10\">\n <FormattedTime value={info.lastChange} timeZone=\"UTC\" />\n </td>\n <td className=\"pa3 w-20\">{info.description}</td>\n </tr>\n )\n })}\n </tbody>\n </table>\n </MediaQuery>\n <MediaQuery maxWidth={639}>\n <table className=\"pa3 ba b--muted-5 bw1 w-100 collapse\">\n <thead>\n <tr>\n <th className=\"pa3 tl\">\n <span className=\"pl3 ttu\">\n {this.props.intl.formatMessage({\n id: 'order.tracking.date',\n })}\n </span>\n </th>\n <th className=\"pa3 tl\">\n <span className=\"ttu\">\n {this.props.intl.formatMessage({\n id: 'order.tracking.status',\n })}\n </span>\n </th>\n </tr>\n </thead>\n <tbody>\n {visibleColumns.map(info => {\n return (\n <tr key={info.date} className=\"pa3 bt b--muted-5 bw1\">\n <td className=\"pa3 w-20\">\n <div className=\"flex flex-column\">\n <FormattedDate value={info.lastChange} timeZone=\"UTC\" />\n <div className=\"f7\">\n <FormattedTime\n value={info.lastChange}\n timeZone=\"UTC\"\n />\n </div>\n </div>\n </td>\n <td className=\"pa3\">{info.description}</td>\n </tr>\n )\n })}\n </tbody>\n </table>\n </MediaQuery>\n {isViewMoreVisible && (\n <div\n onClick={this.handleViewMore}\n className=\"pa3 pointer bl br bb b--muted-5 bw1 flex justify-center\"\n >\n <span className=\"c-on-action-secondary\">\n {this.props.intl.formatMessage({ id: 'order.tracking.showMore' })}\n </span>\n </div>\n )}\n </div>\n )\n }\n}\n\nTrackingProgress.propTypes = {\n courierStatus: PropTypes.object,\n intl: intlShape.isRequired,\n}\n\nexport default injectIntl(TrackingProgress)\n\n```"
}
] |
code_b2b-orders-history_abe552e3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/Address.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { AddressSummary, AddressRules } from 'vtex.address-form'\n\nconst Address = ({ address }) => {\n return (\n <div className=\"lh-copy f6\">\n <strong>{address.receiverName}</strong>\n <br />\n <AddressRules country={address.country} shouldUseIOFetching>\n <AddressSummary address={address} />\n </AddressRules>\n </div>\n )\n}\n\nAddress.propTypes = {\n address: PropTypes.object.isRequired,\n}\n\nexport default Address\n\n```"
}
] |
code_b2b-orders-history_e9c66b54
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/Error.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\nimport React, { Component } from 'react'\nimport { intlShape, injectIntl } from 'react-intl'\n\nclass Error extends Component {\n getI18nStr = id => this.props.intl.formatMessage({ id })\n\n render() {\n const { error } = this.props\n const status = error && error.status\n\n return (\n <div className=\"tc pt5 mw6 center\">\n <div className=\"pa5 br2 bg-danger--faded\">\n <div>\n <span className=\"ml3\">\n {error && status === 401\n ? this.getI18nStr('global.loginNeeded')\n : error && status === 403\n ? this.getI18nStr('global.unauthorized')\n : error && status === 404\n ? this.getI18nStr('global.notFound')\n : this.getI18nStr('global.unknownError')}\n </span>\n </div>\n </div>\n </div>\n )\n }\n}\n\nError.propTypes = {\n error: PropTypes.object,\n intl: intlShape.isRequired,\n}\n\nexport default injectIntl(Error)\n\n```"
}
] |
code_b2b-orders-history_165b358a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/FinalPrice.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\nimport React from 'react'\n\nimport Price from './FormattedPrice'\n\nconst FinalPrice = props => {\n const { totals, currencyCode } = props\n\n const fullPrice = totals.reduce((price, total) => price + total.value, 0)\n\n return <Price value={fullPrice} currency={currencyCode} />\n}\n\nFinalPrice.propTypes = {\n totals: PropTypes.arrayOf(PropTypes.object),\n currencyCode: PropTypes.string,\n transactions: PropTypes.arrayOf(PropTypes.object),\n}\n\nexport default FinalPrice\n\n```"
}
] |
code_b2b-orders-history_7f0ccef0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/Panel.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { useCssHandles } from 'vtex.css-handles'\n\nconst CSS_HANDLES = ['optionDisclaimer']\n\nconst Panel = ({ children }) => {\n const cssHandles = useCssHandles(CSS_HANDLES)\n return (\n <section\n className={`${cssHandles.optionDisclaimer} myo-option-disclaimer br2 mv3 pv5 ph7 bg-muted-5 c-on-muted-5`}\n >\n {children}\n </section>\n )\n}\nPanel.propTypes = {\n children: PropTypes.any,\n}\n\nexport default Panel\n\n```"
}
] |
code_b2b-orders-history_6b1182fe
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/OrderSummaryHeader.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport { OrderUtils } from '../../utils'\nimport FormattedDate from './FormattedDate'\nimport StatusBadge from './StatusBadge'\n\nconst CSS_HANDLES = ['summaryHeader']\n\nconst OrderSummaryHeader = ({ order }) => {\n const { status, creationDate } = order\n const cssHandles = useCssHandles(CSS_HANDLES)\n\n const isActive = OrderUtils.isOrderActive(status)\n const activeClasses = isActive ? 'o-100' : 'o-50'\n\n return (\n <div\n className={`${cssHandles.summaryHeader} myo-summary-header cf pa5 bw1 b--muted-5 bb bg-muted-5 ${activeClasses}`}\n >\n <div className=\"dib mt2 fl max-w-30 f6 fw5 c-on-muted-5\">\n <FormattedDate date={creationDate} style=\"short\" />\n </div>\n\n <div className=\"dib v-mid fr max-w-70\">\n <StatusBadge order={order} />\n </div>\n </div>\n )\n}\n\nOrderSummaryHeader.propTypes = {\n order: PropTypes.object.isRequired,\n isActive: PropTypes.bool,\n}\n\nexport default OrderSummaryHeader\n\n```"
}
] |
code_b2b-orders-history_7aa771a0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/StatusColor.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { FormattedMessage } from 'react-intl'\n\nconst StatusColor = ({ state, status }) => {\n let styles\n\n const orderState = state || 'unknown'\n\n switch (status) {\n case 'normal':\n styles = ' bg-muted-1 c-on-muted-1 '\n break\n case 'cancelled':\n styles = ' bg-danger c-on-danger '\n break\n case 'pending':\n styles = ' bg-warning c-on-warning '\n break\n case 'disabled':\n styles = ' bg-muted-2 c-on-muted-2 '\n break\n default:\n styles = ' bg-muted-2 c-on-muted-2 '\n }\n\n return (\n <span className={`dib br2 pv2 ph3 f7 f6-xl nowrap ${styles}`}>\n <FormattedMessage id={`order.state.${orderState}`} />\n </span>\n )\n}\n\nStatusColor.propTypes = {\n state: PropTypes.string.isRequired,\n status: PropTypes.string,\n}\n\nexport default StatusColor\n\n```"
}
] |
code_b2b-orders-history_eae1ff83
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/FormattedPrice.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { FormattedNumber } from 'react-intl'\n\nconst Price = ({ value, currency }) => (\n <FormattedNumber currency={currency} style=\"currency\" value={value / 100} />\n)\n\nPrice.propTypes = {\n value: PropTypes.number,\n currency: PropTypes.string,\n}\n\nexport default Price\n\n```"
}
] |
code_b2b-orders-history_6f17395c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/Popover.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nconst Popover = ({ children, isOpen }) => {\n const opacityStyle = isOpen ? ' o-100 ' : ' o-0 '\n\n return (\n <div\n className={`absolute top-2-ns z-5 db ba-ns bb-ns br2 mt3 mt5-ns pa5 f6 b--muted-5 bg-base c-on-base ${opacityStyle}`}\n style={{\n boxShadow: '0px 0px 15px -5px rgba(0,0,0,0.20)',\n transition: 'opacity 0.1s ease-in',\n }}\n >\n {children}\n </div>\n )\n}\n\nPopover.propTypes = {\n children: PropTypes.element.isRequired,\n isOpen: PropTypes.bool.isRequired,\n}\n\nexport default Popover\n\n```"
}
] |
code_b2b-orders-history_c4f0a051
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/ViewAllOrderProductsButton.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { FormattedMessage } from 'react-intl'\nimport { Link } from 'vtex.my-account-commons/Router'\n\nconst ViewAllOrderProductsButton = ({ orderId }) => (\n <Link to={`/orders-history/${orderId}`}>\n <FormattedMessage id=\"order.viewAllItems\" />\n </Link>\n)\n\nViewAllOrderProductsButton.propTypes = {\n orderId: PropTypes.any.isRequired,\n}\n\nexport default ViewAllOrderProductsButton\n\n```"
}
] |
code_b2b-orders-history_e6f372e4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/Button.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nimport Loader from './Loader'\n\nconst Button = ({ children, onClick, color, isLoading }) => {\n const bgColor = `bg-${color}`\n\n return (\n <button\n className={`dim f7 mv3 pv3 ph5 br2 tc c-on-success ${bgColor}`}\n onClick={onClick}\n >\n {children}\n {isLoading && (\n <span>\n \n <Loader size=\"small\" invert />\n </span>\n )}\n </button>\n )\n}\n\nButton.propTypes = {\n children: PropTypes.any,\n color: PropTypes.string,\n onClick: PropTypes.func,\n isLoading: PropTypes.bool,\n}\n\nButton.defaultProps = {\n color: 'success',\n isLoading: false,\n}\n\nexport default Button\n\n```"
}
] |
code_b2b-orders-history_49a0dc05
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/StatusBadge.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport packagify from '@vtex/delivery-packages'\nimport { ProgressBarBundle } from 'vtex.my-account-commons'\n\nimport { OrderUtils } from '../../utils'\nimport { OrderShape } from '../../types'\n\nconst StatusBadge = ({ order }) => {\n let orderState = 'unknown'\n const orderRawStatusPrefix = 'order.state.'\n const isPickup = OrderUtils.isOrderPickUp(order)\n // The order object shape may vary depending on where StatusBadge is called.\n // If it's called from the listing page, the isOrderDelivered function won't work properly.\n // So, we need to rely on the isAllDelivered property.\n const wasDelivered =\n OrderUtils.isOrderDelivered(order) || order.isAllDelivered\n const isReadyToPickup =\n OrderUtils.isOrderPickUp(order) && OrderUtils.isOrderReadyToPickUp(order)\n const {\n utils: { getCurrentProgressBarState },\n } = ProgressBarBundle\n\n const packages = order.packageAttachment != null ? packagify(order) : null\n const currentProgressBarState = getCurrentProgressBarState(\n order.status,\n packages\n )\n const { status: normalizedStatus } = OrderUtils.getFullState(order.status)\n\n if (order.status) {\n orderState =\n currentProgressBarState || `${orderRawStatusPrefix}${order.status}`\n if (\n isPickup &&\n [\n 'window-to-cancel',\n 'approve-payment',\n 'ready-for-handling',\n 'handling',\n 'release-to-fulfillment',\n ].includes(order.status)\n ) {\n orderState = `${orderRawStatusPrefix}handlingPickup`\n } else if (normalizedStatus === 'success') {\n if (isPickup) {\n if (wasDelivered) {\n orderState = `${orderRawStatusPrefix}pickedUp`\n } else if (isReadyToPickup) {\n orderState = `${orderRawStatusPrefix}ready-for-pickup`\n } else {\n orderState = `${orderRawStatusPrefix}handlingPickup`\n }\n } else if (wasDelivered) {\n orderState = `${orderRawStatusPrefix}delivered`\n }\n }\n }\n\n let styles\n let textStyle\n\n switch (normalizedStatus) {\n case 'normal':\n styles = 'bg-muted-1'\n textStyle = 'c-on-muted-1'\n break\n\n case 'cancelled':\n styles = 'bg-danger'\n textStyle = 'c-on-danger'\n break\n\n case 'pending':\n styles = 'bg-warning'\n break\n\n case 'disabled':\n styles = 'bg-muted-2'\n textStyle = 'c-on-muted-2'\n break\n\n case 'success':\n styles = 'bg-success'\n textStyle = 'c-on-success'\n break\n\n default:\n styles = 'bg-muted-2'\n textStyle = 'c-on-muted-2'\n }\n\n return (\n <div className={`dib br2 pv2 ph3 f7 fw5 tc ${styles}`}>\n <span className={textStyle || 'c-on-base'}>\n <FormattedMessage id={orderState} />\n </span>\n </div>\n )\n}\n\nStatusBadge.propTypes = {\n order: OrderShape,\n}\n\nexport default StatusBadge\n\n```"
}
] |
code_b2b-orders-history_8e284a9e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/ProductImage.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { utils } from 'vtex.my-account-commons'\n\nconst { fixImageUrl } = utils\n\nfunction ProductImage({ className, url, alt }) {\n return <img className={className} src={fixImageUrl(url)} alt={alt} />\n}\n\nProductImage.propTypes = {\n className: PropTypes.string,\n url: PropTypes.string,\n alt: PropTypes.string,\n}\n\nexport default ProductImage\n\n```"
}
] |
code_b2b-orders-history_f24304f8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/ProductPrice.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { FormattedMessage } from 'react-intl'\n\nimport Price from './FormattedPrice'\n\nconst ProductPrice = ({ value, isGift, currency }) => {\n if (isGift) {\n return (\n <small className=\"ttu\">\n <FormattedMessage id=\"commons.free\" />\n </small>\n )\n }\n\n return <Price value={value} currency={currency} />\n}\n\nProductPrice.propTypes = {\n value: PropTypes.number,\n isGift: PropTypes.bool,\n currency: PropTypes.string,\n}\n\nexport default ProductPrice\n\n```"
}
] |
code_b2b-orders-history_bea67bbe
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/InvoiceDataSpoiler.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { injectIntl, intlShape } from 'react-intl'\n\nconst InvoiceDataSpoiler = ({ invoiceUrl, intl }) => {\n return (\n <div className=\"pt1\">\n <a\n className=\"f6 link no-underline c-link\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={\n invoiceUrl.trim().indexOf('http') === 0\n ? invoiceUrl\n : `http://${invoiceUrl}`\n }\n >\n {intl.formatMessage({ id: 'order.seeInvoice' })}\n </a>\n </div>\n )\n}\n\nInvoiceDataSpoiler.propTypes = {\n invoiceUrl: PropTypes.string,\n intl: intlShape.isRequired,\n}\n\nexport default injectIntl(InvoiceDataSpoiler)\n\n```"
}
] |
code_b2b-orders-history_f82e7c97
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/Loader.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nimport loaderSVG from '../../images/loader.svg'\nimport loaderInvertSVG from '../../images/loaderInvert.svg'\n\nexport default function Loader({ children, size, display, invert }) {\n let style\n let sizeNumber\n const svgLoader = invert ? loaderInvertSVG : loaderSVG\n\n display = children ? 'block' : display\n\n if (display === 'inline') style = 'dib mh2'\n if (display === 'block') style = 'db center tc'\n\n if (size === 'small') sizeNumber = 16\n if (size === 'default') sizeNumber = 32\n if (size === 'big') sizeNumber = 64\n\n return (\n <div className={style}>\n <img\n src={svgLoader}\n height={sizeNumber}\n width={sizeNumber}\n alt=\"loader\"\n />\n {children ? (\n <span className=\"db f6 bg-muted-1 mt3\">{children}</span>\n ) : null}\n </div>\n )\n}\n\nLoader.propTypes = {\n children: PropTypes.string,\n size: PropTypes.oneOf(['small', 'default', 'big']),\n display: PropTypes.oneOf(['inline', 'block']),\n invert: PropTypes.bool,\n}\n\nLoader.defaultProps = {\n children: '',\n size: 'default',\n display: 'inline',\n}\n\n```"
}
] |
code_b2b-orders-history_b8d80c4a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/EditOrder/OptionGroupDisclaimer.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nconst OptionGroupDisclaimer = ({ group: { description } }) => (\n <div>\n <strong className=\"pt3 db\">{description.title}</strong>\n <ul className=\"pb0 mt3 ml0 mb0 pl5\">\n {description.disclaimers.map((disclaimer, i) => (\n <li className=\"pb3\" key={`disclaimer_${i}`}>\n {disclaimer}\n </li>\n ))}\n </ul>\n </div>\n)\n\nOptionGroupDisclaimer.propTypes = {\n group: PropTypes.object.isRequired,\n}\n\nexport default OptionGroupDisclaimer\n\n```"
}
] |
code_b2b-orders-history_2de5dc07
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/EditOrder/Option.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport kebabCase from 'lodash/kebabCase'\nimport { FormattedMessage } from 'react-intl'\nimport { useCssHandles } from 'vtex.css-handles'\n\nconst CSS_HANDLES = ['option', 'optionInput']\n\nconst Option = ({ id, option, groupName, onChange, disabled }) => {\n const cssHandles = useCssHandles(CSS_HANDLES)\n const handleChange = () => onChange(option, groupName)\n const inputId = kebabCase(id)\n return (\n <li className={`${cssHandles.option} myo-option pv5 bb bw1 b--muted-5`}>\n <span className=\"dtc v-mid\">\n <input\n disabled={disabled}\n type=\"radio\"\n name=\"sacForm\"\n id={inputId}\n value={option.value}\n onChange={handleChange}\n className={`${cssHandles.optionInput} myo-option-input relative input-reset br-100 ba bb bw1 b--muted-3 dib ma0 option`}\n style={{ width: '1.3rem', height: '1.3rem', minHeight: '1.3rem' }}\n />\n </span>\n <label\n className={`w-100 dtc f5 fw4 pl5 lh-copy c-on-base ${\n disabled ? 'cursor-not-allowed o-80' : ''\n }`}\n style={{\n fontSize:\n '1rem' /* Same size as f5 -- used here to override bootstrap */,\n }}\n htmlFor={inputId}\n >\n {option.label.i18n ? (\n <FormattedMessage id={option.label.i18n} />\n ) : (\n option.label\n )}\n </label>\n </li>\n )\n}\n\nOption.defaultProps = {\n id: '00',\n}\n\nOption.propTypes = {\n id: PropTypes.string,\n option: PropTypes.object.isRequired,\n groupName: PropTypes.string.isRequired,\n disabled: PropTypes.bool,\n onChange: PropTypes.func,\n}\n\nexport default Option\n\n```"
}
] |
code_b2b-orders-history_de5cf548
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/EditOrder/OptionGroup.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { useCssHandles } from 'vtex.css-handles'\n\nconst CSS_HANDLES = ['optionHeading']\n\nconst OptionGroup = ({ name = 'Opções', children }) => {\n const cssHandles = useCssHandles(CSS_HANDLES)\n return (\n <section className=\"mv7\">\n <h5\n className={`${cssHandles.optionHeading} myo-option-heading f7 tracked c-muted-1 ttu`}\n >\n {name}\n </h5>\n <ul className=\"list pa0 ma0\">{children}</ul>\n </section>\n )\n}\n\nOptionGroup.propTypes = {\n name: PropTypes.string,\n children: PropTypes.any.isRequired,\n}\n\nexport default OptionGroup\n\n```"
}
] |
code_b2b-orders-history_7c289a24
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/ViewOrder/OrderButtons.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { useEffect, useState } from 'react'\nimport PropTypes from 'prop-types'\nimport { FormattedMessage } from 'react-intl'\nimport { Link } from 'vtex.my-account-commons/Router'\n\nimport iconOptions from '../../images/options.svg'\nimport DropdownButton from './Dropdown'\nimport { addBaseURL } from '../../utils'\nimport { getCustomerEmail } from '../../actions/utils'\n\nconst OrderActions = ({ order, allowSAC }) => {\n const {\n orderId,\n orderGroup,\n allowEdition,\n allowCancellation,\n clientProfileData: { email: clientEmail },\n } = order\n\n const [loggedInEmail, setLoggedInEmail] = useState('')\n\n const handleOrderAgainClick = () => {\n return window.open(\n addBaseURL(`/checkout/orderform/createBy/${orderGroup}`),\n '_self'\n )\n }\n\n const fetchLoggedInEmail = async () => {\n return getCustomerEmail()\n }\n\n useEffect(() => {\n fetchLoggedInEmail()\n .then(email => {\n setLoggedInEmail(email)\n })\n .catch(error => console.error(error))\n\n return () => {\n setLoggedInEmail('')\n }\n }, [setLoggedInEmail])\n\n const isOwner = clientEmail === loggedInEmail\n const showEditOrderButton = allowSAC && allowEdition && isOwner\n const showCancelOrderButton = allowCancellation\n\n const CancelOrderButton = showCancelOrderButton ? (\n <Link className=\"no-underline\" to={`/orders-history/${orderId}/cancel`}>\n <span className=\"db pv2 c-link hover-c-link link\">\n <FormattedMessage id=\"order.cancelOrder\" />\n </span>\n </Link>\n ) : null\n\n const EditOrderButton = showEditOrderButton ? (\n <Link className=\"no-underline\" to={`/orders-history/${orderId}/edit`}>\n <span className=\"db pv2 c-link hover-c-link link\">\n <FormattedMessage id=\"order.changeOrder\" />\n </span>\n </Link>\n ) : null\n\n const OrderAgainButton = (\n // eslint-disable-next-line jsx-a11y/anchor-is-valid\n <a\n // eslint-disable-next-line no-script-url\n href=\"javascript:void(0)\"\n onClick={handleOrderAgainClick}\n className=\"f6 link underline c-link hover-c-link relative\"\n >\n <svg\n className=\"hh1 w1 absolute top-0\"\n fill=\"#134CD8\"\n viewBox=\"0 0 14 16\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M7.01 1.467V.32c0-.263-.304-.414-.515-.255L2.98 2.71c-.32.238-.32.714-.002.954l3.516 2.654c.212.16.515.01.515-.256V5.006c0-.375.34-.656.71-.6 2.56.395 4.44 2.862 3.85 5.632-.37 1.756-1.793 3.174-3.554 3.544-3.03.638-5.704-1.65-5.704-4.562 0-.955.293-1.84.79-2.575.346-.513.21-1.208-.298-1.563l-.02-.014c-.516-.36-1.246-.255-1.598.265C.196 6.607-.258 8.48.146 10.466c.548 2.705 2.74 4.877 5.46 5.4C10.084 16.726 14 13.33 14 9.02c0-3.658-2.822-6.658-6.414-6.955-.322-.027-.577-.277-.577-.598\"\n fillRule=\"evenodd\"\n />\n </svg>\n\n <span className=\"dib\" style={{ marginLeft: '20px' }}>\n <FormattedMessage id=\"order.orderAgain\" />\n </span>\n </a>\n )\n\n const availableOptions = [CancelOrderButton, EditOrderButton].filter(\n option => option !== null\n )\n const options =\n availableOptions.length > 1 ? (\n <DropdownButton icon={iconOptions} label=\"order.moreOptions\">\n {EditOrderButton}\n {CancelOrderButton}\n </DropdownButton>\n ) : (\n availableOptions[0]\n )\n\n return (\n <ul className=\"list tl tr-ns ma0 pa0-s\">\n {isOwner && (\n <li className=\"db dib-ns mr7-ns mb5 mb0-ns\">{OrderAgainButton}</li>\n )}\n <li className=\"db dib-ns mb5 mb0-ns\">{options}</li>\n </ul>\n )\n}\n\nOrderActions.propTypes = {\n order: PropTypes.object.isRequired,\n allowSAC: PropTypes.bool,\n}\n\nexport default OrderActions\n\n```"
}
] |
code_b2b-orders-history_e3020b1e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/ViewOrder/OrderFlow.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { FormattedMessage } from 'react-intl'\n\nimport checkIcon from '../../images/check.svg'\n\nconst OrderFlow = ({ step }) => {\n const status = [\n 'order.stepsFlow.placed', // 'Pedido Realizado',\n 'order.stepsFlow.approved', // 'Pedido Aprovado',\n 'order.stepsFlow.sent', // 'Pedido Enviado',\n 'order.stepsFlow.shipping', // 'Pedido à caminho',\n 'order.stepsFlow.finished', // 'Pedido Concluído',\n ]\n\n /* if (!pos) {\n return (\n <p className=\"dn\">\n <FormattedMessage id=\"order.stepsFlow.cancelled\" />\n </p>\n )\n } */\n\n return (\n <ul className=\"list overflow-hidden ma0\">\n {status.map((label, index) => {\n const activeOpacity = index >= step ? 'o-40' : ''\n const activeStyle = index >= step ? 'ba b--muted-5 br-100' : ''\n const activeImg =\n index >= step ? '' : <img src={checkIcon} alt=\"check\" />\n\n return (\n <li\n className={`fl w-20-ns w-100 mb7 mb0-ns fw6 lh-copy ${activeOpacity}`}\n key={index}\n >\n <span\n className={`mr3 fl db ${activeStyle}`}\n style={{ width: '25px', height: '25px' }}\n >\n {activeImg}\n </span>\n <FormattedMessage id={label} />\n </li>\n )\n })}\n </ul>\n )\n}\n\nOrderFlow.propTypes = {\n step: PropTypes.number,\n}\n\nexport default OrderFlow\n\n```"
}
] |
code_b2b-orders-history_80ebc44f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/ViewOrder/ReplacementHistory.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { FormattedMessage } from 'react-intl'\nimport { Link } from 'vtex.my-account-commons/Router'\n\nimport StatusColor from '../commons/StatusColor'\nimport FormattedDate from '../commons/FormattedDate'\n\nconst ReplacementHistory = ({ history }) => (\n <table className=\"table w-100\">\n <tbody>\n {history.map((order, index) => (\n <tr\n className={`${order.isCurrent ? 'bg-muted-5' : 'bg-base'}`}\n key={index}\n >\n <td className=\"pa2 w-25 pb3 tl v-mid\">\n <FormattedDate date={order.creationDate} />\n </td>\n <td className=\"pa0 w-35 pb3 tl mid\">\n {order.commercialConditionData && (\n <strong>\n <FormattedMessage\n id={`reasons.${order.commercialConditionData.reason}`}\n />\n </strong>\n )}\n </td>\n <td className=\"pa0 w-20 pb3 tc v-mid\">\n <StatusColor state={order.status} status={order.stateStatus} />\n </td>\n <td className=\"pa0 w-20 pb3 tr v-mid\">\n {!order.isCurrent && (\n <Link to={`/orders-history/${order.orderId}`}>\n <FormattedMessage id=\"seeOrder\" />\n </Link>\n )}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n)\n\nReplacementHistory.propTypes = {\n history: PropTypes.array.isRequired,\n}\n\nexport default ReplacementHistory\n\n```"
}
] |
code_b2b-orders-history_4258a40f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/ViewOrder/Dropdown.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport { injectIntl, intlShape } from 'react-intl'\n\nclass DropdownButton extends Component {\n constructor(props) {\n super(props)\n\n this.state = {\n isOpen: false,\n }\n\n this.wrapperRef = React.createRef()\n }\n\n componentDidMount() {\n document.addEventListener('mousedown', this.handleCloseDropdown)\n }\n\n componentWillUnmount() {\n document.removeEventListener('mousedown', this.handleCloseDropdown)\n }\n\n handleOpenDropdown = () => this.setState({ isOpen: true })\n\n handleCloseDropdown = event => {\n // Only close when clicking outside the Dropdown...\n if (this.wrapperRef && !this.wrapperRef.current.contains(event.target)) {\n this.setState({ isOpen: false })\n }\n }\n\n render() {\n const isOpenStyle = this.state.isOpen ? 'db' : 'dn'\n const label = this.props.intl.formatMessage({ id: 'order.moreOptions' })\n\n return (\n <div\n className=\"pointer dib f6 link underline c-link hover-c-link relative\"\n onClick={this.handleOpenDropdown}\n ref={this.wrapperRef}\n >\n <img\n src={this.props.icon}\n className=\"hh1 w1 top-0\"\n style={{ verticalAlign: 'sub' }}\n alt=\"\"\n />\n <span className=\"dib\" style={{ marginLeft: '8px' }}>\n {label}\n </span>\n <div\n className={`tl ph5 pv3 left-0 absolute overflow-hidden ma0 ba br2 bg-base b--muted-5 mw4 ${isOpenStyle}`}\n style={{\n boxShadow: '0px 0px 15px -5px rgba(0,0,0,0.20)',\n top: '110%',\n left: '0',\n }}\n >\n {this.props.children}\n </div>\n </div>\n )\n }\n}\n\nDropdownButton.propTypes = {\n icon: PropTypes.any,\n label: PropTypes.string,\n children: PropTypes.node,\n intl: intlShape,\n}\n\nexport default injectIntl(DropdownButton)\n\n```"
}
] |
code_b2b-orders-history_db0d4450
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/Orders/index.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nconst Orders = ({ children }) => <section className=\"ph0\">{children}</section>\n\nOrders.propTypes = {\n children: PropTypes.any,\n}\n\nexport default Orders\n\n```"
}
] |
code_b2b-orders-history_b2ae7fd2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/Orders/EmptyState.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { intlShape, injectIntl } from 'react-intl'\nimport { EmptyState } from 'vtex.styleguide'\n\nconst EmptyOrders = ({ ongoing, finished, intl }) => {\n let messageId = 'orders.notFound'\n\n if (finished) {\n messageId = 'orders.finishedNotFound'\n } else if (ongoing) {\n messageId = 'orders.ongoingNotFound'\n }\n\n return (\n <EmptyState\n title={\n <span className=\"c-on-base\">\n {intl.formatMessage({ id: messageId })}\n </span>\n }\n />\n )\n}\n\nEmptyOrders.propTypes = {\n ongoing: PropTypes.bool,\n finished: PropTypes.bool,\n intl: intlShape.isRequired,\n}\n\nexport default injectIntl(EmptyOrders)\n\n```"
}
] |
code_b2b-orders-history_d715dcfb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/Order/Products/BundleItem.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\nimport React from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport ProductPrice from '../../commons/ProductPrice'\n\nconst CSS_HANDLES = ['bundleItem']\n\nconst BundleItem = props => {\n const cssHandles = useCssHandles(CSS_HANDLES)\n const { name, price, currencyCode, quantity, isGift } = props\n return (\n <tr\n className={`${cssHandles.bundleItem} myo-bundle-item bt bw1 b--muted-5`}\n >\n <td className=\"tl v-top pv3 v-mid overflow-hidden\">\n <div className=\"ml3 fl overflow-hidden w-80-ns\">\n <p className=\"fw7 f6 mb0\">{name}</p>\n </div>\n </td>\n <td className=\"pv3 tl v-top dn dtc-ns\" />\n <td />\n <td className=\"pl1 pt3 tl v-top v-mid\">\n <ProductPrice\n value={price * quantity}\n currency={currencyCode}\n isGift={isGift}\n />\n </td>\n </tr>\n )\n}\n\nBundleItem.propTypes = {\n name: PropTypes.string,\n price: PropTypes.number,\n currencyCode: PropTypes.string,\n quantity: PropTypes.number,\n isGift: PropTypes.bool,\n}\n\nexport default BundleItem\n\n```"
}
] |
code_b2b-orders-history_f4870be2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/Order/Products/index.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\nimport React from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport { utils } from 'vtex.my-account-commons'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport Product from './Product'\nimport BundleItem from './BundleItem'\nimport Attachment from './Attachment'\n\nconst { reduceBundleItems } = utils\n\nconst CSS_HANDLES = ['productTable']\n\nconst Products = props => {\n const cssHandles = useCssHandles(CSS_HANDLES)\n const { items, currencyCode, sellers } = props\n const itemsWithBundleItems = reduceBundleItems(items)\n\n return (\n <table\n className={`${cssHandles.productTable} myo-product-table table w-100 mt7`}\n >\n <thead>\n <tr className=\"tl\">\n <th className=\"pa0 w-60 w-50-ns pb3\">\n <FormattedMessage id=\"order.package.product\" />\n </th>\n <th className=\"pa0 w-20 pl2 pr2 pb3 dn dtc-ns\">\n <FormattedMessage id=\"order.package.price\" />\n </th>\n <th className=\"pa0 w-20 pl2 pr2 pb3\">\n <FormattedMessage id=\"order.package.quantity\" />\n </th>\n <th className=\"pa0 w-30 w-20-ns pb3\">\n <FormattedMessage id=\"order.package.total\" />\n </th>\n </tr>\n </thead>\n <tbody>\n {itemsWithBundleItems.map((product, index) => {\n const seller = sellers.find(({ id }) => id === product.seller)\n const sellerName = seller ? seller.name : ''\n\n if (product.isBundleItem) {\n return (\n <BundleItem\n key={index}\n currencyCode={currencyCode}\n name={product.name}\n price={product.sellingPrice}\n quantity={product.parentItemQuantity * product.quantity}\n isGift={product.isGift}\n attachments={product.attachments}\n />\n )\n }\n\n if (product.isAttachment) {\n return (\n <Attachment\n key={index}\n name={product.name}\n content={product.content}\n />\n )\n }\n\n return (\n <Product\n key={index}\n id={product.productId}\n sellerName={sellerName}\n currencyCode={currencyCode}\n name={product.name}\n sellingPrice={product.sellingPrice}\n imageUrl={product.imageUrl}\n detailUrl={product.detailUrl}\n quantity={product.quantity}\n measurementUnit={product.measurementUnit}\n unitMultiplier={product.unitMultiplier}\n isGift={product.isGift}\n trackingUrl={\n product.logisticsInfo && product.logisticsInfo.trackingUrl\n }\n trackingNumber={\n product.logisticsInfo && product.logisticsInfo.trackingNumber\n }\n />\n )\n })}\n </tbody>\n </table>\n )\n}\n\nProducts.propTypes = {\n items: PropTypes.arrayOf(PropTypes.object),\n currencyCode: PropTypes.string,\n sellers: PropTypes.arrayOf(PropTypes.object),\n}\n\nexport default Products\n\n```"
}
] |
code_b2b-orders-history_9e76a5b7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/Order/Products/Attachment.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport map from 'lodash/map'\nimport {\n FormattedMessage,\n FormattedDate,\n injectIntl,\n intlShape,\n} from 'react-intl'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { translations } from 'vtex.subscriptions-commons'\n\nimport arrow from '../../../assets/arrow-up.svg'\nimport slugify from '../../../utils/slugify'\n\nconst ATTACHMENT_DATE_VALUES = [\n 'vtex.subscription.key.validity.begin',\n 'vtex.subscription.key.validity.end',\n]\n\nconst CSS_HANDLES = [\n 'attachment',\n 'attachmentGiftWrap',\n 'attachmentInfo',\n 'attachmentKey',\n 'attachmentValue',\n 'attachmentName',\n]\n\nfunction getFormattedSubscriptionKey(key) {\n return (\n <FormattedMessage\n id=\"order.subscription.key.frequency\"\n defaultMessage={key}\n />\n )\n}\n\nfunction getFormattedSubscriptionValue(key, value, intl) {\n if (ATTACHMENT_DATE_VALUES.includes(key)) {\n return <FormattedDate value={new Date(value)} />\n }\n\n const valueParts = value.trim().split(' ')\n let [interval, periodicity] = valueParts\n\n if (!periodicity || !interval) return ''\n\n switch (periodicity) {\n case 'day':\n periodicity = 'DAILY'\n break\n\n default:\n periodicity = `${periodicity}ly`.toUpperCase()\n break\n }\n\n return translations.translatePeriodicity(intl, `${periodicity}`, interval)\n}\n\nconst Attachment = ({ name, content, intl }) => {\n const slugName = slugify(name)\n const cssHandles = useCssHandles(CSS_HANDLES)\n\n const isGiftWrap = name === 'message' && content.text\n if (isGiftWrap) {\n return (\n <tr\n className={`${cssHandles.attachment} ${cssHandles.attachmentGiftWrap} myo-attachment-gift-wrap`}\n slug={slugName}\n >\n <td className=\"pa0 pv5 v-mid overflow-hidden\">\n <div className=\"ml3 fl overflow-hidden w-80-ns\">\n <blockquote className=\"gift-message\">{content.text}</blockquote>\n </div>\n </td>\n <td className=\"dn dtc-ns\" />\n <td />\n <td className=\"pa0 pv5 v-mid\" />\n </tr>\n )\n }\n\n const isSubscription = name.indexOf('vtex.subscription') === 0\n\n const attachmentTitle = isSubscription ? (\n <FormattedMessage id=\"order.subscription\" />\n ) : (\n name\n )\n\n const attachmentInfo = map(content, (value, key) => {\n const elementKey = `${key}-${value}-${name}`\n const shouldNotDisplay = isSubscription && !value\n\n if (shouldNotDisplay) {\n return <div key={elementKey} className=\"dn\" />\n }\n\n let formattedKey = key\n let formattedValue = value\n\n if (isSubscription) {\n formattedKey = getFormattedSubscriptionKey(key)\n formattedValue = getFormattedSubscriptionValue(key, value, intl)\n }\n\n // for compatibility\n const mainClassName = `myo-attachment-${slugify(name)}-${slugify(key)}`\n return (\n <div\n key={elementKey}\n className={`${cssHandles.attachmentInfo} ${mainClassName} myo-attachment-info pb2`}\n name={slugify(name)}\n >\n <span className={`${cssHandles.attachmentKey} myo-attachment-key fw7`}>\n {formattedKey}: \n </span>\n <span className={`${cssHandles.attachmentValue} myo-attachment-value`}>\n {formattedValue}\n </span>\n </div>\n )\n })\n\n return (\n <tr\n className={`${cssHandles.attachment} myo-attachment bg-muted-5`}\n slug={slugName}\n >\n <td className=\"pv3 tl v-top v-mid relative\">\n <div className=\"ml9-ns mt3 fl w-80-ns\">\n <img\n src={arrow}\n alt=\"\"\n className=\"absolute\"\n style={{ top: '-1px' }}\n />\n <p\n className={`${cssHandles.attachmentName} myo-attachment-${slugName} myo-attachment-name f5 mb0`}\n >\n {attachmentTitle}\n </p>\n <div className=\"pt5\">{attachmentInfo}</div>\n </div>\n </td>\n <td className=\"pv3 tl v-top dn dtc-ns\" />\n <td />\n <td className=\"pv3 tl v-top v-mid\" />\n </tr>\n )\n}\n\nAttachment.propTypes = {\n name: PropTypes.string,\n content: PropTypes.object,\n intl: intlShape.isRequired,\n}\n\nexport default injectIntl(Attachment)\n\n```"
}
] |
code_b2b-orders-history_1c071b0c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/Order/Products/Product.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\nimport React from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { Link } from 'vtex.render-runtime'\n\nimport ProductPrice from '../../commons/ProductPrice'\nimport ProductImage from '../../commons/ProductImage'\nimport UnitPrice from '../../commons/UnitPrice'\nimport ProductQuantity from '../../commons/ProductQuantity'\nimport ProductName from '../../commons/ProductName'\n\nconst CSS_HANDLES = [\n 'productRow',\n 'productInfo',\n 'productImage',\n 'productName',\n 'sellerName',\n 'productPrice',\n 'productQuantity',\n 'productTotalPrice',\n]\n\nconst Product = ({\n id,\n imageUrl,\n detailUrl,\n name,\n sellerName,\n currencyCode,\n quantity,\n measurementUnit,\n unitMultiplier,\n isGift,\n sellingPrice,\n}) => {\n const cssHandles = useCssHandles(CSS_HANDLES)\n\n return (\n <tr\n className={`${cssHandles.productRow} myo-product-row bt b--muted-5 bw1`}\n >\n <td\n className={`${cssHandles.productInfo} myo-product-info pv3 tl v-top overflow-hidden`}\n >\n <ProductImage\n className={`${cssHandles.productImage} myo-product-image mw4-ns fl mr5`}\n url={imageUrl}\n alt={name}\n />\n <div className=\"fl overflow-hidden w-80-ns lh-copy\">\n <Link\n to={detailUrl}\n className={`${cssHandles.productName} myo-product-name fw7 f6 mb0 mt0`}\n // eslint-disable-next-line react/jsx-no-target-blank\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n <ProductName productId={id} name={name} />\n </Link>\n <span\n className={`${cssHandles.sellerName} myo-seller-name f7 c-muted-1 db`}\n >\n {sellerName}\n </span>\n </div>\n </td>\n <td\n className={`${cssHandles.productPrice} myo-product-price pl2-ns pt3 tl v-top dn dtc-ns`}\n >\n <UnitPrice\n value={sellingPrice}\n currency={currencyCode}\n measurementUnit={measurementUnit}\n unitMultiplier={unitMultiplier}\n />\n </td>\n <td\n className={`${cssHandles.productQuantity} myo-product-quantity pl2-ns pt3 tl v-top`}\n >\n <ProductQuantity\n unitMultiplier={unitMultiplier}\n quantity={quantity}\n measurementUnit={measurementUnit}\n />\n </td>\n <td\n className={`${cssHandles.productTotalPrice} myo-product-total-price pl1-l pt3 tl v-top`}\n >\n <ProductPrice\n value={sellingPrice * quantity}\n isGift={isGift}\n currency={currencyCode}\n />\n </td>\n </tr>\n )\n}\n\nProduct.propTypes = {\n id: PropTypes.string,\n imageUrl: PropTypes.string,\n detailUrl: PropTypes.string,\n name: PropTypes.string,\n sellerName: PropTypes.string,\n sellingPrice: PropTypes.number,\n currencyCode: PropTypes.string,\n quantity: PropTypes.number,\n unitMultiplier: PropTypes.number,\n measurementUnit: PropTypes.string,\n isGift: PropTypes.bool,\n attachments: PropTypes.array,\n}\n\nexport default Product\n\n```"
}
] |
code_b2b-orders-history_9d265880
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/ProductName/Product.gql from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery Product($values: [ID!]!) {\n productsByIdentifier(field: id, values: $values)\n @context(provider: \"vtex.search-graphql@0.x\") {\n productName\n productId\n items {\n itemId\n name\n variations {\n name\n values\n }\n }\n }\n}\n\n```"
}
] |
code_b2b-orders-history_ff9baa23
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/commons/ProductName/index.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { useQuery } from 'react-apollo'\n\nimport PRODUCT_QUERY from './Product.gql'\n\nfunction ProductName({ productId, name }) {\n const { data: { productsByIdentifier } = {} } = useQuery(PRODUCT_QUERY, {\n variables: { values: [productId] },\n })\n\n return <>{productsByIdentifier?.[0].productName ?? name}</>\n}\n\nProductName.propTypes = {\n productId: PropTypes.string,\n name: PropTypes.string,\n}\n\nexport default ProductName\n\n```"
}
] |
code_b2b-orders-history_54875348
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/ViewOrder/ChangesHistory/ChangeItems.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { FormattedMessage } from 'react-intl'\n\nimport ProductImage from '../../commons/ProductImage'\nimport ProductPrice from '../../commons/ProductPrice'\nimport ProductQuantity from '../../commons/ProductQuantity'\n\nconst ChangeItems = ({ items, currencyCode }) => (\n <div className=\"ba br2 b--muted-4 w-100\">\n {items.map((item, i) => {\n const {\n id,\n imageUrl,\n measurementUnit,\n quantity,\n sellingPrice,\n price,\n name,\n unitMultiplier,\n } = item\n const showDivider = i + 1 < items.length\n\n return (\n <div\n key={id}\n className={`pa6 flex w-100 ${showDivider ? 'bb b--muted-4' : ''}`}\n >\n <div className=\"w-20\">\n {imageUrl && <ProductImage url={imageUrl} />}\n </div>\n <div className=\"w-80 f6\">\n <div className=\"fw6\">{name}</div>\n <div className=\"pt5\">\n {measurementUnit ? (\n <ProductQuantity\n quantity={quantity}\n unitMultiplier={unitMultiplier}\n measurementUnit={measurementUnit}\n />\n ) : (\n <FormattedMessage\n id=\"order.change.quantity\"\n values={{ quantity }}\n />\n )}\n </div>\n <div className=\"pt4 fw6\">\n <ProductPrice\n value={sellingPrice || price}\n currency={currencyCode}\n />\n </div>\n </div>\n </div>\n )\n })}\n </div>\n)\n\nChangeItems.propTypes = {\n items: PropTypes.arrayOf(PropTypes.object).isRequired,\n currencyCode: PropTypes.string.isRequired,\n}\n\nexport default ChangeItems\n\n```"
}
] |
code_b2b-orders-history_19afd0f8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/ViewOrder/ChangesHistory/index.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { FormattedMessage } from 'react-intl'\n\nimport ArrowIcon from './ArrowIcon'\nimport ChangeOrderHeader from './ChangeOrderHeader'\nimport ChangedItems from './ChangeItems'\n\nconst ITEMS_TOTAL = 'items'\nconst CHANGE_TOTAL = 'change'\n\nconst ChangesHistory = ({\n items,\n totals,\n creationDate,\n changes,\n currencyCode,\n}) => {\n const itemsAdded = changes.reduce(\n (all, { itemsAdded: added }) => all.concat(added),\n []\n )\n const itemsRemoved = changes.reduce(\n (all, { itemsRemoved: removed }) => all.concat(removed),\n []\n )\n\n const original = {\n items,\n totals: totals.filter(({ id }) => id.toLowerCase() === ITEMS_TOTAL),\n date: creationDate,\n }\n\n const changed = {\n items: items.slice(),\n totals: totals.filter(({ id }) =>\n [ITEMS_TOTAL, CHANGE_TOTAL].includes(id.toLowerCase())\n ),\n date: changes[changes.length - 1].receipt.date,\n }\n\n if (itemsAdded) {\n itemsAdded.forEach(itemAdded => {\n const itemIndex = changed.items.findIndex(({ id }) => id === itemAdded.id)\n if (itemIndex > -1) {\n changed.items[itemIndex] = {\n ...changed.items[itemIndex],\n quantity: changed.items[itemIndex].quantity + itemAdded.quantity,\n }\n } else {\n changed.items.push(itemAdded)\n }\n })\n }\n\n if (itemsRemoved) {\n itemsRemoved.forEach(itemRemoved => {\n const itemIndex = changed.items.findIndex(\n ({ id }) => id === itemRemoved.id\n )\n if (itemIndex > -1) {\n changed.items[itemIndex] = {\n ...changed.items[itemIndex],\n quantity: changed.items[itemIndex].quantity - itemRemoved.quantity,\n }\n }\n })\n\n changed.items = changed.items.filter(({ quantity }) => quantity > 0)\n }\n\n return (\n <div className=\"mt6\">\n <div className=\"w-100 flex justify-between\">\n <div className=\"w-45\">\n <ChangeOrderHeader\n title={<FormattedMessage id=\"order.change.originalOrder\" />}\n date={original.date}\n totals={original.totals}\n currencyCode={currencyCode}\n />\n </div>\n <div className=\"w-45\">\n <ChangeOrderHeader\n title={<FormattedMessage id=\"order.change.currentOrder\" />}\n date={changed.date}\n totals={changed.totals}\n currencyCode={currencyCode}\n />\n </div>\n </div>\n <div className=\"w-100 flex mt8\">\n <div className=\"w-45\">\n <ChangedItems items={original.items} currencyCode={currencyCode} />\n </div>\n <div className=\"w-10 flex items-center justify-center\">\n <ArrowIcon />\n </div>\n <div className=\"w-45\">\n <ChangedItems items={changed.items} currencyCode={currencyCode} />\n </div>\n </div>\n </div>\n )\n}\n\nChangesHistory.propTypes = {\n changes: PropTypes.arrayOf(PropTypes.object).isRequired,\n items: PropTypes.arrayOf(PropTypes.object).isRequired,\n totals: PropTypes.arrayOf(PropTypes.object).isRequired,\n currencyCode: PropTypes.string.isRequired,\n creationDate: PropTypes.string.isRequired,\n arrow: PropTypes.bool,\n}\n\nexport default ChangesHistory\n\n```"
}
] |
code_b2b-orders-history_5c3618bd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/ViewOrder/ChangesHistory/ChangeOrderHeader.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { FormattedMessage, injectIntl, intlShape } from 'react-intl'\n\nimport FinalPrice from '../../commons/FinalPrice'\n\nconst ChangeOrderHeader = ({\n title,\n date,\n totals,\n currencyCode,\n intl: { formatDate, formatTime },\n}) => (\n <div className=\"w-100\">\n <div className=\"t-heading-4 mb3\">{title}</div>\n <div className=\"t-small c-muted-1\">\n <FormattedMessage\n id=\"order.change.date\"\n values={{\n date: formatDate(date, {\n timeZone: 'UTC',\n day: '2-digit',\n month: 'long',\n year: 'numeric',\n }),\n hour: formatTime(date, {\n timeZone: 'UTC',\n }),\n }}\n />\n </div>\n <div className=\"t-body c-on-base mt5\">\n <FinalPrice totals={totals} currencyCode={currencyCode} />\n </div>\n </div>\n)\n\nChangeOrderHeader.propTypes = {\n title: PropTypes.element.isRequired,\n totals: PropTypes.arrayOf(PropTypes.object).isRequired,\n currencyCode: PropTypes.string.isRequired,\n date: PropTypes.string.isRequired,\n intl: intlShape.isRequired,\n}\n\nexport default injectIntl(ChangeOrderHeader)\n\n```"
}
] |
code_b2b-orders-history_8967f91f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/components/ViewOrder/ChangesHistory/ArrowIcon.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\n\nclass ArrowIcon extends PureComponent {\n render() {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M16 8C16 7.625 15.8667 7.375 15.6 7.125L8 6.03983e-07L6.13333 1.75L11.4667 6.75L-4.0433e-07 6.75L-2.95052e-07 9.25L11.4667 9.25L6.13333 14.25L8 16L15.6 8.875C15.8667 8.625 16 8.375 16 8Z\"\n fill=\"#3F3F40\"\n />\n </svg>\n )\n }\n}\n\nexport default ArrowIcon\n\n```"
}
] |
code_b2b-orders-history_16d75e9d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-orders-history/react/actions/utils/index.js from the b2b-orders-history VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport Cookies from 'js-cookie'\nimport axiosRetry from '@vtex/axios-concurrent-retry'\n\nimport axios from '../../utils/customAxios'\nimport { addBaseURL } from '../../utils'\n\nlet session\n\nfunction getSession() {\n axiosRetry(axios, {\n retries: 3,\n retryTimeout: 1,\n retryDelay: axiosRetry.exponentialDelay,\n })\n\n return axios\n .get(addBaseURL('/api/sessions/?items=*'))\n .then(({ data }) => data)\n}\n\nfunction getImpersonatedCustomerEmail() {\n return Cookies.get('vtex-impersonated-customer-email')\n}\n\nexport async function retrieveSession() {\n // eslint-disable-next-line require-atomic-updates\n session = session || (await getSession())\n\n return session\n}\n\nasync function getImpersonatedCustomerFromSessionOrCookie() {\n // eslint-disable-next-line require-atomic-updates\n const currentSession = await retrieveSession()\n\n if (currentSession) {\n return (\n (currentSession.namespaces &&\n currentSession.namespaces.impersonate &&\n currentSession.namespaces.impersonate.storeUserEmail &&\n currentSession.namespaces.impersonate.storeUserEmail.value) ||\n null\n )\n }\n\n return getImpersonatedCustomerEmail()\n}\n\nexport async function getCustomerEmail() {\n const currentSession = await retrieveSession()\n\n const storeUserEmail =\n currentSession &&\n currentSession.namespaces &&\n currentSession.namespaces.profile &&\n currentSession.namespaces.profile.email &&\n currentSession.namespaces.profile.email.value\n\n return storeUserEmail || getImpersonatedCustomerFromSessionOrCookie()\n}\n\nexport async function checkB2B(baseUrl) {\n const currentSession = await retrieveSession()\n\n return currentSession?.namespaces['storefront-permissions']?.organization\n ?.value\n ? baseUrl.replace(/api/gi, '_v/private/b2b')\n : baseUrl\n}\n\nexport async function getOrdersURL(baseUrl, page = '1') {\n session = null\n\n const customerEmail = await getImpersonatedCustomerFromSessionOrCookie()\n const b2bUrl = await checkB2B(baseUrl)\n\n return customerEmail\n ? `${b2bUrl}?clientEmail=${customerEmail}&page=${page}`\n : `${b2bUrl}?page=${page}`\n}\n\nexport async function getOrderDetailURL(baseUrl) {\n const customerEmail = await getImpersonatedCustomerFromSessionOrCookie()\n const b2bUrl = await checkB2B(baseUrl)\n\n return customerEmail ? `${b2bUrl}?clientEmail=${customerEmail}` : b2bUrl\n}\n\nexport const parseJSON = response => {\n return response.json()\n}\n\nexport const checkStatus = response => {\n if (response.status >= 200 && response.status < 300) {\n return response\n }\n\n throw response\n}\n\nexport async function getCallCenterEmail() {\n const currentSession = await retrieveSession()\n\n const email =\n currentSession &&\n currentSession.namespaces &&\n currentSession.namespaces.authentication &&\n currentSession.namespaces.authentication.adminUserEmail &&\n currentSession.namespaces.authentication.adminUserEmail.value\n\n return email\n}\n\nexport const OPERATION_ID_HEADER = 'x-vtex-operation-id'\n\nexport function getResponseOperationId(response) {\n return response && response.headers.get(OPERATION_ID_HEADER)\n}\n\n```"
}
] |
code_wish-list-v2_ee0377b1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/messages/pt.json from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/test\": \"teste\",\n \"store/test\": \"teste\",\n \"store/favorite-list.search-product-by-sku\": \"Search products by SKU\"\n}\n\n```"
}
] |
code_wish-list-v2_d12b729b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/messages/en.json from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/test\": \"test\",\n \"store/test\": \"test\",\n \"store/favorite-list.search-product-by-sku\": \"Search products by SKU\"\n}\n\n```"
}
] |
code_wish-list-v2_8947e18d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/messages/es.json from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/test\": \"teste\",\n \"store/test\": \"teste\",\n \"store/favorite-list.search-product-by-sku\": \"Search products by SKU\"\n}\n\n```"
}
] |
code_wish-list-v2_5df7f9b3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/docs/README.md from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/clouda-inc/wish-list-v2) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# My Wishlists\n\n<!-- DOCS-IGNORE:start -->\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n\n[](#contributors-)\n\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n<!-- DOCS-IGNORE:end -->\n\nThe **My Wishlists** app handles the favorite products of users. Users can create multiple lists and add the products they like to those lists. They can manage them and Add them to the cart and buy.\n\n\n\n## Configuration\n\nTo configure the My Wishlists app, check the sections below.\n\n### Adding the My Wishlists app to your theme's dependencies\n\nIn your theme's `manifest.json`, add the Search Result app as a dependency:\n\n```json\n\"dependencies\": {\n \"vtex.my-wishlists\": \"2.x\"\n}\n```\n\nNow, you can use all the blocks exported by the `my-wishlists` app.\n\nAdd the `wishlist-button` to Product Details page. In the example below, the `wishlist-button` is added to the `flex-layout.row` block from the `store.product` template, which uses the product context:\n\n```json\n \"store.product\": {\n \"children\": [\n \"flex-layout.row#wishlist-button-pdp\",\n ]\n },\n \"flex-layout.row#wishlist-button-pdp\": {\n \"children\": [\n \"button-wishlist-pdp\"\n ]\n }\n```\n\nAdd the `wishlist-button` to Search page. In the example below, the `wishlist-button` is added to the `product-summary.shelf` block under the `gallery` in `store.search` template:\n\n```json\n \"product-summary.shelf\": {\n \"children\": [\"responsive-layout.desktop#productSummary\"]\n },\n \"responsive-layout.desktop#productSummary\": {\n \"children\": [\n \"flex-layout.row#wishlist-button-plp\"\n ]\n },\n \"flex-layout.row#wishlist-button-plp\": {\n \"children\": [\n \"button-wishlist-pdp\"\n ]\n }\n```\n\n## Master Data\n\nData in the wishlist are stored in VTEX masterdata entity named `myWishlists`.\n\nThis entity is created automatically when first time accessing the wishlist.\n\n### Updating schema\n\nIf masterdata schema is updated during the development (if any changes added to schema), schema version needs to be updated.\nOn each schema version update new schema is created automatically with following format `{versionNumber}-mywishlists` (i.e. `0.0.2-mywishlists`).\n\n#### Master data schema\n\nHere is the latest masterdata schema.\n\nData Entity Name: `myWishlists`\nSchema Name: `0.0.4-mywishlists`\n\n<details><summary>myWishlists</summary>\n\n```json\n{\n \"properties\": {\n \"email\": {\n \"type\": \"string\",\n \"format\": \"email\"\n },\n \"wishlistType\": {\n \"type\": \"string\"\n },\n \"products\": {\n \"type\": \"array\"\n },\n \"isPublic\": {\n \"type\": \"boolean\"\n },\n \"fieldsConfig\": {\n \"type\": \"array\"\n }\n },\n \"required\": [\"email\", \"wishlistType\", \"products\", \"isPublic\"],\n \"v-indexed\": [\n \"email\",\n \"wishlistType\",\n \"products\",\n \"isPublic\",\n \"fieldsConfig\"\n ],\n \"v-default-fields\": [\n \"email\",\n \"wishlistType\",\n \"products\",\n \"isPublic\",\n \"fieldsConfig\"\n ],\n \"v-cache\": false,\n \"v-immediate-indexing\": true,\n \"v-security\": {\n \"allowGetAll\": true,\n \"publicRead\": [\n \"id\",\n \"email\",\n \"wishlistType\",\n \"products\",\n \"isPublic\",\n \"fieldsConfig\"\n ],\n \"publicWrite\": [\n \"email\",\n \"wishlistType\",\n \"products\",\n \"isPublic\",\n \"fieldsConfig\"\n ],\n \"publicFilter\": [\n \"email\",\n \"wishlistType\",\n \"products\",\n \"isPublic\",\n \"fieldsConfig\"\n ]\n }\n}\n```\n\n</details>\n\n\n## Wishlist Share Component\n\nTo use the Wishlist Share component you must add the route to your store theme\n\n1. Add the route \n```routes.json```\n```json\n{\n \"store.custom#wishlistshare\": {\n \"path\": \"/wishlist-share\"\n }\n}\n```\n2. Add the block to the store\n\n**Example**\n\n```wishlistshare.jsonc```\n```json\n{\n \"store.custom#wishlistshare\": {\n \"blocks\": [\n \"flex-layout.row#wishlistshare\"\n ]\n },\n \"flex-layout.row#wishlistshare\": {\n \"children\": [\n \"wishlist-share\"\n ]\n }\n}\n```\n\n## Customization\n\nIn order to apply CSS customizations in this and other blocks, follow the instructions given in the recipe on [Using CSS Handles for store customization](https://vtex.io/docs/recipes/style/using-css-handles-for-store-customization).\n\n| CSS Handles |\n| ------------------------------------- |\n| `notesContainer` |\n| `addNotesIcons` |\n| `notesButtonContainer` |\n| `notesSubmitButtonContainer` |\n| `notesSubmitButton` |\n| `notesSubmitDisabledButton` |\n| `notesModalContainer` |\n| `notesModalTitle` |\n| `notesModalBottomRow` |\n| `notesCancelButton` |\n| `productSummary` |\n| `productSummaryImageContainer` |\n| `productSummaryImage` |\n| `productSummaryInfo` |\n| `productSummaryInfoName` |\n| `productSummaryInfoDetails` |\n| `productSummaryInfoDetailsPartNumber` |\n| `productSummaryInfoDetailsPrice` |\n| `noteSubTitle` |\n| `autocompleteInputWrapper` |\n| `productPriceContainer` |\n| `unitPriceContainer` |\n| `wishlistNameContainer` |\n| `buttonWishlistName` |\n| `titleWishlistName` |\n| `wishlistName` |\n| `wishlistSearchContainer` |\n| `wishlistProductTexts` |\n| `wishlistSelector` |\n| `wishlistSearchSKUContainer` |\n| `wishlistPrivacyOptionsContainer` |\n| `componentContainer` |\n| `componentContainerHelper` |\n| `addSkuContainer` |\n| `textContainer` |\n| `textContainerTitle` |\n| `textContainerDescription` |\n| `wishlistOptionTexts` |\n| `wishlistCreationOptions` |\n| `wishlistCreateNew` |\n| `wishlistDelete` |\n| `wishlistAddItem` |\n| `wishlistRemoveItem` |\n| `wishlistDeleteWishList` |\n| `wishlistDeleteItem` |\n| `wishlistCreateNewHelper` |\n| `wishlistSearchSKU` |\n| `wishlistSelectListOne` |\n| `wishlistSelectListOneOption` |\n| `wishlistSelectListOneText` |\n| `MyWishListsPage` |\n| `containerLinkShare` |\n| `popupCopy` |\n| `privacySettings` |\n| `createListandAndSelectFav` |\n| `nameAndOptionsMobile` |\n| `optionsMobile` |\n\n<!-- DOCS-IGNORE:start -->\n\n## Contributors ✨\n\nThanks goes to these wonderful people:\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!\n\n<!-- DOCS-IGNORE:end -->\n\n---\n\nCheck out some documentation models that are already live:\n\n- [Breadcrumb](https://github.com/vtex-apps/breadcrumb)\n- [Image](https://vtex.io/docs/components/general/vtex.store-components/image)\n- [Condition Layout](https://vtex.io/docs/components/all/vtex.condition-layout@1.1.6/)\n- [Add To Cart Button](https://vtex.io/docs/components/content-blocks/vtex.add-to-cart-button@0.9.0/)\n- [Store Form](https://vtex.io/docs/components/all/vtex.store-form@0.3.4/)\n\n```"
}
] |
code_wish-list-v2_cdd57f39
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/graphql/schema.graphql from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\n# To really understand GraphQL, go to https://graphql.org/learn/\n\ntype Wishlist {\n id: ID\n email: String\n wishlistType: String\n products: [Products]\n isPublic: Boolean\n fieldsConfig: FieldsConfig\n createdIn: String\n}\n\ninput WishlistInput {\n id: ID\n wishlistType: String\n products: [ProductsInput]\n isPublic: Boolean\n fieldsConfig: FieldsConfigInput\n}\n\ninput FieldsConfigInput {\n department: String\n description: String\n}\n\ntype FieldsConfig {\n department: String\n description: String\n}\n\ninput ProductsInput {\n ID: Int\n Image: String\n linkProduct: String\n nameProduct: String\n quantityProduct: Int\n skuCodeReference: String\n department: String\n bundle: Int\n notes: String\n unitValue: Float\n}\n\ntype Products {\n ID: Int\n Image: String\n linkProduct: String\n nameProduct: String\n quantityProduct: Int\n skuCodeReference: String\n department: String\n bundle: Int\n notes: String\n}\n\ntype DocumentCreatedResponse {\n Id: String\n Href: String\n DocumentId: String\n}\n\ntype DeleteWishlistResponse {\n id: String\n success: Boolean\n}\n\ntype UpdateWishlistResponse {\n id: String\n success: Boolean\n}\n\ntype DateRange {\n from: String\n to: String\n}\n\ntype FixedPrices {\n tradePolicyId: String\n value: Float\n listPrice: Float\n minQuantity: Int\n dateRange: DateRange\n}\n\ntype Query {\n \"\"\"\n Return a wishlist\n \"\"\"\n getWishlist(id: ID!): Wishlist\n\n \"\"\"\n Returns a list of wishlist by email user\n \"\"\"\n getWishlistsByEmail(page: Int, pageSize: Int): [Wishlist]\n}\n\ntype Mutation {\n \"\"\"\n Create a new wishlist\n \"\"\"\n createWishlist(wishlist: WishlistInput!): DocumentCreatedResponse\n\n \"\"\"\n Update a existing wishlist\n \"\"\"\n updateWishlist(wishlist: WishlistInput): UpdateWishlistResponse\n\n \"\"\"\n Delete a wishlist\n \"\"\"\n deleteWishlist(id: ID!): DeleteWishlistResponse\n}\n\n```"
}
] |
code_wish-list-v2_a4dbd388
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/service.json from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"memory\": 256,\n \"ttl\": 10,\n \"timeout\": 5,\n \"minReplicas\": 2,\n \"maxReplicas\": 5\n}\n\n```"
}
] |
code_wish-list-v2_981ff819
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/package.json from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"@graphql-tools/schema\": \"^10.0.3\",\n \"@graphql-tools/utils\": \"^10.1.2\",\n \"@vtex/clients\": \"^2.21.0\",\n \"graphql\": \"^16.8.1\",\n \"graphql-tools\": \"^9.0.1\",\n \"ramda\": \"^0.26.1\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^12.0.0\",\n \"@types/ramda\": \"types/npm-ramda#dist\",\n \"@vtex/api\": \"6.48.0\",\n \"@vtex/test-tools\": \"^3.4.3\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"typescript\": \"3.9.7\",\n \"vtex.apps-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.apps-graphql@3.17.4/public/@types/vtex.apps-graphql\",\n \"vtex.checkout-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.checkout-graphql@0.67.1/public/@types/vtex.checkout-graphql\",\n \"vtex.checkout-resources\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.checkout-resources@0.50.0/public/@types/vtex.checkout-resources\",\n \"vtex.css-handles\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.css-handles@1.0.1/public/@types/vtex.css-handles\",\n \"vtex.my-account\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.my-account@1.29.0/public/@types/vtex.my-account\",\n \"vtex.my-account-commons\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.my-account-commons@1.7.2/public/@types/vtex.my-account-commons\",\n \"vtex.order-items\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.order-items@0.14.0/public/@types/vtex.order-items\",\n \"vtex.order-manager\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.order-manager@0.12.0/public/@types/vtex.order-manager\",\n \"vtex.pixel-manager\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.pixel-manager@1.9.0/public/@types/vtex.pixel-manager\",\n \"vtex.product-context\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.product-context@0.10.1/public/@types/vtex.product-context\",\n \"vtex.quickorder\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.quickorder@3.16.0/public/@types/vtex.quickorder\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.134.11/public/@types/vtex.render-runtime\",\n \"vtex.search-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.search-graphql@0.65.0/public/@types/vtex.search-graphql\",\n \"vtex.store\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store@2.137.3/public/@types/vtex.store\",\n \"vtex.store-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-graphql@2.172.1/public/@types/vtex.store-graphql\",\n \"vtex.store-icons\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-icons@0.18.0/public/@types/vtex.store-icons\",\n \"vtex.store-resources\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-resources@0.101.0/public/@types/vtex.store-resources\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.146.13/public/@types/vtex.styleguide\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit && tslint -c tslint.json './**/*.ts'\"\n },\n \"version\": \"2.3.12\"\n}\n\n```"
}
] |
code_wish-list-v2_9955ab5a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/index.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { ParamsContext, RecorderState, ServiceContext } from '@vtex/api'\nimport { Service } from '@vtex/api'\n\nimport { Clients } from './clients'\nimport { mutations, queries, resolvers } from './resolvers'\n\nconst MEDIUM_TIMEOUT_MS = 5 * 1000\n\ndeclare global {\n // We declare a global Context type just to avoid re-writing ServiceContext<Clients, State> in every handler and resolver\n type Context = ServiceContext<Clients>\n}\n\n// Export a service that defines resolvers and clients' options\nexport default new Service<Clients, RecorderState, ParamsContext>({\n clients: {\n implementation: Clients,\n options: {\n default: {\n timeout: MEDIUM_TIMEOUT_MS,\n },\n },\n },\n graphql: {\n resolvers: {\n ...resolvers,\n Mutation: {\n ...mutations,\n },\n Query: {\n ...queries,\n },\n },\n },\n})\n\n```"
}
] |
code_wish-list-v2_7915d2fe
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/MyWishListsPage.jsx from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```jsx\nimport React from 'react'\nimport { Route } from 'vtex.my-account-commons/Router'\n\nimport MyWishLists from './components/MyWishLists'\nimport styles from './styles.css'\n\nconst MyWishListsPage = () => (\n <div className={styles.MyWishListsPage}>\n <Route path=\"/my-wishlists\" exact component={MyWishLists} />\n </div>\n)\n\nexport default MyWishListsPage\n\n```"
}
] |
code_wish-list-v2_3aec5f4e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/styles.css from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n:global(.ReactVirtualized__Grid__innerScrollContainer)\n :global(.flex .items-center .w-100 .h-100) {\n height: 100% !important;\n text-align: center !important;\n}\n\n.wishlistNameContainer {\n display: flex;\n justify-content: flex-start;\n}\n\n.buttonWishlistName {\n color: #ffffff;\n background-color: #002266;\n margin-left: 1em;\n text-transform: capitalize;\n border-radius: 50px;\n border-color: transparent;\n font-weight: 700;\n cursor: pointer;\n padding: 3px;\n width: 81px;\n}\n\n.titleWishlistName {\n margin-bottom: 10px;\n border: 2px solid #e3e4e6;\n border-radius: 4px;\n text-align: -webkit-center;\n}\n\n:global(.ReactVirtualized__Grid__innerScrollContainer) :global(span) {\n text-align: center !important;\n width: 100% !important;\n}\n\n:global(.ReactVirtualized__Grid__innerScrollContainer)\n .wishlistProductUnitValue {\n text-align: right !important;\n padding-right: 5px;\n}\n\n:global(.ReactVirtualized__Grid__innerScrollContainer) :global(div > a) {\n justify-content: center;\n display: flex;\n}\n\n/* :global(.ReactVirtualized__Grid__innerScrollContainer) > :global(div):nth-child(3) > :global(div) {\n width: auto;\n}\n\n:global(.ReactVirtualized__Grid__innerScrollContainer) > :global(div):nth-child(4) > :global(span) {\n width: auto !important;\n}\n\n:global(.ReactVirtualized__Grid__innerScrollContainer) > :global(div):nth-child(5) > :global(div) {\n width: auto;\n} */\n\n.wishlistSearchContainer :global(.vtex-input-prefix__group) {\n display: flex;\n align-items: center;\n border-radius: 0.3125rem;\n border: 2px solid #e3e4e6;\n height: 2.375rem;\n}\n\n.wishlistSearchContainer :global(.vtex-styleguide-9-x-input) {\n border-right: 0.125rem solid #e3e4e6;\n height: 100%;\n}\n\n.wishlistSearchContainer\n :global(.vtex-input-prefix__group)\n :global(.vtex-input__suffix) {\n width: 1.375rem;\n height: 1.375rem;\n padding: 0 0.5rem;\n height: 100%;\n}\n\n.wishlistSearchContainer\n :global(.vtex-input-prefix__group)\n :global(.vtex-input__suffix)\n div\n div {\n display: none;\n}\n\n.wishlistSearchContainer\n :global(.vtex-input-prefix__group)\n :global(.vtex-input__suffix)\n span {\n padding: 0;\n}\n\n.wishlistSearchContainer\n :global(.vtex-input-prefix__group)\n :global(.vtex-input__suffix)\n svg {\n width: 0.8125rem;\n color: #002266;\n}\n\n.wishlistSearchContainer\n :global(.vtex-input-prefix__group)\n :global(.vtex__icon-clear) {\n margin-left: 0.375rem;\n}\n\n.wishlistSearchContainer\n :global(.vtex-table__container)\n > div:nth-child(2)\n button {\n color: #002266;\n}\n\n:global(#toggleFieldsBtn) :global(.vtex-button__label) > span {\n color: #002266;\n}\n\n:global(#toggleFieldsBtn) :global(.vtex-button__label) > span:first-child {\n display: none;\n}\n\n:global(.ReactVirtualized__Grid__innerScrollContainer) :global(div > a > img) {\n width: 75% !important;\n display: flex;\n justify-content: center !important;\n}\n\n:global(.ReactVirtualized__Grid__innerScrollContainer)\n :global(div):nth-child(4) {\n justify-content: initial !important;\n}\n\n.wishlistName {\n font-size: 35px;\n font-weight: 700;\n margin-right: 3em;\n text-transform: capitalize;\n cursor: pointer;\n}\n\n.wishlistProductTexts,\n.wishlistProductTexts a {\n font-weight: 400;\n color: #000000;\n text-decoration: none;\n}\n\n:global(.ReactVirtualized__Grid__innerScrollContainer) :global(div) {\n text-align: center;\n}\n:global(.ReactVirtualized__Grid__innerScrollContainer)\n :global(.vtex-numeric-stepper__plus-button),\n:global(.vtex-numeric-stepper__minus-button) {\n border: none !important;\n}\n\n:global(.ReactVirtualized__Grid__innerScrollContainer)\n :global(.vtex-numeric-stepper__minus-button__text),\n:global(.vtex-numeric-stepper__plus-button__text) {\n font-size: 20px !important;\n font-weight: 700 !important;\n}\n\n:global(.ReactVirtualized__Grid__innerScrollContainer)\n :global(.vtex-numeric-stepper__input) {\n width: 50px !important;\n}\n\n.wishlistSelector {\n width: 100%;\n align-items: baseline;\n}\n.wishlistSelector label {\n display: flex;\n justify-content: flex-start;\n align-items: center;\n width: fit-content;\n height: 30px;\n}\n\n.wishlistSelector,\n.wishlistSearchSKUContainer :global(.vtex-input),\n.wishlistPrivacyOptionsContainer,\n.wishlistSearchContainer :global(.vtex-input) {\n display: flex;\n align-items: center;\n}\n\n.wishlistSelector :global(.vtex-dropdown__container),\n.wishlistPrivacyOptionsContainer :global(.vtex-dropdown__container) {\n height: 30px !important;\n}\n\n.wishlistSelector :global(.vtex-dropdown__button),\n.wishlistPrivacyOptionsContainer :global(.vtex-dropdown__button),\n.wishlistSearchSKUContainer :global(.vtex-input-prefix__group) {\n width: 400px !important;\n height: 30px !important;\n padding: 5px 0 8px 10px;\n}\n\n.wishlistSearchSKUContainer :global(.vtex-input-prefix__group) {\n padding: 0 !important;\n}\n\n.wishlistSearchContainer :global(.vtex-input-prefix__group) {\n width: 30%;\n}\n\n.wishlistSelector :global(.vtex-dropdown__label),\n.wishlistSearchSKUContainer :global(.vtex-input__label),\n.wishlistSearchContainer :global(.vtex-input__label),\n.textContainerTitle {\n font-family: Roboto, HelveticaNeue, 'Helvetica Neue', sans-serif, Inter !important;\n font-weight: 700 !important;\n font-size: 16px;\n line-height: 30.26px !important;\n color: #7a8094 !important;\n width: fit-content !important;\n margin-right: 3em;\n width: 196.8px !important;\n}\n\n.wishlistSearchContainer :global(.vtex-input__label) {\n margin-right: 0;\n}\n\n.componentContainer {\n float: inline-start !important;\n width: 328px !important;\n}\n\n@media (max-width: 1290px) {\n .componentContainer {\n width: 100% !important;\n }\n}\n\n@media (max-width: 768px) {\n .componentContainer {\n max-width: 100%;\n }\n}\n\n.componentContainerHelper {\n padding-left: 0 !important;\n padding-right: 0 !important;\n}\n\n.componentContainerHelper {\n width: 100%;\n padding: 0 !important;\n}\n\n.addSkuContainer {\n display: flex;\n margin-top: 1rem;\n}\n\n.componentContainerHelper label div {\n border-top-right-radius: 0.25rem;\n border-bottom-right-radius: 0.25rem;\n}\n\n.componentContainerHelper :global(.vtex__icon-search) {\n color: #026 !important;\n}\n.textContainer {\n min-width: 150px;\n width: 150px;\n display: flex;\n align-items: center;\n}\n\n.textContainerTitle {\n width: fit-content !important;\n max-width: 196.8px !important;\n margin: 0;\n margin-top: 0;\n}\n\n.textContainerDescription {\n display: none;\n}\n\n.wishlistSearchContainer :global(.w-40) {\n display: flex;\n justify-content: flex-start;\n width: 100%;\n}\n\n.wishlistSearchContainer :global(.vtex-input__label) {\n width: 196.8px !important;\n max-width: 191px;\n margin-right: 1.75rem !important;\n}\n\n.wishlistOptionTexts {\n font-family: Roboto, HelveticaNeue, 'Helvetica Neue', sans-serif, Inter;\n font-weight: 700;\n font-size: 18px;\n line-height: 30.26px;\n color: #7a8094;\n margin-right: 3em;\n display: inline-block;\n width: 132px !important;\n}\n\n.wishlistCreationOptions {\n display: flex;\n justify-content: space-around;\n width: fit-content;\n margin-left: 1.5rem;\n align-items: center;\n width: 100%;\n}\n.wishlistCreateWishlistUI{\n}\n.wishlistCreateWishlistPageTitle {\n}\n.wishlistCreateNew,\n.wishlistDelete,\n.wishlistAddItem,\n.wishlistRemoveItem {\n text-transform: capitalize;\n border-radius: 50px;\n border-color: transparent;\n font-weight: 700;\n cursor: pointer;\n padding: 3px;\n width: 140px;\n}\n\n.wishlistDeleteWishList {\n color: #ffffff;\n width: auto;\n border: none;\n background-color: red;\n cursor: pointer;\n margin-left: 1em;\n height: 2.375rem;\n border-radius: 50px;\n text-transform: capitalize;\n border-radius: 50px;\n border-color: transparent;\n font-weight: 700;\n padding: 12px;\n}\n.wishlistDeleteItem {\n color: rgb(71, 71, 71);\n width: 50px;\n border: none;\n background-color: #ffffff;\n cursor: pointer;\n}\n\n.wishlistAddItem {\n margin: 0 !important;\n width: 100px;\n}\n\n.wishlistRemoveItem {\n width: 150px;\n}\n\n.wishlistAddItem,\n.wishlistDeleteItem {\n border-radius: 50px;\n width: 100px;\n}\n\n.wishlistCreateNew,\n.wishlistAddItem {\n color: #ffffff;\n background-color: #002266;\n}\n\n.wishlistCreateNewHelper {\n margin-right: 5px;\n}\n.wishlistCreateNew {\n width: auto;\n height: 2.375rem;\n}\n\n.wishlistAddItem {\n margin-right: 3em;\n}\n\n.wishlistDelete,\n.wishlistRemoveItem {\n color: #ffffff;\n background-color: #f60000;\n}\n\n.wishlistSearchSKU {\n height: 30px;\n width: 405px;\n border-radius: 10px;\n border: 1.8px solid #cacbcc;\n padding-left: 15px;\n}\n.wishlistSelectListTitle{}\n.wishlistSelectListOne {\n cursor: pointer;\n width: 100%;\n height: 40px !important;\n padding: 5px 10px;\n border-width: 2px;\n border-style: solid;\n border-color: #e3e4e6;\n box-sizing: border-box;\n font-size: 16px;\n outline: none;\n color: #979899;\n border-radius: 0.25rem;\n}\n\n.wishlistSelectListOne .wishlistSelectListOneOption {\n cursor: pointer;\n}\n.wishlistSelectListOne:hover {\n border-color: #cacbcc;\n}\n\n.wishlistSelectListOneText {\n font-family: Roboto, HelveticaNeue, 'Helvetica Neue', sans-serif, Inter !important;\n font-weight: 700 !important;\n font-size: 18px;\n min-width: 150px !important;\n color: #7a8094;\n}\n\n.wishlistSelectListOneOption {\n color: black;\n}\n\n.MyWishListsPage {\n padding: 0 20px 0 20px;\n font-size: 12px;\n max-width: 1100px;\n}\n\n.wishlistCreateNew {\n padding: 10px;\n}\n.containerLinkShare {\n position: relative;\n margin: 0;\n}\n\n.image--copy {\n max-width: none;\n}\n\n.popupCopy {\n position: absolute;\n right: 0;\n top: 2rem;\n color: #fff;\n background-color: #264d9e;\n padding: 0.3rem;\n}\n\n.popupCopy::before {\n content: '';\n position: absolute;\n bottom: 100%;\n right: 20%;\n border-width: 5px;\n border-style: solid;\n border-color: transparent transparent #264d9e transparent;\n}\n\n.url--link {\n margin-right: 0.6rem;\n}\n\n.privacySettings :global(.vtex-styleguide-9-x-dropdown) {\n margin-left: 3.5em !important;\n}\n\n.wishlistSearchSKUContainer :global(.vtex-input-prefix__group) {\n margin-left: 3.5em;\n height: 40px !important;\n width: 303px !important;\n}\n\n.wishlistSearchContainer :global(.vtex-input-prefix__group) {\n width: 100%;\n margin-left: -2em;\n height: 2.375rem;\n}\n\n.wishlistSearchContainer :global(.w-40),\n#toolbar {\n position: relative;\n}\n\n:global(#toolbar) {\n flex-direction: column !important;\n}\n\n.importList__generalContainer {\n margin: 24px 64px 64px;\n}\n\n.importList__buttonContainer {\n position: relative;\n}\n\n.importList__modalContainer {\n position: absolute;\n top: 0;\n right: -10px;\n transform: translateX(100%);\n z-index: 9;\n}\n\n.wishlistOptionsContainer {\n display: flex;\n align-items: center;\n}\n\n.wishlistSearchContainer :global(.vtex-input) {\n margin-top: 0;\n}\n\n.addSkuContainer .text-container {\n max-width: 140px;\n}\n\n/* Edit View button styles */\n:global(#toggleFieldsBtn) {\n top: 3.15rem;\n border: 1px solid #e3e4e6;\n border-radius: 0.25rem;\n min-height: 28.09px !important;\n margin-left: 32rem;\n height: 1.875rem;\n}\n\n:global(.edit-view-text) {\n text-transform: capitalize;\n font-size: 14px;\n color: #9ba0ae;\n opacity: 1;\n position: relative;\n top: -1px;\n width: auto;\n}\n\n.createListandAndSelectFav {\n display: flex;\n width: 100%;\n column-gap: 2rem;\n}\n\n.nameAndOptionsMobile {\n display: flex;\n width: 100%;\n justify-content: space-between;\n}\n\n.optionsMobile {\n display: flex;\n column-gap: 1rem;\n align-items: center;\n}\n\n.quickOrderAutocompleteItemsWrapper {\n row-gap: 0.5rem;\n padding: .75rem;\n}\n\n.quickOrderAutocompleteItems {\n gap: 0.5rem;\n}\n\n.productThumb {\n min-width: 50px;\n}\n\n.productTitle {\n display: -webkit-box;\n max-width: 130px;\n -webkit-line-clamp: 4;\n -webkit-box-orient: vertical;\n overflow: hidden;\n text-wrap: wrap;\n}\n\n.productSku {\n flex-wrap: wrap;\n gap: 0.5rem;\n}\n\n.productLabel {\n width: 100%;\n justify-content: space-between;\n}\n\n.quickOrderAutocomplete {\n flex-direction: column;\n width: 100%;\n gap: 0.5rem;\n}\n\n.addToFavouritebutton {\n max-width: 7rem;\n height: 3rem;\n}\n\n.buttonClearWrapper {\n width: fit-content;\n padding-left: .5rem;\n}\n\n.buttonClear {\n width: fit-content;\n}\n\n.buttonClear :global(.vtex-button) {\n width: fit-content;\n}\n\n.buttonClear :global(.vtex-button__label) {\n padding: 0;\n width: fit-content;\n}\n\n@media screen and(min-width: 1300px) {\n .wishlistCreationOptions {\n margin-left: -4em;\n }\n}\n@media screen and (min-width: 1291px) {\n .wishlistSelectListOneText {\n width: unset !important;\n margin: 0;\n }\n\n .wishlistSelectListOne {\n width: 310px;\n }\n\n .wishlistCreationOptions {\n justify-content: flex-start;\n margin-left: -4em;\n }\n\n .wishlistCreateNewHelper {\n margin-right: 1em;\n }\n\n .componentContainerHelper {\n padding: 0 !important;\n width: 310px;\n }\n\n .textContainerTitle {\n margin-top: 0rem;\n }\n\n .wishlistSearchContainer :global(.vtex-input-prefix__group) {\n width: 310px;\n }\n .wishlistSearchContainer :global(.vtex-input__label) {\n margin-right: 0 !important;\n width: 174px !important;\n margin-bottom: 0;\n }\n}\n@media (max-width: 1024px) {\n .importList__generalContainer {\n margin: 24px 15px 30px;\n }\n .wishlistOptionsContainer {\n display: flex;\n flex-direction: column-reverse;\n }\n .componentContainer {\n /* margin-left: 1.8em; */\n width: 100% !important;\n }\n .wishlistCreationOptions {\n justify-content: flex-start;\n margin-left: 0;\n }\n}\n\n@media (max-width: 768px) {\n .wishlistDeleteWishList {\n margin-left: 0.5em;\n padding: 6px 5.3px 6px;\n font-size: 12.5px;\n }\n .wishlistSearchSKUContainer :global(.vtex-input),\n .wishlistPrivacyOptionsContainer,\n .wishlistSearchContainer :global(.vtex-input) {\n margin-bottom: 1em;\n }\n\n .wishlistCreationOptions {\n justify-content: space-between;\n }\n\n .textContainerTitle {\n margin-top: 0;\n }\n\n .componentContainerHelper {\n padding: 0 !important;\n }\n\n .wishlistSearchContainer :global(.vtex-input__label),\n .textContainer,\n .textContainerTitle,\n .wishlistSelectListOneText {\n width: 100% !important;\n max-width: 100% !important;\n margin: 0.5em 0;\n }\n\n .wishlistCreateNewHelper {\n margin-right: 4.5px;\n }\n\n .wishlistCreateNew {\n padding: 6px 5.3px 6px;\n font-size: 12.5px;\n }\n\n .wishlistOptionsContainer {\n display: flex;\n flex-direction: column-reverse;\n }\n .componentContainer {\n float: none !important;\n width: 100% !important;\n margin-left: 0 !important;\n padding-left: 0 !important;\n }\n\n .wishlistSearchContainer :global(.w-40),\n #toolbar {\n position: unset;\n }\n\n .wishlistSelector {\n flex-direction: column !important;\n align-items: flex-start;\n }\n\n .wishlistSelectListOne {\n width: 100% !important;\n }\n\n .wishlistCreationOptions {\n margin: 0;\n }\n\n .wishlistPrivacyOptionsContainer {\n height: max-content !important;\n }\n\n .containerLinkShare {\n padding: 0;\n margin: 0;\n }\n\n .url--link {\n margin-bottom: 0;\n }\n\n .wishlistOptionTexts {\n width: 100% !important;\n margin: 0;\n }\n\n .wishlistSearchSKUContainer :global(.vtex-input),\n .wishlistSearchContainer :global(.vtex-input),\n .privacySettings,\n .wishlistPrivacyOptionsContainer {\n display: flex !important;\n flex-direction: column !important;\n align-items: flex-start !important;\n }\n\n .wishlistSelector :global(.vtex-dropdown__button),\n .wishlistPrivacyOptionsContainer :global(.vtex-dropdown__button),\n .wishlistSearchSKUContainer :global(.vtex-input-prefix__group),\n .wishlistSearchContainer :global(.vtex-input__label),\n .privacySettings,\n .privacySettings :global(.vtex-dropdown__container),\n .wishlistSelector :global(.vtex-dropdown__button),\n .wishlistSearchContainer :global(.vtex-input-prefix__group),\n .wishlistPrivacyOptionsContainer :global(.vtex-dropdown) {\n width: 100% !important;\n }\n\n :global(.vtex-table__container) :global(#toggleFieldsBtn) {\n margin-top: 4.5rem;\n margin-right: 0;\n margin-left: 0;\n }\n\n :global(.vtex-table__container)\n :global(#toggleFieldsBtn)\n :global(.absolute)\n :global(.left-0)\n :global(.z-999)\n :global(.ba)\n :global(.b--muted-4)\n :global(.br2)\n :global(.mt2)\n :global(.mh2) {\n position: absolute !important;\n left: -22em !important;\n }\n\n .wishlistSearchContainer :global(.vtex-table__container) {\n margin-bottom: 2em;\n }\n\n .privacySettings :global(.vtex-styleguide-9-x-dropdown) {\n margin-left: initial !important;\n }\n\n .wishlistSearchSKUContainer :global(.vtex-input-prefix__group) {\n margin-left: initial;\n width: initial !important;\n }\n\n .wishlistSearchContainer :global(.vtex-input-prefix__group) {\n margin-left: initial;\n }\n\n :global(#toolbar) {\n position: relative;\n }\n :global(#toolbar) :global(.w-40) {\n position: absolute;\n width: 100%;\n }\n\n :global(#toolbar) :global(.flex.flex-row.items-center) {\n justify-content: flex-end;\n }\n\n .addSkuContainer {\n flex-direction: column;\n }\n}\n\n.absolute.br--bottom.br2.bb.bl.br.bw1.b--muted-2.bg-base.w-100.z-1.shadow-5 {\n z-index: 9999;\n}\n\n@media (max-width: 640px) {\n .importList__generalContainer {\n margin: 24px 12px 30px;\n }\n\n .importList__modalContainer {\n top: unset;\n right: unset;\n left: 0;\n bottom: -10px;\n transform: translateY(100%);\n z-index: 9;\n }\n\n .wishlistCreateNew,\n .wishlistDeleteWishList {\n height: 2rem;\n width: 4.5rem;\n }\n\n .wishlistName {\n margin-right: 0;\n }\n\n .wishlistSearchContainer :global(.vtex-input__label),\n .textContainerTitle,\n .wishlistSelectListOneText {\n font-size: 1.5625rem;\n }\n}\n\n@media (max-width: 380px) {\n :global(#toolbar) :global(.flex.flex-row.items-center) {\n margin-bottom: 2.5rem;\n }\n :global(#toggleFieldsBtn) {\n margin-top: 2rem !important;\n }\n}\n\n.wishlistSearchContainer {\n margin-top: 1rem;\n}\n\n.skuSelection,\n.skuSelected {\n display: block;\n}\n\n.wishlistShare{\n}\n\n.wishlistProductImage{\n padding: 2px 0;\n max-width: 36px;\n object-fit: contain;\n}\n\n.wishlistShareTableCell,\n.wishlistTableCell{\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n}\n```"
}
] |
code_wish-list-v2_619ee91f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/global.css from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n.vtex-quickorder-2-x-inputQuantity>label>div>input {\n padding-left : 0;\n padding-right: 0;\n text-align : center;\n}\n\n.vtex-button__label .c-on-base {\n display: none;\n}\n\n```"
}
] |
code_wish-list-v2_85282bde
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/WishlistShare.js from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport WishlistShare from './components/WishlistShare'\n\nexport default WishlistShare\n\n```"
}
] |
code_wish-list-v2_55e3febc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/package.json from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"my-wishlists\",\n \"version\": \"2.3.12\",\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"apollo-client\": \"^2.6.8\",\n \"axios\": \"^0.27.0\",\n \"react\": \"^16.12.0\",\n \"react-apollo\": \"^3.1.3\",\n \"react-dom\": \"^16.12.0\",\n \"react-intl\": \"^3.12.0\",\n \"uuid\": \"^9.0.1\",\n \"zustand\": \"^4.4.3\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^3.1.3\",\n \"@types/lodash.debounce\": \"^4.0.9\",\n \"@types/node\": \"^13.9.8\",\n \"@types/react\": \"^16.9.31\",\n \"@vtex/test-tools\": \"^3.3.2\",\n \"@vtex/tsconfig\": \"^0.4.4\",\n \"apollo-cache-inmemory\": \"^1.6.5\",\n \"graphql\": \"^14.6.0\",\n \"typescript\": \"3.9.7\",\n \"vtex.apps-graphql\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.apps-graphql@3.17.4/public/@types/vtex.apps-graphql\",\n \"vtex.checkout-graphql\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.checkout-graphql@0.67.1/public/@types/vtex.checkout-graphql\",\n \"vtex.checkout-resources\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.checkout-resources@0.50.0/public/@types/vtex.checkout-resources\",\n \"vtex.css-handles\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.css-handles@1.0.1/public/@types/vtex.css-handles\",\n \"vtex.my-account\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.my-account@1.29.0/public/@types/vtex.my-account\",\n \"vtex.my-account-commons\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.my-account-commons@1.7.2/public/@types/vtex.my-account-commons\",\n \"vtex.order-items\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.order-items@0.14.0/public/@types/vtex.order-items\",\n \"vtex.order-manager\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.order-manager@0.12.0/public/@types/vtex.order-manager\",\n \"vtex.pixel-manager\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.pixel-manager@1.9.0/public/@types/vtex.pixel-manager\",\n \"vtex.product-context\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.product-context@0.10.1/public/@types/vtex.product-context\",\n \"vtex.quickorder\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.quickorder@3.16.0/public/@types/vtex.quickorder\",\n \"vtex.render-runtime\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.134.11/public/@types/vtex.render-runtime\",\n \"vtex.search-graphql\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.search-graphql@0.65.0/public/@types/vtex.search-graphql\",\n \"vtex.store\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.store@2.137.3/public/@types/vtex.store\",\n \"vtex.store-graphql\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-graphql@2.172.1/public/@types/vtex.store-graphql\",\n \"vtex.store-icons\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-icons@0.18.0/public/@types/vtex.store-icons\",\n \"vtex.store-resources\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-resources@0.101.0/public/@types/vtex.store-resources\",\n \"vtex.styleguide\": \"https://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.146.13/public/@types/vtex.styleguide\"\n },\n \"resolutions\": {\n \"@types/jest\": \"26.0.15\"\n }\n}\n\n```"
}
] |
code_wish-list-v2_2e6c6b93
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/ButtonWishlist.tsx from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport ButtonWishlist from './components/buttonWishlist/ButtonWishlist'\n\nexport default ButtonWishlist\n\n```"
}
] |
code_wish-list-v2_37e01bc5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/MyWishListsLink.js from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\nimport { intlShape, injectIntl } from 'react-intl'\n\nconst MyWishListsLink = ({ render, intl }) => {\n return render([\n {\n name: intl.formatMessage({ id: 'Favorites Lists' }),\n path: '/my-wishlists',\n },\n ])\n}\n\nMyWishListsLink.propTypes = {\n render: PropTypes.func.isRequired,\n intl: intlShape.isRequired,\n}\n\nexport default injectIntl(MyWishListsLink)\n\n```"
}
] |
code_wish-list-v2_6ecf917c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/store/interfaces.json from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"button-wishlist-pdp\": {\n \"component\": \"ButtonWishlist\",\n \"render\": \"client\"\n },\n \"my-account-link.my-wishlists-link\": {\n \"component\": \"MyWishListsLink\"\n },\n \"my-account-page.my-wishlists-page\": {\n \"component\": \"MyWishListsPage\"\n },\n \"wishlist-share\": {\n \"component\": \"WishlistShare\"\n }\n}\n\n```"
}
] |
code_wish-list-v2_bfc94be1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/store/plugins.json from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"my-account-pages > my-account-page\": \"my-account-page.my-wishlists-page\",\n \"my-account-menu > my-account-link\": \"my-account-link.my-wishlists-link\"\n}\n```"
}
] |
code_wish-list-v2_e838292d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/masterdata/myWishlist/schema.json from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"$schema\": \"https://json-schema.org/draft-07/schema#\",\n \"title\": \"wishlist\",\n \"type\": \"object\",\n \"properties\": {\n \"email\": {\n \"type\": \"string\",\n \"format\": \"email\"\n },\n \"wishlistType\": {\n \"type\": \"string\"\n },\n \"products\": {\n \"type\": \"array\"\n },\n \"isPublic\": {\n \"type\": \"boolean\"\n },\n \"fieldsConfig\": {\n \"type\": \"array\"\n }\n },\n \"required\": [\"email\", \"wishlistType\", \"products\", \"isPublic\", \"fieldsConfig\"],\n \"v-indexed\": [\n \"email\",\n \"wishlistType\",\n \"products\",\n \"isPublic\",\n \"fieldsConfig\"\n ],\n \"v-default-fields\": [\n \"email\",\n \"wishlistType\",\n \"products\",\n \"isPublic\",\n \"fieldsConfig\"\n ],\n \"v-cache\": false,\n \"v-immediate-indexing\": true\n}\n\n```"
}
] |
code_wish-list-v2_c4f8fb16
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/clients/masterdata.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext, RequestConfig } from '@vtex/api'\nimport { JanusClient } from '@vtex/api'\n\nimport { DATA_ENTITY_NAME, FIELDS, SCHEMA_NAME } from '../utils/constant'\nimport { Wishlist } from '../typings/wishlist'\n\nexport default class MasterDataClient extends JanusClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(context, {\n ...options,\n headers: {\n ...options?.headers,\n VtexIdclientAutCookie: context.authToken,\n Accept: 'application/vnd.vtex.pricing.v3+json',\n 'Cache-Control': 'no-cache',\n 'Content-Type': 'application/json',\n },\n })\n }\n\n public async getWishlist(id: string): Promise<Wishlist> {\n return this.http.get(\n `/api/dataentities/${DATA_ENTITY_NAME}/documents/${id}?_fields=${FIELDS}&_schema=${SCHEMA_NAME}`\n )\n }\n\n public async searchWistlist(\n field: string,\n value: string,\n pagination?: { page: number; pageSize: number }\n ): Promise<Wishlist[]> {\n const { page, pageSize } = pagination ?? {}\n\n return this.http.get(\n `/api/dataentities/${DATA_ENTITY_NAME}/search?_where=${field}=\"${value}\" &_fields=${FIELDS}&_sort=createdIn&_schema=${SCHEMA_NAME}`,\n {\n headers: {\n 'REST-Range': `resources=${page ?? 0}-${pageSize ?? 100}`,\n },\n }\n )\n }\n\n public async searchForExistingWishList(\n where: string,\n pagination?: { page: number; pageSize: number }\n ): Promise<Wishlist[] | null> {\n const { page, pageSize } = pagination ?? {}\n\n const config: RequestConfig = {\n headers: {\n 'REST-Range': `resources=${page ?? 0}-${pageSize ?? 100}`,\n },\n retries: 1,\n initialBackoffDelay: 2000,\n exponentialBackoffCoefficient: 2,\n verbose: true,\n }\n\n try {\n return this.http.get(\n `/api/dataentities/${DATA_ENTITY_NAME}/search?_where=${where} &_fields=${FIELDS}&_sort=createdIn&_schema=${SCHEMA_NAME}`,\n config\n )\n } catch (err) {\n throw new Error(err)\n }\n }\n\n public async createWishlist(payload: Wishlist) {\n return this.http.post(\n `/api/dataentities/${DATA_ENTITY_NAME}/documents?_schema=${SCHEMA_NAME}`,\n payload\n )\n }\n\n public async updateWishlist(id: string, payload: Wishlist) {\n return this.http.patch(\n `/api/dataentities/${DATA_ENTITY_NAME}/documents/${id}?_schema=${SCHEMA_NAME}`,\n payload\n )\n }\n\n public async deleteWishlist(id: string) {\n return this.http.delete(\n `/api/dataentities/${DATA_ENTITY_NAME}/documents/${id}?_schema=${SCHEMA_NAME}`\n )\n }\n}\n\n```"
}
] |
code_wish-list-v2_cce3aadf
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/clients/vtexId.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { JanusClient } from '@vtex/api'\n\ninterface AuthenticatedUser {\n userId: string\n user: string\n}\n\nexport default class VtexId extends JanusClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(context, {\n ...options,\n headers: {\n VtexIdclientAutCookie: context.authToken,\n ...options?.headers,\n 'x-vtex-user-agent': context.userAgent,\n },\n })\n }\n\n public async getAuthenticatedUser(\n authToken: string\n ): Promise<AuthenticatedUser> {\n return this.http.get('/api/vtexid/pub/authenticated/user/', {\n metric: 'authenticated-user-get',\n params: { authToken },\n })\n }\n}\n\n```"
}
] |
code_wish-list-v2_5b1a43b2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/clients/index.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\nimport { masterDataFor } from '@vtex/clients'\n\nimport { Wishlist } from '../typings/wishlist'\nimport MasterDataClient from './masterdata'\nimport VtexId from './vtexId'\nimport { DATA_ENTITY_NAME } from '../utils/constant'\nimport RequestHub from '../utils/HUB'\n\nexport class Clients extends IOClients {\n public get wishlist() {\n return this.getOrSet(\n 'wishlist',\n masterDataFor<Wishlist>(DATA_ENTITY_NAME, undefined, 2)\n )\n }\n\n public get md() {\n return this.getOrSet('md', MasterDataClient)\n }\n\n public get vtexId() {\n return this.getOrSet('vtexId', VtexId)\n }\n\n public get hub() {\n return this.getOrSet('hub', RequestHub)\n }\n}\n\n```"
}
] |
code_wish-list-v2_69b6ce8d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/middleware/auth.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { AuthenticationError } from '@vtex/api'\n\nexport const auth = async (ctx: Context) => {\n const {\n cookies,\n clients: { vtexId },\n } = ctx\n\n let email = cookies.get('vtex-impersonated-customer-email') as string\n\n if (!email) {\n const cookie = cookies.get(\n `VtexIdclientAutCookie_${ctx.vtex.account}`\n ) as string\n\n if (!cookie) {\n throw new AuthenticationError('Unauthorized access')\n }\n\n const user = await vtexId.getAuthenticatedUser(cookie)\n\n if (!user?.userId) {\n throw new AuthenticationError('Unauthorized access')\n }\n\n email = user.user\n }\n\n return { email }\n}\n\n```"
}
] |
code_wish-list-v2_f36367c4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/middleware/configuration.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { Apps } from '@vtex/api'\n\nimport { DATA_ENTITY_NAME, SCHEMA, SCHEMA_NAME } from '../utils/constant'\n\nconst getAppId = (): string => {\n return process.env.VTEX_APP_ID ?? ''\n}\n\nconst routes = {\n baseUrl: (account: string) =>\n `http://${account}.vtexcommercestable.com.br/api`,\n wishListEntity: (account: string, entity: string) =>\n `${routes.baseUrl(account)}/dataentities/${entity}`,\n saveSchema: (account: string, schema_version: string, entity: string) =>\n `${routes.wishListEntity(account, entity)}/schemas/${schema_version}`,\n}\n\nconst defaultHeaders = (authToken: string) => ({\n 'Content-Type': 'application/json',\n Accept: 'application/vnd.vtex.ds.v10+json',\n VtexIdclientAutCookie: authToken,\n 'Proxy-Authorization': authToken,\n})\n\nconst defaultSettings = {\n adminSetup: {\n storeLogoUrl: '',\n hasSchema: false,\n schemaVersion: null,\n },\n}\n\nexport const configuration = async (ctx: Context) => {\n const {\n vtex: { account, authToken },\n clients: { hub },\n } = ctx\n\n const apps = new Apps(ctx.vtex)\n const app: string = getAppId()\n let settings = await apps.getAppSettings(app)\n\n if (!settings.adminSetup) {\n settings = defaultSettings\n }\n\n if (\n !settings.adminSetup.hasSchema ||\n settings.adminSetup.schemaVersion !== SCHEMA_NAME\n ) {\n try {\n const url = routes.saveSchema(account, SCHEMA_NAME, DATA_ENTITY_NAME)\n\n const headers = defaultHeaders(authToken)\n\n await hub.put(url, SCHEMA, headers)\n\n settings.adminSetup.hasSchema = true\n settings.adminSetup.schemaVersion = SCHEMA_NAME\n } catch (e) {\n if (e.response.status >= 400) {\n settings.adminSetup.hasSchema = false\n } else {\n settings.adminSetup.hasSchema = true\n settings.adminSetup.schemaVersion = SCHEMA_NAME\n }\n }\n }\n\n await apps.saveAppSettings(app, settings)\n\n return 'settings'\n}\n\n```"
}
] |
code_wish-list-v2_16e81934
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/typings/wishlist.d.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport interface Wishlist {\n id: string\n email: string\n wishlistType: string\n products: Products[]\n isPublic: boolean\n fieldsConfig?: FieldsConfig\n}\n\nexport interface FieldsConfig {\n department: string\n description: string\n}\n\nexport interface Products {\n ID: number\n Image: string\n unitValue: number\n linkProduct: string\n nameProduct: string\n quantityProduct: number\n skuCodeReference: string\n department: string\n bundle: number\n price: number\n notes: string\n}\n\nexport interface WishlistUpdateArs extends Wishlist {\n id: string\n wishlist: Wishlist\n}\n\nexport type WishlistInput = {\n wishlist: Wishlist\n}\n\n```"
}
] |
code_wish-list-v2_a5d3e8c3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/utils/constant.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const FIELDS =\n 'id,email,wishlistType,products,isPublic,fieldsConfig,createdIn'\n\nexport const DATA_ENTITY_NAME = 'myWishlists'\n\nexport const SCHEMA_NAME = '0.0.4-mywishlists'\n\nexport const SCHEMA = {\n properties: {\n email: {\n type: 'string',\n format: 'email',\n },\n wishlistType: {\n type: 'string',\n },\n products: {\n type: 'array',\n },\n isPublic: {\n type: 'boolean',\n },\n fieldsConfig: {\n type: 'array',\n },\n },\n required: ['email', 'wishlistType', 'products', 'isPublic'],\n 'v-indexed': [\n 'email',\n 'wishlistType',\n 'products',\n 'isPublic',\n 'fieldsConfig',\n ],\n 'v-default-fields': [\n 'email',\n 'wishlistType',\n 'products',\n 'isPublic',\n 'fieldsConfig',\n ],\n 'v-cache': false,\n 'v-immediate-indexing': true,\n 'v-security': {\n allowGetAll: true,\n publicRead: [\n 'id',\n 'email',\n 'wishlistType',\n 'products',\n 'isPublic',\n 'fieldsConfig',\n ],\n },\n}\n\n```"
}
] |
code_wish-list-v2_00b7c583
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/utils/HUB.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { ExternalClient, InstanceOptions, IOContext } from '@vtex/api'\n\ntype Headers = {\n [key: string]: string\n}\n\ntype Data = {\n [key: string]: unknown\n}\n\nexport default class RequestHub extends ExternalClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(\n `http://${context.account}.vtexcommercestable.com.br/api/`,\n context,\n options\n )\n }\n\n public authToken() {\n return this.context.authToken\n }\n\n public account() {\n return this.context.account\n }\n\n public get(url: string, headers?: Headers, data?: Data) {\n return this.http.getRaw(url, {\n headers,\n data,\n })\n }\n\n public post(url: string, data: Data, headers?: Headers) {\n return this.http.postRaw(url, data, {\n headers,\n })\n }\n\n public put(url: string, data: Data, headers?: Headers) {\n return this.http.putRaw(url, data, {\n headers,\n })\n }\n\n public delete(url: string) {\n return this.http.delete(url)\n }\n}\n\n```"
}
] |
code_wish-list-v2_1671dc96
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/resolvers/getWishlist.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { configuration } from '../middleware/configuration'\n\nexport const getWishlist = async (\n _: unknown,\n args: { id: string },\n ctx: Context\n) => {\n const {\n clients: { md },\n } = ctx\n\n const { id } = args\n\n await configuration(ctx)\n\n return md.getWishlist(id)\n}\n\n```"
}
] |
code_wish-list-v2_150b4e3b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/resolvers/getWishlistsByEmail.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { auth } from '../middleware/auth'\nimport { configuration } from '../middleware/configuration'\n\nexport const getWishlistsByEmail = async (\n _: unknown,\n args: {\n email: string\n page: number\n pageSize: number\n },\n ctx: Context\n) => {\n const {\n clients: { md },\n } = ctx\n\n const { page, pageSize } = args\n\n const pagination = {\n page,\n pageSize,\n }\n\n await configuration(ctx)\n const { email } = await auth(ctx)\n\n const wishlists = await md.searchWistlist('email', email, pagination)\n\n return wishlists || null\n}\n\n```"
}
] |
code_wish-list-v2_d1fedd39
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/resolvers/deleteWishlist.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { AuthenticationError } from '@vtex/api'\n\nimport { auth } from '../middleware/auth'\n\nexport const deleteWishlist = async (\n _: unknown,\n args: { id: string },\n ctx: Context\n) => {\n const {\n clients: { md },\n } = ctx\n\n const { id } = args\n\n const { email } = await auth(ctx)\n\n const getWishlist = await md.getWishlist(id)\n\n const existWishlist = getWishlist?.id\n\n if (!existWishlist) {\n throw new Error('An wishlist with this id does not exist')\n }\n\n if (getWishlist?.email !== email) {\n throw new AuthenticationError('Unauthorized access')\n }\n\n await md.deleteWishlist(id)\n\n return {\n id,\n success: true,\n }\n}\n\n```"
}
] |
code_wish-list-v2_00d3cf46
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/resolvers/createWishlist.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { WishlistInput } from '../typings/wishlist'\nimport { auth } from '../middleware/auth'\n\nfunction hasSpecialCharacters(str: string) {\n const specialCharactersRegex = /[!@$%^*(),.?\":{}|<>]/g\n\n return specialCharactersRegex.test(str)\n}\n\nexport const createWishlist = async (\n _: unknown,\n args: WishlistInput,\n ctx: Context\n) => {\n const {\n clients: { md },\n } = ctx\n\n const { wishlistType } = args?.wishlist || {}\n\n const { email } = await auth(ctx)\n\n if (hasSpecialCharacters(wishlistType)) {\n throw new Error(\n `An error occurred. No special characters are allowed in the name.`\n )\n }\n\n const foundWishlist = await md.searchForExistingWishList(\n `wishlistType = \"${encodeURIComponent(wishlistType)}\" AND email = ${email}`\n )\n\n const existWishlistName = foundWishlist && foundWishlist.length > 0\n\n if (existWishlistName) {\n throw new Error(`Already exist wishlist with name ${wishlistType}`)\n }\n\n const wishlist = {\n ...args?.wishlist,\n email,\n }\n\n return md.createWishlist(wishlist)\n}\n\n```"
}
] |
code_wish-list-v2_f7598ae5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/resolvers/updateWishlist.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { AuthenticationError } from '@vtex/api'\n\nimport { auth } from '../middleware/auth'\nimport type { Products, WishlistUpdateArs } from '../typings/wishlist'\n\nexport const updateWishlist = async (\n _: unknown,\n args: WishlistUpdateArs,\n ctx: Context\n) => {\n const {\n clients: { md },\n } = ctx\n\n const { email } = await auth(ctx)\n\n const { wishlist } = args || {}\n\n if (!wishlist?.id) {\n throw new Error('An id must be provided')\n }\n\n const { email: emailUser, id, wishlistType, isPublic, products } =\n (await md.getWishlist(wishlist.id)) || {}\n\n const existWishlist = id\n\n const data = wishlist?.products.map((prod) => {\n const d = products?.find((pro) => pro.ID === prod.ID)\n\n return {\n ...prod,\n quantityProduct: prod.quantityProduct\n ? prod.quantityProduct\n : d?.quantityProduct ?? 1,\n notes: prod.notes ? prod.notes : d?.notes,\n }\n })\n\n if (!existWishlist) {\n throw new Error('An wishlist with this id does not exist')\n }\n\n if (emailUser !== email) {\n throw new AuthenticationError('Unauthorized access')\n }\n\n const updatedWishlist = {\n id,\n email: wishlist?.email || emailUser,\n wishlistType: wishlist?.wishlistType || wishlistType,\n isPublic: wishlist?.isPublic || isPublic,\n products: data as Products[],\n }\n\n await md.updateWishlist(wishlist.id, updatedWishlist)\n\n return {\n id: wishlist.id,\n success: true,\n }\n}\n\n```"
}
] |
code_wish-list-v2_d956f648
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/node/resolvers/index.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { getWishlist } from './getWishlist'\nimport { getWishlistsByEmail } from './getWishlistsByEmail'\nimport { createWishlist } from './createWishlist'\nimport { updateWishlist } from './updateWishlist'\nimport { deleteWishlist } from './deleteWishlist'\n\nexport const mutations = {\n createWishlist,\n updateWishlist,\n deleteWishlist,\n}\n\nexport const queries = {\n getWishlist,\n getWishlistsByEmail,\n}\n\nexport const resolvers = {}\n\n```"
}
] |
code_wish-list-v2_0ad793c6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/context/ProductsContext.tsx from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useCallback, useEffect, useState } from 'react'\n\ntype ProductsContextType = {\n items: any[]\n setItems: React.Dispatch<React.SetStateAction<any[]>>\n updateItem: (item: any) => void\n getItem: (id: string) => any\n updateQuantityBySkuReferenceCode: (\n skuReferenceCode: string,\n quantity: number\n ) => void\n}\n\nconst ProductsContext = React.createContext<ProductsContextType | undefined>(\n undefined\n)\n\nconst ProductsProvider = ({\n children,\n items,\n}: {\n children: React.ReactNode\n items: any[]\n}) => {\n const [localItems, setLocalItems] = useState<any[]>([])\n\n const updateItem = useCallback(\n (item: any) => {\n const index = localItems.findIndex((i) => i.id === item.id)\n const newItems = [...localItems]\n\n newItems[index] = item\n setLocalItems(newItems)\n },\n [localItems, setLocalItems]\n )\n\n const getItem = useCallback(\n (id: string) => {\n return localItems.find((item) => item.itemId === id)\n },\n [localItems]\n )\n\n const updateQuantityBySkuReferenceCode = useCallback(\n (skuReferenceCode: string, quantity: number) => {\n const item = localItems.find(\n (local) => local.skuReferenceCode === skuReferenceCode\n )\n\n if (!item) {\n return\n }\n\n updateItem({ ...item, quantity })\n },\n [localItems, updateItem]\n )\n\n const value = React.useMemo(\n () => ({\n items: localItems,\n setItems: setLocalItems,\n updateItem,\n getItem,\n updateQuantityBySkuReferenceCode,\n }),\n [localItems, updateItem, getItem, updateQuantityBySkuReferenceCode]\n )\n\n useEffect(() => {\n setLocalItems(items)\n }, [items])\n\n return (\n <ProductsContext.Provider value={value}>\n {children}\n </ProductsContext.Provider>\n )\n}\n\nconst useProducts = () => {\n const context = React.useContext(ProductsContext)\n\n if (!context) {\n throw new Error('useProducts must be used within a ProductsProvider')\n }\n\n return context\n}\n\nexport { ProductsProvider, useProducts }\n\n```"
}
] |
code_wish-list-v2_24b9ef02
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/context/RowContext.tsx from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport { useProducts } from './ProductsContext'\n\ntype RowContextType = {\n row: any\n updateQuantity: (quantity: number) => void\n}\nconst RowContext = React.createContext<RowContextType | null>(null)\n\nconst RowProvider = ({\n children,\n row: rowData,\n}: {\n children: React.ReactNode\n row: any\n}) => {\n const { getItem } = useProducts()\n const row = getItem(rowData.itemId)\n const [localRow, setLocalRow] = useState<any>(row)\n\n const updateQuantity = useCallback(\n (quantity: number) => {\n setLocalRow({ ...localRow, quantity })\n },\n [localRow]\n )\n\n useEffect(() => {\n setLocalRow(row)\n }, [row])\n\n const value = useMemo(() => ({ row: localRow, updateQuantity }), [\n localRow,\n updateQuantity,\n ])\n\n return <RowContext.Provider value={value}>{children}</RowContext.Provider>\n}\n\nconst useRow = () => {\n const context = React.useContext(RowContext)\n\n if (!context) {\n throw new Error('useRow must be used within a RowProvider')\n }\n\n return context\n}\n\nexport { RowProvider, useRow }\n\n```"
}
] |
code_wish-list-v2_661cd545
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/mutation/createWishList.gql from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation CreateWishList($wishList: WishlistInput!) {\n createWishlist(wishlist: $wishList) {\n Id\n Href\n DocumentId\n }\n}\n\n```"
}
] |
code_wish-list-v2_fc4912ea
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/mutation/removeWishList.gql from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation RemoveWishList($id: ID!) {\n deleteWishlist(id: $id) {\n id\n success\n }\n}\n\n```"
}
] |
code_wish-list-v2_1ec1f224
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/typings/vtex.product-context.d.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.product-context/useProduct' {\n const useProduct: () => ProductContext\n export default useProduct\n}\n\ndeclare module 'vtex.product-context' {\n export interface ProductContext {\n selectedQuantity: number\n selectedItem?: SelectedItem\n }\n\n interface SelectedItem {\n itemId: string\n unitMultiplier: number\n measurementUnit: string\n sellers: Array<{\n commertialOffer: {\n AvailableQuantity: number\n }\n sellerDefault: boolean\n }>\n }\n\n const useProduct: () => ProductContext\n export default useProduct\n}\n\ndeclare module 'vtex.product-context/ProductDispatchContext' {\n type DispatchFunction = (payload: { type: string; args?: unknown }) => void\n export const useProductDispatch: () => DispatchFunction\n}\n\n```"
}
] |
code_wish-list-v2_dd705d00
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/typings/gql.d.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.gql' {\n import { DocumentNode } from 'graphql'\n\n const Schema: DocumentNode\n\n export default Schema\n}\n\ndeclare module '*.graphql' {\n import { DocumentNode } from 'graphql'\n\n const schema: DocumentNode\n\n export default schema\n}\n\n```"
}
] |
code_wish-list-v2_34d11ee3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/typings/css.d.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n type Styles = {\n [selector: string]: string\n }\n\n const styles: Styles\n const css: any\n\n export default styles\n}\n\n```"
}
] |
code_wish-list-v2_326be3de
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/typings/vtex.styleguid.d.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide' {\n export const Button\n export const Input\n export const Tooltip\n export const NumericStepper\n export const Checkbox\n export const Spinner\n export const Modal\n export const ToastContext\n export const ToastProvider\n export const ToastConsumer\n export const AutocompleteInput\n export const Tag\n export const IconClear\n export const Table\n export const withToast\n export const IconDelete\n export const Layout\n export const PageHeader\n\n interface InputProps {\n [key: string]: any\n }\n}\n\n```"
}
] |
code_wish-list-v2_d6d763f5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/queries/product.gql from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery Product($slug: String) {\n product(slug: $slug) @context(provider: \"vtex.search-graphql\") {\n properties {\n name\n values\n }\n productName\n description\n link\n priceRange {\n sellingPrice {\n highPrice\n }\n }\n items {\n itemId\n name\n unitMultiplier\n sellers {\n sellerId\n sellerName\n sellerDefault\n }\n referenceId {\n Key\n Value\n }\n images {\n imageUrl\n }\n }\n categoryTree {\n name\n }\n skuSpecifications {\n field {\n name\n }\n values {\n name\n }\n }\n }\n}\n\n```"
}
] |
code_wish-list-v2_34d666df
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/queries/getWishListsByEmail.gql from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetWishListByEmail {\n getWishlistsByEmail {\n id\n email\n wishlistType\n products {\n ID\n Image\n linkProduct\n nameProduct\n quantityProduct\n skuCodeReference\n department\n bundle\n notes\n }\n }\n}\n\n```"
}
] |
code_wish-list-v2_3ead2bf8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/queries/autocomplete.gql from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery Autocomplete($inputValue: String!) {\n productSuggestions(fullText: $inputValue, hideUnavailableItems: true)\n @context(provider: \"vtex.search-graphql\") {\n products {\n items {\n itemId\n name\n images {\n imageUrl\n }\n }\n link\n linkText\n productName\n }\n }\n}\n\n```"
}
] |
code_wish-list-v2_1a19535b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/queries/AppSettings.graphql from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery getSettings {\n publicSettingsForApp(app: \"vtex.my-wishlists\", version: \"2.x\")\n @context(provider: \"vtex.apps-graphql\") {\n message\n }\n}\n```"
}
] |
code_wish-list-v2_6973f2ec
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/utils/copyToClipboard.js from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nexport default function copyToClipboard(link, setTextCopied) {\n // Create a hidden textarea element to copy the text\n const textarea = document.createElement('textarea')\n\n textarea.value = link // Use the link passed as an argument\n document.body.appendChild(textarea)\n textarea.select()\n textarea.setSelectionRange(0, 99999)\n document.execCommand('copy')\n document.body.removeChild(textarea)\n setTextCopied(true)\n setTimeout(() => {\n setTextCopied(false)\n }, 2000)\n}\n\n```"
}
] |
code_wish-list-v2_bc98d2f5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/utils/jsonSchema.tsx from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n/* eslint-disable no-console */\nimport React from 'react'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { IconDelete } from 'vtex.styleguide'\n\nimport Notes from '../components/Notes'\nimport ProductPriceTotal from '../components/ProductPriceTotal'\nimport { ProductStepper } from '../components/ProductQuantity'\nimport UnitPrice from '../components/UnitPrice'\nimport styles from '../styles.css'\n// import ProductDescription from '../components/ProductDescription'\nimport SkuName from '../components/SkuName'\nimport { RowProvider } from '../context/RowContext'\nimport { AdminSettings } from '../interfaces'\nimport { removePrefixRegex } from './stringUtils'\n\ninterface CellProps {\n title: string\n width?: number\n active?: boolean\n sortable?: boolean\n cellRenderer: (value: any, rowData: any) => JSX.Element // Tipo genérico para a função de renderização\n}\n\ninterface IJsonSchema {\n properties: {\n image: CellProps\n skuName: CellProps\n department: CellProps\n skuReferenceCode: CellProps\n quantity: CellProps\n unitValue: CellProps\n totalValue: CellProps\n notes: CellProps\n add: CellProps\n remove: CellProps\n }\n}\n\nexport const getProductPath = (rowData: any) => {\n const isFastStore = (window?.location?.hostname ?? '').startsWith('secure')\n\n const linkUrl = rowData.linkProduct || ''\n const parts = linkUrl.split('.br/')\n const id = rowData.itemId || rowData.ID\n\n // eslint-disable-next-line prefer-destructuring\n const productSlug = parts[parts.length - 1]?.split('/')?.[0] ?? ''\n const productPath = isFastStore ? `${productSlug}-${id}` : productSlug\n\n const hostUrl = removePrefixRegex(window.location.host ?? '', 'secure.')\n const newBaseUrl = `https://${hostUrl}`\n\n return `${newBaseUrl}/${productPath}/p`\n}\n\nconst WrapperProductStepper = ({ selectedWishlist, wishlists }) => {\n const currentWishlist =\n selectedWishlist !== null\n ? wishlists.find((wish) => wish.id === selectedWishlist)\n : wishlists[0]\n\n return <ProductStepper wishlist={currentWishlist} />\n}\n\nexport const JsonSchema = ({\n addProductsToCart,\n deleteItemsWishlist,\n selectedWishlist,\n wishlist,\n wishlists,\n updateWishlist,\n wishlistColumns,\n}) => {\n const runtime = useRuntime()\n const { culture } = runtime\n const currency = culture.customCurrencySymbol\n\n const imageCellRenderer = ({ cellData, rowData }) => {\n const productUrl = getProductPath(rowData)\n\n return (\n <a\n href={productUrl || ''}\n target=\"_blank\"\n rel=\"noreferrer\"\n className={styles.wishlistTableCell}\n >\n <img\n src={cellData || rowData.Image || ''}\n alt={rowData.name || ''}\n className={styles.wishlistProductImage}\n />\n </a>\n )\n }\n\n const departmentCellRenderer = ({ cellData, rowData }) => {\n return (\n <p className={styles.wishlistProductDepartment}>\n {cellData || rowData.department || ''}\n </p>\n )\n }\n\n const skuReferenceCodeCellRenderer = ({ cellData, rowData }) => {\n const productUrl = getProductPath(rowData)\n\n return (\n <a\n href={productUrl || ''}\n className={styles.wishlistProductTexts}\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {cellData || rowData.skuCodeReference || ''}\n </a>\n )\n }\n\n // const nameCellRenderer = ({ rowData }) => {\n // const linkUrl = rowData.linkProduct || ''\n // const parts = linkUrl.split('.br/')\n // const productUrl = `${window.location.origin}/${parts[parts.length - 1]}`\n\n // return (\n // <ProductDescription itemId={rowData.itemId} productUrl={productUrl} />\n // )\n // }\n\n const qtyCellRenderer = ({ rowData }) => {\n return (\n <RowProvider row={rowData}>\n <div className={styles.wishlistTableCell}>\n <WrapperProductStepper\n selectedWishlist={selectedWishlist}\n wishlists={wishlists}\n />\n </div>\n </RowProvider>\n )\n }\n\n const unitValueCellRenderer = ({ rowData }) => {\n return (\n <UnitPrice\n itemId={rowData.itemId}\n skuReference={rowData?.skuReferenceCode}\n currency={currency}\n />\n )\n }\n\n const addToCartCellRenderer = ({ rowData }) => {\n return (\n <button\n className={styles.wishlistAddItem}\n onClick={() => addProductsToCart(rowData, wishlist || {})}\n >\n Add\n </button>\n )\n }\n\n const removeCellRenderer = (rowData) => {\n return (\n <button\n className={styles.wishlistDeleteItem}\n onClick={async () => {\n deleteItemsWishlist({\n row: rowData,\n wishlist,\n selectedWishlist,\n updateWishlist,\n })\n }}\n >\n <IconDelete />\n </button>\n )\n }\n\n const priceCellRenderer = ({ rowData }) => {\n return (\n <ProductPriceTotal\n itemId={rowData.itemId}\n productQuantity={rowData?.quantity}\n currency={currency}\n />\n )\n }\n\n const notesCellRenderer = ({ rowData }) => {\n return (\n <Notes\n wishlist={selectedWishlist !== null ? wishlist : wishlists[0]}\n updateWishlist={updateWishlist}\n skuReference={rowData?.skuReferenceCode}\n currentNotes={rowData?.notes}\n productName={rowData?.name || ''}\n productImage={rowData?.image || ''}\n partNumber={rowData?.skuReferenceCode || ''}\n currency={currency}\n itemId={rowData?.itemId}\n quantity={rowData?.quantity}\n />\n )\n }\n\n const skuNameCellRenderer = ({ rowData }) => {\n const productUrl = getProductPath(rowData)\n\n return <SkuName itemId={rowData.itemId} productUrl={productUrl} />\n }\n\n const jsonschema: IJsonSchema = {\n properties: {\n image: {\n title: 'Image',\n // width: undefined,\n active: true,\n cellRenderer: imageCellRenderer,\n },\n skuName: {\n title: 'Name',\n // width: undefined,\n active: true,\n cellRenderer: skuNameCellRenderer,\n },\n department: {\n sortable: true,\n title: 'Department',\n // width: undefined,\n active: true,\n cellRenderer: departmentCellRenderer,\n },\n skuReferenceCode: {\n title: 'Part #',\n // width: undefined,\n active: true,\n cellRenderer: skuReferenceCodeCellRenderer,\n },\n // description: {\n // sortable: true,\n // title: 'Description',\n // width: 220,\n // name: '',\n // cellRenderer: nameCellRenderer,\n // },\n quantity: {\n title: 'Qty',\n // width: undefined,\n cellRenderer: qtyCellRenderer,\n },\n unitValue: {\n title: 'Unit Value',\n // width: undefined,\n cellRenderer: unitValueCellRenderer,\n },\n totalValue: {\n title: 'Price',\n // width: undefined,\n cellRenderer: priceCellRenderer,\n },\n notes: {\n title: 'Notes',\n // width: undefined,\n cellRenderer: notesCellRenderer,\n },\n add: {\n title: 'Add',\n // width: undefined,\n cellRenderer: addToCartCellRenderer,\n },\n remove: {\n title: 'Remove',\n // width: undefined,\n cellRenderer: removeCellRenderer,\n },\n },\n }\n\n if (!wishlistColumns?.publicSettingsForApp?.message) return jsonschema\n const wishlistColumnsSettings: AdminSettings = JSON.parse(\n wishlistColumns.publicSettingsForApp.message\n )\n\n jsonschema.properties.image.title = wishlistColumnsSettings.imageName\n jsonschema.properties.image.width = wishlistColumnsSettings.imageRowWidth\n jsonschema.properties.skuName.title = wishlistColumnsSettings.skuNameTitle\n jsonschema.properties.skuName.width =\n wishlistColumnsSettings.skuNameRowWidthAccount\n jsonschema.properties.department.title =\n wishlistColumnsSettings.departmentTitle\n jsonschema.properties.department.width =\n wishlistColumnsSettings.departmentRowWidth\n jsonschema.properties.skuReferenceCode.title =\n wishlistColumnsSettings.skuReferenceCodeTitle\n jsonschema.properties.skuReferenceCode.width =\n wishlistColumnsSettings.skuReferenceCodeRowWidth\n jsonschema.properties.quantity.title = wishlistColumnsSettings.quantityTitle\n jsonschema.properties.quantity.width =\n wishlistColumnsSettings.quantityRowWidth\n jsonschema.properties.unitValue.title = wishlistColumnsSettings.unitValueTitle\n jsonschema.properties.unitValue.width =\n wishlistColumnsSettings.unitValueRowWidth\n jsonschema.properties.totalValue.title =\n wishlistColumnsSettings.totalValueTitle\n jsonschema.properties.totalValue.width =\n wishlistColumnsSettings.totalValueRowWidth\n jsonschema.properties.add.title = wishlistColumnsSettings.addTitle\n jsonschema.properties.add.width = wishlistColumnsSettings.addRowWidth\n jsonschema.properties.remove.title = wishlistColumnsSettings.removeTitle\n\n for (const [key, value] of Object.entries(wishlistColumnsSettings)) {\n if (!value) {\n delete jsonschema.properties[key]\n }\n }\n\n return jsonschema\n}\n\n```"
}
] |
code_wish-list-v2_c1e2a915
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/utils/tableRowsSchema.js from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nconst tableRowsSchema = {\n items: [\n {\n image: '',\n department: '',\n skuReferenceCode: '',\n name: '',\n qty: '',\n unitValue: '',\n totalValue: '',\n },\n ],\n}\n\nconst tableLength = 5\n\nexport const initialJsonState = {\n slicedData: tableRowsSchema.items.slice(0, tableLength),\n searchValue: '',\n emptyStateLabel: 'Nothing to show.',\n filterStatements: ['Ascending', 'Descending'],\n}\n\n```"
}
] |
code_wish-list-v2_317824e5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/utils/stringUtils.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const removePrefixRegex = (str, prefix) => {\n return str.replace(new RegExp(`^${prefix}`), '')\n}\n\n```"
}
] |
code_wish-list-v2_10765408
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/utils/handleDataLayerEvent.ts from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nconst handleDataLayerEvent = (eventName: string, eventData: unknown[]) => {\n if (typeof window !== 'undefined') {\n ;(window.dataLayer ?? []).push({\n event: eventName,\n items: eventData,\n })\n }\n}\n\nexport default handleDataLayerEvent\n\n```"
}
] |
code_wish-list-v2_6a86a94f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/components/WishlistDesktop.tsx from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useState, useContext } from 'react'\nimport { ToastContext, ModalDialog } from 'vtex.styleguide'\n\nimport EditableWishlistTitle from './WishlistName/WishlistName'\nimport ModalCreateList from './ModalCreateList'\nimport WishlistPrivacyOptions from './WishlistPrivacyOptions'\nimport styles from '../styles.css'\n\nconst WishlistDesktop = ({\n selectedWishlist,\n wishlists,\n wishlist,\n fetchData,\n handleSelectWishlist,\n emailIDInfo,\n buttonModalTable,\n isModalAccountTable,\n handleSubmitDataTable,\n createWishlist,\n setFieldValidationTable,\n nameListAccountTable,\n setNameListAccountTable,\n setIsModalAccountTable,\n deleteWishlist,\n buttonCloseModalTable,\n handleNameListTable,\n fieldValidationTable,\n isDeleting,\n}) => {\n const [isCreateLoading, setIsCreateLoading] = useState(false)\n const [isDeleteLoading, setIsDeleteLoading] = useState(false)\n const [isModalOpen, setIsModalOpen] = useState(false)\n const { showToast } = useContext<any>(ToastContext)\n\n const onCreateList = async (event) => {\n setIsCreateLoading(true)\n try {\n await handleSubmitDataTable({\n event,\n createWishlist,\n setFieldValidationTable,\n nameListAccountTable,\n setNameListAccountTable,\n setIsModalAccountTable,\n })\n showToast('You created a new Wishlist')\n setIsCreateLoading(false)\n } catch (error) {\n showToast({\n message:\n error?.message?.replace('GraphQL error: ', '') ??\n `An error occurred. Make sure there isn't a wishlist with the same name.`,\n status: 'ERROR',\n })\n\n console.error(error)\n await fetchData()\n setIsCreateLoading(false)\n }\n }\n\n const onDeleteList = async () => {\n setIsDeleteLoading(true)\n try {\n await deleteWishlist()\n setIsDeleteLoading(false)\n if (wishlists.length === 1) {\n window.location.reload()\n }\n closeModal()\n } catch (error) {\n console.error(error)\n await fetchData()\n setIsDeleteLoading(false)\n closeModal()\n }\n }\n\n const closeModal = () => {\n setIsModalOpen(false)\n }\n\n const openModal = () => {\n setIsModalOpen(true)\n }\n\n return (\n <div id=\"wish-list-desktop\">\n <ModalDialog\n centered\n loading={isDeleteLoading}\n confirmation={{\n onClick: onDeleteList,\n label: 'Yes',\n isDangerous: true,\n testId: 'deleteConfirmBtn',\n }}\n cancelation={{\n onClick: closeModal,\n label: 'Cancel',\n }}\n isOpen={isModalOpen}\n onClose={closeModal}\n >\n <div className=\"\">\n <p className=\"f3 f3-ns fw3 gray\">\n Are you sure you want to delete your wishlist{' '}\n {emailIDInfo.find((list) => list.value === selectedWishlist)?.label}{' '}\n ?\n </p>\n <p>This action is irreversible.</p>\n </div>\n </ModalDialog>\n\n <EditableWishlistTitle\n initialTitle={selectedWishlist !== null ? wishlist.wishlistType : ''}\n wishlistId={\n selectedWishlist !== null ? selectedWishlist : wishlists[0].id\n }\n wishlist={selectedWishlist !== null ? wishlist : wishlists[0]}\n fetchData={fetchData}\n />\n\n <div className={styles.wishlistOptionsContainer}>\n <div className={styles.wishlistSelector}>\n <p className={styles.wishlistSelectListOneText}>Favorites List</p>\n <select\n className={styles.wishlistSelectListOne}\n id=\"selectListTable\"\n onChange={(e) => {\n handleSelectWishlist(e.target.value)\n }}\n size={1}\n value={selectedWishlist}\n >\n <option value=\"\" disabled selected>\n Select an option\n </option>\n {emailIDInfo.map((newDates) => (\n <option\n className={styles.wishlistSelectListOneOption}\n value={newDates.value}\n key={newDates.value}\n id={newDates.value}\n >\n {newDates.label}\n </option>\n ))}\n </select>\n </div>\n <section className={`${styles.wishlistCreationOptions} relative`}>\n <button\n className={`${styles.wishlistCreateNew} ${styles.wishlistCreateNewHelper}`}\n onClick={buttonModalTable}\n >\n Create New List\n </button>\n {isModalAccountTable && (\n <ModalCreateList\n buttonCloseModal={buttonCloseModalTable}\n handleNameList={handleNameListTable}\n fieldValidation={fieldValidationTable}\n handleSubmitData={onCreateList}\n isButtonLoading={isCreateLoading}\n blockClass=\"vtex-create-wishlist-desktop\"\n />\n )}\n <WishlistPrivacyOptions\n selectedWishlist={\n selectedWishlist !== null ? selectedWishlist : wishlists[0].id\n }\n wishlists={wishlists}\n buttonLabel=\"Share This List\"\n />\n <button\n className={styles.wishlistDeleteWishList}\n onClick={openModal}\n disabled={isDeleteLoading}\n >\n {isDeleting ? `Deleting...` : `Delete Selected List`}\n </button>\n </section>\n </div>\n </div>\n )\n}\n\nexport default WishlistDesktop\n\n```"
}
] |
code_wish-list-v2_99bb39ba
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/components/MyWishLists.tsx from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n// Hooks\nimport React, { useEffect, useState } from 'react'\nimport { Spinner, Button } from 'vtex.styleguide'\nimport { useMutation } from 'react-apollo'\n\nimport useCreateListAccount from '../hooks/useCreateListAccount'\n// Global Store\nimport useStoreGlobal from '../globalStore/globalStore'\n// Components\nimport Wishlist from './Wishlist'\nimport ModalCreateList from './ModalCreateList'\n// Helpers\nimport useQueryWishlists from '../hooks/actions/useQueryWishlists'\n// Styles\nimport styles from '../styles.css'\n// GQL\nimport CREATE_WISHLIST from '../mutation/createWishList.gql'\n\nconst MyWishLists = () => {\n const [isLoading, setIsLoading] = useState(false)\n const [isLoadingPage, setIsLoadingPage] = useState(false)\n const [errorMessage, setErrorMessage] = useState<string | null>(null)\n const { setSelectedWishlist, selectedWishlist } = useStoreGlobal()\n const setWishlists = useStoreGlobal((state) => state.setWishlists)\n const wishlists = useStoreGlobal((state) => state.wishlists)\n\n const { data, loading, refetch, error } = useQueryWishlists()\n\n const [createNewListMutaion] = useMutation(CREATE_WISHLIST, {})\n\n const {\n isModalAccount,\n nameListAccount,\n fieldValidation,\n setNameListAccount,\n setFieldValidation,\n setIsModalAccount,\n buttonModal,\n buttonCloseModal,\n handleNameList,\n } = useCreateListAccount()\n\n useEffect(() => {\n if (data?.getWishlistsByEmail) {\n if (data.getWishlistsByEmail.length > 0) {\n setWishlists(data.getWishlistsByEmail)\n if (!selectedWishlist) {\n setSelectedWishlist(data.getWishlistsByEmail[0].id)\n }\n } else {\n setWishlists([])\n }\n }\n\n if (error) {\n setErrorMessage(error.message)\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [data, error])\n\n useEffect(() => {\n wishlists && setIsLoadingPage(loading)\n }, [loading, wishlists])\n\n // Create list post\n const handleSubmitData = (event: { preventDefault: () => void }) => {\n event.preventDefault()\n\n if (nameListAccount.trim() === '') {\n setFieldValidation('The field cannot be empty')\n } else {\n setIsLoading(true)\n createNewListMutaion({\n variables: {\n wishList: {\n wishlistType: nameListAccount,\n products: [],\n isPublic: false,\n },\n },\n })\n .then(refetch)\n .then(() => {\n setNameListAccount('')\n setFieldValidation('')\n setIsModalAccount(false)\n setIsLoading(false)\n })\n .catch((errorSubmit) => {\n console.error(errorSubmit)\n setNameListAccount('')\n setFieldValidation('')\n setIsModalAccount(false)\n setIsLoading(false)\n })\n }\n }\n\n const handleCloseButton = (event: { preventDefault: () => void }) => {\n event.preventDefault()\n buttonCloseModal()\n }\n\n if (errorMessage)\n return (\n <p className={styles.errorMessage}>\n Your wishlist failed to load, please refresh the page.\n </p>\n )\n\n if (isLoadingPage) return <Spinner />\n\n if (wishlists.length === 0) {\n return (\n <section className={styles.wishlistCreateWishlistUI}>\n <Button href=\"/account\">RETURN</Button>\n <h1 className={styles.wishlistCreateWishlistPageTitle}>\n Create your wishlist!\n </h1>\n <button className={styles.wishlistCreateNew} onClick={buttonModal}>\n New Wishlist\n </button>\n {isModalAccount && (\n <ModalCreateList\n buttonCloseModal={handleCloseButton}\n handleNameList={handleNameList}\n fieldValidation={fieldValidation}\n handleSubmitData={handleSubmitData}\n blockClass=\"vtex-create-wishlist-main\"\n isButtonLoading={isLoading}\n />\n )}\n </section>\n )\n }\n\n return <Wishlist wishlists={wishlists} fetchData={refetch} />\n}\n\nexport default MyWishLists\n\n```"
}
] |
code_wish-list-v2_c711a6e3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/components/ProductDescription.tsx from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { Spinner } from 'vtex.styleguide'\n\nimport useQueryProductByIdentifier from '../hooks/actions/useQueryProductByIdentifier'\nimport styles from './unitPrice.css'\n\ninterface Props {\n itemId: number\n productUrl: string\n}\n\nconst ProductDescription = ({ itemId, productUrl }: Props) => {\n const {\n getProperty,\n error: productError,\n loading,\n } = useQueryProductByIdentifier('sku', itemId)\n\n const Wrapper = ({ children }) => {\n return <div className={`${styles.descriptionContainer}`}>{children}</div>\n }\n\n return productError ? (\n <Wrapper>\n <span>Error</span>\n </Wrapper>\n ) : loading ? (\n <Wrapper>\n <Spinner size={20} />\n </Wrapper>\n ) : (\n <Wrapper>\n <a\n href={productUrl || ''}\n className={styles.wishlistProductTexts}\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {getProperty('productDescription')}\n </a>\n </Wrapper>\n )\n}\n\nexport default ProductDescription\n\n```"
}
] |
code_wish-list-v2_b28ae72e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/components/UnitPrice.jsx from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```jsx\nimport React from 'react'\nimport { Spinner } from 'vtex.styleguide'\n\nimport useQueryGetProductPrice from '../hooks/actions/useQueryGetProductPrice'\nimport styles from './unitPrice.css'\n\nconst UnitPrice = ({ currency = '$', itemId }) => {\n const { price, error: productError, loading } = useQueryGetProductPrice(\n 'sku',\n itemId,\n 1\n )\n\n const Wrapper = ({ children }) => {\n return <div className={`${styles.unitPriceContainer}`}>{children}</div>\n }\n\n return productError ? (\n <Wrapper>\n <span>Error</span>\n </Wrapper>\n ) : loading ? (\n <Wrapper>\n <Spinner size={20} />\n </Wrapper>\n ) : (\n <Wrapper>\n {`${currency} ${price ? parseFloat(price).toFixed(2) : null}`}\n </Wrapper>\n )\n}\n\nexport default UnitPrice\n\n```"
}
] |
code_wish-list-v2_ab32178e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/components/SkuName.tsx from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { Spinner } from 'vtex.styleguide'\n\nimport useQueryProductByIdentifier from '../hooks/actions/useQueryProductByIdentifier'\nimport styles from './unitPrice.css'\n\ninterface Props {\n itemId: number\n productUrl: string\n}\n\nconst SkuName = ({ itemId, productUrl }: Props) => {\n const {\n getProperty,\n error: productError,\n loading,\n } = useQueryProductByIdentifier('sku', itemId)\n\n const Wrapper = ({ children }) => {\n return <div className={`${styles.skuNameContainer}`}>{children}</div>\n }\n\n return productError ? (\n <Wrapper>\n <span>Error</span>\n </Wrapper>\n ) : loading ? (\n <Wrapper>\n <Spinner size={20} />\n </Wrapper>\n ) : (\n <Wrapper>\n <a\n href={productUrl || ''}\n className={styles.wishlistProductTexts}\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {getProperty('productNameWithSkuName')}\n </a>\n </Wrapper>\n )\n}\n\nexport default SkuName\n\n```"
}
] |
code_wish-list-v2_7e08bef0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/components/Wishlist.tsx from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n// Hooks\nimport React, { useCallback, useContext, useEffect, useState } from 'react'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { Table, ToastContext } from 'vtex.styleguide'\n// Components\nimport { useQuery } from 'react-apollo'\n\nimport useCreateListAccount from '../hooks/useCreateListAccount'\nimport AutocompleteBlock from './SearchSKU/AutocompleteBlock'\n// Helpers & Utils\nimport useStoreGlobal from '../globalStore/globalStore'\nimport useCreateWishlist from '../hooks/actions/useMutationCreateWishlist'\nimport useDeleteWishlist from '../hooks/actions/useMutationDeleteWishlist'\nimport useUpdateWishlist from '../hooks/actions/useMutationUpdateWishlist'\nimport useQueryWishlistById from '../hooks/actions/useQueryWishlistById'\nimport useAddToCart from '../hooks/useAddToCart'\nimport useBulkAction from '../hooks/useBulkAction'\nimport AppSettings from '../queries/AppSettings.graphql'\nimport { JsonSchema } from '../utils/jsonSchema'\nimport { deleteItemsWishlist, extractProductData, getEmailID } from './helpers'\n// Table config\nimport { initialJsonState } from '../utils/tableRowsSchema'\nimport {\n handleFiltersChange,\n handleNextClick,\n handlePrevClick,\n handleSubmitDataTable,\n SelectorObject,\n} from './helpers/tableConfig'\nimport {\n handleInputSearchChange,\n handleInputSearchClear,\n handleInputSearchSubmit,\n} from './helpers/tableSearch'\nimport WishlistDesktop from './WishlistDesktop'\nimport WishlistMobile from './WishlistMobile'\n// Styles\nimport { ProductsProvider } from '../context/ProductsContext'\nimport styles from '../styles.css'\n\ninterface TablePaginationWrapperProps {\n tableSchema: any\n toolbar: any\n bulkActions: any\n pagination: any\n filters: any\n items: any\n}\n\nconst TablePaginationWrapper = React.memo<TablePaginationWrapperProps>(\n ({\n tableSchema,\n toolbar,\n bulkActions,\n pagination,\n filters,\n items,\n }: TablePaginationWrapperProps) => {\n return (\n <Table\n fullWidth\n density=\"medium\"\n updateTableKey={`vtex-table=${Math.floor(Math.random() * 1000)}`}\n schema={tableSchema}\n items={items}\n toolbar={toolbar}\n bulkActions={bulkActions}\n pagination={pagination}\n filters={filters}\n />\n )\n },\n (prevProps, nextProps) => {\n return prevProps.items.length === nextProps.items.length\n }\n)\n\nTablePaginationWrapper.displayName = 'TablePaginationWrapper'\n\nfunction Wishlist({ wishlists, fetchData }) {\n const { deviceInfo } = useRuntime()\n const emailIDInfo = getEmailID(wishlists)\n const { selectedWishlist, setSelectedWishlist } = useStoreGlobal()\n const { showToast } = useContext<any>(ToastContext)\n const [filterState, setfilterState] = useState<any>([])\n\n const { data: wishlistColumns } = useQuery(AppSettings, {\n variables: {\n // eslint-disable-next-line no-undef\n version: process.env.VTEX_APP_VERSION,\n },\n ssr: false,\n })\n\n const handleSelectWishlist = useCallback(\n (id) => {\n setSelectedWishlist(id)\n },\n [setSelectedWishlist]\n )\n\n const initialProducts =\n wishlists.length > 0\n ? extractProductData({ items: wishlists[0]?.products })\n : []\n\n const [allProducts, setAllProducts] = useState(initialProducts)\n const [displayedProducts, setDisplayedProducts] = useState(initialProducts)\n\n const [, setIsLoadingSKU] = useState(false)\n const [searchValue, setSearchValue] = useState('')\n const [updatedSelectedRows, setUpdatedSelectedRows] = useState([])\n const [wishlist, setWishlist] = useState<any>([])\n const [initialState, setInitialState] = useState(initialJsonState)\n const { refetch } = useQueryWishlistById(selectedWishlist, (data) => {\n if (!data || !data.getWishlist) return\n\n setWishlist(data.getWishlist)\n const products = extractProductData({\n items: data.getWishlist.products,\n })\n\n const sortedProducts = products.sort((a, b) =>\n a.department.localeCompare(b.department)\n )\n\n setAllProducts(sortedProducts)\n setDisplayedProducts(sortedProducts)\n })\n\n const updateData = () =>\n refetch().then(({ data }) => {\n if (!data || !data.getWishlist) return\n\n setWishlist(data.getWishlist)\n\n const products = extractProductData({\n items: data.getWishlist.products,\n })\n\n const sortedProducts = (products || []).sort((a, b) =>\n a.department.localeCompare(b.department)\n )\n\n setAllProducts(sortedProducts)\n setDisplayedProducts(sortedProducts)\n })\n\n const { createWishlist } = useCreateWishlist(async (data) => {\n await fetchData()\n if (data.createWishlist) {\n setSelectedWishlist(data.createWishlist.DocumentId)\n }\n })\n\n const { updateWishlist } = useUpdateWishlist(async () => {\n await updateData()\n })\n\n const { deleteWishlist, loading: isDeleting } = useDeleteWishlist(\n selectedWishlist,\n async () => {\n setSelectedWishlist(null)\n await fetchData()\n setSelectedWishlist(\n (wishlists ?? []).length > 0 ? wishlists[0]?.id : null\n )\n }\n )\n\n // Pagination Logic\n const [currentPage, setCurrentPage] = useState(1)\n const [itemsPerPage, setItemsPerPage] = useState(30)\n const [totalItems, setTotalItems] = useState(0)\n const [paginatedData, setPaginatedData] = useState([])\n const addProductsToCart = useAddToCart()\n const handleBulkAction = useBulkAction({\n wishlist,\n selectedWishlist,\n setUpdatedSelectedRows,\n updateWishlist,\n })\n\n const tableSchema = JsonSchema({\n addProductsToCart,\n deleteItemsWishlist,\n selectedWishlist,\n wishlist,\n wishlists,\n updateWishlist,\n wishlistColumns,\n })\n\n const {\n fieldValidationTable,\n isModalAccountTable,\n setFieldValidationTable,\n nameListAccountTable,\n setNameListAccountTable,\n setIsModalAccountTable,\n buttonCloseModalTable,\n buttonModalTable,\n handleNameListTable,\n } = useCreateListAccount()\n\n useEffect(() => {\n const updateStylesForMobile = () => {\n const targetElement = document.querySelector(\n 'body > div.render-container.render-route-store-account > div > div.vtex-store__template.bg-base > div > div:nth-child(3) > div > div > div > div > div > div:nth-child(7) > div > div:nth-child(3) > div.whitebird-my-wishlists-0-x-componentContainer.w-two-thirds-l.w-100-ns.fr-l > div > div'\n ) as HTMLDivElement\n\n if (window.innerWidth <= 768) {\n if (targetElement) {\n targetElement.classList.remove('pa7')\n targetElement.style.setProperty('padding-left', '0rem', 'important')\n }\n } else if (targetElement) {\n targetElement.classList.add('pa7')\n }\n }\n\n updateStylesForMobile()\n window.addEventListener('resize', updateStylesForMobile)\n\n return () => {\n window.removeEventListener('resize', updateStylesForMobile)\n }\n }, [])\n\n useEffect(() => {\n const button = document.querySelector(\n '#toggleFieldsBtn > button'\n ) as HTMLButtonElement\n\n button.style.minHeight = '28.10px'\n button.style.minWidth = 'min-content'\n\n button.addEventListener('mouseenter', () => {\n button.style.backgroundColor = '#f2f4f5'\n })\n\n button.addEventListener('mouseleave', () => {\n button.style.backgroundColor = ''\n button.style.color = ''\n })\n\n const svgContainer = button.querySelector('.vtex-button__label')\n\n if (!svgContainer) {\n return\n }\n\n const svg = svgContainer.querySelector('svg')\n\n if (svg) {\n svg.style.display = 'none'\n }\n\n let editViewText = svgContainer.querySelector(\n '.edit-view-text'\n ) as HTMLSpanElement\n\n if (editViewText) {\n return\n }\n\n editViewText = document.createElement('span')\n editViewText.classList.add('edit-view-text')\n editViewText.textContent = 'Edit View'\n\n if (window.innerWidth <= 768) {\n button.style.minHeight = '28.09px !important'\n editViewText.textContent = 'Edit'\n editViewText.style.cssText += 'font-weight: 500; font-size: 13px'\n editViewText.style.cssText += 'top: initial'\n }\n\n svgContainer.appendChild(editViewText)\n }, [])\n\n useEffect(() => {\n const button = document.querySelector(\n '#toggleFieldsBtn'\n ) as HTMLButtonElement\n\n if (window.innerWidth <= 768) {\n button.style.minHeight = '28px !important'\n }\n\n if (!button) return\n\n const handleButtonClick = () => {\n setTimeout(() => {\n const elementToStyle = document.querySelector(\n '#toggleFieldsBtn > div'\n ) as HTMLDivElement\n\n if (elementToStyle) {\n if (window.innerWidth <= 1046) {\n elementToStyle.style.setProperty('position', 'fixed', 'important')\n elementToStyle.style.setProperty('top', '50%', 'important')\n elementToStyle.style.setProperty('left', '50%', 'important')\n elementToStyle.style.setProperty(\n 'transform',\n 'translate(-50%, -50%)',\n 'important'\n )\n elementToStyle.style.setProperty('z-index', '1000', 'important')\n }\n }\n }, 0)\n }\n\n button.addEventListener('click', handleButtonClick)\n\n return () => {\n button.removeEventListener('click', handleButtonClick)\n }\n }, [])\n\n useEffect(() => {\n setSelectedWishlist(selectedWishlist)\n handleSelectWishlist(selectedWishlist)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selectedWishlist])\n\n // Logic to get paginated data\n useEffect(() => {\n const startIndex = (currentPage - 1) * itemsPerPage\n const endIndex = startIndex + itemsPerPage\n const data = displayedProducts || []\n const slicedData = data.slice(startIndex, endIndex)\n\n setPaginatedData(slicedData)\n }, [currentPage, itemsPerPage, displayedProducts])\n\n // Logic to update the total number of items\n useEffect(() => {\n const data = displayedProducts || []\n\n setTotalItems(data.length)\n }, [displayedProducts])\n\n // Handlers to change page and rows per page\n const handleRowsChange = (e, value) => {\n e.preventDefault()\n setItemsPerPage(parseInt(value, 10))\n setCurrentPage(1) // Return to the first page when the number of rows per page changes\n }\n\n const handleButtonCloseModalTable = (event: {\n preventDefault: () => void\n }) => {\n event.preventDefault()\n buttonCloseModalTable()\n }\n\n const onAddToWishlist = async (product: any) => {\n setIsLoadingSKU(true)\n const { product: productData } = product.data || {}\n\n const item =\n productData.items.find(\n (itm: { itemId: string }) => itm.itemId === product?.value\n ) || {}\n\n const unitMultiplierProperty = productData.properties.find(\n (prop: { name: string }) => prop.name === 'UnitMultiplier'\n )\n\n const unitMultiplierValue = unitMultiplierProperty\n ? parseInt(unitMultiplierProperty.values[0], 10)\n : 1\n\n const hasBundle = unitMultiplierValue > 1\n\n const newProduct = {\n ID: Number(item.itemId),\n Image: item?.images?.[0]?.imageUrl,\n // unitValue: productData.priceRange.sellingPrice.highPrice,\n linkProduct: productData?.link,\n nameProduct: productData?.productName,\n quantityProduct: 1,\n skuCodeReference: item?.referenceId?.[0]?.Value,\n department: productData?.categoryTree?.[0]?.name,\n bundle: hasBundle ? unitMultiplierValue : item.unitMultiplier,\n }\n\n if (newProduct.bundle > 1) {\n newProduct.quantityProduct *= newProduct.bundle\n }\n\n try {\n if (\n wishlist.products.some((p: { ID: number }) => p.ID === newProduct.ID)\n ) {\n showToast('You have already added this product to the list')\n\n return false\n }\n\n await updateWishlist({\n variables: {\n wishlist: {\n id: selectedWishlist,\n products: [...wishlist.products, newProduct],\n },\n },\n })\n showToast('Successfully added to the Favorites List')\n\n return true\n } catch (error) {\n console.error('Error adding to the list:', error)\n\n return false\n } finally {\n setIsLoadingSKU(false)\n }\n }\n\n const tableFilterOptions = {\n department: {\n label: 'Department',\n renderFilterLabel: () => {\n if (!filterState.department || !filterState.department.object) {\n return 'All'\n }\n\n const keys = filterState.department.object\n ? Object.keys(filterState.department.object)\n : []\n\n const isAllTrue = !keys.some(\n (key) => !filterState.department.object[key]\n )\n\n const isAllFalse = !keys.some(\n (key) => filterState.department.object[key]\n )\n\n const trueKeys = keys.filter(\n (key) => filterState.department.object[key]\n )\n\n let trueKeysLabel = ''\n\n trueKeys.forEach((key, index) => {\n trueKeysLabel += `${key}${index === trueKeys.length - 1 ? '' : ', '}`\n })\n\n return `${isAllTrue ? 'All' : isAllFalse ? 'None' : `${trueKeysLabel}`}`\n },\n verbs: [\n {\n label: 'Sort',\n value: 'Sort',\n object: (e: React.ChangeEvent<HTMLSelectElement>) => {\n return SelectorObject(e, filterState?.department?.object)\n },\n },\n ],\n },\n name: {\n label: 'Description',\n renderFilterLabel: () => {\n if (!filterState.name || !filterState.name.object) {\n return 'All'\n }\n\n const keys = filterState.name.object\n ? Object.keys(filterState.name.object)\n : []\n\n const isAllTrue = !keys.some((key) => !filterState.name.object[key])\n\n const isAllFalse = !keys.some((key) => filterState.name.object[key])\n\n const trueKeys = keys.filter((key) => filterState.name.object[key])\n\n let trueKeysLabel = ''\n\n trueKeys.forEach((key, index) => {\n trueKeysLabel += `${key}${index === trueKeys.length - 1 ? '' : ', '}`\n })\n\n return `${isAllTrue ? 'All' : isAllFalse ? 'None' : `${trueKeysLabel}`}`\n },\n verbs: [\n {\n label: 'Sort',\n value: 'Sort',\n object: (e: React.ChangeEvent<HTMLSelectElement>) =>\n SelectorObject(e, filterState?.name?.object),\n },\n ],\n },\n }\n\n const bulkActionsrowsSelected = (qty: number) => (\n <React.Fragment>Selected rows: {qty}</React.Fragment>\n )\n\n const bulkActionsAllRowsSelected = (qty: number) => (\n <React.Fragment>All rows selected {qty}</React.Fragment>\n )\n\n const toolbar = {\n inputSearch: {\n label: 'Search This List',\n value: searchValue,\n onChange: (e: React.ChangeEvent<HTMLInputElement>) =>\n handleInputSearchChange({\n e,\n allProducts,\n setSearchValue,\n setDisplayedProducts,\n }),\n onClear: () => handleInputSearchClear(setDisplayedProducts, allProducts),\n onSubmit: (e) =>\n handleInputSearchSubmit({\n e,\n allProducts,\n searchValue,\n setDisplayedProducts,\n }),\n },\n fields: {\n label: 'Toggle visible fields',\n showAllLabel: 'Show All',\n hideAllLabel: 'Hide All',\n },\n }\n\n const bulkActions = {\n selectedRows: updatedSelectedRows,\n texts: {\n secondaryActionsLabel: 'Actions',\n rowsSelected: bulkActionsrowsSelected,\n selectAll: 'Select all',\n allRowsSelected: bulkActionsAllRowsSelected,\n },\n totalItems: '',\n onChange: (params) => {\n setUpdatedSelectedRows(params.selectedRows)\n },\n others: [\n {\n label: 'Add to cart',\n handleCallback: (params) => {\n handleBulkAction(params.selectedRows, 'addToCart')\n },\n },\n {\n label: 'Remove item(s)',\n isDangerous: true,\n handleCallback: (params) =>\n handleBulkAction(params.selectedRows, 'deleteRowsWishlist'),\n },\n ],\n }\n\n const pagination = {\n onNextClick: () =>\n handleNextClick({\n currentPage,\n setCurrentPage,\n totalItems,\n itemsPerPage,\n }),\n onPrevClick: () => handlePrevClick(currentPage, setCurrentPage),\n currentItemFrom: (currentPage - 1) * itemsPerPage + 1,\n currentItemTo: Math.min(currentPage * itemsPerPage, totalItems),\n onRowsChange: handleRowsChange,\n textShowRows: 'Show rows',\n textOf: 'of',\n totalItems,\n rowsOptions: [30, 40, 50, 60],\n }\n\n const filters = {\n alwaysVisibleFilters: ['department', 'name'],\n statements: initialState.filterStatements,\n onChangeStatements: (e: React.ChangeEvent<HTMLInputElement>) => {\n handleFiltersChange({\n statements: initialState.filterStatements,\n initialState,\n setInitialState,\n paginatedData,\n setPaginatedData,\n setDisplayedProducts,\n onChangeStatements: e[2],\n setfilterState,\n filterState,\n })\n },\n clearAllFiltersButtonLabel: 'Clear Filters',\n collapseLeft: true,\n options: tableFilterOptions,\n }\n\n return (\n <>\n {deviceInfo.type === 'phone' ? (\n <WishlistMobile\n selectedWishlist={selectedWishlist}\n wishlists={wishlists}\n wishlist={wishlist}\n fetchData={fetchData}\n handleSelectWishlist={handleSelectWishlist}\n emailIDInfo={emailIDInfo}\n buttonModalTable={buttonModalTable}\n isModalAccountTable={isModalAccountTable}\n handleSubmitDataTable={handleSubmitDataTable}\n createWishlist={createWishlist}\n setFieldValidationTable={setFieldValidationTable}\n nameListAccountTable={nameListAccountTable}\n setNameListAccountTable={setNameListAccountTable}\n setIsModalAccountTable={setIsModalAccountTable}\n deleteWishlist={deleteWishlist}\n buttonCloseModalTable={buttonCloseModalTable}\n handleNameListTable={handleNameListTable}\n fieldValidationTable={fieldValidationTable}\n isDeleting={isDeleting}\n />\n ) : (\n <WishlistDesktop\n selectedWishlist={selectedWishlist}\n wishlists={wishlists}\n wishlist={wishlist}\n fetchData={fetchData}\n handleSelectWishlist={handleSelectWishlist}\n emailIDInfo={emailIDInfo}\n buttonModalTable={buttonModalTable}\n isModalAccountTable={isModalAccountTable}\n handleSubmitDataTable={handleSubmitDataTable}\n createWishlist={createWishlist}\n setFieldValidationTable={setFieldValidationTable}\n nameListAccountTable={nameListAccountTable}\n setNameListAccountTable={setNameListAccountTable}\n setIsModalAccountTable={setIsModalAccountTable}\n deleteWishlist={deleteWishlist}\n buttonCloseModalTable={handleButtonCloseModalTable}\n handleNameListTable={handleNameListTable}\n fieldValidationTable={fieldValidationTable}\n isDeleting={isDeleting}\n />\n )}\n\n <AutocompleteBlock\n text=\"Add SKU\"\n description=\"Search and add to your list\"\n componentOnly={false}\n onAddToWishlist={onAddToWishlist}\n />\n <section className={styles.wishlistSearchContainer}>\n <ProductsProvider items={paginatedData}>\n <TablePaginationWrapper\n tableSchema={tableSchema}\n pagination={pagination}\n bulkActions={bulkActions}\n toolbar={toolbar}\n filters={filters}\n items={paginatedData}\n />\n </ProductsProvider>\n </section>\n </>\n )\n}\n\nexport default Wishlist\n\n```"
}
] |
code_wish-list-v2_73de10db
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/components/productPriceTotal.css from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n.productPriceContainer {\n width: 100%;\n min-width: 100%;\n display: flex;\n align-items: center;\n justify-content: flex-end;\n}\n\n```"
}
] |
code_wish-list-v2_f7873313
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/components/notes.css from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n.notesContainer {\n width: 100%;\n min-width: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.addNotesIcons {\n display: flex;\n width: 100%;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n}\n\n.notesButtonContainer {\n display: flex;\n justify-content: flex-end;\n gap: 1rem;\n padding-top: 1rem;\n}\n\n.notesSubmitButtonContainer {\n \n}\n\n.notesSubmitButton {\n font-size: 1rem;\n margin: 0;\n overflow: visible;\n text-transform: capitalize;\n border-radius: 50px;\n border-color: #000000;\n cursor: pointer;\n color: #FFFFFF;\n background-color: #002266;\n width: 80px;\n height: 34px;\n padding: 10px;\n font-weight: 400;\n line-height: 19.36px;\n text-align: center;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.notesSubmitDisabledButton {\n opacity: 0.5;\n}\n\n.notesModalContainer {\n display: flex;\n flex-direction: column;\n row-gap: 1rem;\n}\n\n.notesModalTitle {\n padding-top: 1rem;\n}\n\n.notesModalBottomRow {\n \n}\n\n.notesCancelButton {\n font-size: 1rem;\n margin: 0;\n overflow: visible;\n text-transform: capitalize;\n border-radius: 50px;\n border-color: #000000;\n font-weight: 400;\n cursor: pointer;\n color: #000000;\n width: 80px;\n height: 34px;\n padding: 10px;\n font-weight: 400;\n line-height: 19.36px;\n text-align: center;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.productSummary {\n display: flex;\n flex-direction: row;\n gap: 1rem;\n padding-top: 2rem;\n padding-bottom: 1rem;\n padding-left: 2rem;\n border-bottom: 1px solid #9C9C9C;\n}\n\n.productSummaryImageContainer {\n\n}\n\n.productSummaryImage {\n object-fit: contain;\n}\n\n.productSummaryInfo {\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n}\n\n.productSummaryInfoName {\n font-size: 20px;\n font-weight: 700;\n line-height: 24.2px;\n text-align: left;\n color: #7A8094;\n}\n\n.productSummaryInfoDetails {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n gap: 2rem;\n}\n\n.productSummaryInfoDetailsPartNumber {\n font-size: 17px;\n font-weight: 400;\n line-height: 20.57px;\n text-align: left;\n color: #7A8094;\n}\n\n.productSummaryInfoDetailsPrice {\n font-size: 17px;\n font-weight: 400;\n line-height: 20.57px;\n text-align: left;\n color: #7A8094;\n}\n\n:global(.vtex-modal__modal) :global(.vtex-styleguide-9-x-shadowTransition) {\n background: #002266;\n border-radius: 5px 5px 0 0;\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n}\n\n:global(.vtex-modal__modal) :global(.vtex-styleguide-9-x-shadowTransition)>span {\n font-size: 24px;\n font-weight: 700;\n line-height: 29.05px;\n text-align: center;\n color: #ffffff\n}\n\n:global(.vtex-modal__close-icon) {\n padding-top: unset;\n padding-bottom: unset;\n padding-left: unset;\n padding-right: 1rem;\n height: 100%;\n} \n\n:global(.vtex-modal__close-icon) :global(.vtex__icon-close) {\n color: #ffffff\n}\n\n.noteSubTitle {\n font-size: 16px;\n font-weight: 700;\n line-height: 19.36px;\n text-align: left;\n color: #7A8094;\n height: 50px;\n}\n\n```"
}
] |
code_wish-list-v2_9494d0fc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/components/Notes.tsx from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useState, useEffect, useRef, useContext } from 'react'\nimport { Modal, ToastContext } from 'vtex.styleguide'\n\nimport { NoteIcon } from './Icons'\nimport styles from './notes.css'\nimport useQueryGetProductPrice from '../hooks/actions/useQueryGetProductPrice'\n\nconst Notes = ({\n wishlist: initialWishlist,\n updateWishlist,\n skuReference,\n currentNotes,\n productName,\n productImage,\n partNumber,\n currency,\n itemId,\n quantity,\n}) => {\n const [show, setShow] = useState(false)\n const [notes, setNotes] = useState('')\n\n const { price } = useQueryGetProductPrice(\n 'sku',\n itemId,\n quantity ? parseInt(quantity, 10) : 1\n )\n\n const wishlistRef = useRef(initialWishlist)\n\n const { showToast } = useContext<any>(ToastContext)\n\n useEffect(() => {\n wishlistRef.current = initialWishlist\n }, [initialWishlist])\n\n useEffect(() => {\n setNotes(currentNotes)\n }, [currentNotes])\n\n const handleNotesSubmit = async () => {\n try {\n const updatedProducts = wishlistRef.current.products?.map(\n (product: { skuCodeReference: any }) => ({\n ...product,\n ...(product.skuCodeReference === skuReference ? { notes } : {}),\n })\n )\n\n await updateWishlist({\n variables: {\n wishlist: {\n id: wishlistRef.current.id,\n products: updatedProducts,\n },\n },\n })\n\n showToast('Notes saved successfully!')\n setShow(false)\n } catch (error) {\n showToast('Error saving notes!')\n console.error('Notes submit error: ', error)\n }\n }\n\n const formattedValue = `${currency} ${price.toFixed(2)}`\n\n return (\n <div className={`${styles.notesContainer}`}>\n <div\n className={`${styles.addNotesIcons}`}\n onClick={() => setShow(!show)}\n aria-hidden=\"true\"\n >\n <NoteIcon />\n </div>\n\n <Modal\n isOpen={show}\n onClose={() => setShow(false)}\n title=\"Add a Note\"\n className=\"w-100 hhh\"\n >\n <div className={`${styles.notesModalContainer}`}>\n <div className={`${styles.productSummary}`}>\n <div className={`${styles.productSummaryImageContainer}`}>\n <img\n className={`${styles.productSummaryImage}`}\n src={productImage}\n alt={productName}\n width=\"74px\"\n height=\"64px\"\n />\n </div>\n <div className={`${styles.productSummaryInfo}`}>\n <div className={`${styles.productSummaryInfoName}`}>\n <span>{productName}</span>\n </div>\n <div className={`${styles.productSummaryInfoDetails}`}>\n <div\n className={`${styles.productSummaryInfoDetailsPartNumber}`}\n >\n <span>Part #: {partNumber}</span>\n </div>\n <div className={`${styles.productSummaryInfoDetailsPrice}`}>\n <span>Price: {formattedValue}</span>\n </div>\n </div>\n </div>\n </div>\n <div>\n <span\n className={`${styles.notesModalTitle} f3 db lh-copy measure flex items-center`}\n >\n Note\n </span>\n </div>\n <textarea\n className=\"w-100 pa4\"\n id=\"wish-list-notes\"\n name=\"wish-list-notes\"\n rows={8}\n onChange={(e) => setNotes(e.target.value)}\n value={notes}\n />\n <div className={`${styles.notesButtonContainer}`}>\n <div className={`${styles.notesCancelButtonContainer}`}>\n <button\n className={`${styles.notesCancelButton}`}\n onClick={() => setShow(false)}\n >\n Cancel\n </button>\n </div>\n <div className={`${styles.notesSubmitButtonContainer}`}>\n <button\n className={`${styles.notesSubmitButton}`}\n onClick={() => handleNotesSubmit()}\n >\n Save\n </button>\n </div>\n </div>\n </div>\n </Modal>\n </div>\n )\n}\n\nexport default Notes\n\n```"
}
] |
code_wish-list-v2_07916a49
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/components/WishlistMobile.tsx from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useState, useContext } from 'react'\nimport { ToastContext, ModalDialog, Button } from 'vtex.styleguide'\n\nimport EditableWishlistTitle from './WishlistName/WishlistName'\nimport ModalCreateList from './ModalCreateList'\nimport WishlistPrivacyOptions from './WishlistPrivacyOptions'\nimport styles from '../styles.css'\n\nconst WishlistMobile = ({\n selectedWishlist,\n wishlists,\n wishlist,\n fetchData,\n handleSelectWishlist,\n emailIDInfo,\n buttonModalTable,\n isModalAccountTable,\n handleSubmitDataTable,\n createWishlist,\n setFieldValidationTable,\n nameListAccountTable,\n setNameListAccountTable,\n setIsModalAccountTable,\n deleteWishlist,\n buttonCloseModalTable,\n handleNameListTable,\n fieldValidationTable,\n isDeleting,\n}) => {\n const [isCreateLoading, setIsCreateLoading] = useState(false)\n const [isDeleteLoading, setIsDeleteLoading] = useState(false)\n const [isModalOpen, setIsModalOpen] = useState(false)\n\n const { showToast } = useContext<any>(ToastContext)\n\n const onCreateList = async (event: React.FormEvent) => {\n setIsCreateLoading(true)\n try {\n await handleSubmitDataTable({\n event,\n createWishlist,\n setFieldValidationTable,\n nameListAccountTable,\n setNameListAccountTable,\n setIsModalAccountTable,\n })\n showToast('You created a new Wishlist')\n setIsCreateLoading(false)\n } catch (error) {\n showToast(error)\n console.error(error)\n setIsCreateLoading(false)\n }\n }\n\n const onDeleteList = async () => {\n\n setIsDeleteLoading(true)\n try {\n await deleteWishlist()\n setIsDeleteLoading(false)\n if(wishlists.length === 1){\n window.location.reload()\n }\n closeModal()\n } catch (error) {\n console.error(error)\n await fetchData()\n setIsDeleteLoading(false)\n closeModal()\n }\n }\n\n const closeModal = () => {\n setIsModalOpen(false)\n }\n\n const openModal = () => {\n setIsModalOpen(true)\n }\n\n return (\n <div id=\"wish-list-mobile\">\n {/* Mobile Design */}\n\n <ModalDialog\n centered\n loading={isDeleteLoading}\n confirmation={{\n onClick: onDeleteList,\n label: 'Yes',\n isDangerous: true,\n testId: \"deleteConfirmBtn\"\n }}\n cancelation={{\n onClick: closeModal,\n label: 'Cancel',\n }}\n isOpen={isModalOpen}\n onClose={closeModal}>\n <div className=\"\">\n <p className=\"f3 f3-ns fw3 gray\">\n Are you sure you want to delete your wishlist {emailIDInfo.find( list => list.value == selectedWishlist)?.label} ?\n </p>\n <p>\n This action is irreversible.\n </p>\n </div>\n </ModalDialog>\n\n <div className={styles.wishlistOptionsContainer}>\n <div className={styles.wishlistSelector}>\n <div className={styles.wishlistSelectListTitle}>\n <Button href=\"/account\" >RETURN</Button>\n <p className={styles.wishlistSelectListOneText}>Favorites List</p>\n </div>\n \n <div className={`${styles.createListandAndSelectFav}`}>\n <select\n className={styles.wishlistSelectListOne}\n id=\"selectListTable\"\n onChange={(e) => {\n handleSelectWishlist(e.target.value)\n }}\n size={1}\n value={selectedWishlist}\n >\n <option value=\"\" disabled selected>\n Select an option\n </option>\n {emailIDInfo.map((newDates) => (\n <option\n className={styles.wishlistSelectListOneOption}\n value={newDates.value}\n key={newDates.value}\n id={newDates.value}\n >\n {newDates.label}\n </option>\n ))}\n </select>\n <section className=\"relative\">\n <button\n className={`${styles.wishlistCreateNew} ${styles.wishlistCreateNewHelper}`}\n onClick={buttonModalTable}\n >\n New\n </button>\n {isModalAccountTable && (\n <ModalCreateList\n buttonCloseModal={buttonCloseModalTable}\n handleNameList={handleNameListTable}\n fieldValidation={fieldValidationTable}\n handleSubmitData={onCreateList}\n isButtonLoading={isCreateLoading}\n blockClass=\"vtex-create-wishlist-mobile\"\n />\n )}\n </section>\n </div>\n </div>\n </div>\n\n <div className={`${styles.nameAndOptionsMobile}`}>\n <EditableWishlistTitle\n initialTitle={selectedWishlist !== null ? wishlist.wishlistType : ''}\n wishlistId={\n selectedWishlist !== null ? selectedWishlist : wishlists[0].id\n }\n wishlist={selectedWishlist !== null ? wishlist : wishlists[0]}\n fetchData={fetchData}\n />\n <div className={`${styles.optionsMobile}`}>\n <WishlistPrivacyOptions\n selectedWishlist={\n selectedWishlist !== null ? selectedWishlist : wishlists[0].id\n }\n wishlists={wishlists}\n buttonLabel=\"Share\"\n />\n <button\n className={styles.wishlistDeleteWishList}\n onClick={openModal}\n >\n {isDeleting ? `Deleting...` : `Delete`}\n </button>\n </div>\n </div>\n </div>\n )\n}\n\nexport default WishlistMobile\n\n```"
}
] |
code_wish-list-v2_41c936f4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of wish-list-v2/react/components/Icons.tsx from the wish-list-v2 VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nexport const NoteIcon = () => {\n return (\n <svg\n width=\"20px\"\n height=\"20px\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"https://www.w3.org/2000/svg\"\n >\n <path\n d=\"M20 8.25V18C20 21 18.21 22 16 22H8C5.79 22 4 21 4 18V8.25C4 5 5.79 4.25 8 4.25C8 4.87 8.24997 5.43 8.65997 5.84C9.06997 6.25 9.63 6.5 10.25 6.5H13.75C14.99 6.5 16 5.49 16 4.25C18.21 4.25 20 5 20 8.25Z\"\n stroke=\"#292D32\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M16 4.25C16 5.49 14.99 6.5 13.75 6.5H10.25C9.63 6.5 9.06997 6.25 8.65997 5.84C8.24997 5.43 8 4.87 8 4.25C8 3.01 9.01 2 10.25 2H13.75C14.37 2 14.93 2.25 15.34 2.66C15.75 3.07 16 3.63 16 4.25Z\"\n stroke=\"#292D32\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M8 13H12\"\n stroke=\"#292D32\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M8 17H16\"\n stroke=\"#292D32\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n )\n}\n\nexport const SearchIcon = () => {\n return (\n <svg\n width=\"25\"\n height=\"24\"\n viewBox=\"0 0 25 24\"\n fill=\"none\"\n xmlns=\"https://www.w3.org/2000/svg\"\n xmlnsXlink=\"https://www.w3.org/1999/xlink\"\n >\n <rect width=\"25\" height=\"24\" fill=\"url(#pattern0_904_1396)\" />\n <defs>\n <pattern\n id=\"pattern0_904_1396\"\n patternContentUnits=\"objectBoundingBox\"\n width=\"1\"\n height=\"1\"\n >\n <use\n xlinkHref=\"#image0_904_1396\"\n transform=\"matrix(0.0344828 0 0 0.0359195 0 -0.164511)\"\n />\n </pattern>\n <image\n id=\"image0_904_1396\"\n width=\"29\"\n height=\"37\"\n xlinkHref=\"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAAlAB0DASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD9Sv7Pi/vT/wDf+T/4qj+z4v70/wD3/k/+KrD+I3xF0D4T+CtU8V+J79dN0TTY/MnnYFjyQqqqjlmZiFAHUkV4H/w118QF0f8A4So/s8+LB4C2+f8A2n/aFt/aHkdfN/s//WY2/N97Hv3rpp4erWXNBaeqXy13ZlKpCDsz6Y/s+L+9P/3/AJP/AIqj7BF/fm/7/v8A41i/Dz4g6D8VPBeleKvDN+upaJqUXm29woIPUhlYHlWVgVKnkEEV0dYSi4txlo0aJpq6Pmn9vixmX4T+FtfkspdS0Hwx4v0vXNds4kMhm0+J2EwKfxKC6kjoApJ4Fe0P8XPBUfgL/hNm8U6WPCfk+eNX+1L5BXbnAbP3sfw/ezxjPFdXNDHcwyQzRrLFIpR43UFWUjBBB6givDG/YZ+A7+IjrZ+Gmkm9LlzHul+zZJz/AMe+/wArHtsxXZCpSnTjTq3XK3tZ7+rX36+hhKM4ycoW17nIf8E79Tsdd+Efi/V9JlhXQ9U8aatfaZYRupaxtXdPLhdAf3Z4LbT2cHoRX1LXz1+zx+xroP7NvxI8ZeI/DWv6k2i69Gsdv4dk/wCPezAbcSW3EykHIRiAVVmBLE5r6FpY2dOpXlOk7p/1b5DoRlGmozVmgoooriNwooooA//Z\"\n />\n </defs>\n </svg>\n )\n}\n\n```"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.