id
stringlengths
12
53
messages
listlengths
3
3
code_address-locator_dab69d12
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/Card.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nconst Card = ({ children }) => (\n <div className=\"w-100 flex justify-center\">\n <div className=\"ph6 ph9-ns pv7 pv8-ns bg-base shadow-2 br2 mh5 mv5 mw6 w-100\">\n {children}\n </div>\n </div>\n)\n\nCard.propTypes = {\n children: PropTypes.node,\n}\n\nexport default Card\n```" } ]
code_address-locator_b276ccc6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/Loader.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport ContentLoader from 'react-content-loader'\n\nconst Loader = props => (\n <ContentLoader\n height={60}\n width={100}\n speed={2}\n primaryColor=\"#f3f3f3\"\n secondaryColor=\"#ecebeb\"\n {...props}\n >\n <rect x=\"0\" y=\"0\" rx=\"1\" ry=\"1\" width=\"50\" height=\"10\" />\n <rect x=\"0\" y=\"15\" rx=\"1\" ry=\"1\" width=\"100\" height=\"20\" />\n <rect x=\"0\" y=\"40\" rx=\"1\" ry=\"1\" width=\"100\" height=\"20\" />\n </ContentLoader>\n)\n\nexport default Loader\n\n```" } ]
code_address-locator_7ac24964
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/AddressManager/AddressPage.css from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n@keyframes appear {\n 0% {\n opacity: 0;\n }\n 99% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n.spinnerAppear {\n opacity: 0;\n animation: appear 3s;\n animation-fill-mode: forwards;\n}\n```" } ]
code_address-locator_e690bddd
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/AddressManager/index.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { useEffect, useCallback } from 'react'\nimport queryString from 'query-string'\nimport { head, path } from 'ramda'\nimport { useRuntime } from 'vtex.render-runtime'\n\nimport { useAddress, withAddressProvider } from '../AddressContext'\nimport AddressPage from './AddressPage'\n\nimport '../../global.css'\n\nconst redirectToReturnURL = navigate => {\n try {\n const parsedQueryString = queryString.parse(window.location.search)\n const returnURL = (parsedQueryString && parsedQueryString.returnUrl) || ''\n const cleanUrl = head(returnURL) === '/' ? returnURL : `/${returnURL}`\n navigate({ to: cleanUrl })\n } catch (e) {\n // Unable to redirect\n }\n}\n\nconst AddressManager = props => {\n const { address } = useAddress()\n const { navigate } = useRuntime()\n\n const redirect = useCallback(() => redirectToReturnURL(navigate), [navigate])\n\n useEffect(() => {\n if (!!path(['orderForm', 'shippingData', 'address'], address)) {\n redirect()\n }\n }, [address, redirect])\n return <AddressPage {...props} onSelectAddress={redirect} />\n}\n\nAddressManager.schema = {\n title: 'admin/address-locator.address-manager-title',\n description: 'admin/address-locator.address-manager-description',\n type: 'object',\n properties: {\n logoUrl: {\n type: 'string',\n title: 'admin/address-locator.address-manager.logo-title',\n widget: {\n 'ui:widget': 'image-uploader',\n },\n },\n },\n}\n\nexport default withAddressProvider(AddressManager)\n\n```" } ]
code_address-locator_0e4ecfc1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/AddressManager/AddressPage.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { memo, useCallback, useState, useRef } from 'react'\nimport PropTypes from 'prop-types'\nimport { Spinner } from 'vtex.styleguide'\nimport { ExtensionPoint, useRuntime } from 'vtex.render-runtime'\n\nimport Card from '../Card'\n\nimport { useAddress } from '../AddressContext'\n\nconst transformAnimationStyle = (quantity, isPickupOpen) => ({\n transition: 'transform 300ms',\n transform: `translate3d(${isPickupOpen ? `-${quantity}` : '0'}, 0, 0)`,\n})\n\n/**\n * Component that allows the user to locate his address, by inserting, searching, retrieving and\n * saving it into orderform.\n * Configure the key for Google Geolocation API, by inserting it on the admin logistics section.\n */\nconst AddressPage = ({ onSelectAddress }) => {\n const { address } = useAddress()\n const {\n hints: { phone: isPhone },\n } = useRuntime()\n const [isPickupOpen, setPickupOpen] = useState(false)\n const wrapperRef = useRef(null)\n const handlePickupClick = useCallback(() => {\n setPickupOpen(true)\n }, [setPickupOpen])\n\n const handleOrderFormUpdated = useCallback(() => {\n onSelectAddress && onSelectAddress()\n }, [onSelectAddress])\n\n const closeModal = useCallback(() => {\n setPickupOpen(false)\n }, [setPickupOpen])\n\n if (address.loading) {\n return (\n <div\n className=\"flex flex-grow-1 items-center justify-center\"\n style={{\n height: 750,\n }}\n >\n <Spinner />\n </div>\n )\n }\n\n return (\n <div ref={wrapperRef}>\n <div\n className=\"vtex-address-modal__address-page\"\n style={transformAnimationStyle('110%', isPickupOpen && isPhone)}\n >\n <Card>\n <ExtensionPoint\n id=\"address-search\"\n onUpdateOrderForm={handleOrderFormUpdated}\n />\n <ExtensionPoint\n id=\"pickup-selector\"\n onConfirm={handleOrderFormUpdated}\n onFindPickupClick={handlePickupClick}\n isPickupOpen={isPickupOpen}\n parentRef={isPhone && wrapperRef}\n closeModal={closeModal}\n />\n </Card>\n <Card>\n <ExtensionPoint id=\"address-redeem\" />\n </Card>\n </div>\n </div>\n )\n}\n\nAddressPage.propTypes = {\n onSelectAddress: PropTypes.func,\n}\n\nexport default memo(AddressPage)\n\n```" } ]
code_address-locator_7add8d09
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/AddressRedeem/AddressRedeemForm.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { useMemo } from 'react'\nimport PropTypes from 'prop-types'\nimport { find, propEq } from 'ramda'\nimport { FormattedMessage } from 'react-intl'\nimport Button from 'vtex.styleguide/Button'\nimport { ProfileField } from 'vtex.profile-form'\nimport convertIso3To2 from 'country-iso-3-to-2'\nimport examples from 'libphonenumber-js/examples.mobile.json'\nimport { getExampleNumber } from 'libphonenumber-js'\nimport { useRuntime } from 'vtex.render-runtime'\n\nimport StyleguideInput from '../StyleguideInput'\nimport CountryIcon from './CountryIcon'\n\nconst isDisabled = profilePhone =>\n !profilePhone.value || !profilePhone.value.length\n\nconst AddressRedeemForm = ({\n loading,\n rules,\n profile,\n onFieldUpdate,\n onSubmit,\n}) => {\n const {\n culture: { country },\n } = useRuntime()\n const countryIso2 = convertIso3To2(country)\n const phonePlaceholder = useMemo(\n () => getExampleNumber(countryIso2, examples).formatNational(),\n [country]\n )\n const homePhoneField = {\n ...find(propEq('name', 'homePhone'), rules.personalFields),\n required: true,\n }\n\n const profilePhone = profile[homePhoneField.name]\n return (\n <form\n className=\"vtex-address-locator__address-redeem w-100\"\n onSubmit={onSubmit}\n >\n <div className=\"mb5 relative input--icon-left\">\n <ProfileField\n field={homePhoneField}\n data={profilePhone}\n onFieldUpdate={onFieldUpdate}\n options={{\n placeholder: phonePlaceholder,\n size: 'large',\n inputmode: 'numeric',\n type: 'tel',\n prefix: <CountryIcon country={countryIso2} size={20} />,\n }}\n Input={StyleguideInput}\n />\n </div>\n <Button\n type=\"submit\"\n isLoading={loading}\n disabled={isDisabled(profilePhone)}\n block\n >\n <FormattedMessage id=\"store/address-locator.address-redeem-button\" />\n </Button>\n </form>\n )\n}\n\nAddressRedeemForm.propTypes = {\n /* Query loading state */\n loading: PropTypes.bool.isRequired,\n /* Submit event handler */\n onSubmit: PropTypes.func.isRequired,\n /* Input change event handler */\n onFieldUpdate: PropTypes.func.isRequired,\n /* Profile Form rules object for the store country */\n rules: PropTypes.shape({\n country: PropTypes.string,\n personalFields: PropTypes.arrayOf(\n PropTypes.shape({\n display: PropTypes.func,\n label: PropTypes.string,\n mask: PropTypes.func,\n maxLength: PropTypes.number,\n name: PropTypes.string,\n submit: PropTypes.func,\n validate: PropTypes.func,\n })\n ),\n }).isRequired,\n profile: PropTypes.shape({\n homePhone: PropTypes.shape({\n value: PropTypes.string,\n touched: PropTypes.bool,\n error: PropTypes.string,\n }),\n }).isRequired,\n}\n\nexport default AddressRedeemForm\n\n```" } ]
code_address-locator_5826940c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/AddressRedeem/AddressRedeemQueryWrapper.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { useState } from 'react'\nimport { find, head, prop, propEq, path } from 'ramda'\nimport { withApollo } from 'react-apollo'\nimport { modules } from 'vtex.profile-form'\nimport { useRuntime } from 'vtex.render-runtime'\n\nimport AddressRedeemForm from './AddressRedeemForm'\nimport documentsQuery from '../../queries/documents.gql'\nimport getCountryDialCode from '../../utils/getCountryDialCode'\nimport { useAddress } from '../AddressContext'\n\nconst { addValidation } = modules\n\n/**\n * Component responsible for retrieving the user's address by his phone number\n */\n\nconst AddressRedeemQueryWrapper = ({ rules, client }) => {\n const {\n culture: { country },\n } = useRuntime()\n const { address } = useAddress()\n const [queryLoading, updateQueryLoading] = useState(false)\n const [profile, updateProfile] = useState(() =>\n addValidation({ homePhone: '' }, rules)\n )\n\n const handleFieldUpdate = field =>\n updateProfile(oldProfile => ({ ...oldProfile, ...field }))\n\n const updateAddressProfile = async ({ email }) => {\n let hasError = false\n try {\n const response = await address.updateOrderFormProfile({\n variables: {\n orderFormId: address.orderForm.orderFormId,\n fields: { email },\n },\n })\n hasError = Boolean(\n path(['data', 'updateOrderFormProfile', 'orderForm'], response)\n )\n } catch (e) {\n hasError = true\n }\n if (hasError) {\n // Show error to user\n }\n }\n\n const handleSubmit = async e => {\n e.preventDefault()\n if (profile.homePhone.error) {\n return\n }\n updateQueryLoading(true)\n\n try {\n const { data = { documents: [] } } = await client.query({\n query: documentsQuery,\n variables: {\n acronym: 'CL',\n fields: ['email'],\n where: `homePhone=+${getCountryDialCode(\n country\n )}${profile.homePhone.value.replace(/\\D/g, '')}`,\n },\n })\n const fields = prop('fields', head(data.documents))\n if (!fields) throw new Error('Profile not found')\n\n const { value: email } = find(propEq('key', 'email'), fields)\n await updateAddressProfile({ email })\n } catch (e) {\n updateProfile(oldProfile => ({\n ...oldProfile,\n homePhone: { ...oldProfile.homePhone, error: 'NOT_FOUND' },\n }))\n }\n updateQueryLoading(false)\n }\n\n return (\n <AddressRedeemForm\n rules={rules}\n profile={profile}\n loading={queryLoading}\n country={country}\n onSubmit={handleSubmit}\n onFieldUpdate={handleFieldUpdate}\n />\n )\n}\n\nexport default withApollo(AddressRedeemQueryWrapper)\n\n```" } ]
code_address-locator_6aaca03d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/AddressRedeem/AddressRedeem.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Fragment } from 'react'\nimport { FormattedMessage } from 'react-intl'\n\nimport { useAddress } from '../AddressContext'\nimport Loader from '../Loader'\nimport AddressRedeemQueryWrapper from './AddressRedeemQueryWrapper'\n\nconst LoaderView = () => (\n <div className=\"pv7 ph6 br2 bg-white\">\n <Loader style={{ width: '100%', height: '100%' }} />\n </div>\n)\n\nconst AddressRedeem = ({ rules }) => {\n const {\n address: { loading: isLoading },\n } = useAddress()\n\n return (\n <Fragment>\n <h2 className=\"t-heading-2 mt0 mb4\">\n <FormattedMessage id=\"store/address-locator.address-redeem-recurring\" />\n </h2>\n <div className=\"vtex-address-modal__redeem\">\n {isLoading ? (\n <LoaderView />\n ) : (\n <AddressRedeemQueryWrapper rules={rules} />\n )}\n </div>\n </Fragment>\n )\n}\n\nexport default AddressRedeem\n\n```" } ]
code_address-locator_08b711c9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/AddressRedeem/index.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { ProfileRules } from 'vtex.profile-form'\n\nimport AddressRedeem from './AddressRedeem'\n\n/**\n * Component responsible for retrieving the user's address by his phone number\n */\n\nconst ProfileRulesWrapper = () => {\n const {\n culture: { country },\n } = useRuntime()\n return (\n <ProfileRules country={country} shouldUseIOFetching>\n <AddressRedeem />\n </ProfileRules>\n )\n}\n\nexport default ProfileRulesWrapper\n\n```" } ]
code_address-locator_3cdcbeec
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/AddressRedeem/CountryIcon.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { memo, useState } from 'react'\nimport getCountryDialCode from '../../utils/getCountryDialCode'\n\nconst CountryIcon = ({ size, country }) => {\n const [flagSource, setFlagSource] = useState(undefined)\n\n if (flagSource === undefined) {\n import(`svg-country-flags/png100px/${country.toLowerCase()}.png`)\n .then(src => setFlagSource(src.default))\n .catch(() => setFlagSource(null))\n return null\n }\n\n const dialCode = getCountryDialCode(country)\n return (\n <div className=\"flex items-center\">\n {flagSource && (\n <img\n className=\"pr2\"\n style={{ objectFit: 'contain' }}\n src={flagSource}\n width={size}\n height={size}\n />\n )}\n <p>{`+${dialCode}`}</p>\n </div>\n )\n}\n\nexport default memo(CountryIcon)\n\n```" } ]
code_address-locator_c0c00f10
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/PickupSelector/index.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { useState, useCallback, Fragment } from 'react'\nimport PropTypes from 'prop-types'\nimport { Button, Spinner, Modal } from 'vtex.styleguide'\nimport { AddressRules } from 'vtex.address-form'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { createPortal } from 'react-dom'\nimport { FormattedMessage } from 'react-intl'\n\nimport { useAddress } from '../AddressContext'\nimport PickupModalContainer from './PickupModalContainer'\nimport transformAnimationStyle from '../../utils/transformAnimationStyle'\n\nconst PickupWrapper = ({ children, parentRef, closeModal }) => {\n if (!parentRef.current) {\n return (\n <Modal centered isOpen onClose={closeModal} showTopBar={false}>\n <div className=\"vw-90 vh-80\">{children}</div>\n </Modal>\n )\n }\n\n return createPortal(children, parentRef.current)\n}\n\nconst PickupSelector = ({\n loading,\n onConfirm,\n onFindPickupClick,\n isPickupOpen,\n parentRef,\n closeModal,\n}) => {\n const [isFetching, setFetching] = useState(false)\n const { address } = useAddress()\n const {\n culture: { country },\n } = useRuntime()\n\n const onHandlePickedSLA = useCallback(\n async pickupPoint => {\n setFetching(true)\n try {\n await address.updateOrderFormCheckin({\n variables: {\n orderFormId: address.orderForm.orderFormId,\n checkin: { isCheckedIn: true, pickupPointId: pickupPoint.id },\n },\n })\n } catch (err) {\n // Show user that pickup point choice failed?\n }\n\n setFetching(false)\n onConfirm && onConfirm()\n },\n [setFetching, address, onConfirm]\n )\n\n if (!isPickupOpen) {\n return (\n <Fragment>\n <Button variation=\"tertiary\" block onClick={onFindPickupClick}>\n <FormattedMessage id=\"store/address-locator.pickup-button\" />\n </Button>\n </Fragment>\n )\n }\n const isLoading = isFetching || loading\n const animationStyle = !!parentRef.current\n ? {\n left: '100%',\n ...transformAnimationStyle('100%', isPickupOpen),\n }\n : {}\n\n return (\n <PickupWrapper parentRef={parentRef} closeModal={closeModal}>\n {\n <AddressRules country={country} shouldUseIOFetching>\n <div\n className=\"w-100 center absolute top-0 bottom-0 left-0 right-0\"\n style={animationStyle}\n >\n {isLoading ? (\n <div className=\"w-100 h-100 flex items-center justify-center\">\n <Spinner />\n </div>\n ) : (\n <PickupModalContainer handlePickedSLA={onHandlePickedSLA} />\n )}\n </div>\n </AddressRules>\n }\n </PickupWrapper>\n )\n}\n\nPickupSelector.propTypes = {\n loading: PropTypes.bool,\n onConfirm: PropTypes.func.isRequired,\n onFindPickupClick: PropTypes.func,\n isPickupOpen: PropTypes.bool,\n parentRef: PropTypes.shape({ current: PropTypes.instanceOf(PropTypes.any) }),\n closeModal: PropTypes.func,\n}\n\nexport default PickupSelector\n\n```" } ]
code_address-locator_7c2a9fba
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/PickupSelector/PickupModalContainer.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { useEffect, useMemo, useCallback, useReducer } from 'react'\nimport PropTypes from 'prop-types'\nimport { injectIntl } from 'react-intl'\nimport { graphql, withApollo } from 'react-apollo'\nimport { compose } from 'recompose'\nimport { path } from 'ramda'\nimport { PickupPointsSelector } from 'vtex.pickup-points-selector'\nimport { helpers } from 'vtex.address-form'\nimport { useRuntime } from 'vtex.render-runtime'\n\nimport nearPickupPointsQuery from '../../queries/nearPickupPoints.gql'\nimport logisticsQuery from '../../queries/logistics.gql'\nimport { newAddress } from '../../utils/newAddress'\nimport getCurrentPositionPromise from '../../utils/getCurrentPositionPromise'\n\nconst { injectRules, addValidation } = helpers\n\nfunction reducer(state, action) {\n const args = action.args || {}\n switch (action.type) {\n case 'SET_GEOLOCATION_PERMISSION': {\n return {\n ...state,\n hasGeolocationPermission: args.hasGeolocationPermission,\n }\n }\n case 'SAVE_NULL_PICKUP_POINTS': {\n return {\n ...state,\n pickupOptions: [],\n pickupPoints: [],\n isSearching: false,\n }\n }\n case 'SAVE_PICKUP_POINTS': {\n return {\n ...state,\n pickupOptions: args.pickupOptions,\n pickupPoints: args.pickupPoints,\n isSearching: false,\n selectedPickupPoint: args.selectedPickupPoint,\n }\n }\n case 'BEGIN_ADDRESS_SEARCH': {\n return {\n ...state,\n isSearching: true,\n searchAddress: args.searchAddress,\n }\n }\n case 'SELECT_PICKUP_POINT': {\n return {\n ...state,\n selectedPickupPoint: args.selectedPickupPoint,\n }\n }\n default:\n return state\n }\n}\n\nconst initialState = {\n hasGeolocationPermission: undefined,\n pickupOptions: [],\n searchAddress: addValidation(newAddress({ addressType: 'search' })),\n selectedPickupPoint: null,\n pickupPoints: [],\n isSearching: true,\n}\n\nconst convertPickupPointToOption = pickupPoint => {\n if (!pickupPoint) return pickupPoint\n return {\n id: pickupPoint.id,\n shippingEstimate: '40m',\n deliveryChannel: 'pickup-in-point',\n shippingEstimateDate: null,\n lockTTL: null,\n availableDeliveryWindows: [],\n deliveryWindow: null,\n listPrice: 0,\n tax: 0,\n price: 0,\n pickupStoreInfo: {\n isPickupStore: true,\n ...pickupPoint,\n },\n }\n}\n\nconst PickupModalContainer = ({\n handlePickedSLA,\n logisticsQuery,\n intl,\n rules,\n client,\n onConfirm,\n}) => {\n const {\n culture: { country, currency },\n } = useRuntime()\n const [state, dispatch] = useReducer(reducer, initialState)\n const {\n hasGeolocationPermission,\n pickupOptions,\n searchAddress,\n selectedPickupPoint,\n pickupPoints,\n isSearching,\n } = state\n\n const storePreferencesData = useMemo(\n () => ({\n countryCode: country,\n currencySymbol: currency,\n }),\n [country, currency]\n )\n\n const changeActivePickupDetails = useCallback(\n ({ pickupPoint }) =>\n dispatch({\n type: 'SELECT_PICKUP_POINT',\n args: { selectedPickupPoint: pickupPoint },\n }),\n [dispatch]\n )\n\n const changeActiveSLAOption = useCallback(\n () => handlePickedSLA(selectedPickupPoint),\n [handlePickedSLA, selectedPickupPoint]\n )\n\n const savePickupPoints = useCallback(\n pickupPoints => {\n if (!pickupPoints) {\n dispatch({ type: 'SAVE_NULL_PICKUP_POINTS' })\n return\n }\n const pickupOptions = pickupPoints.map(convertPickupPointToOption)\n const newSelectedPickupPoint = pickupOptions[0]\n dispatch({\n type: 'SAVE_PICKUP_POINTS',\n args: {\n pickupOptions,\n pickupPoints,\n selectedPickupPoint: newSelectedPickupPoint,\n },\n })\n },\n [dispatch]\n )\n\n const handleSearchAddressChange = useCallback(\n async address => {\n const cleanAddress = addValidation(newAddress(address))\n dispatch({\n type: 'BEGIN_ADDRESS_SEARCH',\n args: {\n searchAddress: cleanAddress,\n },\n })\n if (cleanAddress.geoCoordinates.value.length < 2) {\n savePickupPoints(null)\n }\n\n const [long, lat] = cleanAddress.geoCoordinates.value\n try {\n const response = await client.query({\n query: nearPickupPointsQuery,\n variables: { lat: lat.toString(), long: long.toString() },\n })\n const pickupPoints = path(\n ['data', 'nearPickupPoints', 'items'],\n response\n )\n savePickupPoints(pickupPoints)\n } catch (err) {\n savePickupPoints(null)\n }\n },\n [dispatch, savePickupPoints, client]\n )\n\n const handlePickupConfirm = useCallback(\n options => {\n onConfirm && onConfirm(options)\n },\n [onConfirm]\n )\n\n useEffect(() => {\n getCurrentPositionPromise()\n .then(() =>\n dispatch({\n type: 'SET_GEOLOCATION_PERMISSION',\n args: { hasGeolocationPermission: true },\n })\n )\n .catch(() =>\n dispatch({\n type: 'SET_GEOLOCATION_PERMISSION',\n args: { hasGeolocationPermission: false },\n })\n )\n }, [dispatch])\n if (logisticsQuery.loading || hasGeolocationPermission === undefined) {\n return null\n }\n\n return (\n <PickupPointsSelector\n askForGeolocation={hasGeolocationPermission}\n changeActivePickupDetails={changeActivePickupDetails}\n changeActiveSLAOption={changeActiveSLAOption}\n googleMapsKey={logisticsQuery.logistics.googleMapsKey}\n intl={intl}\n isPickupDetailsActive={false}\n items={[]}\n logisticsInfo={[]}\n onAddressChange={handleSearchAddressChange}\n pickupOptions={pickupOptions}\n rules={rules}\n searchAddress={searchAddress}\n selectedPickupPoint={selectedPickupPoint}\n storePreferencesData={storePreferencesData}\n pickupPoints={pickupPoints}\n isSearching={isSearching}\n height=\"100%\"\n onConfirm={handlePickupConfirm}\n />\n )\n}\n\nPickupModalContainer.propTypes = {\n client: PropTypes.object,\n handlePickedSLA: PropTypes.func,\n intl: PropTypes.object,\n logisticsQuery: PropTypes.object,\n rules: PropTypes.object,\n storePreferencesData: PropTypes.object,\n onConfirm: PropTypes.func,\n}\n\nexport default compose(\n withApollo,\n graphql(logisticsQuery, {\n name: 'logisticsQuery',\n }),\n injectRules,\n injectIntl\n)(PickupModalContainer)\n\n```" } ]
code_address-locator_66d52378
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/ChangeAddress/index.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { useCallback, useState, useRef } from 'react'\nimport Spinner from 'vtex.styleguide/Spinner'\nimport { useModal } from 'vtex.modal/ModalContext'\nimport { ExtensionPoint } from 'vtex.render-runtime'\n\nimport { useAddress, withAddressProvider } from '../AddressContext'\n\nimport AddressList from './AddressList'\nimport '../../global.css'\nimport transformAnimationStyle from '../../utils/transformAnimationStyle'\n\n/**\n * Component responsible for displaying and managing user's address using address.\n */\n\nconst ChangeAddress = () => {\n const { address } = useAddress()\n const { closeModal } = useModal()\n const [isPickupOpen, setPickupOpen] = useState(false)\n const [isLoading, setLoading] = useState(false)\n const wrapperRef = useRef(null)\n\n const handleSelectAddress = useCallback(\n async setAddress => {\n const { orderFormId } = address.orderForm\n setLoading(true)\n const orderForm = await address\n .updateOrderFormShipping({\n variables: {\n orderFormId,\n address: setAddress,\n },\n })\n .catch(() => null)\n setLoading(false)\n if (!orderForm) {\n // TODO: Display error\n }\n closeModal && closeModal()\n },\n [address, closeModal]\n )\n\n const handleOrderFormUpdated = useCallback(() => {\n closeModal && closeModal()\n }, [closeModal])\n\n const handlePickupConfirm = useCallback(() => {\n setPickupOpen(false)\n handleOrderFormUpdated()\n }, [handleOrderFormUpdated, setPickupOpen])\n\n const handlePickupClick = useCallback(() => {\n setPickupOpen(true)\n }, [setPickupOpen])\n return (\n <div\n className=\"overflow-hidden relative br2 flex items-center nh6 nh8-ns nb8 pa8 nt5 nt6-ns\"\n style={{\n minHeight: isPickupOpen ? '75vh' : '50vh',\n }}\n ref={wrapperRef}\n >\n <div style={transformAnimationStyle('110%', isPickupOpen)}>\n <ExtensionPoint\n id=\"address-search\"\n onUpdateOrderForm={handleOrderFormUpdated}\n />\n <ExtensionPoint\n id=\"pickup-selector\"\n loading={isLoading}\n onConfirm={handlePickupConfirm}\n onFindPickupClick={handlePickupClick}\n isPickupOpen={isPickupOpen}\n parentRef={wrapperRef}\n />\n {!isLoading ? (\n <AddressList onSelectAddress={handleSelectAddress} />\n ) : (\n <div className=\"flex flex-grow-1 justify-center items-center\">\n <Spinner />\n </div>\n )}\n </div>\n </div>\n )\n}\n\nexport default withAddressProvider(ChangeAddress)\n\n```" } ]
code_address-locator_2ef3601f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/ChangeAddress/AddressListItem.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { pick } from 'ramda'\n\nconst AddressListItem = ({ address, onSelectAddress, isLastAddress }) => {\n const handleClick = () => {\n const addressFields = pick(\n [\n 'addressType',\n 'city',\n 'complement',\n 'neighborhood',\n 'number',\n 'postalCode',\n 'street',\n 'state',\n 'receiverName',\n 'country',\n 'geoCoordinates',\n ],\n address\n )\n onSelectAddress && onSelectAddress(addressFields)\n }\n\n const { street, number, neighborhood, city } = address\n return (\n <div\n tabIndex={0}\n className={`${!isLastAddress && 'bb b--muted-4'} pv4 dim pointer`}\n onClick={handleClick}\n onKeyDown={e => e.key === 'Enter' && handleClick()}\n >\n <p className=\"ma0 t-body c-on-base\">{`${street}, ${number}`}</p>\n <span className=\"f7 t-small c-muted-2\">\n {!neighborhood ? city : `${neighborhood}, ${city}`}\n </span>\n </div>\n )\n}\n\nAddressListItem.propTypes = {\n address: PropTypes.object.isRequired,\n onSelectAddress: PropTypes.func,\n isLastAddress: PropTypes.bool,\n}\n\nexport default AddressListItem\n\n```" } ]
code_address-locator_b6da5878
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/ChangeAddress/AddressList.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { memo, useMemo } from 'react'\nimport PropTypes from 'prop-types'\nimport { FormattedMessage } from 'react-intl'\nimport { pathOr, uniq } from 'ramda'\n\nimport { useAddress } from '../AddressContext'\nimport AddressListItem from './AddressListItem'\n\nconst MAX_ADDRESS_QUANTITY = 5\n\nconst AddressList = ({ onSelectAddress }) => {\n const { address } = useAddress()\n const availableAddresses = useMemo(() => {\n const filtered = pathOr(\n [],\n ['orderForm', 'shippingData', 'availableAddresses'],\n address\n )\n .filter(\n address =>\n address.city &&\n address.street &&\n address.number &&\n address.addressType !== 'pickup'\n )\n .reverse()\n return uniq(filtered).slice(0, MAX_ADDRESS_QUANTITY)\n }, [address])\n\n if (availableAddresses.length === 0) {\n return null\n }\n\n return (\n <div className=\"vtex-address-locator__address-list pa5\">\n <FormattedMessage id=\"store/address-manager.address-list\">\n {text => <span className=\"t-small f6 c-muted-1\">{text}</span>}\n </FormattedMessage>\n {availableAddresses.map((address, key) => (\n <AddressListItem\n key={key}\n address={address}\n isLastAddress={key === availableAddresses.length - 1}\n onSelectAddress={onSelectAddress}\n />\n ))}\n </div>\n )\n}\n\nAddressList.propTypes = {\n /* Function that will be called when selecting an address */\n onSelectAddress: PropTypes.func,\n}\n\nexport default memo(AddressList)\n\n```" } ]
code_address-locator_926f338d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/AddressSearch/SearchForm.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component, Fragment } from 'react'\nimport { createPortal } from 'react-dom'\nimport { FormattedMessage, injectIntl } from 'react-intl'\nimport PropTypes from 'prop-types'\nimport { withScriptjs } from 'react-google-maps'\nimport { graphql } from 'react-apollo'\nimport { compose, branch, mapProps, renderComponent } from 'recompose'\nimport { path } from 'ramda'\nimport alpha2ToAlpha3 from 'country-iso-2-to-3'\nimport { Alert, Button, Input, Spinner } from 'vtex.styleguide'\n\nimport Autocomplete from './Autocomplete'\n\nimport { withAddress } from '../AddressContext'\nimport logisticsQuery from '../../queries/logistics.gql'\nimport getCurrentPositionPromise from '../../utils/getCurrentPositionPromise'\n\n/**\n * Geolocation error codes. Can be found here:\n * https://developer.mozilla.org/en-US/docs/Web/API/PositionError\n */\nconst ERROR_POSITION_DENIED = 1\nconst ERROR_POSITION_UNAVAILABLE = 2\nconst ERROR_TIMEOUT = 3\nconst ERROR_ADDRESS_NOT_FOUND = 9 // custom ad hoc error code\n\n/**\n * Component responsible for searching the user address in Google Maps API, when\n * inserting it or using navigator geolocation to get current position\n */\nclass SearchForm extends Component {\n static propTypes = {\n /* Google Maps Geolocation API key */\n googleMapKey: PropTypes.string,\n /* Function that will be called after updating the orderform */\n onOrderFormUpdated: PropTypes.func,\n /* Set to loading mode */\n loading: PropTypes.bool,\n country: PropTypes.string,\n }\n\n state = {\n address: null,\n formattedAddress: '',\n shouldDisplayNumberInput: false,\n shouldDisplayComplementInput: false,\n isLoading: false,\n inputError: null,\n inputAddressError: null,\n AlertMessage: false,\n shouldDisplayStreetInput: false,\n hasSearchedStreet: false,\n }\n\n constructor(props) {\n super(props)\n\n this.inputRefs = []\n this.form = React.createRef()\n }\n\n requestGoogleMapsApi = async params => {\n const { lat, long, address } = params\n const { googleMapKey } = this.props\n const baseUrl = `https://maps.googleapis.com/maps/api/geocode/json?key=${googleMapKey}&`\n let suffix = ''\n if (address) {\n suffix = `address=${address}`\n } else if (lat && long) {\n suffix = `latlng=${lat},${long}`\n }\n try {\n const response = await fetch(baseUrl + suffix)\n return await response.json()\n } catch (err) {\n return { results: [] }\n }\n }\n\n /* Use the navigator geolocation to get the user position and retrieve his address using Google Maps API */\n handleSetCurrentPosition = async () => {\n if (navigator.geolocation) {\n this.setState({ isLoading: true })\n try {\n const position = await getCurrentPositionPromise()\n const { latitude, longitude } = position.coords\n const parsedResponse = await this.requestGoogleMapsApi({\n lat: latitude,\n long: longitude,\n })\n\n if (!parsedResponse.results.length) {\n return this.setState({\n inputError: ERROR_ADDRESS_NOT_FOUND,\n isLoading: false,\n })\n }\n\n const place = parsedResponse.results[0]\n const newAddress = this.getParsedAddress(place)\n if (!newAddress.postalCode) {\n return this.setState({\n inputAddressError: ERROR_ADDRESS_NOT_FOUND,\n isLoading: false,\n })\n }\n this.setState({\n address: newAddress,\n shouldDisplayNumberInput: true,\n shouldDisplayComplementInput: true,\n isLoading: false,\n inputError: null,\n inputAddressError: null,\n AlertMessage: null,\n shouldDisplayStreetInput: true,\n hasSearchedStreet: true,\n formattedAddress: place.formatted_address,\n })\n } catch (error) {\n this.setState({ inputError: error, isLoading: false })\n }\n }\n }\n\n handleOnPlaceSelected = place => {\n const errorState = {\n AlertMessage: (\n <FormattedMessage id=\"store/address-locator.address-search-invalid-address\" />\n ),\n address: null,\n shouldDisplayNumberInput: false,\n shouldDisplayComplementInput: false,\n isLoading: false,\n inputError: null,\n inputAddressError: null,\n shouldDisplayStreetInput: false,\n hasSearchedStreet: false,\n }\n if (!place.address_components) {\n return this.setState(errorState)\n }\n const address = this.getParsedAddress(place)\n\n if (!address.city) {\n return this.setState(errorState)\n }\n const isComplete = address.postalCode && address.street\n this.setState({\n address,\n formattedAddress: place.formatted_address,\n shouldDisplayNumberInput: true,\n shouldDisplayComplementInput: true,\n isLoading: false,\n inputError: null,\n inputAddressError: null,\n AlertMessage: null,\n shouldDisplayStreetInput: !isComplete,\n hasSearchedStreet: false,\n })\n }\n\n /**\n * The place object returned from Google Maps API has some extra informations about the address that won't be used when sending\n * to orderform. So, this function will reduce nested address information into a simpler consumable object.\n *\n * @param {Object} place The place object returned from Google Maps API\n * @returns {Object} The reduced address data with only necessary fields/information\n */\n getParsedAddress = place => {\n const parsedAddressComponents = place.address_components.reduce(\n (accumulator, address) => {\n const parsedItem = address.types.reduce(\n (accumulator, type) => ({\n ...accumulator,\n [type]: address.short_name,\n }),\n {}\n )\n return { ...accumulator, ...parsedItem }\n },\n {}\n )\n\n const { lat, lng } = path(['geometry', 'location'], place) || {}\n // lat and lng may come as a function or a double\n const latitude = typeof lat === 'function' ? lat() : lat\n const longitude = typeof lng === 'function' ? lng() : lng\n\n const address = {\n addressType: 'residential',\n city:\n parsedAddressComponents.administrative_area_level_2 ||\n parsedAddressComponents.locality,\n complement: '',\n /* Google Maps API returns Alpha-2 ISO codes, but checkout API requires Alpha-3 */\n country: alpha2ToAlpha3(parsedAddressComponents.country),\n neighborhood: parsedAddressComponents.sublocality_level_1,\n number: parsedAddressComponents.street_number || '',\n postalCode: parsedAddressComponents.postal_code,\n receiverName: '',\n state: parsedAddressComponents.administrative_area_level_1,\n street: parsedAddressComponents.route,\n geoCoordinates: latitude && longitude ? [longitude, latitude] : null,\n }\n\n return address\n }\n\n checkAddressWithGoogle = async () => {\n const { address } = this.state\n try {\n const parsedResponse = await this.requestGoogleMapsApi({\n address: `${address.street} ${address.number}`,\n })\n if (!parsedResponse.results.length) {\n return\n }\n\n const place = parsedResponse.results[0]\n const googleAddress = this.getParsedAddress(place)\n if (!googleAddress.postalCode) {\n return\n }\n\n if (googleAddress.postalCode !== address.postalCode) {\n // TODO use sentry to log\n }\n if (\n address.geoCoordinates[0] !== googleAddress.geoCoordinates[0] ||\n address.geoCoordinates[1] !== googleAddress.geoCoordinates[1]\n ) {\n // TODO use sentry to log\n }\n return googleAddress.geoCoordinates\n } catch (err) {\n return null\n }\n }\n\n handleFormSubmit = async e => {\n e.preventDefault()\n\n const canSubmit = this.canSubmit()\n\n if (!canSubmit) {\n const formElement = this.form.current\n const inputs = Array.from(\n formElement ? formElement.querySelectorAll('input') : []\n )\n for (const input of inputs) {\n if (input.value === '') {\n input.focus()\n break\n }\n }\n return\n }\n\n this.setState({\n isLoading: true,\n inputError: null,\n AlertMessage: null,\n })\n const { address: addressContext, onOrderFormUpdated } = this.props\n const { address } = this.state\n\n try {\n const googleCoords = await this.checkAddressWithGoogle()\n\n const response = await addressContext.updateOrderFormShipping({\n variables: {\n orderFormId: addressContext.orderForm.orderFormId,\n address: {\n ...address,\n geoCoordinates: googleCoords || address.geoCoordinates,\n },\n },\n })\n\n const newAddress = path(\n ['data', 'updateOrderFormShipping', 'shippingData', 'address'],\n response\n )\n\n if (!newAddress || !this.getIsAddressValid(newAddress)) {\n return this.setState({\n isLoading: false,\n inputError: ERROR_ADDRESS_NOT_FOUND,\n })\n }\n\n if (onOrderFormUpdated) {\n onOrderFormUpdated()\n }\n } catch (e) {\n this.setState({\n isLoading: false,\n AlertMessage: (\n <FormattedMessage id=\"store/address-locator.graphql-error\" />\n ),\n })\n }\n }\n\n getIsAddressValid = address =>\n address.city && address.street && address.number\n\n handleAddressKeyChanged = (e, key) => {\n const { address } = this.state\n if (!address) return\n address[key] = e.target.value\n this.setState({ address })\n }\n\n handleAddressChanged = e =>\n this.setState({\n address: undefined,\n formattedAddress: e.target.value,\n })\n\n handleCloseAlert = () => this.setState({ AlertMessage: null })\n\n canUsePortal = () => Boolean(document && document.body)\n\n getErrorMessage = errorCode => {\n switch (errorCode) {\n case ERROR_ADDRESS_NOT_FOUND:\n return (\n <FormattedMessage id=\"store/address-locator.address-search-not-found-error\" />\n )\n case ERROR_TIMEOUT:\n return (\n <FormattedMessage id=\"store/address-locator.address-search-timeout-error\" />\n )\n case ERROR_POSITION_UNAVAILABLE:\n return (\n <FormattedMessage id=\"store/address-locator.address-search-position-unavailable-error\" />\n )\n case ERROR_POSITION_DENIED:\n return (\n <FormattedMessage id=\"store/address-locator.address-search-position-denied-error\" />\n )\n default:\n return null\n }\n }\n\n renderExtraDataInput = (field, type) => {\n const { address } = this.state\n const {\n intl: { formatMessage },\n } = this.props\n if (!address) return null\n\n return (\n <div className=\"mb4\">\n <Input\n type={type}\n value={address[field]}\n placeholder={formatMessage({\n id: `store/address-locator.address-search-${field}-placeholder`,\n })}\n size=\"large\"\n label={formatMessage({\n id: `store/address-locator.address-search-${field}-label`,\n })}\n onChange={e => this.handleAddressKeyChanged(e, field)}\n />\n </div>\n )\n }\n\n canSubmit = () => {\n const { address } = this.state\n return address && address.number && address.street\n }\n\n render() {\n const {\n formattedAddress,\n isLoading,\n inputError,\n AlertMessage,\n shouldDisplayStreetInput,\n hasSearchedStreet,\n shouldDisplayNumberInput,\n shouldDisplayComplementInput,\n } = this.state\n const { loading: isDisabled, country } = this.props\n\n return (\n <Fragment>\n {AlertMessage &&\n this.canUsePortal() &&\n createPortal(\n <div className=\"fixed top-0 z-max\">\n <Alert type=\"warning\" onClose={this.handleCloseAlert}>\n {AlertMessage}\n </Alert>\n </div>,\n document.body\n )}\n <form\n className=\"address-search w-100\"\n ref={this.form}\n onSubmit={this.handleFormSubmit}\n >\n <div className=\"mb4\">\n {!hasSearchedStreet && (\n <div className=\"mb4\">\n <div className=\"relative input--icon-right\">\n <Autocomplete\n isLoading={isDisabled}\n onPlaceSelected={this.handleOnPlaceSelected}\n types={['address']}\n componentRestrictions={{ country }}\n value={formattedAddress}\n errorMessage={this.getErrorMessage(inputError)}\n onChange={this.handleAddressChanged}\n onSuffixPress={this.handleSetCurrentPosition}\n hideLabel\n />\n </div>\n </div>\n )}\n\n {shouldDisplayStreetInput &&\n hasSearchedStreet &&\n this.renderExtraDataInput('street', 'text')}\n {shouldDisplayStreetInput &&\n hasSearchedStreet &&\n this.renderExtraDataInput('neighborhood', 'text')}\n {shouldDisplayStreetInput &&\n hasSearchedStreet &&\n this.renderExtraDataInput('postalCode', 'text')}\n {shouldDisplayNumberInput &&\n this.renderExtraDataInput('number', 'number')}\n {shouldDisplayComplementInput &&\n this.renderExtraDataInput('complement', 'text')}\n </div>\n <Button className=\"w-100\" type=\"submit\" isLoading={isLoading} block>\n <FormattedMessage id=\"store/address-locator.address-search-button\" />\n </Button>\n </form>\n </Fragment>\n )\n }\n}\n\nconst LoadingSpinner = () => (\n <div className=\"flex flex-grow-1 justify-center items-center\">\n <Spinner />\n </div>\n)\n\nexport default compose(\n graphql(logisticsQuery, {\n name: 'logisticsQuery',\n }),\n branch(\n props => !props.logisticsQuery.loading,\n compose(\n mapProps(ownerProps => {\n const { googleMapsKey } = ownerProps.logisticsQuery.logistics\n const {\n onOrderFormUpdated,\n updateOrderFormMutation,\n country,\n } = ownerProps\n\n return {\n googleMapKey: googleMapsKey,\n googleMapURL: `https://maps.googleapis.com/maps/api/js?key=${googleMapsKey}&v=3.exp&libraries=places`,\n loadingElement: <SearchForm loading />,\n onOrderFormUpdated: onOrderFormUpdated,\n country,\n updateOrderFormMutation,\n }\n }),\n withScriptjs\n ),\n renderComponent(LoadingSpinner)\n ),\n withAddress,\n injectIntl\n)(SearchForm)\n\n```" } ]
code_address-locator_05377623
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/AddressSearch/index.js from the address-locator 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 { useRuntime } from 'vtex.render-runtime'\n\nimport SearchForm from './SearchForm'\n\nconst AddressSearch = ({ onUpdateOrderForm }) => {\n const {\n culture: { country },\n } = useRuntime()\n\n return (\n <div className=\"vtex-address-modal__address\">\n <h1 className=\"t-heading-1 mt0 mb4 mb7-ns\">\n <FormattedMessage id=\"store/address-locator.address-page-title\" />\n </h1>\n <SearchForm onOrderFormUpdated={onUpdateOrderForm} country={country} />\n <hr className=\"mv5 mv6-ns bg-muted-3 bn\" style={{ height: 1 }} />\n </div>\n )\n}\n\nAddressSearch.propTypes = {\n onUpdateOrderForm: PropTypes.func.isRequired,\n}\n\nexport default AddressSearch\n\n```" } ]
code_address-locator_522c64e3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/AddressSearch/Autocomplete.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { Input } from 'vtex.styleguide'\nimport { injectIntl } from 'react-intl'\n\nimport LocationInputIcon from './LocationInputIcon'\n\n/*\n\nBased on: https://github.com/ErrorPro/react-google-autocomplete/blob/master/src/index.js\n\n*/\n\nclass ReactGoogleAutocomplete extends React.Component {\n static propTypes = {\n onPlaceSelected: PropTypes.func,\n types: PropTypes.arrayOf(PropTypes.string),\n componentRestrictions: PropTypes.shape({\n country: PropTypes.string,\n }),\n bounds: PropTypes.object,\n isLoading: PropTypes.bool,\n value: PropTypes.string,\n errorMessage: PropTypes.string,\n onChange: PropTypes.func,\n onSuffixPress: PropTypes.func,\n hideLabel: PropTypes.bool,\n }\n\n constructor(props) {\n super(props)\n this.input = React.createRef()\n this.autocomplete = null\n this.event = null\n }\n\n componentDidMount() {\n if (!this.props.isLoading) {\n this.setup()\n }\n }\n\n setup = () => {\n const { types = ['(cities)'], componentRestrictions, bounds } = this.props\n const config = {\n types,\n bounds,\n }\n\n if (componentRestrictions) {\n config.componentRestrictions = componentRestrictions\n }\n\n this.disableAutofill()\n\n this.autocomplete = new google.maps.places.Autocomplete(\n this.input.current,\n config\n )\n\n this.event = this.autocomplete.addListener(\n 'place_changed',\n this.onSelected.bind(this)\n )\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.isLoading && !this.props.isLoading) {\n this.setup()\n }\n }\n\n disableAutofill() {\n // Autofill workaround adapted from https://stackoverflow.com/questions/29931712/chrome-autofill-covers-autocomplete-for-google-maps-api-v3/49161445#49161445\n if (window.MutationObserver) {\n const observerHack = new MutationObserver(() => {\n observerHack.disconnect()\n if (this.input.current) {\n this.input.current.autocomplete = 'disable-autofill'\n }\n })\n observerHack.observe(this.input.current, {\n attributes: true,\n attributeFilter: ['autocomplete'],\n })\n }\n }\n\n componentWillUnmount() {\n this.event && this.event.remove()\n }\n\n onSelected() {\n if (this.props.onPlaceSelected) {\n this.props.onPlaceSelected(this.autocomplete.getPlace())\n }\n }\n\n render() {\n const {\n value,\n errorMessage,\n onChange,\n onSuffixPress,\n hideLabel,\n intl: { formatMessage },\n } = this.props\n\n return (\n <Input\n ref={this.input}\n key=\"input\"\n type=\"text\"\n value={value}\n errorMessage={errorMessage}\n placeholder={formatMessage({\n id: 'store/address-locator.address-search-placeholder',\n })}\n size=\"large\"\n label={\n !hideLabel &&\n formatMessage({ id: 'store/address-locator.address-search-label' })\n }\n onChange={onChange}\n suffix={<LocationInputIcon onClick={onSuffixPress} />}\n />\n )\n }\n}\n\nexport default injectIntl(ReactGoogleAutocomplete)\n\n```" } ]
code_address-locator_e0241e4f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/AddressSearch/LocationInputIcon.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nimport { IconLocationInput } from 'vtex.store-icons'\n\nconst LocationInputIcon = ({ onClick }) => {\n return (\n <span\n onClick={onClick}\n className=\"pointer vtex-input-icon vtex-input-icon--location c-action-primary\"\n >\n <IconLocationInput size={18} viewBox=\"0 0 18 18\" />\n </span>\n )\n}\n\nLocationInputIcon.propTypes = {\n onClick: PropTypes.func,\n}\n\nexport default LocationInputIcon\n\n```" } ]
code_address-locator_c9162e0e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/AddressChallenge/AddressChallenge.css from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n@keyframes appear {\n 0% {\n opacity: 0;\n }\n 99% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n.spinnerAppear {\n opacity: 0;\n animation: appear 3s;\n animation-fill-mode: forwards;\n}\n\n```" } ]
code_address-locator_8d3522f3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of address-locator/react/components/AddressChallenge/index.js from the address-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { useEffect } from 'react'\n\nimport { graphql } from 'react-apollo'\nimport { path, compose } from 'ramda'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { Spinner } from 'vtex.styleguide'\nimport { address as addressQuery } from 'vtex.store-resources/Queries'\nimport styles from './AddressChallenge.css'\n\nconst ADDRESS_PATH = '/address'\n\nconst redirectToAddress = (page, navigate) => {\n const pathName = window.location.pathname.replace(/\\/$/, '')\n if (page !== 'store.address' && pathName !== ADDRESS_PATH) {\n navigate({\n fallbackToWindowLocation: false,\n query: `returnUrl=${encodeURIComponent(pathName)}`,\n page: 'store.address',\n })\n }\n}\n\nconst hasShippingAddress = compose(\n Boolean,\n path(['shippingData', 'address'])\n)\n\nconst AddressChallenge = ({ data, children }) => {\n const { navigate, page } = useRuntime()\n const { loading, orderForm = {}, error } = data\n const orderFormHasAddress = hasShippingAddress(orderForm)\n const hasError = !!error\n useEffect(() => {\n if (!loading && !hasError && !orderFormHasAddress) {\n redirectToAddress(page, navigate)\n }\n }, [loading, orderFormHasAddress, page, navigate, hasError])\n\n if (loading) {\n return (\n <div className=\"flex justify-center items-center absolute top-0 bottom-0 left-0 right-0 bg-base\">\n <div className={styles.spinnerAppear}>\n <Spinner />\n </div>\n </div>\n )\n }\n if (!loading && orderFormHasAddress) {\n return children\n }\n return null\n}\n\nexport default graphql(addressQuery, {\n options: () => ({ ssr: false }),\n})(AddressChallenge)\n\n```" } ]
code_expertsender_f1704150
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of expertsender/docs/README.md from the expertsender VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# ExpertSender\n\nOpen the VTEX APP Store and install the app on your store.\n\nor\n\nRun the following command:\n\n```sh\nvtex install vtex.expertsender@1.x\n```\n\nNext, open the app settings on your admin and fill the form with Click Domain, `aid`, and `wid`.\n\n### Setup in Cart and Checkout page\n\nOpen your admin in the Checkout section in the `checkout6-custom.js`:\n\nhttps://ACCOUNT.myvtex.com/admin/portal/#/sites/default/code/files/checkout6-custom.js\n\nAdd the following snippet in the file and replace `\"YOUR-AID\"`, `\"YOUR-WID\"`, and `\"YOUR-CLICKDOMAIN\"` with the proper values:\n\n```js\n// ExpertSender\n(function () {\n window.adraker = {\n aid: \"YOUR-AID\",\n wid: \"YOUR-WID\",\n clickDomain: \"YOUR-CLICKDOMAIN\"\n };\n var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];\n g.type = 'text/javascript'; g.async = true; g.defer = true;\n g.src = \"//adraker-dev.azureedge.net/web.min.js?id=\" + aid + \",\" + wid;\n s.parentNode.insertBefore(g, s);\n})();\n```\n\nClick Save.\n\n```" } ]
code_search-graphql_557b1f7f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/utils/generateDoc.js from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nconst fs = require('fs')\n\nconst { loadFilesSync } = require('@graphql-tools/load-files')\nconst { mergeTypeDefs } = require('@graphql-tools/merge')\nconst graphql = require('graphql')\nconst {\n loadSchemaJSON,\n renderSchema,\n} = require('graphql-markdown')\n\nconst SCHEMA_PATH = `${__dirname}/../graphql/**/*.graphql`\nconst BUNDLE_PATH = `${__dirname}/../joined.graphql`\nconst MARKDOWN_PATH = `${__dirname}/../docs/README.md`\n\n;(async () => {\n // Generate bundle\n const loadedFiles = loadFilesSync(SCHEMA_PATH)\n const typeDefs = mergeTypeDefs(loadedFiles)\n const printedTypeDefs = graphql.print(typeDefs)\n fs.writeFileSync(BUNDLE_PATH, printedTypeDefs)\n\n // Generate markdown\n fs.unlinkSync(MARKDOWN_PATH)\n const schema = await loadSchemaJSON(BUNDLE_PATH, { graphql })\n renderSchema(schema, {\n title: 'search-graphql',\n prologue:\n '# VTEX Search GraphQL\\n\\nThis app exports a GraphQL schema for search results on VTEX Stores.\\n\\nThe default implementation for this schema is on [vtex.search-resolver](https://github.com/vtex-apps/search-resolver) app.\\n\\n### Usage\\n\\nTo use it in your app, decalre it on your manifest file like:\\n```\\n\"dependencies\": {\\n \"vtex.search-graphql\": \"0.x\"\\n}\\n```\\n\\nYou may then use it in your front end component queries, for example, write file `productQuery.gql`:\\n```graphql\\nquery ProductQuery($slug: String) {\\n product(identifier: { field: slug, value: $slug}) @context(provider: \"vtex.search-graphql\") {\\n productName\\n }\\n}\\n```\\n\\nTo resolve this query, you need to have a app that implements the schema declared in this app, such as: [vtex.search-resolver](https://github.com/vtex-apps/search-resolver)',\n printer: (doc) => fs.appendFileSync(MARKDOWN_PATH, doc)\n })\n\n // Delete temp file\n fs.unlinkSync(BUNDLE_PATH)\n})()\n\n```" } ]
code_search-graphql_99caa771
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/schema.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nenum SORT {\n ASC\n DESC\n}\n\ntype Query {\n \"\"\"\n Returns a specified product\n \"\"\"\n product(\n \"\"\"\n Product slug\n \"\"\"\n slug: String\n \"\"\"\n Product identifier\n \"\"\"\n identifier: ProductUniqueIdentifier\n \"\"\"\n Seller id encoded with base64 according to this format SW#{sellerId}\n \"\"\"\n regionId: String\n \"\"\"\n Trade Policy\n \"\"\"\n salesChannel: Int\n ): Product @cacheControl(scope: SEGMENT, maxAge: SHORT) @withSegment\n\n \"\"\"\n Lists the banners registered for a given query. Check the [configuring banners documentation](https://help.vtex.com/en/tracks/vtex-intelligent-search--19wrbB7nEQcmwzDPl1l4Cb/4ViKEivLJtJsvpaW0aqIQ5) for a full explanation of the banner feature.\n \"\"\"\n banners(\n \"\"\"\n Search term. It can contain any character.\n \"\"\"\n fullText: String = \"\"\n \"\"\"\n List of the selected facets\n\n The order in which the terms appear is not relevant to the search.\n\n You can also repeat the same `facetKey` several times for different values.\n \"\"\"\n selectedFacets: [SelectedFacetInput]\n ): Banners @cacheControl(scope: SEGMENT, maxAge: SHORT) @withSegment\n\n \"\"\"\n Tries to correct a misspelled term from the search.\n \"\"\"\n correction(\n \"\"\"\n Search term. It can contain any character.\n \"\"\"\n fullText: String = \"\"\n ): Correction @cacheControl(scope: SEGMENT, maxAge: SHORT) @withSegment\n\n \"\"\"\n Lists suggested terms similar to the search term.\n \"\"\"\n searchSuggestions(\n \"\"\"\n Search term. It can contain any character.\n \"\"\"\n fullText: String!\n \"\"\"\n As fuzzy and operator, it controls the search state, but it is for general purposes. This field allows the search engines to apply features that are not handled by the other fields.\n The possible values in this field are defined by each search engine.\n \"\"\"\n searchState: String\n ): SearchSuggestions\n @cacheControl(scope: SEGMENT, maxAge: MEDIUM)\n @withSegment\n\n \"\"\"\n Lists the products for a given query.\n \"\"\"\n productSearch(\n \"\"\"\n **Deprecated**. Use `fullText` instead.\n \"\"\"\n query: String = \"\"\n \"\"\"\n Search term. It can contain any character.\n \"\"\"\n fullText: String = \"\"\n \"\"\"\n **Deprecated**. Use `selectedFacets` instead.\n \"\"\"\n map: String = \"\"\n \"\"\"\n List of the selected facets\n\n The order in which the terms appear is not relevant to the search.\n\n You can also repeat the same `facetKey` several times for different values.\n \"\"\"\n selectedFacets: [SelectedFacetInput]\n \"\"\"\n **Deprecated**. Use `selectedFacets` instead.\n \"\"\"\n category: String = \"\"\n \"\"\"\n **Deprecated**. Use `selectedFacets` instead.\n \"\"\"\n specificationFilters: [String]\n \"\"\"\n Filter by price range. e.g.: {a} TO {b} - {a} is the minimum price \"from\" and {b} is the highest price \"to\"\n \"\"\"\n priceRange: String = \"\"\n \"\"\"\n **Deprecated**. Use `selectedFacets` instead.\n \"\"\"\n collection: String = \"\"\n \"\"\"\n Filter by availability at a specific sales channel. e.g.: salesChannel:4 if want filter by available products for the sales channel 4\n \"\"\"\n salesChannel: String = \"\"\n \"\"\"\n Order by a criteria. OrderByPriceDESC/OrderByPriceASC, OrderByTopSaleDESC, OrderByReviewRateDESC, OrderByNameASC/OrderByNameDESC, OrderByReleaseDateDESC, OrderByBestDiscountDESC, OrderByScoreDESC\n If you want to sort by a specification, use the format {specification key}:{asc|desc}. For example: 'pricePerUnit:asc' or 'size:desc' (this only works on `vtex.search-resolver@1.x`)\n \"\"\"\n orderBy: String = \"OrderByScoreDESC\"\n \"\"\"\n Pagination item start\n \"\"\"\n from: Int = 0\n \"\"\"\n Pagination item end\n \"\"\"\n to: Int = 9\n \"\"\"\n If true, uses isAvailablePerSalesChannel_ parameter on query with segment's sales channel. Will override any given salesChannel arg\n \"\"\"\n hideUnavailableItems: Boolean = false\n \"\"\"\n If you want faster searches and do not care about most up to date prices and promotions, use skip value.\n \"\"\"\n simulationBehavior: SimulationBehavior = default\n \"\"\"\n Each search engine has its own database, but this database might not have all the product information like `clusterHighlights` or `productClusters`.\n As an alternative, the search engine may use the VTEX API to complete this information by setting this field to true.\n \"\"\"\n productOriginVtex: Boolean = false\n \"\"\"\n Indicates how the search-engine will deal with the fullText if there is more than one word. Set `and` if the returned products must have all the words in its metadata or `or` otherwise.\n \"\"\"\n operator: Operator\n \"\"\"\n Indicates how the search engine will correct misspelled words by using fuzzy logic.\n It can be a number representing the max number of misspelled letters, or the string `auto` suggesting that the search-engine should set this value by itself.\n \"\"\"\n fuzzy: String\n \"\"\"\n As fuzzy and operator, it controls the search state, but it is for general purposes. This field allows the search engines to apply features that are not handled by the other fields.\n The possible values in this field are defined by each search engine.\n \"\"\"\n searchState: String\n\n \"\"\"\n Search options that customize the search result.\n \"\"\"\n options: Options\n variant: String\n\n \"\"\"\n **Deprecated**. Use `advertisementOptions` instead.\n \"\"\"\n showSponsored: Boolean\n\n \"\"\"\n Whether or not to fetch sponsored products. If there are sponsored products for that context, it will be returned.\n \"\"\"\n advertisementOptions: AdvertisementOptions\n \"\"\"\n Origin of the request for tracking purposes\n \"\"\"\n origin: String\n ): ProductSearch @cacheControl(scope: SEGMENT, maxAge: SHORT) @withSegment\n\n sponsoredProducts(\n \"\"\"\n Search term. It can contain any character.\n \"\"\"\n fullText: String = \"\"\n \"\"\"\n List of the selected facets\n\n The order in which the terms appear is not relevant to the search.\n\n You can also repeat the same `facetKey` several times for different values.\n \"\"\"\n selectedFacets: [SelectedFacetInput]\n \"\"\"\n Filter by price range. e.g.: {a} TO {b} - {a} is the minimum price \"from\" and {b} is the highest price \"to\"\n \"\"\"\n priceRange: String = \"\"\n \"\"\"\n Filter by availability at a specific sales channel. e.g.: salesChannel:4 if want filter by available products for the sales channel 4\n \"\"\"\n salesChannel: String = \"\"\n \"\"\"\n Order by a criteria. OrderByPriceDESC/OrderByPriceASC, OrderByTopSaleDESC, OrderByReviewRateDESC, OrderByNameASC/OrderByNameDESC, OrderByReleaseDateDESC, OrderByBestDiscountDESC, OrderByScoreDESC\n If you want to sort by a specification, use the format {specification key}:{asc|desc}. For example: \"pricePerUnit:asc\" or \"size:desc\" (this only works on `vtex.search-resolver@1.x`)\n \"\"\"\n orderBy: String = \"OrderByScoreDESC\"\n \"\"\"\n Pagination item start\n \"\"\"\n from: Int = 0\n \"\"\"\n Pagination item end\n \"\"\"\n to: Int = 9\n \"\"\"\n If true, uses isAvailablePerSalesChannel_ parameter on query with segment's sales channel. Will override any given salesChannel arg\n \"\"\"\n hideUnavailableItems: Boolean = false\n \"\"\"\n If you want faster searches and do not care about most up to date prices and promotions, use skip value.\n \"\"\"\n simulationBehavior: SimulationBehavior = default\n \"\"\"\n Each search engine has its own database, but this database might not have all the product information like `clusterHighlights` or `productClusters`.\n As an alternative, the search engine may use the VTEX API to complete this information by setting this field to true.\n \"\"\"\n productOriginVtex: Boolean = false\n \"\"\"\n Indicates how the search-engine will deal with the fullText if there is more than one word. Set `and` if the returned products must have all the words in its metadata or `or` otherwise.\n \"\"\"\n operator: Operator\n \"\"\"\n Indicates how the search engine will correct misspelled words by using fuzzy logic.\n It can be a number representing the max number of misspelled letters, or the string `auto` suggesting that the search-engine should set this value by itself.\n \"\"\"\n fuzzy: String\n \"\"\"\n As fuzzy and operator, it controls the search state, but it is for general purposes. This field allows the search engines to apply features that are not handled by the other fields.\n The possible values in this field are defined by each search engine.\n \"\"\"\n searchState: String\n\n \"\"\"\n Search options that customize the search result.\n \"\"\"\n options: Options\n\n \"\"\"\n Identifier for users, logged in or not. Used for A/B tests.\n \"\"\"\n anonymousId: String\n\n \"\"\"\n Identifier for user device, used for analytics purposes.\n \"\"\"\n macId: String\n\n \"\"\"\n Identifier for user ID if logged in, used for analytics purposes.\n \"\"\"\n userId: String\n ): [Product] @cacheControl(scope: SEGMENT, maxAge: SHORT) @withSegment\n\n searchMetadata(\n \"\"\"\n Terms that is used in search e.g.: eletronics/samsung\n \"\"\"\n query: String = \"\"\n \"\"\"\n Text inputted by the user as the search term\n \"\"\"\n fullText: String = \"\"\n \"\"\"\n Defines terms types: Brand, Category, Department e.g.: c,b\n \"\"\"\n map: String = \"\"\n \"\"\"\n List of the selected facets\n\n The order in which the terms appear is not relevant to the search.\n\n You can also repeat the same `facetKey` several times for different values.\n \"\"\"\n selectedFacets: [SelectedFacetInput]\n ): SearchMetadata @cacheControl(scope: PUBLIC, maxAge: MEDIUM) @withSegment\n\n \"\"\"\n Returns products list filtered and ordered\n \"\"\"\n products(\n \"\"\"\n Terms that is used in search e.g.: eletronics/samsung\n \"\"\"\n query: String = \"\"\n \"\"\"\n Defines terms types: Brand, Category, Department e.g.: c,b\n \"\"\"\n map: String = \"\"\n \"\"\"\n Filter by category. {a}/{b} - {a} and {b} are categoryIds\n \"\"\"\n category: String = \"\"\n \"\"\"\n Array of product specification. specificationFilter_{a}:{b} - {a} is the specificationId, {b} = specification value\n \"\"\"\n specificationFilters: [String]\n \"\"\"\n Filter by price range. e.g.: {a} TO {b} - {a} is the minimum price \"from\" and {b} is the highest price \"to\"\n \"\"\"\n priceRange: String = \"\"\n \"\"\"\n Filter by collection. where collection also know as productClusterId\n \"\"\"\n collection: String = \"\"\n \"\"\"\n Filter by availability at a specific sales channel. e.g.: salesChannel:4 if want filter by available products for the sales channel 4\n \"\"\"\n salesChannel: String = \"\"\n \"\"\"\n Order by a criteria. OrderByPriceDESC/OrderByPriceASC, OrderByTopSaleDESC, OrderByReviewRateDESC, OrderByNameASC/OrderByNameDESC, OrderByReleaseDateDESC, OrderByBestDiscountDESC, OrderByScoreDESC\n \"\"\"\n orderBy: String = \"OrderByScoreDESC\"\n \"\"\"\n Pagination item start\n \"\"\"\n from: Int = 0\n \"\"\"\n Pagination item end\n \"\"\"\n to: Int = 9\n \"\"\"\n If true, uses isAvailablePerSalesChannel_ parameter on query with segment's sales channel. Will override any given salesChannel arg\n \"\"\"\n hideUnavailableItems: Boolean = false\n \"\"\"\n If you want faster searches and do not care about most up to date prices and promotions, use skip value.\n \"\"\"\n simulationBehavior: SimulationBehavior = default\n \"\"\"\n List of shipping options to filter products\n \"\"\"\n shippingOptions: [String]\n variant: String\n \"\"\"\n Options for advertisement in this search request.\n \"\"\"\n advertisementOptions: AdvertisementOptions\n \"\"\"\n As fuzzy and operator, it controls the search state, but it is for general purposes. This field allows the search engines to apply features that are not handled by the other fields.\n The possible values in this field are defined by each search engine.\n \"\"\"\n searchState: String\n ): [Product] @cacheControl(scope: SEGMENT, maxAge: SHORT) @withSegment\n\n productRecommendations(\n identifier: ProductUniqueIdentifier\n type: CrossSelingInputEnum\n groupBy: CrossSelingGroupByEnum\n \"\"\"\n As fuzzy and operator, it controls the search state, but it is for general purposes. This field allows the search engines to apply features that are not handled by the other fields.\n The possible values in this field are defined by each search engine.\n \"\"\"\n searchState: String\n ): [Product] @cacheControl(scope: SEGMENT, maxAge: SHORT) @withSegment\n\n productsByIdentifier(\n field: ProductUniqueIdentifierField!\n values: [ID!]\n \"\"\"\n Filter by availability at a specific sales channel.\n \"\"\"\n salesChannel: String\n ): [Product] @cacheControl(scope: SEGMENT, maxAge: SHORT) @withSegment\n\n \"\"\"\n Returns facets category\n \"\"\"\n facets(\n \"\"\"\n **Deprecated**. Use `fullText` instead.\n \"\"\"\n query: String = \"\"\n \"\"\"\n Search term. It can contain any character.\n \"\"\"\n fullText: String = \"\"\n \"\"\"\n **Deprecated**. Use `selectedFacets` instead.\n \"\"\"\n map: String = \"\"\n \"\"\"\n List of the selected facets\n\n The order in which the terms appear is not relevant to the search.\n\n You can also repeat the same `facetKey` several times for different values.\n \"\"\"\n selectedFacets: [SelectedFacetInput] = []\n \"\"\"\n If true, uses isAvailablePerSalesChannel_ parameter on query with segment's sales channel.\n \"\"\"\n hideUnavailableItems: Boolean = false\n \"\"\"\n If true, remove hidden facets from the result.\n \"\"\"\n removeHiddenFacets: Boolean = false\n \"\"\"\n If Static, ignores SpecificationFilters received on the map and query when returning\n the facets available, which makes the facets never change.\n \"\"\"\n behavior: String = \"Static\"\n \"\"\"\n Indicates how the search-engine will deal with the fullText if there is more than one word. Set `and` if the returned products must have all the words in its metadata or `or` otherwise.\n \"\"\"\n operator: Operator\n \"\"\"\n Indicates how the search engine will correct misspelled words by using fuzzy logic.\n It can be a number representing the max number of misspelled letters, or the string `auto` suggesting that the search-engine should set this value by itself.\n \"\"\"\n fuzzy: String\n \"\"\"\n As fuzzy and operator, it controls the search state, but it is for general purposes. This field allows the search engines to apply features that are not handled by the other fields.\n The possible values in this field are defined by each search engine.\n \"\"\"\n searchState: String\n \"\"\"\n Pagination item start\n \"\"\"\n from: Int\n \"\"\"\n Pagination item end\n \"\"\"\n to: Int\n \"\"\"\n Determines the behavior of the category tree\n \"\"\"\n categoryTreeBehavior: CategoryTreeBehavior = default\n \"\"\"\n Initial attributes (based on the `initialMap` parameter)\n \"\"\"\n initialAttributes: String\n \"\"\"\n Variant used to A/B test\n \"\"\"\n variant: String\n ): Facets @cacheControl(scope: SEGMENT, maxAge: MEDIUM) @withSegment\n\n \"\"\"\n Get auto complete suggestions in search\n \"\"\"\n autocomplete(\n \"\"\"\n Number of items that is returned\n \"\"\"\n maxRows: Int = 12\n \"\"\"\n Terms that is used in search e.g.: iphone\n \"\"\"\n searchTerm: String\n ): Suggestions @cacheControl(scope: SEGMENT, maxAge: MEDIUM) @withSegment\n\n \"\"\"\n Get list of the 10 most searched terms\n \"\"\"\n topSearches(\n \"\"\"\n As fuzzy and operator, it controls the search state, but it is for general purposes. This field allows the search engines to apply features that are not handled by the other fields.\n The possible values in this field are defined by each search engine.\n \"\"\"\n searchState: String\n ): SearchSuggestions\n @cacheControl(scope: SEGMENT, maxAge: MEDIUM)\n @withSegment\n\n \"\"\"\n Lists the suggested terms and attributes similar to the search term.\n \"\"\"\n autocompleteSearchSuggestions(\n \"\"\"\n Search term. It can contain any character.\n \"\"\"\n fullText: String!\n \"\"\"\n As fuzzy and operator, it controls the search state, but it is for general purposes. This field allows the search engines to apply features that are not handled by the other fields.\n The possible values in this field are defined by each search engine.\n \"\"\"\n searchState: String\n ): SearchSuggestions\n @cacheControl(scope: SEGMENT, maxAge: MEDIUM)\n @withSegment\n\n \"\"\"\n Get product suggestions\n \"\"\"\n productSuggestions(\n \"\"\"\n Text inputted by the user as the search term\n \"\"\"\n fullText: String!\n \"\"\"\n Selected facet key\n \"\"\"\n facetKey: String\n \"\"\"\n Selected facet value\n \"\"\"\n facetValue: String\n \"\"\"\n Each search engine has its own database, but this database might not have all the product information like `clusterHighlights` or `productClusters`.\n As an alternative, the search engine may use the VTEX API to complete this information by setting this field to true.\n \"\"\"\n productOriginVtex: Boolean = false\n \"\"\"\n If you want faster searches and do not care about most up to date prices and promotions, use skip value.\n \"\"\"\n simulationBehavior: SimulationBehavior = default\n \"\"\"\n If true, uses isAvailablePerSalesChannel_ parameter on query with segment's sales channel\n \"\"\"\n hideUnavailableItems: Boolean\n \"\"\"\n Seller id encoded with base64 according to this format SW#{sellerId}\n \"\"\"\n regionId: String\n \"\"\"\n Sales Channel related to the region ID\n \"\"\"\n salesChannel: Int\n \"\"\"\n Order by a criteria. OrderByPriceDESC/OrderByPriceASC, OrderByTopSaleDESC, OrderByReviewRateDESC, OrderByNameASC/OrderByNameDESC, OrderByReleaseDateDESC, OrderByBestDiscountDESC, OrderByScoreDESC\n If you want to sort by a specification, use the format {specification key}:{asc|desc}. For example: \"pricePerUnit:asc\" or \"size:desc\" (this only works on `vtex.search-resolver@1.x`)\n \"\"\"\n orderBy: String = \"OrderByScoreDESC\"\n \"\"\"\n Number of product suggestions that should be returned\n \"\"\"\n count: Int\n \"\"\"\n List of shipping options to filter suggestions\n \"\"\"\n shippingOptions: [String]\n variant: String\n \"\"\"\n Whether or not to fetch sponsored products. If there are sponsored products for that context, it will be returned.\n \"\"\"\n advertisementOptions: AdvertisementOptions\n \"\"\"\n Origin of the request for tracking purposes\n \"\"\"\n origin: String\n ): ProductSuggestions\n @cacheControl(scope: SEGMENT, maxAge: MEDIUM)\n @withSegment\n\n \"\"\"\n Get search urls access stats count\n \"\"\"\n searchURLsCount(\n \"\"\"\n Number of items that is returned\n \"\"\"\n limit: Int = 100\n\n \"\"\"\n Sorting strategy, asc: ascending, desc: descending\n \"\"\"\n sort: SORT\n ): [SearchURLStats] @cacheControl(scope: PUBLIC, maxAge: SHORT)\n}\n\nenum SimulationBehavior {\n \"\"\"\n Does simulation on catalog as usual\n \"\"\"\n default\n \"\"\"\n Does simulation on catalog only for seller 1P\n \"\"\"\n only1P\n \"\"\"\n Calls catalog passing a parameter to not simulate each SKU and get its most up to date price.\n \"\"\"\n skip\n \"\"\"\n Does the simulation on the client side\n \"\"\"\n async\n \"\"\"\n Only first party sellers will include the regionId\n \"\"\"\n regionalize1p\n}\n\nenum CrossSelingGroupByEnum {\n \"\"\"\n It's the default behavior, it will group SKUs from the same product and bring only products. Limited by 12 products.\n \"\"\"\n PRODUCT\n \"\"\"\n Return all skus registered in the catalog for the recommendation.\n \"\"\"\n NONE\n}\n\nenum CategoryTreeBehavior {\n \"\"\"\n Uses the default value set by the search provider\n \"\"\"\n default\n \"\"\"\n Show the category tree when it is possible\n \"\"\"\n show\n \"\"\"\n Hide the category tree in any situation\n \"\"\"\n hide\n}\n\ninput AdvertisementOptions {\n \"\"\"\n Whether or not to fetch sponsored products in this request.\n \"\"\"\n showSponsored: Boolean\n \"\"\"\n How many sponsored products should be fetched.\n \"\"\"\n sponsoredCount: Int\n \"\"\"\n If true, the search will return the same product twice - once as a regular product and once as a sponsored product.\n \"\"\"\n repeatSponsoredProducts: Boolean\n \"\"\"\n Where the sponsored product is being shown. Used for analytics purposes.\n \"\"\"\n advertisementPlacement: String\n}\n\n```" } ]
code_search-graphql_a576da21
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/directives.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ndirective @withSegment on FIELD_DEFINITION\n\ndirective @toVtexAssets on FIELD_DEFINITION\n\n```" } ]
code_search-graphql_f35f9326
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/node/package.json from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"search-graphql\",\n \"description\": \"Don't delete this file, it's necessary to generate the TypeScript types of the GraphQL\"\n}\n\n```" } ]
code_search-graphql_21810ce1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/types/ProductSearch.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype ProductSearch {\n \"\"\"\n List of products.\n \"\"\"\n products: [Product]\n \"\"\"\n Total number of products.\n \"\"\"\n recordsFiltered: Int\n \"\"\"\n Title used in the title's tag.\n \"\"\"\n titleTag: String\n \"\"\"\n String to be used in the `<meta name=\"description\"...` tag.\n \"\"\"\n metaTagDescription: String\n breadcrumb: [SearchBreadcrumb]\n @deprecated(reason: \"Use the `breadcrumb` from the `facets` query instead.\")\n canonical: String\n suggestion: SearchSuggestions\n @deprecated(reason: \"Use the `suggestion` query instead.\")\n \"\"\"\n Object that indicates if the term was misspelled and suggests a possible correction.\n \"\"\"\n correction: SearchCorrection\n \"\"\"\n Indicates how the search-engine dealt with the fullText when there is more than one word.\\n * `and` - It means that the products contains all the words in the query.\\n * `or` - It means that the results will contain at least one word from the original search query. If `and` was not possible, `or` will be the fallback.\n \"\"\"\n operator: Operator\n \"\"\"\n Indicates how the search engine corrected the misspelled word by using fuzzy logic. It can be a number representing the max number of misspelled letters, or the string `auto` suggesting that the search-engine should set this value by itself.\n \"\"\"\n fuzzy: String\n \"\"\"\n As fuzzy and operator, it controls the search state, but it is for general purposes. This field allows the search engines to apply features that are not handled by the other fields.\n The possible values in this field are defined by each search engine.\n \"\"\"\n searchState: String\n banners: [SearchBanner]\n @deprecated(reason: \"Use the `banners` query instead.\")\n \"\"\"\n Returns the redirect URL set for the given query.\n \"\"\"\n redirect: String\n \"\"\"\n Options to ProductSearch.\n \"\"\"\n options: ProductSearchOptions\n \"\"\"\n ID used to identify a search query.\n \"\"\"\n searchId: String\n \"\"\"\n Origin of the request for tracking purposes\n \"\"\"\n origin: String\n}\n\ntype ProductSearchOptions {\n \"\"\"\n Indicates if delivery promises is enabled.\n \"\"\"\n deliveryPromisesEnabled: Boolean\n}\n\nenum Operator {\n and\n or\n}\n\ntype SearchBreadcrumb {\n \"\"\"\n Human-readable format of the facet key.\n \"\"\"\n name: String @translatableV2\n \"\"\"\n Query link.\n \"\"\"\n href: String\n}\n\ntype SearchMetadata {\n titleTag: String\n metaTagDescription: String @translatableV2\n}\n\ninput SelectedFacetInput {\n \"\"\"\n Facet key.\n \"\"\"\n key: String\n \"\"\"\n Facet value.\n \"\"\"\n value: String\n}\n\ntype SelectedFacet {\n key: String\n value: String\n}\n\ninput Options {\n \"\"\"\n If the search has a redirect enabled, this allows (`true`) or not (`false`) the redirect to be used.\n \"\"\"\n allowRedirect: Boolean\n}\n\n```" } ]
code_search-graphql_466213e5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/types/PageType.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype PageType {\n id: String\n type: PageEntityIdentifier\n}\n\nenum PageEntityIdentifier {\n brand\n department\n category\n subcategory\n search\n}\n\n```" } ]
code_search-graphql_60e05842
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/types/SearchSuggestions.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype SearchSuggestions {\n \"\"\"\n A list of search suggestions.\n \"\"\"\n searches: [SearchSuggestion]\n}\n\ntype SearchSuggestion {\n \"\"\"\n Search term.\n \"\"\"\n term: String!\n \"\"\"\n Number of times the term was searched.\n \"\"\"\n count: Int!\n \"\"\"\n List of facets in which the term can be searched.\n \"\"\"\n attributes: [SearchSuggestionAttribute]\n}\n\ntype SearchSuggestionAttribute {\n \"\"\"\n Facet key.\n \"\"\"\n key: String!\n \"\"\"\n Facet value.\n \"\"\"\n value: String!\n \"\"\"\n Human-readable format of the facet key.\n \"\"\"\n labelValue: String!\n}\n\n```" } ]
code_search-graphql_56c43fda
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/types/SearchURLStats.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype SearchURLStats {\n path: String!\n count: Int!\n}\n```" } ]
code_search-graphql_47421443
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/types/Brand.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype Brand {\n \"\"\"\n slug is used as cacheId\n \"\"\"\n cacheId: ID\n \"\"\"\n Brand id\n \"\"\"\n id: Int\n \"\"\"\n Brand logo\n \"\"\"\n imageUrl: String @toVtexAssets\n \"\"\"\n Text link\n \"\"\"\n slug: String\n \"\"\"\n Name of brand\n \"\"\"\n name: String @translatableV2(behavior: \"USER_ONLY\")\n \"\"\"\n Title used by html tag\n \"\"\"\n titleTag: String @translatableV2(behavior: \"USER_ONLY\")\n \"\"\"\n Description used by html tag\n \"\"\"\n metaTagDescription: String @translatableV2\n \"\"\"\n Brand is active\n \"\"\"\n active: Boolean\n}\n\n```" } ]
code_search-graphql_1846fece
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/types/Facets.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype QueryArgs {\n map: String\n query: String\n selectedFacets: [SelectedFacet]\n}\n\ntype Range {\n from: Float\n to: Float\n}\n\ntype FacetValue {\n id: ID\n quantity: Int!\n name: String @translatableV2\n key: String\n value: String\n selected: Boolean\n children: [FacetValue]\n range: Range\n link: String\n linkEncoded: String\n href: String\n}\n\nenum FilterType {\n TEXT\n NUMBER\n CATEGORYTREE\n BRAND\n PRICERANGE\n DELIVERY\n}\n\ntype Facet {\n name: String @translatableV2\n values(from: Int, to: Int): [FacetValue]\n type: FilterType\n hidden: Boolean\n quantity: Int\n}\n\ntype Facets {\n departments: [DepartmentFacet]\n @deprecated(reason: \"Use the `facets` instead.\")\n brands: [BrandFacet] @deprecated(reason: \"Use the `facets` instead.\")\n specificationFilters: [FilterFacets]\n categoriesTrees: [CategoriesTreeFacet] @deprecated(reason: \"Use the `facets` instead.\")\n \"\"\"\n Price range for the given query.\n \"\"\"\n priceRanges: [PriceRangesFacet]\n recordsFiltered: Int @deprecated(reason: \"Use the recordsFiltered from the `productSearch` instead.\")\n \"\"\"\n Info about the searched query.\n \"\"\"\n queryArgs: QueryArgs\n \"\"\"\n List of facets.\n \"\"\"\n facets: [Facet]\n \"\"\"\n Indicates whether there was sampling in the aggregation of facets or not. In search results that have many products, only the first 30000 will be aggregated to avoid performance issues.\n \"\"\"\n sampling: Boolean\n \"\"\"\n Generated breadcrumb for the given query.\n \"\"\"\n breadcrumb: [SearchBreadcrumb]\n}\n\ntype DepartmentFacet {\n id: ID!\n quantity: Int!\n name: String @translatableV2\n link: String!\n linkEncoded: String!\n map: String\n value: String!\n selected: Boolean!\n}\n\ntype BrandFacet {\n id: ID!\n quantity: Int!\n name: String! @translatableV2(behavior: \"USER_ONLY\")\n link: String!\n linkEncoded: String!\n map: String\n value: String!\n selected: Boolean!\n}\n\ntype PriceRangesFacet {\n quantity: Int!\n name: String @translatableV2\n link: String!\n linkEncoded: String!\n map: String\n value: String!\n selected: Boolean!\n slug: String\n}\n\ntype CategoriesTreeFacet {\n id: ID!\n quantity: Int!\n name: String @translatableV2\n link: String!\n linkEncoded: String!\n \"\"\"\n Contains slugified links according to the store structure. /:department/d, /:category/:subcategory, etc\n \"\"\"\n href: String!\n map: String\n value: String!\n children: [CategoriesTreeFacet]\n selected: Boolean!\n}\n\ntype FilterFacet {\n quantity: Int!\n name: String @translatableV2\n link: String!\n linkEncoded: String!\n map: String\n value: String!\n selected: Boolean!\n}\n\ntype FilterFacets {\n name: String\n facets: [FilterFacet]\n}\n\n```" } ]
code_search-graphql_0cd1a062
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/types/Advertisement.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype Advertisement {\n \"\"\"\n ID of the ad item associated with the sponsored product.\n \"\"\"\n adId: ID\n \"\"\"\n ID of the campaign owner of the ad item.\n \"\"\"\n campaignId: ID\n \"\"\"\n Cost of the goal action. E.g: CPC, cost per click.\n \"\"\"\n actionCost: Float\n \"\"\"\n Ad Request ID.\n \"\"\"\n adRequestId: ID\n \"\"\"\n Ad Response ID.\n \"\"\"\n adResponseId: ID\n}\n\n```" } ]
code_search-graphql_5e977d08
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/types/Benefits.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\n\"\"\" Benefit of a Product \"\"\"\ntype Benefit {\n \"\"\" Flag which indicates if the benefit is featured or not \"\"\"\n featured: Boolean\n \"\"\" Id of the product which the benefit is associated \"\"\"\n id: String\n \"\"\" Name of the benefit \"\"\"\n name: String\n \"\"\" Items of the benefit \"\"\"\n items: [BenefitItem]\n \"\"\" Type of benefit \"\"\"\n teaserType: String\n}\n\ntype BenefitItem {\n \"\"\" Product itself \"\"\"\n benefitProduct: Product\n \"\"\" IDs of the SKU Items that are taking part in the benefit \"\"\"\n benefitSKUIds: [String]\n \"\"\" Discount applied to the benefit product \"\"\"\n discount: Float\n \"\"\" Minimum quantity of the benefit product that is required to validate the benefit \"\"\"\n minQuantity: Int\n}\n```" } ]
code_search-graphql_943e815c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/types/Autocomplete.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype ProductSuggestions {\n \"\"\"\n Number of suggested products\n \"\"\"\n count: Int!\n \"\"\"\n Suggested products\n \"\"\"\n products: [Product]!\n \"\"\"\n If the term is misspelled or not\n \"\"\"\n misspelled: Boolean\n \"\"\"\n Indicates how the search-engine will deal with the fullText if there is more than one word. Set `and` if the returned products must have all the words in its metadata or `or` otherwise.\n \"\"\"\n operator: Operator\n \"\"\"\n ID used to identify a search query.\n \"\"\"\n searchId: String\n \"\"\"\n Origin of the request for tracking purposes\n \"\"\"\n origin: String\n}\n\n```" } ]
code_search-graphql_04788adf
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/types/ItemMetadata.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype ItemMetadata {\n items: [ItemMetadataUnit]\n priceTable: [ItemPriceTable]\n}\n\ntype ItemPriceTable {\n type: String\n values: [PriceTableItem]\n}\n\ntype PriceTableItem {\n id: String\n assemblyId: String\n price: Int\n}\n\ntype ItemMetadataUnit {\n id: ID\n name: String\n skuName: String\n productId: String\n refId: String\n ean: String\n imageUrl: String @toVtexAssets\n detailUrl: String\n seller: String\n assemblyOptions: [AssemblyOption]\n}\n\ntype AssemblyOption {\n id: ID\n name: String\n required: Boolean\n composition: CompositionType\n inputValues: [InputValue]\n}\n\nscalar StringOrBoolean\n\ntype InputValue {\n label: String\n maxLength: Int\n type: InputValueType\n defaultValue: StringOrBoolean\n domain: [String]\n}\n\nenum InputValueType {\n TEXT\n BOOLEAN\n OPTIONS\n}\n\ntype CompositionType {\n minQuantity: Int\n maxQuantity: Int\n items: [CompositionItem]\n}\n\ntype CompositionItem {\n id: ID\n minQuantity: Int\n maxQuantity: Int\n initialQuantity: Int\n priceTable: String\n seller: String\n}\n\ninput AssemblyOptionInput {\n id: ID!\n quantity: Int!\n assemblyId: String!\n seller: String!\n options: [AssemblyOptionInput!]\n}\n\n```" } ]
code_search-graphql_0f270d1e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/types/Suggestions.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype Suggestions {\n \"\"\" searchTerm from Query autocomplete is used as cacheId \"\"\"\n cacheId: ID\n itemsReturned: [Items]\n}\n\ntype Items {\n thumb: String\n name: String @translatableV2\n href: String\n criteria: String\n slug: String\n productId: String\n}\n\n```" } ]
code_search-graphql_8aa93595
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/types/Category.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype Category {\n \"\"\" id is used as cacheId \"\"\"\n cacheId: ID\n \"\"\" URI of category \"\"\"\n href: String\n \"\"\" Category text link \"\"\"\n slug: String\n \"\"\" Category ID \"\"\"\n id: Int\n \"\"\" Category name \"\"\"\n name: String @translatableV2\n \"\"\" Title used by html tag\"\"\"\n titleTag: String @translatableV2\n \"\"\" Description used by html tag\"\"\"\n hasChildren: Boolean\n \"\"\" Has children categories \"\"\"\n metaTagDescription: String @translatableV2\n \"\"\" Categories children \"\"\"\n children: [Category]\n}\n\n```" } ]
code_search-graphql_95d4b698
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/types/Product.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype Product {\n \"\"\"\n Brand of the product\n \"\"\"\n brand: String @translatableV2(behavior: \"USER_ONLY\")\n \"\"\"\n Id of the brand of the product\n \"\"\"\n brandId: Int\n \"\"\"\n linkText is used as cacheId\n \"\"\"\n cacheId: ID\n categoryId: ID\n \"\"\"\n Categories of the product\n \"\"\"\n categories: [String]\n @deprecated(\n reason: \"Use 'categoryTree' field for internationalization support\"\n )\n \"\"\"\n Product's categories\n \"\"\"\n categoryTree: [Category]\n \"\"\"\n List of related products\n \"\"\"\n clusterHighlights: [ClusterHighlight]\n productClusters: [ProductClusters]\n \"\"\"\n Product description\n \"\"\"\n description: String @translatableV2\n \"\"\"\n SKU objects of the product\n \"\"\"\n items(filter: ItemsFilter): [SKU]\n \"\"\"\n List of SKU Specifications\n \"\"\"\n skuSpecifications: [SkuSpecification]\n \"\"\"\n Product URL\n \"\"\"\n link: String\n \"\"\"\n Product slug\n \"\"\"\n linkText: String\n \"\"\"\n Product ID\n \"\"\"\n productId: ID\n \"\"\"\n Product name\n \"\"\"\n productName: String @translatableV2\n \"\"\"\n Array of product properties\n \"\"\"\n properties: [Property]\n \"\"\"\n Array of product properties\n \"\"\"\n propertyGroups: [PropertyGroup]\n \"\"\"\n Product reference\n \"\"\"\n productReference: String\n \"\"\"\n Title used by html tag\n \"\"\"\n titleTag: String @translatableV2\n \"\"\"\n Description used by html tag\n \"\"\"\n metaTagDescription: String @translatableV2\n \"\"\"\n Related Products\n \"\"\"\n recommendations(groupBy: CrossSelingGroupByEnum): Recommendation\n \"\"\"\n JSON specification of the product\n \"\"\"\n jsonSpecifications: String\n \"\"\"\n List of benefits associated with this product\n \"\"\"\n benefits: [Benefit]\n itemMetadata: ItemMetadata\n \"\"\"\n Array of product SpecificationGroup\n \"\"\"\n specificationGroups: [SpecificationGroup]\n\n \"\"\"\n Returns highest and lowest prices for available SKUs in product.\n \"\"\"\n priceRange: ProductPriceRange\n\n \"\"\"\n Product Release Date, for list ordering and product cluster highlight\n \"\"\"\n releaseDate: String\n\n \"\"\"\n Product properties that will be selected by default. e.g: {key: \"Color\", value: \"Blue\"}\n \"\"\"\n selectedProperties: [SelectedProperty]\n \"\"\"\n Merchandising rule applied to the product\n \"\"\"\n rule: Rule\n \"\"\"\n If this product is sponsored, ad information will be added here.\n \"\"\"\n advertisement: Advertisement\n deliveryPromisesBadges: [BadgeItem]\n specification: String\n}\n\ntype BadgeItem {\n typeName: String\n pickupId: String\n pickupName: String\n}\n\ntype SelectedProperty {\n key: String\n value: String\n}\n\nenum ItemsFilter {\n \"\"\"\n Returns all items, same as no filter.\n \"\"\"\n ALL\n \"\"\"\n Returns only the first available item. Returns first if no item is available.\n \"\"\"\n FIRST_AVAILABLE\n \"\"\"\n Returns all available items. Returns first if no item is available.\n \"\"\"\n ALL_AVAILABLE\n}\n\ntype ProductPriceRange {\n sellingPrice: PriceRange\n listPrice: PriceRange\n}\n\ntype PriceRange {\n highPrice: Float\n lowPrice: Float\n}\n\ntype OnlyProduct {\n brand: String\n categoryId: ID\n categoryTree: [Category]\n clusterHighlights: [ClusterHighlight]\n productClusters: [ProductClusters]\n description: String\n link: String\n linkText: String\n productId: ID\n productName: String\n properties: [Property]\n propertyGroups: [PropertyGroup]\n productReference: String\n recommendations: Recommendation\n jsonSpecifications: String\n}\n\ntype ProductClusters {\n id: ID\n name: String\n}\n\ntype ClusterHighlight {\n id: ID\n name: String\n}\n\ntype Seller {\n sellerId: ID\n sellerName: String\n addToCartLink: String\n sellerDefault: Boolean\n commertialOffer: Offer\n}\n\ntype Recommendation {\n buy: [Product]\n view: [Product]\n similars: [Product]\n}\n\ntype SKU {\n itemId: ID\n name: String @translatableV2\n nameComplete: String @translatableV2\n complementName: String\n ean: String\n referenceId: [Reference]\n measurementUnit: String\n unitMultiplier: Float\n kitItems: [KitItem]\n images(quantity: Int): [Image]\n videos: [Video]\n sellers: [Seller]\n variations: [Property]\n attachments: [Attachment] @deprecated(reason: \"Use itemMetaData instead\")\n estimatedDateArrival: String\n}\n\ntype SkuSpecification {\n field: SKUSpecificationField\n values: [SKUSpecificationValue]\n}\n\ntype SKUSpecificationField {\n originalName: String\n name: String @translatableV2\n}\n\ntype SKUSpecificationValue {\n originalName: String\n name: String @translatableV2\n}\n\ntype productSpecification {\n fieldName: String @translatableV2\n fieldValues: [String] @translatableV2\n}\n\ninput ProductUniqueIdentifier {\n field: ProductUniqueIdentifierField!\n value: ID!\n}\n\nenum ProductUniqueIdentifierField {\n id\n slug\n ean\n reference\n sku\n}\n\ntype KitItem {\n itemId: ID\n amount: Int\n product: OnlyProduct\n sku: SKU\n}\n\ntype Attachment {\n id: ID\n name: String\n required: Boolean\n domainValues: [DomainValues]\n}\n\ntype DomainValues {\n FieldName: String\n MaxCaracters: String\n DomainValues: String\n}\n\nenum InstallmentsCriteria {\n MAX_WITHOUT_INTEREST\n MAX_WITH_INTEREST\n MAX # Equivalent to MAX_WITHOUT_INTEREST. Kept for backwards-compatibility\n MIN\n ALL\n}\n\ntype Offer {\n Installments(\n criteria: InstallmentsCriteria = ALL\n rates: Boolean = true\n excludedPaymentSystems: [String]\n includedPaymentSystems: [String]\n ): [Installment]\n Price: Float\n ListPrice: Float\n spotPrice: Float\n PriceWithoutDiscount: Float\n RewardValue: Float\n PriceValidUntil: String\n AvailableQuantity: Float\n Tax: Float\n taxPercentage: Float\n CacheVersionUsedToCallCheckout: String\n DeliverySlaSamples: [DeliverySlaSamples]\n \"\"\"\n List of discount highlights\n \"\"\"\n discountHighlights: [Discount!]\n teasers: [Teaser!]\n \"\"\"\n List of SKUs for gifts associated with the product\n \"\"\"\n giftSkuIds: [String]\n \"\"\"\n List of gifts associated with the product\n \"\"\"\n gifts: [Gift]\n}\n\ntype Gift {\n productName: String\n skuName: String\n brand: String\n linkText: String\n description: String\n images: [GiftImage]\n}\n\ntype GiftImage {\n imageUrl: String\n imageLabel: String\n imageText: String\n}\n\ntype Teaser {\n name: String\n conditions: TeaserCondition\n effects: TeaserEffects\n generalValues: [GeneralValueTeaser]\n}\n\ntype GeneralValueTeaser {\n key: String\n value: String\n}\n\ntype AdditionalInfo {\n key: String\n value: String\n}\n\ntype TeaserCondition {\n minimumQuantity: Int\n parameters: [TeaserValue]\n}\n\ntype TeaserEffects {\n parameters: [TeaserValue]\n}\n\ntype TeaserValue {\n name: String\n value: String\n}\n\n\"\"\"\nDiscount object\n\"\"\"\ntype Discount {\n \"\"\"\n Discount name\n \"\"\"\n name: String\n \"\"\"\n Additional Info\n \"\"\"\n additionalInfo: [AdditionalInfo]\n}\n\ntype DeliverySlaSamples {\n DeliverySlaPerTypes: [DeliverySlaPerTypes]\n Region: Region\n}\n\ntype DeliverySlaPerTypes {\n TypeName: String\n Price: Float\n EstimatedTimeSpanToDelivery: String\n}\n\ntype Region {\n IsPersisted: Boolean\n IsRemoved: Boolean\n Id: ID\n Name: String\n CountryCode: String\n ZipCode: String\n CultureInfoName: String\n}\n\ntype Image {\n cacheId: ID\n imageId: ID\n imageLabel: String\n imageTag: String\n imageUrl: String @toVtexAssets\n imageText: String\n}\n\ntype Video {\n videoUrl: String\n}\n\ntype SpecificationGroup {\n originalName: String\n name: String @translatableV2\n specifications: [SpecificationGroupProperty]\n}\n\ntype SpecificationGroupProperty {\n originalName: String\n name: String @translatableV2\n values: [String] @translatableV2\n}\n\ntype Property {\n originalName: String\n name: String @translatableV2\n values: [String] @translatableV2\n}\n\ntype PropertyGroup {\n name: String\n properties: [String]\n}\n\ntype Installment {\n Value: Float\n InterestRate: Float\n TotalValuePlusInterestRate: Float\n NumberOfInstallments: Int\n PaymentSystemName: String\n PaymentSystemGroupName: String\n Name: String\n}\n\ntype Reference {\n Key: String\n Value: String\n}\n\nenum CrossSelingInputEnum {\n buy\n similars\n view\n viewAndBought\n accessories\n suggestions\n}\n\ntype Rule {\n id: String\n}\n\n```" } ]
code_search-graphql_0ab5e908
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/types/Correction.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype Correction {\n correction: SearchCorrection\n}\n\n\"\"\"\nObject that indicates if the term was misspelled and suggests a possible correction.\n\"\"\"\ntype SearchCorrection {\n \"\"\"\n The corrected term. If the API was not able to correct the term, it will show the original search term.\n \"\"\"\n text: String\n \"\"\"\n The same as `text`, but it highlights the corrected word. Useful when there is more than one word.\n \"\"\"\n highlighted: String\n \"\"\"\n Whether the term was misspelled (`true`) or not (`false`).\n \"\"\"\n misspelled: Boolean\n \"\"\"\n Whether the API was able to suggest a correction (`true`) or not (`false`).\n \"\"\"\n correction: Boolean\n}\n\n```" } ]
code_search-graphql_2ce131d2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of search-graphql/graphql/types/Banners.graphql from the search-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype Banners {\n \"\"\"\n List of banners.\n \"\"\"\n banners: [SearchBanner]\n}\n\ntype SearchBanner {\n \"\"\"\n Banner ID.\n \"\"\"\n id: String\n \"\"\"\n Banner name.\n \"\"\"\n name: String\n \"\"\"\n Banner area.\n \"\"\"\n area: String\n \"\"\"\n Banner HTML.\n \"\"\"\n html: String\n}\n\n```" } ]
code_salesforce-chat_59363f61
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of salesforce-chat/docs/README.md from the salesforce-chat VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Salesforce chat\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\nVTEX Salesforce chat first-party app\n\n## How to install\n\nOpen the VTEX App Store and install this app on your store.\n\nNow, open the app settings on your admin and fill in your Salesforce chat's Content.\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n <tr>\n <td align=\"center\"><a href=\"https://github.com/blaurenzano\"><img src=\"https://avatars3.githubusercontent.com/u/49657838?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>blaurenzano</b></sub></a><br /><a href=\"https://github.com/vtex-apps/salesforce-chat/commits?author=blaurenzano\" title=\"Code\">💻</a></td>\n </tr>\n</table>\n\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n```" } ]
code_graphql-gateway_0bfd4ef5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of graphql-gateway/node/service.json from the graphql-gateway VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"stack\": \"nodejs\",\n \"memory\": 258,\n \"ttl\": 43200,\n \"timeout\": 30,\n \"minReplicas\": 2,\n \"maxReplicas\": 30,\n \"workers\": 4,\n \"cpu\": 30,\n \"routes\": {\n \"graphql\": {\n \"public\": true,\n \"path\": \"/graphql\"\n }\n }\n}\n\n```" } ]
code_graphql-gateway_a6eee73d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of graphql-gateway/node/package.json from the graphql-gateway VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"version\": \"1.0.1\",\n \"dependencies\": {\n \"@apollo/federation\": \"^0.18.1\",\n \"@graphql-tools/delegate\": \"^6.0.15\",\n \"@graphql-tools/merge\": \"^6.0.15\",\n \"@graphql-tools/wrap\": \"^6.0.15\",\n \"@types/co-body\": \"^5.1.0\",\n \"apollo-server-core\": \"^2.16.1\",\n \"axios\": \"^0.21.0\",\n \"cache-control-parser\": \"^1.0.7\",\n \"co-body\": \"^6.0.0\",\n \"eslint-config-vtex\": \"^12.8.8\",\n \"graphql\": \"^15.3.0\",\n \"isomorphic-unfetch\": \"^3.1.0\"\n },\n \"devDependencies\": {\n \"@vtex/api\": \"6.45.4\",\n \"typescript\": \"3.9.7\",\n \"vtex.checkout-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.checkout-graphql@0.55.1/public/@types/vtex.checkout-graphql\",\n \"vtex.graphql-gateway\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.graphql-gateway@0.7.0/public/_types/react\",\n \"vtex.search-resolver\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.search-resolver@1.29.4/public/_types/react\"\n }\n}\n\n```" } ]
code_graphql-gateway_645361d1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of graphql-gateway/node/global.ts from the graphql-gateway VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { IOClients, RecorderState, ServiceContext } from '@vtex/api'\nimport { ApolloServerHttpResponse } from 'apollo-server-core/dist/runHttpQuery'\nimport { GraphQLSchema } from 'graphql'\n\ndeclare global {\n interface Query {\n operationName: string\n variables: Record<string, any> | string\n query: string\n }\n\n interface State extends RecorderState {\n query: Query\n schema: GraphQLSchema\n cacheControl: string[]\n responseInit: ApolloServerHttpResponse\n }\n\n type Context = ServiceContext<IOClients, State>\n}\n\n```" } ]
code_graphql-gateway_ade379ce
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of graphql-gateway/node/index.ts from the graphql-gateway VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport './global'\n\nimport { Cached, LRUCache, method, Service } from '@vtex/api'\n\nimport run from './middlewares/run'\nimport error from './middlewares/error'\nimport schema from './middlewares/schema'\nimport extract from './middlewares/extract'\nimport headers from './middlewares/headers'\n\nconst vbaseCacheStorage = new LRUCache<string, Cached>({\n max: 1e3,\n})\n\nmetrics.trackCache('vbase', vbaseCacheStorage)\n\nexport default new Service({\n clients: {\n options: {\n vbase: {\n concurrency: 3,\n memoryCache: vbaseCacheStorage,\n retries: 1,\n timeout: 1500,\n },\n },\n },\n routes: {\n graphql: method({\n GET: [error, headers, extract, schema, run],\n POST: [error, headers, extract, schema, run],\n }),\n },\n})\n\n```" } ]
code_graphql-gateway_a11e1920
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of graphql-gateway/node/middlewares/schema.ts from the graphql-gateway VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { mergeSchemas } from '@graphql-tools/merge'\nimport {\n introspectSchema,\n RenameTypes,\n wrapSchema,\n} from '@graphql-tools/wrap'\nimport { GraphQLSchema } from 'graphql'\n\nimport { NamespaceUnderFieldTransform } from '../transformers/namespaceUnderField'\nimport { executor as getExecutorForApp } from '../utils/executor'\n\nlet globalSchema: GraphQLSchema | null = null\n\nconst typeName = 'VTEX'\nconst fieldName = 'vtex'\n\nconst apps = [\n {\n app: 'vtex.search-resolver@1.x',\n executor: getExecutorForApp,\n transforms: [\n new RenameTypes(name => `${typeName}_${name}`),\n new NamespaceUnderFieldTransform(typeName, fieldName),\n ],\n },\n {\n app: 'vtex.checkout-graphql@0.x',\n executor: getExecutorForApp,\n transforms: [\n new RenameTypes(name => `${typeName}_${name}`),\n new NamespaceUnderFieldTransform(typeName, fieldName),\n ],\n }\n]\n\nexport default async function schema(ctx: Context, next: () => Promise<void>) {\n if (!globalSchema) {\n const schemas = await Promise.all(\n apps.map(async ({ app, executor, transforms }) => {\n const exe = executor(app)\n\n return wrapSchema(\n {\n schema: await introspectSchema(exe, ctx),\n executor: exe,\n },\n transforms\n )\n })\n )\n\n globalSchema = mergeSchemas({ schemas })\n }\n\n ctx.state.schema = globalSchema\n\n await next()\n}\n\n```" } ]
code_graphql-gateway_6127f74e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of graphql-gateway/node/middlewares/extract.ts from the graphql-gateway VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { VBase } from '@vtex/api'\nimport parse from 'co-body'\nimport fetch from 'isomorphic-unfetch'\n\ninterface PersistedQuery extends Query {\n extensions: {\n persistedQuery: {\n version: string\n sha256Hash: string\n storage: string\n }\n }\n}\n\nconst BUCKET = 'persistedQueries'\n\nconst saveAsync = async (persisted: Record<string, string>, vbase: VBase) => {\n for (const hash of Object.keys(persisted)) {\n // eslint-disable-next-line no-await-in-loop\n await vbase.saveJSON(BUCKET, hash, persisted[hash]).catch(console.error)\n }\n}\n\nconst isPersistedQuery = (query: any): query is PersistedQuery =>\n !!query.extensions\n\nconst parseString = (x: unknown) => {\n if (typeof x !== 'string') {\n return x\n }\n\n if (x === 'undefined') {\n return undefined\n }\n\n return JSON.parse(x)\n}\n\nexport default async function extract(ctx: Context, next: () => Promise<void>) {\n const {\n vtex: { authToken, logger },\n clients: { vbase },\n } = ctx\n\n const rawQuery =\n ctx.request.method === 'POST' ? await parse.json(ctx) : ctx.request.query\n\n const query = {\n query: rawQuery.query,\n operationName: rawQuery.operationName,\n variables: parseString(rawQuery.variables),\n extensions: parseString(rawQuery.extensions),\n }\n\n // We have a persisted query in here. We need to translate it to a query\n // so graphql can understand and run it\n if (isPersistedQuery(query)) {\n const {\n extensions: {\n persistedQuery: { sha256Hash },\n },\n } = query\n\n const maybeQuery = await vbase.getJSON<string>(BUCKET, sha256Hash, true)\n\n // Query is already in our local storage. Just translate i\n if (maybeQuery) {\n query.query = maybeQuery\n }\n // Query is somewhere else. We need to fetch it and than try to translate it\n else {\n const storageHost = ctx.get('x-vtex-graphql-referer')\n const url = `http://${storageHost}/page-data/_graphql/persisted.graphql.json`\n\n // fetch persisted.json from remote\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'x-vtex-proxy-to': `https://${storageHost}`,\n accept: 'application/json; charset=utf-8',\n 'Proxy-Authorization': authToken,\n 'accept-encoding': 'gzip',\n // Cookie used to AB-test FastStore stores\n cookie: 'VtexStoreVersion=v2;',\n },\n })\n\n const responseText = await response.text()\n\n try {\n const persisted = JSON.parse(responseText)\n\n if (!persisted?.[sha256Hash]) {\n throw new Error(`URL ${url} does not contains hash ${sha256Hash}`)\n }\n\n // update local storage\n saveAsync(persisted, vbase).catch(console.error)\n\n // set query and continue\n query.query = persisted[sha256Hash]\n } catch (err) {\n logger.error({\n url,\n response: responseText.slice(0, 300),\n headers: response.headers,\n })\n throw err\n }\n }\n\n // Delete extensions so apollo does not try to parse the persisted query again\n delete query.extensions\n }\n\n ctx.state.query = query\n\n await next()\n}\n\n```" } ]
code_graphql-gateway_8e2aa162
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of graphql-gateway/node/middlewares/headers.ts from the graphql-gateway VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport parse, { CacheControl } from 'cache-control-parser'\n\nconst ONE_WEEK_S = 3600 * 24 * 7\nconst BASE_CACHE_CONTROL = 'private, max-age=0, must-revalidate'\n\nconst format = (cacheControl: CacheControl) =>\n [\n cacheControl.isPrivate && 'private',\n cacheControl.isPublic && 'public',\n cacheControl.immutable && 'immutable',\n cacheControl.noCache && 'no-cache',\n cacheControl.noStore && 'no-store',\n cacheControl.mustRevalidate && 'must-revalidate',\n cacheControl.noTransform && 'no-transform',\n cacheControl.proxyRevalidate && 'proxy-revalidate',\n typeof cacheControl.staleIfError === 'number' &&\n `stale-if-error=${cacheControl.staleIfError}`,\n typeof cacheControl.staleWhileRevalidate === 'number' &&\n `stale-while-revalidate=${cacheControl.staleWhileRevalidate}`,\n typeof cacheControl.sharedMaxAge === 'number' &&\n `s-maxage=${cacheControl.sharedMaxAge}`,\n typeof cacheControl.maxAge === 'number' && `max-age=${cacheControl.maxAge}`,\n ]\n .filter(x => !!x)\n .join(', ')\n\nexport default async function headers(ctx: Context, next: () => Promise<void>) {\n ctx.state.cacheControl = []\n\n await next()\n\n const { headers: responseHeaders } = ctx.state.responseInit\n\n // Set Apollo computed Headers\n for (const [key, value] of Object.entries(responseHeaders ?? {})) {\n ctx.set(key, value)\n }\n\n // Set cache control.\n // Apollo cannot compute cache headers correctly, so we use the\n // returned headers from each stitched call to compute an aggregated\n // cache control header\n if (ctx.state.cacheControl.length === 0) {\n ctx.state.cacheControl.push(BASE_CACHE_CONTROL)\n }\n\n const cacheControl = ctx.state.cacheControl\n .map(parse)\n .reduce((previous, current) => {\n if (previous.noCache || previous.noStore || previous.isPrivate) {\n return previous\n }\n\n if (\n typeof current.maxAge === 'number' &&\n typeof previous.maxAge === 'number' &&\n current.maxAge > previous.maxAge\n ) {\n return previous\n }\n\n return current\n })\n\n if (cacheControl.isPublic && cacheControl.maxAge && cacheControl.maxAge > 0) {\n if (!cacheControl.staleWhileRevalidate) {\n cacheControl.staleWhileRevalidate = ONE_WEEK_S\n }\n\n if (!cacheControl.staleIfError) {\n cacheControl.staleIfError = ONE_WEEK_S\n }\n }\n\n ctx.set('cache-control', format(cacheControl))\n}\n\n```" } ]
code_graphql-gateway_2fb925b6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of graphql-gateway/node/middlewares/error.ts from the graphql-gateway VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport default async function extract(ctx: Context, next: () => Promise<void>) {\n try {\n await next()\n } catch (err) {\n if (err.isGraphQLError) {\n ctx.body = err.message\n ctx.status = err.statusCode\n\n Object.entries(err.headers).forEach(([key, value]) => {\n ctx.set(key, value as any)\n })\n\n return\n }\n\n throw err\n }\n}\n\n```" } ]
code_graphql-gateway_d7012aff
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of graphql-gateway/node/middlewares/run.ts from the graphql-gateway VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { LINKED, MAX_AGE } from '@vtex/api'\nimport { runHttpQuery } from 'apollo-server-core'\n\nexport default async function run(ctx: Context, next: () => Promise<void>) {\n const {\n state: { query, schema },\n request: { method },\n request,\n } = ctx\n\n const { graphqlResponse, responseInit } = await runHttpQuery([], {\n method,\n options: {\n cacheControl: {\n calculateHttpHeaders: true,\n defaultMaxAge: MAX_AGE.LONG,\n },\n context: ctx,\n debug: LINKED,\n schema,\n schemaHash: '' as any,\n tracing: false,\n },\n query,\n request,\n })\n\n ctx.body = graphqlResponse\n ctx.state.responseInit = responseInit\n\n await next()\n}\n\n```" } ]
code_graphql-gateway_422e28d8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of graphql-gateway/node/utils/executor.ts from the graphql-gateway VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { AsyncExecutor } from '@graphql-tools/delegate'\nimport { parseAppId, versionToMajor } from '@vtex/api'\nimport http from 'axios'\nimport { print } from 'graphql'\n\nexport const executor = (\n app: string,\n axiosOptions?: (ctx: Context) => { headers: Record<string, string> }\n): AsyncExecutor => async ({ document, variables, context }) => {\n const ctx = (context as unknown) as Context\n const {\n vtex: { account, workspace, authToken },\n state,\n } = ctx\n\n const { name, version } = parseAppId(app)\n const major = versionToMajor(version)\n const query = print(document)\n const data = JSON.stringify({ query, variables })\n\n const options = axiosOptions?.(ctx)\n\n const response = await http.request({\n method: 'POST',\n url: `http://app.io.vtex.com/${name}/v${major}/${account}/${workspace}/_v/graphql`,\n headers: {\n accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: authToken,\n 'x-forwarded-host': (context as any).get('x-vtex-graphql-referer'),\n 'x-vtex-locale': 'en-US',\n 'x-vtex-tenant': 'en-US',\n ...options?.headers,\n },\n data,\n })\n\n const cacheControl = response.headers['cache-control']\n const setCookie = response.headers['set-cookie']\n\n if (setCookie) {\n ctx.set('set-cookie', setCookie)\n }\n\n if (cacheControl) {\n state.cacheControl.push(cacheControl)\n }\n\n return response.data\n}\n\n```" } ]
code_graphql-gateway_42888dd3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of graphql-gateway/node/transformers/namespaceUnderField.ts from the graphql-gateway VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { GraphQLObjectType, GraphQLNonNull, GraphQLSchema } from 'graphql'\nimport { addTypes, modifyObjectFields } from '@graphql-tools/utils'\n\nconst EMTPY_OBJ = {}\nconst noop = () => EMTPY_OBJ\n\nexport class NamespaceUnderFieldTransform {\n constructor(protected typeName: string, protected fieldName: string) {}\n\n public transformSchema(schema: GraphQLSchema): GraphQLSchema {\n const queryType = schema.getQueryType()\n\n if (!queryType) {\n return schema\n }\n\n const queryConfig = queryType.toConfig()\n const nestedQuery = new GraphQLObjectType({\n ...queryConfig,\n name: this.typeName,\n })\n\n const newSchema = addTypes(schema, [nestedQuery])\n const newRootFieldConfigMap = {\n [this.fieldName]: {\n type: new GraphQLNonNull(nestedQuery),\n resolve: noop,\n },\n }\n\n const [transformedSchema] = modifyObjectFields(\n newSchema,\n queryConfig.name,\n () => true,\n newRootFieldConfigMap\n )\n\n return transformedSchema\n }\n}\n\n```" } ]
code_giftcard-ui_80538dd0
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/node/service.json from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"stack\": \"nodejs\",\n \"memory\": 128,\n \"routes\": {\n \"getgiftcards\": {\n \"path\": \"/_v/getgiftcards\",\n \"public\": true\n },\n \"postgiftcard\": {\n \"path\": \"/_v/postgiftcard\",\n \"public\": true\n }\n },\n \"events\": {\n \"onAppsLinked\": {\n \"sender\": \"apps\",\n \"keys\": [\"linked\"]\n }\n }\n}\n\n```" } ]
code_giftcard-ui_ecbc453b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/node/typings.d.ts from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'colossus' {\n import { Context as KoaContext } from 'koa'\n\n export interface IOContext {\n account: string\n workspace: string\n authToken: string\n params: {\n [param: string]: string\n }\n region: string\n route: string\n }\n\n export interface ColossusContext extends KoaContext {\n vtex: IOContext\n }\n}\n\n```" } ]
code_giftcard-ui_3a89a5be
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/node/package.json from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.node-getting-started\",\n \"version\": null,\n \"dependencies\": {\n \"@vtex/api\": \"^0.37.1\",\n \"axios\": \"^0.18.0\"\n },\n \"devDependencies\": {\n \"@types/axios\": \"^0.14.0\",\n \"@types/koa\": \"^2.0.39\",\n \"@types/node\": \"8.x\",\n \"tslint\": \"^5.8.0\",\n \"tslint-config-vtex\": \"^2.0.0\",\n \"typescript\": \"^2.4.2\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit && tslint -c tslint.json './**/*.ts'\"\n }\n}\n\n```" } ]
code_giftcard-ui_5aaf89bd
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/node/index.ts from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ColossusContext } from 'colossus'\nimport { json } from 'co-body'\nimport axios from 'axios'\n\nconst appName = 'vtex-giftcard-v2'\nconst vendor = process.env.VTEX_APP_VENDOR\nconst workspace = process.env.VTEX_WORKSPACE\nconst region = process.env.VTEX_REGION\n\nconst urlBase = `http://${appName}.${vendor}.${region}.vtex.io/gatewayio/${workspace}/giftcardv2/gatewayio/giftcards`\n\nfunction getCookieFrom(ctx) {\n const {\n request: {\n header: { cookie },\n },\n vtex: { authToken },\n } = ctx\n\n return {\n 'Proxy-Authorization': authToken,\n 'Content-Type': 'application/json',\n Cookie: cookie,\n }\n}\n\nexport default {\n events: {\n onAppsLinked: async ctx => {\n console.log(`onAppsLinked body: ${ctx.body}`)\n },\n },\n routes: {\n getgiftcards: async (ctx: ColossusContext) => {\n ctx.set('Cache-Control', 'no-cache')\n\n const response = await axios(urlBase, {\n headers: getCookieFrom(ctx),\n })\n\n ctx.response.status = response.status\n ctx.response.body = response.data\n },\n postgiftcard: async (ctx: ColossusContext) => {\n const method = ctx.request.method\n if (method !== 'POST') {\n ctx.response.status = 405\n ctx.response.body = {\n message: 'Method not allowed',\n }\n return\n }\n\n ctx.set('Cache-Control', 'no-cache')\n\n const data = await json(ctx.req)\n const response = await axios({\n method: 'post',\n url: urlBase,\n data,\n headers: getCookieFrom(ctx),\n })\n\n ctx.response.status = response.status\n ctx.response.body = response.data\n },\n getgiftcard: async (ctx: ColossusContext) => {\n ctx.set('Cache-Control', 'no-cache')\n\n const id = ctx.query.giftCardId\n\n const response = await axios(`${urlBase}/${id}`, {\n headers: getCookieFrom(ctx),\n })\n\n ctx.response.status = response.status\n ctx.response.body = response.data\n },\n },\n}\n\n```" } ]
code_giftcard-ui_e1ecf9e7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/pages/pages.json from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"pages\": {\n \"admin/giftcard\": {\n \"path\": \"/admin/giftcard\"\n }\n },\n \"extensions\": {\n \"admin/giftcard\": {\n \"component\": \"root\"\n }\n }\n}\n\n```" } ]
code_giftcard-ui_7be406ab
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/react/cards.js from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport { connect } from 'react-redux'\nimport PropTypes from 'prop-types'\nimport { intlShape, injectIntl } from 'react-intl'\nimport { withRuntimeContext } from 'render'\n\nimport { getCards, createCard } from './actions/cards'\n\nimport Card from './card'\nimport AdminLoading from './components/AdminLoading'\n\nimport { PageHeader, Table, Badge } from 'vtex.styleguide'\n\nclass Cards extends Component {\n static contextTypes = {\n culture: PropTypes.object,\n }\n\n constructor() {\n super()\n\n this.state = {\n cards: [],\n searchValue: '',\n showCardForm: false,\n isCardCreation: false,\n cardData: {},\n }\n }\n\n static contextTypes = {\n culture: PropTypes.object,\n }\n\n componentDidMount() {\n window.postMessage({ action: { type: 'STOP_LOADING' } }, '*')\n\n const data = {\n account: this.props.runtime.account,\n workspace: this.props.runtime.workspace,\n }\n this.props.getCards(data)\n }\n\n componentDidUpdate(prevProps) {\n if (this.props.cards !== prevProps.cards) {\n this.setState({ cards: this.props.cards })\n }\n }\n\n handleInputSearchChange = e => {\n this.setState({ searchValue: e.target.value })\n }\n\n handleInputSearchClear = () => {\n this.setState({ searchValue: '' })\n }\n\n handleInputSearchSubmit = e => {\n e.preventDefault()\n console.log('handleInputSearchSubmit')\n }\n\n handleNextClick = () => {}\n handlePrevClick = () => {}\n\n handleNewCard = () => {\n this.setState({ showCardForm: true, isCardCreation: true, cardData: {} })\n }\n\n handleCloseAddCard = () => {\n this.setState({ showCardForm: false })\n }\n\n handleRowClick = data => {\n this.setState({\n cardData: data.rowData,\n showCardForm: true,\n isCardCreation: false,\n })\n }\n\n handleCardCreation = data => {\n const d = {\n account: this.props.runtime.account,\n workspace: this.props.runtime.workspace,\n }\n this.props.createCard(d, data)\n this.handleCloseAddCard()\n }\n\n render() {\n const { culture } = this.context\n const { intl, isLoading } = this.props\n const { showCardForm } = this.state\n\n const schema = {\n properties: {\n id: {\n type: 'string',\n title: 'Id',\n width: 60,\n cellRenderer: ({ cellData }) => (\n <div className=\"ph4 pre truncate hidden\">{cellData}</div>\n ),\n },\n balance: {\n type: 'string',\n headerRenderer: () => (\n <div className=\"ph4 tr\">\n {intl.formatMessage({ id: 'cards.table.header.balance' })}\n </div>\n ),\n cellRenderer: ({ cellData }) => (\n <div className=\"ph4 tr\">\n {intl.formatNumber(cellData, {\n style: 'currency',\n currency: culture.currency,\n })}\n </div>\n ),\n },\n emissionDate: {\n type: 'date-time',\n title: intl.formatMessage({ id: 'cards.table.header.emissionDate' }),\n cellRenderer: ({ cellData }) => (\n <div className=\"ph4\">\n {intl.formatDate(cellData, {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n })}\n </div>\n ),\n },\n expiringDate: {\n type: 'date-time',\n title: intl.formatMessage({ id: 'cards.table.header.expiringDate' }),\n cellRenderer: ({ cellData }) => (\n <div className=\"ph4\">\n {intl.formatDate(cellData, {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n })}\n </div>\n ),\n },\n active: {\n type: 'string',\n title: intl.formatMessage({ id: 'cards.table.header.status' }),\n cellRenderer: ({ cellData }) => (\n <div className=\"ph4\">\n {cellData === 'true' ? (\n <Badge type=\"success\">\n {intl.formatMessage({ id: 'active' })}\n </Badge>\n ) : (\n <Badge>{intl.formatMessage({ id: 'inactive' })}</Badge>\n )}\n </div>\n ),\n },\n },\n }\n\n return (\n <div\n className={`bg-muted-5 h-100 relative ${\n showCardForm ? 'overflow-hidden' : ''\n }`}\n >\n {isLoading && <AdminLoading />}\n\n <PageHeader title={intl.formatMessage({ id: 'cards.title' })} />\n\n <div className=\"pa7\">\n <div className=\"bg-base pa7 br3\">\n <Table\n schema={schema}\n items={this.state.cards}\n onRowClick={this.handleRowClick}\n toolbar={{\n inputSearch: {\n value: this.state.searchValue,\n placeholder: intl.formatMessage({ id: 'search.by.id' }),\n onChange: this.handleInputSearchChange,\n onClear: this.handleInputSearchClear,\n onSubmit: this.handleInputSearchSubmit,\n },\n newLine: {\n label: intl.formatMessage({ id: 'new' }),\n handleCallback: this.handleNewCard,\n },\n }}\n pagination={{\n onNextClick: this.handleNextClick,\n onPrevClick: this.handlePrevClick,\n currentItemFrom: 1,\n currentItemTo: 10,\n textOf: intl.formatMessage({ id: 'textOf' }),\n textShowRows: intl.formatMessage({ id: 'textShowRows' }),\n totalItems: this.state.cards.length,\n rowsOptions: [5, 10, 15, 20],\n }}\n />\n </div>\n </div>\n\n {showCardForm && (\n <Card\n onOverlayClick={this.handleCloseAddCard}\n onCreateCardClick={this.handleCardCreation}\n cardData={this.state.cardData}\n isCardCreation={this.state.isCardCreation}\n />\n )}\n </div>\n )\n }\n}\n\nCards.defaultProps = {\n isLoading: true,\n cards: [],\n}\n\nCards.propTypes = {\n intl: intlShape.isRequired,\n getCards: PropTypes.func.isRequired,\n createCard: PropTypes.func.isRequired,\n isLoading: PropTypes.bool,\n cards: PropTypes.array,\n runtime: PropTypes.any,\n}\n\nconst mapStateToProps = state => ({\n isLoading: state.cardsReducer.isLoading,\n cards: state.cardsReducer.cards,\n})\n\nexport default injectIntl(\n connect(\n mapStateToProps,\n { getCards, createCard },\n )(withRuntimeContext(Cards)),\n)\n\n```" } ]
code_giftcard-ui_33671fbd
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/react/root.js from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { Provider } from 'react-redux'\nimport configureStore from './store/configureStore'\nimport Cards from './cards'\n\nconst store = configureStore()\n\nexport default class Root extends React.Component {\n render() {\n return (\n <Provider store={store}>\n <Cards />\n </Provider>\n )\n }\n}\n\nRoot.propTypes = {\n children: PropTypes.node,\n}\n\n```" } ]
code_giftcard-ui_c2680681
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/react/package.json from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.giftcard\",\n \"version\": null,\n \"scripts\": {},\n \"dependencies\": {\n \"axios\": \"^0.18.0\",\n \"react-redux\": \"^5.0.7\",\n \"react-router-dom\": \"^4.2.2\",\n \"redux\": \"^3.7.2\",\n \"redux-devtools-extension\": \"^2.13.2\",\n \"redux-logger\": \"^3.0.6\",\n \"redux-thunk\": \"^2.2.0\"\n },\n \"devDependencies\": {\n \"babel-core\": \"^6.26.0\",\n \"babel-eslint\": \"^8.2.2\",\n \"babel-preset-env\": \"^1.6.1\",\n \"babel-preset-react\": \"^6.24.1\",\n \"eslint\": \"^4.19.1\",\n \"eslint-config-vtex\": \"^8.0.0\",\n \"eslint-config-vtex-react\": \"^3.0.1\",\n \"eslint-plugin-import\": \"^2.10.0\",\n \"eslint-plugin-react\": \"^7.0.0\",\n \"prop-types\": \"^15.5.10\",\n \"react\": \"^16.2.0\",\n \"react-dom\": \"^16.2.0\",\n \"react-intl\": \"^2.4.0\",\n \"redux-mock-store\": \"^1.5.1\"\n }\n}\n\n```" } ]
code_giftcard-ui_f26f21d8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/react/card.js from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport { intlShape, injectIntl } from 'react-intl'\n\nimport { fields } from './constants'\nimport { Input, Button } from 'vtex.styleguide'\n\nclass Card extends Component {\n constructor(props) {\n super(props)\n\n const cardData = props.cardData\n\n this.state = {\n relationName: cardData.relationName || '',\n emissionDate: cardData.emissionDate || '',\n expiringDate: cardData.expiringDate || '',\n caption: cardData.caption || '',\n redemptionCode: cardData.redemptionCode || '',\n userdocument: cardData.userdocument || '',\n conditions: cardData.conditions || '',\n balance: cardData.balance || '',\n group: cardData.group || '',\n active: cardData.active || '',\n }\n }\n\n handleInputChange = e => {\n const name = `${e.target.name}`\n const value = e.target.value\n this.setState({ [name]: value })\n }\n\n handleCardCreation = () => {\n this.props.onCreateCardClick(this.state)\n }\n\n render() {\n const { intl, onOverlayClick, isCardCreation } = this.props\n\n return (\n <div className=\"absolute bottom-0 right-0 left-0 top-0 w-100 h-100 z-999\">\n <div\n style={{ zIndex: '1001', background: 'rgba(0, 0, 0, 0.75)' }}\n className=\"flex absolute items-stretch justify-end w-50 bottom-0 right-0 left-0 top-0\"\n onClick={onOverlayClick}\n />\n <div\n style={{\n zIndex: '1002',\n boxShadow: '0 12px 15px 0 rgba(0,0,0,0.25)',\n }}\n className=\"absolute w-50 pa6 bottom-0 right-0 top-0 overflow-x-auto bg-white\"\n >\n <h1>\n {intl.formatMessage({\n id: isCardCreation ? 'newCard.title' : 'cardDetails.title',\n })}\n </h1>\n\n {fields.map(field => (\n <div key={field} className=\"mb5\">\n {isCardCreation ? (\n <Input\n onChange={this.handleInputChange}\n value={this.state[field].toString()}\n name={field}\n label={intl.formatMessage({ id: `newCard.label.${field}` })}\n />\n ) : (\n <div>\n <label>\n {intl.formatMessage({ id: `newCard.label.${field}` })}\n </label>\n <div>{this.state[field]}</div>\n </div>\n )}\n </div>\n ))}\n\n {isCardCreation && (\n <div className=\"flex flex-row justify-end\">\n <div className=\"mr4\">\n <Button onClick={onOverlayClick} variation=\"tertiary\">\n {intl.formatMessage({ id: 'cancel' })}\n </Button>\n </div>\n <Button onClick={this.handleCardCreation}>\n {intl.formatMessage({ id: 'create' })}\n </Button>\n </div>\n )}\n </div>\n </div>\n )\n }\n}\n\nCard.defaultProps = {\n cardData: {},\n}\n\nCard.propTypes = {\n intl: intlShape,\n cardData: PropTypes.object,\n isCardCreation: PropTypes.bool,\n onOverlayClick: PropTypes.func.isRequired,\n onCreateCardClick: PropTypes.func.isRequired,\n}\n\nexport default injectIntl(Card)\n\n```" } ]
code_giftcard-ui_42e59a95
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/react/locales/pt.json from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"cancel\": \"cancelar\",\n \"create\": \"gerar\",\n \"new\": \"novo\",\n \"active\": \"Ativo\",\n \"inactive\": \"Inativo\",\n\n \"search.by.id\": \"Pesquisa por ID de cartão\",\n \"textOf\": \"de\",\n \"textShowRows\": \"mostrar linhas\",\n\n \"cards.title\": \"Gift Cards\",\n \"cards.table.header.balance\": \"Saldo\",\n \"cards.table.header.emissionDate\": \"Data de emissão\",\n \"cards.table.header.expiringDate\": \"Data de vencimento\",\n \"cards.table.header.status\": \"Estado\",\n\n \"newCard.title\": \"Novo Gift Card\",\n \"newCard.label.relationName\": \"Nome da relação\",\n \"newCard.label.emissionDate\": \"Data de emissão\",\n \"newCard.label.expiringDate\": \"Data de vencimento\",\n \"newCard.label.caption\": \"Caption\",\n \"newCard.label.redemptionCode\": \"Código de redenção\",\n \"newCard.label.userdocument\": \"Documento do usuário\",\n \"newCard.label.conditions\": \"Condições\",\n \"newCard.label.balance\": \"Saldo\",\n \"newCard.label.group\": \"Groupo\",\n \"newCard.label.active\": \"Ativo\",\n\n \"cardDetails.title\": \"Detalhes do Gift Card\"\n}\n\n```" } ]
code_giftcard-ui_7cd1e7e5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/react/locales/en.json from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"cancel\": \"cancel\",\n \"create\": \"create\",\n \"new\": \"new\",\n \"active\": \"Active\",\n \"inactive\": \"Inactive\",\n\n \"search.by.id\": \"Search by card id\",\n \"textOf\": \"de\",\n \"textShowRows\": \"show rows\",\n\n \"cards.title\": \"Gift Cards\",\n \"cards.table.header.balance\": \"Balance\",\n \"cards.table.header.emissionDate\": \"Emission date\",\n \"cards.table.header.expiringDate\": \"Expiring date\",\n \"cards.table.header.status\": \"Status\",\n\n \"newCard.title\": \"New Card\",\n \"newCard.label.relationName\": \"Relation name\",\n \"newCard.label.emissionDate\": \"Emission date\",\n \"newCard.label.expiringDate\": \"Expiring date\",\n \"newCard.label.caption\": \"Caption\",\n \"newCard.label.redemptionCode\": \"Redemption code\",\n \"newCard.label.userdocument\": \"User document\",\n \"newCard.label.conditions\": \"Conditions\",\n \"newCard.label.balance\": \"Balance\",\n \"newCard.label.group\": \"Group\",\n \"newCard.label.active\": \"Active\",\n\n \"cardDetails.title\": \"Gift Card Details\"\n}\n\n```" } ]
code_giftcard-ui_d162b11b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/react/locales/es.json from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"cancel\": \"cancelar\",\n \"create\": \"crear\",\n \"new\": \"nuevo\",\n \"active\": \"Activo\",\n \"inactive\": \"Inactivo\",\n\n \"search.by.id\": \"Búsqueda por identificación de tarjeta\",\n \"textOf\": \"de\",\n \"textShowRows\": \"mostrar filas\",\n\n \"cards.title\": \"Gift Cards\",\n \"cards.table.header.balance\": \"Saldo\",\n \"cards.table.header.emissionDate\": \"Fecha de emisión\",\n \"cards.table.header.expiringDate\": \"Fecha de vencimiento\",\n \"cards.table.header.status\": \"Estado\",\n\n \"newCard.title\": \"Nuevo Gift Card\",\n \"newCard.label.relationName\": \"Nombre de la relación\",\n \"newCard.label.emissionDate\": \"Fecha de emisión\",\n \"newCard.label.expiringDate\": \"Fecha de caducidad\",\n \"newCard.label.caption\": \"Caption\",\n \"newCard.label.redemptionCode\": \"Codigo de redención\",\n \"newCard.label.userdocument\": \"Documento de usuario\",\n \"newCard.label.conditions\": \"Condiciones\",\n \"newCard.label.balance\": \"Saldo\",\n \"newCard.label.group\": \"Groupo\",\n \"newCard.label.active\": \"Activo\",\n\n \"cardDetails.title\": \"Detalles de lo Gift Card\"\n}\n\n```" } ]
code_giftcard-ui_a9f6e17c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/react/constants/index.js from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nexport const fields = [\n 'relationName',\n 'emissionDate',\n 'expiringDate',\n 'caption',\n 'redemptionCode',\n 'userdocument',\n 'conditions',\n 'balance',\n 'group',\n 'active',\n]\n\n```" } ]
code_giftcard-ui_e3eb20d5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/react/components/AdminLoading.js from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\n\nclass AdminLoading extends React.Component {\n componentDidMount() {\n window.postMessage({ action: { type: 'START_LOADING' } }, '*')\n }\n\n componentWillUnmount() {\n window.postMessage({ action: { type: 'STOP_LOADING' } }, '*')\n }\n\n render() {\n return null\n }\n}\nexport default AdminLoading\n\n```" } ]
code_giftcard-ui_e7d9f7e4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/react/actions/types.js from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nexport const REQUEST_CARDS = 'REQUEST_CARDS'\nexport const RECEIVE_CARDS_SUCCESS = 'RECEIVE_CARDS_SUCCESS'\nexport const RECEIVE_CARDS_ERROR = 'RECEIVE_CARDS_ERROR'\n\nexport const REQUEST_CARD_CREATION = 'REQUEST_CARD_CREATION'\nexport const RECEIVE_CARD_CREATION_SUCCESS = 'RECEIVE_CARD_CREATION_SUCCESS'\nexport const RECEIVE_CARD_CREATION_ERROR = 'RECEIVE_CARD_CREATION_ERROR'\n\n```" } ]
code_giftcard-ui_f34f4266
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/react/reducers/index.js from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport { combineReducers } from 'redux'\n\nimport cardsReducer from './cards'\n\nconst rootReducer = combineReducers({\n cardsReducer,\n})\n\nexport default rootReducer\n\n```" } ]
code_giftcard-ui_f755171c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/react/store/configureStore.prod.js from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport { createStore, applyMiddleware, compose } from 'redux'\nimport thunk from 'redux-thunk'\nimport rootReducer from '../reducers'\n\nconst finalCreateStore = compose(applyMiddleware(thunk))(createStore)\n\nconst configureStore = initialState =>\n finalCreateStore(rootReducer, initialState)\n\nexport default configureStore\n\n```" } ]
code_giftcard-ui_e1fa5cba
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/react/store/configureStore.dev.js from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport { createStore, applyMiddleware } from 'redux'\nimport { composeWithDevTools } from 'redux-devtools-extension'\nimport thunk from 'redux-thunk'\nimport logger from 'redux-logger'\nimport rootReducer from '../reducers'\n\nconst finalCreateStore = composeWithDevTools(\n applyMiddleware(thunk),\n applyMiddleware(logger),\n)(createStore)\n\nconst configureStore = initialState =>\n finalCreateStore(rootReducer, initialState)\n\nexport default configureStore\n\n```" } ]
code_giftcard-ui_ceb9b35f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/react/store/configureStore.js from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./configureStore.prod')\n} else {\n module.exports = require('./configureStore.dev')\n}\n\n```" } ]
code_giftcard-ui_fb989e93
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/react/actions/cards/index.js from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport * as TYPES from '../types'\nimport axios from 'axios'\n\nconst localApiBase = ({ workspace, account }) =>\n `https://${workspace}--${account}.myvtex.com/_v`\n\n// #region getCards\nconst requestGetCards = () => ({\n type: TYPES.REQUEST_CARDS,\n})\n\nconst receiveGetCardsSuccess = cards => ({\n type: TYPES.RECEIVE_CARDS_SUCCESS,\n cards,\n})\n\nconst receiveGetCardsError = data => ({\n type: TYPES.RECEIVE_CARDS_ERROR,\n data,\n})\n\nexport const getCards = data => dispatch => {\n dispatch(requestGetCards(data))\n\n const { account, workspace } = data\n const url = `${localApiBase({ account, workspace })}/getgiftcards`\n\n return axios(url)\n .then(response => dispatch(receiveGetCardsSuccess(response.data)))\n .catch(error =>\n dispatch(\n receiveGetCardsError(\n (error && error.response && error.response.data) || null,\n ),\n ),\n )\n}\n// #endregion\n\n// #region create card\nconst requestCardCreation = (data, cardData) => ({\n type: TYPES.REQUEST_CARD_CREATION,\n data,\n cardData,\n})\n\nconst receiveCardCreationSuccess = response => ({\n type: TYPES.RECEIVE_CARD_CREATION_SUCCESS,\n response,\n})\n\nconst receiveCardCreationError = data => ({\n type: TYPES.RECEIVE_CARD_CREATION_ERROR,\n data,\n})\n\nexport const createCard = (data, cardData) => dispatch => {\n dispatch(requestCardCreation(data, cardData))\n\n const { account, workspace } = data\n const url = `${localApiBase({ account, workspace })}/postgiftcard`\n\n return axios\n .post(url, cardData)\n .then(response => {\n if (response.status === 200) {\n dispatch(receiveCardCreationSuccess(response))\n } else {\n dispatch(receiveCardCreationError(response.status))\n }\n })\n .catch(error =>\n dispatch(\n receiveCardCreationError(\n (error && error.response && error.response.data) || null,\n ),\n ),\n )\n}\n// #endregion\n\n```" } ]
code_giftcard-ui_62bb6b17
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of giftcard-ui/react/reducers/cards/index.js from the giftcard-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport * as TYPES from '../../actions/types'\n\nconst initialState = {\n isLoading: false,\n}\n\nconst cardsReducer = (state = initialState, action) => {\n switch (action.type) {\n case TYPES.REQUEST_CARDS: {\n return {\n ...state,\n isLoading: true,\n }\n }\n case TYPES.RECEIVE_CARDS_SUCCESS: {\n return {\n ...state,\n isLoading: false,\n cards: action.cards,\n }\n }\n case TYPES.RECEIVE_CARDS_ERROR: {\n return {\n ...state,\n isLoading: false,\n }\n }\n\n case TYPES.REQUEST_CARD_CREATION: {\n return {\n ...state,\n isLoading: true,\n }\n }\n case TYPES.RECEIVE_CARD_CREATION_SUCCESS: {\n return {\n ...state,\n isLoading: false,\n }\n }\n case TYPES.RECEIVE_CARD_CREATION_ERROR: {\n return {\n ...state,\n isLoading: false,\n }\n }\n\n default:\n return state\n }\n}\n\nexport default cardsReducer\n\n```" } ]
code_instore-form-fields_5907b29c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of instore-form-fields/docs/README.md from the instore-form-fields VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Instore Form Fields\n\nThis is an VTEX IO app that provides the tooling for adding extra fields on your Instore Customer Profile Registration Form.\n\nIt is as simple as creating a new IO React App and adding\n\n```\n \"registration-container/{{whatever-name}}\": {\n \"component\": \"vtex.instore-form-fields/FormInput\",\n \"props\": {\n \"ffor\": \"{{key on Masterdata}}\",\n \"nameKey\": \"{{locale key to label the input}}\",\n \"initialValue\": \"{{if any, it is optional}}\"\n }\n },\n```\n\nAnd also, don't forget to [add the same key on Masterdata](http://help.vtex.com/pt/faq/como-crio-um-campo-no-master-data) you mentioned on your app, otherwise it won't save a thing.\n```" } ]
code_instore-form-fields_82ef39e4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of instore-form-fields/react/FormInput.js from the instore-form-fields VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport PropTypes from 'prop-types'\n\nclass FormInput extends Component {\n static propTypes = {\n for: PropTypes.string,\n nameKey: PropTypes.string,\n initialValue: PropTypes.string,\n handleInputChange: PropTypes.func,\n isRequired: PropTypes.bool,\n }\n\n static defaultTypes = {\n initialValue: \"\"\n }\n\n render () {\n const { ffor, nameKey, initialValue, handleInputChange, isRequired } = this.props\n return (\n <div className=\"ph5 pt4\">\n <label className=\"db f6 f5-ns mb4 gray\" htmlFor={ffor}>\n <FormattedMessage id={nameKey} />\n </label>\n <input\n type=\"text\"\n placeholder=\"\"\n id={ffor}\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"off\"\n spellCheck=\"false\"\n className=\"db ba b--black-20 w-100 w-100-ns pa4 pa5-ns lh-copy f4-ns mb5 mb6-ns\"\n defaultValue={initialValue}\n onChange={handleInputChange}\n required={isRequired}\n />\n </div>\n )\n }\n\n}\n\nexport default FormInput\n\n```" } ]
code_instore-form-fields_10023541
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of instore-form-fields/react/package.json from the instore-form-fields VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"react-intl\": \"^2.7.2\"\n }\n}\n\n```" } ]
code_cybersource-ui_fa700c93
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/messages/en.json from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/cybersource.title\": \"Cybersource\",\n \"admin/cybersource.saveSettings.success\": \"Settings saved successfully\",\n \"admin/cybersource.saveSettings.failure\": \"Settings could not be saved, see console for details\",\n \"admin/cybersource.settings.introduction\": \"{cybersourceLink}\",\n \"admin/cybersource.saveSettings.buttonText\": \"Save settings\",\n \"admin/cybersource.settings.isLive.label\": \"Production mode\",\n \"admin/cybersource.settings.merchantId.label\": \"Merchant id\",\n \"admin/cybersource.settings.merchantKey.label\": \"Merchant key\",\n \"admin/cybersource.settings.sharedSecretKey.label\": \"Shared secret key\",\n \"admin/cybersource.settings.customNsu.label\": \"Custom NSU\",\n \"admin/cybersource.settings.orderSuffix.label\": \"Reference Suffix\",\n \"admin/cybersource.settings.enableTransactionPosting.label\": \"Enable transaction posting\",\n \"admin/cybersource.settings.salesChannelExclude.label\": \"Sales Channels to Exclude from Cybersource.\",\n \"admin/cybersource.settings.nexusRegions.label\": \"Tax Nexus Regions.\",\n \"admin/cybersource.settings.shippingProductCode.label\": \"Shipping Product Code.\",\n \"admin/cybersource.settings.isLive.helpText\": \"Disable this toggle if using a sandbox API key.\",\n \"admin/cybersource.settings.merchantId.helpText\": \"Write your merchant Id\",\n \"admin/cybersource.settings.merchantKey.helpText\": \"Write your merchant Key\",\n \"admin/cybersource.settings.sharedSecretKey.helpText\": \"Write your shared secret key\",\n \"admin/cybersource.settings.customNsu.helpText\": \"Override default NSU with custom value\",\n \"admin/cybersource.settings.UseOrderIdForFingerprint.label\": \"Use Order Id For Device Fingerprint\",\n \"admin/cybersource.settings.UseOrderIdForFingerprint.helpText\": \"Use Order Id For Device Fingerprint in place of the Session Id\",\n \"admin/cybersource.settings.orderSuffix.helpText\": \"Optional Order Reference Suffix\",\n \"admin/cybersource.settings.EnableTax.label\": \"Enable Tax Calculations\",\n \"admin/cybersource.settings.EnableTax.helpText\": \"Enable Tax Placeholder\",\n \"admin/cybersource.settings.enableTransactionPosting.helpText\": \"Enable transaction posting\",\n \"admin/cybersource.settings.salesChannelExclude.helpText\": \"Comma separated list of sales channel ids to exclude.\",\n \"admin/cybersource.settings.nexusRegions.helpText\": \"Comma separated list of states where tax is to be collected. If none, tax will be calculated for all regions.\",\n \"admin/cybersource.settings.shippingProductCode.helpText\": \"Shipping Product Code.\",\n \"admin/cybersource.settings.successfulPortion\": \"Successful Portion\",\n \"admin/cybersource.settings.userInput\": \"User Input\",\n \"admin/cybersource.settings.isValid\": \"Valid\",\n \"admin/cybersource.settings.valid\": \"Valid\",\n \"admin/cybersource.settings.invalid\": \"Invalid\",\n \"admin/cybersource.settings.showRefenceWords\": \"Show All Referencable Words\",\n \"admin/cybersource.settings.merchantDefinedInfo\": \"Merchant Defined Information\",\n \"admin/cybersource.settings.merchantDefinedFields\": \"Merchant Defined Fields\",\n \"admin/cybersource.settings.merchantFieldsReadme\": \"Adding Merchant Defined Fields\",\n \"admin/cybersource.settings.readmeContent\": \"You can create merchant defined fields on this page that will be included when sending VTEX orders to CyberSource.{lineBreak}{lineBreak}Each line of the text area will be treated as a new merchant defined field; multiple values on a single line will be sent as part of the same field. See the app's documentation for further instructions.{lineBreak}{lineBreak}Any characters outside of double curly brackets will be interpreted as a static value.{lineBreak}Meanwhile any values inside double curly brackets must be in the following format: Reference Word|Modification Word|Values\",\n \"admin/cybersource.settings.readmeLink\": \"Full Documentation Link\",\n \"admin/cybersource.settings.reports.reports.label\": \"Reports\",\n \"admin/cybersource.settings.reports.reportsDay.label\": \"Reports Day\",\n \"admin/cybersource.settings.reports.conversionTime.label\": \"Conversion Time\",\n \"admin/cybersource.settings.reports.merchantReferenceNumber.label\": \"Merchant Reference Number\",\n \"admin/cybersource.settings.reports.newDecision.label\": \"New Decision\",\n \"admin/cybersource.settings.reports.originalDecision.label\": \"Original Decision\",\n \"admin/cybersource.settings.reports.reviewer.label\": \"Reviewer\",\n \"admin/cybersource.settings.reports.reviewerComments.label\": \"Reviewer Comments\",\n \"admin/cybersource.settings.reports.noReports.label\": \"There is no reports here!\"\n}\n\n```" } ]
code_cybersource-ui_73d8e118
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/messages/context.json from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/cybersource.title\": \"Cybersource\",\n \"admin/cybersource.saveSettings.success\": \"Settings saved successfully\",\n \"admin/cybersource.saveSettings.failure\": \"Settings could not be saved, see console for details\",\n \"admin/cybersource.settings.introduction\": \"{cybersourceLink}\",\n \"admin/cybersource.saveSettings.buttonText\": \"Save settings\",\n \"admin/cybersource.settings.isLive.label\": \"Production mode\",\n \"admin/cybersource.settings.merchantId.label\": \"Merchant id\",\n \"admin/cybersource.settings.merchantKey.label\": \"Merchant key\",\n \"admin/cybersource.settings.sharedSecretKey.label\": \"Shared secret key\",\n \"admin/cybersource.settings.customNsu.label\": \"Custom NSU\",\n \"admin/cybersource.settings.orderSuffix.label\": \"Reference Suffix\",\n \"admin/cybersource.settings.enableTransactionPosting.label\": \"Enable transaction posting\",\n \"admin/cybersource.settings.salesChannelExclude.label\": \"Sales Channels to Exclude from Cybersource.\",\n \"admin/cybersource.settings.nexusRegions.label\": \"Tax Nexus Regions.\",\n \"admin/cybersource.settings.shippingProductCode.label\": \"Shipping Product Code.\",\n \"admin/cybersource.settings.isLive.helpText\": \"Disable this toggle if using a sandbox API key.\",\n \"admin/cybersource.settings.merchantId.helpText\": \"Write your merchant Id\",\n \"admin/cybersource.settings.merchantKey.helpText\": \"Write your merchant Key\",\n \"admin/cybersource.settings.sharedSecretKey.helpText\": \"Write your shared secret key\",\n \"admin/cybersource.settings.customNsu.helpText\": \"Override default NSU with custom value\",\n \"admin/cybersource.settings.UseOrderIdForFingerprint.label\": \"Use Order Id For Device Fingerprint\",\n \"admin/cybersource.settings.UseOrderIdForFingerprint.helpText\": \"Use Order Id For Device Fingerprint in place of the Session Id\",\n \"admin/cybersource.settings.orderSuffix.helpText\": \"Optional Order Reference Suffix\",\n \"admin/cybersource.settings.EnableTax.label\": \"Enable Tax Calculations\",\n \"admin/cybersource.settings.EnableTax.helpText\": \"Enable Tax Placeholder\",\n \"admin/cybersource.settings.enableTransactionPosting.helpText\": \"Enable transaction posting\",\n \"admin/cybersource.settings.salesChannelExclude.helpText\": \"Comma separated list of sales channel ids to exclude.\",\n \"admin/cybersource.settings.nexusRegions.helpText\": \"Comma separated list of states where tax is to be collected. If none, tax will be calculated for all regions.\",\n \"admin/cybersource.settings.shippingProductCode.helpText\": \"Shipping Product Code.\",\n \"admin/cybersource.settings.successfulPortion\": \"Successful Portion\",\n \"admin/cybersource.settings.userInput\": \"User Input\",\n \"admin/cybersource.settings.isValid\": \"Valid\",\n \"admin/cybersource.settings.valid\": \"Valid\",\n \"admin/cybersource.settings.invalid\": \"Invalid\",\n \"admin/cybersource.settings.showRefenceWords\": \"Show All Referencable Words\",\n \"admin/cybersource.settings.merchantDefinedInfo\": \"Merchant Defined Information\",\n \"admin/cybersource.settings.merchantDefinedFields\": \"Merchant Defined Fields\",\n \"admin/cybersource.settings.merchantFieldsReadme\": \"Adding Merchant Defined Fields\",\n \"admin/cybersource.settings.readmeContent\": \"You can create merchant defined fields on this page that will be included when sending VTEX orders to CyberSource.{lineBreak}{lineBreak}Each line of the text area will be treated as a new merchant defined field; multiple values on a single line will be sent as part of the same field. See the app's documentation for further instructions.{lineBreak}{lineBreak}Any characters outside of double curly brackets will be interpreted as a static value.{lineBreak}Meanwhile any values inside double curly brackets must be in the following format: Reference Word|Modification Word|Values\",\n \"admin/cybersource.settings.readmeLink\": \"Full Documentation Link\",\n \"admin/cybersource.settings.reports.reports.label\": \"Reports\",\n \"admin/cybersource.settings.reports.reportsDay.label\": \"Reports Day\",\n \"admin/cybersource.settings.reports.conversionTime.label\": \"Conversion Time\",\n \"admin/cybersource.settings.reports.merchantReferenceNumber.label\": \"Merchant Reference Number\",\n \"admin/cybersource.settings.reports.newDecision.label\": \"New Decision\",\n \"admin/cybersource.settings.reports.originalDecision.label\": \"Original Decision\",\n \"admin/cybersource.settings.reports.reviewer.label\": \"Reviewer\",\n \"admin/cybersource.settings.reports.reviewerComments.label\": \"Reviewer Comments\",\n \"admin/cybersource.settings.reports.noReports.label\": \"There is no reports here!\"\n}\n\n```" } ]
code_cybersource-ui_9cce4387
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/admin/navigation.json from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"LMProductId\": \"6\",\n \"section\": \"transactions\",\n \"path\": \"/admin/cybersource\",\n \"icon\": \"extensions-ic\",\n \"titleId\": \"admin/cybersource.title\"\n}\n\n```" } ]
code_cybersource-ui_4d7fc1fe
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/admin/routes.json from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin.app.cybersource\": {\n \"component\": \"Admin\",\n \"path\": \"/admin/app/cybersource\"\n }\n}\n\n```" } ]
code_cybersource-ui_bb66e322
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/docs/README.md from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/vtex-apps/cybersource) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n\n[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)\n\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\n# CyberSource IO\n\nThis app uses the CyberSource REST API to process payments, risk management, and taxes.\n\n## Configuration\n\n1. [Install](https://developers.vtex.com/vtex-developer-docs/docs/vtex-io-documentation-installing-an-app) `vtex.cybersource` and `vtex.cybersource-ui` in the desired account.\n\n2. In Cybersource EBC, generate authentication keys.\n\t- Payment Configuration -> Key Management -> Generate Key\n\t- Choose `REST - Shared Secret` and Generate Key\n\n3. In VTEX Admin, search for \"Cybersource\" to find the admin panel as shown below:\n\t![image](https://user-images.githubusercontent.com/47258865/178300211-3d3eadf2-6f44-4db4-95dd-76fae2bfebc4.png)\n\n - Enter your `Merchant ID`\n - Enter your `Merchant Key` and `Shared Secret Key` from step 2\n - Select a `Processor` (choose \"Other\" if your processor does not appear in the list) \n - Select a `Region` (choose \"Other\" if your region does not appear in the list)\n - Optionally enter a `Reference Suffix` (by default, orders in CyberSource's system will be associated with the VTEX order group ID, but this setting can be used to append a suffix such as \"-01\")\n - Optionally enter a `Custom NSU`\n - Choose whether to `Enable Tax Calculations` if you wish to use CyberSource as your tax calculation provider in checkout\n - Choose whether to `Enable Transaction Posting` to post completed transactions for tax reporting\n - Optionally enter any `Sales Channels to Exclude from CyberSource`\n - Optionally enter a `Shipping Product Code` for purposes of shipping tax calculation\n - Optionally enter a list of `Tax Nexus Regions`\n - Click `Save Settings`\n\n4. In VTEX Admin, navigate to Payment Settings (`/admin/pci-gateway/#/rules`)\n\t- Select the Gateway Affiliations tab and click the green plus to add a new affiliation\n\t- From the list of gateways, select `Cybersource IO`\n\t- Configure the affiliation as follows: \n - Leave `Application Key` & `Application Token` blank (they are not used)\n\t - Select the desired `Payment settlement` behavior: \n - \"Use Behavior Recommended By The Payment Processor\" will result in authorized payments being automatically captured after 4 days (or if the order is invoiced, whichever comes first)\n - \"Deactivated\" will result in payments being captured only when the VTEX order is invoiced\n\t - Enter your `Company Name` and `Company Tax Id`\n - `Capture Setting`: if set to \"Immediate Capture\", the connector will send a single \"Auth and Capture\" request to CyberSource when the order is placed; otherwise it will follow standard VTEX behavior (separate calls for auth and capture) \n - `Merchant Id`, `Merchant Key`, and `Shared Secret Key` are optional overrides; if left blank, the connector will read these values from the settings entered in step 3\n - Click `Save`\n\t![image](https://user-images.githubusercontent.com/47258865/178299999-a27149a6-f937-4602-96ed-d232d8795095.png)\n\n5. In VTEX Admin, still in the Payment Settings interface\n\t- Select the Payment Conditions tab\n - Click the green plus to add a new payment condition for the desired credit card type (ex. Visa)\n - In `Process with affiliation`, choose `Cybersource IO` (or if you have customized the name of the affiliation, select the name you entered)\n - Click `Save`\n - Repeat as needed for other credit card types\n - If you previously created credit card payment rules for other gateways (including the legacy CyberSource connector), you may set these rules to `Inactive`. Transactions in progress that were started on that connector will still be processed by it even if it is inactive; only new transactions will be processed by the new connector. \n - If you need to roll back to the previous connector for any reason, simply set its payment rule(s) to `Active` and set the `Cybersource IO` payment rule(s) to `Inactive`. \n\n### Optional: Device Fingerprint\n\nAdd the following code to your checkout custom JS and replace `{{ORG_ID}}` and `{{MERCHANT_ID}}` with the appropriate values.\n```\nfunction addsDeviceFingerPrint() {\n if (!window.vtex) return;\n if (window.vtex.deviceFingerprint) return;\n $.ajax({\n type: 'get',\n async: true,\n url: rootPath() + '/api/sessions?items=*'\n }).then(function(response) {\n var ORG_ID = \"{{ORG_ID}}\";\n var MERCHANT_ID = \"{{MERCHANT_ID}}\";\n console.log('session', response);\n window.vtex.deviceFingerprint = response.id;\n var sessionId = response.id || \"CYBERSOURCE\";\n var script = document.createElement(\"script\");\n script.type = \"text/javascript\";\n script.src = `https://h.online-metrix.net/fp/tags.js?org_id=${ORG_ID}&session_id=${MERCHANT_ID}${sessionId}`;\n document.head.appendChild(script);\n var noScript = document.createElement(\"noscript\");\n var iframe = document.createElement(\"iframe\");\n iframe.style = \"width: 100px; height: 100px; border: 0; position: absolute; top: -5000px;\";\n iframe.src = `https://h.online-metrix.net/fp/tags?org_id=${ORG_ID}&session_id=${MERCHANT_ID}${sessionId}`;\n noScript.appendChild(iframe);\n document.body.appendChild(noScript);\n })\n}\n```\n\n### Optional: Merchant Defined Fields\n\n- In VTEX Admin, search for \"Cybersource\" to navigate to the app's admin panel.\n- In the `Merchant Defined Fields` tab, users can define custom fields.\n- The text input follows these rules:\n 1. Any values outside of **{{}}** curly brackets will be taken at direct value\n 2. Any values between the **{{}}** must be in the following format `Reference Word|Modification Word|Values`\n 1. All reference words can be found in the `Show All Referencable Words` dropdown\n 1. Reference words can be left blank if `Modification Word` and `Values` are present\n 2. Reference word is case sensitive\n 2. Modification Words are either `Pad` or `date`\n 3. If using `Pad`, the `Values` must be either in the format of a `number` or `desired length:fill character`\n 1. `fill character` must be a single value. For example, `9:x` will result in a desired length of 9, and filling empty spaces with x \n 4. If using `date`, the `Values` must be in the format of `dd/MM/yyyy` or any combination of it.\n 1. `M` for month must be capitalized. This format can be scrambled to your liking, such as `yyyy/MM` or `yyyy` or `dd/yyyy/MM`\n 3. Every new line is a new Merchant Defined Field\n- Examples\n\n| Input | Is it Valid? | Reason |\n| ------------- | ------------- | ------------- |\n| {{MiniCart.Buyer.LastName}},{{MiniCart.Buyer.FirstName}} | Valid | Reference words are valid |\n| 26940{{\\|date\\|yy} | Invalid | Missing second closing bracket |\n| 26940{{\\|date\\|yy}} | Valid | Valid |\n| currency{{notaword}} | Invalid | Invalid reference word |\n\n## Contributors ✨\n\nThanks go to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\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 welcome!\n\n```" } ]
code_cybersource-ui_7d9d3db7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/react/package.json from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"cybersource-ui\",\n \"version\": \"0.8.0\",\n \"description\": \"Cybersource UI\",\n \"repository\": \"https://github.com/vtex-apps/cybersource\",\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^3.1.3\",\n \"@types/jest\": \"^26.0.4\",\n \"@types/node\": \"^14.0.14\",\n \"@types/react\": \"^16.9.41\",\n \"@vtex/test-tools\": \"^3.1.0\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"apollo-cache-inmemory\": \"^1.6.5\",\n \"graphql\": \"^14.6.0\",\n \"typescript\": \"3.9.7\",\n \"vtex.apps-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.apps-graphql@2.8.0/public/@types/vtex.apps-graphql\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.132.3/public/@types/vtex.render-runtime\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.145.2/public/@types/vtex.styleguide\"\n },\n \"dependencies\": {\n \"@vtex/admin-ui\": \"latest\",\n \"axios\": \"^0.19.2\",\n \"graphql\": \"^15.3.0\",\n \"react-apollo\": \"^3.1.5\",\n \"react-intl\": \"^5.0.2\"\n }\n}\n\n```" } ]
code_cybersource-ui_a05867c5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/react/Admin.tsx from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-unused-vars */\n// react/adminExample.tsx\nimport type { FC } from 'react'\nimport React, { useState, useEffect } from 'react'\nimport {\n ToastProvider,\n ToastConsumer,\n Layout,\n PageHeader,\n PageBlock,\n Button,\n Toggle,\n Input,\n Dropdown,\n Spinner,\n Tab,\n Tabs,\n} from 'vtex.styleguide'\nimport { FormattedMessage, useIntl } from 'react-intl'\nimport { Link } from 'vtex.render-runtime'\nimport { useQuery, useMutation } from 'react-apollo'\n\nimport MerchantDictionary from './components/merchantDictionary'\nimport Reports from './components/Reports'\nimport M_INIT_CONFIG from './mutations/InitConfiguration.gql'\nimport RemoveConfiguration from './mutations/RemoveConfiguration.gql'\nimport AppSettings from './queries/appSettings.gql'\nimport SaveAppSettings from './mutations/saveAppSettings.gql'\n\nconst Admin: FC = () => {\n const { formatMessage } = useIntl()\n const [saveSettings] = useMutation(SaveAppSettings)\n const [initConfig] = useMutation(M_INIT_CONFIG)\n const [removeConfig] = useMutation(RemoveConfiguration)\n const [settingsLoading, setSettingsLoading] = useState(false)\n const [settingsState, setSettingsState] = useState({\n IsLive: false,\n MerchantId: '',\n MerchantKey: '',\n SharedSecretKey: '',\n Processor: '',\n Region: '',\n OrderSuffix: '',\n CustomNsu: '',\n EnableTransactionPosting: false,\n SalesChannelExclude: '',\n ShippingProductCode: '',\n NexusRegions: '',\n EnableTax: false,\n MerchantDictionary: [],\n UseOrderIdForFingerprint: false,\n })\n\n const [initialAdminState, setAdminState] = useState({\n currentTab: 1,\n })\n\n const { data } = useQuery(AppSettings, {\n variables: {\n version: process.env.VTEX_APP_VERSION,\n },\n ssr: false,\n })\n\n const processorOptions = [\n { value: 'Braspag', label: 'Braspag' },\n { value: 'VPC', label: 'VPC' },\n { value: 'Izipay', label: 'Izipay' },\n { value: 'eGlobal', label: 'eGlobal' },\n { value: 'BBVA', label: 'BBVA' },\n { value: 'Banorte', label: 'Banorte' },\n { value: 'Prosa', label: 'Prosa' },\n { value: 'Santander', label: 'Santander' },\n { value: 'Amex Direct', label: 'American Express Direct' },\n { value: 'Other', label: 'Other' },\n ]\n\n const regionOptions = [\n { value: 'CO', label: 'Colombia' },\n { value: 'PE', label: 'Peru' },\n { value: 'MX', label: 'Mexico' },\n { value: 'BR', label: 'Brasil' },\n { value: 'EC', label: 'Ecuador' },\n { value: 'Other', label: 'Other' },\n ]\n\n const handleSaveSettings = async (showToast: any) => {\n setSettingsLoading(true)\n\n try {\n if (settingsState.EnableTax) {\n await initConfig()\n } else {\n await removeConfig()\n }\n\n await saveSettings({\n variables: {\n version: process.env.VTEX_APP_VERSION,\n settings: JSON.stringify(settingsState),\n },\n }).then(() => {\n showToast({\n message: formatMessage({\n id: 'admin/cybersource.saveSettings.success',\n }),\n duration: 5000,\n })\n setSettingsLoading(false)\n })\n } catch (error) {\n console.error(error)\n showToast({\n message: formatMessage({\n id: 'admin/cybersource.saveSettings.failure',\n }),\n duration: 5000,\n })\n setSettingsLoading(false)\n }\n }\n\n useEffect(() => {\n if (!data?.getAppSettings) return\n\n setSettingsState({\n ...settingsState,\n CustomNsu: data.getAppSettings.customNsu,\n EnableTax: data.getAppSettings.enableTax,\n EnableTransactionPosting: data.getAppSettings.enableTrasactionPosting,\n IsLive: data.getAppSettings.isLive,\n MerchantId: data.getAppSettings.merchantId,\n MerchantKey: data.getAppSettings.merchantKey,\n NexusRegions: data.getAppSettings.nexusRegions,\n OrderSuffix: data.getAppSettings.orderSuffix,\n Processor: data.getAppSettings.processor,\n Region: data.getAppSettings.region,\n SalesChannelExclude: data.getAppSettings.salesChannelExclude,\n SharedSecretKey: data.getAppSettings.sharedSecretKey,\n ShippingProductCode: data.getAppSettings.shippingProductCode,\n MerchantDictionary: data.getAppSettings.merchantDictionary,\n UseOrderIdForFingerprint: data.getAppSettings.useOrderIdForFingerprint,\n })\n }, [data])\n\n if (!data) {\n return (\n <Layout\n pageHeader={\n <PageHeader\n title={<FormattedMessage id=\"admin/cybersource.title\" />}\n />\n }\n fullWidth\n >\n <PageBlock>\n <Spinner />\n </PageBlock>\n </Layout>\n )\n }\n\n return (\n <ToastProvider positioning=\"window\">\n <ToastConsumer>\n {({ showToast }: { showToast: any }) => (\n <Layout\n pageHeader={\n <PageHeader\n title={<FormattedMessage id=\"admin/cybersource.title\" />}\n />\n }\n fullWidth\n >\n <div>\n <Tabs fullWidth>\n <Tab\n label=\"Admin Settings\"\n active={initialAdminState.currentTab === 1}\n onClick={() => setAdminState({ currentTab: 1 })}\n >\n <div className=\"pt7\">\n <PageBlock\n subtitle={\n <FormattedMessage\n id=\"admin/cybersource.settings.introduction\"\n values={{\n cybersourceLink: (\n // eslint-disable-next-line react/jsx-no-target-blank\n <Link\n to=\"https://www.cybersource.com/\"\n target=\"_blank\"\n >\n https://www.cybersource.com/\n </Link>\n ),\n lineBreak: <br />,\n }}\n />\n }\n >\n <section className=\"pv4\">\n <Toggle\n semantic\n label={formatMessage({\n id: 'admin/cybersource.settings.isLive.label',\n })}\n size=\"large\"\n checked={settingsState.IsLive}\n onChange={() => {\n setSettingsState({\n ...settingsState,\n IsLive: !settingsState.IsLive,\n })\n }}\n helpText={formatMessage({\n id: 'admin/cybersource.settings.isLive.helpText',\n })}\n />\n </section>\n <section className=\"pb4 mt4\">\n <Input\n label={formatMessage({\n id: 'admin/cybersource.settings.merchantId.label',\n })}\n value={settingsState.MerchantId}\n onChange={(e: React.FormEvent<HTMLInputElement>) =>\n setSettingsState({\n ...settingsState,\n MerchantId: e.currentTarget.value,\n })\n }\n helpText={formatMessage({\n id: 'admin/cybersource.settings.merchantId.helpText',\n })}\n />\n </section>\n <section className=\"pb4 mt4\">\n <Input\n label={formatMessage({\n id: 'admin/cybersource.settings.merchantKey.label',\n })}\n value={settingsState.MerchantKey}\n onChange={(e: React.FormEvent<HTMLInputElement>) =>\n setSettingsState({\n ...settingsState,\n MerchantKey: e.currentTarget.value,\n })\n }\n helpText={formatMessage({\n id: 'admin/cybersource.settings.merchantKey.helpText',\n })}\n />\n </section>\n <section className=\"pb4 mt4\">\n <Input\n label={formatMessage({\n id: 'admin/cybersource.settings.sharedSecretKey.label',\n })}\n value={settingsState.SharedSecretKey}\n onChange={(e: React.FormEvent<HTMLInputElement>) =>\n setSettingsState({\n ...settingsState,\n SharedSecretKey: e.currentTarget.value,\n })\n }\n helpText={formatMessage({\n id: 'admin/cybersource.settings.sharedSecretKey.helpText',\n })}\n />\n </section>\n <section className=\"mb5\">\n <Dropdown\n label=\"Processor\"\n options={processorOptions}\n value={settingsState.Processor}\n onChange={(e: React.FormEvent<HTMLInputElement>) =>\n setSettingsState({\n ...settingsState,\n Processor: e.currentTarget.value,\n })\n }\n />\n </section>\n <section className=\"mb5\">\n <Dropdown\n label=\"Region\"\n options={regionOptions}\n value={settingsState.Region}\n onChange={(e: React.FormEvent<HTMLInputElement>) =>\n setSettingsState({\n ...settingsState,\n Region: e.currentTarget.value,\n })\n }\n />\n </section>\n <section className=\"pb4 mt4\">\n <Input\n label={formatMessage({\n id: 'admin/cybersource.settings.orderSuffix.label',\n })}\n value={settingsState.OrderSuffix}\n onChange={(e: React.FormEvent<HTMLInputElement>) =>\n setSettingsState({\n ...settingsState,\n OrderSuffix: e.currentTarget.value,\n })\n }\n helpText={formatMessage({\n id: 'admin/cybersource.settings.orderSuffix.helpText',\n })}\n />\n </section>\n <section className=\"pb4 mt4\">\n <Input\n label={formatMessage({\n id: 'admin/cybersource.settings.customNsu.label',\n })}\n value={settingsState.CustomNsu}\n onChange={(e: React.FormEvent<HTMLInputElement>) =>\n setSettingsState({\n ...settingsState,\n CustomNsu: e.currentTarget.value,\n })\n }\n helpText={formatMessage({\n id: 'admin/cybersource.settings.customNsu.helpText',\n })}\n />\n </section>\n <section className=\"pv4\">\n <Toggle\n semantic\n label={formatMessage({\n id: 'admin/cybersource.settings.UseOrderIdForFingerprint.label',\n })}\n size=\"large\"\n checked={settingsState.UseOrderIdForFingerprint}\n onChange={() => {\n setSettingsState({\n ...settingsState,\n UseOrderIdForFingerprint:\n !settingsState.UseOrderIdForFingerprint,\n })\n }}\n helpText={formatMessage({\n id: 'admin/cybersource.settings.UseOrderIdForFingerprint.helpText',\n })}\n />\n </section>\n <section className=\"pv4\">\n <Toggle\n semantic\n label={formatMessage({\n id: 'admin/cybersource.settings.EnableTax.label',\n })}\n size=\"large\"\n checked={settingsState.EnableTax}\n onChange={() => {\n setSettingsState({\n ...settingsState,\n EnableTax: !settingsState.EnableTax,\n })\n }}\n helpText={formatMessage({\n id: 'admin/cybersource.settings.EnableTax.helpText',\n })}\n />\n </section>\n <section className=\"pv4\">\n <Toggle\n semantic\n label={formatMessage({\n id: 'admin/cybersource.settings.enableTransactionPosting.label',\n })}\n size=\"large\"\n checked={settingsState.EnableTransactionPosting}\n onChange={() => {\n setSettingsState({\n ...settingsState,\n EnableTransactionPosting:\n !settingsState.EnableTransactionPosting,\n })\n }}\n helpText={formatMessage({\n id: 'admin/cybersource.settings.enableTransactionPosting.helpText',\n })}\n />\n </section>\n <section className=\"pb4 mt4\">\n <Input\n label={formatMessage({\n id: 'admin/cybersource.settings.salesChannelExclude.label',\n })}\n value={settingsState.SalesChannelExclude}\n onChange={(e: React.FormEvent<HTMLInputElement>) =>\n setSettingsState({\n ...settingsState,\n SalesChannelExclude: e.currentTarget.value,\n })\n }\n helpText={formatMessage({\n id: 'admin/cybersource.settings.salesChannelExclude.helpText',\n })}\n />\n </section>\n <section className=\"pb4 mt4\">\n <Input\n label={formatMessage({\n id: 'admin/cybersource.settings.shippingProductCode.label',\n })}\n value={settingsState.ShippingProductCode}\n onChange={(e: React.FormEvent<HTMLInputElement>) =>\n setSettingsState({\n ...settingsState,\n ShippingProductCode: e.currentTarget.value,\n })\n }\n helpText={formatMessage({\n id: 'admin/cybersource.settings.shippingProductCode.helpText',\n })}\n />\n </section>\n <section className=\"pb4 mt4\">\n <Input\n label={formatMessage({\n id: 'admin/cybersource.settings.nexusRegions.label',\n })}\n value={settingsState.NexusRegions}\n onChange={(e: React.FormEvent<HTMLInputElement>) =>\n setSettingsState({\n ...settingsState,\n NexusRegions: e.currentTarget.value,\n })\n }\n helpText={formatMessage({\n id: 'admin/cybersource.settings.nexusRegions.helpText',\n })}\n />\n </section>\n <section className=\"pt4\">\n <Button\n variation=\"primary\"\n onClick={() => handleSaveSettings(showToast)}\n isLoading={settingsLoading}\n >\n <FormattedMessage id=\"admin/cybersource.saveSettings.buttonText\" />\n </Button>\n </section>\n </PageBlock>\n </div>\n </Tab>\n <Tab\n label={formatMessage({\n id: 'admin/cybersource.settings.merchantDefinedFields',\n })}\n active={initialAdminState.currentTab === 2}\n onClick={() => setAdminState({ currentTab: 2 })}\n >\n <div className=\"pt7\">\n <MerchantDictionary\n handleSaveSettings={handleSaveSettings}\n showToast={showToast}\n settingsState={settingsState}\n setSettingsState={setSettingsState}\n settingsLoading={settingsLoading}\n />\n </div>\n </Tab>\n <Tab\n label={formatMessage({\n id: 'admin/cybersource.settings.reports.reports.label',\n })}\n active={initialAdminState.currentTab === 3}\n onClick={() => setAdminState({ currentTab: 3 })}\n >\n <div className=\"pt7\">\n <Reports />\n </div>\n </Tab>\n </Tabs>\n </div>\n </Layout>\n )}\n </ToastConsumer>\n </ToastProvider>\n )\n}\n\nexport default Admin\n\n```" } ]
code_cybersource-ui_a1ea3cc9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/react/types/index.tsx from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nexport interface Report {\n conversionTime: string\n merchantReferenceNumber: string\n newDecision: string\n originalDecision: string\n reviewer: string\n reviewerComments: string\n}\nexport interface ReportsTableProps {\n reports: Report[]\n loading: boolean\n}\nexport interface ReportsState {\n selectedDay: any\n loading: boolean\n reports: Report[]\n}\n\n```" } ]
code_cybersource-ui_ed3dad89
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/react/mutations/InitConfiguration.gql from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation InitConfiguration {\n initConfiguration\n}\n\n```" } ]
code_cybersource-ui_f1fd0532
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/react/mutations/RemoveConfiguration.gql from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation RemoveConfiguration {\n removeConfiguration\n}\n\n```" } ]
code_cybersource-ui_785371ed
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/react/mutations/saveAppSettings.gql from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation SaveAppSettings($version: String, $settings: String) {\n saveAppSettings(\n app: \"vtex.cybersource-ui\"\n settings: $settings\n version: $version\n ) @context(provider: \"vtex.apps-graphql\") {\n message\n }\n}\n\n```" } ]
code_cybersource-ui_0da5ecce
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/react/typings/png.d.ts from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.png' {\n const path: string\n export default path\n}\n\n```" } ]
code_cybersource-ui_3b82d89b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/react/typings/css.d.ts from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const css: any\n export default css\n}\n\n```" } ]
code_cybersource-ui_4be8e0ce
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/react/typings/graphql.d.ts from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.graphql' {\n import type { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\ndeclare module '*.gql' {\n import type { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\n```" } ]
code_cybersource-ui_16e69c36
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/react/typings/vtex.styleguide.d.ts from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide' {\n export const PageHeader\n export const Alert\n export const Modal\n export const Box\n export const Card\n export const Dropdown\n export const Spinner\n export const Table\n export const Button\n export const ButtonPlain\n export const IconWarning\n export const IconCheck\n export const Input\n export const InputSearch\n export const IconCaretDown\n export const IconCaretUp\n export const IconArrowDown\n export const IconArrowBack\n export const IconArrowUp\n export const IconClose\n export const IconExternalLink\n export const IconSearch\n export const IconSuccess\n export const IconCopy\n export const IconCog\n export const Tooltip\n export const ToastConsumer\n export const ToastProvider\n export const withToast\n export const ButtonWithIcon\n export const Pagination\n export const Collapsible\n export const Textarea\n export const NumericStepper\n export const EmptyState\n export const Tab\n export const Tag\n export const Layout\n export const Tabs\n export const Divider\n export const PageBlock\n export const Toggle\n export const Link\n}\n\n```" } ]
code_cybersource-ui_d38fe64c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/react/queries/reports.gql from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery Reports($startDate: String, $endDate: String) {\n conversionReport(startDate: $startDate, endDate: $endDate) {\n conversionDetails {\n conversionTime\n merchantReferenceNumber\n newDecision\n originalDecision\n reviewer\n reviewerComments\n }\n }\n}\n\n```" } ]
code_cybersource-ui_fc760fa7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/react/queries/appSettings.gql from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery AppSettings($version: String) {\n getAppSettings{\n isLive\n merchantId\n merchantKey\n sharedSecretKey\n processor\n region\n orderSuffix\n customNsu\n useOrderIdForFingerprint\n enableTax\n enableTransactionPosting\n salesChannelExclude\n shippingProductCode\n nexusRegions\n merchantDictionary{\n userInput\n isValid\n goodPortion\n }\n }\n}\n```" } ]
code_cybersource-ui_8a6762e9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/react/queries/merchantDefinedFields.gql from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery MerchantDefinedFields {\n merchantDefinedFields\n}\n\n```" } ]
code_cybersource-ui_5a5b566a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/react/components/Reports.tsx from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable no-console */\nimport React, { useState, useEffect } from 'react'\nimport { defineMessages, useIntl } from 'react-intl'\nimport { useApolloClient } from 'react-apollo'\nimport { createSystem } from '@vtex/admin-ui'\nimport { DatePicker } from 'vtex.styleguide'\n\nimport type { Report } from '../types'\nimport ReportsTable from './ReportsTable'\nimport reportsQuery from '../queries/reports.gql'\n\nconst messages = defineMessages({\n reportsDay: {\n defaultMessage: 'Reports Day',\n id: 'admin/cybersource.settings.reports.reportsDay.label',\n },\n reports: {\n defaultMessage: 'Reports',\n id: 'admin/cybersource.settings.reports.reports.label',\n },\n})\n\nconst Reports = () => {\n const [SystemProvider] = createSystem({ key: 'cybersource' })\n const client = useApolloClient()\n const { formatDate, formatMessage } = useIntl()\n const [state, setState] = useState({\n selectedDay: new Date(),\n loading: true,\n reports: [],\n })\n\n const handleChange = (date: any) => {\n setState(prev => ({\n ...prev,\n selectedDay: date,\n reports: [],\n }))\n }\n\n useEffect(() => {\n setState(prev => ({\n ...prev,\n loading: true,\n }))\n const { selectedDay } = state\n const nextDay = new Date(selectedDay.getTime() + 24 * 60 * 60 * 1000)\n const formatedDate = formatDate(selectedDay, {\n day: '2-digit',\n month: '2-digit',\n year: 'numeric',\n })\n\n const nextfdayFormatedDate = formatDate(nextDay, {\n day: '2-digit',\n month: '2-digit',\n year: 'numeric',\n })\n\n console.log('date::', selectedDay)\n console.log('nextDay::', nextDay)\n console.log('formatedDate::', formatedDate)\n console.log('nextDayFormatedDate::', nextfdayFormatedDate)\n\n // last report: 03/17/2022\n client\n .query({\n query: reportsQuery,\n variables: {\n startDate: formatedDate,\n endDate: nextfdayFormatedDate,\n },\n })\n .then((response: any) => {\n console.log('report::', response)\n const reports =\n response?.data?.conversionReport?.conversionDetails ?? []\n\n setState(prev => ({\n ...prev,\n loading: false,\n reports: reports.map((report: Report) => ({\n ...report,\n conversionTime: formatDate(report.conversionTime, {\n day: '2-digit',\n month: '2-digit',\n year: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n }),\n })),\n }))\n })\n .catch((err: any) => {\n console.log('no reports:', err)\n setState(prev => ({\n ...prev,\n loading: false,\n }))\n })\n }, [state.selectedDay])\n\n return (\n <SystemProvider>\n <div className=\"mb5\">\n <DatePicker\n label={formatMessage(messages.reportsDay)}\n value={state.selectedDay}\n onChange={(date: any) => handleChange(date)}\n locale=\"en-US\"\n />\n </div>\n <div className=\"mb5\">\n <ReportsTable reports={state.reports} loading={state.loading} />\n </div>\n </SystemProvider>\n )\n}\n\nexport default Reports\n\n```" } ]
code_cybersource-ui_8d715cdf
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/react/components/merchantDictionary.tsx from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FunctionComponent } from 'react'\nimport React, { useState, useEffect } from 'react'\nimport { useQuery } from 'react-apollo'\nimport { FormattedMessage, useIntl } from 'react-intl'\nimport {\n Button,\n Collapsible,\n PageBlock,\n Table,\n Tag,\n Textarea,\n Link,\n} from 'vtex.styleguide'\n\nimport MerchantDefinedFields from '../queries/merchantDefinedFields.gql'\n\nconst MerchantDictionary: FunctionComponent<any> = (props: any) => {\n const { formatMessage } = useIntl()\n\n const defaultSchema = {\n properties: {\n userInput: {\n title: formatMessage({\n id: 'admin/cybersource.settings.userInput',\n }),\n width: 300,\n },\n isValid: {\n title: formatMessage({\n id: 'admin/cybersource.settings.isValid',\n }),\n minWidth: 100,\n cellRenderer: ({ cellData }: any) => {\n return cellData ? (\n <Tag type=\"success\" variation=\"low\">\n {formatMessage({\n id: 'admin/cybersource.settings.valid',\n })}\n </Tag>\n ) : (\n <Tag type=\"error\" variation=\"low\">\n {formatMessage({\n id: 'admin/cybersource.settings.invalid',\n })}\n </Tag>\n )\n },\n },\n goodPortion: {\n title: formatMessage({\n id: 'admin/cybersource.settings.successfulPortion',\n }),\n minWidth: 100,\n },\n },\n }\n\n const [state, setState] = useState<{\n textInput: string\n lookupSet: Set<string>\n keyWords: Set<string>\n inputMapping: any\n ruleCharacters: any\n dateLengthRules: any\n validatedResult: Array<{\n userInput: string\n isValid: boolean\n goodPortion: string\n }>\n isOpen: boolean\n }>({\n textInput:\n props?.settingsState?.MerchantDictionary?.length > 0\n ? props.settingsState.MerchantDictionary.reduce(\n (prev: any, curr: any) => {\n return { userInput: `${prev.userInput}\\n${curr.userInput}` }\n }\n ).userInput\n : '',\n lookupSet: new Set([]),\n keyWords: new Set(['PAD', 'DATE', 'AGE', 'EQUALS']),\n inputMapping: {},\n ruleCharacters: { '{': '}', '}': '{' },\n dateLengthRules: {\n d: 2,\n M: 4,\n y: 4,\n },\n validatedResult: props.settingsState.MerchantDictionary ?? [],\n isOpen: false,\n })\n\n const { data } = useQuery(MerchantDefinedFields, {\n ssr: false,\n })\n\n useEffect(() => {\n if (data?.merchantDefinedFields.length > 0) {\n setState((prevState: any) => ({\n ...prevState,\n lookupSet: new Set(data.merchantDefinedFields),\n }))\n }\n }, [data])\n\n const validateInputMap = (textInput: string) => {\n const textInputArr = textInput.split('\\n')\n\n const validatedResult = []\n\n for (const text of textInputArr) {\n let goodPortion = ''\n const stack: string[] = []\n\n for (const char of text) {\n // If there is no opening bracket, just add to it\n if (stack.length === 0 && !(char in state.ruleCharacters)) {\n goodPortion += char\n } else if (stack.length < 2 && char === '{') {\n // If there is an opening bracket\n stack.push(char)\n goodPortion += char\n } else if (stack.length >= 1 && char === '}') {\n // If there is a closing bracket\n // Pops the whole word, if there are no pipe between two sets of brackets\n if (state.lookupSet.has(stack[stack.length - 1])) {\n const poppedWord: string = stack.pop() ?? ''\n\n goodPortion += poppedWord\n } else {\n const splitBracketString = stack[stack.length - 1].split('|')\n\n if (\n splitBracketString.length === 3 &&\n (state.lookupSet.has(splitBracketString[0]) ||\n splitBracketString[0].length === 0) &&\n state.keyWords.has(splitBracketString[1].toUpperCase())\n ) {\n const poppedWord: string = stack.pop() ?? ''\n\n goodPortion += poppedWord\n }\n }\n\n // Pops the bottom layer bracket\n if (stack[stack.length - 1] === '{') {\n stack.pop()\n goodPortion += '}'\n }\n } else if (\n stack[0] === stack[1] &&\n stack[0] === '{' &&\n !(char in state.ruleCharacters)\n ) {\n // Adds to the stack if there are previous brackets, otherwise, append to it\n stack.length === 2\n ? stack.push(char)\n : (stack[stack.length - 1] += char)\n }\n }\n\n validatedResult.push({\n userInput: text,\n goodPortion,\n isValid: stack.length === 0,\n })\n }\n\n setState({ ...state, validatedResult, textInput })\n\n props.setSettingsState({\n ...props.settingsState,\n MerchantDictionary: state.validatedResult,\n })\n }\n\n return (\n <div>\n <div className=\"pa3 bg-muted-5\">\n <PageBlock\n variation=\"annotated\"\n title={formatMessage({\n id: 'admin/cybersource.settings.merchantFieldsReadme',\n })}\n subtitle={\n <Link\n target=\"_blank\"\n href=\"https://developers.vtex.com/vtex-developer-docs/docs/vtex-cybersource-ui\"\n >\n {formatMessage({\n id: 'admin/cybersource.settings.readmeLink',\n })}\n </Link>\n }\n >\n <div className=\"pv2\">\n <FormattedMessage\n id=\"admin/cybersource.settings.readmeContent\"\n values={{ lineBreak: <br /> }}\n />\n </div>\n </PageBlock>\n </div>\n <div className=\"mb6\">\n <div className=\"pa3\">\n <Collapsible\n header={\n <span className=\"c-action-primary hover-c-action-primary fw5\">\n {formatMessage({\n id: 'admin/cybersource.settings.showRefenceWords',\n })}\n </span>\n }\n onClick={(e: any) => {\n setState({ ...state, isOpen: e.target.isOpen })\n }}\n isOpen={state.isOpen}\n >\n {Array.from(state.lookupSet).map((keyword: string) => {\n return (\n <span key={keyword} className=\"pa3\">\n <Tag type=\"success\" variation=\"low\">\n {keyword}\n </Tag>\n </span>\n )\n })}\n </Collapsible>\n </div>\n <Textarea\n label={formatMessage({\n id: 'admin/cybersource.settings.merchantDefinedInfo',\n })}\n onChange={(e: any) => {\n validateInputMap(e.target.value)\n }}\n value={state.textInput}\n />\n <div className=\"mb5\">\n <Table\n fullWidth\n schema={defaultSchema}\n items={state.validatedResult}\n density=\"high\"\n />\n </div>\n </div>\n <Button\n variation=\"primary\"\n onClick={() => {\n props.handleSaveSettings(props.showToast)\n }}\n isLoading={props.settingsLoading}\n >\n <FormattedMessage id=\"admin/cybersource.saveSettings.buttonText\" />\n </Button>\n </div>\n )\n}\n\nexport default MerchantDictionary\n\n```" } ]
code_cybersource-ui_563896b8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of cybersource-ui/react/components/ReportsTable.tsx from the cybersource-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useEffect } from 'react'\nimport {\n useDataGridState,\n useDataViewState,\n DataGrid,\n DataView,\n} from '@vtex/admin-ui'\nimport { defineMessages, useIntl } from 'react-intl'\n\nimport type { ReportsTableProps } from '../types'\n\nconst messages = defineMessages({\n conversionTime: {\n defaultMessage: 'Conversion Time',\n id: 'admin/cybersource.settings.reports.conversionTime.label',\n },\n merchantReferenceNumber: {\n defaultMessage: 'Merchant Reference Number',\n id: 'admin/cybersource.settings.reports.merchantReferenceNumber.label',\n },\n newDecision: {\n defaultMessage: 'New Decision',\n id: 'admin/cybersource.settings.reports.newDecision.label',\n },\n originalDecision: {\n defaultMessage: 'Original Decision',\n id: 'admin/cybersource.settings.reports.originalDecision.label',\n },\n reviewer: {\n defaultMessage: 'Reviewer',\n id: 'admin/cybersource.settings.reports.reviewer.label',\n },\n reviewerComments: {\n defaultMessage: 'Reviewer Comments',\n id: 'admin/cybersource.settings.reports.reviewerComments.label',\n },\n noReports: {\n defaultMessage: 'There is no reports here!',\n id: 'admin/cybersource.settings.reports.noReports.label',\n },\n})\n\nconst ReportsTable = ({ reports, loading }: ReportsTableProps) => {\n const { formatMessage } = useIntl()\n const view = useDataViewState()\n const state = useDataGridState({\n view,\n length: 6,\n columns: [\n {\n id: 'conversionTime',\n header: () => <strong>{formatMessage(messages.conversionTime)}</strong>,\n },\n {\n id: 'merchantReferenceNumber',\n header: () => (\n <strong>{formatMessage(messages.merchantReferenceNumber)}</strong>\n ),\n },\n {\n id: 'newDecision',\n header: () => <strong>{formatMessage(messages.newDecision)}</strong>,\n },\n {\n id: 'originalDecision',\n header: () => (\n <strong>{formatMessage(messages.originalDecision)}</strong>\n ),\n },\n {\n id: 'reviewer',\n header: () => <strong>{formatMessage(messages.reviewer)}</strong>,\n },\n {\n id: 'reviewerComments',\n header: () => (\n <strong>{formatMessage(messages.reviewerComments)}</strong>\n ),\n },\n ],\n items: reports,\n })\n\n useEffect(() => {\n if (loading) {\n view.setStatus({\n type: 'loading',\n })\n }\n\n if (reports.length === 0 && !loading) {\n view.setStatus({\n type: 'empty',\n message: formatMessage(messages.noReports),\n })\n }\n\n if (reports.length > 0 && !loading) {\n view.setStatus({\n type: 'ready',\n })\n }\n }, [loading])\n\n return (\n <DataView state={view}>\n <DataGrid state={state} />\n </DataView>\n )\n}\n\nexport default ReportsTable\n\n```" } ]
code_b2b-orders-history_63bd87d3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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/messages/sl.json from the b2b-orders-history VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"a11y.orderHeader.shippingModal\": \"Odpri pojavni naslov\",\n \"commons.hello\": \"Živijo\",\n \"commons.continue\": \"Nadaljuj\",\n \"commons.free\": \"Brezplačno\",\n \"commons.other\": \"Drug\",\n \"commons.reasonOtherExplanation\": \"Povejte nam zakaj preklicujete to naročilo\",\n \"commons.save\": \"Shrani\",\n \"commons.close\": \"Zapri\",\n \"commons.no\": \"Ne\",\n \"commons.yes\": \"Da\",\n \"commons.reload\": \"Ponovno nalaganje\",\n \"commons.cancel\": \"Prekliči\",\n \"myo.commons.back\": \"Nazaj\",\n \"goBackToMyOrders\": \"pojdi nazaj na Moja naročila\",\n \"order\": \"Naročilo\",\n \"seeOrder\": \"Oglej si naročilo\",\n \"greeting.replaced\": \"Vaše #{value} naročilo je bilo uspešno zamenjano!\",\n \"greeting.cancelled\": \"Naročilo #{value} je bilo oddano za preklic in bo končano kmalu!\",\n \"greeting.edit\": \"Vaša naročnina je bila uspešno posodobljena!\",\n \"pages.editOrder.greeting\": \"Dobrodošli v samopostrežbo. Vaše naročilo se pripravlja za dostavo. Kaj lahko storimo za vas?\",\n \"pages.editOrder.changeUnavailable\": \"To naročilo ni na voljo za spremembe izdelka.\",\n \"pages.cancelOrder.greeting\": \"Dobrodošli v samopostrežbo. Zakaj želite preklicati vaše naročilo?\",\n \"orders.toggle.ordersThatArentFinished\": \"Naročila v teku\",\n \"orders.toggle.ordersThatAreFinished\": \"Zaključena naročila\",\n \"orders.notFound\": \"Nič še niste naročili!\",\n \"orders.finishedNotFound\": \"Nimate zaključenih naročil\",\n \"orders.ongoingNotFound\": \"Nimate naročil v teku\",\n \"order.dateIs\": \"Datum naročila\",\n \"order.shipsTo\": \"Odpošiljanje\",\n \"order.total\": \"Skupaj\",\n \"order.moreOptions\": \"Več možnosti\",\n \"orders.title\": \"Naročila\",\n \"orders.edit\": \"Uredi naročila #{orderNumber}\",\n \"order.history\": \"Spremeni zgodovino\",\n \"order.change.date\": \"{date} ob {hour}\",\n \"order.change.quantity\": \"Količina: {quantity}\",\n \"order.change.originalOrder\": \"Izvorno naročilo\",\n \"order.change.currentOrder\": \"Trenutno naročilo\",\n \"order.viewAllItems\": \"Poglej vse predmete\",\n \"order.printBankInvoice\": \"Tiskaj bančni izpisek\",\n \"order.cancelOrder\": \"Zahtevaj preklic\",\n \"order.changeOrder\": \"Spremeni naročilo\",\n \"order.orderAgain\": \"Naroči ponovno\",\n \"order.goToOrderDetails\": \"Poglej podrobnosti naročila\",\n \"order.confirmCancellation\": \"Potrdi preklic\",\n \"order.estimatedDeliveryTo\": \"Predvidena dobava v\",\n \"order.navigationArrowTitle\": \"Puščica za vrnitev\",\n \"order.seeInvoice\": \"Oglej si račun\",\n \"order.trackingData.clickHereToGoToExternalPage\": \"Poglej informacije o sledenju na spletni strani ponudnika\",\n \"order.trackingData.shipping\": \"Sledenje #{trackingNumber}\",\n \"order.stepsFlow.placed\": \"Naročilo oddano\",\n \"order.stepsFlow.approved\": \"Naročilo potrjeno\",\n \"order.stepsFlow.sent\": \"Naročilo odposlano\",\n \"order.stepsFlow.shipping\": \"Odpošiljanje naročila\",\n \"order.stepsFlow.finished\": \"Naročilo zaključeno\",\n \"order.stepsFlow.cancelled\": \"Naročilo preklicano\",\n \"order.state.unknown\": \"Obdelujem\",\n \"order.state.waiting-for-seller-confirmation\": \"Obdelujem\",\n \"order.state.order-created\": \"Obdelujem\",\n \"order.state.order-completed\": \"Obdelujem\",\n \"order.state.on-order-completed\": \"Obdelujem\",\n \"order.state.payment-pending\": \"Obdelujem plačilo\",\n \"order.state.window-to-cancel\": \"Obravnavanje odpošiljanja\",\n \"order.state.approve-payment\": \"Obravnavanje odpošiljanja\",\n \"order.state.payment-approved\": \"Plačilo odobreno\",\n \"order.state.request-cancel\": \"Zahteva za preklic\",\n \"order.state.cancel\": \"Obdelujem preklic\",\n \"order.state.canceled\": \"Preklicano\",\n \"order.state.waiting-for-seller-decision\": \"Preklic zahtevan\",\n \"order.state.invoice\": \"Odpošiljanje\",\n \"order.state.invoiced\": \"Odposlano\",\n \"order.state.replaced\": \"Zamenjano\",\n \"order.state.cancellation-requested\": \"Preklic zahtevan\",\n \"order.state.ready-for-handling\": \"Obravnavanje odpošiljanja\",\n \"order.state.handling\": \"Obravnavanje odpošiljanja\",\n \"order.state.authorize-fullfilment\": \"Obdelujem plačilo\",\n \"order.state.release-to-fulfillment\": \"Obravnavanje odpošiljanja\",\n \"order.state.delivered\": \"Dobavljeno\",\n \"order.state.ready-for-pickup\": \"Pripravljeno za prevzem\",\n \"order.state.pickedUp\": \"Prevzeto\",\n \"order.state.handlingPickup\": \"Obravnavanje naročila\",\n \"order.progress.pickup\": \"Prevzemi\",\n \"order.progress.confirmOrder\": \"Oddaj naročilo\",\n \"order.progress.confirmingOrder\": \"Oddajanje naročila\",\n \"order.progress.orderConfirmed\": \"Naročilo oddano\",\n \"order.progress.approvePayment\": \"Odobri plačilo\",\n \"order.progress.approvingPayment\": \"Odobravanje plačila\",\n \"order.progress.paymentApproved\": \"Plačilo odobreno\",\n \"order.progress.handleShipping\": \"Obravnaj naročilo\",\n \"order.progress.handlingShipping\": \"Obravnavanje naročila\",\n \"order.progress.shippingHandled\": \"Paket obravnan\",\n \"order.progress.deliverToCarrier\": \"Dobava ponudniku\",\n \"order.progress.delivering\": \"Dobavavljanje naročila\",\n \"order.progress.delivered\": \"Naročilo dobavljeno\",\n \"order.progress.deliverToPickup\": \"Odpošlji na točko prevzema\",\n \"order.progress.deliveringToPickup\": \"Pošiljanje na točko prevzema\",\n \"order.progress.deliveredToPickup\": \"Poslano na točko prevzema\",\n \"order.progress.ship\": \"Odpošlji naročilo\",\n \"order.progress.shipping\": \"Odpošiljanje naročila\",\n \"order.progress.shipped\": \"Naročilo odposlano\",\n \"package.progress.handleShipping\": \"Obravnavaj paket\",\n \"package.progress.handlingShipping\": \"Obravnavanje paketa\",\n \"package.progress.shippingHandled\": \"Paket obravnan\",\n \"package.progress.deliverToCarrier\": \"Dobavi naročilo\",\n \"package.progress.delivering\": \"Na poti k prevozniku\",\n \"package.progress.delivered\": \"Naročilo dobavljeno\",\n \"package.progress.ship\": \"Odpošlji paket\",\n \"package.progress.shipping\": \"Odpošiljanje paketa\",\n \"package.progress.shipped\": \"Paket odposlan\",\n \"order.summary.title\": \"Povzetek\",\n \"order.summary.total\": \"Skupaj\",\n \"order.shippingInfo\": \"Naslov\",\n \"order.paymentInfo\": \"Podatki o plačilu\",\n \"order.package.heading\": \"Paket\",\n \"order.package.numbering\": \"od\",\n \"order.package.day\": \"dan\",\n \"order.package.product\": \"Izdelek\",\n \"order.package.price\": \"Cena\",\n \"order.package.quantity\": \"Količina\",\n \"order.package.total\": \"Skupaj\",\n \"order.shippingEstimate.bd\": \"{timeAmount, plural, =0 {Isti dan} one {Pripravljeno v # delovnem dnevu} two {Pripravljeno v # delovnih dneh} few {Pripravljeno v # delovnih dneh} other {Pripravljeno v # delovnih dneh}}\",\n \"order.shippingEstimate.d\": \"{timeAmount, plural, =0 {Isti dan} one {Dobavljeno v # dnevu} two {Dobavljeno v # delovnih dneh} few {Dobavljeno v # delovnih dneh} other {Dobavljeno v # delovnih dneh}}\",\n \"order.shippingEstimate.h\": \"{timeAmount, plural, =0 {Zdaj} one {Dobavljeno v # uri} two {Dobavljeno v # urah} few {Dobavljeno v # urah} other {Dobavljeno v # urah}}\",\n \"order.shippingEstimate.m\": \"{timeAmount, plural, =0 {Zdaj} one {Dobavljeno v # minuti} two {Dobavljeno v # minutah} few {Dobavljeno v # minutah} other {Dobavljeno v # minutah}}\",\n \"order.shippingEstimate.withTime\": \"Dobava do {date} ob {hour}\",\n \"order.shippingEstimate.noTime\": \"Dobava do {date}\",\n \"order.shippingEstimate.window\": \"Dobava {date}, med {startHour} in {endHour}\",\n \"order.shippingEstimate.pickup.withTime\": \"Prevzem mogoč do {date} ob {hour}\",\n \"order.shippingEstimate.pickup.noTime\": \"Prevzem mogoč do {date}\",\n \"order.shippingEstimate.pickup.window\": \"Prevzem mogoč do {date}, med {startHour} in {endHour}\",\n \"order.tracking.date\": \"Datum\",\n \"order.tracking.time\": \"Čas\",\n \"order.tracking.status\": \"Stanje\",\n \"order.tracking.showMore\": \"Pokaži več\",\n \"paymentData.additionalInfo\": \"Dodatne informacije\",\n \"paymentData.paymentGroup.MercadoPago.name\": \"MercadoPago\",\n \"paymentData.paymentGroup.payPal.name\": \"PayPal\",\n \"paymentData.paymentGroup.stelo.name\": \"Stelo\",\n \"paymentData.paymentGroup.safetypay.name\": \"Spletna bremenitev\",\n \"paymentData.paymentGroup.Bcash.name\": \"Bcash\",\n \"paymentData.paymentGroup.giftCard.name\": \"Darilna kartica\",\n \"paymentData.paymentGroup.debit.name\": \"Spletna bremenitev\",\n \"paymentData.paymentGroup.debitCard.name\": \"Debetna kartica\",\n \"paymentData.paymentGroup.creditDirectSale.name\": \"Plačilo s PIN številčnico\",\n \"paymentData.paymentGroup.creditCard.name\": \"Kreditna kartica\",\n \"paymentData.paymentGroup.creditCard.endingIn\": \"poteče na\",\n \"paymentData.paymentGroup.bankInvoice.name\": \"Račun\",\n \"paymentData.paymentGroup.evolucard.name\": \"Evolucard\",\n \"paymentData.paymentGroup.promissory.name\": \"Zadolžnica\",\n \"paymentData.paymentGroup.alignet.name\": \"Alignet\",\n \"paymentData.paymentGroup.pagSeguro.name\": \"PagSeguro\",\n \"paymentData.paymentGroup.pagosWeb.name\": \"Načini plačila\",\n \"paymentData.paymentGroup.peela.name\": \"Peela\",\n \"paymentData.paymentGroup.koin.name\": \"Koin Pós-Pago\",\n \"paymentData.giftCard.loyalty-program.name\": \"Program zvestobe\",\n \"reasons.shipping\": \"Sprememba podatkov odpošiljanja\",\n \"reasons.payment\": \"Sprememba podatkov plačila\",\n \"reasons.profile\": \"Sprememba osebnih podatkov\",\n \"reasons.unknown\": \"Razlogi niso določeni\",\n \"global.unknownError\": \"Pojavila se je nepričakovana napaka, poskušamo jo rešiti. Poskusite znova kasneje\",\n \"global.errorServer\": \"Pojavila se je napaka v naših serverjih. Poskusite znova kasneje.\",\n \"global.loginNeeded\": \"Morate se prijaviti.\",\n \"global.unauthorized\": \"Niste pooblaščeni za dostop do tega.\",\n \"global.notFound\": \"Ni bilo najdeno\",\n \"order.subscription\": \"Naročnina\",\n \"order.subscription.key.frequency\": \"Frekvenca\",\n \"product.quantity\": \"{qtd, plural, one {# e} two {# e} few {# e} other {# e}}\"\n}\n\n```" } ]
code_b2b-orders-history_244194f1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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/messages/nl.json from the b2b-orders-history VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"a11y.orderHeader.shippingModal\": \"Open adrespopup\",\n \"commons.hello\": \"Hallo\",\n \"commons.continue\": \"Doorgaan\",\n \"commons.free\": \"Gratis\",\n \"commons.other\": \"Overige\",\n \"commons.reasonOtherExplanation\": \"Vertel ons waarom u deze bestelling annuleert\",\n \"commons.save\": \"Opslaan\",\n \"commons.close\": \"Sluiten\",\n \"commons.no\": \"Nee\",\n \"commons.yes\": \"Ja\",\n \"commons.reload\": \"Herladen\",\n \"commons.cancel\": \"Annuleer\",\n \"myo.commons.back\": \"Terug\",\n \"goBackToMyOrders\": \"Ga terug naar Mijn bestellingen\",\n \"order\": \"Bestelling\",\n \"seeOrder\": \"Bekijk bestelling\",\n \"greeting.replaced\": \"Uw bestelling #{value} is succesvol vervangen!\",\n \"greeting.cancelled\": \"De bestelling #{value} is ingediend voor annulering en zal binnenkort worden afgerond!\",\n \"greeting.edit\": \"Uw abonnement is succesvol bijgewerkt!\",\n \"pages.editOrder.greeting\": \"Welkom bij zelfbediening. Uw bestelling is klaar voor levering. Wat kunnen we voor u doen?\",\n \"pages.editOrder.changeUnavailable\": \"Deze bestelling is niet beschikbaar voor productwijzigingen.\",\n \"pages.cancelOrder.greeting\": \"Welkom bij zelfbediening. Waarom wilt u uw bestelling annuleren?\",\n \"orders.toggle.ordersThatArentFinished\": \"Lopende bestellingen\",\n \"orders.toggle.ordersThatAreFinished\": \"Voltooide bestellingen\",\n \"orders.notFound\": \"Je hebt nog niets besteld!\",\n \"orders.finishedNotFound\": \"Je hebt geen voltooide bestellingen\",\n \"orders.ongoingNotFound\": \"Je hebt geen lopende bestellingen\",\n \"order.dateIs\": \"Besteldatum\",\n \"order.shipsTo\": \"Verzending\",\n \"order.total\": \"Totaal\",\n \"order.moreOptions\": \"Meer opties\",\n \"orders.title\": \"Bestellingen\",\n \"orders.edit\": \"Bestelling aanpassen #{orderNumber}\",\n \"order.history\": \"Geschiedenis aanpassen\",\n \"order.change.date\": \"{date} om {hour}\",\n \"order.change.quantity\": \"Hoeveelheid: {quantity}\",\n \"order.change.originalOrder\": \"Originele bestelling\",\n \"order.change.currentOrder\": \"Huidige bestelling\",\n \"order.viewAllItems\": \"Bekijk alle items\",\n \"order.printBankInvoice\": \"Druk de bankfactuur af\",\n \"order.cancelOrder\": \"Verzoek tot annulering\",\n \"order.changeOrder\": \"Bestelling aanpassen\",\n \"order.orderAgain\": \"Opnieuw bestellen\",\n \"order.goToOrderDetails\": \"Bekijk de bestelgegevens\",\n \"order.confirmCancellation\": \"Annulering bevestigen\",\n \"order.estimatedDeliveryTo\": \"Geschatte levering aan\",\n \"order.navigationArrowTitle\": \"Terugkeerpijl\",\n \"order.seeInvoice\": \"Bekijk factuur\",\n \"order.trackingData.clickHereToGoToExternalPage\": \"Zie de trackinginformatie op de website van de vervoerder\",\n \"order.trackingData.shipping\": \"Tracking #{trackingNumber}\",\n \"order.stepsFlow.placed\": \"Bestelling geplaatst\",\n \"order.stepsFlow.approved\": \"Bestelling goedgekeurd\",\n \"order.stepsFlow.sent\": \"Bestelling verzonden\",\n \"order.stepsFlow.shipping\": \"Bestelling verzenden\",\n \"order.stepsFlow.finished\": \"Bestelling voltooid\",\n \"order.stepsFlow.cancelled\": \"Bestelling geannuleerd\",\n \"order.state.unknown\": \"Verwerken\",\n \"order.state.waiting-for-seller-confirmation\": \"Verwerken\",\n \"order.state.order-created\": \"Verwerken\",\n \"order.state.order-completed\": \"Verwerken\",\n \"order.state.on-order-completed\": \"Verwerken\",\n \"order.state.payment-pending\": \"Betaling verwerken\",\n \"order.state.window-to-cancel\": \"Afhandeling van verzending\",\n \"order.state.approve-payment\": \"Afhandeling van verzending\",\n \"order.state.payment-approved\": \"Betaling goedgekeurd\",\n \"order.state.request-cancel\": \"Annulering aangevraagd\",\n \"order.state.cancel\": \"Verwerking annulering\",\n \"order.state.canceled\": \"Geannuleerd\",\n \"order.state.waiting-for-seller-decision\": \"Annulering aangevraagd\",\n \"order.state.invoice\": \"Verzending\",\n \"order.state.invoiced\": \"Verzonden\",\n \"order.state.replaced\": \"Vervangen\",\n \"order.state.cancellation-requested\": \"Annulering aangevraagd\",\n \"order.state.ready-for-handling\": \"Behandeling van de verzending\",\n \"order.state.handling\": \"Behandeling van de verzending\",\n \"order.state.authorize-fullfilment\": \"Verwerking van betaling\",\n \"order.state.release-to-fulfillment\": \"Behandeling van de verzending\",\n \"order.state.delivered\": \"Afgeleverd\",\n \"order.state.ready-for-pickup\": \"Klaar om af te halen\",\n \"order.state.pickedUp\": \"Afgehaald\",\n \"order.state.handlingPickup\": \"Behandelen bestelling\",\n \"order.progress.pickup\": \"Afhalen\",\n \"order.progress.confirmOrder\": \"Bestelling plaatsen\",\n \"order.progress.confirmingOrder\": \"Plaatsing van de bestelling\",\n \"order.progress.orderConfirmed\": \"Bestelling geplaatst\",\n \"order.progress.approvePayment\": \"Betaling goedkeuren\",\n \"order.progress.approvingPayment\": \"Goedkeuring van de betaling\",\n \"order.progress.paymentApproved\": \"Betaling goedgekeurd\",\n \"order.progress.handleShipping\": \"Behandel bestelling\",\n \"order.progress.handlingShipping\": \"Behandelen bestelling\",\n \"order.progress.shippingHandled\": \"Bestelling behandeld\",\n \"order.progress.deliverToCarrier\": \"Lever aan vervoerder\",\n \"order.progress.delivering\": \"Levering bestelling\",\n \"order.progress.delivered\": \"Bestelling geleverd\",\n \"order.progress.deliverToPickup\": \"Verzenden naar afhaalpunt\",\n \"order.progress.deliveringToPickup\": \"Verzenden naar afhaalpunt\",\n \"order.progress.deliveredToPickup\": \"Verzonden naar afhaalpunt\",\n \"order.progress.ship\": \"Verzend bestelling\",\n \"order.progress.shipping\": \"Verzending bestelling\",\n \"order.progress.shipped\": \"Bestelling verzonden\",\n \"package.progress.handleShipping\": \"Behandel pakket\",\n \"package.progress.handlingShipping\": \"Behandeling pakket\",\n \"package.progress.shippingHandled\": \"Pakket behandelt\",\n \"package.progress.deliverToCarrier\": \"Lever bestelling\",\n \"package.progress.delivering\": \"Onderweg naar vervoerder\",\n \"package.progress.delivered\": \"Bestelling geleverd\",\n \"package.progress.ship\": \"Verzend pakket\",\n \"package.progress.shipping\": \"Verzending pakket\",\n \"package.progress.shipped\": \"Pakket verzonden\",\n \"order.summary.title\": \"Overzicht\",\n \"order.summary.total\": \"Totaal\",\n \"order.shippingInfo\": \"Adres\",\n \"order.paymentInfo\": \"Betalingsinfo\",\n \"order.package.heading\": \"Pakket\",\n \"order.package.numbering\": \"van\",\n \"order.package.day\": \"dag\",\n \"order.package.product\": \"Product\",\n \"order.package.price\": \"Prijs\",\n \"order.package.quantity\": \"Aantal\",\n \"order.package.total\": \"Subtotaal\",\n \"order.shippingEstimate.bd\": \"{timeAmount, plural, =0 {Op dezelfde dag} one {Levering binnen # werkdag} other {Levering binnen # werkdagen}}\",\n \"order.shippingEstimate.d\": \"{timeAmount, plural, =0 {Op dezelfde dag} one {Levering binnen # dag} other {Levering binnen # dagen}}\",\n \"order.shippingEstimate.h\": \"{timeAmount, plural, =0 {Nu} one {Levering binnen # uur} other {Levering binnen # uren}}\",\n \"order.shippingEstimate.m\": \"{timeAmount, plural, =0 {Nu} one {Levering binnen # minuut} other {Levering binnen # minuten}}\",\n \"order.shippingEstimate.withTime\": \"Levering op {date} om {hour}\",\n \"order.shippingEstimate.noTime\": \"Levering op {date}\",\n \"order.shippingEstimate.window\": \"Levering {date}, tussen {startHour} en {endHour}\",\n \"order.shippingEstimate.pickup.withTime\": \"Afhalen gereed voor {date} om {hour}\",\n \"order.shippingEstimate.pickup.noTime\": \"Afhalen gereed voor {date}\",\n \"order.shippingEstimate.pickup.window\": \"Afhalen gereed voor {date}, tussen {startHour} en {endHour}\",\n \"order.tracking.date\": \"Datum\",\n \"order.tracking.time\": \"Tijd\",\n \"order.tracking.status\": \"Status\",\n \"order.tracking.showMore\": \"Toon meer\",\n \"paymentData.additionalInfo\": \"Extra informatie\",\n \"paymentData.paymentGroup.MercadoPago.name\": \"MercadoPago\",\n \"paymentData.paymentGroup.payPal.name\": \"PayPal\",\n \"paymentData.paymentGroup.stelo.name\": \"Stelo\",\n \"paymentData.paymentGroup.safetypay.name\": \"Online Debit\",\n \"paymentData.paymentGroup.Bcash.name\": \"Bcash\",\n \"paymentData.paymentGroup.giftCard.name\": \"Geschenkkaart\",\n \"paymentData.paymentGroup.debit.name\": \"Online Debit\",\n \"paymentData.paymentGroup.debitCard.name\": \"Debetkaart\",\n \"paymentData.paymentGroup.creditDirectSale.name\": \"PIN Pad-betaling\",\n \"paymentData.paymentGroup.creditCard.name\": \"Kredietkaart\",\n \"paymentData.paymentGroup.creditCard.endingIn\": \"eindigend op\",\n \"paymentData.paymentGroup.bankInvoice.name\": \"Factuur\",\n \"paymentData.paymentGroup.evolucard.name\": \"Evolucard\",\n \"paymentData.paymentGroup.promissory.name\": \"Schuldbekentenis\",\n \"paymentData.paymentGroup.alignet.name\": \"Alignet\",\n \"paymentData.paymentGroup.pagSeguro.name\": \"PagSeguro\",\n \"paymentData.paymentGroup.pagosWeb.name\": \"Betaalmethoden\",\n \"paymentData.paymentGroup.peela.name\": \"Peela\",\n \"paymentData.paymentGroup.koin.name\": \"Koin Pós-Pago\",\n \"paymentData.giftCard.loyalty-program.name\": \"Loyaliteitsprogramma\",\n \"reasons.shipping\": \"Wijziging van de verzendgegevens\",\n \"reasons.payment\": \"Wijziging van de verzendgegevens\",\n \"reasons.profile\": \"Wijziging van persoonsgegevens\",\n \"reasons.unknown\": \"Reden niet gespecificeerd\",\n \"global.unknownError\": \"Er is een onverwachte fout opgetreden, we proberen deze op te lossen. Probeer het later opnieuw\",\n \"global.errorServer\": \"Er was een fout in onze servers. Probeer het later nog eens.\",\n \"global.loginNeeded\": \"U moet inloggen.\",\n \"global.unauthorized\": \"U bent niet bevoegd om hier toegang toe te krijgen.\",\n \"global.notFound\": \"Niet gevonden\",\n \"order.subscription\": \"Abonnement\",\n \"order.subscription.key.frequency\": \"Frequentie\",\n \"product.quantity\": \"{qtd, plural, one {# eenheid} other {# eenheden}}\"\n}\n\n```" } ]