id
stringlengths 12
53
| messages
listlengths 3
3
|
|---|---|
code_b2b-quotes_043a0fc6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/components/ButtonCollapseWrapper.tsx from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport type { FunctionComponent } from 'react'\nimport React from 'react'\n\nconst ButtonCollapseWrapper: FunctionComponent = ({ children }) => {\n return (\n <div className=\"absolute left-0 w-100 h-100\" style={{ display: 'grid' }}>\n {children}\n </div>\n )\n}\n\nexport default ButtonCollapseWrapper\n\n```"
}
] |
code_b2b-quotes_24469900
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/components/B2BQuotesLockingModal.tsx from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment, useEffect, useState } from 'react'\nimport { Modal, Button } from 'vtex.styleguide'\nimport { defineMessages, useIntl } from 'react-intl'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { useCheckoutURL } from 'vtex.checkout-resources/Utils'\nimport { useMutation, useQuery } from 'react-apollo'\nimport { OrderForm } from 'vtex.order-manager'\n\nimport CLEAR_CART from '../graphql/clearCartMutation.graphql'\nimport GET_ORDERFORM from '../graphql/orderForm.gql'\nimport ORDERFORM_CUSTOM_DATA from '../graphql/setOrderFormCustomData.graphql'\n\nconst storePrefix = 'store/b2b-quotes.'\n\nconst messages = defineMessages({\n title: {\n id: `${storePrefix}quote-locking.title`,\n },\n message: {\n id: `${storePrefix}quote-locking.message`,\n },\n returnToCheckout: {\n id: `${storePrefix}quote-locking.return-to-checkout`,\n },\n clearCart: {\n id: `${storePrefix}quote-locking.clear-cart`,\n },\n})\n\nconst useCheckout = () => {\n const { url: checkoutUrl, major } = useCheckoutURL()\n const { navigate, rootPath = '' } = useRuntime()\n\n const goToCheckout = (url: string) => {\n if (major > 0 && url === checkoutUrl) {\n navigate({ to: url })\n } else {\n window.location.href = `${rootPath}${url}`\n }\n }\n\n return goToCheckout\n}\n\nconst B2BQuotesLockingModal = () => {\n const { formatMessage } = useIntl()\n const [open, setOpen] = useState(false)\n const goToCheckout = useCheckout()\n const { url: checkoutUrl } = useCheckoutURL()\n const [clearCart] = useMutation(CLEAR_CART)\n const [setOrderFormCustomData] = useMutation(ORDERFORM_CUSTOM_DATA)\n const [loading, setLoading] = useState(false)\n const { setOrderForm }: OrderFormContext = OrderForm.useOrderForm()\n const { data: orderFormData } = useQuery(GET_ORDERFORM, {\n ssr: false,\n fetchPolicy: 'network-only',\n })\n\n const handleClearCart = async () => {\n setLoading(true)\n const { orderForm } = orderFormData\n const { orderFormId } = orderForm\n\n try {\n await clearCart({\n variables: {\n orderFormId,\n },\n })\n await setOrderFormCustomData({\n variables: {\n orderFormId,\n appId: 'b2b-quotes-graphql',\n value: 0,\n field: 'quoteId',\n },\n })\n } catch (e) {\n console.error(e)\n }\n\n setLoading(false)\n setOpen(false)\n setOrderForm({\n ...orderForm,\n items: [],\n })\n }\n\n const handleReturnToCheckout = () => {\n setOpen(false)\n goToCheckout(checkoutUrl)\n }\n\n useEffect(() => {\n if (!orderFormData) {\n return\n }\n\n const { orderForm } = orderFormData\n const { customData, items } = orderForm\n\n if (\n !customData?.customApps ||\n !customData?.customApps.some(\n (item: any) => item.id === 'b2b-quotes-graphql'\n )\n ) {\n return\n }\n\n const index = customData.customApps.findIndex((item: any) => {\n return item.id === 'b2b-quotes-graphql'\n })\n\n const { quoteId } = customData.customApps[index].fields\n\n if (\n index !== -1 &&\n quoteId &&\n parseInt(quoteId, 10) !== 0 &&\n items?.length > 0\n ) {\n setOpen(true)\n }\n }, [orderFormData])\n\n return (\n <Fragment>\n {open && (\n <Modal\n onClose={() => handleClearCart()}\n closeOnEsc={false}\n showCloseButton={false}\n closeOnOverlayClick={false}\n isOpen={open}\n showCloseIcon={false}\n bottomBar={\n <div className=\"flex-s w-100-s items-center-s flex-column-s flex-column-reverse-s justify-end-m flex-row-m\">\n <span className=\"mr4 \">\n <Button\n isLoading={loading}\n variation=\"tertiary\"\n onClick={handleClearCart}\n >\n {formatMessage(messages.clearCart)}\n </Button>\n </span>\n <span>\n <Button\n disabled={loading}\n variation=\"primary\"\n onClick={handleReturnToCheckout}\n >\n {formatMessage(messages.returnToCheckout)}\n </Button>\n </span>\n </div>\n }\n >\n <div>\n <h1>{formatMessage(messages.title)}</h1>\n <p>{formatMessage(messages.message)}</p>\n </div>\n </Modal>\n )}\n </Fragment>\n )\n}\n\nexport default B2BQuotesLockingModal\n\n```"
}
] |
code_b2b-quotes_38599ecf
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/__tests__/index.test.tsx from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\ndescribe('Orders List Scenarios', () => {\n it('should work', () => {\n expect(1).toBe(1)\n })\n})\n\n```"
}
] |
code_b2b-quotes_4b4e3a23
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/getDimension.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetDimension {\n getDimension(dimType: manualPrice)\n @context(provider: \"vtex.order-auth-graphql\") {\n ruleCollection {\n trigger {\n effect {\n description\n effectType\n }\n condition {\n conditionType\n lessThan\n greatherThan\n }\n }\n }\n }\n}\n\n```"
}
] |
code_b2b-quotes_b41a82c8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/orderForm.gql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetOrderForm {\n orderForm @context(provider: \"vtex.store-graphql\") {\n orderFormId\n userType\n loggedIn\n allowManualPrice\n clientProfileData {\n email\n }\n customData {\n customApps {\n id\n major\n fields\n }\n }\n salesChannel\n totalizers {\n id\n name\n value\n }\n value\n items {\n name\n skuName\n refId\n id\n productId\n imageUrl\n listPrice\n price\n quantity\n sellingPrice\n seller\n }\n shippingData {\n address {\n street\n number\n complement\n postalCode\n city\n geoCoordinates\n neighborhood\n country\n state\n }\n }\n }\n}\n\n```"
}
] |
code_b2b-quotes_d80598dc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/getQuotes.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetQuotes(\n $organization: [String]\n $costCenter: [String]\n $status: [String]\n $search: String\n $page: Int\n $pageSize: Int\n $sortOrder: String\n $sortedBy: String\n) {\n getQuotes(\n organization: $organization\n costCenter: $costCenter\n status: $status\n search: $search\n page: $page\n pageSize: $pageSize\n sortOrder: $sortOrder\n sortedBy: $sortedBy\n ) @context(provider: \"vtex.b2b-quotes-graphql\") {\n data {\n id\n referenceName\n creatorEmail\n creatorRole\n creationDate\n expirationDate\n lastUpdate\n subtotal\n status\n organization\n organizationName\n costCenter\n costCenterName\n viewedBySales\n viewedByCustomer\n hasChildren\n childrenQuantity\n }\n pagination {\n total\n }\n }\n}\n\n```"
}
] |
code_b2b-quotes_33aee0a2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/checkSellerQuotes.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery CheckSellerQuotes($sellers: [String!]!) {\n checkSellerQuotes(sellers: $sellers)\n @context(provider: \"vtex.b2b-quotes-graphql\") {\n id\n name\n }\n}\n\n```"
}
] |
code_b2b-quotes_4430050b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/updateQuote.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation UpdateQuote(\n $id: String\n $items: [QuoteItemInput]\n $subtotal: Float\n $note: String\n $decline: Boolean\n $expirationDate: String\n) {\n updateQuote(\n input: {\n id: $id\n items: $items\n subtotal: $subtotal\n note: $note\n decline: $decline\n expirationDate: $expirationDate\n }\n ) @context(provider: \"vtex.b2b-quotes-graphql\")\n}\n\n```"
}
] |
code_b2b-quotes_1a9b9b17
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/clearCartMutation.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation ClearCart($orderFormId: String) {\n clearCart(orderFormId: $orderFormId)\n @context(provider: \"vtex.b2b-quotes-graphql\")\n}\n\n```"
}
] |
code_b2b-quotes_d6194354
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/getOrganizations.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetOrganizations(\n $status: [String]\n $search: String\n $page: Int\n $pageSize: Int\n $sortOrder: String\n $sortedBy: String\n) {\n getOrganizations(\n status: $status\n search: $search\n page: $page\n pageSize: $pageSize\n sortOrder: $sortOrder\n sortedBy: $sortedBy\n ) @context(provider: \"vtex.b2b-organizations-graphql\") {\n pagination {\n total\n }\n data {\n id\n name\n }\n }\n}\n\n```"
}
] |
code_b2b-quotes_b8cf5ac2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/getAppSettings.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetAppSettings {\n getAppSettings @context(provider: \"vtex.b2b-quotes-graphql\") {\n adminSetup {\n cartLifeSpan\n quotesManagedBy\n }\n }\n}\n\n```"
}
] |
code_b2b-quotes_c257d514
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/checkPermissions.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery CheckPermissions($email: String!) {\n getQuoteEnabledForUser(email: $email)\n}\n\n```"
}
] |
code_b2b-quotes_54018e3c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/getCostCenter.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetCostCenter($id: ID!) {\n getCostCenterById(id: $id)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n name\n }\n}\n\n```"
}
] |
code_b2b-quotes_fed2b497
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/createQuote.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation CreateQuote(\n $referenceName: String\n $items: [QuoteItemInput]\n $subtotal: Float\n $note: String\n $sendToSalesRep: Boolean\n) {\n createQuote(\n input: {\n referenceName: $referenceName\n items: $items\n subtotal: $subtotal\n note: $note\n sendToSalesRep: $sendToSalesRep\n }\n ) @context(provider: \"vtex.b2b-quotes-graphql\")\n}\n\n```"
}
] |
code_b2b-quotes_6aef7818
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/getPermissions.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetPermissions {\n checkUserPermission @context(provider: \"vtex.storefront-permissions\") {\n role {\n id\n name\n slug\n }\n permissions\n }\n}\n\n```"
}
] |
code_b2b-quotes_84ee8590
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/getCostCentersByOrganizationId.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetCostCentersByOrganizationId(\n $id: ID\n $search: String\n $page: Int\n $pageSize: Int\n $sortOrder: String\n $sortedBy: String\n) {\n getCostCentersByOrganizationId(\n id: $id\n search: $search\n page: $page\n pageSize: $pageSize\n sortOrder: $sortOrder\n sortedBy: $sortedBy\n ) @context(provider: \"vtex.b2b-organizations-graphql\") {\n pagination {\n total\n }\n data {\n id\n name\n }\n }\n}\n\n```"
}
] |
code_b2b-quotes_36535ec2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/getChildrenQuotes.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetChildrenQuotes($id: String) {\n getChildrenQuotes(id: $id, sortOrder: \"ASC\", sortedBy: \"sellerName\")\n @context(provider: \"vtex.b2b-quotes-graphql\") {\n id\n referenceName\n creatorEmail\n creatorRole\n creationDate\n expirationDate\n lastUpdate\n subtotal\n status\n organization\n organizationName\n costCenter\n costCenterName\n viewedBySales\n viewedByCustomer\n seller\n sellerName\n parentQuote\n }\n}\n\n```"
}
] |
code_b2b-quotes_2c803ed8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/getQuote.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetQuote($id: String) {\n getQuote(id: $id) @context(provider: \"vtex.b2b-quotes-graphql\") {\n id\n referenceName\n creatorEmail\n creatorRole\n creationDate\n expirationDate\n lastUpdate\n updateHistory {\n email\n role\n date\n status\n note\n }\n items {\n name\n skuName\n refId\n id\n productId\n imageUrl\n listPrice\n price\n quantity\n sellingPrice\n seller\n }\n subtotal\n status\n organization\n organizationName\n costCenterName\n hasChildren\n seller\n sellerName\n parentQuote\n childrenQuantity\n }\n}\n\n```"
}
] |
code_b2b-quotes_55f96a14
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/getFullChildrenQuotes.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetFullChildrenQuotes($id: String) {\n getChildrenQuotes(id: $id, sortOrder: \"ASC\", sortedBy: \"sellerName\")\n @context(provider: \"vtex.b2b-quotes-graphql\") {\n id\n referenceName\n creatorEmail\n creatorRole\n creationDate\n expirationDate\n lastUpdate\n subtotal\n status\n organization\n organizationName\n costCenter\n costCenterName\n viewedBySales\n viewedByCustomer\n seller\n sellerName\n parentQuote\n items {\n name\n skuName\n refId\n id\n productId\n imageUrl\n listPrice\n price\n quantity\n sellingPrice\n seller\n }\n updateHistory {\n email\n role\n date\n status\n note\n }\n }\n}\n\n```"
}
] |
code_b2b-quotes_62dd382e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/getOrganization.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetOrganization($id: ID) {\n getOrganizationById(id: $id)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n name\n }\n}\n\n```"
}
] |
code_b2b-quotes_1e3bceea
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/saveAppSettings.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation SaveAppSettings($input: AppSettingsInput!) {\n saveAppSettings(input: $input) @context(provider: \"vtex.b2b-quotes-graphql\") {\n adminSetup {\n cartLifeSpan\n quotesManagedBy\n }\n }\n}\n\n```"
}
] |
code_b2b-quotes_667b69d2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/useQuote.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation UseQuote($id: String, $orderFormId: String) {\n useQuote(id: $id, orderFormId: $orderFormId)\n @context(provider: \"vtex.b2b-quotes-graphql\")\n}\n\n```"
}
] |
code_b2b-quotes_e3904d43
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/setOrderFormCustomData.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation setOrderFormCustomData(\n $appId: String\n $field: String\n $value: String\n $orderFormId: String\n) {\n setOrderFormCustomData(\n orderFormId: $orderFormId\n appId: $appId\n field: $field\n value: $value\n ) @context(provider: \"vtex.store-graphql\") {\n orderFormId\n customData {\n customApps {\n fields\n id\n major\n }\n }\n }\n}\n\n```"
}
] |
code_b2b-quotes_92804989
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/graphql/getMainOrganization.graphql from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetMainOrganization {\n getOrganizationByIdStorefront\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n }\n}\n\n```"
}
] |
code_b2b-quotes_b4e36cc5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/modules/session.ts from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface KeyValue {\n value: string\n}\n\ninterface Session {\n id: string\n namespaces: {\n store: {\n channel: string\n }\n profile: {\n isAuthenticated: KeyValue\n email?: KeyValue\n }\n }\n}\n\ninterface SessionUnauthorized {\n type: 'Unauthorized'\n message: string\n}\n\ninterface SessionForbidden {\n type: 'Forbidden'\n message: string\n}\n\ninterface SessionPromise {\n response: Session | SessionUnauthorized | SessionForbidden\n}\n\nexport function getSession() {\n return window &&\n (window as any).__RENDER_8_SESSION__ &&\n (window as any).__RENDER_8_SESSION__.sessionPromise\n ? ((window as any).__RENDER_8_SESSION__.sessionPromise as Promise<\n SessionPromise\n >)\n : null\n}\n\n```"
}
] |
code_b2b-quotes_1e448231
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/modules/checkoutHook.ts from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useCheckoutURL } from 'vtex.checkout-resources/Utils'\nimport { useRuntime } from 'vtex.render-runtime'\n\nexport default function useCheckout() {\n const { url: checkoutUrl, major } = useCheckoutURL()\n const { navigate, rootPath = '' } = useRuntime()\n\n const goToCheckout = (url: string) => {\n if (major > 0 && url === checkoutUrl) {\n navigate({ to: url })\n } else {\n window.location.href = `${rootPath}${url}`\n }\n }\n\n return goToCheckout\n}\n\n```"
}
] |
code_b2b-quotes_ce6dfba7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/utils/metrics/createQuote.ts from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport axios from 'axios'\n\nimport type { Metric, SessionResponse } from './metrics'\nimport { sendMetric } from './metrics'\n\nconst GRAPHQL_URL = (accountName: string, workspace?: string) => {\n if (workspace) {\n return `https://${workspace}--${accountName}.myvtex.com/_v/private/graphql/v1`\n }\n\n return `https://${accountName}.myvtex.com/_v/private/graphql/v1`\n}\n\ntype CreateQuoteFieldsMetric = {\n cost_center_name: string\n buyer_org_id: string\n buyer_org_name: string\n member_id: string\n member_email: string\n role: string\n creation_date: string\n quote_id: string\n quote_reference_name: string\n send_to_sales_rep: boolean\n}\n\ntype CreateQuoteMetricsParam = {\n quoteId: string\n sessionResponse: SessionResponse\n workspace: string\n account: string\n sendToSalesRep: boolean\n}\n\ntype CreateQuoteMetric = Metric & { fields: CreateQuoteFieldsMetric }\n\nconst fetchMetricsData = async (\n accountName: string,\n workspace: string,\n quoteId: string\n) => {\n const query = JSON.stringify({\n query: `query GetMetricsData($id: String) {\n getQuote(id: $id) @context(provider: \"vtex.b2b-quotes-graphql\") {\n organization\n organizationName\n costCenterName\n referenceName\n creatorRole\n creationDate\n }\n }`,\n variables: { id: quoteId },\n })\n\n const { data, errors } = (\n await axios.post(GRAPHQL_URL(accountName, workspace), query)\n ).data\n\n if (errors) {\n console.error('Graphql errors', errors)\n throw new Error('Graphql Errors when trying get quote and user data')\n }\n\n return data?.getQuote as QuoteMetricsData\n}\n\nconst buildCreateQuoteMetric = async (\n metricsParam: CreateQuoteMetricsParam\n): Promise<CreateQuoteMetric> => {\n const { namespaces } = metricsParam.sessionResponse\n const userEmail = namespaces?.profile?.email?.value\n\n const metricsData = await fetchMetricsData(\n metricsParam.account,\n metricsParam.workspace,\n metricsParam.quoteId\n )\n\n const metric: CreateQuoteMetric = {\n name: 'b2b-suite-buyerorg-data',\n kind: 'create-quote-ui-event',\n description: 'Create Quotation Action - UI',\n account: metricsParam.account,\n fields: {\n buyer_org_id: metricsData.organization,\n buyer_org_name: metricsData.organizationName,\n cost_center_name: metricsData.costCenterName,\n member_id: namespaces?.profile?.id?.value,\n member_email: userEmail,\n role: metricsData.creatorRole,\n creation_date: metricsData.creationDate,\n quote_id: metricsParam.quoteId,\n quote_reference_name: metricsData.referenceName,\n send_to_sales_rep: metricsParam.sendToSalesRep,\n },\n }\n\n return metric\n}\n\ntype QuoteMetricsData = {\n organization: string // organizationId\n organizationName: string\n costCenterName: string\n referenceName: string // quote reference name\n creatorRole: string\n creationDate: string\n}\n\nexport const sendCreateQuoteMetric = async (\n metricsParam: CreateQuoteMetricsParam\n) => {\n try {\n const metric = await buildCreateQuoteMetric(metricsParam)\n\n await sendMetric(metric)\n } catch (error) {\n console.warn('Unable to log metrics', error)\n }\n}\n\n```"
}
] |
code_b2b-quotes_9114fc9b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/utils/metrics/metrics.ts from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport axios from 'axios'\n\nconst ANALYTICS_URL = 'https://rc.vtex.com/api/analytics/schemaless-events'\n\ntype CreateQuoteMetric = {\n kind: 'create-quote-ui-event'\n description: 'Create Quotation Action - UI'\n}\n\ntype UseQuoteMetric = {\n kind: 'use-quote-ui-event'\n description: 'Use Quotation Action - UI'\n}\n\nexport type Metric = {\n name: 'b2b-suite-buyerorg-data'\n account: string\n} & (CreateQuoteMetric | UseQuoteMetric)\n\nexport type SessionProfile = {\n id: { value: string }\n email: { value: string }\n}\n\nexport type SessionResponse = {\n namespaces: {\n profile: SessionProfile\n }\n}\n\nexport const sendMetric = async (metric: Metric) => {\n try {\n await axios.post(ANALYTICS_URL, metric)\n } catch (error) {\n console.warn('Unable to log metrics', error)\n }\n}\n\n```"
}
] |
code_b2b-quotes_dc0280d4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/utils/metrics/useQuote.ts from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { Metric, SessionResponse } from './metrics'\nimport { sendMetric } from './metrics'\n\ntype UseQuoteFieldsMetric = {\n quote_id: string\n quote_reference_name: string\n order_form_id: string\n quote_creation_date: string\n quote_use_date: string\n creator_email: string\n user_email: string\n cost_center_name: string\n buyer_org_id: string\n buyer_org_name: string\n quote_last_update: string\n}\n\ntype UseQuoteMetric = Metric & { fields: UseQuoteFieldsMetric }\n\nexport type UseQuoteMetricsParams = {\n quoteState: Quote\n orderFormId: string\n account: string\n sessionResponse: SessionResponse\n}\n\nconst buildUseQuoteMetric = (\n metricsParam: UseQuoteMetricsParams\n): UseQuoteMetric => {\n const { quoteState, orderFormId, account, sessionResponse } = metricsParam\n\n const metric: UseQuoteMetric = {\n name: 'b2b-suite-buyerorg-data',\n kind: 'use-quote-ui-event',\n description: 'Use Quotation Action - UI',\n account,\n fields: {\n buyer_org_id: quoteState.organization,\n buyer_org_name: quoteState.organizationName,\n cost_center_name: quoteState.costCenterName,\n quote_id: quoteState.id,\n quote_reference_name: quoteState.referenceName,\n order_form_id: orderFormId,\n quote_creation_date: quoteState.creationDate,\n quote_use_date: new Date().toISOString(),\n creator_email: quoteState.creatorEmail,\n user_email: sessionResponse.namespaces?.profile?.email?.value,\n quote_last_update: quoteState.lastUpdate,\n },\n }\n\n return metric\n}\n\nexport const sendUseQuoteMetric = async (\n metricsParam: UseQuoteMetricsParams\n) => {\n try {\n const metric = buildUseQuoteMetric(metricsParam)\n\n await sendMetric(metric)\n } catch (error) {\n console.warn('Unable to log metrics', error)\n }\n}\n\n```"
}
] |
code_b2b-quotes_444fe32f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/components/QuoteDetails/SaveButtons.tsx from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment } from 'react'\nimport { Button } from 'vtex.styleguide'\nimport { FormattedMessage } from 'react-intl'\n\nimport { arrayShallowEqual } from '../../utils/shallowEquals'\n\nconst SaveButtons = ({\n isNewQuote,\n updatingQuoteState,\n sentToSalesRep,\n quoteState,\n onSaveForLater,\n onSaveQuote,\n quoteItems,\n expirationDate,\n noteState,\n isSalesRep,\n}: any) => {\n if (quoteState.hasChildren) return null\n\n if (isNewQuote) {\n return (\n <Fragment>\n <span className=\"mr4\">\n <Button\n variation=\"secondary\"\n isLoading={updatingQuoteState && !sentToSalesRep}\n onClick={onSaveForLater}\n disabled={\n !quoteState.items?.length ||\n !quoteState.referenceName ||\n updatingQuoteState\n }\n >\n <FormattedMessage id=\"store/b2b-quotes.create.button.save-for-later\" />\n </Button>\n </span>\n <span className=\"mr4\">\n <Button\n variation=\"primary\"\n isLoading={updatingQuoteState && sentToSalesRep}\n onClick={onSaveQuote}\n disabled={\n !quoteState.items?.length ||\n !quoteState.referenceName ||\n updatingQuoteState\n }\n >\n <FormattedMessage id=\"store/b2b-quotes.create.button.request-quote\" />\n </Button>\n </span>\n </Fragment>\n )\n }\n\n return (\n <Fragment>\n <span className=\"mr4\">\n <Button\n variation=\"primary\"\n onClick={onSaveQuote}\n isLoading={updatingQuoteState}\n disabled={\n quoteState.items.some((item: any) => item.error) ||\n (quoteState.items.length &&\n noteState === '' &&\n expirationDate === quoteState.expirationDate &&\n arrayShallowEqual(quoteItems, quoteState.items))\n }\n >\n {isSalesRep ? (\n <FormattedMessage id=\"store/b2b-quotes.quote-details.save\" />\n ) : (\n <FormattedMessage id=\"store/b2b-quotes.quote-details.submit-to-sales-rep\" />\n )}\n </Button>\n </span>\n </Fragment>\n )\n}\n\nexport default SaveButtons\n\n```"
}
] |
code_b2b-quotes_baf4d723
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/components/QuoteDetails/QuoteTable.tsx from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment, useState } from 'react'\nimport { FormattedMessage, useIntl } from 'react-intl'\nimport { formatCurrency, FormattedCurrency } from 'vtex.format-currency'\nimport { useRuntime } from 'vtex.render-runtime'\nimport {\n Card,\n Collapsible,\n Input,\n InputCurrency,\n Table,\n Tag,\n Totalizer,\n} from 'vtex.styleguide'\n\nimport { itemDiscountEligible } from '../../utils/helpers'\nimport { quoteMessages, statusMessages } from '../../utils/messages'\nimport { LabelByStatusMap } from '../../utils/status'\n\nconst QuoteTable = ({\n isNewQuote,\n quoteState,\n updatingSubtotal,\n originalSubtotal,\n isSalesRep,\n formState,\n maxDiscountState,\n discountState,\n onUpdateSellingPrice,\n onUpdateQuantity,\n checkedSellers,\n}: any) => {\n const intl = useIntl()\n const {\n culture,\n culture: { currency: currencyCode, locale },\n } = useRuntime()\n\n const { formatMessage, formatDate } = intl\n const formatPrice = (value: number) =>\n formatCurrency({\n intl,\n culture,\n value: value / 100,\n })\n\n quoteState.expirationDate = quoteState.expirationDate || ''\n\n const checkedExternalSellers = checkedSellers\n ?.filter((seller: any) => seller.id !== '1')\n ?.map((seller: any) => seller.id)\n\n const renderTable = (items: any, totalizers?: any) => (\n <Table\n totalizers={totalizers}\n fullWidth\n schema={{\n properties: {\n imageUrl: {\n title: formatMessage(quoteMessages.image),\n cellRenderer: ({ rowData: { imageUrl, skuName } }: any) =>\n imageUrl && (\n <div className=\"dib v-mid relative\">\n <img\n className=\"br2 v-mid\"\n height=\"38\"\n width=\"38\"\n src={imageUrl}\n alt={skuName}\n crossOrigin=\"anonymous\"\n />\n </div>\n ),\n width: 70,\n },\n refId: {\n title: formatMessage(quoteMessages.refCode),\n width: 200,\n },\n name: {\n title: formatMessage(quoteMessages.name),\n cellRenderer: ({ rowData }: any) => {\n return (\n <div>\n <span>{rowData.name}</span>\n {rowData.skuName !== rowData.name && (\n <Fragment>\n <br />\n <span className=\"t-mini\">{rowData.skuName}</span>\n </Fragment>\n )}\n </div>\n )\n },\n minWidth: 300,\n },\n listPrice: {\n title: formatMessage(quoteMessages.originalPrice),\n headerRight: true,\n width: 120,\n cellRenderer: ({ rowData }: any) => {\n return (\n isSalesRep && (\n <div\n className={`w-100 tr${\n rowData.listPrice !== rowData.sellingPrice\n ? ' strike '\n : ''\n }`}\n >\n <FormattedCurrency value={rowData.listPrice / 100} />\n </div>\n )\n )\n },\n },\n sellingPrice: {\n title: formatMessage(quoteMessages.quotePrice),\n headerRight: true,\n width: 120,\n cellRenderer: ({\n cellData: sellingPrice,\n rowData: { id: itemId, listPrice, error },\n }: any) => {\n if (\n formState.isEditable &&\n isSalesRep &&\n discountState === 0 &&\n itemDiscountEligible({\n listPrice,\n sellingPrice,\n error,\n maxDiscountState,\n })\n ) {\n return (\n <InputCurrency\n name=\"price\"\n value={sellingPrice / 100}\n onChange={onUpdateSellingPrice(itemId)}\n currencyCode={currencyCode}\n locale={locale}\n error={error}\n />\n )\n }\n\n return (\n <div className=\"w-100 tr\">\n <FormattedCurrency value={sellingPrice / 100} />\n </div>\n )\n },\n },\n quantity: {\n title: formatMessage(quoteMessages.quantity),\n width: 100,\n cellRenderer: ({\n cellData: quantity,\n rowData: { id: itemId },\n }: any) => {\n if (formState.isEditable && isSalesRep) {\n return (\n <Input\n id={itemId}\n name=\"quantity\"\n value={quantity}\n onChange={onUpdateQuantity(itemId)}\n />\n )\n }\n\n return quantity\n },\n },\n total: {\n title: formatMessage(quoteMessages.total),\n headerRight: true,\n cellRenderer: ({ rowData }: any) => {\n return (\n <span className=\"tr w-100\">\n <FormattedCurrency\n value={\n rowData.sellingPrice\n ? (rowData.sellingPrice * rowData.quantity) / 100\n : 0\n }\n />\n </span>\n )\n },\n width: 100,\n },\n },\n }}\n items={items}\n emptyStateLabel={formatMessage(quoteMessages.emptyState)}\n />\n )\n\n const totalizers = [\n {\n label: formatMessage(quoteMessages.originalSubtotal),\n value: formatPrice(originalSubtotal),\n },\n {\n label: formatMessage(quoteMessages.percentageDiscount),\n value:\n updatingSubtotal && originalSubtotal\n ? `${Math.round(100 - (updatingSubtotal / originalSubtotal) * 100)}%`\n : `0%`,\n },\n {\n label: formatMessage(quoteMessages.quotedSubtotal),\n value: formatPrice(updatingSubtotal),\n },\n ...(quoteState.expirationDate && [\n {\n label: formatMessage(quoteMessages.expiration),\n value: formatDate(quoteState.expirationDate, {\n day: 'numeric',\n month: 'numeric',\n year: 'numeric',\n }),\n },\n ]),\n ...(quoteState.status && [\n {\n label: formatMessage(quoteMessages.status),\n value: (\n <Tag type={LabelByStatusMap[quoteState.status]}>\n <FormattedMessage\n id={\n statusMessages[quoteState.status as keyof typeof statusMessages]\n .id\n }\n />\n </Tag>\n ),\n },\n ]),\n ]\n\n if (!isNewQuote || !checkedExternalSellers?.length) {\n return renderTable(quoteState.items, totalizers)\n }\n\n const itemsBySeller: Record<string, any> = {}\n\n quoteState.items.forEach((item: any) => {\n let sellerId: string = item.seller\n\n if (!checkedExternalSellers.includes(item.seller)) {\n sellerId = '1'\n }\n\n if (!itemsBySeller[sellerId]) {\n itemsBySeller[sellerId] = { items: [] }\n }\n\n itemsBySeller[sellerId].items.push(item)\n itemsBySeller[sellerId].sellerName = checkedSellers.find(\n (seller: any) => seller.id === sellerId\n )?.name\n })\n\n return (\n <div className=\"flex flex-column\">\n {!quoteState.parentQuote && (\n <div className=\"mb6\">\n <Totalizer items={totalizers} />\n </div>\n )}\n {Object.entries(itemsBySeller).map(([seller, sellerQuote]: any) => (\n <ChildrenQuoteCard key={seller} title={sellerQuote.sellerName}>\n {renderTable(sellerQuote.items)}\n </ChildrenQuoteCard>\n ))}\n </div>\n )\n}\n\nfunction ChildrenQuoteCard({ children, title }: React.PropsWithChildren<any>) {\n const [open, setOpen] = useState(true)\n\n return (\n <div className=\"mb6\">\n <Card>\n <Collapsible\n isOpen={open}\n onClick={() => setOpen((prev) => !prev)}\n header={title}\n >\n <div className=\"pv4\">{children}</div>\n </Collapsible>\n </Card>\n </div>\n )\n}\n\nexport default QuoteTable\n\n```"
}
] |
code_b2b-quotes_753e4fbb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/components/QuoteDetails/QuoteName.tsx from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { useIntl } from 'react-intl'\nimport { Input } from 'vtex.styleguide'\n\nimport { quoteMessages } from '../../utils/messages'\n\nconst QuoteName = ({\n isNewQuote,\n quoteState,\n formState,\n onChange,\n childrenQuantity,\n sellerName,\n}: any) => {\n const { formatMessage } = useIntl()\n\n return isNewQuote ? (\n <div className=\"w-50-l mb5\">\n <Input\n size=\"large\"\n placeholder={formatMessage(quoteMessages.placeholderName)}\n dataAttributes={{\n 'hj-white-list': true,\n test: 'string',\n }}\n label={formatMessage(quoteMessages.labelName)}\n value={quoteState.referenceName}\n errorMessage={formState.errorMessage}\n onChange={onChange}\n />\n </div>\n ) : (\n <h3 className=\"t-heading-3 mb8\">\n {quoteState.referenceName}\n {childrenQuantity > 0 && (\n <span className=\"v-mid c-muted-2 pl3 t-heading-4\">\n ({childrenQuantity})\n </span>\n )}\n {sellerName && (\n <div className=\"c-muted-2 pt2 t-heading-4\">({sellerName})</div>\n )}\n </h3>\n )\n}\n\nexport default QuoteName\n\n```"
}
] |
code_b2b-quotes_a4068e72
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/components/QuoteDetails/QuoteChildren.tsx from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { memo, useMemo, useState } from 'react'\nimport { FormattedMessage, useIntl } from 'react-intl'\nimport { formatCurrency } from 'vtex.format-currency'\nimport { useRuntime } from 'vtex.render-runtime'\nimport {\n Button,\n Card,\n Collapsible,\n Tab,\n Tabs,\n Tag,\n Totalizer,\n} from 'vtex.styleguide'\n\nimport { isQuoteUsable } from '../../utils/helpers'\nimport { quoteMessages, statusMessages } from '../../utils/messages'\nimport { LabelByStatusMap } from '../../utils/status'\nimport QuoteTable from './QuoteTable'\nimport QuoteUpdateHistory from './QuoteUpdateHistory'\n\ninterface Props {\n quote: Quote\n isSalesRep: boolean\n handleUseQuote: (quote: Quote) => void\n permissions: string[]\n usingParentQuote: boolean\n usingQuoteChild?: string\n}\n\nconst QuoteChildren: React.FC<Props> = ({\n quote,\n isSalesRep,\n handleUseQuote,\n permissions,\n usingParentQuote,\n usingQuoteChild,\n}) => {\n const { culture, navigate } = useRuntime()\n const intl = useIntl()\n const { formatMessage, formatDate } = intl\n const [open, setOpen] = useState(true)\n const [loadingViewQuote, setLoadingViewQuote] = useState(false)\n const [currentTab, setCurrentTab] = useState<number | null>(1)\n const {\n id,\n items,\n subtotal,\n status,\n seller,\n sellerName,\n expirationDate,\n updateHistory,\n } = quote\n\n const formatPrice = (value: number) =>\n formatCurrency({\n intl,\n culture,\n value: value / 100,\n })\n\n const originalSubtotal = useMemo(\n () =>\n (items ?? []).reduce((acc, item) => {\n return acc + item.price * item.quantity\n }, 0),\n [items]\n )\n\n const discount = useMemo(\n () => Math.round(100 - (subtotal / originalSubtotal) * 100),\n [originalSubtotal, subtotal]\n )\n\n const quoteUsable = isQuoteUsable(permissions, status)\n\n return (\n <div className=\"mb5\">\n <Card>\n <Collapsible\n onClick={() => setOpen((prev) => !prev)}\n header={\n <div className=\"flex justify-between items-center\">\n <div>\n <span className=\"mr3\">{sellerName ?? seller}</span>\n <Tag type={LabelByStatusMap[status]}>\n <FormattedMessage\n id={\n statusMessages[status as keyof typeof statusMessages]?.id\n }\n />\n </Tag>\n </div>\n <div className=\"flex flex-column-s flex-row-l justify-start items-center\">\n <span className=\"t-mini c-muted-2 mr3\">\n {formatMessage(quoteMessages.expiration)}\n </span>\n <span>\n {expirationDate\n ? formatDate(expirationDate, {\n day: 'numeric',\n month: 'numeric',\n year: 'numeric',\n })\n : '---'}\n </span>\n </div>\n </div>\n }\n isOpen={open}\n >\n <div className=\"pt6\">\n <div className=\"mb5\">\n <Totalizer\n items={[\n {\n label: formatMessage(quoteMessages.percentageDiscount),\n value: `${discount}%`,\n },\n {\n label: formatMessage(quoteMessages.originalSubtotal),\n value: formatPrice(originalSubtotal),\n },\n {\n label: formatMessage(quoteMessages.quotedSubtotal),\n value: formatPrice(subtotal),\n },\n ]}\n />\n </div>\n <Tabs>\n <Tab\n label={formatMessage(quoteMessages.productsTitle, {\n total: items.length,\n })}\n active={currentTab === 1}\n onClick={() => setCurrentTab(1)}\n >\n <div className=\"mt5\">\n <QuoteTable\n quoteState={quote}\n updatingSubtotal={subtotal}\n originalSubtotal={originalSubtotal}\n isSalesRep={isSalesRep}\n formState={{ isEditable: false }}\n />\n </div>\n </Tab>\n <Tab\n label={formatMessage(quoteMessages.historyTitle)}\n active={currentTab === 2}\n onClick={() => setCurrentTab(2)}\n >\n <div className=\"flex flex-column-s flex-column-l\">\n <QuoteUpdateHistory updateHistory={updateHistory} />\n </div>\n </Tab>\n </Tabs>\n <div className=\"flex mt6 justify-end\">\n <Button\n variation=\"secondary\"\n size=\"small\"\n isLoading={loadingViewQuote}\n onClick={() => {\n setLoadingViewQuote(true)\n\n navigate({\n page: 'store.b2b-quote-details',\n params: { id },\n query: 'parent',\n })\n }}\n >\n {formatMessage(quoteMessages.updatePageTitle)}\n </Button>\n <div className=\"ml3\">\n <Button\n size=\"small\"\n disabled={!quoteUsable}\n isLoading={usingParentQuote || usingQuoteChild === id}\n onClick={() => handleUseQuote(quote)}\n >\n {formatMessage(quoteMessages.useQuote)}\n </Button>\n </div>\n </div>\n </div>\n </Collapsible>\n </Card>\n </div>\n )\n}\n\nexport default memo(QuoteChildren)\n\n```"
}
] |
code_b2b-quotes_6191db1b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/components/QuoteDetails/AlertMessage.tsx from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { Alert } from 'vtex.styleguide'\nimport { FormattedMessage } from 'react-intl'\nimport React from 'react'\n\nconst AlertMessage = ({ quoteState, noteState }: any) =>\n quoteState.items.some((item: any) => item.error) ? (\n <div className=\"mb4\">\n <Alert type=\"error\">\n <FormattedMessage\n id=\"store/b2b-quotes.quote-details.discount-error\"\n values={{ count: noteState.length }}\n />\n </Alert>\n </div>\n ) : null\n\nexport default AlertMessage\n\n```"
}
] |
code_b2b-quotes_5e073962
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/components/QuoteDetails/QuoteDetailsNotAuthenticated.tsx from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { Layout, PageBlock, PageHeader, Spinner } from 'vtex.styleguide'\nimport { FormattedMessage, useIntl } from 'react-intl'\nimport React from 'react'\n\nimport { quoteMessages } from '../../utils/messages'\n\nconst QuoteDetailsNotAuthenticated = ({\n isNewQuote,\n permissionsLoading,\n isAuthenticated,\n onLinkClick,\n}: any) => {\n const { formatMessage } = useIntl()\n\n const Message = () =>\n !isAuthenticated ? (\n <FormattedMessage id=\"store/b2b-quotes.error.notAuthenticated\" />\n ) : (\n <FormattedMessage id=\"store/b2b-quotes.error.notPermitted\" />\n )\n\n return (\n <Layout fullWidth>\n <div className=\"mw9 center\">\n <Layout\n fullWidth\n pageHeader={\n <PageHeader\n title={formatMessage(\n isNewQuote\n ? quoteMessages.createPageTitle\n : quoteMessages.updatePageTitle\n )}\n linkLabel={formatMessage(quoteMessages.back)}\n onLinkClick={() => onLinkClick}\n />\n }\n >\n <PageBlock>\n {permissionsLoading ? <Spinner /> : <Message />}\n </PageBlock>\n </Layout>\n </div>\n </Layout>\n )\n}\n\nexport default QuoteDetailsNotAuthenticated\n\n```"
}
] |
code_b2b-quotes_974b2c7e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/components/QuoteDetails/QuoteUpdateHistory.tsx from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { FormattedMessage, useIntl } from 'react-intl'\nimport { Card, Tag } from 'vtex.styleguide'\n\nimport { statusMessages } from '../../utils/messages'\nimport { LabelByStatusMap } from '../../utils/status'\n\nconst QuoteUpdateHistory = ({ updateHistory }: any) => {\n const { formatDate } = useIntl()\n\n return (\n <div className=\"mt3\">\n {updateHistory.length > 0 && (\n <h3 className=\"t-heading-4\">\n <FormattedMessage id=\"store/b2b-quotes.quote-details.update-history.title\" />\n </h3>\n )}\n {updateHistory.map((update: any, index: number) => {\n return (\n <div key={index} className=\"ph4 pv2\">\n <Card>\n <div>\n <FormattedMessage\n id=\"store/b2b-quotes.quote-details.update-history.update-details\"\n values={{\n date: formatDate(update.date, {\n day: 'numeric',\n month: 'numeric',\n year: 'numeric',\n }),\n email: update.email,\n role: update.role,\n status: (\n <Tag type={LabelByStatusMap[update.status]}>\n <FormattedMessage\n id={\n statusMessages[\n update.status as keyof typeof statusMessages\n ].id\n }\n />\n </Tag>\n ),\n index,\n }}\n />\n </div>\n {update.note && (\n <div>\n <b>\n <FormattedMessage id=\"store/b2b-quotes.quote-details.update-history.notes\" />\n </b>\n <br />\n {update.note}\n </div>\n )}\n </Card>\n </div>\n )\n })}\n </div>\n )\n}\n\nexport default QuoteUpdateHistory\n\n```"
}
] |
code_b2b-quotes_1769f9c7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/components/QuoteDetails/QuoteDetails.tsx from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n/* eslint-disable react/display-name */\nimport type { ChangeEventHandler, FunctionComponent } from 'react'\nimport React, {\n Fragment,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from 'react'\nimport { useMutation, useQuery } from 'react-apollo'\nimport { FormattedMessage, useIntl } from 'react-intl'\nimport { useCheckoutURL } from 'vtex.checkout-resources/Utils'\nimport { OrderForm } from 'vtex.order-manager'\nimport { useRuntime } from 'vtex.render-runtime'\nimport {\n Alert,\n Button,\n DatePicker,\n Layout,\n PageBlock,\n PageHeader,\n Spinner,\n Textarea,\n ToastContext,\n} from 'vtex.styleguide'\n\nimport CHECK_SELLER_QUOTES from '../../graphql/checkSellerQuotes.graphql'\nimport CLEAR_CART from '../../graphql/clearCartMutation.graphql'\nimport CREATE_QUOTE from '../../graphql/createQuote.graphql'\nimport GET_AUTH_RULES from '../../graphql/getDimension.graphql'\nimport GET_CHILDREN_QUOTES from '../../graphql/getFullChildrenQuotes.graphql'\nimport GET_PERMISSIONS from '../../graphql/getPermissions.graphql'\nimport GET_QUOTE from '../../graphql/getQuote.graphql'\nimport GET_ORDERFORM from '../../graphql/orderForm.gql'\nimport UPDATE_QUOTE from '../../graphql/updateQuote.graphql'\nimport USE_QUOTE from '../../graphql/useQuote.graphql'\nimport useCheckout from '../../modules/checkoutHook'\nimport {\n initQuoteFromOrderForm,\n isQuoteUsable,\n useSessionResponse,\n} from '../../utils/helpers'\nimport { quoteMessages } from '../../utils/messages'\nimport { sendCreateQuoteMetric } from '../../utils/metrics/createQuote'\nimport type { UseQuoteMetricsParams } from '../../utils/metrics/useQuote'\nimport { sendUseQuoteMetric } from '../../utils/metrics/useQuote'\nimport { arrayShallowEqual } from '../../utils/shallowEquals'\nimport { Status } from '../../utils/status'\nimport storageFactory from '../../utils/storage'\nimport AlertMessage from './AlertMessage'\nimport PercentageDiscount from './PercentageDiscount'\nimport QuoteChildren from './QuoteChildren'\nimport QuoteDetailsNotAuthenticated from './QuoteDetailsNotAuthenticated'\nimport QuoteName from './QuoteName'\nimport QuoteTable from './QuoteTable'\nimport QuoteUpdateHistory from './QuoteUpdateHistory'\nimport SaveButtons from './SaveButtons'\n\nconst localStore = storageFactory(() => localStorage)\nconst MAX_DISCOUNT_PERCENTAGE = 99\n\nlet isAuthenticated =\n JSON.parse(String(localStore.getItem('b2bquotes_isAuthenticated'))) ?? false\n\nconst initialState = {\n id: '',\n costCenter: '',\n costCenterName: '',\n creationDate: '',\n creatorEmail: '',\n creatorRole: '',\n expirationDate: '',\n items: [],\n lastUpdate: '',\n organization: '',\n organizationName: '',\n referenceName: '',\n status: '',\n subtotal: 0,\n updateHistory: [],\n viewedByCustomer: false,\n viewedBySales: false,\n hasChildren: false,\n}\n\nconst QuoteDetails: FunctionComponent = () => {\n /**\n * constants\n */\n const {\n route: { params },\n query,\n navigate,\n workspace,\n account,\n } = useRuntime()\n\n const isNewQuote = !params?.id\n const sessionResponse: any = useSessionResponse()\n const intl = useIntl()\n const { formatMessage } = intl\n const { url: checkoutUrl } = useCheckoutURL()\n const goToCheckout = useCheckout()\n const { setOrderForm }: OrderFormContext = OrderForm.useOrderForm()\n const { showToast } = useContext(ToastContext)\n\n const toastMessage = (message: MessageDescriptor) => {\n const translatedMessage = formatMessage(message)\n const action = undefined\n\n showToast({ message: translatedMessage, duration: 5000, action })\n }\n\n const [quoteState, setQuoteState] = useState<Quote>(initialState)\n const [formState, setFormState] = useState({\n isEditable: false,\n canAddNotes: false,\n errorMessage: '',\n })\n\n const [orderFormState, setOrderFormState] = useState('')\n const [noteState, setNoteState] = useState('')\n const [maxDiscountState, setMaxDiscountState] = useState(\n MAX_DISCOUNT_PERCENTAGE\n )\n\n const [discountState, setDiscountState] = useState(0)\n const [updatingQuoteState, setUpdatingQuoteState] = useState(false)\n const [usingQuoteState, setUsingQuoteState] = useState(false)\n const [usingQuoteChild, setUsingQuoteChild] = useState<string>()\n const [originalSubtotal, setOriginalSubtotal] = useState(0)\n const [updatingSubtotal, setUpdatingSubtotal] = useState(0)\n const [sentToSalesRep, setSentToSalesRep] = useState(false)\n const getQuoteVariables = { id: params?.id }\n\n /**\n * GraphQL Queries\n */\n const { data, loading, refetch } = useQuery(GET_QUOTE, {\n fetchPolicy: 'network-only',\n variables: getQuoteVariables,\n ssr: false,\n skip: isNewQuote,\n })\n\n const {\n data: childrenQuoteList,\n loading: childrenQuotesLoading,\n refetch: refetchChildrenQuotes,\n } = useQuery(GET_CHILDREN_QUOTES, {\n fetchPolicy: 'network-only',\n variables: getQuoteVariables,\n ssr: false,\n skip: isNewQuote || !data?.getQuote?.hasChildren,\n })\n\n const childrenQuotes = childrenQuoteList?.getChildrenQuotes\n\n const sellers = Array.from(\n new Set(quoteState.items.map((item: QuoteItem) => item.seller))\n )\n\n const externalSellers = sellers.filter((seller) => seller !== '1')\n\n const {\n data: checkSellerQuotesData,\n loading: checkSellerQuotesLoading,\n } = useQuery(CHECK_SELLER_QUOTES, {\n fetchPolicy: 'network-only',\n ssr: false,\n skip: !isNewQuote,\n variables: { sellers: externalSellers },\n })\n\n const checkedSellers = checkSellerQuotesData?.checkSellerQuotes\n\n const hasCheckedExternalSellers = !!checkedSellers?.some(\n (seller: Seller) => seller.id !== '1'\n )\n\n const {\n data: orderFormData,\n refetch: refetchOrderForm,\n } = useQuery(GET_ORDERFORM, { ssr: false, fetchPolicy: 'network-only' })\n\n const { data: orderAuthData } = useQuery(GET_AUTH_RULES, { ssr: false })\n const {\n data: permissionsData,\n loading: permissionsLoading,\n } = useQuery(GET_PERMISSIONS, { ssr: false })\n\n const {\n id = '',\n items = [],\n status = '',\n expirationDate,\n childrenQuantity,\n parentQuote,\n seller,\n sellerName,\n } = data?.getQuote ?? {}\n\n const { permissions = [] } = permissionsData?.checkUserPermission ?? {}\n const isSalesRep = permissions.some(\n (permission: string) => permission.indexOf('edit-quotes') >= 0\n )\n\n const quoteUsable = isQuoteUsable(permissions, status)\n\n const quoteDeclinable =\n permissions.includes('decline-quotes') &&\n (!seller || seller === '1') &&\n !quoteState.hasChildren &&\n status &&\n status !== Status.EXPIRED &&\n status !== Status.DECLINED\n\n /**\n * GraphQL Mutations\n */\n const [createQuoteMutation] = useMutation(CREATE_QUOTE)\n const [updateQuote] = useMutation(UPDATE_QUOTE)\n const [mutationUseQuote] = useMutation(USE_QUOTE)\n const [clearCart] = useMutation(CLEAR_CART)\n /**\n * functions\n */\n const setEditable = useCallback(() => {\n let isEditable = true\n let canAddNotes = true\n\n if (parentQuote && seller && seller !== '1') {\n isEditable = false\n }\n\n if (isNewQuote && sellers.length > 1 && hasCheckedExternalSellers) {\n canAddNotes = false\n }\n\n setFormState((f) => {\n return {\n ...f,\n isEditable,\n canAddNotes,\n }\n })\n }, [\n hasCheckedExternalSellers,\n isNewQuote,\n parentQuote,\n seller,\n sellers.length,\n ])\n\n const handleClearCart = (orderFormId: string) => {\n return clearCart({\n variables: {\n orderFormId,\n },\n })\n }\n\n const handleCreateQuote = (sendToSalesRep: boolean) => {\n const { orderForm } = orderFormData\n\n setUpdatingQuoteState(true)\n const { referenceName, items: quoteItems } = quoteState\n const cart = {\n referenceName,\n items: quoteItems,\n subtotal: updatingSubtotal,\n note: noteState,\n sendToSalesRep,\n }\n\n createQuoteMutation({\n variables: cart,\n })\n .then((result: any) => {\n if (result.data.createQuote) {\n const metricsParam = {\n quoteId: result.data.createQuote,\n sessionResponse,\n workspace,\n sendToSalesRep,\n account,\n }\n\n sendCreateQuoteMetric(metricsParam)\n\n toastMessage(quoteMessages.createSuccess)\n handleClearCart(orderForm.orderFormId).then(() => {\n setQuoteState(initialState)\n setUpdatingSubtotal(0)\n setOriginalSubtotal(0)\n setTimeout(() => {\n refetchOrderForm().then((resp: any) => {\n if (resp?.data?.orderForm) {\n setOrderForm(resp?.data?.orderForm)\n }\n\n setUpdatingQuoteState(false)\n navigate({\n page: 'store.b2b-quotes',\n fallbackToWindowLocation: true,\n fetchPage: true,\n })\n\n return resp\n })\n }, 500)\n })\n } else {\n toastMessage(quoteMessages.createError)\n setUpdatingQuoteState(false)\n }\n })\n .catch(() => {\n toastMessage(quoteMessages.createError)\n setUpdatingQuoteState(false)\n })\n }\n\n const createQuote = (sendToSalesRep: boolean) => {\n setSentToSalesRep(sendToSalesRep)\n if (!quoteState.referenceName) {\n setFormState({\n ...formState,\n errorMessage: formatMessage(quoteMessages.required),\n })\n } else {\n handleCreateQuote(sendToSalesRep)\n }\n }\n\n const handleAfterSaveQuote = () => {\n if (parentQuote && query?.parent !== undefined) {\n navigate({\n page: 'store.b2b-quote-details',\n params: { id: parentQuote },\n })\n } else {\n refetch(getQuoteVariables)\n refetchChildrenQuotes(getQuoteVariables)\n }\n }\n\n const handleSaveQuote = () => {\n setUpdatingQuoteState(true)\n const {\n id: _id,\n items: _items,\n expirationDate: _expirationDate,\n } = quoteState\n\n const itemsChanged = !arrayShallowEqual(data.getQuote.items, _items)\n\n updateQuote({\n variables: {\n id: _id,\n ...(itemsChanged && { items: _items }),\n ...(itemsChanged && { subtotal: updatingSubtotal }),\n ...(noteState && { note: noteState }),\n decline: false,\n expirationDate: _expirationDate,\n },\n })\n .catch((error) => {\n console.error(error)\n toastMessage(quoteMessages.updateError)\n setUpdatingQuoteState(false)\n })\n .then(() => {\n setNoteState('')\n setDiscountState(0)\n setUpdatingQuoteState(false)\n toastMessage(quoteMessages.updateSuccess)\n handleAfterSaveQuote()\n })\n }\n\n const updateUseState = (quote: Quote, newState: boolean) => {\n if (quote.parentQuote) {\n if (newState) {\n setUsingQuoteChild(quote.id)\n\n return\n }\n\n setUsingQuoteChild(undefined)\n\n return\n }\n\n setUsingQuoteState(newState)\n }\n\n const handleUseQuote = (quote: Quote) => {\n updateUseState(quote, true)\n const { id: _id } = quote\n const variables = {\n id: _id,\n orderFormId: orderFormState,\n }\n\n mutationUseQuote({\n variables,\n })\n .catch((error) => {\n console.error(error)\n toastMessage(quoteMessages.useError)\n updateUseState(quote, false)\n })\n .then(() => {\n const metricsParam: UseQuoteMetricsParams = {\n quoteState: quote,\n orderFormId: variables.orderFormId,\n account,\n sessionResponse,\n }\n\n sendUseQuoteMetric(metricsParam)\n goToCheckout(checkoutUrl)\n updateUseState(quote, false)\n })\n }\n\n const handleDeclineQuote = () => {\n setUpdatingQuoteState(true)\n updateQuote({\n variables: {\n id,\n ...(noteState && { note: noteState }),\n decline: true,\n },\n })\n .catch((error) => {\n console.error(error)\n toastMessage(quoteMessages.updateError)\n setUpdatingQuoteState(false)\n })\n .then(() => {\n setNoteState('')\n setDiscountState(0)\n setUpdatingQuoteState(false)\n toastMessage(quoteMessages.updateSuccess)\n handleAfterSaveQuote()\n })\n }\n\n const handleUpdateSellingPrice: (\n id: string\n ) => ChangeEventHandler<HTMLInputElement> = (itemId) => (event) => {\n const newItems = quoteState.items.map((item: QuoteItem) => {\n if (item.id === itemId) {\n let newPrice = ((event.target.value as unknown) as number) * 100\n\n if (newPrice > item.price) {\n newPrice = item.price\n }\n\n return {\n ...item,\n sellingPrice: newPrice,\n error:\n !newPrice || newPrice / item.price < (100 - maxDiscountState) / 100\n ? true\n : undefined, // setting error to false will cause create/update mutation to error\n }\n }\n\n return item\n })\n\n setQuoteState({\n ...quoteState,\n items: newItems,\n })\n }\n\n const handleUpdateQuantity: (\n id: string\n ) => ChangeEventHandler<HTMLInputElement> = (itemId) => (event) => {\n let newSubtotal = 0\n const newItems = quoteState.items.map((item: QuoteItem) => {\n if (item.id === itemId) {\n let quantity =\n !new RegExp(/[^\\d]/g).test(event.target.value) && event.target.value\n ? parseInt(event.target.value, 10)\n : 1\n\n if (quantity <= 0) {\n quantity = 1\n } else if (quantity > 50) {\n quantity = 50\n }\n\n newSubtotal += item.sellingPrice * quantity\n\n return {\n ...item,\n quantity,\n }\n }\n\n newSubtotal += item.sellingPrice * item.quantity\n\n return item\n })\n\n setUpdatingSubtotal(newSubtotal)\n setQuoteState({\n ...quoteState,\n items: newItems,\n subtotal: newSubtotal,\n })\n }\n\n const handlePercentageDiscount = (percent: number) => {\n setDiscountState(percent)\n let newItems = [] as QuoteItem[]\n let newSubtotal = 0\n\n if (percent === 0) {\n if (isNewQuote) {\n newItems = initQuoteFromOrderForm(orderFormData?.orderForm)\n } else {\n newItems = data.getQuote.items\n }\n } else {\n quoteState.items.forEach((item: QuoteItem) => {\n const newSellingPrice = Math.round(item.price * ((100 - percent) / 100))\n\n newSubtotal += newSellingPrice * item.quantity\n\n newItems.push({ ...item, sellingPrice: newSellingPrice })\n })\n }\n\n setUpdatingSubtotal(newSubtotal)\n setQuoteState({\n ...quoteState,\n items: newItems,\n subtotal: newSubtotal,\n })\n }\n\n /**\n * effects\n */\n useEffect(() => {\n if (!quoteState.items.find((item) => item.error)) {\n setUpdatingSubtotal(\n quoteState.items.reduce(\n (sum, item) => sum + item.sellingPrice * item.quantity,\n 0\n )\n )\n }\n\n const price = quoteState.items.reduce(\n (sum: number, item: QuoteItem) => sum + item.price * item.quantity,\n 0\n )\n\n setOriginalSubtotal(price)\n }, [quoteState])\n\n useEffect(() => {\n if (!orderFormData?.orderForm) return\n\n setOrderFormState(orderFormData.orderForm.orderFormId)\n }, [orderFormData])\n\n useEffect(() => {\n if (!orderAuthData?.getDimension?.ruleCollection?.length) return\n\n const { ruleCollection } = orderAuthData.getDimension\n\n const maxDiscountPercentage =\n ruleCollection.find(\n (collection: any) =>\n collection?.trigger?.effect?.description === 'DenyEffect'\n )?.trigger?.condition?.greatherThan ?? MAX_DISCOUNT_PERCENTAGE\n\n setMaxDiscountState(maxDiscountPercentage)\n }, [orderAuthData])\n\n useEffect(() => {\n if (!data?.getQuote) return\n\n const {\n getQuote: {\n id: _id,\n costCenter,\n costCenterName,\n creationDate,\n creatorEmail,\n creatorRole,\n expirationDate: _expirationDate,\n items: _items,\n lastUpdate,\n organization,\n organizationName,\n referenceName,\n status: _status,\n subtotal,\n updateHistory,\n viewedByCustomer,\n viewedBySales,\n hasChildren,\n },\n } = data\n\n setUpdatingSubtotal(subtotal)\n setQuoteState({\n id: _id,\n costCenter,\n costCenterName,\n creationDate,\n creatorEmail,\n creatorRole,\n expirationDate: _expirationDate,\n items: _items,\n lastUpdate,\n organization,\n organizationName,\n referenceName,\n status: _status,\n subtotal,\n updateHistory,\n viewedByCustomer,\n viewedBySales,\n hasChildren,\n })\n\n if (\n _status === Status.PENDING ||\n _status === Status.READY ||\n _status === Status.REVISED\n ) {\n setEditable()\n }\n }, [data, setEditable])\n\n useEffect(() => {\n // only run this function if this is a new quote and there is orderForm data\n if (!(isNewQuote && orderFormData?.orderForm?.items?.length)) return\n\n let subtotal = 0\n const itemsCopy = initQuoteFromOrderForm(orderFormData.orderForm)\n\n itemsCopy.forEach((item: QuoteItem) => {\n subtotal += item.sellingPrice * item.quantity\n })\n\n setEditable()\n setQuoteState((prevState) => {\n return { ...prevState, items: itemsCopy }\n })\n setUpdatingSubtotal(subtotal)\n }, [isNewQuote, orderFormData, setEditable])\n\n if (sessionResponse) {\n isAuthenticated =\n sessionResponse?.namespaces?.profile?.isAuthenticated?.value === 'true'\n\n localStore.setItem(\n 'b2bquotes_isAuthenticated',\n JSON.stringify(isAuthenticated)\n )\n }\n\n if (\n !isAuthenticated ||\n !permissions?.length ||\n (!isNewQuote &&\n !permissions.some((permission: string) =>\n permission.includes('access-quotes')\n )) ||\n (isNewQuote && !permissions.includes('create-quotes'))\n ) {\n return (\n <QuoteDetailsNotAuthenticated\n isNewQuote={isNewQuote}\n permissionsLoading={permissionsLoading}\n isAuthenticated={isAuthenticated}\n onLinkClick={() => {\n navigate({\n page: 'store.b2b-quotes',\n })\n }}\n />\n )\n }\n\n return (\n <Layout fullWidth>\n <div className=\"mw9 center\">\n <Layout\n fullWidth\n pageHeader={\n <PageHeader\n title={formatMessage(\n isNewQuote\n ? quoteMessages.createPageTitle\n : quoteMessages.updatePageTitle\n )}\n linkLabel={formatMessage(quoteMessages.back)}\n onLinkClick={() => {\n if (parentQuote && query?.parent !== undefined) {\n navigate({\n page: 'store.b2b-quote-details',\n params: { id: parentQuote },\n })\n } else {\n navigate({\n page: 'store.b2b-quotes',\n })\n }\n }}\n />\n }\n >\n <PageBlock>\n {loading || childrenQuotesLoading || checkSellerQuotesLoading ? (\n <Spinner />\n ) : (\n <Fragment>\n <AlertMessage quoteState={quoteState} noteState={noteState} />\n\n <div className=\"flex flex-column pl5\">\n <div className=\"mb5 flex flex-column-s flex-row-l justify-between items-center\">\n <QuoteName\n childrenQuantity={childrenQuantity}\n sellerName={sellerName || seller}\n isNewQuote={isNewQuote}\n quoteState={quoteState}\n setQuoteState={setQuoteState}\n formState={formState}\n onChange={(e: any) => {\n setQuoteState({\n ...quoteState,\n referenceName: e.target.value,\n })\n }}\n />\n\n <div className=\"nowrap\">\n <SaveButtons\n isNewQuote={isNewQuote}\n updatingQuoteState={updatingQuoteState}\n sentToSalesRep={sentToSalesRep}\n quoteState={quoteState}\n onSaveForLater={() => {\n createQuote(false)\n }}\n onSaveQuote={() => {\n if (isNewQuote) {\n createQuote(!isSalesRep)\n } else {\n handleSaveQuote()\n }\n }}\n quoteItems={items}\n expirationDate={expirationDate}\n noteState={noteState}\n isSalesRep={isSalesRep}\n />\n {quoteDeclinable && (\n <span className=\"mr4\">\n <Button\n variation=\"danger\"\n onClick={() => handleDeclineQuote()}\n disabled={\n !formState.isEditable || updatingQuoteState\n }\n >\n <FormattedMessage id=\"store/b2b-quotes.quote-details.decline\" />\n </Button>\n </span>\n )}\n\n {quoteUsable && (\n <span className=\"mr4\">\n <Button\n variation=\"primary\"\n onClick={() => handleUseQuote(quoteState)}\n isLoading={usingQuoteState}\n >\n <FormattedMessage id=\"store/b2b-quotes.quote-details.use-quote\" />\n </Button>\n </span>\n )}\n </div>\n </div>\n </div>\n\n {quoteState.hasChildren && !!childrenQuotes?.length ? (\n childrenQuotes.map((quote: Quote) => (\n <QuoteChildren\n key={quote.id}\n quote={quote}\n isSalesRep={isSalesRep}\n usingParentQuote={usingQuoteState}\n usingQuoteChild={usingQuoteChild}\n handleUseQuote={handleUseQuote}\n permissions={permissions}\n />\n ))\n ) : (\n <div className=\"pa5\">\n <QuoteTable\n isNewQuote={isNewQuote}\n quoteState={quoteState}\n updatingSubtotal={updatingSubtotal}\n originalSubtotal={originalSubtotal}\n isSalesRep={isSalesRep}\n formState={formState}\n maxDiscountState={maxDiscountState}\n discountState={discountState}\n onUpdateSellingPrice={handleUpdateSellingPrice}\n onUpdateQuantity={handleUpdateQuantity}\n checkedSellers={checkedSellers}\n />\n {formState.isEditable && isSalesRep && (\n <div className=\"mt3\">\n <h3 className=\"t-heading-4 mb4\">\n <FormattedMessage id=\"store/b2b-quotes.quote-details.apply-discount.title\" />\n </h3>\n <div className=\"pa5\">\n <PercentageDiscount\n updatingSubtotal={updatingSubtotal}\n originalSubtotal={originalSubtotal}\n maxDiscountState={maxDiscountState}\n discountState={discountState}\n handlePercentageDiscount={handlePercentageDiscount}\n />\n {maxDiscountState < 100 && (\n <div className=\"mt1\">\n <FormattedMessage\n id=\"store/b2b-quotes.quote-details.apply-discount.maxDiscount-text\"\n values={{ maxDiscount: maxDiscountState }}\n />\n </div>\n )}\n </div>\n </div>\n )}\n\n {quoteState.expirationDate &&\n formState.isEditable &&\n isSalesRep && (\n <div className=\"mt3\">\n <h3 className=\"t-heading-4\">\n <FormattedMessage id=\"store/b2b-quotes.quote-details.expiration-date-change.title\" />\n </h3>\n <div className=\"pa5\">\n <DatePicker\n label={formatMessage(quoteMessages.expiration)}\n minDate={new Date()}\n locale=\"en-US\"\n value={new Date(quoteState.expirationDate)}\n onChange={(date: Date) =>\n setQuoteState({\n ...quoteState,\n expirationDate: date.toISOString(),\n })\n }\n />\n </div>\n </div>\n )}\n\n <QuoteUpdateHistory\n updateHistory={quoteState.updateHistory}\n />\n\n {formState.canAddNotes && (\n <div className=\"mt3 pa5\">\n <Textarea\n label={formatMessage(quoteMessages.addNote)}\n value={noteState}\n onChange={(\n e: React.ChangeEvent<HTMLInputElement>\n ) => {\n setNoteState(e.target.value)\n }}\n characterCountdownText={\n <FormattedMessage\n id=\"store/b2b-quotes.create.characterLeft\"\n values={{ count: noteState.length }}\n />\n }\n maxLength=\"500\"\n rows=\"4\"\n />\n </div>\n )}\n\n {isNewQuote && !formState.canAddNotes && (\n <div className=\"mt3 pa5\">\n <Alert type=\"warning\">\n {formatMessage(\n quoteMessages.notesAfterCreatedHelpText\n )}\n </Alert>\n </div>\n )}\n </div>\n )}\n </Fragment>\n )}\n </PageBlock>\n </Layout>\n </div>\n </Layout>\n )\n}\n\nexport default QuoteDetails\n\n```"
}
] |
code_b2b-quotes_789f8303
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-quotes/react/components/QuoteDetails/PercentageDiscount.tsx from the b2b-quotes VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment } from 'react'\nimport { Slider } from 'vtex.styleguide'\nimport { FormattedMessage } from 'react-intl'\n\nconst PercentageDiscount = ({\n updatingSubtotal,\n originalSubtotal,\n maxDiscountState,\n discountState,\n handlePercentageDiscount,\n}: any) => {\n if (\n discountState === 0 ||\n (updatingSubtotal !== undefined &&\n originalSubtotal !== undefined &&\n Math.round(100 - (updatingSubtotal / originalSubtotal) * 100) <=\n maxDiscountState)\n ) {\n return (\n <Fragment>\n <div className=\"mt5\">\n <Slider\n onChange={([value]: [number]) => {\n handlePercentageDiscount(value)\n }}\n min={0}\n max={maxDiscountState}\n step={1}\n disabled={false}\n defaultValues={[0]}\n alwaysShowCurrentValue\n formatValue={(a: number) => `${a}%`}\n value={discountState}\n />\n </div>\n\n <div className=\"mt1\">\n <FormattedMessage id=\"store/b2b-quotes.quote-details.apply-discount.help-text\" />\n </div>\n </Fragment>\n )\n }\n\n return (\n <div className=\"mt1\">\n <FormattedMessage id=\"store/b2b-quotes.quote-details.apply-discount.disabled-message\" />\n </div>\n )\n}\n\nexport default PercentageDiscount\n\n```"
}
] |
code_seller-financial-commission_4ce205ea
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/messages/en.json from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/navigation.section-title\": \"Financial commission\",\n \"admin/navigation.detail-title\": \"Detail\"\n}\n\n```"
}
] |
code_seller-financial-commission_a451dd69
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/messages/context.json from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/navigation.section-title\": \"Admin section title\",\n \"admin/navigation.detail-title\": \"Admin title\"\n}\n\n```"
}
] |
code_seller-financial-commission_9d300b3f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/admin/navigation.json from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n[\n {\n \"adminVersion\": 4,\n \"section\": \"orders\",\n \"titleId\": \"admin/navigation.section-title\",\n \"subSection\": \"commissionReport\",\n \"subSectionItems\": [\n {\n \"labelId\": \"admin/navigation.detail-title\",\n \"path\": \"/admin/commission-detail\"\n }\n ]\n }\n]\n\n```"
}
] |
code_seller-financial-commission_18f4daf1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/admin/routes.json from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin.app.detail\": {\n \"component\": \"commissionDetail\",\n \"path\": \"/admin/app/commission-detail\"\n },\n \"admin.app.invoiceDetail\": {\n \"component\": \"invoiceSellerDetail\",\n \"path\": \"/admin/app/commission-report/invoice/:id\"\n }\n}\n\n```"
}
] |
code_seller-financial-commission_ef675076
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/docs/README.md from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/{OrganizationName}/{AppName}) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# Seller financial commission\n\n**Seller Financial commission** provides a way to list all orders and invoices created by a specific seller, filter them by status or by a specific period of time.\n\n\n## **Install:**\n\nInstall `vtex.seller-financial-commission` in your account.\n\n```powershell\nvtex install vtex.seller-financial-commission\n```\n\n## **Features:**\n\n- List All Seller Orders and Invoices at the end of the billing cycle. <br/>\n - Each order is listed with its respective ID, Creation Date, Total Ammount, Total Commission, Rate and Status.\n - Each invoice is listed with its respective status and with its creation date.\n- Orders and Invoices can be filtered by Status or by creation date\n- Visualize invoice detail.\n \n- A copy of the invoice detail can be sent by e-mail. By default the e-mail will be sent to the vendor's address, but this value can be changed\n \n\n## **Components financial commission:**\n\nThis app allows you create the interface to show the information about the commissions of the sellers.\n\nAdd the components financial app in your new apps in the section dependencies of the manifest file.\n\n```powershell\n\"dependencies\":{\n \"vtex.components-financial-commission\": \"0.x\"\n}\n```\n\n`⚠️` See more details about this app related with the technical topics [Components financial](https://github.com/vtex-apps/components-financial-commission/)\n\n### Important:\n\n`🚫` Please, don't upload the file `yarn.lock`. Remove this file of the `commit`.\n\n`✅` When you clone the project, create your work branch from `develop`.\n\n`✅` Upload your changes by making a `pull request`.\n\n`⚠️` Not forget to update the version and documentation. This last only if this is necessary.\n\n```"
}
] |
code_seller-financial-commission_424f8e2c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/graphql/schema.graphql from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ntype Query {\n \"\"\"\n Request the marketplace to retrieve current seller's invoices\n \"\"\"\n sellerInvoices(sellerInvoiceParams: SellerInvoiceParams): ListInvoices\n @cacheControl(scope: PRIVATE, maxAge: LONG)\n \"\"\"\n Request the marketplace to retrieve an Invoice\n \"\"\"\n getInvoice(id: String!): Invoice @cacheControl(scope: PRIVATE, maxAge: SHORT)\n \"\"\"\n Retrieve orders to seller\n \"\"\"\n sellerOrders(searchOrdersParams: SearchOrdersParams): SearchOrdersResponse\n @cacheControl(scope: PRIVATE, maxAge: LONG)\n \"\"\"\n Retrieve template for order detail\n \"\"\"\n getTemplate: String @cacheControl(scope: PRIVATE, maxAge: LONG)\n}\n\ntype Mutation {\n \"\"\"\n Request the marketplace to create an Invoice\n \"\"\"\n createInvoice(invoiceData: InvoiceDataInput!): String\n \"\"\"\n Send invoice data to a specific email address\n \"\"\"\n sendEmail(emailData: EmailDataInput!): String\n}\n\n```"
}
] |
code_seller-financial-commission_36b7a784
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/node/service.json from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"memory\": 256,\n \"ttl\": 30,\n \"timeout\": 5,\n \"minReplicas\": 2,\n \"maxReplicas\": 5\n}\n\n```"
}
] |
code_seller-financial-commission_93580d26
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/node/package.json from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"@vtex/api\": \"6.45.12\",\n \"@vtex/clients\": \"^2.19.4\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^12.0.0\",\n \"@vtex/api\": \"6.45.12\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"tslint\": \"^5.0.0\",\n \"tslint-config-vtex\": \"^2.1.0\",\n \"typescript\": \"3.9.7\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit && tslint -c tslint.json './**/*.ts'\"\n },\n \"version\": \"0.2.2\"\n}\n\n```"
}
] |
code_seller-financial-commission_ac5da810
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/node/index.ts from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { ParamsContext, RecorderState } from '@vtex/api'\nimport { Service } from '@vtex/api'\n\nimport clients from './clients'\nimport type { Clients } from './clients'\nimport { queries, mutations } from './resolvers'\n\nexport default new Service<Clients, RecorderState, ParamsContext>({\n clients,\n graphql: {\n resolvers: {\n Query: {\n ...queries,\n },\n Mutation: {\n ...mutations,\n },\n },\n },\n})\n\n```"
}
] |
code_seller-financial-commission_3eb934ab
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/react/commissionDetail.tsx from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { detail as Detail } from 'vtex.components-financial-commission'\n\nimport SELLER_ORDERS from './graphql/sellerOrders.gql'\nimport CREATE_INVOICE from './graphql/createInvoice.gql'\nimport SELLER_INVOICES from './graphql/sellerInvoices.gql'\n\nfunction CommissionDetail() {\n const { account } = useRuntime()\n\n return (\n <Detail\n account={account}\n ordersQuery={SELLER_ORDERS}\n invoiceMutation={CREATE_INVOICE}\n invoicesQuery={SELLER_INVOICES}\n />\n )\n}\n\nexport default CommissionDetail\n\n```"
}
] |
code_seller-financial-commission_63585f66
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/react/package.json from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"seller-financial-commission\",\n \"version\": \"0.0.0\",\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"apollo-client\": \"^2.6.8\",\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/jest\": \"^25.1.4\",\n \"@types/node\": \"^13.9.8\",\n \"@types/react\": \"^16.9.31\",\n \"@vtex/test-tools\": \"^3.3.2\",\n \"@vtex/tsconfig\": \"^0.4.4\",\n \"apollo-cache-inmemory\": \"^1.6.5\",\n \"graphql\": \"^14.6.0\",\n \"typescript\": \"3.9.7\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.132.4/public/@types/vtex.render-runtime\"\n }\n}\n\n```"
}
] |
code_seller-financial-commission_65f495a4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/react/invoiceSellerDetail.tsx from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { invoiceDetail as InvoiceDetail } from 'vtex.components-financial-commission'\n\nimport GET_INVOICE from './graphql/getInvoice.gql'\nimport SEND_EMAIL from './graphql/sendEmail.gql'\nimport GET_TEMPLATE from './graphql/getTemplate.gql'\n\nconst InvoiceSellerDetail = () => {\n return (\n <InvoiceDetail\n invoiceQuery={GET_INVOICE}\n getTemplate={GET_TEMPLATE}\n sendEmail={SEND_EMAIL}\n />\n )\n}\n\nexport default InvoiceSellerDetail\n\n```"
}
] |
code_seller-financial-commission_1772c733
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/graphql/types/global.graphql from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ninput SellerInvoiceParams {\n sellerName: String!\n pagination: Pagination\n dates: Dates!\n}\n\ninput Pagination {\n page: Int\n pageSize: Int\n}\n\ninput Dates {\n startDate: String\n endDate: String\n}\n\ntype ListInvoices {\n data: [InvoiceList]\n pagination: PaginationInvoice\n}\n\ntype InvoiceList {\n id: String\n status: String\n invoiceCreatedDate: String\n totalizers: Totalizers\n}\n\ntype Totalizers {\n subTotal: Float\n fee: Float\n total: Float\n}\n\ntype PaginationInvoice {\n total: Int\n page: Int\n pageSize: Int\n}\n\nscalar JSONData\n\ntype Invoice {\n status: String\n invoiceCreatedDate: String\n seller: SellerInvoiceData\n orders: [Order]\n totalizers: Totalizers\n comment: String\n jsonData: JSONData\n}\n\ntype SellerInvoiceData {\n id: String\n name: String\n contact: SellerContact\n}\n\ntype SellerContact {\n phone: String\n email: String\n}\n\ntype Order {\n orderId: String\n sellerOrderId: String\n totalComission: Float\n totalOrderValue: Float\n totalOrderRate: Float\n}\n\ninput SearchOrdersParams {\n dateStart: String!\n dateEnd: String!\n sellerName: String!\n page: Int!\n perpage: Int!\n status: String\n}\n\ntype SearchOrdersResponse {\n data: [OrderSearch]\n paging: PagingOrders\n}\n\ntype OrderSearch {\n orderId: String\n sellerOrderId: String\n marketplaceOrderId: String\n totalComission: Float\n totalOrderValue: Float\n status: String\n statusDescription: String\n creationDate: String\n rate: [ItemsRateOrdersSearch]\n}\n\ntype ItemsRateOrdersSearch {\n itemId: String\n nameItem: String\n rate: RateOrders\n}\n\ntype RateOrders {\n productCommissionPercentage: Float\n freightCommissionPercentage: Float\n}\n\ntype PagingOrders {\n total: Int\n pages: Int\n currentPage: Int\n perPage: Int\n}\n\ninput InvoiceDataInput {\n id: String\n name: String\n email: String\n startDate: String\n endDate: String\n}\n\ninput EmailDataInput {\n email: String\n jsonData: String\n}\n\n```"
}
] |
code_seller-financial-commission_0fc61f8e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/node/clients/index.ts from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { ClientsConfig, IOClients, LRUCache } from '@vtex/api'\n\nimport MarketplaceAppClient from './marketplace'\nimport AffiliatesClient from './affiliates'\n\nexport class Clients extends IOClients {\n public get marketplace() {\n return this.getOrSet('marketplace', MarketplaceAppClient)\n }\n\n public get affiliate() {\n return this.getOrSet('affiliate', AffiliatesClient)\n }\n\n /* public marketplaceV2(marketplaceURL: string, context: IOContext): any {\n return new MarketplaceFinancialCommission(marketplaceURL, context)\n } */\n}\n\nconst TIMEOUT_MS = 60000\nconst memoryCache = new LRUCache<string, any>({ max: 5000 })\n\nmetrics.trackCache('seller-financial-commission', memoryCache)\n\nconst clients: ClientsConfig<Clients> = {\n implementation: Clients,\n options: {\n default: {\n retries: 2,\n timeout: TIMEOUT_MS,\n memoryCache,\n },\n },\n}\n\nexport default clients\n\n```"
}
] |
code_seller-financial-commission_1a125c37
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/node/typings/custom.d.ts from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport type Maybe<T> = T | void\n\nexport interface InvoiceFilterParams {\n sellerInvoiceParams: {\n pagination: {\n page: number\n pageSize: number\n } | null\n dates: {\n startDate: string\n endDate: string\n }\n }\n}\n\nexport interface InvoiceData {\n id: string\n name: string\n email: string\n startDate: string\n endDate: string\n}\n\nexport interface FlatFilters {\n page?: number\n pageSize?: number\n startDate: string\n endDate: string\n}\n\nexport interface OrderFilterParams {\n searchOrdersParams: {\n dateStart: string\n dateEnd: string\n sellerName: string\n page: number\n perpage: number\n status?: string\n }\n}\n\nexport interface EmailData {\n email: string\n jsonData: string\n}\n\n```"
}
] |
code_seller-financial-commission_7ce7389c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/node/typings/global.d.ts from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { ServiceContext } from '@vtex/api'\nimport type { Clients } from '../clients'\n\ndeclare global {\n type Context = ServiceContext<Clients>\n}\n\nexport {}\n\n```"
}
] |
code_seller-financial-commission_83cc85e3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/node/utils/toQueryString.ts from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport function toQueryString(params: Record<string, any>) {\n return Object.keys(params)\n .map(\n (key) => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`\n )\n .join('&')\n}\n\n```"
}
] |
code_seller-financial-commission_ee6a6e87
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/node/resolvers/getInvoice.ts from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface GetInvoiceInput {\n id: string\n}\n\nexport const getInvoice = async (\n _: unknown,\n params: GetInvoiceInput,\n ctx: Context\n) => {\n const {\n vtex: { account: sellerAccount, workspace },\n clients: { marketplace, affiliate },\n } = ctx\n\n const { id } = params\n\n const marketplaceAccount = await affiliate.getMarketplaceName()\n\n const marketplaceReference = {\n account: marketplaceAccount,\n workspace,\n }\n\n const invoice = await marketplace.getInvoice(\n sellerAccount,\n id,\n marketplaceReference\n )\n\n return invoice\n}\n\n```"
}
] |
code_seller-financial-commission_7d00b31b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/node/resolvers/sellerInvoices.ts from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { InvoiceFilterParams } from '../typings/custom'\n\nexport const sellerInvoices = async (\n _: unknown,\n params: InvoiceFilterParams,\n ctx: Context\n) => {\n const {\n vtex: { account: sellerAccount, workspace },\n clients: { marketplace, affiliate },\n } = ctx\n\n const marketplaceAccount = await affiliate.getMarketplaceName()\n\n const marketplaceReference = {\n account: marketplaceAccount,\n workspace,\n }\n\n const filter = {\n ...params.sellerInvoiceParams.dates,\n ...params.sellerInvoiceParams.pagination,\n }\n\n const invoices = await marketplace.invoicesBySeller(\n sellerAccount,\n marketplaceReference,\n filter\n )\n\n return invoices\n}\n\n```"
}
] |
code_seller-financial-commission_8c887a69
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/node/resolvers/createInvoice.ts from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { InvoiceData } from '../typings/custom'\n\ninterface CreateInvoiceInput {\n invoiceData: InvoiceData\n}\n\nexport const createInvoice = async (\n _: any,\n params: CreateInvoiceInput,\n ctx: Context\n) => {\n const {\n vtex: { account: sellerAccount, workspace },\n clients: { marketplace, affiliate },\n } = ctx\n\n const marketplaceAccount = await affiliate.getMarketplaceName()\n\n const marketplaceReference = {\n account: marketplaceAccount,\n workspace,\n }\n\n const response = await marketplace.createInvoice(\n sellerAccount,\n marketplaceReference,\n params.invoiceData\n )\n\n return response\n}\n\n```"
}
] |
code_seller-financial-commission_97278626
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/node/resolvers/sendEmail.ts from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { EmailData } from '../typings/custom'\n\ninterface SendEmailInput {\n emailData: EmailData\n}\n\nexport const sendEmail = async (\n _: unknown,\n params: SendEmailInput,\n ctx: Context\n) => {\n const {\n vtex: { workspace },\n clients: { marketplace, affiliate },\n } = ctx\n\n const marketplaceAccount = await affiliate.getMarketplaceName()\n\n const marketplaceReference = {\n account: marketplaceAccount,\n workspace,\n }\n\n const response = await marketplace.sendEmail(marketplaceReference, {\n email: params.emailData.email,\n jsonData: JSON.parse(params.emailData.jsonData),\n })\n\n return response\n}\n\n```"
}
] |
code_seller-financial-commission_91216ce6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/node/resolvers/index.ts from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { getInvoice } from './getInvoice'\nimport { getTemplate } from './getTemplate'\nimport { sendEmail } from './sendEmail'\nimport { createInvoice } from './createInvoice'\nimport { sellerInvoices } from './sellerInvoices'\nimport { sellerOrders } from './sellerOrders'\n\nexport const queries = {\n sellerInvoices,\n getInvoice,\n sellerOrders,\n getTemplate,\n}\n\nexport const mutations = {\n createInvoice,\n sendEmail,\n}\n\n```"
}
] |
code_seller-financial-commission_bdb3e53a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/node/resolvers/sellerOrders.ts from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { OrderFilterParams } from '../typings/custom'\nimport { toQueryString } from '../utils/toQueryString'\n\nexport const sellerOrders = async (\n _: unknown,\n params: OrderFilterParams,\n ctx: Context\n) => {\n const {\n vtex: { workspace, account },\n clients: { marketplace, affiliate },\n } = ctx\n\n const marketplaceAccount = await affiliate.getMarketplaceName()\n\n const marketplaceReference = {\n account: marketplaceAccount,\n workspace,\n }\n\n const queryString = toQueryString({\n ...params.searchOrdersParams,\n sellerId: account,\n })\n\n const invoices = await marketplace.sellerOrders(\n marketplaceReference,\n queryString\n )\n\n return invoices\n}\n\n```"
}
] |
code_seller-financial-commission_06d82431
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/node/resolvers/getTemplate.ts from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const getTemplate = async (_: unknown, __: unknown, ctx: Context) => {\n const {\n vtex: { workspace },\n clients: { marketplace, affiliate },\n } = ctx\n\n const marketplaceAccount = await affiliate.getMarketplaceName()\n\n const marketplaceReference = {\n account: marketplaceAccount,\n workspace,\n }\n\n const template = await marketplace.getTemplate(marketplaceReference)\n\n return template.template.Templates.email.Message\n}\n\n```"
}
] |
code_seller-financial-commission_dbe32a45
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/node/clients/marketplace/index.ts from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { AuthType, InstanceOptions, IOClient, IOContext } from '@vtex/api'\n\nimport { FlatFilters, InvoiceData, EmailData } from '../../typings/custom'\n\nconst useHttps = !process.env.VTEX_IO\n\ninterface MarketplaceReference {\n account: string\n workspace: string\n}\n\n/**\n * Used to perform calls on the marketplace app installed in the marketplace account.\n */\nexport default class MarketplaceAppClient extends IOClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n const protocol = useHttps ? 'https' : 'http'\n const appName = 'marketplace-financial-commission'\n\n super(context, {\n ...options,\n authType: AuthType.bearer,\n baseURL: `${protocol}://app.io.vtex.com/vtex.${appName}/v0`,\n name: appName,\n headers: {\n ...options?.headers,\n ...(context.authToken\n ? { VtexIdclientAutCookie: context.authToken }\n : null),\n 'Content-Type': 'application/json',\n },\n })\n }\n\n public async getInvoice(\n sellerId: string,\n id: string,\n marketplaceReference: MarketplaceReference\n ) {\n return this.http.get(\n this.routes.invoiceById(sellerId, id, marketplaceReference)\n )\n }\n\n public async createInvoice(\n sellerId: string,\n marketplaceReference: MarketplaceReference,\n invoiceData: InvoiceData\n ) {\n return this.http.post(\n this.routes.newInvoice(sellerId, marketplaceReference),\n invoiceData\n )\n }\n\n public async invoicesBySeller(\n sellerId: string,\n marketplaceReference: MarketplaceReference,\n filters: FlatFilters\n ) {\n return this.http.post(\n this.routes.invoices(sellerId, marketplaceReference),\n filters\n )\n }\n\n public async sellerOrders(\n marketplaceReference: MarketplaceReference,\n queryString: string\n ) {\n return this.http.get(this.routes.orders(marketplaceReference, queryString))\n }\n\n public async getTemplate(marketplaceReference: MarketplaceReference) {\n return this.http.get(this.routes.template(marketplaceReference))\n }\n\n public async sendEmail(\n marketplaceReference: MarketplaceReference,\n emailData: EmailData\n ) {\n return this.http.post(this.routes.email(marketplaceReference), emailData)\n }\n\n private get routes() {\n const baseRoute = `_v/policy/financial-commission`\n\n return {\n invoiceById: (\n sellerId: string,\n id: string,\n { account, workspace }: MarketplaceReference\n ) => `/${account}/${workspace}/${baseRoute}/${sellerId}/invoice/${id}`,\n newInvoice: (\n sellerId: string,\n { account, workspace }: MarketplaceReference\n ) => `/${account}/${workspace}/${baseRoute}/${sellerId}/invoice`,\n invoices: (\n sellerId: string,\n { account, workspace }: MarketplaceReference\n ) => `/${account}/${workspace}/${baseRoute}/${sellerId}/invoices`,\n orders: ({ account, workspace }: MarketplaceReference, query: string) =>\n `/${account}/${workspace}/_v/policy/private/orders?${query}`,\n template: ({ account, workspace }: MarketplaceReference) =>\n `/${account}/${workspace}/${baseRoute}/template`,\n email: ({ account, workspace }: MarketplaceReference) =>\n `/${account}/${workspace}/${baseRoute}/mail`,\n }\n }\n}\n\n```"
}
] |
code_seller-financial-commission_2b9f553f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/node/clients/affiliates/index.ts from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext, IOResponse } from '@vtex/api'\nimport { JanusClient } from '@vtex/api'\n\nexport interface Affiliate {\n name: string\n id: string\n followUpEmail: string\n salesChannel: string\n searchURIEndpoint: string\n useSellerPaymentMethod: boolean\n searchURIEndpointVersion: string\n searchURIEndpointAvailableVersions: string[]\n}\n\nexport default class AffiliatesClient extends JanusClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(context, {\n ...options,\n headers: {\n ...options?.headers,\n VtexIdclientAutCookie:\n context.adminUserAuthToken ?? context.authToken ?? '',\n 'x-vtex-user-agent': context.userAgent,\n },\n })\n }\n\n public async getMarketplaceName(): Promise<string> {\n // https://developers.vtex.com/vtex-rest-api/reference/affiliations\n const url = `/api/fulfillment/pvt/affiliates`\n\n const apiResponse = (await this.http.getRaw(url)) as IOResponse<Affiliate[]>\n\n const fulfillmentURL = apiResponse.data[0].searchURIEndpoint.split('/')\n const marketplaceAccountName = fulfillmentURL[fulfillmentURL.length - 2]\n\n return marketplaceAccountName\n }\n}\n\n```"
}
] |
code_seller-financial-commission_6ff6a697
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/react/typings/gql.d.ts from the seller-financial-commission 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_seller-financial-commission_2a6bf2ca
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/react/typings/css.d.ts from the seller-financial-commission 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_seller-financial-commission_4c1c4da6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/react/utils/config.ts from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const config = {\n getUrl: (path?: string) => `https://${window.location.host}/${path ?? ''}`,\n}\n\n```"
}
] |
code_seller-financial-commission_1547eef0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/react/graphql/sellerInvoices.gql from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery SELLER_INVOICES($sellerInvoiceParams: SellerInvoiceParams) {\n invoicesBySeller: sellerInvoices(sellerInvoiceParams: $sellerInvoiceParams) {\n data {\n id\n status\n invoiceCreatedDate\n totalizers {\n subTotal\n fee\n total\n }\n }\n pagination {\n total\n page\n pageSize\n }\n }\n}\n\n```"
}
] |
code_seller-financial-commission_896aca2e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/react/graphql/getInvoice.gql from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GET_INVOICE($id: String!) {\n getInvoice(id: $id) {\n status\n invoiceCreatedDate\n seller {\n id\n name\n contact {\n phone\n email\n }\n }\n orders {\n orderId\n sellerOrderId\n totalComission\n totalOrderValue\n totalOrderRate\n }\n totalizers {\n subTotal\n fee\n total\n }\n comment\n jsonData\n }\n}\n\n```"
}
] |
code_seller-financial-commission_0b93c4aa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/react/graphql/sendEmail.gql from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation SEND_EMAIL($emailData: EmailDataInput!) {\n sendEmail(emailData: $emailData)\n}\n\n```"
}
] |
code_seller-financial-commission_f58e01a2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/react/graphql/getTemplate.gql from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GET_TEMPLATE($variables: String) {\n getTemplate\n}\n\n```"
}
] |
code_seller-financial-commission_b2c724a3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/react/graphql/sellerOrders.gql from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery SELLER_ORDERS($searchOrdersParams: SearchOrdersParams) {\n orders: sellerOrders(searchOrdersParams: $searchOrdersParams) {\n data {\n orderId\n sellerOrderId\n marketplaceOrderId\n totalComission\n totalOrderValue\n status\n statusDescription\n creationDate\n rate {\n itemId\n nameItem\n rate {\n productCommissionPercentage\n freightCommissionPercentage\n }\n }\n }\n paging {\n total\n pages\n currentPage\n perPage\n }\n }\n}\n\n```"
}
] |
code_seller-financial-commission_52aef28d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-financial-commission/react/graphql/createInvoice.gql from the seller-financial-commission VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation CREATE_INVOICE($invoiceData: InvoiceDataInput!) {\n createInvoice(invoiceData: $invoiceData)\n}\n\n```"
}
] |
code_seller-selector_4b5b037f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/messages/de.json from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/seller-list.pending\": \"Postleitzahl zur Berechnung eingeben\",\n \"store/seller-list.shipping-label\": \"Versand berechnen\",\n \"store/seller-link.linkText\": \"{sellerQuantity, plural, one {1 weiterer Verkäufer} other {# weitere Verkäufer}} anzeigen\",\n \"store/seller-list.shipping-estimate\": \"{name} {price} {estimate}\",\n \"admin/editor.seller-selector.title\": \"Verkäuferauswahl\",\n \"admin/editor.seller-selector.head-cell\": \"Kopfzelle\",\n \"admin/editor.seller-selector.head-cell-text\": \"Kopfzeilentext\",\n \"admin/editor.seller-selector.limitShippingInformation-title\": \"Wie viele Versandkosten sollen angezeigt werden?\",\n \"admin/editor.seller-selector.limitShippingInformation-description\": \"Legen Sie fest, wie viele Versandkosten angezeigt werden sollen. Diese Konfiguration wird auf alle Verkäufer dieser Seite angewendet\",\n \"admin/editor.seller-selector.add-to-cart\": \"Zum Einkaufswagen hinzufügen\",\n \"admin/editor.seller-selector.oneClickBuy-title\": \"Weiterleitung zur Kasse\",\n \"admin/editor.seller-link.title\": \"Verkäufer-Link\",\n \"admin/editor.seller-link.textLinkTitle\": \"Link-Text\",\n \"admin/editor.seller-link.textLinkDescription\": \"Verfügbare Werte für Interpolation: '{sellerQuantity}'\"\n}\n\n```"
}
] |
code_seller-selector_11a4b66c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/messages/pl.json from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/seller-list.pending\": \"Wpisz kod pocztowy, aby obliczyć\",\n \"store/seller-list.shipping-label\": \"Oblicz wysyłkę\",\n \"store/seller-link.linkText\": \"Wyświetl {sellerQuantity, plural, one {1 sprzedawcę więcej} few {# sprzedawców więcej} many {# sprzedawców więcej} other {# sprzedawcy więcej}}\",\n \"store/seller-list.shipping-estimate\": \"{name} {price} {estimate}\",\n \"admin/editor.seller-selector.title\": \"Wybór sprzedawcy\",\n \"admin/editor.seller-selector.head-cell\": \"Komórka nagłówka\",\n \"admin/editor.seller-selector.head-cell-text\": \"Tekst komórki nagłówka\",\n \"admin/editor.seller-selector.limitShippingInformation-title\": \"Ile ofert wysyłki ma zostać wyświetlonych?\",\n \"admin/editor.seller-selector.limitShippingInformation-description\": \"Skonfiguruj liczbę wyświetlonych ofert wysyłki; ta konfiguracja zostanie zastosowana do wszystkich sprzedawców na tej stronie\",\n \"admin/editor.seller-selector.add-to-cart\": \"Dodaj do koszyka\",\n \"admin/editor.seller-selector.oneClickBuy-title\": \"Przekieruj do kasy\",\n \"admin/editor.seller-link.title\": \"Łącze sprzedawcy\",\n \"admin/editor.seller-link.textLinkTitle\": \"Tekst łącza\",\n \"admin/editor.seller-link.textLinkDescription\": \"Wartości dostępne do interpolacji: „{sellerQuantity}”\"\n}\n```"
}
] |
code_seller-selector_4b302d13
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/messages/pt.json from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/seller-list.pending\": \"Digite o CEP para calcular\",\n \"store/seller-list.shipping-label\": \"Calcular o frete\",\n \"store/seller-link.linkText\": \"Verificar {sellerQuantity, plural, one {uma outra loja} other {# outras lojas}}\",\n \"store/seller-list.shipping-estimate\": \"{name} {price} {estimate}\",\n \"admin/editor.seller-selector.title\": \"Seletor de vendedor\",\n \"admin/editor.seller-selector.head-cell\": \"Cabeçalho\",\n \"admin/editor.seller-selector.head-cell-text\": \"Texto do cabeçalho\",\n \"admin/editor.seller-selector.limitShippingInformation-title\": \"Quantas cotações de frete devem aparecer?\",\n \"admin/editor.seller-selector.limitShippingInformation-description\": \"Configure quantas informações de frete devem ser exibidas na tela simultaneamente, esta configuração será aplicada a todos os vendedores nessa pagina\",\n \"admin/editor.seller-selector.add-to-cart\": \"Adicionar Ao Carrinho\",\n \"admin/editor.seller-selector.oneClickBuy-title\": \"Redirect to checkout\",\n \"admin/editor.seller-link.title\": \"Link de vendedor\",\n \"admin/editor.seller-link.textLinkTitle\": \"Texto do link\",\n \"admin/editor.seller-link.textLinkDescription\": \"Valores disponíveis para interpolação: '{sellerQuantity}'\"\n}\n\n```"
}
] |
code_seller-selector_39cae694
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/messages/ar-SA.json from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/seller-list.pending\": \"اكتب الرمز البريدي لاحتساب\",\n \"store/seller-list.shipping-label\": \"حساب الشحن\",\n \"store/seller-link.linkText\": \"View {sellerQuantity, plural, one {بائع إضافي} other {# باعة إضافيين}}\",\n \"store/seller-list.shipping-estimate\": \"{name} {price} {estimate}\",\n \"admin/editor.seller-selector.title\": \"محدد البائع\",\n \"admin/editor.seller-selector.head-cell\": \"خانة الترويسة\",\n \"admin/editor.seller-selector.head-cell-text\": \"نص الخلية للترويسة\",\n \"admin/editor.seller-selector.limitShippingInformation-title\": \"كم عدد عروض الشحن التي ينبغي عرضها؟\",\n \"admin/editor.seller-selector.limitShippingInformation-description\": \"إعداد عدد عروض الشحن التي يجب عرضها، سيتم تطبيق هذا الإعداد على جميع البائعين في هذه الصفحة\",\n \"admin/editor.seller-selector.add-to-cart\": \"أضف لعربة التسوق\",\n \"admin/editor.seller-selector.oneClickBuy-title\": \"إعادة التوجيه إلى الدفع\",\n \"admin/editor.seller-link.title\": \"رابط البائع\",\n \"admin/editor.seller-link.textLinkTitle\": \"نص الرابط\",\n \"admin/editor.seller-link.textLinkDescription\": \"القيم المتاحة للاستقطاب: '{sellerQuantity}'\"\n}\n\n```"
}
] |
code_seller-selector_4d2cc8a0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/messages/en.json from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/seller-list.pending\": \"Type postal code to calculate\",\n \"store/seller-list.shipping-label\": \"Calculate shipping\",\n \"store/seller-link.linkText\": \"View {sellerQuantity, plural, one {1 more seller} other {# more sellers}}\",\n \"store/seller-list.shipping-estimate\": \"{name} {price} {estimate}\",\n \"admin/editor.seller-selector.title\": \"Seller Selector\",\n \"admin/editor.seller-selector.head-cell\": \"Header Cell\",\n \"admin/editor.seller-selector.head-cell-text\": \"Header Cell Text\",\n \"admin/editor.seller-selector.limitShippingInformation-title\": \"How many shipping quotes should be displayed?\",\n \"admin/editor.seller-selector.limitShippingInformation-description\": \"Configure how many shipping quotes should be displayed, this configuration will be applied to all sellers in this page\",\n \"admin/editor.seller-selector.add-to-cart\": \"Add To Cart\",\n \"admin/editor.seller-selector.oneClickBuy-title\": \"Redirect to checkout\",\n \"admin/editor.seller-link.title\": \"Seller Link\",\n \"admin/editor.seller-link.textLinkTitle\": \"Link text\",\n \"admin/editor.seller-link.textLinkDescription\": \"Values available for interpolation: '{sellerQuantity}'\"\n}\n\n```"
}
] |
code_seller-selector_da11be73
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/messages/context.json from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/seller-list.pending\": \"Type postal code to calculate\",\n \"store/seller-list.shipping-label\": \"Calculate shipping\",\n \"store/seller-link.linkText\": \"View {sellerQuantity, plural, one {1 more seller} other {# more sellers}}\",\n \"store/seller-list.shipping-estimate\": \"{name} {price} {estimate}\",\n \"admin/editor.seller-selector.title\": \"Seller Selector\",\n \"admin/editor.seller-selector.head-cell\": \"Header Cell\",\n \"admin/editor.seller-selector.head-cell-text\": \"Header Cell Text\",\n \"admin/editor.seller-selector.limitShippingInformation-title\": \"How many shipping quotes should be displayed?\",\n \"admin/editor.seller-selector.limitShippingInformation-description\": \"Configure how many shipping quotes should be displayed, this configuration will be applied to all sellers in this page\",\n \"admin/editor.seller-selector.add-to-cart\": \"Add To Cart\",\n \"admin/editor.seller-selector.oneClickBuy-title\": \"Redirect to checkout\",\n \"admin/editor.seller-link.title\": \"Seller Link\",\n \"admin/editor.seller-link.textLinkTitle\": \"Link text\",\n \"admin/editor.seller-link.textLinkDescription\": \"Values available for interpolation: '{sellerQuantity}'\"\n}\n\n```"
}
] |
code_seller-selector_a37fc740
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/messages/es.json from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/seller-list.pending\": \"Escriba el código postal para calcular\",\n \"store/seller-list.shipping-label\": \"Calcular el flete\",\n \"store/seller-link.linkText\": \"Verifique {sellerQuantity, plural, one {otro vendedor} other {# otros vendedores}}\",\n \"store/seller-list.shipping-estimate\": \"{name} {price} {estimate}\",\n \"admin/editor.seller-selector.title\": \"Selector de vendedor\",\n \"admin/editor.seller-selector.head-cell\": \"Celda de encabezado\",\n \"admin/editor.seller-selector.head-cell-text\": \"Texto de celda de encabezado\",\n \"admin/editor.seller-selector.limitShippingInformation-title\": \"¿Cuántas cotizaciones de envío se deben mostrar?\",\n \"admin/editor.seller-selector.limitShippingInformation-description\": \"Configure cuántas cotizaciones de envío deben mostrarse, esta configuración se aplicará a todos los vendedores en esta página\",\n \"admin/editor.seller-selector.add-to-cart\": \"Añadir al carrito\",\n \"admin/editor.seller-selector.oneClickBuy-title\": \"Redireccionar a pagar\",\n \"admin/editor.seller-link.title\": \"Enlace del vendedor\",\n \"admin/editor.seller-link.textLinkTitle\": \"Texto del enlace\",\n \"admin/editor.seller-link.textLinkDescription\": \"Valores disponibles para interpolación: '{sellerQuantity}'\"\n}\n\n```"
}
] |
code_seller-selector_52b8dafa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/docs/README.md from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# Seller Selector\n\nSeller Selector displays the number of [**sellers**](https://help.vtex.com/tutorial/what-is-a-seller--5FkLvhZ3Few4CWWIuYOK2w) your marketplace has for each product. It enables users to compare prices from each seller and add the desired product to their cart.\n\n\n\n## Configuration\n\n1. Install the Seller Selector app to your store with the following command:\n```sh\nvtex install vtex.seller-selector@0.x\n```\n\n2. Add the Seller Selector app to your theme's dependencies in the `manifest.json` as shown below:\n\n```json\n\"dependencies\": {\n \"vtex.seller-selector\": \"0.x\"\n}\n```\n\n3. Add the `link-seller` block, exported by the `vtex.seller-selector` app, inside your product page (`store.product` template). When rendered, the block will create a link to the Seller Selector main page. For example:\n\n```diff\n \"flex-layout.col#right-col\": {\n \"props\": {\n \"preventVerticalStretch\": true,\n \"rowGap\": 0\n },\n \"children\": [\n \"product-name\",\n+ \"link-seller\"\n \"product-price#product-details\",\n \"product-separator\",\n \"flex-layout.row#buy-button\",\n \"availability-subscriber\",\n \"shipping-simulator\",\n \"share#default\"\n ]\n },\n```\n\nBy declaring the `link-seller` block, a page containing all available sellers will be displayed automatically. However, you can configure the Seller Selector page layout, using props for each one of the blocks used to build it behind the scenes. \n\n\n### Advanced Configuration\nBehind the scenes, the Seller Selector page uses the following default implementation:\n\n```json\n{\n \"store.sellers\": {\n \"blocks\": [\n \"seller-table\"\n ]\n },\n \"seller-table\": {\n \"children\": [\n \"vtex.store-components:product-name\",\n \"seller-simulate-shipping\",\n \"seller-head\",\n \"seller-body\"\n ]\n },\n \"seller-head\": {\n \"children\": [\n \"seller-head-cell#Seller\",\n \"seller-head-cell#Price\",\n \"seller-head-cell#Shipping\",\n \"seller-head-cell#PriceWithShipping\",\n \"seller-head-cell#BuyButton\"\n ]\n },\n \"seller-head-cell#Seller\": {\n \"props\": {\n \"title\": \"Seller\"\n }\n },\n \"seller-head-cell#Price\": {\n \"props\": {\n \"title\": \"Price\"\n }\n },\n \"seller-head-cell#Shipping\": {\n \"props\": {\n \"title\": \"Shipping\"\n }\n },\n \"seller-head-cell#PriceWithShipping\": {\n \"props\": {\n \"title\": \"Price With Shipping\"\n }\n },\n \"seller-head-cell#BuyButton\": {\n \"props\": {\n \"title\": \"Add To Cart\"\n }\n },\n \"seller-body\": {\n \"children\": [\n \"seller-row\"\n ]\n },\n \"seller-row\": {\n \"children\": [\n \"seller-name\",\n \"seller-price\",\n \"seller-shipping\",\n \"seller-price-with-shipping\",\n \"seller-add-to-cart\"\n ]\n },\n \"seller-add-to-cart\":{\n \"blocks\":[\n \"add-to-cart-button\"\n ]\n }\n}\n```\n\n\n\n| Block name | Description |\n| -------- | ------------------------ |\n| `seller-table` | Layout block that provides a table to build the Seller Selector page with other blocks. It is possible to build the page using three main blocks: `seller-simulate-shipping`, `seller-head` and `seller-body` (declared as children of `seller-head`). \n| `seller-simulate-shipping` | Builds a form so users can add a postal code and then simulate the shipping costs to the desired address. |\n| `seller-head` | Builds a header to be used on the Seller Selector table. You can pass to it the `seller-head-cell` block as children. |\n| `seller-head-cell` | Defines a title for each column in the table header. |\n| `seller-body` | Defines the page main content. It is responsible for displaying all sellers' data in the table body.|\n| `seller-row` | Used inside the Seller Selector table to separate seller's data into columns. You can use the blocks listed below (`seller-name`, `seller-price`, `seller-shipping`, `seller-price-with-shipping`, `seller-add-to-cart`) as `seller-row`'s children in order to provide all needed seller's data. |\n| `seller-name` | Displays the seller name. |\n| `seller-price` | Displays the seller price for a given product. |\n| `seller-shipping` | Displays shipping cost considering the sellers' data. |\n| `seller-price-with-shipping` | Displays the purchase final cost (shipping cost + product price). |\n| `seller-add-to-cart` | Displays a Buy button that adds a given seller's product to the shopping cart. It is possible to use two different blocks inside of it `buy-button` or `add-to-cart-button` |\n|`buy-button` | Default buy button, will be used if nothing is provided in the blocks section of `seller-add-to-cart`|\n|`add-to-cart-button` | Buy button to use with Minicart.V2 and GoCommerce Stores |\n\n#### `link-seller` props\n\n| Prop name | Type | Description | Default value |\n| ---------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |\n| `message` | `string` | Text displayed on link counter | `store/seller-link.linkText`|\n\n| Message variables | Type | Description | Example |\n| --- | --- | --- | --- |\n| `sellerQuantity` | `number` | Number of sellers sell this product | <code>View {**sellerQuantity**, plural, one {1 more seller} other {# more sellers}}</code> |\n\nThis block uses the [ICU Message Format](https://format-message.github.io/icu-message-format-for-translators/), making it possible to fully edit the text message and variables displayed on block.\n\n#### `seller-table` props\n\n| Prop name | Type | Description | Default value |\n| ---------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |\n| `limitShownShippingInformation` | `number` | Max number of shipping options to be displayed. | `3` |\n\n\n#### `seller-add-to-cart` props\n\n| Prop name | Type | Description | Default value |\n| ---------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |\n| `isOneClickBuy` | `boolean` | Defines if users will keep navigating in the same page once the Buy button was clicked on (`true`) or if they will be redirected (`false`) | `false` |\n\n\n\n#### `seller-head-cell` props\n\n| Prop name | Type | Description | Default value |\n| ---------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |\n| `title` | `string` | Text displayed on the table header for each column. | `undefined`| \n\n\n\n## Modus operandi\nThe Seller Selector app fetch seller's data automatically from the [admin's Catalog ](https://help.vtex.com/tutorial/configuring-the-seller--tutorials_392). \nBehind the scenes, the blocks exported from the app use the product context in which they are inserted to identify the seller's data in the SKU registry. \nBased on this, they are able to display seller data without having to declare each desired seller in your theme.\n\n\n\n## Customization\n\nIn order to apply CSS customizations in this and other blocks, follow the instructions given in the recipe on [Using CSS Handles for store customization](https://vtex.io/docs/recipes/style/using-css-handles-for-store-customization).\n\n| CSS Handles |\n| ------------------------------- |\n| `linkSellerContainer` |\n| `linkSeller` |\n| `linkSellerText` |\n| `linkSellerNumber` |\n| `sellerMasterContainer` |\n| `sellerBuyContainer` |\n| `sellerList` |\n| `sellerBodyCell` |\n| `sellerHead` |\n| `sellerHeadCell` |\n| `sellerHeadText` |\n| `sellerName` |\n| `sellerPrice` |\n| `sellerPriceShipping` |\n| `sellerPriceShippingText` |\n| `sellerRow` |\n| `sellerShipping` |\n| `sellerShippingText` |\n| `sellerRow` |\n| `simulateShipping` |\n| `simulateShippingSearch` |\n| `simulateShippingSpinner` |\n\n```"
}
] |
code_seller-selector_22bfcfbc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/SimulateShipping.tsx from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useState } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { useLazyQuery } from 'react-apollo'\nimport { useRuntime } from 'vtex.render-runtime'\nimport {\n AddressRules,\n AddressContainer,\n PostalCodeGetter,\n} from 'vtex.address-form'\nimport { StyleguideInput } from 'vtex.address-form/inputs'\nimport { Button, Spinner } from 'vtex.styleguide'\nimport { useProduct } from 'vtex.product-context'\nimport { addValidation } from 'vtex.address-form/helpers'\nimport { FormattedMessage } from 'react-intl'\nimport './global.css'\n\nimport SimulateShippingQuery from './queries/SimulateShipping.gql'\nimport { useSellerContext } from './SellerContext'\nimport { getNewAddress } from './utils'\n\nconst SIMULATE_SHIPPING_CSS_HANDLES = [\n 'simulateShipping',\n 'simulateShippingSearch',\n 'simulateShippingSpinner',\n] as const\n\nfunction SimulateShipping() {\n const handles = useCssHandles(SIMULATE_SHIPPING_CSS_HANDLES)\n const { selectedItem, selectedQuantity } = useProduct() ?? {}\n const { setShippingQuotes } = useSellerContext()\n const [updateShippingQuotes, { loading, data }] = useLazyQuery(\n SimulateShippingQuery\n )\n\n let shippingItems = null\n\n const runtime = useRuntime()\n const {\n culture: { country },\n } = runtime\n\n if (selectedItem) {\n shippingItems = selectedItem.sellers.map((current) => ({\n id: selectedItem.itemId,\n quantity: selectedQuantity?.toString() ?? '1',\n seller: current.sellerId,\n }))\n }\n\n const variables = {\n shippingItems,\n country,\n postalCode: '',\n }\n\n const [address, setAddress] = useState(() =>\n addValidation(getNewAddress(country))\n )\n\n if (data) {\n setShippingQuotes(data.shipping)\n }\n\n function handleAddressChange(newAddress: any) {\n const updatedAddress = {\n ...address,\n ...newAddress,\n }\n\n setAddress(updatedAddress)\n if (updatedAddress.postalCode.valid) {\n const postalCode = updatedAddress.postalCode.value\n\n updateShippingQuotes({ variables: { ...variables, postalCode } })\n }\n }\n\n const showSpinner = () => {\n if (loading) {\n return (\n <div className={`${handles.simulateShippingSpinner} ml4 mt6`}>\n <Spinner />\n </div>\n )\n }\n\n return null\n }\n\n return (\n <div\n className={`${handles.simulateShipping} mt7 flex mr-auto ml-auto mw6 ba-s b--muted-3 pl4 pv5 pb5 mb3 br2`}\n >\n <AddressRules country={country} shouldUseIOFetching>\n <AddressContainer\n Input={StyleguideInput}\n address={address}\n onChangeAddress={handleAddressChange}\n >\n <PostalCodeGetter />\n </AddressContainer>\n </AddressRules>\n <Button\n className={`${handles.simulateShippingSearch} ba-s b--muted-3 br3-s bg-action-primary red`}\n size=\"small\"\n type=\"submit\"\n block\n >\n <FormattedMessage id=\"store/seller-list.shipping-label\" />\n </Button>\n {showSpinner()}\n </div>\n )\n}\n\nexport default SimulateShipping\n\n```"
}
] |
code_seller-selector_ed6b0f2e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/CurrentSellerContext.tsx from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { createContext, useContext, FC } from 'react'\n\nimport { Seller, LogisticsInfo } from './SellerContext'\n\nconst CurrentSellerContext = createContext<CurrentSellerContextValue>({\n currentSeller: null,\n shipping: null,\n})\n\ninterface CurrentSellerContextValue {\n currentSeller: Seller | null\n shipping: LogisticsInfo | null\n}\n\nexport const useCurrentSeller = () => {\n return useContext(CurrentSellerContext)\n}\n\ninterface ProviderProps {\n value: CurrentSellerContextValue\n}\n\nexport const CurrentSellerProvider: FC<ProviderProps> = ({\n value,\n children,\n}) => {\n return (\n <CurrentSellerContext.Provider value={value}>\n {children}\n </CurrentSellerContext.Provider>\n )\n}\n\nexport default {\n CurrentSellerProvider,\n useCurrentSeller,\n}\n\n```"
}
] |
code_seller-selector_9f5d0129
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/SellerName.tsx from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport { useCurrentSeller } from './CurrentSellerContext'\n\nconst SELLERS_CSS_HANDLES = ['sellerName'] as const\n\nfunction SellerName() {\n const { currentSeller } = useCurrentSeller()\n const handles = useCssHandles(SELLERS_CSS_HANDLES)\n\n return (\n <p\n className={`${handles.sellerName} items-center tc w-100-s w-20-m br2 ph6 pv4 ma0 b`}\n >\n {currentSeller?.sellerName}\n </p>\n )\n}\n\nexport default SellerName\n\n```"
}
] |
code_seller-selector_ba92bf5c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/global.css from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n.vtex-store-components-3-x-simulateShipping .vtex-input {\n height: 100%;\n}\n\n.vtex-store-components-3-x-simulateShipping .vtex-input input {\n padding: 10px 5px;\n color: #4f4f4f;\n border: 1px solid #e3e4e6;\n border-radius: 2px;\n height: 100%;\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n\n.vtex-seller-selector-0-x-simulateShipping .vtex-button {\n border-radius: 2px;\n width: auto;\n height: 3.8rem;\n margin-left: 0.875rem;\n margin-top: 0.875rem;\n}\n\n.spinnerContainer{ \n margin-left: 0.875rem;\n margin-top: 1.5rem;\n}\n\n.vtex-seller-selector-0-x-sellerMasterContainer h1{\n font-weight: 700;\n text-align: center;\n margin-top: 30px;\n}\n\n.vtex-seller-selector-0-x-sellerShippingText , .vtex-seller-selector-0-x-sellerPriceShippingText{\n padding: 5px;;\n min-height: 50px;\n}\n\n.vtex-seller-selector-0-x-sellerShippingText:nth-child(even) , .vtex-seller-selector-0-x-sellerPriceShippingText:nth-child(even){\n background-color: #b0b0b085;\n}\n\n@media only screen and (max-width: 540px) {\n .vtex-seller-selector-0-x-simulateShipping{\n flex-direction: column;\n padding: 10px;\n margin: 35px;\n }\n .vtex-seller-selector-0-x-sellerName{\n background: #cacbcc;\n border-radius: 0px;\n }\n}\n```"
}
] |
code_seller-selector_d2cf612a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/SellerHead.tsx from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport type { ReactNode } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\n\nconst SELLERS_CSS_HANDLES = ['sellerHead'] as const\n\ninterface Props {\n children: ReactNode\n}\n\nfunction SellerHead({ children }: Props) {\n const handles = useCssHandles(SELLERS_CSS_HANDLES)\n\n return (\n <div\n className={`${handles.sellerHead} mh7 mt1 justify-between-s dn-s flex-m items-center-s br2 bg-muted-3 hover-bg-muted-3 active-bg-muted-3 c-on-muted-3 hover-c-on-muted-3 active-c-on-muted-3 dib`}\n >\n {children}\n </div>\n )\n}\n\nexport default SellerHead\n\n```"
}
] |
code_seller-selector_29329a5b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/SellerAddToCart.tsx from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { defineMessages } from 'react-intl'\nimport { ExtensionPoint, useChildBlock } from 'vtex.render-runtime'\n\nimport { useCurrentSeller } from './CurrentSellerContext'\n\nconst SELLERS_CSS_HANDLES = ['sellerBuyContainer'] as const\n\ninterface Props {\n isOneClickBuy?: boolean\n}\n\nfunction SellerAddToCart({ isOneClickBuy }: Props) {\n const { currentSeller } = useCurrentSeller()\n const handles = useCssHandles(SELLERS_CSS_HANDLES)\n\n const useAddToCart = !!useChildBlock({ id: 'add-to-cart-button' })\n\n return (\n <div\n className={`${handles.sellerBuyContainer} items-center tc br2 ph6 pv4 ma0 w-100-s w-20-m`}\n >\n <ExtensionPoint\n id={useAddToCart ? 'add-to-cart-button' : 'buy-button'}\n {...{ isOneClickBuy, selectedSeller: currentSeller }}\n />\n </div>\n )\n}\n\nconst messages = defineMessages({\n title: {\n defaultMessage: '',\n id: 'admin/editor.seller-selector.add-to-cart',\n },\n isOneClickBuy: {\n defaultMessage: '',\n id: 'admin/editor.seller-selector.oneClickBuy-title',\n },\n})\n\nSellerAddToCart.schema = {\n title: messages.title.id,\n type: 'object',\n properties: {\n isOneClickBuy: {\n title: messages.isOneClickBuy.id,\n type: 'boolean',\n default: false,\n },\n },\n}\n\nexport default SellerAddToCart\n\n```"
}
] |
code_seller-selector_e4147e77
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/SellerPriceWithShipping.tsx from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { FormattedCurrency } from 'vtex.format-currency'\nimport { FormattedMessage } from 'react-intl'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport { useCurrentSeller } from './CurrentSellerContext'\nimport { useSellerContext } from './SellerContext'\n\nconst SELLERS_CSS_HANDLES = [\n 'sellerPriceShipping',\n 'sellerPriceShippingText',\n] as const\n\nfunction SellerPriceWithShipping() {\n const { currentSeller, shipping } = useCurrentSeller()\n const { limitShownShippingInformation } = useSellerContext()\n const handles = useCssHandles(SELLERS_CSS_HANDLES)\n\n return (\n <div\n className={`${handles.sellerPriceShipping} ma0 items-center tc br2 ph6 pv4 ma0 w-100-s w-20-m`}\n >\n {shipping ? (\n shipping.slas\n .slice(0, limitShownShippingInformation)\n .map((sla, index: number) => (\n <p key={index} className={`${handles.sellerPriceShippingText} ma0`}>\n <FormattedCurrency\n value={\n sla.price / 100.0 +\n (currentSeller ? currentSeller.commertialOffer.Price : 0)\n }\n />\n </p>\n ))\n ) : (\n <FormattedMessage id=\"store/seller-list.pending\" />\n )}\n </div>\n )\n}\n\nexport default SellerPriceWithShipping\n\n```"
}
] |
code_seller-selector_ba8cae36
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/SellerHeadCell.tsx from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport type { PropsWithChildren } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { defineMessages } from 'react-intl'\n\nconst SELLERS_CSS_HANDLES = ['sellerHeadCell', 'sellerHeadText'] as const\n\ninterface Props {\n title: string\n}\n\nfunction SellerHeadCell({ title, children }: PropsWithChildren<Props>) {\n const handles = useCssHandles(SELLERS_CSS_HANDLES)\n\n return (\n <div className={`${handles.sellerHeadCell} w-20`}>\n {title ? (\n <h5\n className={`${handles.sellerHeadText} items-center tc ph6 pv4 ma0 t-heading-6`}\n >\n {title}\n </h5>\n ) : null}\n {children}\n </div>\n )\n}\n\nconst messages = defineMessages({\n title: {\n defaultMessage: '',\n id: 'admin/editor.seller-selector.head-cell',\n },\n text: {\n defaultMessage: '',\n id: 'admin/editor.seller-selector.head-cell-text',\n },\n})\n\nSellerHeadCell.schema = {\n title: messages.title.id,\n type: 'object',\n properties: {\n title: {\n title: messages.text.id,\n type: 'string',\n default: '',\n },\n },\n}\n\nexport default SellerHeadCell\n\n```"
}
] |
code_seller-selector_a803fc79
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/SellerTable.tsx from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useMemo, useState } from 'react'\nimport type { PropsWithChildren } from 'react'\nimport { useProduct } from 'vtex.product-context'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { defineMessages } from 'react-intl'\n\nimport { SellerProvider } from './SellerContext'\nimport type { ShippingQuote } from './SellerContext'\n\nconst SELLERS_CSS_HANDLES = ['sellerMasterContainer'] as const\n\ninterface Props {\n limitShownShippingInformation: number\n}\n\nfunction SellerTable({\n limitShownShippingInformation,\n children,\n}: PropsWithChildren<Props>) {\n const handles = useCssHandles(SELLERS_CSS_HANDLES)\n const { selectedItem } = useProduct() ?? {}\n const [shippingQuotes, setShippingQuotes] = useState<ShippingQuote | null>(\n null\n )\n\n const sellerContext = useMemo(\n () => ({\n sellerList: selectedItem\n ? selectedItem.sellers.filter(\n (seller) => seller.commertialOffer.AvailableQuantity > 0\n )\n : null,\n shippingQuotes,\n setShippingQuotes,\n limitShownShippingInformation: limitShownShippingInformation || 3,\n }),\n [limitShownShippingInformation, selectedItem, shippingQuotes]\n )\n\n return (\n <div className={`${handles.sellerMasterContainer}`}>\n <SellerProvider value={sellerContext}>{children}</SellerProvider>\n </div>\n )\n}\n\nconst messages = defineMessages({\n title: {\n defaultMessage: '',\n id: 'admin/editor.seller-selector.title',\n },\n shippingInformationTitle: {\n defaultMessage: '',\n id: 'admin/editor.seller-selector.limitShippingInformation-title',\n },\n shippingInformationDescription: {\n defaultMessage: '',\n id: 'admin/editor.seller-selector.limitShippingInformation-description',\n },\n})\n\nSellerTable.schema = {\n title: messages.title.id,\n type: 'object',\n properties: {\n limitShownShippingInformation: {\n title: messages.shippingInformationTitle.id,\n description: messages.shippingInformationDescription.id,\n type: 'number',\n default: 3,\n },\n },\n}\n\nexport default SellerTable\n\n```"
}
] |
code_seller-selector_0754eb17
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/SellerBodyCell.tsx from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport type { ReactNode } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\n\nconst SELLERS_CSS_HANDLES = ['sellerBodyCell'] as const\n\ninterface Props {\n children: ReactNode\n}\n\nfunction SellerBodyCell({ children }: Props) {\n const handles = useCssHandles(SELLERS_CSS_HANDLES)\n\n return (\n <div\n className={`${handles.sellerBodyCell} items-center tc w-100-s w-20-m br2 ph6 pv4 ma0 w-100-s w-20-m`}\n >\n {children}\n </div>\n )\n}\n\nexport default SellerBodyCell\n\n```"
}
] |
code_seller-selector_13fd1df4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/package.json from the seller-selector 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 \"apollo-client\": \"^2.6.8\",\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 \"@types/jest\": \"^25.1.4\",\n \"@types/node\": \"^13.9.8\",\n \"@types/react\": \"^16.9.31\",\n \"@vtex/test-tools\": \"^0.3.2\",\n \"@vtex/tsconfig\": \"^0.2.0\",\n \"graphql\": \"^14.6.0\",\n \"typescript\": \"3.9.7\",\n \"vtex.native-types\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.native-types@0.7.5/public/@types/vtex.native-types\",\n \"vtex.add-to-cart-button\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.add-to-cart-button@0.21.1/public/@types/vtex.add-to-cart-button\",\n \"vtex.address-form\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.address-form@4.6.3/public/_types/react\",\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.flex-layout\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.flex-layout@0.15.2/public/@types/vtex.flex-layout\",\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.product-context\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.product-context@0.9.7/public/@types/vtex.product-context\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.126.5/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.store\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store@2.110.0/public/@types/vtex.store\",\n \"vtex.store-components\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-components@3.138.2/public/@types/vtex.store-components\",\n \"vtex.store-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-graphql@2.136.9/public/@types/vtex.store-graphql\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.134.1/public/@types/vtex.styleguide\"\n },\n \"version\": \"0.6.0\"\n}\n\n```"
}
] |
code_seller-selector_d4371137
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/SellerBody.tsx from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useCallback } from 'react'\nimport type { ReactNode } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport { useSellerContext } from './SellerContext'\nimport type { Seller } from './SellerContext'\nimport { CurrentSellerProvider } from './CurrentSellerContext'\n\nconst SELLERS_CSS_HANDLES = ['sellerList']\n\ninterface Props {\n children: ReactNode\n}\n\nfunction SellerBody({ children }: Props) {\n const { sellerList, shippingQuotes } = useSellerContext()\n const handles = useCssHandles(SELLERS_CSS_HANDLES)\n\n const currentSellerCreate = useCallback(\n (current: Seller, index: number) => {\n const currentContext = {\n currentSeller: current,\n shipping: shippingQuotes?.logisticsInfo\n ? shippingQuotes.logisticsInfo[index]\n : null,\n }\n\n return currentContext\n },\n [shippingQuotes]\n )\n\n return (\n <div className={`${handles.sellerList} mh7 mb7`}>\n {sellerList\n ? sellerList.map((current, index: number) => (\n <CurrentSellerProvider\n value={currentSellerCreate(current, index)}\n key={index}\n >\n {children}\n </CurrentSellerProvider>\n ))\n : null}\n </div>\n )\n}\n\nexport default SellerBody\n\n```"
}
] |
code_seller-selector_d7d3d575
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/SellerContext.tsx from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { createContext, useContext } from 'react'\nimport type { PropsWithChildren } from 'react'\n\nexport interface Seller {\n sellerId: string\n sellerName: string\n sellerDefault: boolean\n commertialOffer: Offer\n}\n\ninterface Offer {\n Price: number\n AvailableQuantity: number\n}\n\nexport interface ShippingQuote {\n logisticsInfo: LogisticsInfo[]\n}\n\nexport interface LogisticsInfo {\n itemIndex: number\n slas: SLA[]\n}\n\ninterface SLA {\n id: string\n name: string\n price: number\n shippingEstimate: string\n shippingEstimateDate: string\n}\n\ninterface SellerContextValue {\n sellerList: Seller[] | null\n shippingQuotes: ShippingQuote | null\n setShippingQuotes: (quote: ShippingQuote) => void\n limitShownShippingInformation: number\n}\n\nconst SellerContext = createContext<SellerContextValue>({\n sellerList: null,\n shippingQuotes: null,\n setShippingQuotes: () => {},\n limitShownShippingInformation: 3,\n})\n\nexport const useSellerContext = (): SellerContextValue => {\n return useContext(SellerContext)\n}\n\ninterface ProviderProps {\n value: SellerContextValue\n}\n\nexport function SellerProvider({\n value,\n children,\n}: PropsWithChildren<ProviderProps>) {\n return (\n <SellerContext.Provider value={value}>{children}</SellerContext.Provider>\n )\n}\n\nexport default {\n SellerProvider,\n useSellerContext,\n}\n\n```"
}
] |
code_seller-selector_a0cf22f0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/SellerRow.tsx from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport type { ReactNode } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\n\nconst SELLERS_CSS_HANDLES = ['sellerRow'] as const\n\ninterface Props {\n children: ReactNode\n}\n\nfunction SellerRow({ children }: Props) {\n const handles = useCssHandles(SELLERS_CSS_HANDLES)\n\n return (\n <div\n className={`${handles.sellerRow} justify-between-s bt-0-m b--solid-s bw1 b--muted-3 flex br--bottom items-center-s flex-column-s flex-row-m`}\n >\n {children}\n </div>\n )\n}\n\nexport default SellerRow\n\n```"
}
] |
code_seller-selector_f9041679
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/LinkSeller.tsx from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { Link } from 'vtex.render-runtime'\nimport { useProduct } from 'vtex.product-context'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { IOMessage } from 'vtex.native-types'\nimport { defineMessages } from 'react-intl'\n\nconst LINK_SELLER_HANDLES = [\n 'linkSellerContainer',\n 'linkSeller',\n 'linkSellerText',\n 'linkSellerNumber',\n] as const\n\ninterface Props {\n message?: string\n}\n\nfunction LinkSeller({ message }: Props) {\n const { product, selectedItem } = useProduct() ?? {}\n const handles = useCssHandles(LINK_SELLER_HANDLES)\n\n const availableSellers = selectedItem?.sellers.filter(\n (seller) => seller.commertialOffer.AvailableQuantity > 0\n )\n\n if (!selectedItem || !availableSellers || availableSellers.length <= 1) {\n return null\n }\n\n return (\n <div\n className={`${handles.linkSellerContainer} flex flex-row-reverse relative`}\n >\n <Link\n className={`${handles.linkSeller}`}\n page=\"store.sellers\"\n params={{ slug: product?.linkText }}\n query={selectedItem ? `skuId=${selectedItem.itemId}` : ''}\n >\n <p className={`${handles.linkSellerText} pr6`}>\n <IOMessage\n id={message}\n values={{\n sellerQuantity: availableSellers.length,\n }}\n />\n </p>\n </Link>\n </div>\n )\n}\n\nconst messages = defineMessages({\n title: {\n id: 'admin/editor.seller-link.title',\n },\n})\n\nLinkSeller.schema = {\n title: messages.title.id,\n}\n\nexport default LinkSeller\n\n```"
}
] |
code_seller-selector_ef49c5f2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/SellerPrice.tsx from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { FormattedCurrency } from 'vtex.format-currency'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport { useCurrentSeller } from './CurrentSellerContext'\n\nconst SELLERS_CSS_HANDLES = ['sellerPrice'] as const\n\nfunction SellerPrice() {\n const { currentSeller } = useCurrentSeller()\n\n const handles = useCssHandles(SELLERS_CSS_HANDLES)\n\n return (\n <p\n className={`${handles.sellerPrice} items-center tc w-100-s w-20-m br2 ph6 pv4 ma0`}\n >\n <FormattedCurrency\n value={currentSeller ? currentSeller.commertialOffer.Price : 0}\n />\n </p>\n )\n}\n\nexport default SellerPrice\n\n```"
}
] |
code_seller-selector_6011ae7c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/react/SellerShipping.tsx from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport { FormattedCurrency } from 'vtex.format-currency'\nimport { TranslateEstimate } from 'vtex.shipping-estimate-translator'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport { useCurrentSeller } from './CurrentSellerContext'\nimport { useSellerContext } from './SellerContext'\n\nconst SELLERS_CSS_HANDLES = ['sellerShipping', 'sellerShippingText'] as const\n\nfunction SellerShipping() {\n const { shipping } = useCurrentSeller()\n const { limitShownShippingInformation } = useSellerContext()\n const handles = useCssHandles(SELLERS_CSS_HANDLES)\n\n return (\n <div\n className={`${handles.sellerShipping} items-center tc w-100-s w-20-m br2 ph6 pv4 ma0 w-100-s w-20-m`}\n >\n {shipping ? (\n shipping.slas\n .slice(0, limitShownShippingInformation)\n .map((sla, index: number) => (\n <p key={index} className={`${handles.sellerShippingText} ma0`}>\n <FormattedMessage\n id=\"store/seller-list.shipping-estimate\"\n values={{\n name: sla.name,\n price: <FormattedCurrency value={sla.price / 100} />,\n estimate: (\n <TranslateEstimate\n shippingEstimate={sla.shippingEstimate}\n />\n ),\n }}\n />\n </p>\n ))\n ) : (\n <FormattedMessage id=\"store/seller-list.pending\" />\n )}\n </div>\n )\n}\n\nexport default SellerShipping\n\n```"
}
] |
code_seller-selector_11ad3bf3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/store/contentSchemas.json from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"definitions\": {\n \"LinkSeller\": {\n \"type\": \"object\",\n \"properties\": {\n \"message\": {\n \"title\": \"admin/editor.seller-link.textLinkTitle\",\n \"description\": \"admin/editor.seller-link.textLinkDescription\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\",\n \"default\": \"store/seller-link.linkText\"\n }\n }\n }\n }\n}\n\n```"
}
] |
code_seller-selector_e981c99f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of seller-selector/store/interfaces.json from the seller-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store.sellers\": {\n \"around\": [\"productWrapper\"],\n \"context\": \"vtex.store/ProductContext\"\n },\n \"store.product.sellertest\": {\n \"allowed\": [\"link-seller\"]\n },\n \"link-seller\": {\n \"component\": \"LinkSeller\",\n \"content\": {\n \"$ref\": \"app:vtex.seller-selector#/definitions/LinkSeller\"\n }\n },\n \"seller-table\": {\n \"component\": \"SellerTable\",\n \"composition\": \"children\"\n },\n \"seller-head\": {\n \"component\": \"SellerHead\",\n \"composition\": \"children\"\n },\n \"seller-head-cell\": {\n \"component\": \"SellerHeadCell\",\n \"composition\": \"children\"\n },\n \"seller-body\": {\n \"component\": \"SellerBody\",\n \"composition\": \"children\"\n },\n \"seller-row\": {\n \"component\": \"SellerRow\",\n \"composition\": \"children\"\n },\n \"seller-name\": {\n \"component\": \"SellerName\",\n \"composition\": \"children\"\n },\n \"seller-price\": {\n \"component\": \"SellerPrice\",\n \"composition\": \"children\"\n },\n \"seller-price-with-shipping\": {\n \"component\": \"SellerPriceWithShipping\",\n \"composition\": \"children\"\n },\n \"seller-shipping\": {\n \"component\": \"SellerShipping\"\n },\n \"seller-add-to-cart\": {\n \"component\": \"SellerAddToCart\",\n \"allowed\": [\"add-to-cart-button\", \"buy-button\"]\n },\n \"seller-simulate-shipping\": {\n \"component\": \"SimulateShipping\"\n }\n}\n\n```"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.