id
stringlengths
12
53
messages
listlengths
3
3
code_checkout-shipping_3d0afa72
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/messages/ro.json from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/checkout.shipping.informAddress\": \"Te rugăm să ne spui adresa ta\",\n \"store/checkout.shipping.chooseAddress\": \"Alege o adresă\",\n \"store/checkout.shipping.selectedDeliveryOptionsLabel\": \"Ai selectat\",\n \"store/checkout.shipping.newAddressLabel\": \"O adresă nouă…\",\n \"store/checkout.shipping.shippingOptionLabel\": \"Opțiune expediere\",\n \"store/checkout.shipping.completeAddressLabel\": \"Completează adresa de livrare\",\n \"store/checkout.shipping.receiverNameLabel\": \"Nume și prenume\",\n \"store/checkout.shipping.receiverLabel\": \"Destinatar\",\n \"store/checkout.shipping.shippingOptionsForAddressLabel\": \"Opțiuni de expediere pentru\",\n \"store/checkout.shipping.emptyDeliveryOptionsAlert\": \"Nu sunt disponibile opțiuni de livrare pentru locația ta.\",\n \"store/checkout.shipping.changeAddressLabel\": \"modifică\",\n \"store/checkout.shipping.changeReceiverLabel\": \"modifică\",\n \"store/checkout.shipping.seeDetails\": \"Vezi detalii\",\n \"store/checkout.shipping.distance\": \"la {distanceValue}km\",\n \"store/checkout.shipping.pickupPointsModal.details\": \"Detalii\",\n \"store/checkout.shipping.pickupPointsModal.weekDay0\": \"Duminică\",\n \"store/checkout.shipping.pickupPointsModal.weekDay1\": \"Luni\",\n \"store/checkout.shipping.pickupPointsModal.weekDay2\": \"Marţi\",\n \"store/checkout.shipping.pickupPointsModal.weekDay3\": \"Miercuri\",\n \"store/checkout.shipping.pickupPointsModal.weekDay4\": \"Joi\",\n \"store/checkout.shipping.pickupPointsModal.weekDay5\": \"Vineri\",\n \"store/checkout.shipping.pickupPointsModal.weekDay6\": \"Sâmbătă\",\n \"store/checkout.shipping.pickupPointsModal.weekDay1to5\": \"De luni până vineri\",\n \"store/checkout.shipping.pickupPointsModal.closed\": \"Închis\",\n \"store/checkout.shipping.pickupPointsModal.hourFromTo\": \"{openingTime}h - {closingTime}h\",\n \"store/checkout.shipping.pickupPointsModal.businessHours\": \"Program de lucru\",\n \"store/checkout.shipping.pickupPointsModal.allItemsAvailable\": \"Toate articolele sunt disponibile.\",\n \"store/checkout.shipping.pickupPointsModal.availableItems\": \"Articole disponibile\",\n \"store/checkout.shipping.pickupPointsModal.address\": \"Adresa\",\n \"store/checkout.shipping.goToPayment\": \"Mergi la plată\",\n \"store/checkout.shipping.goToAddress\": \"Mergi la adresă\",\n \"store/checkout.shipping.tryAgainButton\": \"Încearcă din nou\",\n \"store/checkout.shipping.unknownErrorMessage\": \"A apărut o eroare la încercarea de a-ți transmite cererea.\",\n \"store/checkout.shipping.backToAddressList\": \"Sau<a>întoarce-te la lista de adrese</a>.\"\n}\n\n```" } ]
code_checkout-shipping_59a99118
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/messages/ko.json from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/checkout.shipping.informAddress\": \"귀하의 주소를 알려주세요.\",\n \"store/checkout.shipping.chooseAddress\": \"주소 선택\",\n \"store/checkout.shipping.selectedDeliveryOptionsLabel\": \"선택하셨습니다\",\n \"store/checkout.shipping.newAddressLabel\": \"새 주소\",\n \"store/checkout.shipping.shippingOptionLabel\": \"배송 옵션\",\n \"store/checkout.shipping.completeAddressLabel\": \"배송 주소 작성\",\n \"store/checkout.shipping.receiverNameLabel\": \"이름과 성\",\n \"store/checkout.shipping.receiverLabel\": \"받는 사람\",\n \"store/checkout.shipping.shippingOptionsForAddressLabel\": \"배송 옵션\",\n \"store/checkout.shipping.emptyDeliveryOptionsAlert\": \"귀하의 위치에 사용할 수 있는 배송 옵션이 없습니다.\",\n \"store/checkout.shipping.changeAddressLabel\": \"변경\",\n \"store/checkout.shipping.changeReceiverLabel\": \"변경\",\n \"store/checkout.shipping.seeDetails\": \"상세 보기\",\n \"store/checkout.shipping.distance\": \"{distanceValue}km 거리\",\n \"store/checkout.shipping.pickupPointsModal.details\": \"세부 사항\",\n \"store/checkout.shipping.pickupPointsModal.weekDay0\": \"일요일\",\n \"store/checkout.shipping.pickupPointsModal.weekDay1\": \"월요일\",\n \"store/checkout.shipping.pickupPointsModal.weekDay2\": \"화요일\",\n \"store/checkout.shipping.pickupPointsModal.weekDay3\": \"수요일\",\n \"store/checkout.shipping.pickupPointsModal.weekDay4\": \"목요일\",\n \"store/checkout.shipping.pickupPointsModal.weekDay5\": \"금요일\",\n \"store/checkout.shipping.pickupPointsModal.weekDay6\": \"토요일\",\n \"store/checkout.shipping.pickupPointsModal.weekDay1to5\": \"월요일에서 금요일\",\n \"store/checkout.shipping.pickupPointsModal.closed\": \"닫힘\",\n \"store/checkout.shipping.pickupPointsModal.hourFromTo\": \"{openingTime}시간 - {closingTime}시간\",\n \"store/checkout.shipping.pickupPointsModal.businessHours\": \"영업시간\",\n \"store/checkout.shipping.pickupPointsModal.allItemsAvailable\": \"모든 항목을 사용할 수 있습니다.\",\n \"store/checkout.shipping.pickupPointsModal.availableItems\": \"사용 가능한 항목\",\n \"store/checkout.shipping.pickupPointsModal.address\": \"주소\",\n \"store/checkout.shipping.goToPayment\": \"결제로 이동\",\n \"store/checkout.shipping.goToAddress\": \"주소로 이동\",\n \"store/checkout.shipping.tryAgainButton\": \"다시 시도\",\n \"store/checkout.shipping.unknownErrorMessage\": \"요청을 하는 동안 오류가 발생했습니다.\",\n \"store/checkout.shipping.backToAddressList\": \"또는 <a>주소 목록으로 돌아가세요</a>.\"\n}\n\n```" } ]
code_checkout-shipping_618b5840
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/messages/no.json from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/checkout.shipping.informAddress\": \"Informer om adressen din\",\n \"store/checkout.shipping.chooseAddress\": \"Velg en adresse\",\n \"store/checkout.shipping.selectedDeliveryOptionsLabel\": \"Du valgte\",\n \"store/checkout.shipping.newAddressLabel\": \"Ny adresse…\",\n \"store/checkout.shipping.shippingOptionLabel\": \"Fraktalternativ\",\n \"store/checkout.shipping.completeAddressLabel\": \"Fullfør leveringsadressen\",\n \"store/checkout.shipping.receiverNameLabel\": \"Fornavn og etternavn\",\n \"store/checkout.shipping.receiverLabel\": \"Mottaker\",\n \"store/checkout.shipping.shippingOptionsForAddressLabel\": \"Fraktalternativer for\",\n \"store/checkout.shipping.emptyDeliveryOptionsAlert\": \"Ingen leveringsalternativer er tilgjengelige for din posisjon.\",\n \"store/checkout.shipping.changeAddressLabel\": \"endre\",\n \"store/checkout.shipping.changeReceiverLabel\": \"endre\",\n \"store/checkout.shipping.seeDetails\": \"Vis detaljer\",\n \"store/checkout.shipping.distance\": \"{distanceValue} km unna\",\n \"store/checkout.shipping.pickupPointsModal.details\": \"Detaljer\",\n \"store/checkout.shipping.pickupPointsModal.weekDay0\": \"Søndag\",\n \"store/checkout.shipping.pickupPointsModal.weekDay1\": \"Mandag\",\n \"store/checkout.shipping.pickupPointsModal.weekDay2\": \"Tirsdag\",\n \"store/checkout.shipping.pickupPointsModal.weekDay3\": \"Onsdag\",\n \"store/checkout.shipping.pickupPointsModal.weekDay4\": \"Torsdag\",\n \"store/checkout.shipping.pickupPointsModal.weekDay5\": \"Fredag\",\n \"store/checkout.shipping.pickupPointsModal.weekDay6\": \"Lørdag\",\n \"store/checkout.shipping.pickupPointsModal.weekDay1to5\": \"Mandag til fredag\",\n \"store/checkout.shipping.pickupPointsModal.closed\": \"Stengt\",\n \"store/checkout.shipping.pickupPointsModal.hourFromTo\": \"{openingTime}t - {closingTime}t\",\n \"store/checkout.shipping.pickupPointsModal.businessHours\": \"Arbeidstid\",\n \"store/checkout.shipping.pickupPointsModal.allItemsAvailable\": \"Alle produktene er tilgjengelige.\",\n \"store/checkout.shipping.pickupPointsModal.availableItems\": \"Tilgjengelige varer\",\n \"store/checkout.shipping.pickupPointsModal.address\": \"Adresse\",\n \"store/checkout.shipping.goToPayment\": \"Gå til betaling\",\n \"store/checkout.shipping.goToAddress\": \"Gå til adresse\",\n \"store/checkout.shipping.tryAgainButton\": \"Prøv igjen\",\n \"store/checkout.shipping.unknownErrorMessage\": \"Det oppsto en feil under forsøket på å komme med forespørselen.\",\n \"store/checkout.shipping.backToAddressList\": \"Eller, <a>gå tilbake til adresseliste</a>.\"\n}\n\n```" } ]
code_checkout-shipping_66b8d926
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/messages/ar.json from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/checkout.shipping.informAddress\": \"يرجى إعلامنا بعنوانك\",\n \"store/checkout.shipping.chooseAddress\": \"اختر عنوانًا\",\n \"store/checkout.shipping.selectedDeliveryOptionsLabel\": \"لقد حدّدت\",\n \"store/checkout.shipping.newAddressLabel\": \"عنوان جديد…\",\n \"store/checkout.shipping.shippingOptionLabel\": \"خيار الشحن\",\n \"store/checkout.shipping.completeAddressLabel\": \"أكمِل عنوان التسليم\",\n \"store/checkout.shipping.receiverNameLabel\": \"الإسم والنسب\",\n \"store/checkout.shipping.receiverLabel\": \"المستقبِل\",\n \"store/checkout.shipping.shippingOptionsForAddressLabel\": \"خيارات الشحن لـ\",\n \"store/checkout.shipping.emptyDeliveryOptionsAlert\": \"لا توجد خيارات توصيل متاحة لموقعك.\",\n \"store/checkout.shipping.changeAddressLabel\": \"تغيير\",\n \"store/checkout.shipping.changeReceiverLabel\": \"تغيير\",\n \"store/checkout.shipping.seeDetails\": \"عرض التفاصيل\",\n \"store/checkout.shipping.distance\": \"تبعد ب {distanceValue} كلم\",\n \"store/checkout.shipping.pickupPointsModal.details\": \"التفاصبل\",\n \"store/checkout.shipping.pickupPointsModal.weekDay0\": \"الأحد\",\n \"store/checkout.shipping.pickupPointsModal.weekDay1\": \"الإثنين\",\n \"store/checkout.shipping.pickupPointsModal.weekDay2\": \"الثلاثاء\",\n \"store/checkout.shipping.pickupPointsModal.weekDay3\": \"الأربعاء\",\n \"store/checkout.shipping.pickupPointsModal.weekDay4\": \"الخميس\",\n \"store/checkout.shipping.pickupPointsModal.weekDay5\": \"الجمعة\",\n \"store/checkout.shipping.pickupPointsModal.weekDay6\": \"السبت\",\n \"store/checkout.shipping.pickupPointsModal.weekDay1to5\": \"الإثنين إلى الجمعة\",\n \"store/checkout.shipping.pickupPointsModal.closed\": \"مغلق/ة\",\n \"store/checkout.shipping.pickupPointsModal.hourFromTo\": \"من الساعة {openingTime} إلى الساعة {closingTime}\",\n \"store/checkout.shipping.pickupPointsModal.businessHours\": \"ساعات العمل\",\n \"store/checkout.shipping.pickupPointsModal.allItemsAvailable\": \"جميع العناصر متوفرة.\",\n \"store/checkout.shipping.pickupPointsModal.availableItems\": \"العناصر المتاحة\",\n \"store/checkout.shipping.pickupPointsModal.address\": \"العنوان\",\n \"store/checkout.shipping.goToPayment\": \"انتقِل للدفع\",\n \"store/checkout.shipping.goToAddress\": \"انتقل للعنوان\",\n \"store/checkout.shipping.tryAgainButton\": \"حاول من جديد\",\n \"store/checkout.shipping.unknownErrorMessage\": \"حدث خطأ أثناء محاولة تقديم طلبك.\",\n \"store/checkout.shipping.backToAddressList\": \"أو، <a>انتقِل إلى قائمة العناوين</a>.\"\n}\n\n```" } ]
code_checkout-shipping_0a4ee113
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/docs/README.md from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Checkout Shipping\n\n⚠️ **This is an ongoing, unsupported, unfinished and undocumented project. We do not guarantee any results after installation.** ⚠️\n\nThis app has the `ShippingSummary`, `AddressSummary`, `ShippingAddress` and `ShippingForm` components used in the shipping step of the checkout.\n\n![Shipping summary component](./images/shipping_summary.png)\n![Shipping form component](./images/form_postal_code.png)\n![Address summary component](./images/address_summary.png)\n![Shipping address component](./images/form_fill_address.png)\n\n## Usage\n\nThis app is used by [`checkout-step-group`](https://github.com/vtex-apps/checkout-step-group) and shouldn't be used individually. Should you find the need to use it, you need to:\n\n1. Add it as a dependency: `vtex add vtex.checkout-shipping`\n\n2. Import the components in your code:\n\n```jsx\nimport React from 'react'\nimport {\n ShippingSummary,\n ShippingForm,\n ShippingAddress,\n AddressSummary\n} from 'vtex.checkout-shipping'\n\nconst MyShippingForm = ({ isPreviewMode = false }) => {\n if (isPreviewMode) {\n return (\n <ShippingSummary />\n )\n }\n\n return (\n // no need to pass in any props, as the component\n // uses all information provided by the `order-manager` app.\n <ShippingForm />\n )\n}\n\nconst MyShippingAddress = ({ isPreviewMode = false }) => {\n if (isPreviewMode) {\n return (\n <AddressSummary />\n )\n }\n\n return <ShippingAddress />\n}\n```\n\nNote that you need to have `OrderShippingProvider` from `vtex.order-shipping` app somewhere above these components in your tree.\n\n## State machines\n\n_Last updated in v0.7.0_\n\nThis app uses [XState](https://xstate.js.org/) as its state management library. Having [XState DevTools](https://github.com/amitnovick/xstate-devtools) installed really helps when debugging or developing.\n\nSince the shipping inside checkout is comprised of two separate steps, shipping and address, we created two state machines to control each one of those steps, which we describe below.\n\n### Shipping State Machine Diagram\n\n![Shipping state machine diagram](./images/shipping_state_machine.png)\n\nThe shipping has a multistep UI and its state machine has [states nodes](https://xstate.js.org/docs/guides/statenodes.html) that reflect each step of filling the shipping info.\n\n#### 1. `initial`:\n\nThe initial state is used to determine the next state by combining [eventless transitions](https://xstate.js.org/docs/guides/transitions.html#eventless-always-transitions) (which are, in short, transitions that occur immediately) and [guarded transitions](https://xstate.js.org/docs/guides/guards.html#guarded-transitions) (conditional transitions).\n\nIn the case the user is returning to the store (there are saved addresses already), the machine transitions to `selectAddress`.\n\nAnother case is when the user was already filling the shipping information and had selected the shipping address in a previous interaction, then the machine transitions to `selectDeliveryOption`.\n\n#### 2. `createAddress`:\n\n![Create address form](./images/form_postal_code.png)\n\n#### 3. `selectAddress`:\n\n![Select address form](./images/form_select_address.png)\n\n#### 4. `selectDeliveryOption`:\n\nThis state is comprised of two sub-states, `idle` and `editing`.\n\n##### 4.1. `selectDeliveryOption.editing`:\n\n![Select delivery option form](./images/form_delivery_options.png)\n\n##### 4.2. `selectDeliveryOption.idle`:\n\n![Delivery option selected](./images/form_delivery_confirmation.png)\n\n#### 5. `done`:\n\nThe machine is in its final state and calls `goToNextStep`, which in turn may redirect the user to either address step or payment step, depending on the conditions of the purchase.\n\n### Address State Machine Diagram\n\n![Address state machine diagram](./images/address_state_machine.png)\n\nThe address step has a simpler UI, consisting only of one screen which is solely responsible to update the customer's address.\n\n#### 1. `editAddress`:\n\n![Edit address form](./images/form_fill_address.png)\n\n#### 2. `done`:\n\nThe machine is in its final state and calls `goToNextStep`, which in turn redirects the user to the payment step.\n\n```" } ]
code_checkout-shipping_b7e34690
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/ShippingAddress.tsx from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { AddressContext } from 'vtex.address-context'\nimport { OrderShipping } from 'vtex.order-shipping'\nimport type { Address } from 'vtex.checkout-graphql'\nimport { Loading } from 'vtex.render-runtime'\n\nimport useAddressStateMachine from './machines/useAddressStateMachine'\nimport AddressCompletionForm from './components/AddressCompletionForm'\nimport useAddressRules from './useAddressRules'\n\nconst { useOrderShipping } = OrderShipping\n\nconst ShippingAddress: React.VFC = () => {\n const { matches, send, state } = useAddressStateMachine()\n\n const handleAddressCompleted = (updatedAddress: Address) => {\n send({\n type: 'SUBMIT_EDIT_ADDRESS',\n updatedAddress: {\n ...updatedAddress,\n addressType: updatedAddress.addressType ?? 'residential',\n },\n })\n }\n\n switch (true) {\n case state.matches('editAddress'): {\n return (\n <AddressCompletionForm\n onAddressCompleted={handleAddressCompleted}\n onAddressReset={() => send('RESET_ADDRESS')}\n isSubmitting={matches({ editAddress: 'submitting' })}\n />\n )\n }\n\n default: {\n return null\n }\n }\n}\n\nconst ShippingAddressWithAddress: React.VFC = () => {\n const { selectedAddress, countries } = useOrderShipping()\n\n const addressRules = useAddressRules()\n\n if (addressRules == null) {\n return <Loading />\n }\n\n return (\n <AddressContext.AddressContextProvider\n address={selectedAddress ?? {}}\n countries={countries}\n rules={addressRules}\n >\n <ShippingAddress />\n </AddressContext.AddressContextProvider>\n )\n}\n\nexport default ShippingAddressWithAddress\n\n```" } ]
code_checkout-shipping_3c2a7b6b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/ShippingOptionList.tsx from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useMemo } from 'react'\nimport type { DeliveryOption, PickupOption } from 'vtex.checkout-graphql'\nimport { Alert } from 'vtex.styleguide'\nimport { ListGroup } from 'vtex.checkout-components'\nimport { getFastestSla, getCheapestSla } from '@vtex/estimate-calculator'\nimport { FormattedMessage } from 'react-intl'\n\nimport ShippingOption from './ShippingOption'\nimport { isPickupOption } from './utils/sla'\n\ninterface Props {\n deliveryOptions: DeliveryOption[]\n pickupOptions: PickupOption[]\n onDeliveryOptionSelected?: (id: string) => void\n onDeliveryOptionDeselected?: (id: string) => void\n onPickupOptionSelected?: (id: string) => void\n onPickupOptionDeselected?: (id: string) => void\n showOnlySelectedShippingOption?: boolean\n}\n\nconst ShippingOptionList: React.FC<Props> = ({\n deliveryOptions,\n pickupOptions = [],\n onDeliveryOptionSelected = () => {},\n onDeliveryOptionDeselected = () => {},\n onPickupOptionSelected = () => {},\n onPickupOptionDeselected = () => {},\n showOnlySelectedShippingOption = false,\n}) => {\n const shippingOptions = useMemo(\n () => [...deliveryOptions, ...pickupOptions.slice(0, 1)],\n [deliveryOptions, pickupOptions]\n )\n\n const handleShippingOptionSelect = (\n shippingOption: DeliveryOption | PickupOption\n ) => {\n if (isPickupOption(shippingOption)) {\n onPickupOptionSelected(shippingOption.id)\n } else {\n onDeliveryOptionSelected(shippingOption.id!)\n }\n }\n\n const handleDeliveryOptionDeselect = (deliveryOption: DeliveryOption) => {\n onDeliveryOptionDeselected(deliveryOption.id!)\n }\n\n const handlePickupOptionDeselect = (pickupOption: PickupOption) => {\n onPickupOptionDeselected(pickupOption.id!)\n }\n\n const fastestOption = useMemo(() => {\n return getFastestSla(\n deliveryOptions.map(({ id, estimate, price }) => ({\n id: id!,\n shippingEstimate: estimate!,\n price,\n }))\n )\n }, [deliveryOptions])\n\n const cheapestOption = useMemo(() => {\n return getCheapestSla(\n deliveryOptions.map(({ id, estimate, price }) => ({\n id: id!,\n shippingEstimate: estimate!,\n price,\n }))\n )\n }, [deliveryOptions])\n\n const selectedShippingOptions = useMemo(() => {\n return shippingOptions.filter(({ isSelected }) => isSelected)\n }, [shippingOptions])\n\n return shippingOptions.length > 0 ? (\n showOnlySelectedShippingOption ? (\n <>\n <p className=\"mt0 mb5 fw4 f4 lh-copy\">\n <FormattedMessage id=\"store/checkout.shipping.selectedDeliveryOptionsLabel\" />\n </p>\n\n <ListGroup borderPosition=\"none\">\n {selectedShippingOptions.map((shippingOption) => (\n <ShippingOption\n key={shippingOption.id}\n shippingOption={shippingOption}\n fastestOption={fastestOption}\n cheapestOption={cheapestOption}\n onDeselectShippingOption={() => {\n if (isPickupOption(shippingOption)) {\n handlePickupOptionDeselect(shippingOption)\n } else {\n handleDeliveryOptionDeselect(shippingOption)\n }\n }}\n isSelected\n />\n ))}\n </ListGroup>\n </>\n ) : (\n <ListGroup>\n {shippingOptions.map((shippingOption) => (\n <ShippingOption\n key={shippingOption.id}\n shippingOption={shippingOption}\n fastestOption={fastestOption}\n cheapestOption={cheapestOption}\n onSelectShippingOption={() => {\n handleShippingOptionSelect(shippingOption)\n }}\n />\n ))}\n </ListGroup>\n )\n ) : (\n <Alert type=\"warning\">\n <FormattedMessage id=\"store/checkout.shipping.emptyDeliveryOptionsAlert\" />\n </Alert>\n )\n}\n\nexport default ShippingOptionList\n\n```" } ]
code_checkout-shipping_3771184e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/AddressSummary.tsx from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useEffect } from 'react'\nimport { PlaceDetails } from 'vtex.place-components'\nimport { AddressContext } from 'vtex.address-context'\nimport { OrderShipping } from 'vtex.order-shipping'\nimport { OrderForm } from 'vtex.order-manager'\nimport { Loading } from 'vtex.render-runtime'\n\nimport useAddressRules from './useAddressRules'\n\nconst { useAddressContext } = AddressContext\nconst { useOrderShipping } = OrderShipping\nconst { useOrderForm } = OrderForm\n\nconst AddressSummary: React.VFC = () => {\n const { selectedAddress } = useOrderShipping()\n const { address, setAddress, isValid } = useAddressContext()\n const {\n orderForm: { canEditData },\n } = useOrderForm()\n\n useEffect(() => {\n if (selectedAddress == null) {\n return\n }\n\n setAddress(selectedAddress)\n }, [selectedAddress, setAddress])\n\n const shouldConsiderValidation =\n (address.isDisposable ?? false) || canEditData\n\n if (shouldConsiderValidation && !isValid) {\n return null\n }\n\n return (\n <div className=\"c-muted-1 lh-copy\">\n <PlaceDetails display=\"extended\" />\n </div>\n )\n}\n\nconst AddressSummaryWithAddress: React.VFC = () => {\n const { selectedAddress, countries } = useOrderShipping()\n\n const addressRules = useAddressRules()\n\n if (selectedAddress != null && addressRules == null) {\n return <Loading />\n }\n\n return (\n <AddressContext.AddressContextProvider\n address={selectedAddress!}\n countries={countries}\n rules={addressRules ?? {}}\n >\n <AddressSummary />\n </AddressContext.AddressContextProvider>\n )\n}\n\nexport default AddressSummaryWithAddress\n\n```" } ]
code_checkout-shipping_d1b7da5b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/ShippingOption.tsx from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useState } from 'react'\nimport classnames from 'classnames'\nimport { TranslateEstimate } from 'vtex.shipping-estimate-translator'\nimport { FormattedPrice } from 'vtex.formatted-price'\nimport { GroupOption } from 'vtex.checkout-components'\nimport type { DeliveryOption, PickupOption } from 'vtex.checkout-graphql'\nimport { IconDelete, ButtonPlain, Divider } from 'vtex.styleguide'\nimport { FormattedMessage } from 'react-intl'\n\nimport PickupDetailsModal from './components/PickupDetailsModal'\nimport { getName, isPickupOption, slugify } from './utils/sla'\n\ninterface EstimateDeliveryOption {\n shippingEstimate: string\n price: number\n}\n\nexport const ShippingOptionPreview: React.VFC = () => {\n return (\n <>\n <button\n className=\"w-100 tl pointer db lh-copy bg-base ph5 pv5-ns flex items-center justify-between bn pv4\"\n role=\"option\"\n aria-selected=\"false\"\n disabled\n >\n <div className=\"flex w-100\">\n <div className=\"flex flex-column w-100\">\n <span className=\"br1 mw4 w-100 pt2 pb3 mv2 bg-muted-5\" />\n <span className=\"br1 dib mt4 mw5 w-100 pt2 pb3 mv2 bg-muted-5\" />\n </div>\n <div className=\"mw3 w-100\">\n <span className=\"br1 dib w-100 pt2 pb3 mv2 bg-muted-5\" />\n </div>\n </div>\n </button>\n <div className=\"w-100 pr5 pr0-ns pl5\">\n <Divider />\n </div>\n </>\n )\n}\n\ninterface Props {\n onSelectShippingOption?: () => void\n onDeselectShippingOption?: () => void\n shippingOption: DeliveryOption | PickupOption\n isSelected?: boolean\n fastestOption?: EstimateDeliveryOption\n cheapestOption?: EstimateDeliveryOption\n}\n\nconst ShippingOption: React.VFC<Props> = ({\n onSelectShippingOption,\n onDeselectShippingOption,\n shippingOption,\n fastestOption,\n cheapestOption,\n isSelected = false,\n}) => {\n const [showPickupModal, setShowPickupModal] = useState(false)\n\n const content = (\n <div className=\"flex w-100\" id={slugify(shippingOption.id)}>\n <div className=\"flex flex-column w-100\">\n <span className=\"c-on-base fw5\">{getName(shippingOption)}</span>\n <span\n className={classnames('dib mt2 fw5', {\n 'c-muted-1':\n shippingOption.estimate !== fastestOption?.shippingEstimate,\n 'c-success':\n shippingOption.estimate === fastestOption?.shippingEstimate,\n })}\n >\n <TranslateEstimate shippingEstimate={shippingOption.estimate ?? ''} />\n </span>\n {isPickupOption(shippingOption) && (\n <span className=\"fw4 f6 c-muted-1\">\n <FormattedMessage\n id=\"store/checkout.shipping.distance\"\n values={{\n distanceValue: shippingOption.storeDistance?.toFixed(1),\n }}\n />\n </span>\n )}\n </div>\n <div\n className={classnames('fw4', {\n 'c-success fw5': shippingOption.price === cheapestOption?.price,\n })}\n >\n <FormattedPrice value={(shippingOption.price ?? 0) / 100} />\n </div>\n </div>\n )\n\n return isSelected ? (\n <div className=\"bg-muted-5 pa5 flex-column items-start lh-copy\">\n <div className=\"flex\">\n {content}\n <button\n className=\"flex-shrink-0 c-muted-1 ml5 pa2 flex bg-transparent bn pointer\"\n onClick={onDeselectShippingOption}\n role=\"option\"\n aria-selected\n >\n <IconDelete />\n </button>\n </div>\n\n {isPickupOption(shippingOption) && (\n <div className=\"flex flex-column items-start\">\n <ButtonPlain size=\"small\" onClick={() => setShowPickupModal(true)}>\n <FormattedMessage id=\"store/checkout.shipping.seeDetails\" />\n </ButtonPlain>\n\n <PickupDetailsModal\n pickupOption={shippingOption}\n showPickupModal={showPickupModal}\n setShowPickupModal={setShowPickupModal}\n />\n </div>\n )}\n </div>\n ) : (\n <GroupOption\n onClick={onSelectShippingOption}\n selected={shippingOption.isSelected}\n >\n {content}\n </GroupOption>\n )\n}\n\nexport default ShippingOption\n\n```" } ]
code_checkout-shipping_2790cd36
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/ShippingForm.tsx from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { Address } from 'vtex.checkout-graphql'\nimport React, { useCallback } from 'react'\nimport { OrderForm } from 'vtex.order-manager'\nimport { OrderShipping } from 'vtex.order-shipping'\nimport { AddressContext } from 'vtex.address-context'\nimport { Button } from 'vtex.styleguide'\nimport { FormattedMessage } from 'react-intl'\nimport { Loading } from 'vtex.render-runtime'\n\nimport NewAddressForm from './NewAddressForm'\nimport AddressList from './components/AddressList'\nimport ShippingOptionList from './ShippingOptionList'\nimport useShippingStateMachine from './machines/useShippingStateMachine'\nimport useAddressRules from './useAddressRules'\nimport ShippingHeader from './ShippingHeader'\n\nconst { useOrderForm } = OrderForm\nconst { useOrderShipping } = OrderShipping\n\nconst ShippingForm: React.VFC = () => {\n const {\n orderForm: {\n canEditData,\n shipping: { availableAddresses },\n userProfileId,\n },\n } = useOrderForm()\n\n const { selectedAddress, deliveryOptions, pickupOptions } = useOrderShipping()\n\n const { matches, send, state } = useShippingStateMachine({\n availableAddresses: (availableAddresses as Address[]) ?? [],\n canEditData,\n selectedAddress: selectedAddress ?? null,\n userProfileId,\n retryAddress: null,\n })\n\n const handleAddressCreated = useCallback(\n (address: Address) => {\n send({\n type: 'SUBMIT_CREATE_ADDRESS',\n address: {\n ...address,\n addressType: address.addressType ?? 'residential',\n },\n })\n },\n [send]\n )\n\n const handleDeliveryOptionSelect = (deliveryOptionId: string) => {\n send({\n type: 'SUBMIT_SELECT_SHIPPING_OPTION',\n shippingOptionId: deliveryOptionId,\n deliveryChannel: 'delivery',\n })\n }\n\n const handlePickupOptionSelect = (pickupOptionId: string) => {\n send({\n type: 'SUBMIT_SELECT_SHIPPING_OPTION',\n shippingOptionId: pickupOptionId,\n deliveryChannel: 'pickup-in-point',\n })\n }\n\n switch (true) {\n case matches('selectShippingOption'): {\n return (\n <>\n <ShippingHeader onEditAddress={() => send('EDIT_ADDRESS')} />\n\n <ShippingOptionList\n deliveryOptions={deliveryOptions}\n pickupOptions={pickupOptions}\n onDeliveryOptionSelected={handleDeliveryOptionSelect}\n onPickupOptionSelected={handlePickupOptionSelect}\n onDeliveryOptionDeselected={() => send('DESELECT_SHIPPING_OPTION')}\n onPickupOptionDeselected={() => send('DESELECT_SHIPPING_OPTION')}\n showOnlySelectedShippingOption={matches({\n selectShippingOption: 'idle',\n })}\n />\n\n {matches({ selectShippingOption: 'idle' }) &&\n state.context.hasHistory && (\n <div className=\"mt6\">\n <Button\n block\n size=\"large\"\n onClick={() => send('GO_TO_ADDRESS_STEP')}\n testId=\"continue-shipping-button\"\n >\n <span className=\"f5\">\n <FormattedMessage id=\"store/checkout.shipping.goToAddress\" />\n </span>\n </Button>\n </div>\n )}\n </>\n )\n }\n\n case matches('selectAddress'): {\n return (\n <AddressList\n hasError={matches({ selectAddress: 'error' })}\n isSubmitting={matches({ selectAddress: 'submitting' })}\n addresses={state.context.availableAddresses}\n selectedAddress={state.context.selectedAddress}\n onCreateAddress={() => send('GO_TO_CREATE_ADDRESS')}\n onAddressSelected={(address) =>\n send({ type: 'SUBMIT_SELECT_ADDRESS', address })\n }\n onRetrySelectAddress={() => {\n send('RETRY_SELECT_ADDRESS', {\n address: state.context.retryAddress!,\n })\n }}\n onEditAddress={() => send('EDIT_ADDRESS')}\n />\n )\n }\n\n case matches('createAddress'):\n\n // eslint-disable-next-line no-fallthrough\n default: {\n return (\n <NewAddressForm\n onAddressCreated={handleAddressCreated}\n onEditAddress={() => send('EDIT_ADDRESS')}\n onRetryCreateAddress={() => {\n send('RETRY_CREATE_ADDRESS', {\n address: state.context.retryAddress!,\n })\n }}\n isSubmitting={matches({ createAddress: 'submitting' })}\n hasError={matches({ createAddress: 'error' })}\n hasAvailableAddresses={matches({\n createAddress: { editing: 'withListBacklink' },\n })}\n onViewAddressList={() => send('GO_TO_SELECT_ADDRESS')}\n />\n )\n }\n }\n}\n\nconst ShippingFormWithAddress: React.FC = () => {\n const { selectedAddress, countries } = useOrderShipping()\n\n const addressRules = useAddressRules()\n\n if (addressRules == null) {\n return <Loading />\n }\n\n return (\n <AddressContext.AddressContextProvider\n address={selectedAddress!}\n countries={countries}\n rules={addressRules}\n >\n <ShippingForm />\n </AddressContext.AddressContextProvider>\n )\n}\n\nexport default ShippingFormWithAddress\n\n```" } ]
code_checkout-shipping_70016fb7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/package.json from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"checkout-shipping\",\n \"version\": \"0.9.0\",\n \"private\": true,\n \"license\": \"UNLICENSED\",\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^4.0.0\",\n \"@types/classnames\": \"^2.2.10\",\n \"@types/history\": \"^4\",\n \"@types/node\": \"^12.12.31\",\n \"@types/react\": \"^16.9.26\",\n \"@types/react-router\": \"^5.1.11\",\n \"@vtex/test-tools\": \"^3.4.1\",\n \"vtex.address-context\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.address-context@0.6.2/public/@types/vtex.address-context\",\n \"vtex.checkout-components\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.checkout-components@0.5.1/public/@types/vtex.checkout-components\",\n \"vtex.checkout-container\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.checkout-container@0.8.0/public/@types/vtex.checkout-container\",\n \"vtex.checkout-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.checkout-graphql@0.56.2/public/@types/vtex.checkout-graphql\",\n \"vtex.checkout-resources\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.checkout-resources@0.42.0/public/@types/vtex.checkout-resources\",\n \"vtex.country-data-settings\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.country-data-settings@0.4.0/public/@types/vtex.country-data-settings\",\n \"vtex.format-currency\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.format-currency@0.3.0/public/@types/vtex.format-currency\",\n \"vtex.formatted-price\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.formatted-price@0.4.0/public/@types/vtex.formatted-price\",\n \"vtex.order-manager\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.order-manager@0.9.0/public/@types/vtex.order-manager\",\n \"vtex.order-shipping\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.order-shipping@0.7.0/public/@types/vtex.order-shipping\",\n \"vtex.place-components\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.place-components@0.14.2/public/@types/vtex.place-components\",\n \"vtex.places-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.places-graphql@0.4.0/public/@types/vtex.places-graphql\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.128.2/public/@types/vtex.render-runtime\",\n \"vtex.shipping-estimate-translator\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.shipping-estimate-translator@2.2.2/public/@types/vtex.shipping-estimate-translator\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.136.1/public/@types/vtex.styleguide\"\n },\n \"dependencies\": {\n \"@vtex/estimate-calculator\": \"^1.1.0\",\n \"@xstate/react\": \"^1.2.2\",\n \"classnames\": \"^2.2.6\",\n \"graphql\": \"^14.6.0\",\n \"react\": \"^16.13.1\",\n \"react-apollo\": \"^3.1.5\",\n \"react-dom\": \"^16.13.1\",\n \"react-intl\": \"^3\",\n \"xstate\": \"^4.16.0\"\n },\n \"peerDependencies\": {\n \"@types/jest\": \"^26.0.21\"\n }\n}\n\n```" } ]
code_checkout-shipping_cbb64d9f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/NewAddressForm.tsx from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport {\n DeviceCoordinates,\n LocationInput,\n LocationCountry,\n LocationSearch,\n} from 'vtex.place-components'\nimport type { Address } from 'vtex.places-graphql'\nimport { FormattedMessage } from 'react-intl'\nimport { ListGroup } from 'vtex.checkout-components'\nimport { Loading } from 'vtex.render-runtime'\nimport { useGeolocationEnabled } from 'vtex.checkout-resources'\n\nimport ShippingHeader from './ShippingHeader'\nimport { ShippingOptionPreview } from './ShippingOption'\nimport ShippingEditError from './components/ShippingEditError'\n\ninterface Props {\n onAddressCreated: (address: Address) => void\n onRetryCreateAddress?: () => void\n onEditAddress?: () => void\n onViewAddressList?: () => void\n isSubmitting: boolean\n hasError: boolean\n hasAvailableAddresses: boolean\n}\n\nconst NewAddressForm: React.FC<Props> = ({\n onAddressCreated,\n onRetryCreateAddress = () => {},\n onEditAddress = () => {},\n onViewAddressList = () => {},\n isSubmitting,\n hasError,\n hasAvailableAddresses,\n}) => {\n const [geolocationEnabled, loading] = useGeolocationEnabled()\n\n if (loading) {\n return <Loading />\n }\n\n if (hasError) {\n return (\n <ShippingEditError\n onEditAddress={onEditAddress}\n onTryAgain={onRetryCreateAddress}\n />\n )\n }\n\n if (isSubmitting) {\n return (\n <>\n <ShippingHeader onEditAddress={onEditAddress} />\n\n <ListGroup>\n <ShippingOptionPreview />\n <ShippingOptionPreview />\n <ShippingOptionPreview />\n </ListGroup>\n </>\n )\n }\n\n return (\n <>\n <p className=\"t-body mt0 mb6\">\n <FormattedMessage id=\"store/checkout.shipping.informAddress\" />\n </p>\n\n <div>\n <DeviceCoordinates onSuccess={onAddressCreated} />\n </div>\n\n <LocationCountry className=\"w-100 mw6 mt6\" />\n\n {!geolocationEnabled ? (\n <div className=\"mt6 w-100 mw5\">\n <LocationInput onSuccess={onAddressCreated} variation=\"primary\" />\n </div>\n ) : (\n <div className=\"mt6 w-100 mw6\">\n <LocationSearch onSelectAddress={onAddressCreated} />\n </div>\n )}\n\n {hasAvailableAddresses && (\n <div className=\"mt6\">\n <FormattedMessage\n id=\"store/checkout.shipping.backToAddressList\"\n values={{\n // eslint-disable-next-line react/display-name\n a: (chunks: any) => {\n return (\n <button\n className=\"bn bg-transparent pa0 c-action-primary pointer\"\n onClick={onViewAddressList}\n >\n {chunks}\n </button>\n )\n },\n }}\n />\n </div>\n )}\n </>\n )\n}\n\nexport default NewAddressForm\n\n```" } ]
code_checkout-shipping_6f8002c7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/ShippingHeader.tsx from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { ButtonPlain } from 'vtex.styleguide'\nimport { PlaceDetails } from 'vtex.place-components'\nimport { FormattedMessage } from 'react-intl'\n\ninterface Props {\n onEditAddress?: () => void\n}\n\nconst ShippingHeader: React.VFC<Props> = ({ onEditAddress }) => {\n return (\n <>\n <p className=\"t-body fw6 mv0\">\n <FormattedMessage id=\"store/checkout.shipping.shippingOptionsForAddressLabel\" />\n </p>\n <div className=\"flex items-center mt2 mb6\">\n <div className=\"lh-copy\">\n <PlaceDetails display=\"minimal\" />\n </div>\n <div className=\"ml3\">\n <ButtonPlain onClick={onEditAddress}>\n <FormattedMessage id=\"store/checkout.shipping.changeAddressLabel\" />\n </ButtonPlain>\n </div>\n </div>\n </>\n )\n}\n\nexport default ShippingHeader\n\n```" } ]
code_checkout-shipping_abd48c93
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/ShippingSummary.tsx from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { OrderShipping } from 'vtex.order-shipping'\nimport { TranslateEstimate } from 'vtex.shipping-estimate-translator'\nimport { FormattedCurrency } from 'vtex.format-currency'\nimport type { DeliveryOption, PickupOption } from 'vtex.checkout-graphql'\n\nimport { getName } from './utils/sla'\n\nconst { useOrderShipping } = OrderShipping\n\nconst ShippingSummary: React.FC = () => {\n const { deliveryOptions, pickupOptions } = useOrderShipping()\n\n const shippingOptions = [...deliveryOptions, ...pickupOptions]\n\n const selectedShippingOptions = shippingOptions.filter(\n ({ isSelected }) => isSelected\n )\n\n if (!selectedShippingOptions.length) {\n return null\n }\n\n return (\n <div className=\"c-muted-1 lh-copy\">\n {selectedShippingOptions.map(\n (shippingOption: DeliveryOption | PickupOption) => (\n <div key={shippingOption.id}>\n <span>\n {getName(shippingOption)} &ndash; {''}\n <FormattedCurrency value={shippingOption.price / 100} />\n </span>\n <p className=\"mv0\">\n <TranslateEstimate shippingEstimate={shippingOption.estimate} />\n </p>\n </div>\n )\n )}\n </div>\n )\n}\n\nexport default ShippingSummary\n\n```" } ]
code_checkout-shipping_cab2555e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/useAddressRules.tsx from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { useAddressRules } from 'vtex.address-context'\n\nexport default useAddressRules\n\n```" } ]
code_checkout-shipping_55a68056
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/typings/assets.d.ts from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const styles: { [key: string]: string }\n export default styles\n}\n\n```" } ]
code_checkout-shipping_14af25d4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/typings/graphql.d.ts from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.gql' {\n import type { DocumentNode } from 'graphql'\n\n const query: DocumentNode\n\n export default query\n}\n\n```" } ]
code_checkout-shipping_ccfd77cc
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/typings/vtex.styleguide.d.ts from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type React from 'react'\n\ndeclare module 'vtex.styleguide' {\n const IconCaretRight: React.FC\n\n interface IconEditProps {\n solid?: boolean\n }\n\n const IconEdit: React.FC<IconEditProps>\n\n const IconDelete: React.FC\n\n const Button: React.FC<any>\n\n const Checkbox: React.FC<any>\n\n const Input: React.FC<any>\n\n const Alert: React.FC<any>\n\n const Modal: React.FC<any>\n\n const Divider: React.FC<any>\n}\n\n```" } ]
code_checkout-shipping_900859fe
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/utils/sla.ts from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { DeliveryOption, PickupOption } from 'vtex.checkout-graphql'\n\nexport const isPickupOption = (\n shippingOption: DeliveryOption | PickupOption\n): shippingOption is PickupOption => {\n return shippingOption.deliveryChannel === 'pickup-in-point'\n}\n\nexport const getName = (shippingOption: DeliveryOption | PickupOption) => {\n return isPickupOption(shippingOption)\n ? shippingOption.friendlyName\n : shippingOption.id\n}\n\nexport const slugify = (text: string) => {\n return text?.toLowerCase().replace(/\\s+/g, '-').replace(/[()]/g, '')\n}\n\n```" } ]
code_checkout-shipping_267cca18
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/components/PickupDetailsModal.tsx from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { TranslateEstimate } from 'vtex.shipping-estimate-translator'\nimport { FormattedPrice } from 'vtex.formatted-price'\nimport type { PickupOption, BusinessHour } from 'vtex.checkout-graphql'\nimport { Divider } from 'vtex.styleguide'\nimport { PlaceDetails } from 'vtex.place-components'\nimport { AddressContext } from 'vtex.address-context'\nimport { Modal } from 'vtex.checkout-components'\nimport { FormattedMessage, defineMessages, FormattedTime } from 'react-intl'\n\nconst { useAddressContext } = AddressContext\n\nconst messages = defineMessages({\n details: {\n defaultMessage: 'Details',\n id: 'store/checkout.shipping.pickupPointsModal.details',\n },\n weekDay0: {\n defaultMessage: 'Sunday',\n id: 'store/checkout.shipping.pickupPointsModal.weekDay0',\n },\n weekDay1: {\n defaultMessage: 'Monday',\n id: 'store/checkout.shipping.pickupPointsModal.weekDay1',\n },\n weekDay2: {\n defaultMessage: 'Tuesday',\n id: 'store/checkout.shipping.pickupPointsModal.weekDay2',\n },\n weekDay3: {\n defaultMessage: 'Wednesday',\n id: 'store/checkout.shipping.pickupPointsModal.weekDay3',\n },\n weekDay4: {\n defaultMessage: 'Thursday',\n id: 'store/checkout.shipping.pickupPointsModal.weekDay4',\n },\n weekDay5: {\n defaultMessage: 'Friday',\n id: 'store/checkout.shipping.pickupPointsModal.weekDay5',\n },\n weekDay6: {\n defaultMessage: 'Saturday',\n id: 'store/checkout.shipping.pickupPointsModal.weekDay6',\n },\n weekDay1to5: {\n defaultMessage: 'Monday to Friday',\n id: 'store/checkout.shipping.pickupPointsModal.weekDay1to5',\n },\n})\n\nconst formatHour = (hour: string) => {\n const hoursNumbers = hour.split(':').map((t) => parseInt(t, 10))\n // eslint-disable-next-line prefer-spread\n const time = new Date().setHours.apply(new Date(), hoursNumbers)\n\n return <FormattedTime value={time} hour=\"numeric\" />\n}\n\ninterface Props {\n pickupOption: PickupOption\n setShowPickupModal: (showPickupModal: boolean) => void\n showPickupModal: boolean\n}\n\nconst PickupDetailsModal: React.VFC<Props> = ({\n pickupOption,\n showPickupModal,\n setShowPickupModal,\n}) => {\n const { countries, rules } = useAddressContext()\n\n return (\n <Modal\n isOpen={showPickupModal}\n onClose={() => setShowPickupModal(false)}\n title={<FormattedMessage {...messages.details} />}\n >\n <div className=\"lh-copy\">\n <Divider orientation=\"horizontal\" />\n <div className=\"flex-column mt4 mb4\">\n <div className=\"flex justify-between mb0\">\n <p className=\"fw6 f3 mv0\">{pickupOption.friendlyName}</p>\n <span className=\"fw5 f5 flex items-center\">\n <FormattedPrice value={(pickupOption.price ?? 0) / 100} />\n </span>\n </div>\n\n <p className=\"fw5 f5 c-muted-1 mv0\">\n <TranslateEstimate shippingEstimate={pickupOption.estimate ?? ''} />\n </p>\n\n <p className=\"fw4 f6 c-muted-1 mv0\">\n <FormattedMessage\n id=\"store/checkout.shipping.distance\"\n values={{\n distanceValue: pickupOption.storeDistance?.toFixed(1),\n }}\n />\n </p>\n </div>\n\n <div className=\"flex-column mb4\">\n <p className=\"fw6 mb2 mt0\">\n <FormattedMessage id=\"store/checkout.shipping.pickupPointsModal.address\" />\n </p>\n\n <AddressContext.AddressContextProvider\n address={pickupOption.address}\n countries={countries}\n rules={rules}\n >\n <PlaceDetails />\n </AddressContext.AddressContextProvider>\n </div>\n\n <div className=\"flex-column mb4\">\n <p className=\"fw6 mb2 mt0\">\n <FormattedMessage id=\"store/checkout.shipping.pickupPointsModal.businessHours\" />\n </p>\n\n <table className=\"dt--fixed\">\n <tbody>\n {pickupOption.businessHours.map((businessHour: BusinessHour) => (\n <tr\n key={businessHour.dayNumber}\n className=\"flex justify-between bb b--light-gray mt2\"\n >\n <td>\n <FormattedMessage\n id={`store/checkout.shipping.pickupPointsModal.weekDay${businessHour.dayNumber}`}\n />\n </td>\n\n <td>\n {businessHour.closed ? (\n <FormattedMessage id=\"store/checkout.shipping.pickupPointsModal.closed\" />\n ) : (\n <FormattedMessage\n id=\"store/checkout.shipping.pickupPointsModal.hourFromTo\"\n values={{\n openingTime: formatHour(businessHour.openingTime),\n closingTime: formatHour(businessHour.closingTime),\n }}\n />\n )}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n\n <div className=\"flex-column\">\n <p className=\"fw6 mb2 mt0\">\n <FormattedMessage id=\"store/checkout.shipping.pickupPointsModal.availableItems\" />\n </p>\n <p className=\"mv0\">\n <FormattedMessage id=\"store/checkout.shipping.pickupPointsModal.allItemsAvailable\" />\n </p>\n </div>\n </div>\n </Modal>\n )\n}\n\nexport default PickupDetailsModal\n\n```" } ]
code_checkout-shipping_ecc9d902
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/components/ShippingEditError.tsx from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { Alert } from 'vtex.styleguide'\nimport { FormattedMessage } from 'react-intl'\n\nimport ShippingHeader from '../ShippingHeader'\n\ninterface Props {\n onEditAddress: () => void\n onTryAgain: () => void\n}\n\nconst ShippingEditError: React.VFC<Props> = ({ onEditAddress, onTryAgain }) => {\n return (\n <>\n <ShippingHeader onEditAddress={onEditAddress} />\n\n <Alert\n type=\"warning\"\n action={{\n onClick: onTryAgain,\n label: (\n <span className=\"f5 ttn\">\n <FormattedMessage id=\"store/checkout.shipping.tryAgainButton\" />\n </span>\n ),\n }}\n >\n <FormattedMessage id=\"store/checkout.shipping.unknownErrorMessage\" />\n </Alert>\n </>\n )\n}\n\nexport default ShippingEditError\n\n```" } ]
code_checkout-shipping_336f5821
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/components/AddressCompletionForm.tsx from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useState, useMemo } from 'react'\nimport { AddressForm, useAddressForm } from 'vtex.place-components'\nimport type { Address } from 'vtex.checkout-graphql'\nimport { Button, Input, ButtonPlain } from 'vtex.styleguide'\nimport { OrderForm } from 'vtex.order-manager'\nimport { AddressContext } from 'vtex.address-context'\nimport { FormattedMessage, useIntl } from 'react-intl'\n\nconst { useOrderForm } = OrderForm\nconst { useAddressContext } = AddressContext\n\ninterface Props {\n isSubmitting: boolean\n onAddressCompleted?: (updatedAddress: Address) => void\n onAddressReset: () => void\n}\n\nconst AddressCompletionForm: React.FC<Props> = ({\n isSubmitting,\n onAddressReset = () => {},\n onAddressCompleted = () => {},\n}) => {\n const intl = useIntl()\n const {\n orderForm: { clientProfileData, canEditData },\n } = useOrderForm()\n\n const { address: initialAddress } = useAddressContext()\n const form = useAddressForm({ initialAddress })\n\n const mandatoryEditableFields = form.invalidFields\n\n const { firstName, lastName } = clientProfileData ?? {\n firstName: '',\n lastName: '',\n }\n\n const autoReceiverName = useMemo(() => `${firstName} ${lastName}`, [\n firstName,\n lastName,\n ])\n\n const [editingReceiverName, setEditingReceiverName] = useState(\n !form.address.receiverName && !canEditData\n )\n\n const handleEditReceiverName = () => {\n setEditingReceiverName(true)\n }\n\n const handleNameChange: React.ChangeEventHandler<HTMLInputElement> = (\n evt\n ) => {\n form.onFieldChange('receiverName', evt.target.value)\n }\n\n const handleFormSubmit: React.FormEventHandler = (evt) => {\n evt.preventDefault()\n\n const updatedAddress = { ...form.address }\n\n const onlyReceiverInvalid =\n form.invalidFields.length > 0 &&\n form.invalidFields.every((field) => field === 'receiverName')\n\n if (!editingReceiverName && onlyReceiverInvalid) {\n updatedAddress.receiverName = autoReceiverName\n onAddressCompleted(updatedAddress)\n } else if (form.isValid) {\n onAddressCompleted(updatedAddress)\n } else {\n form.invalidFields.forEach((field: string) => {\n form.onFieldBlur(field)\n })\n }\n }\n\n return (\n <div className=\"lh-copy\">\n <form onSubmit={handleFormSubmit}>\n <span className=\"dib mb4 t-body fw6\">\n <FormattedMessage id=\"store/checkout.shipping.completeAddressLabel\" />\n </span>\n\n <AddressForm\n hiddenFields={['receiverName']}\n onResetAddress={onAddressReset}\n mandatoryEditableFields={mandatoryEditableFields}\n form={form}\n />\n\n <div className=\"mt6 mb6\">\n <p className=\"fw5 mb5 mt0\">\n <FormattedMessage id=\"store/checkout.shipping.receiverLabel\" />\n </p>\n\n {!editingReceiverName ? (\n <div className=\"flex items-center\">\n <span className=\"mr3\">\n {form.address.receiverName ?? autoReceiverName}\n </span>\n <ButtonPlain onClick={handleEditReceiverName}>\n <FormattedMessage id=\"store/checkout.shipping.changeReceiverLabel\" />\n </ButtonPlain>\n </div>\n ) : (\n <Input\n label={intl.formatMessage({\n id: 'store/checkout.shipping.receiverNameLabel',\n })}\n onChange={handleNameChange}\n onBlur={() => {\n form.onFieldBlur('receiverName')\n }}\n value={form.address.receiverName}\n errorMessage={\n form.meta.receiverName?.blurred &&\n form.meta.receiverName?.errorMessage\n ? intl.formatMessage(form.meta.receiverName.errorMessage)\n : ''\n }\n />\n )}\n </div>\n\n <Button\n testId=\"continue-address-button\"\n block\n size=\"large\"\n type=\"submit\"\n disabled={isSubmitting}\n isLoading={isSubmitting}\n >\n <span className=\"f5\">\n <FormattedMessage id=\"store/checkout.shipping.goToPayment\" />\n </span>\n </Button>\n </form>\n </div>\n )\n}\n\nexport default AddressCompletionForm\n\n```" } ]
code_checkout-shipping_0eb9be40
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/components/AddressList.tsx from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { AddressContext } from 'vtex.address-context'\nimport { PlaceDetails } from 'vtex.place-components'\nimport type { Address } from 'vtex.checkout-graphql'\nimport { OrderShipping } from 'vtex.order-shipping'\nimport { FormattedMessage } from 'react-intl'\nimport { ListGroup, GroupOption } from 'vtex.checkout-components'\n\nimport ShippingHeader from '../ShippingHeader'\nimport { ShippingOptionPreview } from '../ShippingOption'\nimport ShippingEditError from './ShippingEditError'\n\nconst { useAddressContext } = AddressContext\nconst { useOrderShipping } = OrderShipping\n\ninterface Props {\n addresses: Address[]\n onCreateAddress?: () => void\n onAddressSelected?: (address: Address) => void\n onRetrySelectAddress?: () => void\n onEditAddress?: () => void\n selectedAddress: Address | null\n isSubmitting: boolean\n hasError: boolean\n}\n\nconst AddressList: React.FC<Props> = ({\n addresses,\n onEditAddress = () => {},\n onCreateAddress = () => {},\n onRetrySelectAddress = () => {},\n onAddressSelected = () => {},\n selectedAddress,\n isSubmitting,\n hasError,\n}) => {\n const { countries } = useOrderShipping()\n const { rules } = useAddressContext()\n\n if (hasError) {\n return (\n <ShippingEditError\n onEditAddress={onEditAddress}\n onTryAgain={onRetrySelectAddress}\n />\n )\n }\n\n if (isSubmitting) {\n return (\n <>\n <ShippingHeader onEditAddress={onEditAddress} />\n\n <ListGroup>\n <ShippingOptionPreview />\n <ShippingOptionPreview />\n <ShippingOptionPreview />\n </ListGroup>\n </>\n )\n }\n\n return (\n <div>\n <span className=\"db fw6 lh-copy mb3\">\n <FormattedMessage id=\"store/checkout.shipping.chooseAddress\" />\n </span>\n <ListGroup>\n {addresses.map((address, id) => (\n <GroupOption\n onClick={() => onAddressSelected(address)}\n selected={address.addressId === selectedAddress?.addressId}\n key={`${address?.addressId}-${id}`}\n >\n <AddressContext.AddressContextProvider\n address={address}\n countries={countries}\n rules={rules}\n >\n <PlaceDetails />\n </AddressContext.AddressContextProvider>\n </GroupOption>\n ))}\n <GroupOption onClick={onCreateAddress}>\n <FormattedMessage id=\"store/checkout.shipping.newAddressLabel\" />\n </GroupOption>\n </ListGroup>\n </div>\n )\n}\n\nexport default AddressList\n\n```" } ]
code_checkout-shipping_f1e118e3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/__tests__/PickupDetailsModal.tsx from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { render, screen } from '@vtex/test-tools/react'\nimport { AddressContext } from 'vtex.address-context'\nimport type { PickupOption } from 'vtex.checkout-graphql'\n\nimport PickupDetailsModal from '../components/PickupDetailsModal'\n\ndescribe('PickupDetailsModal', () => {\n it('should display pickup address instead of user address', async () => {\n render(\n <AddressContext.AddressContextProvider\n address={{\n street: 'User fake street',\n }}\n countries={[]}\n rules={{}}\n >\n <PickupDetailsModal\n pickupOption={\n {\n address: {\n street: 'Pickup fake street',\n },\n businessHours: [] as PickupOption['businessHours'],\n } as PickupOption\n }\n showPickupModal\n setShowPickupModal={() => {}}\n />\n </AddressContext.AddressContextProvider>\n )\n\n expect(screen.queryByText(/Pickup fake street/i)).toBeInTheDocument()\n expect(screen.queryByText(/User fake street/i)).not.toBeInTheDocument()\n })\n})\n\n```" } ]
code_checkout-shipping_0f9bc82f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/machines/useShippingStateMachine.ts from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { useMachine } from '@xstate/react'\nimport { Router, routes } from 'vtex.checkout-container'\nimport { OrderShipping } from 'vtex.order-shipping'\nimport { assign } from 'xstate'\nimport { AddressContext } from 'vtex.address-context'\nimport { useContext } from 'react'\n\nimport shippingStateMachine from './shippingStateMachine'\nimport type { ShippingMachineContext, ShippingMachineEvents } from './types'\nimport useMatcher from './useMatcher'\n\nconst { useOrderShipping } = OrderShipping\nconst { useAddressContext } = AddressContext\n\nconst useShippingStateMachine = ({\n availableAddresses,\n selectedAddress,\n canEditData,\n userProfileId,\n}: Omit<ShippingMachineContext, 'hasHistory'>) => {\n const {\n insertAddress,\n selectDeliveryOption,\n selectPickupOption,\n updateSelectedAddress,\n } = useOrderShipping()\n\n const { setAddress } = useAddressContext()\n\n const history = useContext(Router.__RouterContext)?.history\n\n const [state, send] = useMachine<\n ShippingMachineContext,\n ShippingMachineEvents\n >(shippingStateMachine, {\n devTools: true,\n context: {\n availableAddresses,\n selectedAddress,\n canEditData,\n userProfileId,\n hasHistory: !!history,\n },\n actions: {\n goToNextStep: () => history?.push(routes.ADDRESS),\n updateAddressContext: (_, event) => {\n if (\n event.type !== 'SUBMIT_CREATE_ADDRESS' &&\n event.type !== 'SUBMIT_SELECT_ADDRESS'\n ) {\n return\n }\n\n setAddress(event.address)\n },\n updateSelectedAddress: assign((_, event) => {\n if (\n event.type === 'done.invoke.tryToCreateAddress' ||\n event.type === 'done.invoke.tryToSelectAddress'\n ) {\n const updatedAddress = event.data.orderForm.shipping.selectedAddress\n\n setAddress(updatedAddress)\n\n return {\n selectedAddress: event.data.orderForm.shipping.selectedAddress,\n }\n }\n\n return {}\n }),\n },\n services: {\n tryToCreateAddress: async (_, event) => {\n if (\n event.type !== 'SUBMIT_CREATE_ADDRESS' &&\n event.type !== 'RETRY_CREATE_ADDRESS'\n ) {\n return\n }\n\n try {\n return await insertAddress(event.address)\n } catch {\n throw event.address\n }\n },\n tryToSelectAddress: async (_, event) => {\n if (\n event.type !== 'SUBMIT_SELECT_ADDRESS' &&\n event.type !== 'RETRY_SELECT_ADDRESS'\n ) {\n return\n }\n\n try {\n return await updateSelectedAddress(event.address)\n } catch {\n throw event.address\n }\n },\n tryToSelectShippingOption: async (_, event) => {\n if (event.type !== 'SUBMIT_SELECT_SHIPPING_OPTION') {\n return\n }\n\n if (event.deliveryChannel === 'delivery') {\n return selectDeliveryOption(event.shippingOptionId)\n }\n\n return selectPickupOption(event.shippingOptionId)\n },\n },\n })\n\n const matches = useMatcher<ShippingMachineContext, ShippingMachineEvents>(\n state\n )\n\n return { matches, send, state }\n}\n\nexport default useShippingStateMachine\n\n```" } ]
code_checkout-shipping_edfdb860
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/machines/shippingStateMachine.ts from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { assign, Machine } from 'xstate'\n\nimport type { ShippingMachineContext, ShippingMachineEvents } from './types'\n\nconst hasSelectedAddress = ({ selectedAddress }: ShippingMachineContext) =>\n selectedAddress != null\n\nconst hasNoAvailableAddresses = ({\n availableAddresses,\n}: ShippingMachineContext) => availableAddresses.length === 0\n\nconst hasAvailableAddresses = ({\n availableAddresses,\n}: ShippingMachineContext) => availableAddresses.length !== 0\n\nconst isFirstPurchase = ({\n canEditData,\n userProfileId,\n}: ShippingMachineContext) => canEditData && !userProfileId\n\nconst hasEditingAddressId = ({ editingAddressId }: ShippingMachineContext) =>\n editingAddressId != null\n\nconst shippingStateMachine = Machine<\n ShippingMachineContext,\n ShippingMachineEvents\n>(\n {\n initial: 'initial',\n context: {\n availableAddresses: [],\n canEditData: true,\n selectedAddress: null,\n userProfileId: null,\n editingAddressId: null,\n hasHistory: true,\n retryAddress: null,\n },\n states: {\n initial: {\n always: [\n { target: 'createAddress', cond: hasEditingAddressId },\n { target: 'selectShippingOption', cond: hasSelectedAddress },\n { target: 'selectAddress', cond: hasAvailableAddresses },\n { target: 'createAddress' },\n ],\n },\n createAddress: {\n initial: 'editing',\n states: {\n editing: {\n initial: 'withListBacklink',\n states: {\n normal: {\n on: {\n GO_TO_SELECT_ADDRESS: undefined,\n },\n },\n withListBacklink: {\n always: [\n {\n target: 'normal',\n cond: isFirstPurchase,\n },\n {\n target: 'normal',\n cond: hasNoAvailableAddresses,\n },\n ],\n },\n },\n on: {\n GO_TO_SELECT_ADDRESS: 'selectAddress',\n SUBMIT_CREATE_ADDRESS: {\n target: 'submitting',\n actions: 'updateAddressContext',\n },\n },\n },\n submitting: {\n on: {\n EDIT_ADDRESS: {\n target: 'editing',\n actions: 'clearRetryAddress',\n },\n },\n invoke: {\n src: 'tryToCreateAddress',\n onDone: {\n target: 'done',\n actions: [\n 'updateSelectedAddress',\n 'updateAvailableAddresses',\n 'clearRetryAddress',\n ],\n },\n onError: {\n target: 'error',\n actions: 'updateRetryAddress',\n },\n },\n },\n error: {\n on: {\n RETRY_CREATE_ADDRESS: 'submitting',\n EDIT_ADDRESS: {\n target: 'editing',\n actions: 'clearRetryAddress',\n },\n },\n },\n selectAddress: {\n entry: 'clearEditingAddressId',\n type: 'final',\n },\n done: {\n entry: 'clearEditingAddressId',\n type: 'final',\n },\n },\n onDone: [\n {\n target: 'selectAddress',\n cond: (_, __, meta) =>\n meta.state.matches({ createAddress: 'selectAddress' }),\n },\n { target: 'selectShippingOption' },\n ],\n },\n selectAddress: {\n initial: 'idle',\n states: {\n idle: {\n always: [\n {\n target: 'createAddress',\n cond: hasNoAvailableAddresses,\n },\n {\n target: 'createAddress',\n cond: isFirstPurchase,\n },\n ],\n on: {\n GO_TO_CREATE_ADDRESS: 'createAddress',\n SUBMIT_SELECT_ADDRESS: {\n target: 'submitting',\n actions: 'updateAddressContext',\n },\n },\n },\n submitting: {\n on: {\n EDIT_ADDRESS: {\n target: 'idle',\n actions: 'clearRetryAddress',\n },\n },\n invoke: {\n src: 'tryToSelectAddress',\n onDone: {\n target: 'selectOption',\n actions: ['updateSelectedAddress', 'clearRetryAddress'],\n },\n onError: {\n target: 'error',\n actions: 'updateRetryAddress',\n },\n },\n },\n error: {\n on: {\n RETRY_SELECT_ADDRESS: 'submitting',\n EDIT_ADDRESS: {\n target: 'idle',\n actions: 'clearRetryAddress',\n },\n },\n },\n createAddress: {\n type: 'final',\n },\n selectOption: {\n type: 'final',\n },\n },\n\n onDone: [\n {\n target: 'selectShippingOption',\n cond: (_, __, meta) =>\n meta.state.matches({ selectAddress: 'selectOption' }),\n },\n {\n target: 'createAddress',\n },\n ],\n },\n selectShippingOption: {\n initial: 'editing',\n on: {\n EDIT_ADDRESS: [\n {\n target: 'createAddress',\n cond: isFirstPurchase,\n actions: 'updateEditingAddressId',\n },\n { target: 'selectAddress' },\n ],\n },\n states: {\n idle: {\n on: {\n DESELECT_SHIPPING_OPTION: 'editing',\n GO_TO_ADDRESS_STEP: 'done',\n },\n },\n editing: {\n on: {\n SUBMIT_SELECT_SHIPPING_OPTION: 'submitting',\n },\n },\n submitting: {\n on: {\n EDIT_ADDRESS: undefined,\n },\n invoke: {\n src: 'tryToSelectShippingOption',\n onDone: 'idle',\n },\n },\n done: {\n type: 'final',\n },\n },\n\n onDone: 'done',\n },\n done: {\n entry: 'goToNextStep',\n },\n },\n },\n {\n actions: {\n goToNextStep: () => {},\n updateEditingAddressId: assign((ctx) => {\n return {\n editingAddressId: ctx.selectedAddress?.addressId,\n }\n }),\n clearEditingAddressId: assign((_) => {\n return {\n editingAddressId: null,\n }\n }),\n updateRetryAddress: assign((_, action) => {\n if (\n action.type !== 'error.platform.tryToCreateAddress' &&\n action.type !== 'error.platform.tryToSelectAddress'\n ) {\n return {}\n }\n\n return {\n retryAddress: action.data,\n }\n }),\n clearRetryAddress: assign({\n retryAddress: (_) => {\n return null\n },\n }),\n updateAvailableAddresses: assign({\n availableAddresses: (ctx, action) => {\n if (action.type !== 'done.invoke.tryToCreateAddress') {\n return ctx.availableAddresses\n }\n\n return action.data.orderForm.shipping.availableAddresses\n },\n }),\n },\n }\n)\n\nexport default shippingStateMachine\n\n```" } ]
code_checkout-shipping_76f65476
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/machines/types.ts from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type {\n Address,\n DeliveryOption,\n PickupOption,\n} from 'vtex.checkout-graphql'\n\nexport interface ShippingMachineContext {\n availableAddresses: Address[]\n canEditData: boolean\n selectedAddress: Address | null\n retryAddress: Address | null\n userProfileId?: string | null\n editingAddressId?: string | null\n hasHistory: boolean\n}\n\nexport type ShippingMachineEvents =\n | { type: 'GO_TO_CREATE_ADDRESS' }\n | { type: 'GO_TO_SELECT_ADDRESS' }\n | { type: 'GO_TO_ADDRESS_STEP' }\n | { type: 'DESELECT_SHIPPING_OPTION' }\n | { type: 'EDIT_ADDRESS' }\n | { type: 'SUBMIT_SELECT_ADDRESS' | 'RETRY_SELECT_ADDRESS'; address: Address }\n | {\n type: 'SUBMIT_SELECT_SHIPPING_OPTION'\n shippingOptionId: string\n deliveryChannel: string\n }\n | { type: 'SUBMIT_CREATE_ADDRESS' | 'RETRY_CREATE_ADDRESS'; address: Address }\n | {\n type: 'done.invoke.tryToCreateAddress'\n data: {\n orderForm: {\n shipping: {\n availableAddresses: Address[]\n deliveryOptions: DeliveryOption[]\n pickupOptions: PickupOption[]\n selectedAddress: Address\n }\n }\n }\n }\n | {\n type: 'error.platform.tryToCreateAddress'\n data: Address\n }\n | {\n type: 'done.invoke.tryToSelectAddress'\n data: {\n orderForm: {\n shipping: {\n deliveryOptions: DeliveryOption[]\n pickupOptions: PickupOption[]\n selectedAddress: Address\n }\n }\n }\n }\n | {\n type: 'error.platform.tryToSelectAddress'\n data: Address\n }\n | {\n type: 'done.invoke.tryToSelectShippingOption'\n data: {\n success: boolean\n }\n }\n\nexport type AddressMachineEvents =\n | { type: 'SUBMIT_RECEIVER_INFO'; receiverName: string }\n | { type: 'EDIT_ADDRESS' }\n | {\n type: 'SUBMIT_EDIT_ADDRESS'\n updatedAddress: Address\n }\n | { type: 'RESET_ADDRESS' }\n | {\n type: 'done.invoke.tryToUpdateCompleteAddress'\n data: {\n success: boolean\n orderForm: {\n shipping: {\n deliveryOptions: DeliveryOption[]\n pickupOptions: PickupOption[]\n selectedAddress: Address\n }\n }\n buyerIsReceiver: boolean\n }\n }\n\n```" } ]
code_checkout-shipping_c83da653
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/machines/useAddressStateMachine.ts from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { useMachine } from '@xstate/react'\nimport { Router, routes } from 'vtex.checkout-container'\nimport { OrderShipping } from 'vtex.order-shipping'\nimport { AddressContext } from 'vtex.address-context'\nimport { assign } from 'xstate'\n\nimport addressStateMachine from './addressStateMachine'\nimport type { AddressMachineEvents } from './types'\nimport useMatcher from './useMatcher'\n\nconst { useHistory } = Router\nconst { useOrderShipping } = OrderShipping\nconst { useAddressContext } = AddressContext\n\nconst useAddressStateMachine = () => {\n const { updateSelectedAddress } = useOrderShipping()\n const { setAddress } = useAddressContext()\n\n const history = useHistory()\n\n const [state, send] = useMachine<unknown, AddressMachineEvents>(\n addressStateMachine,\n {\n devTools: true,\n actions: {\n goToNextStep: () => history.push(routes.PAYMENT),\n goToCreateAddress: () => {\n history.push(routes.SHIPPING)\n },\n updateSelectedAddress: assign((_, event) => {\n if (event.type === 'done.invoke.tryToUpdateCompleteAddress') {\n const updatedAddress = event.data.orderForm.shipping.selectedAddress\n\n setAddress(updatedAddress)\n\n return {}\n }\n\n return {}\n }),\n },\n services: {\n tryToUpdateCompleteAddress: async (_, event) => {\n if (event.type !== 'SUBMIT_EDIT_ADDRESS') {\n return\n }\n\n const result = await updateSelectedAddress(event.updatedAddress)\n\n return result\n },\n },\n }\n )\n\n const matches = useMatcher<unknown, AddressMachineEvents>(state)\n\n return { matches, send, state }\n}\n\nexport default useAddressStateMachine\n\n```" } ]
code_checkout-shipping_cf58addd
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/machines/useMatcher.ts from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { useCallback } from 'react'\nimport type { State, EventObject, Typestate } from 'xstate'\n\nconst useMatcher = <Context, Events extends EventObject>(\n state: State<Context, Events>\n) =>\n useCallback((params: Typestate<Context>['value']) => state.matches(params), [\n state,\n ])\n\nexport default useMatcher\n\n```" } ]
code_checkout-shipping_f21832f4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/machines/addressStateMachine.ts from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { Machine } from 'xstate'\n\nimport type { AddressMachineEvents } from './types'\n\nconst addressStateMachine = Machine<unknown, AddressMachineEvents>(\n {\n initial: 'editAddress',\n states: {\n editAddress: {\n initial: 'editing',\n states: {\n editing: {\n on: {\n SUBMIT_EDIT_ADDRESS: 'submitting',\n RESET_ADDRESS: {\n actions: 'goToCreateAddress',\n },\n },\n },\n submitting: {\n invoke: {\n src: 'tryToUpdateCompleteAddress',\n onDone: [\n {\n target: 'updateComplete',\n actions: 'updateSelectedAddress',\n },\n ],\n onError: 'editing',\n },\n },\n updateComplete: {\n type: 'final',\n },\n },\n\n onDone: 'done',\n },\n done: {\n entry: 'goToNextStep',\n },\n },\n },\n {\n actions: {\n goToNextStep: () => {},\n },\n }\n)\n\nexport default addressStateMachine\n\n```" } ]
code_checkout-shipping_74cb7a67
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of checkout-shipping/react/typings/@vtex/estimate-calculator.d.ts from the checkout-shipping VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '@vtex/estimate-calculator' {\n interface SLA {\n id: string\n shippingEstimate: string\n price: number\n }\n\n function getFastestSla(slas: SLA[]): SLA | undefined\n\n function getCheapestSla(slas: SLA[]): SLA | undefined\n}\n\n```" } ]
code_wine-meter_88a7ce11
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of wine-meter/messages/pt.json from the wine-meter VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/test\": \"teste\",\n \"store/test\": \"teste\"\n}\n```" } ]
code_wine-meter_0583ceb4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of wine-meter/messages/en.json from the wine-meter VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/test\": \"test\",\n \"store/test\": \"test\"\n}\n\n```" } ]
code_wine-meter_340bf76d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of wine-meter/messages/es.json from the wine-meter VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/test\": \"teste\",\n \"store/test\": \"teste\"\n}\n```" } ]
code_wine-meter_594899fa
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of wine-meter/docs/README.md from the wine-meter VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# WINE METER\n\n<!-- DOCS-IGNORE:start -->\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-)\nStefan Luntraru\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n<!-- DOCS-IGNORE:end -->\n\nConfigurable attributes should be created via admin, the canvas only requires coordinates.\n\n## Configuration \n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\nCanvas attributes : \nwinemeter_fructe\nwinemeter_dulceata\nwinemeter_aciditate\nwinemeter_tanini\n\nSpecs attributes :\nwinespec_decantare\nwinespec_invechire \nwinespec_temperatura\nwinespec_mancare\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- DOCS-IGNORE:start -->\n\n## Contributors ✨\n\nThanks goes to these wonderful people:\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\nStefan Luntraru\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\n<!-- DOCS-IGNORE:end -->\n\n```" } ]
code_wine-meter_b3245544
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of wine-meter/react/WineMeter.css from the wine-meter VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n/*========================================================================\n GENERAL STYLE\n==========================================================================*/\n.scalingSvgContainer {\n position: relative;\n display: block;\n margin: auto;\n width: 250px;\n height: 235px;\n margin-top: -20px;\n\n}\n\n.scalingSvg {\n position: absolute;\n height: 250px;\n width: 235px;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n}\n\n.labels {\n width: 250px;\n height: 235px;\n position: relative;\n top: -235px;\n margin: auto;\n z-index: 999;\n}\n\n\n.winemeter-logo {\n width: 75px;\n height: 50px;\n position: absolute;\n background: url(assets/winefulmeter.png);\n background-size: contain;\n background-repeat: no-repeat;\n top: 25px;\n left: 25px;\n}\n\n.graph{\n position: relative;\n display: block;\n margin: auto;\n max-width: 422px;\n width: 100%;\n padding: 25px;\n border: solid 1px #eaeaea;\n padding-top: 60px;\n}\n\n\n.pentagon {\n width: 250px;\n margin: auto;\n height: 235px;\n margin: auto;\n display: block;\n background-repeat: no-repeat;\n background-size: contain;\n background-position: center;\n padding: 25px;\n position: relative;\n top: -470px;\n margin-bottom: -450px;\n}\n\n.winemeter-winespecs {\n display: flex;\n flex-direction: row;\n justify-content: flex-start;\n align-items: flex-start;\n flex-wrap: wrap;\n}\n\n.winemeter-winespec_decantare,\n.winemeter-winespec_mancare,\n.winemeter-winespec_temperatura,\n.winemeter-winespec_invechire {\n max-width: 50%;\n width: 100%;\n margin-bottom: 30px;\n padding: 0 10px;\n padding-top: 90px;\n text-align: center;\n background-size: 79px 79px !important;\n background-repeat: no-repeat !important;\n background-position: center top !important;\n font-size: 12px;\n}\n\n.winemeter-winespec_decantare {\n background: url(assets/decantare.svg);\n}\n\n.winemeter-winespec_mancare {\n background: url(assets/mancare.svg);\n}\n\n.winemeter-winespec_temperatura {\n background: url(assets/temperatura.svg);\n}\n\n.winemeter-winespec_invechire {\n background: url(assets/timp.svg);\n}\n\n.winemeter-logo {\n width: 75px;\n height: 50px;\n position: absolute;\n background: url(assets/winefulmeter.png);\n background-size: contain;\n background-repeat: no-repeat;\n top: 25px;\n left: 25px;\n}\n\n.pentCanvas{\n margin-top: 2px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n\n.pentCanvas canvas {\n\n}\n\n.labelCorp{\n font-size: 11px;\n position: absolute;\n top: 20px;\n left: 50%;\n transform: translateX(-50%);\n}\n\n.labelTanini{\n font-size: 11px;\n position: absolute;\n top: 96px;\n left: -5px;\n}\n\n.labelAciditate{\n font-size: 11px;\n position: absolute;\n left: 30px;\n top:210px;\n}\n\n.labelDulceata{\n font-size: 11px;\n position: absolute;\n right: 30px;\n top:210px;\n}\n\n.labelFructe{\n font-size: 11px;\n position: absolute;\n top: 96px;\n right: -10px;\n}\n\n.cls1 {\n fill: none;\n stroke: #e5e6ea;\n stroke-miterlimit: 10;\n}\n\n.cls2 {\n fill: #e5e6ea;\n}\n\n```" } ]
code_wine-meter_68454abe
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of wine-meter/react/Greeting.test.tsx from the wine-meter VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { render } from '@vtex/test-tools/react'\n\nimport Greeting from './Greeting'\n\ntest('greets Fred', () => {\n const { queryByText } = render(<Greeting name=\"Fred\" />)\n\n expect(queryByText('Hey, Fred')).toBeInTheDocument()\n})\n\n```" } ]
code_wine-meter_9f9cd8d7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of wine-meter/react/WineMeter.tsx from the wine-meter VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { Circle, Line, Stage, Layer } from 'react-konva';\nimport { useProduct } from 'vtex.product-context';\nimport styles from './WineMeter.css'\n\nfunction filterByValue(array: any[] | undefined, string: string) {\n if (array) {\n return array.filter(o =>\n Object.keys(o).some(k => o[k].includes(string.toLowerCase())));\n }\n\n return null;\n}\n\nfunction arrayToObject(arr: any[] | undefined, key: string) {\n if (arr) {\n // @ts-ignore\n return arr.reduce((obj, item) => {\n obj[item[key]] = item\n return obj\n }, {})\n }\n\n return null;\n}\n\nfunction Specs(this: any) {\n const productContextValue = useProduct();\n const attributes = productContextValue?.product?.properties;\n const filteredObj = filterByValue(attributes, 'winespec');\n\n // @ts-ignore\n return filteredObj.map((item: any) => (\n <div className={'vtex-wine-meter-1-x-winemeter-' + item.name}>\n { item.values[0] }\n </div>\n ));\n}\n\nfunction Canvas(this: any) {\n var corpLat: number,\n corpLong: number,\n fructeLat: number,\n fructeLong: number,\n dulceataLat: number,\n dulceataLong: number,\n aciditateLat: number,\n aciditateLong: number,\n taniniLat: number,\n taniniLong: number;\n\n const productContextValue = useProduct();\n const ceva = productContextValue?.product?.properties;\n const produs = arrayToObject(ceva, 'name');\n\n switch (produs.winemeter_corp.values[0]) {\n case '5': corpLat = 89; corpLong = 0; break;\n case '4': corpLat = 89; corpLong = 19; break;\n case '3': corpLat = 89; corpLong = 38; break;\n case '2': corpLat = 89; corpLong = 54; break;\n case '1': corpLat = 89; corpLong = 70; break;\n default: corpLat = 0; corpLong = 0; break;\n }\n\n switch (produs.winemeter_fructe.values[0]) {\n case '5': fructeLat = 180; fructeLong = 63; break;\n case '4': fructeLat = 158; fructeLong = 68; break;\n case '3': fructeLat = 142; fructeLong = 74; break;\n case '2': fructeLat = 125; fructeLong = 79; break;\n case '1': fructeLat = 106; fructeLong = 82; break;\n default: fructeLat = 0; fructeLong = 0; break;\n }\n\n switch (produs.winemeter_dulceata.values[0]) {\n case '5': dulceataLat = 144; dulceataLong = 159; break;\n case '4': dulceataLat = 133; dulceataLong = 144; break;\n case '3': dulceataLat = 121; dulceataLong = 130; break;\n case '2': dulceataLat = 111; dulceataLong = 117; break;\n case '1': dulceataLat = 101; dulceataLong = 104; break;\n default: dulceataLat = 0; dulceataLong = 0; break;\n }\n\n switch (produs.winemeter_aciditate.values[0]) {\n case '5': aciditateLat = 34; aciditateLong = 159; break;\n case '4': aciditateLat = 45; aciditateLong = 144; break;\n case '3': aciditateLat = 57; aciditateLong = 130; break;\n case '2': aciditateLat = 67; aciditateLong = 118; break;\n case '1': aciditateLat = 78; aciditateLong = 105; break;\n default: aciditateLat = 0; aciditateLong = 0; break;\n }\n\n switch (produs.winemeter_tanini.values[0]) {\n case '5': taniniLat = 1; taniniLong = 64; break;\n case '4': taniniLat = 19; taniniLong = 69; break;\n case '3': taniniLat = 37; taniniLong = 73; break;\n case '2': taniniLat = 54; taniniLong = 78; break;\n case '1': taniniLat = 70; taniniLong = 84; break;\n default: taniniLat = 0; taniniLong = 0; break;\n }\n\n return (\n <Stage width={178} height={160}>\n <Layer>\n <Line\n x={0}\n y={0}\n points={[corpLat, corpLong, fructeLat, fructeLong, dulceataLat, dulceataLong, aciditateLat, aciditateLong, taniniLat, taniniLong]}\n closed\n stroke=\"black\"\n strokeWidth={0}\n fill=\"rgba(255, 221, 28, .5)\"\n />\n <Circle x={corpLat} y={corpLong} radius={50} fill=\"black\" width={10} height={10} />\n <Circle x={fructeLat} y={fructeLong} radius={50} fill=\"black\" width={10} height={10} />\n <Circle x={dulceataLat} y={dulceataLong} radius={50} fill=\"black\" width={10} height={10} />\n <Circle x={aciditateLat} y={aciditateLong} radius={50} fill=\"black\" width={10} height={10} />\n <Circle x={taniniLat} y={taniniLong} radius={50} fill=\"black\" width={10} height={10} />\n </Layer>\n </Stage>\n );\n}\n\nfunction WineMeter() {\n return (\n <div className={styles.graph} data-corp=\"3\" data-tanini=\"3\" data-fructe=\"4\" data-dulceata=\"3\" data-aciditate=\"3\">\n <div className=\"vtex-wine-meter-1-x-winemeter-logo\"/>\n <div className={styles.scalingSvgContainer}>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 321.27 286.32\" className={styles.scalingSvg}>\n <g id=\"Layer_2\" data-name=\"Layer 2\">\n <g id=\"Layer_2-2\" data-name=\"Layer 2\">\n <path className={styles.cls1}\n d=\"M157.4,39.56,41.88,119.91a5.67,5.67,0,0,0-2.12,6.52L83.26,251a5.67,5.67,0,0,0,5.35,3.8h144A5.67,5.67,0,0,0,238,251l43.5-124.58a5.67,5.67,0,0,0-2.12-6.52L163.87,39.56A5.67,5.67,0,0,0,157.4,39.56Z\"></path>\n <path className={styles.cls1}\n d=\"M157.88,65.12,67.53,128a4.82,4.82,0,0,0-1.8,5.54l34,97.42a4.82,4.82,0,0,0,4.55,3.23H217a4.82,4.82,0,0,0,4.55-3.23l34-97.42a4.82,4.82,0,0,0-1.8-5.54L163.39,65.12A4.82,4.82,0,0,0,157.88,65.12Z\"></path>\n <path className={styles.cls1}\n d=\"M158.21,89,91.53,135.39a4.25,4.25,0,0,0-1.59,4.89L115,212.1a4.25,4.25,0,0,0,4,2.85h83.21a4.25,4.25,0,0,0,4-2.85l25.08-71.82a4.25,4.25,0,0,0-1.59-4.89L163.06,89A4.25,4.25,0,0,0,158.21,89Z\"></path>\n <path className={styles.cls1}\n d=\"M158.69,110.87l-45.26,31.48a3.4,3.4,0,0,0-1.27,3.91l17,48.7a3.4,3.4,0,0,0,3.21,2.28h56.51A3.4,3.4,0,0,0,192.1,195l17-48.7a3.4,3.4,0,0,0-1.27-3.91l-45.26-31.48A3.4,3.4,0,0,0,158.69,110.87Z\"></path>\n <path className={styles.cls1}\n d=\"M159,133.61l-22.74,15.82a2.83,2.83,0,0,0-1.06,3.26L143.73,177a2.83,2.83,0,0,0,2.68,1.9h28.46a2.83,2.83,0,0,0,2.68-1.9L186,152.69a2.83,2.83,0,0,0-1.06-3.26l-22.74-15.82A2.83,2.83,0,0,0,159,133.61Z\"></path>\n </g>\n </g>\n </svg>\n </div>\n <div className={styles.labels}>\n <span data-toggle=\"tooltip\"\n title=\"Corpul vinului este dat de alcool si de extractul strugurelui. Cu cat vinul este mai corpolent, cu atat este mai dens.\"\n className={styles.labelCorp}>Corp</span>\n <span data-toggle=\"tooltip\"\n title=\"O concentratie mai mare de tanini, ofera vinului un gust putin amarui care ne “face gura punga”.\"\n className={styles.labelTanini}>Tanini</span>\n <span data-toggle=\"tooltip\"\n title=\"Nivelul fructelor determina daca vinul are gust si arome accentuate de fructe sau acestea lipsesc.\"\n className={styles.labelFructe}>Fructe</span>\n <span data-toggle=\"tooltip\"\n title=\"Nivelul de dulceata ofera vinului un gust mai dulce sau mai acrisor, chiar daca el este sec.\"\n className={styles.labelDulceata}>Dulceata</span>\n <span data-toggle=\"tooltip\"\n title=\"Aciditatea scazuta ofera vinului un gust “plat”, aciditatea mare un gust acrisor si astringent.\"\n className={styles.labelAciditate}>Aciditate</span>\n </div>\n <div className={styles.pentagon} id=\"5-factors\">\n <div className={styles.pentCanvas}>\n { Canvas() }\n </div>\n </div>\n <div className=\"vtex-wine-meter-1-x-winemeter-winespecs\">\n { Specs() }\n </div>\n </div>\n )\n}\n\nexport default WineMeter;\n\n```" } ]
code_wine-meter_aaf00b93
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of wine-meter/react/package.json from the wine-meter VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"wine-meter\",\n \"version\": \"1.0.1\",\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"apollo-client\": \"^2.6.8\",\n \"konva\": \"^8.3.1\",\n \"react\": \"^16.12.0\",\n \"react-apollo\": \"^3.1.3\",\n \"react-dom\": \"^16.12.0\",\n \"react-konva\": \"^17.0.2-5\",\n \"react-polygon\": \"^0.2.0\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^3.1.3\",\n \"@types/jest\": \"^25.1.4\",\n \"@types/node\": \"^13.9.8\",\n \"@types/prop-types\": \"^15.7.0\",\n \"@types/ramda\": \"^0.26.5\",\n \"@types/react\": \"^16.9.31\",\n \"@types/react-intl\": \"^3.0.0\",\n \"@vtex/test-tools\": \"^3.3.2\",\n \"@vtex/tsconfig\": \"^0.4.4\",\n \"apollo-cache-inmemory\": \"^1.6.5\",\n \"graphql\": \"^14.6.0\",\n \"react-intl\": \"^3.12.0\",\n \"typescript\": \"3.9.7\",\n \"vtex.product-context\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.product-context@0.10.0/public/@types/vtex.product-context\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.132.3/public/@types/vtex.render-runtime\"\n }\n}\n\n```" } ]
code_wine-meter_aa1670ea
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of wine-meter/react/Greeting.tsx from the wine-meter VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\ntype Props = {\n name: string\n}\n\nfunction Greeting({ name }: Props) {\n return <div>Hey, {name}</div>\n}\n\nexport default Greeting\n\n```" } ]
code_wine-meter_149cefd4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of wine-meter/store/interfaces.json from the wine-meter VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"wine-meter\": {\n \"component\": \"WineMeter\",\n \"composition\": \"children\"\n }\n}\n\n```" } ]
code_wine-meter_7188f42c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of wine-meter/react/typings/gql.d.ts from the wine-meter VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.gql' {\n import { DocumentNode } from 'graphql'\n\n const Schema: DocumentNode\n\n export default Schema\n}\n\ndeclare module '*.graphql' {\n import { DocumentNode } from 'graphql'\n\n const schema: DocumentNode\n\n export default Schema\n}\n\n```" } ]
code_wine-meter_9b6e4bf8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of wine-meter/react/typings/css.d.ts from the wine-meter VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n type Styles = {\n [selector: string]: string\n }\n\n const styles: Styles\n\n export default styles\n}\n\n```" } ]
code_proxy-mailing-flow_71fc2ea5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of proxy-mailing-flow/docs/README.md from the proxy-mailing-flow VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Proxy Mailing Flow v3\n\nThis service allows you to handling the mailing to be able to cancel and generate orders without repeating notifications to the user.\n\n## Flows\n\nWith this application you can customize the emails when the orders pass through the `order-created` and `invoiced` states. You also can skip notifications to the user when the order is created adding a custom app (in custom data) to the order, this custom app must have an `\"id\": \"origin\"`.\n\n## Settings fields\nThere are 6 fields to complete for configure the app.\n- Default email: is the email for mailing flows that doesn’t find any seller.\n\n- Subscriber MasterData Entity List: here you can define one (at least) or more data entity acronyms for the subscribers to the mailing flow (example: seller and supervisor).\n\n- Client Mailing Template Name (order-created): is the name of the message-\t\tcenter template url.\n\n- Client Mailing Template Name (invoiced): is the name of the message-center template url.\n\n- Subscribers Mailing Template Name (order-created): is the name of the message-center template url.\n\n- Subscribers Mailing Template Name (invoiced): is the name of the message-center template url.\n\nYou can see how to modify the templates [**here**](https://developers.vtex.com/vtex-rest-api/docs/how-to-set-up-functions-in-the-message-center-templates)\n\n![Settings fields](https://user-images.githubusercontent.com/55720621/135907990-74d3fd11-e2fb-4232-9a79-e26772f71dba.png)\n## Steps by step:\n1. First you have to [**disable transactional emails**](https://help.vtex.com/en/tutorial/how-to-disable-a-transactional-email--frequentlyAskedQuestions_6715). \n2. You need to install this app running `vtex install vtexarg.proxy-mailing-flow@3.x` command on the *vtex toolbelt*.\n3. Then you must hook the order status changes to this service. You can see how to do this [**here**](https://developers.vtex.com/vtex-rest-api/reference/order-hook-1#hookconfiguration) (you need admin super roll). Here the body example:\n > {\n > \"filter\": {\n > \"type\": \"FromWorkflow\",\n > \"status\": [\"order-created\", \"invoiced\"]\n > },\n > \"hook\": {\n > \"url\": \"https://{{accountName}}.myvtex.com/_v/proxy-mailing-flow/\"\n > }\n > }\n4. Configure the settings fields of the app in the link `https://{{account}}.myvtex.com/admin/apps/vtexarg.proxy-mailing-flow@3.x/setup`.\n\n```" } ]
code_proxy-mailing-flow_f85f1dbc
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of proxy-mailing-flow/node/service.json from the proxy-mailing-flow VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"memory\": 256,\n \"ttl\": 10,\n \"timeout\": 2,\n \"minReplicas\": 2,\n \"maxReplicas\": 4,\n \"workers\": 1,\n \"routes\": {\n \"status\": {\n \"path\": \"/_v/proxy-mailing-flow/\",\n \"public\": true\n }\n }\n}\n\n```" } ]
code_proxy-mailing-flow_fbc37c96
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of proxy-mailing-flow/node/package.json from the proxy-mailing-flow VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"@vtex/clients\": \"^2.13.0\",\n \"co-body\": \"^6.0.0\",\n \"ramda\": \"^0.25.0\"\n },\n \"devDependencies\": {\n \"@types/co-body\": \"^0.0.3\",\n \"@types/jest\": \"^24.0.18\",\n \"@types/node\": \"^12.0.0\",\n \"@types/ramda\": \"types/npm-ramda#dist\",\n \"@vtex/api\": \"6.45.4\",\n \"@vtex/test-tools\": \"^1.0.0\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"typescript\": \"3.9.7\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty\"\n },\n \"version\": \"3.0.7\"\n}\n\n```" } ]
code_proxy-mailing-flow_e9cd606f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of proxy-mailing-flow/node/index.ts from the proxy-mailing-flow VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { ClientsConfig, ServiceContext, RecorderState } from '@vtex/api'\nimport { LRUCache, method, Service } from '@vtex/api'\n\nimport { Clients } from './clients'\nimport { sendEmail } from './middlewares/sendEmail'\nimport { getOrder } from './middlewares/getOrder'\nimport { getClientData } from './middlewares/getClientData'\nimport { pong } from './middlewares/pong'\n\nconst TIMEOUT_MS = 800\n\nconst memoryCache = new LRUCache<string, any>({ max: 5000 })\n\nmetrics.trackCache('status', memoryCache)\n\nconst clients: ClientsConfig<Clients> = {\n implementation: Clients,\n options: {\n default: {\n retries: 2,\n timeout: TIMEOUT_MS,\n },\n status: {\n memoryCache,\n },\n },\n}\n\ndeclare global {\n type Context = ServiceContext<Clients, State>\n interface ClientProfileDataInterface {\n email: string\n customerClass: string\n }\n interface OrderResponseInterface {\n orderId: string\n clientProfileData: ClientProfileDataInterface\n customData: CustomDataInterface\n marketingData: MarketingDataInterface\n }\n interface BodyInterface {\n State: string\n OrderId: string\n hookConfig: string\n }\n interface CustomDataInterface {\n customApps: [CustomFieldInterface]\n }\n interface MarketingDataInterface {\n marketingTags: string[]\n }\n interface CustomFieldInterface {\n id: string\n }\n interface State extends RecorderState {\n orderResponse: OrderResponseInterface\n body: BodyInterface\n emails: { clientEmail: string; subsEmails: string[] }\n flow: string\n }\n}\n\nexport default new Service({\n clients,\n routes: {\n status: method({\n POST: [pong, getOrder, getClientData, sendEmail],\n }),\n },\n})\n\n```" } ]
code_proxy-mailing-flow_910796ac
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of proxy-mailing-flow/node/clients/masterdata.ts from the proxy-mailing-flow VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { ExternalClient } from '@vtex/api'\n\nexport default class Masterdata extends ExternalClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(\n `http://${context.account}.vtexcommercestable.com.br/api/dataentities/CL/search`,\n context,\n {\n ...options,\n headers: {\n VtexIdClientAutCookie: context.authToken,\n 'X-Vtex-Use-Https': 'true',\n },\n }\n )\n }\n\n public async getClientData(\n customerClass: string,\n agente: string\n ): Promise<ClientData[]> {\n return this.http.get(`?customerClass=${customerClass}&agente=${agente}`)\n }\n}\n\nexport interface ClientData {\n email: string\n}\n\n```" } ]
code_proxy-mailing-flow_ef792f51
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of proxy-mailing-flow/node/clients/email.ts from the proxy-mailing-flow VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext, IOResponse } from '@vtex/api'\nimport { ExternalClient } from '@vtex/api'\n\nexport default class Email extends ExternalClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(\n `http://${context.account}.vtexcommercestable.com.br/api/mail-service/pvt/sendmail`,\n context,\n {\n ...options,\n headers: {\n VtexIdClientAutCookie: context.authToken,\n },\n }\n )\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-types\n public async sendEmail(body: BodyEmail): Promise<IOResponse<String>> {\n return this.http.postRaw('', body)\n }\n}\n\nexport interface BodyEmail {\n providerName: string\n templateName: string\n jsonData: JsonData\n}\n\nexport interface JsonData {\n to?: string\n orders?: unknown[]\n clientProfileData?: {\n email?: string\n }\n}\n\n```" } ]
code_proxy-mailing-flow_df024ed8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of proxy-mailing-flow/node/clients/orders.ts from the proxy-mailing-flow VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext, IOResponse } from '@vtex/api'\nimport { ExternalClient } from '@vtex/api'\n\nexport default class OrdersClient extends ExternalClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(\n `http://${context.account}.vtexcommercestable.com.br/api/oms/pvt/orders`,\n context,\n {\n ...options,\n headers: {\n VtexIdClientAutCookie: context.authToken,\n 'X-Vtex-Use-Https': 'true',\n },\n }\n )\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-types\n public async getOrder(orderId: string): Promise<IOResponse<String>> {\n return this.http.getRaw(`${orderId}`)\n }\n}\n\n```" } ]
code_proxy-mailing-flow_eb6b7393
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of proxy-mailing-flow/node/clients/index.ts from the proxy-mailing-flow VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\n\nimport Masterdata from './masterdata'\nimport Email from './email'\nimport OrdersClient from './orders'\n\nexport class Clients extends IOClients {\n public get orders() {\n return this.getOrSet('orders', OrdersClient)\n }\n\n public get masterdataclient() {\n return this.getOrSet('getClientData', Masterdata)\n }\n\n public get email() {\n return this.getOrSet('sendEmail', Email)\n }\n}\n\n```" } ]
code_proxy-mailing-flow_ee4d56eb
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of proxy-mailing-flow/node/middlewares/getClientData.ts from the proxy-mailing-flow VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* eslint-disable no-console */\nimport { LogLevel } from '@vtex/api'\n\nimport type { ClientData } from '../clients/masterdata'\n\nexport async function getClientData(ctx: Context, next: () => Promise<any>) {\n const {\n state: { orderResponse },\n clients: { masterdataclient },\n } = ctx\n\n try {\n const appId = process.env.VTEX_APP_ID ? process.env.VTEX_APP_ID : ''\n const settings = await ctx.clients.apps.getAppSettings(appId)\n const { subscriberEntityList, defaultEmail } = settings\n const subscriberEntityListParsed = subscriberEntityList.split(',')\n const { customerClass } = orderResponse.clientProfileData\n const { marketingTags } = orderResponse.marketingData\n\n const subscriberPromises: Array<Promise<ClientData[]>> =\n subscriberEntityListParsed.map((sub: string) => {\n const customerClassTag = marketingTags.find((tag: string) =>\n tag.includes('customerClass')\n )\n\n console.log('customerClassTag', customerClassTag)\n\n ctx.vtex.logger.log(\n {\n message: 'customerClassTag',\n detail: {\n customerClassTag: customerClassTag\n },\n },\n LogLevel.Info\n )\n\n if (!customerClassTag) {\n return masterdataclient.getClientData(customerClass, sub)\n }\n\n // eslint-disable-next-line prefer-destructuring\n const ccFromMarketingTags = customerClassTag.split('customerClass-')[1]\n\n console.log('ccFromMarketingTags', ccFromMarketingTags)\n\n ctx.vtex.logger.log(\n {\n message: 'ccFromMarketingTags',\n detail: {\n ccFromMarketingTags: ccFromMarketingTags\n },\n },\n LogLevel.Info\n )\n\n return masterdataclient.getClientData(ccFromMarketingTags, sub)\n })\n\n const subscribers: ClientData[][] = await Promise.all(subscriberPromises)\n\n const subscriberEmails: string[][] = subscribers.map(\n (sub: ClientData[]) => {\n const aux: string[] = []\n\n sub.forEach((user: ClientData) => aux.push(user.email))\n\n // sub.map((user: ClientData) => user.email)\n return aux\n }\n )\n\n const subscribersEmailsFlat: any[] = []\n\n subscriberEmails.forEach((group: string[]) => {\n subscribersEmailsFlat.push(...group)\n })\n\n console.log({ subscribersEmailsFlat })\n console.log({ defaultEmail })\n const subsEmails =\n subscribersEmailsFlat.length > 0 ? subscribersEmailsFlat : [defaultEmail]\n\n console.log({ subsEmails })\n const emails = {\n clientEmail: orderResponse.clientProfileData.email,\n subsEmails,\n }\n\n console.log('emails', emails)\n\n ctx.state.emails = emails\n\n ctx.vtex.logger.log(\n {\n message: 'getClientData Info',\n detail: {\n appId,\n settings,\n customerClass,\n emails,\n },\n },\n LogLevel.Info\n )\n\n await next()\n } catch (err) {\n ctx.vtex.logger.log(\n {\n message: 'getClientData Error',\n detail: {\n errorMessage: err.message,\n error: err,\n },\n },\n LogLevel.Error\n )\n\n ctx.status = 500\n ctx.body = { error: 'Error sending email', message: err }\n\n await next()\n }\n}\n\n```" } ]
code_proxy-mailing-flow_6c62843e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of proxy-mailing-flow/node/middlewares/pong.ts from the proxy-mailing-flow VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* eslint-disable no-console */\nimport { json } from 'co-body'\nimport { LogLevel } from '@vtex/api'\n\nexport async function pong(ctx: Context, next: () => Promise<any>) {\n const body = await json(ctx.req)\n\n ctx.state.body = body\n ctx.state.flow = 'Init'\n\n ctx.vtex.logger.log(\n {\n message: 'Init',\n detail: {\n receivedBody: body,\n },\n },\n LogLevel.Info\n )\n\n console.log({\n message: 'Init',\n detail: {\n receivedBody: body,\n },\n })\n\n if (body.hookConfig) {\n ctx.vtex.logger.log(\n {\n message: 'Ping received',\n },\n LogLevel.Info\n )\n\n ctx.state.flow = 'Pong'\n ctx.status = 200\n ctx.body = { response: 'pong' }\n\n return\n }\n\n await next()\n}\n\n```" } ]
code_proxy-mailing-flow_a0f0191c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of proxy-mailing-flow/node/middlewares/sendEmail.ts from the proxy-mailing-flow VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/ban-types */\n/* eslint-disable no-console */\nimport type { IOResponse } from '@vtex/api'\nimport { LogLevel } from '@vtex/api'\n\nimport type { BodyEmail, JsonData } from '../clients/email'\n\nexport async function sendEmail(ctx: Context, next: () => Promise<any>) {\n const {\n state: { orderResponse, emails, flow },\n clients: { email },\n } = ctx\n\n ctx.vtex.logger.log(\n {\n message: 'sendEmail emails',\n detail: {\n emails,\n },\n },\n LogLevel.Info\n )\n\n ctx.vtex.logger.log(\n {\n message: 'sendEmail flow',\n detail: {\n flow,\n },\n },\n LogLevel.Info\n )\n\n try {\n const emailBodyBuilder = (\n providerName: string,\n templateName: string,\n jsonData: JsonData\n ) => {\n return {\n providerName,\n templateName,\n jsonData,\n }\n }\n\n const appId = process.env.VTEX_APP_ID ? process.env.VTEX_APP_ID : ''\n const {\n clientTemplateCreated,\n clientTemplateInvoiced,\n subscribersTemplateCreated,\n subscribersTemplateInvoiced,\n } = await ctx.clients.apps.getAppSettings(appId)\n\n const subscribers = emails.subsEmails\n\n let emailBodyClient: BodyEmail\n\n if (flow === 'Invoiced') {\n emailBodyClient = emailBodyBuilder(\n 'noreply',\n clientTemplateInvoiced,\n orderResponse\n )\n } else {\n emailBodyClient = emailBodyBuilder('noreply', clientTemplateCreated, {\n to: emails.clientEmail,\n orders: [orderResponse],\n })\n }\n\n const emailBodySubscribersList: BodyEmail[] = subscribers.map(\n (sub: string) => {\n if (flow === 'Invoiced') {\n const clientProfileDataSub = { ...orderResponse.clientProfileData }\n const orderResponseSub = { ...orderResponse }\n\n clientProfileDataSub.email = sub\n orderResponseSub.clientProfileData = clientProfileDataSub\n\n return emailBodyBuilder(\n 'noreply',\n subscribersTemplateInvoiced,\n orderResponseSub\n )\n }\n\n return emailBodyBuilder('noreply', subscribersTemplateCreated, {\n to: sub,\n orders: [orderResponse],\n })\n }\n )\n\n const emailResponseClient: IOResponse<String> = await email.sendEmail(\n emailBodyClient\n )\n\n const emailResponseSubs: EmailResponseSubs[] = await Promise.all(\n emailBodySubscribersList.map(async (body: BodyEmail) => {\n const aux = await email.sendEmail(body)\n\n ctx.vtex.logger.log(\n {\n message: 'sendEmail aux email.sendEmail',\n detail: {\n response: aux,\n },\n },\n LogLevel.Info\n )\n\n if (flow === 'Invoiced') {\n return {\n status: aux.status,\n data: aux.data,\n email: body?.jsonData?.clientProfileData?.email,\n }\n }\n\n return {\n status: aux.status,\n data: aux.data,\n email: body?.jsonData?.to,\n }\n })\n )\n\n const response = {\n orderId: orderResponse.orderId,\n response: [\n ...emailResponseSubs,\n {\n status: emailResponseClient.status,\n data: emailResponseClient.data,\n email: emails.clientEmail,\n },\n ],\n }\n\n ctx.vtex.logger.log(\n {\n message: 'sendEmail Info',\n detail: {\n response: response,\n },\n },\n LogLevel.Info\n )\n\n console.log('orderId send email', response.orderId)\n console.log('email operations', response.response)\n\n ctx.status = 200\n ctx.body = response\n ctx.state.flow =\n flow === 'Invoiced' ? 'EmailSent-Invoiced' : 'EmailSent-Created'\n\n await next()\n } catch (err) {\n ctx.vtex.logger.log(\n {\n message: 'sendEmail Error',\n detail: {\n emails: emails,\n order: orderResponse,\n errorMessage: err.message,\n error: err,\n },\n },\n LogLevel.Error\n )\n\n ctx.status = 500\n ctx.body = { error: 'Error sending email', message: err }\n\n await next()\n }\n}\n\ninterface EmailResponseSubs {\n status: number\n data: String\n email: string | undefined\n}\n\n```" } ]
code_proxy-mailing-flow_aabbe8dd
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of proxy-mailing-flow/node/middlewares/getOrder.ts from the proxy-mailing-flow VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { LogLevel } from '@vtex/api'\n\nexport async function getOrder(ctx: Context, next: () => Promise<any>) {\n const {\n state: { body },\n clients: { orders },\n } = ctx\n\n ctx.state.flow = 'GetOrderInit'\n\n try {\n if (body.State === 'order-created') {\n ctx.state.flow = 'OrderCreated'\n\n const orderResponse: any = await orders.getOrder(body.OrderId)\n\n ctx.state.orderResponse = orderResponse.data\n\n if (!orderResponse.data.customData) {\n ctx.state.flow = 'OrderCreatedWithoutOrigin'\n ctx.state.orderResponse = orderResponse.data\n\n ctx.vtex.logger.log(\n {\n message: 'getOrder no custom data',\n detail: {\n customData: orderResponse.data.customData,\n },\n },\n LogLevel.Info\n )\n\n await next()\n } else {\n const custom = orderResponse.data.customData.customApps.find(\n (e: any) => e.id === 'origin'\n )\n\n if (!custom) {\n ctx.state.flow = 'OrderCreatedWithoutOrigin'\n ctx.state.orderResponse = orderResponse.data\n\n ctx.vtex.logger.log(\n {\n message: 'getOrder order created without origin',\n detail: {\n customApp: custom,\n },\n },\n LogLevel.Info\n )\n\n await next()\n } else {\n ctx.state.flow = 'OrderCreatedWithOrigin'\n ctx.body = {\n message: 'No Invoiced or OrderCreatedWithoutOrigin => No Email',\n }\n ctx.status = 200\n\n ctx.vtex.logger.log(\n {\n message: 'getOrder order created with origin',\n detail: {\n customApp: custom,\n },\n },\n LogLevel.Info\n )\n\n return\n }\n }\n } else {\n ctx.state.flow = 'Invoiced'\n const orderResponse: any = await orders.getOrder(body.OrderId)\n\n ctx.state.orderResponse = orderResponse.data\n\n ctx.vtex.logger.log(\n {\n message: 'getOrder invoiced',\n },\n LogLevel.Info\n )\n\n await next()\n }\n } catch (err) {\n ctx.vtex.logger.log(\n {\n message: 'getOrder Error',\n detail: {\n errorMessage: err.message,\n error: err,\n },\n },\n LogLevel.Error\n )\n\n ctx.status = 500\n ctx.body = { message: err }\n\n await next()\n }\n}\n\n```" } ]
code_proxy-mailing-flow_bec29b8e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of proxy-mailing-flow/node/__tests__/simple.test.ts from the proxy-mailing-flow VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n// You can import your files here for testing them\n//\n// More info: https://github.com/sapegin/jest-cheat-sheet\n\ndescribe('simpleTest', () => {\n it('one test case', async () => {\n expect(0.2 + 0.1).not.toBe(0.3)\n })\n})\n\n```" } ]
code_breadcrumb_bc878ff5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/messages/pt.json from the breadcrumb VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/breadcrumb.homeLink\": \"Link de Início\"\n}\n```" } ]
code_breadcrumb_738f7d68
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/messages/es.json from the breadcrumb VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/breadcrumb.homeLink\": \"Enlace de Inicio\"\n}\n```" } ]
code_breadcrumb_19d22b7a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/docs/README.md from the breadcrumb VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/vtex-apps/breadcrumb) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\n# Breadcrumb\n\nThe VTEX BreadCrumb is a navigation scheme that shows a user's browsing history up to their current location in your store.\n\n![img2-breadcrumb](https://user-images.githubusercontent.com/52087100/69836587-a4237380-1228-11ea-89c8-0f34cea3a96f.png)\n\n## Configuration\n\n1. Import the breadcrumb's app to your theme's dependencies in the `manifest.json`, for example:\n\n```json\n dependencies: {\n \"vtex.breadcrumb\": \"1.x\"\n }\n```\n\n2. Add the `breadcrumb` block to the Product template. For example:\n\n```\n \"breadcrumb\": {\n \"props\": {\n \"showOnMobile\": true\n }\n },\n```\n\n| Prop name | Type | Description | Default value |\n| ------------ | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | \n| `showOnMobile` | `Boolean` | It determines whether Breadcrumb should also be displayed on mobile | `false` |\n| `homeIconSize` | `Number` | Controls the `size` property of [`IconHome`](https://github.com/vtex-apps/store-icons#icons) | `26` |\n| `caretIconSize` | `Number` | Controls the `size` property of [`IconCaret`](https://github.com/vtex-apps/store-icons#icons) | `8` |\n\n:warning: The product's categories should appear as an array in one of this two formats:\n\n```javascript\ncategories = ['/Eletronics/', '/Eletronics/Computers']\n```\n\n```javascript\ncategories = ['eletronics', 'eletronics-computers']\n```\n\n3. Add the `breadcrumb.search` block to the Search template. For example:\n\n```\n \"breadcrumb.search\": {\n \"props\": {\n \"showOnMobile\": true\n }\n },\n```\n\n| Prop name | Type | Description | Default value |\n| ------------ | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | \n| `showOnMobile` | `Boolean` | It determines whether Breadcrumb should also be displayed on mobile | `false` |\n| `homeIconSize` | `Number` | Controls the `size` property of [`IconHome`](https://github.com/vtex-apps/store-icons#icons) | `26` |\n| `caretIconSize` | `Number` | Controls the `size` property of [`IconCaret`](https://github.com/vtex-apps/store-icons#icons) | `8` |\n> ℹ️ *The `breadcrumb.search` block is specific for the Breadcrumb inside the search result page.* \n\n## Customization\n\nIn order to apply CSS customizations in this and other blocks, follow the instructions given in the recipe on [Using CSS Handles for store customization](https://vtex.io/docs/recipes/style/using-css-handles-for-store-customization). \n\n| CSS Handles |\n| ----------- | \n| `container` | \n| `link` | \n| `arrow` | \n| `homeLink` | \n| `termArrow` |\n\n\n## Contributors ✨\n\nThanks goes to these wonderful people:\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- 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_breadcrumb_e6f76d2b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/react/Breadcrumb.tsx from the breadcrumb VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { useProduct } from 'vtex.product-context'\nimport { ProductBreadcrumb as ProductBreadcrumbStructuredData } from 'vtex.structured-data'\n\nimport BaseBreadcrumb, { Props } from './components/BaseBreadcrumb'\n\nconst withProductContextWrapper = (\n Component: React.ComponentType<Props>\n): React.FC<Props> => (props) => {\n const { product } = useProduct() || { product: null }\n const term = props.term ?? product?.productName\n const categoryTree = props.categoryTree ?? product?.categoryTree\n const categories = props.categories ?? product?.categories ?? []\n\n return (\n <>\n {product?.linkText && (\n <ProductBreadcrumbStructuredData\n categoryTree={categoryTree}\n productName={product?.productName}\n productSlug={product?.linkText}\n />\n )}\n <Component\n term={term}\n categories={categories}\n categoryTree={categoryTree}\n breadcrumb={props.breadcrumb}\n showOnMobile={props.showOnMobile}\n homeIconSize={props.homeIconSize}\n caretIconSize={props.caretIconSize}\n />\n </>\n )\n}\n\nexport default withProductContextWrapper(BaseBreadcrumb)\n\n```" } ]
code_breadcrumb_44552bb7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/react/package.json from the breadcrumb VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.breadcrumbs\",\n \"description\": \"A Breadcrumb component.\",\n \"scripts\": {\n \"test\": \"vtex-test-tools test\",\n \"lint\": \"tsc --noEmit --pretty && tslint -c tslint.json './**/*.ts'\"\n },\n \"author\": \"VTEX\",\n \"license\": \"ISC\",\n \"dependencies\": {\n \"react\": \"^16.3.1\",\n \"react-dom\": \"^16.3.1\",\n \"unorm\": \"^1.4.1\",\n \"react-apollo\": \"^3.1.3\",\n \"react-intl\": \"3\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^4.0.0\",\n \"@types/jest\": \"^25.1.4\",\n \"@types/node\": \"^11.9.6\",\n \"@types/ramda\": \"^0.26.8\",\n \"@types/react\": \"^16.4.18\",\n \"@types/react-dom\": \"^16.0.9\",\n \"@types/unorm\": \"^1.3.27\",\n \"@vtex/test-tools\": \"^3.2.0\",\n \"@vtex/tsconfig\": \"^0.4.4\",\n \"apollo-cache-inmemory\": \"^1.2.2\",\n \"graphql\": \"^14.6.0\",\n \"typescript\": \"3.9.7\",\n \"vtex.css-handles\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.css-handles@0.4.2/public/@types/vtex.css-handles\",\n \"vtex.device-detector\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.device-detector@0.2.4/public/@types/vtex.device-detector\",\n \"vtex.product-context\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.product-context@0.8.1/public/@types/vtex.product-context\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.111.1/public/@types/vtex.render-runtime\",\n \"vtex.search-page-context\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.search-page-context@0.0.3/public/_types/react\",\n \"vtex.store-icons\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-icons@0.17.0/public/@types/vtex.store-icons\",\n \"vtex.structured-data\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.structured-data@0.5.0/public/@types/vtex.structured-data\"\n },\n \"version\": \"1.9.5\"\n}\n\n```" } ]
code_breadcrumb_41db9028
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/react/SearchBreadcrumb.tsx from the breadcrumb VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport SearchBreadcrumb from './components/SearchBreadcrumb'\n\nexport default SearchBreadcrumb\n\n```" } ]
code_breadcrumb_e86e4025
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/react/ProductBreadcumb.tsx from the breadcrumb VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport ProductBreadcrumb from './components/ProductBreadcrumb'\n\nexport default ProductBreadcrumb\n\n```" } ]
code_breadcrumb_cac6204e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/store/interfaces.json from the breadcrumb VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"breadcrumb\": {\n \"component\": \"Breadcrumb\"\n },\n \"breadcrumb.product\": {\n \"component\": \"ProductBreadcrumb\"\n },\n \"breadcrumb.search\": {\n \"component\": \"SearchBreadcrumb\"\n }\n}\n\n```" } ]
code_breadcrumb_58532271
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/react/typings/render.d.ts from the breadcrumb VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* Typings for `render-runtime` */\ndeclare module 'vtex.render-runtime' {\n import { Component, ReactElement } from 'react'\n\n export interface NavigationOptions {\n page: string\n params?: any\n }\n\n export interface RenderContextProps {\n runtime: {\n navigate: (options: NavigationOptions) => void\n }\n }\n\n export const ExtensionPoint: ReactElement\n export const Helmet: ReactElement\n export const Link: ComponentType<any>\n export const NoSSR: ReactElement\n export const RenderContextConsumer: ReactElement\n export const canUseDOM: boolean\n export const withRuntimeContext: <TOriginalProps extends {}>(\n Component: ComponentType<TOriginalProps & RenderContextProps>\n ) => ComponentType<TOriginalProps>\n\n export const withSession: <TOriginalProps extends {}>(\n Component: ComponentType<TOriginalProps & RenderContextProps>\n ) => ComponentType<TOriginalProps>\n\n export const buildCacheLocator = (\n app: string,\n type: string,\n cacheId: string\n ) => string\n\n interface RenderComponent<P = {}, S = {}> extends Component<P, S> {\n getCustomMessages?: (locale: string) => any\n schema: ComponentSchema\n getSchema?: (a: any, b: ?any) => ComponentSchema\n uiSchema: UISchema\n }\n\n export interface ComponentsRegistry {\n [component: string]: RenderComponent<any, any>\n }\n\n export interface Window extends Window {\n __RENDER_7_COMPONENTS__: ComponentsRegistry\n }\n\n let global: Window\n}\n\n```" } ]
code_breadcrumb_8aeba131
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/react/typings/css.d.ts from the breadcrumb 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_breadcrumb_b6a9e8d5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/react/components/BaseBreadcrumb.tsx from the breadcrumb VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment, useMemo } from 'react'\nimport unorm from 'unorm'\nimport { useIntl } from 'react-intl'\nimport { Link } from 'vtex.render-runtime'\nimport { useCssHandles, applyModifiers } from 'vtex.css-handles'\nimport { IconCaret, IconHome } from 'vtex.store-icons'\nimport { useDevice } from 'vtex.device-detector'\n\nconst CSS_HANDLES = [\n 'container',\n 'link',\n 'homeLink',\n 'arrow',\n 'term',\n 'termArrow',\n] as const\n\nexport interface NavigationItem {\n name: string\n href: string\n}\n\nexport interface Props {\n term?: string\n /** Shape [ '/Department' ,'/Department/Category'] */\n categories: string[]\n categoryTree?: NavigationItem[]\n breadcrumb?: NavigationItem[]\n showOnMobile?: boolean\n homeIconSize?: number\n caretIconSize?: number\n}\n\nconst makeLink = (str: string) =>\n unorm\n .nfd(str)\n .toLowerCase()\n .replace(/[\\u0300-\\u036f]/g, '')\n .trim()\n .replace(/[-\\s]+/g, '-')\n\nconst getCategoriesList = (categories: string[]): NavigationItem[] => {\n const categoriesSorted = categories\n .slice()\n .sort((a, b) => a.length - b.length)\n\n return categoriesSorted.map((category) => {\n const categoryStripped = category.replace(/^\\//, '').replace(/\\/$/, '')\n const currentCategories = categoryStripped.split('/')\n const [categoryKey] = currentCategories.reverse()\n const linkCompletion = currentCategories.length === 1 ? '/d' : ''\n const href = `/${makeLink(categoryStripped)}${linkCompletion}`\n\n return {\n href,\n name: categoryKey,\n }\n })\n}\n\n/**\n * Breadcrumb Component.\n */\nconst Breadcrumb: React.FC<Props> = ({\n term,\n categories,\n categoryTree,\n breadcrumb,\n showOnMobile = false,\n homeIconSize = 26,\n caretIconSize = 8,\n}) => {\n const intl = useIntl()\n const handles = useCssHandles(CSS_HANDLES)\n const { isMobile } = useDevice()\n const navigationList = useMemo(\n () => breadcrumb ?? categoryTree ?? getCategoriesList(categories),\n [breadcrumb, categories, categoryTree]\n )\n\n const linkBaseClasses = 'dib pv1 link ph2 c-muted-2 hover-c-link'\n const shouldBeRendered = (showOnMobile && isMobile) || !isMobile\n\n if (!navigationList.length || !shouldBeRendered) {\n return null\n }\n\n return (\n <div data-testid=\"breadcrumb\" className={`${handles.container} pv3`}>\n <Link\n className={`${handles.link} ${handles.homeLink} ${linkBaseClasses} v-mid`}\n page=\"store.home\"\n aria-label={intl.formatMessage({\n id: 'store/breadcrumb.homeLink',\n })}\n >\n <IconHome size={homeIconSize} />\n </Link>\n {navigationList.map(({ name, href }, i) => {\n let decodedName = ''\n\n try {\n decodedName = decodeURIComponent(name)\n } catch {\n decodedName = name\n }\n\n return (\n <span\n key={`navigation-item-${i}`}\n className={`${applyModifiers(\n handles.arrow,\n (i + 1).toString()\n )} ph2 c-muted-2`}\n >\n <IconCaret orientation=\"right\" size={caretIconSize} />\n <Link\n className={`${applyModifiers(\n handles.link,\n (i + 1).toString()\n )} ${linkBaseClasses}`}\n to={href}\n // See https://github.com/vtex-apps/breadcrumb/pull/66 for the reasoning behind this\n waitToPrefetch={1200}\n >\n {decodedName}\n </Link>\n </span>\n )\n })}\n\n {term && (\n <Fragment>\n <span\n className={`${handles.arrow} ${handles.termArrow} ph2 c-muted-2`}\n >\n <IconCaret orientation=\"right\" size={caretIconSize} />\n </span>\n <span className={`${handles.term} ph2 c-on-base`}>{term}</span>\n </Fragment>\n )}\n </div>\n )\n}\n\nBreadcrumb.defaultProps = {\n categories: [],\n}\n\nexport default Breadcrumb\n\n```" } ]
code_breadcrumb_2f6b6861
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/react/__tests__/BreadCrumb.test.tsx from the breadcrumb VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { render } from '@vtex/test-tools/react'\nimport { useProduct } from 'vtex.product-context'\n\nimport Breadcrumb from '../Breadcrumb'\nimport { Props } from '../components/BaseBreadcrumb'\n\ndescribe('<BreadCrumb /> component', () => {\n const defaultCategories = ['/Eletrônicos/Smartphones/', '/Eletrônicos/']\n const renderComponent = (customProps?: Partial<Props>) => {\n const props = {\n categories: defaultCategories,\n ...customProps,\n }\n\n return render(<Breadcrumb {...props} />)\n }\n\n it('should match the snapshot', () => {\n expect(renderComponent({ term: 'term' }).asFragment()).toMatchSnapshot()\n })\n\n it('should render links', () => {\n const { queryByText, asFragment } = renderComponent()\n\n expect(asFragment().querySelectorAll('a')).toHaveLength(3)\n expect(queryByText('eletrônicos')).toBeDefined()\n expect(queryByText('smartphones')).toBeDefined()\n })\n\n it('should render term', () => {\n const { rerender, queryByText } = renderComponent({\n term: 'term',\n })\n\n expect(queryByText('term')).toBeDefined()\n\n rerender(<Breadcrumb categories={defaultCategories} />)\n\n expect(queryByText('term')).toBeNull()\n })\n\n it('should render structured data', () => {\n useProduct.mockImplementationOnce(() => ({\n product: { linkText: 'classic-shoes' },\n }))\n\n const { getByText } = renderComponent({})\n\n expect(getByText('Structured Data')).toBeDefined()\n })\n})\n\n```" } ]
code_breadcrumb_77b56e9d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/react/typings/vtex.search-page-context/SearchPageContext.d.ts from the breadcrumb VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.search-page-context/SearchPageContext' {\n export const useSearchPage: () => any\n}\n\n```" } ]
code_breadcrumb_2c6fe93c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/react/components/ProductBreadcrumb/index.tsx from the breadcrumb VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useContext } from 'react'\nimport { ProductContext } from 'vtex.product-context'\nimport { ProductBreadcrumb as ProductBreadcrumbStructuredData } from 'vtex.structured-data'\n\nimport BaseBreadcrumb, { Props, NavigationItem } from '../BaseBreadcrumb'\n\nconst withProductContextWrapper = (\n Component: React.ComponentType<Props>\n): React.FC<Props> => (props) => {\n const { product } = useContext(ProductContext) || { product: null }\n const categoryTree: NavigationItem[] = product?.categoryTree\n const categories = product?.categories ?? []\n\n return (\n <>\n <ProductBreadcrumbStructuredData\n categoryTree={categoryTree}\n productName={product?.productName}\n productSlug={product?.linkText}\n />\n <Component\n term={product?.productName}\n categories={categories}\n categoryTree={categoryTree}\n breadcrumb={props.breadcrumb}\n showOnMobile={props.showOnMobile}\n homeIconSize={props.homeIconSize}\n caretIconSize={props.caretIconSize}\n />\n </>\n )\n}\n\nexport default withProductContextWrapper(BaseBreadcrumb)\n\n```" } ]
code_breadcrumb_6f59a2e1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/react/components/ProductBreadcrumb/README.md from the breadcrumb VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# VTEX Product Breadcrumb\n\nThis block (`breadcrumb.product`) is meant to be used inside your product page. It uses the Product Context and only fetches data from there.\n\nIt has the same props as the original `breadcrumb` block.\n\n## Example usage\n\n```\njs\n\"store.product\": {\n \"children\": [\"breadcrumb.product\"]\n}\n```\n\n```" } ]
code_breadcrumb_cf577406
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/react/components/SearchBreadcrumb/index.tsx from the breadcrumb VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport { useSearchPage } from 'vtex.search-page-context/SearchPageContext'\nimport { SearchBreadcrumb as SearchBreadcrumbStructuredData } from 'vtex.structured-data'\n\nimport BaseBreadcrumb, { NavigationItem } from '../BaseBreadcrumb'\n\ninterface Props {\n showOnMobile?: boolean\n homeIconSize?: number\n caretIconSize?: number\n}\n\nconst SearchBreadcrumb: FC<Props> = ({\n showOnMobile,\n homeIconSize,\n caretIconSize,\n}) => {\n const { searchQuery } = useSearchPage()\n const breadcrumb: NavigationItem[] =\n searchQuery?.data?.productSearch?.breadcrumb ??\n searchQuery?.data?.facets?.breadcrumb ??\n []\n\n return (\n <>\n <SearchBreadcrumbStructuredData breadcrumb={breadcrumb} />\n <BaseBreadcrumb\n breadcrumb={breadcrumb}\n showOnMobile={showOnMobile}\n categories={[]} // unused prop, its OK\n homeIconSize={homeIconSize}\n caretIconSize={caretIconSize}\n />\n </>\n )\n}\n\nexport default SearchBreadcrumb\n\n```" } ]
code_breadcrumb_02a7e1ae
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of breadcrumb/react/components/SearchBreadcrumb/README.md from the breadcrumb VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# VTEX Search Breadcrumb\n\nThis block (`breadcrumb.search`) is meant to be used inside your search page. It uses the Search Page Context and only fetches data from there.\n\nIt has the same props as the original `breadcrumb` block.\n\n## Example usage\n\n```\njs\n\"search-result-layout.desktop\": {\n \"children\": [\"breadcrumb.search\"]\n}\n```\n\n```" } ]
code_pocfamiliabercomat-multifront_efbbd25c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/messages/pt.json from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"editor.multisite.title\" : \"Multisitio\",\n \"editor.multisite.description\" : \"Componente de Multisitio\",\n \"editor.multisite.navigation.name1\" : \"Primeiro nome de navegação\",\n \"editor.multisite.navigation.default\" : \"Nome\",\n \"editor.multisite.navigation.value1\" : \"Primeiro parâmetro ID\",\n \"editor.multisite.navigation.name2\" : \"Segundo nome de navegação\",\n \"editor.multisite.navigation.value2\" : \"Segundo parâmetro ID\",\n \"editor.multisite.navigation.name3\" : \"Terceiro nome de navegação\",\n \"editor.multisite.navigation.value3\" : \"Terceiro parâmetro ID\",\n \"editor.image.src.title\" : \"Src\",\n \"editor.image.alt.title\" : \"Alt\",\n \"editor.image.title.title\" : \"Título\"\n}\n\n```" } ]
code_pocfamiliabercomat-multifront_a3510d38
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/messages/en.json from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"editor.multisite.title\" : \"Multisite\",\n \"editor.multisite.description\" : \"Multisite component\",\n \"editor.multisite.navigation.name1\" : \"First navigation name\",\n \"editor.multisite.navigation.default\" : \"Name\",\n \"editor.multisite.navigation.value1\" : \"First parameter ID\",\n \"editor.multisite.navigation.name2\" : \"Second navigation name\",\n \"editor.multisite.navigation.value2\" : \"Second parameter ID\",\n \"editor.multisite.navigation.name3\" : \"Third navigation name\",\n \"editor.multisite.navigation.value3\" : \"Third parameter ID\",\n \"editor.image.src.title\" : \"Src\",\n \"editor.image.alt.title\" : \"Alt\",\n \"editor.image.title.title\" : \"Title\"\n}\n```" } ]
code_pocfamiliabercomat-multifront_652ec466
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/messages/context.json from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"editor.multisite.title\" : \"Multisite\",\n \"editor.multisite.description\" : \"Multisite component\",\n \"editor.multisite.navigation.name1\" : \"First navigation name\",\n \"editor.multisite.navigation.default\" : \"Name\",\n \"editor.multisite.navigation.value1\" : \"First parameter ID\",\n \"editor.multisite.navigation.name2\" : \"Second navigation name\",\n \"editor.multisite.navigation.value2\" : \"Second parameter ID\",\n \"editor.multisite.navigation.name3\" : \"Third navigation name\",\n \"editor.multisite.navigation.value3\" : \"Third parameter ID\",\n \"editor.image.src.title\" : \"Src\",\n \"editor.image.alt.title\" : \"Alt\",\n \"editor.image.title.title\" : \"Title\"\n}\n```" } ]
code_pocfamiliabercomat-multifront_a2318bb4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/messages/es.json from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"editor.multisite.title\" : \"Multisitio\",\n \"editor.multisite.description\" : \"Componente Multisitio\",\n \"editor.multisite.navigation.name1\" : \"Primer nombre de la navegación\",\n \"editor.multisite.navigation.default\" : \"Nombre\",\n \"editor.multisite.navigation.value1\" : \"Primer ID de parametro\",\n \"editor.multisite.navigation.name2\" : \"Segundo nombre de la navegación\",\n \"editor.multisite.navigation.value2\" : \"Segundo ID de parametro\",\n \"editor.multisite.navigation.name3\" : \"Tercer nombre de la navegación\",\n \"editor.multisite.navigation.value3\" : \"Tercer ID de parametro\",\n \"editor.image.src.title\" : \"Src\",\n \"editor.image.alt.title\" : \"Alt\",\n \"editor.image.title.title\" : \"Título\"\n}\n```" } ]
code_pocfamiliabercomat-multifront_2decdd00
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/docs/README.md from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# VTEX Recommendation Resolver\n\nThis app is an implementation of the VTEX recommendation protocol for recommendation shelves that is defined by the schema GraphQL [recommendation-graphql](https://github.com/vtex-apps/recommendation-graphql).\n\n```" } ]
code_pocfamiliabercomat-multifront_f33b6498
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/node/service.json from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"stack\": \"nodejs\",\n \"memory\": 256,\n \"minReplicas\": 3,\n \"workers\": 1,\n \"ttl\": 60\n}\n\n```" } ]
code_pocfamiliabercomat-multifront_b18f804f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/node/package.json from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"graphql\": \"^14.5.8\",\n \"graphql-tools\": \"^4.0.6\",\n \"vtex.search-segment-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.search-segment-graphql@0.1.0/public\"\n },\n \"devDependencies\": {\n \"@types/atob\": \"^2.1.2\",\n \"@types/node\": \"^12.0.0\",\n \"@vtex/api\": \"6.45.12\",\n \"@vtex/prettier-config\": \"^0.1.3\",\n \"eslint\": \"^6.8.0\",\n \"eslint-config-vtex\": \"^12.2.1\",\n \"husky\": \"^4.2.0\",\n \"lint-staged\": \"^10.0.2\",\n \"prettier\": \"^1.19.1\",\n \"typescript\": \"3.9.7\",\n \"vtex.css-handles\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.css-handles@0.4.4/public/@types/vtex.css-handles\",\n \"vtex.messages\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.messages@1.65.0/public/@types/vtex.messages\",\n \"vtex.native-types\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.native-types@0.8.0/public/@types/vtex.native-types\",\n \"vtex.search-segment-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.search-segment-graphql@0.1.1/public/@types/vtex.search-segment-graphql\",\n \"vtex.search-session\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.search-session@0.2.10/public/_types/react\",\n \"vtex.store-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-graphql@2.152.0/public/@types/vtex.store-graphql\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.146.1/public/@types/vtex.styleguide\"\n },\n \"version\": \"0.1.4\"\n}\n\n```" } ]
code_pocfamiliabercomat-multifront_247eda00
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/node/global.ts from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {\n IOContext,\n ParamsContext,\n RecorderState,\n ServiceContext,\n SegmentData,\n} from '@vtex/api'\n\nimport { Clients } from './clients/index'\n\ndeclare global {\n type Context = ServiceContext<Clients, RecorderState, CustomContext>\n\n interface CustomContext extends ParamsContext {\n vtex: CustomIOContext\n }\n interface CustomIOContext extends IOContext {\n segment?: SegmentData\n }\n\n interface SearchSegmentInput {\n userEmail?: string\n isAuthenticated?: boolean\n selectedFacets?: SelectedFacet[]\n }\n\n interface SelectedFacet {\n key: string\n value: string\n }\n}\n\n```" } ]
code_pocfamiliabercomat-multifront_ec78d09c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/node/index.ts from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { Service, RecorderState, ParamsContext } from '@vtex/api'\nimport schema from 'vtex.search-segment-graphql/graphql'\n\nimport { Clients, clients } from './clients'\nimport { queries as segmentSearchQueries } from './resolvers/segmentSearch'\n\nexport default new Service<Clients, RecorderState, ParamsContext>({\n clients,\n graphql: {\n resolvers: {\n Query: {\n ...segmentSearchQueries,\n },\n },\n schema,\n },\n})\n\n```" } ]
code_pocfamiliabercomat-multifront_3da8868b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/react/package.json from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"@vtex/css-handles\": \"^1.0.0\",\n \"atob\": \"^2.1.2\",\n \"classnames\": \"^2.2.6\",\n \"ramda\": \"^0.26.1\",\n \"react\": \"^16.12.0\",\n \"react-apollo\": \"^3.1.3\",\n \"react-dom\": \"^16.12.0\",\n \"react-intl\": \"^3.12.0\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^3.1.3\",\n \"@types/atob\": \"^2.1.2\",\n \"@types/classnames\": \"^2.2.7\",\n \"@types/jest\": \"^24.0.18\",\n \"@types/node\": \"^12.7.5\",\n \"@types/prop-types\": \"^15.7.0\",\n \"@types/ramda\": \"^0.26.5\",\n \"@types/react\": \"^16.9.31\",\n \"@vtex/test-tools\": \"^3.3.2\",\n \"@vtex/tsconfig\": \"^0.4.4\",\n \"apollo-cache-inmemory\": \"^1.6.5\",\n \"apollo-client\": \"^2.5.1\",\n \"graphql\": \"^14.6.0\",\n \"typescript\": \"3.9.7\",\n \"vtex.css-handles\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.css-handles@0.4.4/public/@types/vtex.css-handles\",\n \"vtex.messages\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.messages@1.65.0/public/@types/vtex.messages\",\n \"vtex.native-types\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.native-types@0.8.0/public/@types/vtex.native-types\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.132.4/public/@types/vtex.render-runtime\",\n \"vtex.search-segment-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.search-segment-graphql@0.1.1/public/@types/vtex.search-segment-graphql\",\n \"vtex.search-session\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.search-session@0.2.10/public/_types/react\",\n \"vtex.store-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-graphql@2.152.0/public/@types/vtex.store-graphql\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.146.1/public/@types/vtex.styleguide\"\n }\n}\n\n```" } ]
code_pocfamiliabercomat-multifront_3ad4ef75
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/react/ConditionalFrontBlock.tsx from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { FC } from \"react\";\nimport React from \"react\";\n\nconst ConditionalFrontBlock: FC<any> = ({\n frontValue,\n children\n}) => {\n\n // obtenemos el código postal guardado en el local storage\n const storageCp = window?.localStorage?.getItem(\"CP\") || \"\";\n const postalCode = parseInt(storageCp);\n\n console.log('postalCode', postalCode);\n\n // let conditionalFront = <></>;\n let id = 1; //aca valor default\n let condition = frontValue == id;\n let conditionalFront = <>{condition && children}</>;\n\n if (postalCode > 3500 && postalCode < 3790) {\n\n id = 2;\n let condition = frontValue == id;\n return conditionalFront = <>{condition && children}</>;\n\n } else if (postalCode > 4000 && postalCode < 4242) {\n\n id = 3;\n let condition = frontValue == id;\n return conditionalFront = <>{condition && children}</>;\n\n } else {\n\n return conditionalFront;\n\n }\n};\n\nexport default ConditionalFrontBlock;\n\n\n```" } ]
code_pocfamiliabercomat-multifront_c017037c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/store/contentSchemas.json from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"definitions\": {\n \"ConditionalFrontBlock\": {\n \"type\": \"object\",\n \"properties\": {\n \"segmentValue\": {\n \"title\": \"segmentValue\",\n \"type\": \"number\",\n \"default\": null\n }\n } \n }\n }\n}\n\n```" } ]
code_pocfamiliabercomat-multifront_e1272968
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/store/interfaces.json from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"conditionalFrontBlock\": {\n \"component\": \"ConditionalFrontBlock\",\n \"composition\": \"children\",\n \"content\": {\n \"$ref\": \"#/definitions/ConditionalFrontBlock\"\n }\n }\n}\n\n```" } ]
code_pocfamiliabercomat-multifront_8f08e1a7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/node/clients/index.ts from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ClientsConfig, IOClients } from '@vtex/api'\n\nconst MEDIUM_TIMEOUT_MS = 2 * 1000\n\nexport class Clients extends IOClients {\n // Add client example\n // public get myClient(): ClientType {\n // return this.getOrSet('myClient', ClientType)\n // }\n}\n\nexport const clients: ClientsConfig<Clients> = {\n implementation: Clients,\n options: {\n default: {\n retries: 2,\n timeout: MEDIUM_TIMEOUT_MS,\n },\n },\n}\n\n```" } ]
code_pocfamiliabercomat-multifront_2ee71af4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/node/typings/global.d.ts from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare const metrics\n\ntype GenericObject = Record<string, any>\n\n```" } ]
code_pocfamiliabercomat-multifront_3c15813c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/node/resolvers/segmentSearch.ts from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport const queries = {\n\n searchSegment: async (\n __: unknown, \n args: SearchSegmentInput, \n context: Context\n ) => {\n\n const { parameterValue } = await context.clients.apps.getAppSettings(\n `${process.env.VTEX_APP_ID}`\n )\n const parameter = 'productClustersId';\n \n if(args.isAuthenticated === true){\n const selectedFacets = args.selectedFacets || [];\n if (selectedFacets.length > 0){\n return [{ key: selectedFacets[0].key, value: selectedFacets[0].value }];\n } \n } \n\n return [{ key: parameter, value: parameterValue }];\n\n }\n}\n```" } ]
code_pocfamiliabercomat-multifront_671ece20
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/react/typings/storefront.d.ts from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { FunctionComponent } from 'react'\n\ndeclare global {\n interface StorefrontFunctionComponent<P = GenericObject>\n extends FunctionComponent<P> {\n getSchema?(props: P): GenericObject\n schema?: GenericObject\n }\n\n interface StorefrontComponent<P = GenericObject, S = GenericObject>\n extends Component<P, S> {\n getSchema?(props: P): GenericObject\n schema: GenericObject\n }\n}\n\n```" } ]
code_pocfamiliabercomat-multifront_93fbbac1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/react/typings/vtex.render-runtime.d.ts from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* Typings for `render-runtime` */\ndeclare module 'vtex.render-runtime' {\n import { Component, ComponentType, ReactElement, ReactType } from 'react'\n\n export interface NavigationOptions {\n page: string\n params?: any\n }\n\n export interface RenderContextProps {\n runtime: {\n navigate: (options: NavigationOptions) => void\n }\n }\n\n interface ExtensionPointProps {\n id: string\n [key: string]: any\n }\n\n export const ExtensionPoint: ComponentType<ExtensionPointProps>\n\n interface ChildBlockProps {\n id: string\n }\n\n export const ChildBlock: ComponentType<ChildBlockProps>\n export const useChildBlock = ({ id: string }) => GenericObject\n\n export const Helmet: ReactElement\n export const Link: ReactType\n export const NoSSR: ReactElement\n export const RenderContextConsumer: ReactElement\n export const canUseDOM: boolean\n export const withRuntimeContext: <TOriginalProps extends GenericObject>(\n Component: ComponentType<TOriginalProps & RenderContextProps>\n ) => ComponentType<TOriginalProps>\n}\n\n```" } ]
code_pocfamiliabercomat-multifront_85bd2239
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/react/typings/global.d.ts from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport interface Runtime {\n segmentToken: string\n}\n\nexport interface TimeSplit {\n hours: string\n minutes: string\n seconds: string\n}\n\ntype GenericObject = Record<string, any>\n\n```" } ]
code_pocfamiliabercomat-multifront_7c20567c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/react/typings/css.d.ts from the pocfamiliabercomat-multifront 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_pocfamiliabercomat-multifront_54367ca9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/react/typings/graphql.d.ts from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.graphql' {\n import { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\n```" } ]
code_pocfamiliabercomat-multifront_5acb435b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/react/typings/vtex.styleguide.d.ts from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide' {\n import { ComponentType } from 'react'\n\n export const Input: ComponentType<InputProps>\n\n interface InputProps {\n [key: string]: any\n }\n}\n\n```" } ]
code_pocfamiliabercomat-multifront_67a80194
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/react/utils/time.ts from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { TimeSplit } from '../typings/global'\n\nconst SECONDS_IN_MINUTE = 60\nconst SECONDS_IN_HOUR = 60 * SECONDS_IN_MINUTE\n\nconst fillWithZero = (digits: number, number: number): string => {\n const filled = `${'0'.repeat(digits - 1)}${number}`\n\n return filled.slice(filled.length - digits)\n}\n\nexport const parseTimeRemaining = (totalSeconds: number): TimeSplit => {\n const hours = Math.floor(totalSeconds / SECONDS_IN_HOUR)\n const minutes = Math.floor(\n (totalSeconds % SECONDS_IN_HOUR) / SECONDS_IN_MINUTE\n )\n\n const seconds = Math.floor(\n (totalSeconds % SECONDS_IN_HOUR) % SECONDS_IN_MINUTE\n )\n\n return {\n hours: fillWithZero(2, hours),\n minutes: fillWithZero(2, minutes),\n seconds: fillWithZero(2, seconds),\n }\n}\n\n/**\n *\n * @param targetDate ISOString for the date that the countdown will expire\n * @param dispatchFn A function that updates the state of the component\n */\nexport const tick = (\n targetDate: string,\n dispatchFn: React.Dispatch<React.SetStateAction<TimeSplit>>\n) => {\n const ONE_SECOND_IN_MILLIS = 1000\n const finalDate = new Date(targetDate)\n const now = new Date()\n\n const secondsLeft =\n (finalDate.getTime() - now.getTime()) / ONE_SECOND_IN_MILLIS\n\n setTimeout(() => {\n dispatchFn(parseTimeRemaining(secondsLeft))\n }, ONE_SECOND_IN_MILLIS)\n}\n\nexport const getTwoDaysFromNow = () => {\n const today = new Date()\n\n today.setDate(today.getDate() + 2)\n\n return today.toISOString()\n}\n\n```" } ]
code_pocfamiliabercomat-multifront_0421c278
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of pocfamiliabercomat-multifront/react/styles/styles.css from the pocfamiliabercomat-multifront VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.navigationLink {\n border: 1px solid transparent;\n background-color: transparent;\n color: rgba(150, 150, 150, 0.322);\n text-decoration: none;\n margin-right: .5rem;\n padding: .5rem 1.5rem;\n width: 150px;\n height: 60px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.navigationLink:hover {\n border: 1px solid rgba(150, 150, 150, 0.322);\n cursor: pointer;\n transition: .3s all ease-in;\n}\n\n.active {\n border: 1px solid rgba(150, 150, 150, 0.322);\n color: rgba(44, 44, 44, 0.322);\n transition: .3s all ease-in;\n}\n\n.navigationLink img {\n width: 100%;\n height: auto;\n}\n```" } ]
code_telemarketing_9adf4cf4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of telemarketing/messages/id-ID.json from the telemarketing VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/telemarketing.attendant\": \"Staf: {attendant}\",\n \"store/telemarketing.client\": \"Klien\",\n \"store/telemarketing-login.message\": \"Masuk sebagai\",\n \"store/telemarketing-login.button\": \"Masuk\",\n \"store/telemarketing-logout.button\": \"Keluar\",\n \"store/telemarketing-logout.document-label\": \"Dokumen\",\n \"store/telemarketing-logout.phone-label\": \"Telepon\",\n \"store/telemarketing-logout.button-orders\": \"Pesanan\"\n}\n\n```" } ]
code_telemarketing_59db6fb5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of telemarketing/messages/pt.json from the telemarketing VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/telemarketing.attendant\": \"Atendente: {attendant}\",\n \"store/telemarketing.client\": \"Cliente\",\n \"store/telemarketing-login.message\": \"Entrar como cliente\",\n \"store/telemarketing-login.button\": \"Entrar\",\n \"store/telemarketing-logout.button\": \"Sair\",\n \"store/telemarketing-logout.document-label\": \"Documento\",\n \"store/telemarketing-logout.phone-label\": \"Telefone\",\n \"store/telemarketing-logout.button-orders\": \"Pedidos\"\n}\n\n```" } ]
code_telemarketing_ad096c86
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of telemarketing/messages/ar-SA.json from the telemarketing VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/telemarketing.attendant\": \"المنتظرون: {attendant}\",\n \"store/telemarketing.client\": \"العميل\",\n \"store/telemarketing-login.message\": \"تسجيل الدخول كـ\",\n \"store/telemarketing-login.button\": \"تسجيل الدخول\",\n \"store/telemarketing-logout.button\": \"تسجيل الخروج\",\n \"store/telemarketing-logout.document-label\": \"المستند\",\n \"store/telemarketing-logout.phone-label\": \"رقم الهاتف\",\n \"store/telemarketing-logout.button-orders\": \"طلباتي\"\n}\n\n```" } ]