id
stringlengths 12
53
| messages
listlengths 3
3
|
|---|---|
code_telemarketing_17f02f77
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/messages/en.json from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/telemarketing.attendant\": \"Attendant: {attendant}\",\n \"store/telemarketing.client\": \"Client\",\n \"store/telemarketing-login.message\": \"Login as\",\n \"store/telemarketing-login.button\": \"Login\",\n \"store/telemarketing-logout.button\": \"Logout\",\n \"store/telemarketing-logout.document-label\": \"Document\",\n \"store/telemarketing-logout.phone-label\": \"Phone\",\n \"store/telemarketing-logout.button-orders\": \"Orders\"\n}\n\n```"
}
] |
code_telemarketing_428d01f0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/messages/no-NO.json from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/telemarketing.attendant\": \"Deltaker: {attendant}\",\n \"store/telemarketing.client\": \"Klient\",\n \"store/telemarketing-login.message\": \"Logg inn som\",\n \"store/telemarketing-login.button\": \"Logg inn\",\n \"store/telemarketing-logout.button\": \"Logg ut\",\n \"store/telemarketing-logout.document-label\": \"Dokument\",\n \"store/telemarketing-logout.phone-label\": \"Telefon\",\n \"store/telemarketing-logout.button-orders\": \"Bestillinger\"\n}\n\n```"
}
] |
code_telemarketing_5ca76795
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/messages/context.json from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/telemarketing.attendant\": \"store/telemarketing.attendant\",\n \"store/telemarketing.client\": \"store/telemarketing.client\",\n \"store/telemarketing-login.message\": \"store/telemarketing-login.message\",\n \"store/telemarketing-login.button\": \"store/telemarketing-login.button\",\n \"store/telemarketing-logout.button\": \"store/telemarketing-logout.button\",\n \"store/telemarketing-logout.document-label\": \"store/telemarketing-logout.document-label\",\n \"store/telemarketing-logout.phone-label\": \"store/telemarketing-logout.phone-label\",\n \"store/telemarketing-logout.button-orders\": \"store/telemarketing-logout.button-orders\"\n}\n```"
}
] |
code_telemarketing_5e96b72b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/messages/es.json from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/telemarketing.attendant\": \"Asistente: {attendant}\",\n \"store/telemarketing.client\": \"Cliente\",\n \"store/telemarketing-login.message\": \"Ingresá como cliente\",\n \"store/telemarketing-login.button\": \"Ingresá\",\n \"store/telemarketing-logout.button\": \"Salir\",\n \"store/telemarketing-logout.document-label\": \"Documento\",\n \"store/telemarketing-logout.phone-label\": \"Teléphono\",\n \"store/telemarketing-logout.button-orders\": \"Pedidos\"\n}\n\n```"
}
] |
code_telemarketing_22726279
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/docs/README.md from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# VTEX Telemarketing\n\n## Description\n\nThe VTEX Telemarketing app is a store component that enables a call center operator impersonate a costumer in the store, and this app is used by store theme.\n\n:loudspeaker: **Disclaimer:** Don't fork this project, use, contribute, or open issue with your feature request.\n\n## Release schedule\n\n| Release | Status | Initial Release | Maintenance LTS Start | End-of-life | Store Compatibility |\n| :-----: | :-----------------: | :-------------: | :-------------------: | :---------: | :-----------------: |\n| [2.x] | **Current Release** | 2018-11-08 | | | 2.x |\n| [1.x] | **Maintenance LTS** | 2018-08-15 | 2018-11-08 | March 2019 | 1.x |\n\nSee our [LTS policy](https://github.com/vtex-apps/awesome-io#lts-policy) for more information.\n\n## Table of Contents\n\n- [Usage](#usage)\n - [Blocks API](#blocks-api)\n - [Configuration](#configuration)\n - [Styles API](#styles-api)\n - [CSS namespaces](#css-namespaces)\n- [Troubleshooting](#troubleshooting)\n- [Contributing](#contributing)\n- [Tests](#tests)\n\n## Usage\n\nThis app uses our store builder with the blocks architecture. To know more about the Store Builder [click here](https://help.vtex.com/en/tutorial/understanding-storebuilder-and-stylesbuilder#structuring-and-configuring-our-store-with-object-object).\n\nWe add the telemarketing as a block in our [Store Header](https://github.com/vtex-apps/store-header/blob/master/store/interfaces.json).\n\nTo configure or customize this app, you need to import it in your dependencies in `manifest.json`.\n\n```json\n dependencies: {\n \"vtex.telemarketing\": \"2.x\"\n }\n```\n\nThen, add `telemarketing` block into your app theme as we do in our [Store theme app](https://github.com/vtex-apps/store-theme/blob/master/store/blocks.json).\n\n:loudspeaker: **Disclaimer:** This component will only be displayed for the users that have the role of `2 - Televendas (Call center operator)` in their access profile.\n\nTo give an user the permission of call center operator you need to follow these steps on VTEX admin management page:\n\n- Access the page: Account Management -> Access Profiles -> Click in New Profile -> Select `2 - Televendas (Call center operator)`\n- Add the email of the users that are responsable for impersonating customers(call center operators).\n\n### Blocks API\n\nWhen implementing this app as a block, various inner blocks may be available. The following interface lists the available blocks within telemarketing and describes if they are required or optional.\n\n```json\n{\n \"telemarketing\": {\n \"component\": \"index\"\n }\n}\n```\n\nAs you can see, this app has no required or optional block.\n\n#### Configuration\n\nThis app has no configuration yet.\n\n### Styles API\n\nThis app provides some CSS classes as an API for style customization.\n\nTo use this CSS API, you must add the `styles` builder and create an app styling CSS file.\n\n1. Add the `styles` builder to your `manifest.json`:\n\n```json\n \"builders\": {\n \"styles\": \"1.x\"\n }\n```\n\n2. Create a file called `vtex.telemarketing.css` inside the `styles/css` folder. Add your custom styles:\n\n```css\n.container {\n margin-top: 10px;\n}\n```\n\n#### Customization\n\n| CSS Handles |\n| ------------------------- |\n| `container` |\n| `popoverArrowUp` |\n| `popoverBox` |\n| `popoverContentContainer` |\n| `popoverContainer` |\n| `login` |\n| `loginForm` |\n| `loginFormMessage` |\n| `emailInput` |\n| `clientName` |\n| `clientNameBar` |\n| `logout` |\n| `logoutForm` |\n| `popoverHeaderIcon` |\n| `popoverHeaderEmail` |\n| `loginButton` |\n| `loginAsText` |\n| `popoverHeader` | \n| `loginFormContainer` | \n| `logoutInfoContainer` |\n| `emailContainer` |\n| `emailField` |\n| `emailValue` |\n| `documentContainer` |\n| `documentField` |\n| `documentValue` |\n| `phoneContainer` |\n| `phoneField` |\n| `phoneValue` |\n| `logoutButtonsContainer` |\n| `wrapper` |\n| `telemarketingBar` |\n| `attendantContainer` |\n| `attendantEmail` |\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## Troubleshooting\n\nYou can check if others are passing through similar issues [here](https://github.com/vtex-apps/telemarketing/issues). Also feel free to [open issues](https://github.com/vtex-apps/telemarketing/issues/new) or contribute with pull requests.\n\n## Contributing\n\nCheck it out [how to contribute](https://github.com/vtex-apps/awesome-io#contributing) with this project. \n\n## Tests\n\nTo execute our tests go to `react/` folder and run `yarn test`\n\n### Travis CI\n\n[](https://travis-ci.org/vtex-apps/telemarketing)\n[](https://coveralls.io/github/vtex-apps/telemarketing?branch=master)\n\n```"
}
] |
code_telemarketing_e3dac907
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/index.tsx from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC, Suspense } from 'react'\nimport { NoSSR } from 'vtex.render-runtime'\nimport isMyVtex from './utils/isMyVtex'\n\nconst TelemarketingContainer = React.lazy(() => import('./components/TelemarketingContainer'))\n\nconst Telemarketing: FC = (props) => {\n if (!isMyVtex()) {\n return null\n }\n\n return (\n <NoSSR>\n <Suspense fallback={<React.Fragment />}>\n <TelemarketingContainer {...props} />\n </Suspense>\n </NoSSR>\n )\n}\n\nexport default Telemarketing\n\n```"
}
] |
code_telemarketing_25f40c94
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/package.json from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.impersonate-customer\",\n \"scripts\": {\n \"pretest\": \"yarn\",\n \"test\": \"vtex-test-tools test\",\n \"test:coverage\": \"vtex-test-tools test --collectCoverage\",\n \"gen:coveralls\": \"yarn test:coverage && cat ./coverage/lcov.info | coveralls\",\n \"lint\": \"tsc --noEmit --pretty && tslint -c tslint.json './**/*.ts'\"\n },\n \"dependencies\": {\n \"apollo-client\": \"^2.4.7\",\n \"classnames\": \"^2.2.6\",\n \"debounce\": \"^1.2.0\",\n \"graphql\": \"^14.0.2\",\n \"graphql-tag\": \"^2.10.1\",\n \"ramda\": \"^0.24.1\",\n \"react\": \"^16.3.2\",\n \"react-apollo\": \"~2.1.3\",\n \"react-dom\": \"^16.8.3\",\n \"react-intl\": \"^2.4.0\"\n },\n \"devDependencies\": {\n \"@types/classnames\": \"^2.2.7\",\n \"@types/debounce\": \"^1.2.0\",\n \"@types/graphql\": \"^14.2.0\",\n \"@types/jest\": \"^24.0.9\",\n \"@types/node\": \"^12.0.2\",\n \"@types/ramda\": \"^0.26.8\",\n \"@types/react\": \"^16.4.14\",\n \"@types/react-helmet\": \"^5.0.7\",\n \"@types/react-intl\": \"^2.3.11\",\n \"@vtex/test-tools\": \"^1.1.0\",\n \"coveralls\": \"^3.0.3\",\n \"prettier\": \"^1.17.1\",\n \"tslint\": \"^5.11.0\",\n \"tslint-config-vtex\": \"^2.0.0\",\n \"tslint-eslint-rules\": \"^5.4.0\"\n },\n \"version\": \"2.12.1\"\n}\n\n```"
}
] |
code_telemarketing_2cd2cf63
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/telemarketing.css from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n.wrapper {}\n\n.container .popoverArrowUp {\n right: 20px;\n}\n\n.container .popoverBox {\n min-width: 320px;\n}\n\n/* Popover css */\n\n.popoverArrowUp {\n width: 25px;\n height: 25px;\n left: 86%;\n}\n\n.popoverBox {\n visibility: visible;\n min-width: 310px;\n}\n\n.popoverContentContainer {\n min-width: 100%;\n}\n\n.clientName {\n word-break: break-word;\n}\n\n.clientNameBar {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 90%;\n text-align: left;\n}\n\n@media screen and (aspect-ratio: 40/71) {\n .popoverBox {\n right: -2.4vw;\n width: 100vw;\n top: 4.1vh !important;\n }\n}\n\n.login {\n}\n\n.popoverHeaderIcon {\n}\n\n.popoverHeaderEmail {\n}\n\n.loginForm {\n}\n\n.loginFormMessage {\n}\n\n.emailInput {\n}\n\n.logout {\n}\n\n.logoutForm {\n}\n\n.popoverContainer {\n}\n\n```"
}
] |
code_telemarketing_7ad97db8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/store/interfaces.json from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"telemarketing\": {\n \"component\": \"index\",\n \"render\": \"lazy\"\n }\n}\n```"
}
] |
code_telemarketing_d6098771
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/mutations/impersonate.gql from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation impersonate($email: String!) {\n impersonate(email: $email) {\n id\n adminUserId\n impersonable\n adminUserEmail\n impersonate {\n profile {\n phone\n email\n lastName\n document\n firstName\n }\n }\n }\n}\n\n```"
}
] |
code_telemarketing_b81d6489
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/typings/vtex.react-portal.d.ts from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.react-portal' {\n export const Overlay\n}\n```"
}
] |
code_telemarketing_11dbe7fe
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/typings/vtex.css-handles.d.ts from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.css-handles' {\n export const useCssHandles\n}\n```"
}
] |
code_telemarketing_86bb6a91
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/typings/render.d.ts from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* Typings for `render-runtime` */\ndeclare module 'vtex.render-runtime' {\n import { Component, ReactElement } from 'react'\n \n export const useRuntime: any\n\n export interface NavigationOptions {\n page: string\n params?: any\n } \n export interface RenderContextProps {\n runtime: {\n navigate: (options: NavigationOptions) => void\n }\n }\n\n export const ExtensionPoint: ReactElement\n export const Helmet: ReactElement\n export const Link: ComponentType<any>\n export const NoSSR: ComponentType<any>\n export const RenderContextConsumer: ReactElement\n export const canUseDOM: boolean\n export const withRuntimeContext: <TOriginalProps extends {}>(\n Component: ComponentType<TOriginalProps & RenderContextProps>\n ) => ComponentType<TOriginalProps>\n \n export const withSession: <TOriginalProps extends {}>(\n Component: ComponentType<TOriginalProps & RenderContextProps>\n ) => ComponentType<TOriginalProps>\n \n export const buildCacheLocator = (app: string, type: string, cacheId: string) => string\n\n interface RenderComponent<P = {}, S = {}> extends Component<P, S> {\n getCustomMessages?: (locale: string) => any\n schema: ComponentSchema\n getSchema?: (a: any, b: any?) => ComponentSchema\n uiSchema: UISchema\n }\n\n export interface ComponentsRegistry {\n [component: string]: RenderComponent<any, any>\n }\n\n export interface Window extends Window {\n __RENDER_7_COMPONENTS__: ComponentsRegistry\n }\n\n let global: Window\n}\n```"
}
] |
code_telemarketing_05818685
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/typings/telemarketing.d.ts from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const css: any\n export default css\n}\n\n```"
}
] |
code_telemarketing_46cee01f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/typings/vtex.store-components.d.ts from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.store-components' {\n export const Container\n}\n\n```"
}
] |
code_telemarketing_9251d97b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/typings/vtex.device-detector.d.ts from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.device-detector/useDevice' {\n interface Device {\n device: 'phone' | 'tablet' | 'desktop'\n isMobile: boolean\n }\n\n export default function useDevice(): Device\n}\n```"
}
] |
code_telemarketing_ff3fbadc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/typings/vtex.store-icons.d.ts from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.store-icons' {\n export const IconAssistantSales: ComponentType<any>\n export const IconProfile: ComponentType<any>\n}\n\n```"
}
] |
code_telemarketing_f0ac3802
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/typings/global.d.ts from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface Session {\n loading: boolean\n refetch: () => void\n getSession: {\n adminUserEmail: string\n adminUserId: string\n impersonable: boolean\n profile: Profile\n impersonate: {\n storeUserId: string\n storeUserEmail: string\n profile: Profile\n }\n }\n}\n\ninterface ProcessedSession {\n attendantEmail: string\n canImpersonate: boolean\n client?: Client\n}\n\ninterface Profile {\n document: string\n phone: string\n firstName: string\n lastName: string\n email: string\n}\n\ninterface Client {\n document: string\n phone: string\n name: string\n email: string\n}\n\n```"
}
] |
code_telemarketing_e759318d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/typings/node.d.ts from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.gql' {\n import { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\n```"
}
] |
code_telemarketing_652a8586
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/typings/vtex.store-resources.d.ts from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.store-resources/QuerySession' {\n const Session: any\n export default Session\n}\n\n```"
}
] |
code_telemarketing_2258c60d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/typings/vtex.styleguide.d.ts from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide' {\n export const Button\n export const Input\n}\n\n```"
}
] |
code_telemarketing_3df13efe
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/utils/processSession.ts from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport default (session?: Session): ProcessedSession | null => {\n try {\n if (session && session.getSession && !session.loading) {\n const {\n impersonable,\n adminUserEmail,\n impersonate: { profile },\n } = session.getSession\n\n if (profile) {\n const { document, firstName, lastName, phone, email } = profile\n\n return {\n attendantEmail: adminUserEmail,\n canImpersonate: impersonable,\n client: {\n document,\n email,\n name: `${firstName} ${lastName}`,\n phone,\n },\n }\n } else {\n return {\n attendantEmail: adminUserEmail,\n canImpersonate: impersonable,\n }\n }\n }\n } catch (error) {\n console.error(error)\n }\n\n return null\n}\n\n```"
}
] |
code_telemarketing_6d1a19fb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/utils/isMyVtex.ts from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { compose, includes, pathOr } from 'ramda'\n\nexport default function isMyVtex() {\n return compose(\n includes('myvtex.com'),\n pathOr('', ['location', 'hostname'])\n )(window)\n}\n\n```"
}
] |
code_telemarketing_9e536728
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/utils/format-string.ts from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const truncateString = (str: string, size: number): string => {\n const MAX_LENGTH = 12\n\n size = size || MAX_LENGTH\n\n return str.length <= size ? str : str.substring(0, size - 3).concat('...')\n}\n\n```"
}
] |
code_telemarketing_c759a9e9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/components/Popover.tsx from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { ReactNode, useRef, useState, useCallback } from 'react'\nimport classnames from 'classnames'\nimport useOutsideClick from '../hooks/useOutsideClick'\nimport styles from '../telemarketing.css'\nimport { Overlay } from 'vtex.react-portal'\n\ninterface Props {\n /** Function that will display the header */\n renderHeader: () => JSX.Element\n /** Aditional classes for arrows */\n arrowClasses: string\n /** If is mobile or not */\n mobile: boolean\n /** Children */\n readonly children: ReactNode\n}\n\n/** Component that shows a content when it´s header is clicked */\nconst Popover = (props: Props) => {\n const boxRef = useRef<any>(null)\n const iconRef = useRef<any>(null)\n const [isBoxOpen, setBoxOpen] = useState(false)\n const { renderHeader, children, arrowClasses, mobile } = props\n\n const handleOutsideClick = () => setBoxOpen(false)\n useOutsideClick(boxRef, handleOutsideClick, isBoxOpen)\n\n const toggleBox = useCallback(() => setBoxOpen(!isBoxOpen), [])\n\n const boxPositionStyle = mobile\n ? {}\n : {\n right: iconRef.current && iconRef.current.offsetWidth - 43,\n }\n\n const boxClasses = classnames(\n styles.popoverBox,\n 'absolute-ns top-2 z-max bb b--muted-3 fixed-s',\n isBoxOpen ? 'flex' : 'dn',\n {\n 'left-0 right-0': mobile,\n }\n )\n\n return (\n <div\n className={`${\n styles.popoverContainer\n } relative flex h-100 items-center pr4`}\n >\n <div\n className=\"pointer w-100\"\n onClick={toggleBox}\n ref={e => {\n iconRef.current = e\n }}\n >\n {renderHeader()}\n </div>\n <Overlay>\n <div className={boxClasses} style={boxPositionStyle} ref={boxRef}>\n <div\n className={`${\n styles.popoverContentContainer\n } mt3-ns bg-base shadow-3-ns`}\n >\n {children}\n </div>\n <div\n className={`${\n styles.popoverArrowUp\n } absolute top-0 rotate-135 dib-ns dn-s ${arrowClasses}`}\n />\n </div>\n </Overlay> \n </div>\n )\n}\n\nexport default Popover\n\n```"
}
] |
code_telemarketing_49ceb373
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/components/LogoutCustomerSession.tsx from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport classnames from 'classnames'\nimport React, { ReactNode, useCallback, useMemo } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { Link } from 'vtex.render-runtime'\nimport { IconAssistantSales, IconProfile } from 'vtex.store-icons'\nimport { Button } from 'vtex.styleguide'\n\nimport Popover from './Popover'\n\nimport { FormattedMessage } from 'react-intl'\n\nconst CSS_HANDLES = [\n 'logoutHeader',\n 'clientNameBar',\n 'logout',\n 'popoverHeaderIcon',\n 'popoverHeaderEmail',\n 'logoutForm',\n 'clientName',\n 'popoverHeader',\n 'logoutInfoContainer',\n 'emailContainer',\n 'emailField',\n 'emailValue',\n 'documentContainer',\n 'documentField',\n 'documentValue',\n 'phoneContainer',\n 'phoneField',\n 'phoneValue',\n 'logoutButtonsContainer',\n] as const\ninterface Props {\n /** Signed in client */\n client: Client\n /** Loading Status */\n loading: boolean\n /** Calls the depersonify on the parent component */\n onDepersonify: () => any\n /** Current signedin attendant email */\n attendantEmail: string\n /** If is mobile or not */\n mobile: boolean\n /** Children */\n readonly children?: ReactNode\n}\n\n/** Component that shows the client info calls the setSession function to logout. */\nconst LogoutCustomerSession = (props: Props) => {\n const { client, loading, onDepersonify, attendantEmail, mobile } = props\n const handles = useCssHandles(CSS_HANDLES)\n\n const getClientName = (client: any) =>\n !!client\n ? client.name.includes('null')\n ? client.email.slice(0, client.email.indexOf('@'))\n : client.name\n : null\n\n const getHeader = (mobile: boolean) => {\n const headerClasses = classnames(\n handles.logoutHeader,\n 'c-on-base--inverted',\n mobile ? 'flex items-center w-100' : 'flex items-center'\n )\n return (\n <div className={headerClasses}>\n <IconProfile />\n <div className={`pa2 ${handles.clientNameBar} w-100`}>{clientName}</div>\n </div>\n )\n }\n\n const clientName = useMemo(() => getClientName(client), [client])\n const renderHeader = useCallback(() => getHeader(mobile), [mobile])\n\n return (\n <div className={`${handles.logout} ${mobile && 'w-50'}`}>\n <Popover\n arrowClasses=\"bg-emphasis\"\n renderHeader={renderHeader}\n mobile={mobile}\n >\n <div className={`${handles.popoverHeader} bg-emphasis w-100 pa7`}>\n <div className={`${handles.popoverHeaderIcon} c-on-base--inverted`}>\n <IconAssistantSales size={50} />\n </div>\n <div className={`${handles.popoverHeaderEmail} c-on-emphasis`}>\n {attendantEmail}\n </div>\n </div>\n <div className={`${handles.logoutInfoContainer} bg-base w-100 pt7 pb5 ph5`}>\n <div className={`${handles.logoutForm} c-disabled`}>\n <div className=\"w-100 bw1 bb b--muted-5 flex-wrap\">\n <div\n className={`${handles.clientName} w-100 t-heading-5 center pb5 c-on-base`}\n >\n {clientName}\n </div>\n\n <div className={`${handles.emailContainer} w-100 flex flex-wrap t-small`}>\n <div className={`${handles.emailField} tl pb5 pr2`}>Email</div>\n <div className={`${handles.emailValue} pb5 pl2 c-muted-1`}>{client.email}</div>\n </div>\n\n <div className={`${handles.documentContainer} w-100 flex flex-wrap t-small`}>\n <div className={`${handles.documentField} tl pb5 pr2`}>\n <FormattedMessage id=\"store/telemarketing-logout.document-label\" />\n </div>\n <div className={`${handles.documentValue} pb5 pl2 c-muted-1`}>{client.document}</div>\n </div>\n\n <div className={`${handles.phoneContainer} w-100 flex flex-wrap t-small`}>\n <div className={`${handles.phoneField} tl pb5 pr2`}>\n <FormattedMessage id=\"store/telemarketing-logout.phone-label\" />\n </div>\n <div className={`${handles.phoneValue} pb5 pl2 c-muted-1`}>{client.phone}</div>\n </div>\n </div>\n <div className={`${handles.logoutButtonsContainer} flex justify-around mt5`}>\n <Link page=\"store.account\">\n <Button size=\"regular\">\n <FormattedMessage id=\"store/telemarketing-logout.button-orders\" />\n </Button>\n </Link>\n <Button\n size=\"regular\"\n onClick={() => onDepersonify()}\n isLoading={loading}\n >\n <FormattedMessage id=\"store/telemarketing-logout.button\" />\n </Button>\n </div>\n </div>\n </div>\n </Popover>\n </div>\n )\n}\n\nexport default LogoutCustomerSession\n\n```"
}
] |
code_telemarketing_49d67e9f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/components/TelemarketingContainer.tsx from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { compose, path } from 'ramda'\nimport React, { FC, useState } from 'react'\nimport { graphql } from 'react-apollo'\nimport { withSession } from 'vtex.render-runtime'\nimport sessionQuery from 'vtex.store-resources/QuerySession'\n\nimport depersonifyMutation from '../mutations/depersonify.gql'\nimport impersonateMutation from '../mutations/impersonate.gql'\nimport isMyVtex from '../utils/isMyVtex'\nimport processSession from '../utils/processSession'\nimport Telemarketing from './Telemarketing'\n\ninterface Props {\n /** Query with the session */\n session?: Session\n /** Mutation to depersonify */\n depersonify: () => Promise<void>\n /** Mutation to impersonate a customer */\n impersonate: (s: {}) => Promise<void>\n}\n\nconst TelemarketingContainer: FC<Props> = ({ depersonify, impersonate, session }) => {\n const [emailInput, setEmailInput] = useState<string>('')\n const [loadingImpersonate, setloadingImpersonate] = useState<boolean>(false)\n\n const processedSession = processSession(session)\n\n if (!session || !processedSession || !processedSession.canImpersonate) {\n return null\n }\n\n const handleInputChange = (event: any) => {\n setEmailInput(event.target.value)\n }\n\n const handleDepersonify = () => {\n setloadingImpersonate(true)\n depersonify()\n .then(response => {\n const depersonifyData = path(['data', 'depersonify'], response)\n !!depersonifyData && session.refetch()\n window.location.reload()\n })\n .catch(() => setloadingImpersonate(false))\n }\n\n const handleImpersonate = (email: string) => {\n setloadingImpersonate(true)\n const variables = { email }\n impersonate({ variables })\n .then(response => {\n const profile = path(\n ['data', 'impersonate', 'impersonate', 'profile'],\n response\n )\n !!profile && session.refetch()\n window.location.reload()\n })\n .catch(() => setloadingImpersonate(false))\n }\n\n const { client, attendantEmail } = processedSession\n\n return (\n <Telemarketing\n client={client}\n loading={loadingImpersonate}\n emailInput={emailInput}\n attendantEmail={attendantEmail}\n onImpersonate={handleImpersonate}\n onDepersonify={handleDepersonify}\n onInputChange={handleInputChange}\n />\n )\n}\n\nconst options = {\n name: 'session',\n skip: () => !isMyVtex(),\n options: () => ({\n ssr: false,\n }),\n}\n\nconst EnhancedTelemarketing = withSession({ loading: React.Fragment })(\n compose(\n graphql(sessionQuery, options),\n graphql(depersonifyMutation, { name: 'depersonify' }),\n graphql(impersonateMutation, { name: 'impersonate' }),\n )(TelemarketingContainer as any)\n)\n\nexport default EnhancedTelemarketing\n\n\n```"
}
] |
code_telemarketing_f74ca372
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/components/Telemarketing.tsx from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport classnames from 'classnames'\nimport React, { ReactNode } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\nimport useDevice from 'vtex.device-detector/useDevice'\nimport { Container } from 'vtex.store-components'\nimport { IconAssistantSales } from 'vtex.store-icons'\n\nimport { FormattedMessage } from 'react-intl'\nimport styles from '../telemarketing.css'\nimport LoginAsCustomer from './LoginAsCustomer'\nimport LogoutCustomerSession from './LogoutCustomerSession'\n\nconst CSS_HANDLES = [\n 'wrapper',\n 'telemarketingBar',\n 'attendantContainer',\n 'attendantEmail',\n] as const\ninterface Props {\n /** Attendant email */\n attendantEmail: string\n /** Impersonated customer info */\n client?: Client\n /** Email input value */\n emailInput: string\n /** Loading status */\n loading: boolean\n /** Function to depersonify the impersonated customer */\n onDepersonify: () => any\n /** Function to set the emailInput value */\n onInputChange: (s: string) => void\n /** Function to impersonate */\n onImpersonate: (s: string) => void\n /** Children */\n readonly children?: ReactNode\n}\n\n/** Telemarketing render component */\nconst Telemarketing = ({\n client,\n loading,\n emailInput,\n onInputChange,\n onImpersonate,\n onDepersonify,\n attendantEmail,\n}: Props) => {\n const { isMobile } = useDevice()\n const handles = useCssHandles(CSS_HANDLES)\n\n const containerClasses = classnames(\n styles.container,\n 'flex justify-center tc h2 t-mini pa2 w-100'\n )\n\n return (\n <div\n className={classnames(\n 'w-100',\n handles.wrapper,\n !!client\n ? 'bg-emphasis c-on-emphasis'\n : 'bg-base--inverted c-on-base--inverted'\n )}\n >\n <Container className={containerClasses}>\n <div className={`${handles.telemarketingBar} flex justify-between w-100 mw9`}>\n <div className={`${handles.attendantContainer} flex pl3 w-50 items-center c-on-base--inverted`}>\n <IconAssistantSales />\n <div className={`${handles.attendantEmail} ml2`}>\n {isMobile ? (\n <span>\n {attendantEmail.slice(0, attendantEmail.indexOf('@'))}\n </span>\n ) : (\n <FormattedMessage\n id=\"store/telemarketing.attendant\"\n values={{ attendant: attendantEmail }}\n />\n )}\n </div>\n </div>\n {!!client ? (\n <LogoutCustomerSession\n client={client}\n loading={loading}\n onDepersonify={onDepersonify}\n attendantEmail={attendantEmail}\n mobile={isMobile}\n />\n ) : (\n <LoginAsCustomer\n loading={loading}\n emailInput={emailInput}\n onInputChange={onInputChange}\n onImpersonate={onImpersonate}\n attendantEmail={attendantEmail}\n mobile={isMobile}\n />\n )}\n </div>\n </Container>\n </div>\n )\n}\n\nexport default Telemarketing\n\n```"
}
] |
code_telemarketing_e31b9fa9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/components/LoginAsCustomer.tsx from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useCallback } from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { IconAssistantSales, IconProfile } from 'vtex.store-icons'\nimport { Button, Input } from 'vtex.styleguide'\nimport Popover from './Popover'\n\nconst CSS_HANDLES = [\n 'login',\n 'popoverHeaderIcon',\n 'popoverHeaderEmail',\n 'loginForm',\n 'loginFormMessage',\n 'emailInput',\n 'loginButton',\n 'loginAsText',\n 'popoverHeader',\n 'loginFormContainer',\n] as const\ninterface Props {\n /** Current signedin attendant email */\n attendantEmail: string\n /** Input value */\n emailInput: string\n /** Sets the state of the parent component with new email value */\n onInputChange: (s: string) => void\n /** Calls the impersonate on the parent component */\n onImpersonate: (s: string) => void\n /** Loading status */\n loading: boolean\n /** If is mobile or not */\n mobile: boolean\n}\n\n/** Component that shows the email input and calls the impersonate function using the Popover component. */\nconst LoginAsCustomer = ({\n attendantEmail,\n onInputChange,\n onImpersonate,\n loading,\n emailInput,\n mobile,\n}: Props) => {\n const handles = useCssHandles(CSS_HANDLES)\n const handleHeaderRendering = useCallback(\n () => (\n <div className={`${handles.loginButton} flex items-center c-on-base--inverted`}>\n <IconProfile />\n <div className={`${handles.loginAsText} ml2`}>\n <FormattedMessage id=\"store/telemarketing-login.message\" />\n </div>\n </div>\n ),\n []\n )\n\n const handleKeyPress = useCallback(\n (event: any) => {\n event.key === 'Enter' && onImpersonate(emailInput)\n },\n [emailInput]\n )\n\n return (\n <div className={`${handles.login} w-50 flex flex-row-reverse-ns flex-row-s`}>\n <Popover\n arrowClasses=\"bg-base--inverted\"\n renderHeader={handleHeaderRendering}\n mobile={mobile}\n >\n <div className={`${handles.popoverHeader} bg-base--inverted w-100 pa7 c-on-base--inverted`}>\n <div className={handles.popoverHeaderIcon}>\n <IconAssistantSales size={50} />\n </div>\n <div className={`${handles.popoverHeaderEmail} white-50 mt3`}>\n {attendantEmail}\n </div>\n </div>\n <div className={`${handles.loginFormContainer} bg-base w-100 ph5 pb5 pt7`}>\n <div className={`${handles.loginForm} c-disabled`}>\n <div className={`${handles.loginFormMessage} t-small tl mb3`}>\n <FormattedMessage id=\"store/telemarketing-login.message\" />\n </div>\n <div className={`${handles.emailInput} mb5`}>\n <Input\n value={emailInput}\n onChange={onInputChange}\n placeholder={'Ex: example@mail.com'}\n onKeyPress={handleKeyPress}\n />\n </div>\n <Button\n size=\"regular\"\n onClick={() => onImpersonate(emailInput)}\n isLoading={loading}\n >\n <FormattedMessage id=\"store/telemarketing-login.button\" />\n </Button>\n </div>\n </div>\n </Popover>\n </div>\n )\n}\n\nexport default LoginAsCustomer\n\n```"
}
] |
code_telemarketing_fd72c87e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/__tests__/Telemarketing.test.tsx from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { mergeDeepRight } from 'ramda'\nimport { render, fireEvent } from '@vtex/test-tools/react'\n\nimport Telemarketing from '../components/Telemarketing'\n\ndescribe('<Telemarketing /> component', () => {\n const renderComponent = (customProps = {}) => {\n const defaultProps = {\n attendantEmail: 'attendant@vtex.com',\n emailInput: 'email@vtex.com',\n loading: false,\n onDepersonify: () => {},\n onInputChange: () => {},\n onImpersonate: () => {},\n }\n\n return render(<Telemarketing {...defaultProps} {...customProps} />)\n }\n\n it('should match snapshot without client', () => {\n const { asFragment } = renderComponent()\n\n expect(asFragment()).toMatchSnapshot()\n })\n\n it('should match snapshot with client', () => {\n const client: Client = {\n document: 'document',\n phone: 'phone',\n name: 'name',\n email: 'client@vtex.com',\n }\n\n const { asFragment } = renderComponent({ client: client })\n\n expect(asFragment()).toMatchSnapshot()\n })\n\n it('should show attendant email', () => {\n const email = 'nice_attendant_email@vtex.com'\n const { getByText } = renderComponent({ attendantEmail: email })\n\n const attendantEmail = getByText(email)\n expect(attendantEmail).toBeTruthy()\n })\n\n it('should show login button and form', () => {\n const { getByText, getByPlaceholderText } = renderComponent()\n\n const emailPlaceholder = getByPlaceholderText('Ex: example@mail.com')\n expect(emailPlaceholder).toBeTruthy()\n\n const login = getByText('Login')\n expect(login).toBeTruthy()\n })\n\n it('should show client data', () => {\n const client: Client = {\n document: 'my client document',\n phone: '+9999999999999',\n name: 'my client name',\n email: 'client@vtex.com',\n }\n\n const { getByText, getAllByText } = renderComponent({ client: client })\n\n const document = getByText(client.document)\n expect(document).toBeTruthy()\n\n const phone = getByText(client.phone)\n expect(phone).toBeTruthy()\n\n const name = getAllByText(client.name)\n expect(name).toBeTruthy()\n\n const email = getByText(client.email)\n expect(email).toBeTruthy()\n })\n\n it('should login when clicked', () => {\n const onImpersonate = jest.fn()\n const { getByText } = renderComponent({ onImpersonate: onImpersonate })\n\n fireEvent.click(getByText('Login'))\n\n expect(onImpersonate).toBeCalledTimes(1)\n })\n\n it('should logout when clicked', () => {\n const onDepersonify = jest.fn()\n const client: Client = {\n document: 'my client document',\n phone: '+9999999999999',\n name: 'my client name',\n email: 'client@vtex.com',\n }\n\n const { getByText } = renderComponent({\n client: client,\n onDepersonify: onDepersonify,\n })\n\n fireEvent.click(getByText('Logout'))\n\n expect(onDepersonify).toBeCalledTimes(1)\n })\n})\n\n```"
}
] |
code_telemarketing_e29f99d4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of telemarketing/react/hooks/useOutsideClick.tsx from the telemarketing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { useLayoutEffect } from 'react'\n\nconst useOutsideClick = (\n ref: React.MutableRefObject<any>,\n handler: any,\n when: boolean\n) => {\n const handle = (e: any) =>\n ref && ref.current && !ref.current.contains(e.target) && handler(e)\n\n useLayoutEffect(() => {\n when && document.addEventListener('mousedown', handle)\n return () => document.removeEventListener('mousedown', handle)\n }, [when])\n}\n\nexport default useOutsideClick\n\n```"
}
] |
code_mocked-analytics_a50de95f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mocked-analytics/docs/README.md from the mocked-analytics VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# Mocked Analytics\n\nApp in VTEX IO designed to provide _mocked_ live products data.\n\n### How it works?\n\nRun `vtex link` and use the route provided to get a mocked data.\n\n```"
}
] |
code_mocked-analytics_9e5b6722
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mocked-analytics/node/service.json from the mocked-analytics VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"memory\": 128,\n \"ttl\": 10,\n \"timeout\": 2,\n \"minReplicas\": 2,\n \"maxReplicas\": 10,\n \"workers\": 4,\n \"routes\": {\n \"getLiveUsers\": {\n \"path\": \"/_v/live-products\",\n \"public\": false,\n \"access\": \"authorized\",\n \"policies\": [\n {\n \"effect\": \"allow\",\n \"actions\": [\n \"get\"\n ],\n \"principals\": [\n \"vrn:apps:*:*:*:app/vtex.backend-course@*\",\n \"vrn:apps:*:*:*:app/vtex.events-example@*\"\n ]\n }\n ]\n }\n }\n}\n\n```"
}
] |
code_mocked-analytics_3f381cd1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mocked-analytics/node/package.json from the mocked-analytics VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"co-body\": \"^6.0.0\"\n },\n \"devDependencies\": {\n \"@types/co-body\": \"^0.0.3\",\n \"@types/node\": \"12.x\",\n \"@vtex/api\": \"6.35.0\",\n \"eslint\": \"^6.3.0\",\n \"eslint-config-vtex\": \"^11.0.0\",\n \"prettier\": \"^1.18.2\",\n \"typescript\": \"3.8.3\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty && eslint -c .eslintrc.json --fix './**/*.ts'\"\n },\n \"version\": \"0.0.3\"\n}\n\n```"
}
] |
code_mocked-analytics_f245493e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mocked-analytics/node/index.ts from the mocked-analytics VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {\n Service,\n IOClients,\n ParamsContext,\n ServiceContext,\n RecorderState,\n} from '@vtex/api'\nimport { getLiveUsers } from './handlers/getLiveUsers'\n\ndeclare global {\n type Context = ServiceContext<IOClients, State>\n\n interface State extends RecorderState {\n code: number\n }\n}\n\nexport default new Service<IOClients, State, ParamsContext>({\n routes: {\n getLiveUsers,\n },\n})\n\n```"
}
] |
code_mocked-analytics_75ba46e8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mocked-analytics/node/utils/randomNumber.ts from the mocked-analytics VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport function getRandomNumber(min: number, max: number) {\n return Math.floor(Math.random() * (max - min + 1) + min)\n}\n\n```"
}
] |
code_mocked-analytics_d292797c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mocked-analytics/node/handlers/getLiveUsers.ts from the mocked-analytics VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { getRandomNumber } from '../utils/randomNumber'\n\nexport async function getLiveUsers(ctx: Context) {\n let liveUsers: LiveUsersProduct[] = []\n let productsQdt = getRandomNumber(1, 10)\n for (productsQdt; productsQdt > 0; productsQdt--) {\n liveUsers.push({\n slug: Math.floor(Math.random() * (2000 - 1000 + 1) + 1000).toString(),\n liveUsers: Math.floor(Math.random() * (5 - 1 + 1) + 1),\n })\n }\n ctx.status = 200\n ctx.body = liveUsers\n}\n\nexport interface LiveUsersProduct {\n slug: string\n liveUsers: number\n}\n\n```"
}
] |
code_b2b-checkout-settings_57bc0f30
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/messages/nl.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/b2bCheckoutSettings.navigation.title\": \"B2B kassa-instellingen\",\n \"admin/b2bCheckoutSettings.saveSettings.success\": \"Instellingen opgeslagen\",\n \"admin/b2bCheckoutSettings.saveSettings.failure\": \"Instellingen opslaan is mislukt. Zie console voor details.\",\n \"admin/b2bCheckoutSettings.settings.title\": \"B2B kassa-instellingen\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.label\": \"Toon inkooporder (PO) nummerveld\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.helpText\": \"Schakelt het IO-nummerveld in op de afrekenpagina\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.label\": \"Knop 'Maak een offerte aan' weergeven\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.helpText\": \"Schakelt de knop 'Maak een offerte aan' in de kassa in - alleen als B2B offertes (vtex.b2b-quotes) zijn geïnstalleerd!\",\n \"admin/b2bCheckoutSettings.saveSettings.buttonText\": \"Opslaan\"\n}\n\n```"
}
] |
code_b2b-checkout-settings_e8d2de15
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/messages/ja.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/b2bCheckoutSettings.navigation.title\": \"B2B チェックアウト設定\",\n \"admin/b2bCheckoutSettings.saveSettings.success\": \"設定を保存しました\",\n \"admin/b2bCheckoutSettings.saveSettings.failure\": \"設定を保存できませんでした。詳細はコンソールを確認してください。\",\n \"admin/b2bCheckoutSettings.settings.title\": \"B2B チェックアウト設定\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.label\": \"発注書 (PO) 番号フィールドを表示する\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.helpText\": \"チェックアウトページの PO 番号フィールドを有効にする\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.label\": \"「見積もり作成」ボタンを表示する\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.helpText\": \"チェックアウトの「見積もり作成」ボタンを有効にします。これは、B2B 見積もり (vtex.b2b-quotes) がインストールされている場合に限ります!\",\n \"admin/b2bCheckoutSettings.saveSettings.buttonText\": \"保存\"\n}\n\n```"
}
] |
code_b2b-checkout-settings_3a8b2a97
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/messages/pt.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/b2bCheckoutSettings.navigation.title\": \"Configurações de checkout B2B\",\n \"admin/b2bCheckoutSettings.saveSettings.success\": \"Configurações salvas\",\n \"admin/b2bCheckoutSettings.saveSettings.failure\": \"Erro ao salvar as configurações. Consulte o console para mais detalhes.\",\n \"admin/b2bCheckoutSettings.settings.title\": \"Configurações de checkout B2B\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.label\": \"Mostrar campo do número da ordem de compra (OC)\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.helpText\": \"Habilita o campo de OC na página do checkout\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.label\": \"Mostrar botão 'Criar uma cotação'\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.helpText\": \"Habilita o botão 'Criar uma cotação' no checkout — apenas se o B2B Quotes (vtex.b2b-quotes) estiver instalado!\",\n \"admin/b2bCheckoutSettings.saveSettings.buttonText\": \"Salvar\"\n}\n\n```"
}
] |
code_b2b-checkout-settings_7a2ea23e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/messages/en.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/b2bCheckoutSettings.navigation.title\": \"B2B Checkout Settings\",\n \"admin/b2bCheckoutSettings.saveSettings.success\": \"Settings saved\",\n \"admin/b2bCheckoutSettings.saveSettings.failure\": \"Failed to save settings. See console for details.\",\n \"admin/b2bCheckoutSettings.settings.title\": \"B2B Checkout Settings\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.label\": \"Show purchase order (PO) number field\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.helpText\": \"Enables the PO number field on the checkout page\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.label\": \"Show 'Create a Quote' button\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.helpText\": \"Enables the 'Create a Quote' button in Checkout — only if B2B Quotes (vtex.b2b-quotes) is installed!\",\n \"admin/b2bCheckoutSettings.saveSettings.buttonText\": \"Save\"\n}\n\n```"
}
] |
code_b2b-checkout-settings_df7dcfbc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/messages/it.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/b2bCheckoutSettings.navigation.title\": \"Impostazioni checkout B2B\",\n \"admin/b2bCheckoutSettings.saveSettings.success\": \"Impostazioni salvate\",\n \"admin/b2bCheckoutSettings.saveSettings.failure\": \"Errore durante il salvataggio delle impostazioni. Visualizza la console per ulteriori dettagli.\",\n \"admin/b2bCheckoutSettings.settings.title\": \"Impostazioni checkout B2B\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.label\": \"Mostra il campo relativo al numero dell'ordine di acquisto (PO)\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.helpText\": \"Abilita il campo relativo al numero dell'ordine di acquisto (PO) nella pagina del checkout\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.label\": \"Mostra il pulsante 'Crea preventivo'\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.helpText\": \"Abilita il pulsante 'Crea preventivo' nel checkout (solo se è stato installato B2B Quotes - vtex.b2b-quotes)\",\n \"admin/b2bCheckoutSettings.saveSettings.buttonText\": \"Salva\"\n}\n\n```"
}
] |
code_b2b-checkout-settings_c54c2377
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/messages/fr.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/b2bCheckoutSettings.navigation.title\": \"Paramètres Checkout B2B\",\n \"admin/b2bCheckoutSettings.saveSettings.success\": \"Paramètres enregistrés\",\n \"admin/b2bCheckoutSettings.saveSettings.failure\": \"Impossible d'enregistrer les paramètres. Voir la console pour plus de détails.\",\n \"admin/b2bCheckoutSettings.settings.title\": \"Paramètres Checkout B2B\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.label\": \"Afficher le champ numéro de bon de commande (PO)\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.helpText\": \"Active le champ du numéro de bon de commande sur la page de checkout\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.label\": \"Afficher le bouton « Créer un devis »\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.helpText\": \"Activer le bouton « Créer un devis » dans le checkout -- uniquement si les devis B2B (vtex.b2b-quotes) sont installés !\",\n \"admin/b2bCheckoutSettings.saveSettings.buttonText\": \"Sauvegarder\"\n}\n\n```"
}
] |
code_b2b-checkout-settings_fad9825e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/messages/bg.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/b2bCheckoutSettings.navigation.title\": \"Настройки на B2B финализирането\",\n \"admin/b2bCheckoutSettings.saveSettings.success\": \"Настройките са запазени\",\n \"admin/b2bCheckoutSettings.saveSettings.failure\": \"Неуспешно запазване на настройките. Вижте конзолата за подробности.\",\n \"admin/b2bCheckoutSettings.settings.title\": \"Настройки на B2B финализирането\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.label\": \"Показване на полето с номер на поръчката за покупка (ПП)\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.helpText\": \"Активира полето за номер на ПП в страницата за финализиране\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.label\": \"Показване на бутон „Създаване на оферта“\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.helpText\": \"Активира бутона „Създаване на оферта“ при финализирането — само ако са инсталирани B2B оферти (vtex.b2b-quotes)!\",\n \"admin/b2bCheckoutSettings.saveSettings.buttonText\": \"Запазване\"\n}\n\n```"
}
] |
code_b2b-checkout-settings_5f2ab73d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/messages/ro.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/b2bCheckoutSettings.navigation.title\": \"Setări pentru plată B2B\",\n \"admin/b2bCheckoutSettings.saveSettings.success\": \"Setări salvate\",\n \"admin/b2bCheckoutSettings.saveSettings.failure\": \"Eroare la salvarea setărilor. Consultă consola pentru detalii.\",\n \"admin/b2bCheckoutSettings.settings.title\": \"Setări pentru plată B2B\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.label\": \"Afișează câmpul număr comandă de cumpărare (PO)\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.helpText\": \"Permite câmpul număr PO pe pagina de plată\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.label\": \"Afișează butonul „Creare ofertă”\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.helpText\": \"Activează butonul „Creează o ofertă” în rubrica de Plată — numai dacă sunt instalate oferte B2B (vtex.b2b-quotes)!\",\n \"admin/b2bCheckoutSettings.saveSettings.buttonText\": \"Salvează\"\n}\n\n```"
}
] |
code_b2b-checkout-settings_faebcfdf
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/messages/context.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/b2bCheckoutSettings.navigation.title\": \"admin/b2bCheckoutSettings.navigation.title\",\n \"admin/b2bCheckoutSettings.saveSettings.success\": \"admin/b2bCheckoutSettings.saveSettings.success\",\n \"admin/b2bCheckoutSettings.saveSettings.failure\": \"admin/b2bCheckoutSettings.saveSettings.failure\",\n \"admin/b2bCheckoutSettings.settings.title\": \"admin/b2bCheckoutSettings.settings.title\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.label\": \"admin/b2bCheckoutSettings.settings.showPONumber.label\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.helpText\": \"admin/b2bCheckoutSettings.settings.showPONumber.helpText\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.label\": \"admin/b2bCheckoutSettings.settings.showQuoteButton.label\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.helpText\": \"admin/b2bCheckoutSettings.settings.showQuoteButton.helpText\",\n \"admin/b2bCheckoutSettings.saveSettings.buttonText\": \"admin/b2bCheckoutSettings.saveSettings.buttonText\"\n}\n\n```"
}
] |
code_b2b-checkout-settings_a4507828
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/messages/ko.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/b2bCheckoutSettings.navigation.title\": \"B2B 체크아웃 설정\",\n \"admin/b2bCheckoutSettings.saveSettings.success\": \"설정이 저장됨\",\n \"admin/b2bCheckoutSettings.saveSettings.failure\": \"설정을 저장하지 못했습니다. 자세한 내용은 콘솔을 참조하세요.\",\n \"admin/b2bCheckoutSettings.settings.title\": \"B2B 체크아웃 설정\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.label\": \"구매 주문 번호 필드 표시\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.helpText\": \"체크아웃 페이지에서 PO 번호 필드 활성화\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.label\": \"'견적 생성' 버튼 표시\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.helpText\": \"체크아웃에서 '견적 생성' 버튼 활성화 -- B2B 견적(vtex.b2b-quotes)이 설치된 경우에만 활성화합니다!\",\n \"admin/b2bCheckoutSettings.saveSettings.buttonText\": \"저장\"\n}\n\n```"
}
] |
code_b2b-checkout-settings_d785b2df
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/messages/th.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/b2bCheckoutSettings.navigation.title\": \"การตั้งค่า B2B Checkout\",\n \"admin/b2bCheckoutSettings.saveSettings.success\": \"บันทึกการตั้งค่าแล้ว\",\n \"admin/b2bCheckoutSettings.saveSettings.failure\": \"ไม่สามารถบันทึกการตั้งค่า โปรดดูรายละเอียดในคอนโซล\",\n \"admin/b2bCheckoutSettings.settings.title\": \"การตั้งค่า B2B Checkout\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.label\": \"แสดงฟิลด์เลขที่คำสั่งซื้อ\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.helpText\": \"เปิดใช้งานฟิลด์เลขที่คำสั่งซื้อในหน้าเช็คเอาต์\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.label\": \"แสดงปุ่ม 'สร้างการเสนอราคา'\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.helpText\": \"เปิดใช้งานปุ่ม 'สร้างการเสนอราคา' ใน Checkout เปิดใช้เมื่อติดตั้งการเสนอราคา B2B (vtex.b2b-quotes) แล้วเท่านั้น\",\n \"admin/b2bCheckoutSettings.saveSettings.buttonText\": \"บันทึก\"\n}\n\n```"
}
] |
code_b2b-checkout-settings_8036ed69
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/messages/es.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/b2bCheckoutSettings.navigation.title\": \"Configuración de checkout B2B\",\n \"admin/b2bCheckoutSettings.saveSettings.success\": \"Configuración guardada\",\n \"admin/b2bCheckoutSettings.saveSettings.failure\": \"No se pudo guardar la configuración. Consulta la consola para ver los detalles.\",\n \"admin/b2bCheckoutSettings.settings.title\": \"Configuración de checkout B2B\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.label\": \"Mostrar el campo de no. de orden de compra (PO)\",\n \"admin/b2bCheckoutSettings.settings.showPONumber.helpText\": \"Habilita el campo de no. de orden de compra en la página de checkout\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.label\": \"Mostrar el botón \\\"Crear cotización\\\"\",\n \"admin/b2bCheckoutSettings.settings.showQuoteButton.helpText\": \"Habilita el botón \\\"Crear cotización\\\" en el checkout si B2B Quotes (vtex.b2b-quotes) está instalada.\",\n \"admin/b2bCheckoutSettings.saveSettings.buttonText\": \"Guardar\"\n}\n\n```"
}
] |
code_b2b-checkout-settings_ab0c5640
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/checkout-ui-custom/checkout5-custom.css from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n/* /files/checkout5-custom.css */\n\n/* Displays the option to enter a foreign document */\n.document-box { display: block; }\n\n/* Displays the option to enter an international phone */\n.phone-box { display: block; }\n\n```"
}
] |
code_b2b-checkout-settings_fbf65099
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/checkout-ui-custom/checkout6-custom.js from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable no-undef */\n/* eslint-disable no-console */\n/* eslint-disable func-names */\n/* eslint-disable */\nconst CREDIT_CARDS = [\n 'visa',\n 'mastercard',\n 'diners',\n 'american express',\n 'hipercard',\n 'discover',\n 'aura',\n 'elo',\n 'banricompras',\n 'jcb',\n 'cabal',\n 'nativa',\n 'naranja',\n 'nevada',\n 'shopping',\n 'credz',\n]\n\nconst MAX_TIME_EXPIRATION = 1000 * 60 * 5 // 5 minutes\n\n!(function () {\n let checkVtex = null\n\n const getTranslation = function () {\n const locale = window.vtex.i18n.getLocale()\n const translation = {\n 'pt-BR': {\n cartPurchaseOrderLabel: 'Número do Pedido',\n createQuoteButtonLabel: 'Criar uma Cotação',\n messages: {\n 'b2b-access-denied': {\n title: 'Acesso',\n detail: 'Você não tem acesso ao checkout',\n },\n },\n clearCartLabel: 'Limpar carrinho',\n },\n en: {\n cartPurchaseOrderLabel: 'Reference or PO Number',\n createQuoteButtonLabel: 'Create a Quote',\n messages: {\n 'b2b-access-denied': {\n title: 'ACCESS',\n detail: \"You don't have access to the checkout\",\n },\n },\n clearCartLabel: 'Clear Cart',\n },\n es: {\n cartPurchaseOrderLabel: 'Número de referencia o número del pedido',\n createQuoteButtonLabel: 'Crear un presupuesto',\n messages: {\n 'b2b-access-denied': {\n title: 'ACCESO',\n detail: 'No tienes acceso al checkout',\n },\n },\n clearCartLabel: 'Limpiar carrito',\n },\n de: {\n cartPurchaseOrderLabel: 'Referenz- oder Bestellnummer',\n createQuoteButtonLabel: 'Angebot Anfordern',\n messages: {\n 'b2b-access-denied': {\n title: 'ZUGANG',\n detail: 'Sie haben keinen Zugriff auf den Checkout',\n },\n },\n clearCartLabel: 'Warenkorb leeren',\n },\n }\n\n // default to EN if language not supported\n return translation[locale] || translation.en\n }\n\n // Used to remove cache from requests\n const isWorkspace = function () {\n return window.__RUNTIME__.workspace !== 'master'\n }\n\n let settings\n const storedSettings = JSON.parse(\n window.sessionStorage.getItem('b2b-checkout-settings')\n )\n\n const emailRequested =\n window.vtexjs && window.vtexjs.checkout && window.vtexjs.checkout.orderForm\n ? window.vtexjs.checkout.orderForm.clientProfileData.email\n : null\n\n if (storedSettings && storedSettings.time) {\n const now = new Date().getTime()\n const sessionStorageCheckoutTime = new Date(storedSettings.time).getTime()\n\n if (\n now - sessionStorageCheckoutTime < MAX_TIME_EXPIRATION &&\n emailRequested &&\n emailRequested === storedSettings.email\n ) {\n settings = storedSettings\n }\n }\n\n window.b2bCheckoutSettings = window.b2bCheckoutSettings || settings\n\n const buildClearCartButton = function () {\n if ($('#clear-cart').length > 0) {\n return\n }\n\n const label = getTranslation().clearCartLabel\n\n const btn = $(\n `<button id='clear-cart' class='btn btn-large btn-primary btn-b2b-primary'>${label}</button>`\n )\n\n btn.click(removeCartItemsAndQuote)\n\n $('div.cart').append(btn)\n }\n\n const buildCreateQuoteButton = function () {\n const label = getTranslation().createQuoteButtonLabel\n\n const targets = [\n '.cart-links.cart-links-bottom',\n '.payment-confirmation-wrap',\n ]\n\n targets.forEach(function (target) {\n const btn = $(\n `<button class='btn btn-large btn-primary btn-b2b-primary'>${label}</button>`\n ).click(function () {\n window.location.replace('/b2b-quotes/create')\n })\n\n $(target).append(btn)\n })\n }\n\n const buildPOField = function () {\n if ($('.b2b-purchase-order-number-label').length > 0) return false\n\n const wrap = $('.payment-confirmation-wrap')\n\n const { customData } = window.vtexjs.checkout.orderForm\n let currValue = ''\n\n if (customData) {\n const index = customData.customApps.findIndex(function (item) {\n return item.id === 'b2b-checkout-settings'\n })\n\n if (\n index !== -1 &&\n customData.customApps[index].fields.purchaseOrderNumber\n ) {\n currValue = customData.customApps[index].fields.purchaseOrderNumber\n }\n }\n\n wrap.prepend(`\n <div class=\"b2b-purchase-order-number\">\n <p class=\"b2b-purchase-order-number-label\">\n <label for=\"cart-b2b-purchase-order-number\">${\n getTranslation().cartPurchaseOrderLabel\n }</label>\n </p>\n <input class=\"input-small b2b-purchase-order-number-input\" type=\"text\" id=\"cart-b2b-purchase-order-number\" value=\"${currValue}\">\n </div>\n `)\n\n $('body').on('change', '#cart-b2b-purchase-order-number', function (e) {\n e.preventDefault()\n\n const orderFormID = window.vtexjs.checkout.orderFormId\n const purchaseOrderNumber = $(this).val()\n\n $.ajax({\n url: `${window.location.origin}/api/checkout/pub/orderForm/${orderFormID}/customData/b2b-checkout-settings/purchaseOrderNumber`,\n type: purchaseOrderNumber ? 'PUT' : 'DELETE',\n data: { value: purchaseOrderNumber },\n })\n })\n }\n\n const removeCartItemsAndQuote = function () {\n if (window.vtexjs && window.vtexjs.checkout) {\n window.vtexjs.checkout.removeAllItems().then(function () {\n window.vtexjs.checkout\n .setCustomData({\n value: 0,\n app: 'b2b-quotes-graphql',\n field: 'quoteId',\n })\n .then(function () {})\n })\n }\n }\n\n const showPaymentOptions = function (permissions) {\n const allOptions = document.querySelectorAll(\n '.orderform-template-holder #payment-data .payment-group-item'\n )\n\n const [activeOption] = document.querySelectorAll(\n '.orderform-template-holder #payment-data .payment-group-item.active'\n )\n\n const activeOptionText = activeOption\n ? activeOption.dataset.name.toLowerCase()\n : ''\n\n const isCreditCardActive = CREDIT_CARDS.includes(activeOptionText)\n let firstOption = null\n\n if (\n permissions &&\n permissions.paymentTerms &&\n permissions.paymentTerms.length\n ) {\n allOptions.forEach(function (obj) {\n const currOption = obj.dataset.name.toLowerCase()\n\n const isCreditCard = CREDIT_CARDS.includes(currOption)\n\n if (\n permissions.paymentTerms.findIndex(function (pmt) {\n if (isCreditCard) {\n return pmt.name.toLowerCase() === 'credit card'\n }\n\n return pmt.name.toLowerCase() === currOption\n }) === -1\n ) {\n return\n }\n\n if (firstOption === null) {\n firstOption = obj\n }\n\n obj.setAttribute('data-b2b-allowed', 'true')\n })\n\n if (\n permissions.paymentTerms.findIndex(function (pmt) {\n if (isCreditCardActive) {\n return pmt.name.toLowerCase() === 'credit card'\n }\n\n return pmt.name.toLowerCase() === activeOptionText\n }) === -1\n ) {\n $(firstOption).click()\n }\n }\n }\n\n const applyPermissions = function (permissions) {\n // Add permission keys to the body class for layout changes\n $('body').addClass(permissions.join(' '))\n\n const [, step] = window.location.hash.split('/')\n\n // Check if use can navigate the checkout\n if (\n permissions.indexOf('can-checkout') === -1 &&\n step.indexOf('cart') === -1\n ) {\n window.sessionStorage.setItem('message', 'b2b-access-denied')\n window.location.replace('/checkout/#/cart')\n }\n\n // Show payment options available\n if (step.includes('payment')) {\n const checkPayment = setInterval(function () {\n if (\n document.querySelectorAll(\n '.orderform-template-holder #payment-data .payment-group-item'\n ).length > 0\n ) {\n clearInterval(checkPayment)\n showPaymentOptions(settings)\n }\n }, 500)\n }\n if (step.includes('shipping')) {\n const canEditAddress = 'add-shipping'\n const isLoggedIn =\n window.vtexjs &&\n window.vtexjs.checkout &&\n window.vtexjs.checkout.orderForm &&\n window.vtexjs.checkout.orderForm.loggedIn\n\n const checkShipping = setInterval(function () {\n if (\n !isLoggedIn ||\n (b2bCheckoutSettings &&\n b2bCheckoutSettings.permissions.includes(canEditAddress))\n ) {\n clearInterval(checkShipping)\n window.b2bCheckoutSettings = undefined\n }\n }, 500)\n\n // Set up observer for Brazilian address form fix\n const checkShippingForm = setInterval(function () {\n const shippingContainer = document.querySelector('.shipping-container')\n\n if (shippingContainer) {\n clearInterval(checkShippingForm)\n\n // Initial check\n setTimeout(fixBrazilianAddressForm, 1000)\n\n // Observe changes in the shipping container\n const shippingObserver = new MutationObserver(function () {\n fixBrazilianAddressForm()\n })\n\n shippingObserver.observe(shippingContainer, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['class', 'style']\n })\n }\n }, 500)\n }\n if (step.includes('payment') && b2bCheckoutSettings == undefined) {\n b2bCheckoutSettings = settings\n }\n }\n\n // Flag to prevent multiple executions of the address form fix\n let isFixingAddressForm = false\n\n // Reset the fix flag after address form processing is complete\n const resetFixFlag = function () {\n isFixingAddressForm = false\n }\n\n // Trigger postal code validation by dispatching necessary events\n const triggerPostalCodeValidation = function (postalCodeInput, postalCode) {\n postalCodeInput.value = postalCode\n\n // Trigger all necessary events to activate VTEX validation\n const events = ['input', 'change', 'blur']\n events.forEach(function (eventType) {\n const event = new Event(eventType, { bubbles: true })\n postalCodeInput.dispatchEvent(event)\n })\n\n // Reset the flag after VTEX completes validation (typically takes ~2s)\n setTimeout(resetFixFlag, 2000)\n }\n\n // Handle the appearance of the new address form after clicking the button\n const handleNewAddressFormAppearance = function (currentPostalCode) {\n const postalCodeInput = document.getElementById('ship-postalCode')\n\n if (!postalCodeInput) {\n resetFixFlag()\n return\n }\n\n // Clear the postal code first\n postalCodeInput.value = ''\n\n // Wait briefly, then refill to trigger address lookup\n setTimeout(function () {\n triggerPostalCodeValidation(postalCodeInput, currentPostalCode)\n }, 300)\n }\n\n // Main function to detect and fix Brazilian address form issues\n const fixBrazilianAddressForm = function () {\n // Prevent multiple simultaneous executions\n if (isFixingAddressForm) return\n\n const [, step] = window.location.hash.split('/')\n if (!step || !step.includes('shipping')) return\n\n const countrySelect = document.getElementById('ship-country')\n const postalCodeInput = document.getElementById('ship-postalCode')\n const numberInput = document.getElementById('ship-number')\n const newAddressButton = document.getElementById('new-address-button')\n\n // Check if we have all required elements\n if (!countrySelect || !postalCodeInput || !newAddressButton) {\n return\n }\n\n // Check if country is Brazil and postal code is filled\n const isBrazil = countrySelect.value === 'BRA'\n const hasPostalCode = postalCodeInput.value && postalCodeInput.value.trim() !== ''\n\n if (!isBrazil || !hasPostalCode) {\n return\n }\n\n // Check if number input exists but is not visible\n // The field might be hidden when address list is shown\n const isNumberFieldHidden =\n numberInput &&\n (numberInput.offsetParent === null ||\n window.getComputedStyle(numberInput).display === 'none' ||\n window.getComputedStyle(numberInput.parentElement).display === 'none')\n\n // Also check if address list is visible (indicates we're in the problematic state)\n const addressList = document.querySelector('.address-list.vtex-omnishipping-1-x-addressList')\n const isAddressListVisible = addressList && addressList.offsetParent !== null\n\n // If we're showing the address list and number field is hidden, we need to fix it\n if (isAddressListVisible && isNumberFieldHidden) {\n isFixingAddressForm = true\n const currentPostalCode = postalCodeInput.value\n\n // Click the \"new address\" button to show the form\n newAddressButton.click()\n\n // Wait for the form to appear, then re-fill the postal code\n setTimeout(function () {\n handleNewAddressFormAppearance(currentPostalCode)\n }, 500)\n }\n }\n\n const applyMarketingData = function (organizationId, costCenterId) {\n if (!organizationId || !costCenterId) return false\n\n const marketingData = {\n utmCampaign: organizationId,\n utmMedium: costCenterId,\n }\n\n window.vtexjs.checkout.sendAttachment('marketingData', marketingData)\n }\n\n const handleSettings = function () {\n if (!settings) return\n\n if (settings.showPONumber === true) {\n buildPOField()\n }\n\n if (settings.permissions) {\n applyPermissions(settings.permissions)\n }\n\n const createQuotePermission = JSON.parse(\n window.sessionStorage.getItem('checkout.createQuote')\n )\n\n if (settings.showQuoteButton && createQuotePermission) {\n buildCreateQuoteButton()\n }\n\n if (\n window.vtexjs &&\n window.vtexjs.checkout &&\n window.vtexjs.checkout.orderForm &&\n (!window.vtexjs.checkout.orderForm.marketingData ||\n !window.vtexjs.checkout.orderForm.marketingData.utmCampaign ||\n !window.vtexjs.checkout.orderForm.marketingData.utmMedium)\n ) {\n applyMarketingData(settings.organizationId, settings.costCenterId)\n }\n\n window.b2bCheckoutSettings = settings\n }\n\n const checkQuotes = function () {\n if (\n window.vtexjs &&\n window.vtexjs.checkout &&\n window.vtexjs.checkout.orderForm &&\n window.vtexjs.checkout.orderForm.customData\n ) {\n const { customData } = window.vtexjs.checkout.orderForm\n\n if (customData != null && customData.customApps) {\n const index = customData.customApps.findIndex(function (item) {\n return item.id === 'b2b-quotes-graphql'\n })\n\n if (index !== -1) {\n const quoteId = customData.customApps[index].fields.quoteId\n\n if (quoteId && parseInt(quoteId, 10) !== 0) {\n buildClearCartButton()\n lockFields()\n }\n }\n }\n }\n }\n\n const observeDOM = (function () {\n const MutationObserver =\n window.MutationObserver || window.WebKitMutationObserver\n\n return function (obj, callback) {\n if (!obj || obj.nodeType !== 1) return\n\n if (MutationObserver) {\n // define a new observer\n const mutationObserver = new MutationObserver(callback)\n\n // have the observer observe foo for changes in children\n mutationObserver.observe(obj, { childList: true, subtree: true })\n\n return mutationObserver\n }\n\n // browser support fallback\n if (window.addEventListener) {\n obj.addEventListener('DOMNodeInserted', callback, false)\n obj.addEventListener('DOMNodeRemoved', callback, false)\n }\n }\n })()\n\n const selectorsToLock = [\n 'td.quantity',\n 'a.manualprice-link-remove',\n 'span.new-product-price',\n 'td.item-remove',\n ]\n\n const lockFields = function () {\n selectorsToLock.forEach(function (selector) {\n if (!$(selector).hasClass('item-disabled')) {\n $(selector).addClass('item-disabled')\n }\n })\n }\n\n const observer = new MutationObserver(function () {\n const cartItems = document.querySelector('.cart-items')\n\n if (cartItems) {\n observer.disconnect()\n observeDOM(cartItems, function () {\n cartItems.classList.add('pointer-events-none')\n checkQuotes()\n setTimeout(function () {\n cartItems.classList.remove('pointer-events-none')\n }, 500)\n })\n }\n })\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n })\n\n const fetchSettings = function () {\n const rootPath =\n window.vtex.renderRuntime.rootPath !== undefined\n ? window.vtex.renderRuntime.rootPath\n : ''\n\n const ts = new Date().getTime()\n\n $.ajax({\n url: `${rootPath}/_v/private/b2b-checkout-settings/${\n isWorkspace() ? `?v=${ts}` : ''\n }`,\n }).then(function (response) {\n if (Object.keys(response).length === 0) {\n window.sessionStorage.removeItem('b2b-checkout-settings')\n\n return\n }\n\n response.time = new Date().toISOString()\n\n if (\n window.vtexjs &&\n window.vtexjs.checkout &&\n window.vtexjs.checkout.orderForm\n ) {\n response.email =\n window.vtexjs.checkout.orderForm.clientProfileData.email\n }\n\n window.sessionStorage.setItem(\n 'b2b-checkout-settings',\n JSON.stringify(response)\n )\n settings = response\n handleSettings()\n })\n }\n\n // Wait until it have the vtex runtime to call the functions\n checkVtex = setInterval(function () {\n if (window.vtex !== undefined && window.vtex.renderRuntime !== undefined) {\n clearInterval(checkVtex)\n if (isWorkspace() || !settings) {\n fetchSettings()\n } else {\n handleSettings()\n }\n }\n }, 500)\n\n const initialize = function () {\n const message = window.sessionStorage.getItem('message')\n\n if (settings && settings.permissions) {\n applyPermissions(settings.permissions)\n }\n\n if (message) {\n $(window).trigger('addMessage.vtex', {\n type: 'info',\n id: message,\n content: {\n title: getTranslation().messages[message].title,\n detail: getTranslation().messages[message].detail,\n },\n })\n window.sessionStorage.removeItem('message')\n }\n }\n\n $(window).on('hashchange', () => initialize())\n})()\n\n```"
}
] |
code_b2b-checkout-settings_f1154653
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/checkout-ui-custom/checkout-confirmation-custom.js from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n// WARNING: THE USAGE OF CUSTOM SCRIPTS IS NOT SUPPORTED. VTEX IS NOT LIABLE FOR ANY DAMAGES THIS MAY CAUSE.\n// THIS MAY BREAK YOUR STORE AND STOP SALES. IN CASE OF ERRORS, PLEASE DELETE THE CONTENT OF THIS SCRIPT.\n\n```"
}
] |
code_b2b-checkout-settings_f4ffe26a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/checkout-ui-custom/checkout5-custom.js from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n// WARNING: THE USAGE OF CUSTOM SCRIPTS IS NOT SUPPORTED. VTEX IS NOT LIABLE FOR ANY DAMAGES THIS MAY CAUSE. THIS MAY BREAK YOUR STORE AND STOP SALES. IN CASE OF ERRORS, PLEASE DELETE THE CONTENT OF THIS SCRIPT.\n\n```"
}
] |
code_b2b-checkout-settings_46c656ea
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/checkout-ui-custom/checkout6-custom.css from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n.pointer-events-none {\n pointer-events: none;\n}\n.b2b-purchase-order-number {\n margin-bottom: 15px;\n}\n.b2b-purchase-order-number input[type='text'] {\n height: 30px;\n line-height: 30px;\n max-height: initial;\n display: inline-block;\n padding: 0px 10px;\n border-radius: 4px;\n border: 1px solid #cbcbcb;\n outline: initial;\n font-family: 'Roboto', sans-serif;\n box-sizing: border-box;\n width: 100%;\n}\n.b2b-purchase-order-number input[type='text']:focus {\n box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(0, 0, 0, 0.4);\n}\n\nbody.can-checkout .client-profile-data a.link-box-edit,\nbody.can-checkout button.vtex-omnishipping-1-x-buttonEditAddress,\nbody.can-checkout button.vtex-omnishipping-1-x-buttonCreateAddress,\nbody.can-checkout .orderform-template-holder #payment-data .payment-group-item {\n display: none !important;\n}\n\nbody.change-profile .client-profile-data a.link-box-edit,\nbody.edit-shipping button.vtex-omnishipping-1-x-buttonEditAddress,\nbody.add-shipping button.vtex-omnishipping-1-x-buttonCreateAddress,\nbody.can-checkout\n .orderform-template-holder\n #payment-data\n .payment-group-item[data-b2b-allowed='true'] {\n display: block !important;\n}\n\n.btn-b2b-primary {\n margin: 10px 0;\n width: 100%;\n}\n\n.item-disabled {\n pointer-events: none;\n opacity: 0.5;\n}\n\n.v-custom-payment-item-wrap {\n border: none !important;\n}\n.v-custom-payment-item-wrap.active {\n border: 1px solid !important;\n}\n\n```"
}
] |
code_b2b-checkout-settings_d9c88c1b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/admin/navigation.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n[\n {\n \"section\": \"storeSetup\",\n \"titleId\": \"admin/b2bCheckoutSettings.navigation.title\",\n \"path\": \"/admin/b2b-checkout-settings/\"\n },\n {\n \"section\": \"storeSettings\",\n \"subSection\": \"storeFront\",\n \"adminVersion\": 4,\n \"subSectionItems\": [\n {\n \"labelId\": \"admin/b2bCheckoutSettings.navigation.title\",\n \"path\": \"/admin/b2b-checkout-settings/\"\n }\n ]\n }\n]\n\n```"
}
] |
code_b2b-checkout-settings_7d440af1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/admin/routes.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin.app.b2b-checkout-settings\": {\n \"component\": \"B2BCheckoutAdmin\",\n \"path\": \"/admin/app/b2b-checkout-settings\"\n }\n}\n\n```"
}
] |
code_b2b-checkout-settings_e0fe7cd6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/docs/README.md from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# B2B Checkout Settings\n\n> ℹ The **B2B Checkout Settings** app is part of VTEX’s [B2B Suite](https://developers.vtex.com/vtex-developer-docs/docs/vtex-b2b-suite) solution, a collection of apps that allow stores to manage organizations, storefront roles and permissions, and checkout settings for B2B commerce relationships. We recommend that you use it alongside the other apps in this suite for all functionalities to work as expected.\n\nIn B2B commerce, it is often necessary to provide customized options during checkout, such as:\n\n* Making specific payment methods available for each organization or cost center.\n* Providing pre-filled addresses.\n* Including a purchase order number in the order.\n* Offering the option to create an order quote before making an actual purchase.\n\nThe **B2B Checkout Settings** app works alongside other **B2B Suite** apps to extend the checkout experience for users who are members of organizations, adding all the above possibilities to the checkout page.\n\n\n## Before you start\n\nFirst, make sure you have the [VTEX IO CLI (Command Line Interface)](https://developers.vtex.com/vtex-developer-docs/docs/vtex-io-documentation-vtex-io-cli-install) installed in your machine.\n\nTo use **B2B Checkout Settings**, you must have the [B2B Organizations](https://developers.vtex.com/vtex-developer-docs/docs/vtex-b2b-organizations) app installed in your store, which will enable you to group B2B users into organizations, with their own assigned payment methods, price tables, product collections, and cost centers. \n\nYou must also have the [Storefront Permissions](https://developers.vtex.com/vtex-developer-docs/docs/vtex-storefront-permissions) app installed – it allows you to grant specific storefront roles for B2B users in an organization. See the **Storefront Permissions** app documentation for information on the available roles and how to customize their permissions.\n\n\n## Installation\n\nYou can install this app by running `vtex install vtex.b2b-checkout-settings` in your terminal, using the [VTEX IO CLI](https://developers.vtex.com/vtex-developer-docs/docs/vtex-io-documentation-vtex-io-cli-installation-and-command-reference).\n\nAfter this command, the app will be installed in your VTEX Admin, and B2B store administrators can access it on **Store Setup** > **B2B Checkout Settings**.\n\n\n## How it works\n\nConsidering B2B stores often need similar customizations, **B2B Checkout Settings** provides a ready-to-use customized checkout page for B2B scenarios.\n\nOnce **B2B Checkout Settings** is installed in your account, every script contained in its [`checkout-ui-custom` folder](https://github.com/vtex-apps/b2b-checkout-settings/tree/master/checkout-ui-custom) will be automatically linked to your store. The app will customize your checkout page with the functionalities described below. You will also be able to [configure](#configuration) the app on **Store Setup** > **B2B Checkout Settings**.\n\n\n> ℹ The behavior of the checkout page in VTEX stores is customizable through JavaScript code. In case you need additional customization, we recommend that you use [Checkout UI Custom](https://apps.vtex.com/vtex-checkout-ui-custom/p) if you prefer using the VTEX Admin interface or [Checkout UI Settings](https://developers.vtex.com/vtex-developer-docs/docs/vtex-checkout-ui-settings) if you prefer a code-only option.\n\n\n### Restricted access to checkout\n\nThis app automatically checks users’ roles within the organization by communicating with the **B2B Organizations** app, and validates if the user has the required permissions to access checkout, by communicating with the Storefront Permissions app.\n\nBy default, users with any storefront role can access checkout, except for users with the **Organization Buyer** role. Any attempt to proceed to checkout without the required permission will result in a notification with the following message: _You don’t have access to the checkout_.\n\nNote that if you have [Storefront Permissions UI](https://developers.vtex.com/vtex-developer-docs/docs/vtex-storefront-permissions-ui) installed, you can customize these permissions on the VTEX Admin by accessing **Account Settings > Storefront Permissions**.\n\n\n### Cost Center addresses\n\nThe **B2B Checkout Settings** app communicates with the **B2B Organizations** app and automatically lists the [Cost Center addresses](https://developers.vtex.com/vtex-developer-docs/docs/vtex-b2b-organizations#cost-center-details) associated with the user during checkout:\n\n|  |  |\n|-|-|\n| **Cost Center Details** page, displaying two options of addresses associated with the cost center in question | Checkout page for an user associated with this organization and cost center |\n\n\n### Purchase order number field\n\nA purchase order (PO) is a commercial agreement between a buyer company and a B2B store, authorizing the payment for products or services to be delivered in the future within a specific time frame.\n\nHaving a purchase order number allows B2B customers to pay for authorized purchases by referencing this number. The purchase order is authorized and issued in advance by the company that is making the purchase.\n\nUsing **B2B Checkout Settings**, it is possible to enable an optional **Reference or PO Number** field for customers to insert this information during the checkout.\n\n\n\nSee the [Configuration](#configuration) section to understand how to enable or disable this button.\n\n## Configuration\n\nTo change app settings, in the VTEX Admin go to **Store Setup** > **B2B Checkout Settings**.\n\n\n\nYou can use the toggle button to activate or deactivate the available settings:\n\n* **Show Purchase Order Number Field:** enabling this will add the **Reference or PO Number** input field to the checkout page. This will allow users to insert a purchase order number during checkout.\n* **Show 'Create a Quote' Button:** enabling this will add the `Create a Quote` button to checkout, which allows users to create a quote using the current contents of their cart.\n\n> ⚠️ You should only enable the `Create a Quote` button if your store has the [B2B Quotes](https://github.com/vtex-apps/b2b-quotes) app installed. Check the **B2B Quotes** app documentation for more information on how order quotes work.\n\n```"
}
] |
code_b2b-checkout-settings_e0fa09bd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/graphql/schema.graphql from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ntype Query {\n appSettings: Settings @cacheControl(scope: PUBLIC, maxAge: SHORT)\n}\n\ntype Mutation {\n saveAppSettings(settings: SettingsInput!): Settings\n @withAdminAccess\n @cacheControl(scope: PRIVATE)\n}\n\ntype Settings {\n showPONumber: Boolean\n hasPONumber: Boolean\n showQuoteButton: Boolean\n}\n\ninput SettingsInput {\n showPONumber: Boolean!\n hasPONumber: Boolean!\n showQuoteButton: Boolean!\n}\n\n```"
}
] |
code_b2b-checkout-settings_3398b7c0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/graphql/directives.graphql from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ndirective @withAdminAccess on FIELD | FIELD_DEFINITION\n\n```"
}
] |
code_b2b-checkout-settings_8b822c52
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/vtex.storefront-permissions/configuration.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"B2B Checkout Settings\",\n \"features\": [\n {\n \"label\": \"Can change profile\",\n \"value\": \"change-profile\",\n \"roles\": [\"store-admin\", \"sales-admin\", \"sales-manager\"]\n },\n {\n \"label\": \"Can add shipping\",\n \"value\": \"add-shipping\",\n \"roles\": [\n \"store-admin\",\n \"sales-admin\",\n \"sales-manager\",\n \"sales-representative\",\n \"customer-admin\",\n \"customer-approver\"\n ]\n },\n {\n \"label\": \"Can checkout\",\n \"value\": \"can-checkout\",\n \"roles\": [\n \"store-admin\",\n \"sales-admin\",\n \"sales-manager\",\n \"sales-representative\",\n \"customer-admin\",\n \"customer-approver\"\n ]\n }\n ]\n}\n\n```"
}
] |
code_b2b-checkout-settings_7c32f067
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/service.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"stack\": \"nodejs\",\n \"memory\": 1024,\n \"ttl\": 300,\n \"timeout\": 60,\n \"cpu\": {\n \"type\": \"shared\",\n \"value\": 5,\n \"scalingPercentage\": 20\n },\n \"minReplicas\": 8,\n \"maxReplicas\": 80,\n \"workers\": 1,\n \"routes\": {\n \"settings\": {\n \"path\": \"/_v/private/b2b-checkout-settings/\",\n \"public\": true\n }\n }\n}\n\n```"
}
] |
code_b2b-checkout-settings_3cf7e571
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/typings.d.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface ReqContext {\n account: string\n workspace: string\n authToken: string\n region: string\n production: boolean\n userAgent: string\n}\n\ninterface Logger {\n log(content: string, level: LogLevel, details?: any): PromiseLike<void>\n}\n\ninterface OrderFormConfiguration {\n paymentConfiguration?: PaymentConfiguration\n taxConfiguration?: TaxConfiguration\n minimumQuantityAccumulatedForItems?: number\n decimalDigitsPrecision?: number\n minimumValueAccumulated?: number\n apps?: [App]\n allowMultipleDeliveries?: boolean\n allowManualPrice?: boolean\n maxIntOfWhiteLabelSellers?: number\n maskFirstPurchaseData?: boolean\n recaptchaValidation?: boolean\n}\n\ninterface OperationState {\n orderFormId: string\n ctx: ReqContext\n data?: OperationData\n logger: Logger\n}\n\ninterface OperationData {\n orderForm?: any\n userProfileId: string\n cookie: string\n}\n\ntype ProcessPaymentStep = (\n state: OperationState,\n next: () => Promise<void>\n) => Promise<void>\n\ntype LogLevel = 'info' | 'error' | 'warning'\n\ntype Timings = { [middleware: string]: [number, number] }\n\ndeclare module '*.json' {\n const value: any\n export default value\n}\n\ninterface OrganizationInput {\n name: string\n b2bCustomerAdmin: B2BCustomerInput\n defaultCostCenter: DefaultCostCenterInput\n}\n\ninterface B2BCustomerInput {\n firstName: string\n lastName: string\n email: string\n}\n\ninterface DefaultCostCenterInput {\n name: string\n address: AddressInput\n}\n\ninterface CostCenterInput {\n name: string\n addresses: AddressInput[]\n}\n\ninterface AddressInput {\n addressId: string\n addressType: string\n postalCode: string\n country: string\n receiverName: string\n city: string\n state: string\n street: string\n number: string\n complement: string\n neighborhood: string\n geoCoordinates: [number]\n}\n\ninterface OrganizationRequest {\n name: string\n defaultCostCenter: DefaultCostCenterInput\n b2bCustomerAdmin: string\n status: string\n created: string\n}\n\ninterface Organization {\n id: string\n name: string\n costCenters: string[]\n status: string\n created: string\n}\n\ninterface CostCenter {\n id: string\n name: string\n organization: string\n addresses: any[]\n}\n\ninterface UserArgs {\n id?: string\n roleId: string\n userId?: string\n orgId?: string\n costId?: string\n clId?: string\n canImpersonate?: boolean\n name: string\n email: string\n}\n\n```"
}
] |
code_b2b-checkout-settings_20faa863
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/package.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.b2b-organizations\",\n \"version\": \"3.1.0\",\n \"dependencies\": {\n \"@vtex/api\": \"6.50.1\",\n \"atob\": \"^2.1.2\",\n \"co-body\": \"^6.0.0\",\n \"graphql\": \"^14.5.0\",\n \"graphql-tools\": \"^4.0.6\",\n \"jsonwebtoken\": \"^8.5.0\",\n \"qs\": \"^6.9.4\",\n \"ramda\": \"^0.25.0\"\n },\n \"devDependencies\": {\n \"@ngneat/falso\": \"^6.4.0\",\n \"@types/atob\": \"^2.1.2\",\n \"@types/bluebird\": \"^3.5.25\",\n \"@types/co-body\": \"0.0.3\",\n \"@types/graphql\": \"^14.5.0\",\n \"@types/jest\": \"27.4.1\",\n \"@types/jsonwebtoken\": \"^8.5.0\",\n \"@types/node\": \"^12.12.21\",\n \"@types/ramda\": \"types/npm-ramda#dist\",\n \"@vtex/prettier-config\": \"^0.3.1\",\n \"@vtex/tsconfig\": \"^0.6.0\",\n \"jest\": \"27.5.1\",\n \"ts-jest\": \"^27.1.4\",\n \"ts-node\": \"^10.9.1\",\n \"tslint\": \"^5.12.0\",\n \"tslint-config-prettier\": \"^1.18.0\",\n \"tslint-config-vtex\": \"^2.1.0\",\n \"typescript\": \"3.9.7\",\n \"vtex.b2b-organizations-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.b2b-organizations-graphql@0.9.2/public/@types/vtex.b2b-organizations-graphql\",\n \"vtex.graphql-server\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.graphql-server@1.67.0/public/_types/react\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.146.0/public/@types/vtex.styleguide\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit && tslint -c tslint.json './**/*.ts'\",\n \"test\": \"jest\"\n }\n}\n\n```"
}
] |
code_b2b-checkout-settings_895d093c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/index.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type {\n ClientsConfig,\n ServiceContext,\n ParamsContext,\n RecorderState,\n Cached,\n} from '@vtex/api'\nimport { LRUCache, Service } from '@vtex/api'\n\nimport { Clients } from './clients'\nimport { resolvers } from './resolvers'\nimport { schemaDirectives } from './resolvers/directives'\n\nconst TIMEOUT_MS = 3000\n\n// Create a LRU memory cache for the Status client.\n// The @vtex/api HttpClient respects Cache-Control headers and uses the provided cache.\nconst memoryCache = new LRUCache<string, Cached>({ max: 5000 })\n\nmetrics.trackCache('status', memoryCache)\n\n// This is the configuration for clients available in `ctx.clients`.\nconst clients: ClientsConfig<Clients> = {\n // We pass our custom implementation of the clients bag, containing the Status client.\n implementation: Clients,\n options: {\n // All IO Clients will be initialized with these options, unless otherwise specified.\n default: {\n retries: 2,\n timeout: TIMEOUT_MS,\n },\n // This key will be merged with the default options and add this cache to our Status client.\n status: {\n memoryCache,\n },\n },\n}\n\ndeclare global {\n type Context = ServiceContext<Clients>\n}\n\nexport default new Service<Clients, RecorderState, ParamsContext>({\n clients,\n routes: resolvers.Routes,\n graphql: {\n resolvers: {\n Query: resolvers.Query,\n Mutation: resolvers.Mutation,\n },\n schemaDirectives,\n },\n})\n\n```"
}
] |
code_b2b-checkout-settings_13a0d5c1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/react/package.json from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"b2b-checkout-settings\",\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"react-apollo\": \"^3.1.5\",\n \"react-intl\": \"^5.24.6\"\n },\n \"devDependencies\": {\n \"@types/jest\": \"^26.0.4\",\n \"@types/node\": \"^14.0.14\",\n \"@types/react\": \"^16.9.41\",\n \"@types/react-intl\": \"^3.0.0\",\n \"@vtex/test-tools\": \"^3.1.0\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"vtex.b2b-organizations-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.b2b-organizations-graphql@0.9.2/public/@types/vtex.b2b-organizations-graphql\",\n \"vtex.graphql-server\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.graphql-server@1.67.0/public/_types/react\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.132.3/public/@types/vtex.render-runtime\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.146.0/public/@types/vtex.styleguide\"\n },\n \"version\": \"3.1.0\"\n}\n\n```"
}
] |
code_b2b-checkout-settings_e883e2f1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/react/B2BCheckoutAdmin.tsx from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport B2BCheckoutAdmin from './components/B2BCheckoutAdmin'\n\nexport default B2BCheckoutAdmin\n\n```"
}
] |
code_b2b-checkout-settings_d2a9ab3f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/clients/StorefrontPermissions.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { AppGraphQLClient } from '@vtex/api'\n\nimport { QUERIES } from '../resolvers/Routes/queries'\nimport { getTokenToHeader } from './index'\n\nexport default class StorefrontPermissions extends AppGraphQLClient {\n constructor(ctx: IOContext, options?: InstanceOptions) {\n super('vtex.storefront-permissions@3.x', ctx, options)\n }\n\n public checkUserPermission = async (): Promise<any> => {\n return this.graphql.query(\n {\n extensions: {\n persistedQuery: {\n provider: 'vtex.storefront-permissions@3.x',\n sender: 'vtex.b2b-checkout-settings@3.x',\n },\n },\n query: QUERIES.getPermission,\n variables: {},\n },\n {\n headers: getTokenToHeader(this.context),\n params: {\n locale: this.context.locale,\n },\n }\n )\n }\n}\n\n```"
}
] |
code_b2b-checkout-settings_0d74d71d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/clients/Organizations.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { AppGraphQLClient } from '@vtex/api'\n\nimport { QUERIES } from '../resolvers/Routes/queries'\nimport { getTokenToHeader } from './index'\n\nexport class OrganizationsGraphQLClient extends AppGraphQLClient {\n constructor(ctx: IOContext, options?: InstanceOptions) {\n super('vtex.b2b-organizations-graphql@2.x', ctx, options)\n }\n\n public getAddresses = async (costCenterId: string): Promise<any> => {\n return this.graphql.query(\n {\n extensions: {\n persistedQuery: {\n provider: 'vtex.b2b-organizations-graphql@2.x',\n sender: 'vtex.b2b-checkout-settings@3.x',\n },\n },\n query: QUERIES.getAddresses,\n variables: {\n id: costCenterId,\n },\n },\n {\n headers: getTokenToHeader(this.context),\n params: {\n locale: this.context.locale,\n },\n }\n )\n }\n\n public getOrganization = async (organizationId: string): Promise<any> => {\n return this.graphql.query(\n {\n extensions: {\n persistedQuery: {\n provider: 'vtex.b2b-organizations-graphql@2.x',\n sender: 'vtex.b2b-checkout-settings@3.x',\n },\n },\n query: QUERIES.getOrganizationDetails,\n variables: {\n id: organizationId,\n },\n },\n {\n headers: getTokenToHeader(this.context),\n params: {\n locale: this.context.locale,\n },\n }\n )\n }\n}\n\n```"
}
] |
code_b2b-checkout-settings_353c6b44
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/clients/Checkout.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type {\n InstanceOptions,\n IOContext,\n RequestTracingConfig,\n} from '@vtex/api'\nimport { JanusClient } from '@vtex/api'\n\nimport { createTracing } from '../utils'\n\nconst CHECKOUT_ENDPOINT = 'api/checkout/pvt/configuration/orderForm'\n\nexport class Checkout extends JanusClient {\n constructor(ctx: IOContext, options?: InstanceOptions) {\n super(ctx, {\n ...options,\n headers: {\n ...(ctx.adminUserAuthToken\n ? {\n VtexIdclientAutCookie: ctx.adminUserAuthToken,\n }\n : {}),\n },\n })\n }\n\n public getOrderFormConfiguration(tracingConfig?: RequestTracingConfig) {\n const metric = 'b2b-checkout-settings-getOrderForm'\n\n return this.http.get<OrderFormConfiguration>(CHECKOUT_ENDPOINT, {\n metric,\n tracing: createTracing(metric, tracingConfig),\n })\n }\n\n public setOrderFormConfiguration(\n body: OrderFormConfiguration,\n userToken: string,\n tracingConfig?: RequestTracingConfig\n ) {\n const metric = 'b2b-checkout-settings-setOrderForm'\n\n return this.http.post(CHECKOUT_ENDPOINT, body, {\n headers: {\n VtexIdclientAutCookie: userToken,\n },\n metric,\n tracing: createTracing(metric, tracingConfig),\n })\n }\n}\n\n```"
}
] |
code_b2b-checkout-settings_cebc6966
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/clients/AuthUser.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { JanusClient } from '@vtex/api'\n\nexport class AuthUser extends JanusClient {\n constructor(ctx: IOContext, options?: InstanceOptions) {\n super(ctx, {\n ...options,\n headers: {\n ...options?.headers,\n },\n })\n }\n\n public async validateToken(token: any): Promise<any> {\n return this.http.post(`/api/vtexid/credential/validate`, token)\n }\n}\n\n```"
}
] |
code_b2b-checkout-settings_b270e4d1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/clients/index.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { IOContext } from '@vtex/api'\nimport { IOClients } from '@vtex/api'\n\nimport { AuthUser } from './AuthUser'\nimport { Checkout } from './Checkout'\nimport { OrganizationsGraphQLClient } from './Organizations'\nimport StorefrontPermissions from './StorefrontPermissions'\n\n// Extend the default IOClients implementation with our own custom clients.\nexport class Clients extends IOClients {\n public get storefrontPermissions() {\n return this.getOrSet('storefrontPermissions', StorefrontPermissions)\n }\n\n public get organizations() {\n return this.getOrSet('organizations', OrganizationsGraphQLClient)\n }\n\n public get checkout() {\n return this.getOrSet('checkout', Checkout)\n }\n\n public get authUser() {\n return this.getOrSet('authUser', AuthUser)\n }\n}\n\nexport const getTokenToHeader = (ctx: IOContext) => {\n const adminToken = ctx.authToken\n const userToken = ctx.storeUserAuthToken\n const { sessionToken, account } = ctx\n\n let allCookies = `VtexIdclientAutCookie=${adminToken}`\n\n if (userToken) {\n allCookies += `; VtexIdclientAutCookie_${account}=${userToken}`\n }\n\n return {\n 'x-vtex-credential': ctx.authToken,\n VtexIdclientAutCookie: adminToken,\n cookie: allCookies,\n ...(sessionToken && {\n 'x-vtex-session': sessionToken,\n }),\n }\n}\n\n```"
}
] |
code_b2b-checkout-settings_adff2f65
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/utils/GraphQLError.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport default class GraphQLError extends Error {\n public extensions: any\n\n constructor(message: string, details?: any) {\n super(message)\n this.extensions = { message, ...details }\n }\n}\n\n```"
}
] |
code_b2b-checkout-settings_b39baf6d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/utils/index.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as crypto from 'crypto'\n\nimport type { AxiosError } from 'axios'\nimport type { RequestTracingConfig } from '@vtex/api'\nimport { AuthenticationError, ForbiddenError, UserInputError } from '@vtex/api'\n\nexport const toHash = (obj: any) => {\n return crypto.createHash('md5').update(JSON.stringify(obj)).digest('hex')\n}\n\nexport function statusToError(e: any) {\n if (!e.response) {\n throw e\n }\n\n const { response } = e as AxiosError\n const { status } = response!\n\n if (status === 401) {\n throw new AuthenticationError(e)\n }\n\n if (status === 403) {\n throw new ForbiddenError(e)\n }\n\n if (status === 400) {\n throw new UserInputError(e)\n }\n\n throw e\n}\n\nexport const createTracing = (\n metric: string,\n tracingConfig?: RequestTracingConfig\n) => ({\n requestSpanNameSuffix: metric,\n ...tracingConfig?.tracing,\n})\n\n```"
}
] |
code_b2b-checkout-settings_b0215512
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/resolvers/directives.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { WithPermissions } from './directives/withAdminAccess'\n\nexport const schemaDirectives = {\n withAdminAccess: WithPermissions as any,\n}\n\n```"
}
] |
code_b2b-checkout-settings_af0ae0f4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/resolvers/constants.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const VBASE_BUCKET = 'b2b-checkout-settings'\nexport const VBASE_SETTINGS_FILE = 'settings'\nexport const DEFAULTS = {\n showPONumber: false,\n hasPONumber: false,\n showQuoteButton: false,\n}\n\n```"
}
] |
code_b2b-checkout-settings_2b91b750
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/resolvers/index.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n// import { ForbiddenError } from '@vtex/api'\n\nimport Mutation from './Mutations'\nimport Query from './Queries'\nimport Routes from './Routes'\n\nexport const resolvers = {\n Routes,\n Query,\n Mutation,\n}\n\n```"
}
] |
code_b2b-checkout-settings_ca0bb08c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/resolvers/directives/withAdminAccess.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable max-params */\nimport type { GraphQLField } from 'graphql'\nimport { defaultFieldResolver } from 'graphql'\nimport { SchemaDirectiveVisitor } from 'graphql-tools'\nimport { AuthenticationError, ForbiddenError } from '@vtex/api'\n\nexport class WithPermissions extends SchemaDirectiveVisitor {\n public visitFieldDefinition(field: GraphQLField<any, any>) {\n const { resolve = defaultFieldResolver } = field\n\n field.resolve = async (root: any, args: any, ctx: Context, info: any) => {\n const {\n clients: { authUser },\n vtex: { adminUserAuthToken, logger },\n } = ctx\n\n if (!adminUserAuthToken) {\n throw new AuthenticationError('Unauthorized')\n }\n\n try {\n await authUser.validateToken({\n token: adminUserAuthToken,\n })\n\n return resolve(root, args, ctx, info)\n } catch (error) {\n const {\n response: { status },\n } = error\n\n switch (status) {\n case 401: {\n throw new AuthenticationError('Unauthorized')\n }\n\n case 403: {\n throw new ForbiddenError('Unauthorized Access')\n }\n\n default: {\n logger.error({\n message: 'saveAppSettings-authUser-error',\n error,\n })\n }\n }\n }\n }\n }\n}\n\n```"
}
] |
code_b2b-checkout-settings_9348e55d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/resolvers/Mutations/index.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { GraphQLError } from 'graphql'\n\nimport { VBASE_BUCKET, VBASE_SETTINGS_FILE } from '../constants'\n\nexport interface Settings {\n showPONumber: boolean\n hasPONumber: boolean\n showQuoteButton: boolean\n}\n\nexport default {\n saveAppSettings: async (\n _: void,\n { settings }: { settings: Settings },\n ctx: Context\n ) => {\n const {\n clients: { vbase },\n vtex: { logger },\n } = ctx\n\n if (!settings) throw new GraphQLError('Input not provided')\n\n try {\n await vbase.saveJSON(VBASE_BUCKET, VBASE_SETTINGS_FILE, settings)\n\n return settings\n } catch (error) {\n logger.error({\n message: 'appSettings-saveVbaseError',\n error,\n })\n\n throw new GraphQLError('Failed to save settings')\n }\n },\n}\n\n```"
}
] |
code_b2b-checkout-settings_7f6fa1e9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/resolvers/Queries/index.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { VBASE_BUCKET, VBASE_SETTINGS_FILE, DEFAULTS } from '../constants'\n\nexport default {\n appSettings: async (_: void, __: void, ctx: Context) => {\n const {\n clients: { vbase },\n vtex: { logger },\n } = ctx\n\n let settings = null\n\n try {\n settings = await vbase.getJSON(VBASE_BUCKET, VBASE_SETTINGS_FILE, true)\n } catch (error) {\n logger.error({\n message: 'appSettings-getVbaseError',\n error,\n })\n }\n\n if (!settings) {\n settings = DEFAULTS\n }\n\n return settings\n },\n}\n\n```"
}
] |
code_b2b-checkout-settings_5696e3ab
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/resolvers/Routes/index.test.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { randUuid } from '@ngneat/falso'\nimport type { PaymentTerm } from 'vtex.b2b-organizations-graphql'\n\nimport index from './index'\n\nconst costCenterPaymentTerms = 'costCenterPaymentTerms'\nconst organizationPaymentTerms = 'organizationPaymentTerms'\n\ninterface ResponseBody {\n paymentTerms: PaymentTerm[]\n}\n\nconst getAddressMocked = jest.fn().mockResolvedValueOnce({\n data: {\n getCostCenterById: {\n addresses: {},\n customFields: {},\n paymentTerms: [\n { id: costCenterPaymentTerms, name: costCenterPaymentTerms },\n ],\n },\n },\n})\n\nconst getOrganizationMocked = jest\n .fn()\n .mockImplementationOnce(() =>\n Promise.resolve({\n data: {\n getOrganizationById: {\n addresses: {},\n customFields: {},\n paymentTerms: [\n {\n id: costCenterPaymentTerms,\n name: costCenterPaymentTerms,\n },\n ],\n },\n },\n })\n )\n .mockImplementationOnce(() =>\n Promise.resolve({\n data: {\n getOrganizationById: {\n addresses: {},\n customFields: {},\n paymentTerms: [\n {\n id: organizationPaymentTerms,\n name: organizationPaymentTerms,\n },\n ],\n },\n },\n })\n )\n\nconst mockContext = () => {\n return {\n clients: {\n storefrontPermissions: {\n checkUserPermission: jest.fn().mockResolvedValueOnce({ data: {} }),\n },\n organizations: {\n getAddresses: getAddressMocked,\n getOrganization: getOrganizationMocked,\n },\n session: {\n getSession: jest.fn().mockResolvedValueOnce({\n sessionData: {\n namespaces: {\n 'storefront-permissions': {\n costcenter: {\n value: randUuid(),\n },\n organization: {\n value: randUuid(),\n },\n },\n },\n },\n }),\n },\n vbase: {\n getJSON: jest.fn().mockResolvedValueOnce({}),\n },\n },\n response: {} as Response,\n set: jest.fn(),\n vtex: {\n logger: jest.fn(),\n sessionToken: jest.fn().mockResolvedValueOnce({}),\n storeUserAuthToken: jest.fn().mockResolvedValueOnce({ data: {} }),\n },\n } as unknown as Context\n}\n\nafterEach(() => {\n jest.clearAllMocks()\n})\n\ndescribe('given Routes to call b2b checkout settings', () => {\n describe('when have the cost center and organization with payment terms', () => {\n let context: Context\n\n beforeEach(async () => {\n context = mockContext()\n await index.settings(context)\n })\n\n it('should return payments terms from cost center', () => {\n const { response } = context\n\n expect(response.status).toEqual(200)\n expect(\n (response.body as ResponseBody)?.paymentTerms.some(\n (item: PaymentTerm) => item.id === costCenterPaymentTerms\n )\n ).toBeTruthy()\n\n expect(\n (response.body as ResponseBody)?.paymentTerms.some(\n (item: PaymentTerm) => item.id === organizationPaymentTerms\n )\n ).toBeFalsy()\n })\n })\n\n describe('when have just the organization with payment terms', () => {\n let context: Context\n\n beforeEach(async () => {\n getAddressMocked.mockResolvedValueOnce({\n data: {\n getCostCenterById: {\n addresses: {},\n customFields: {},\n paymentTerms: [],\n },\n },\n })\n\n context = mockContext()\n await index.settings(context)\n })\n\n it('should return payments terms from organization', () => {\n const { response } = context\n\n expect(response.status).toEqual(200)\n expect(\n (response.body as ResponseBody)?.paymentTerms.some(\n (item: PaymentTerm) => item.id === costCenterPaymentTerms\n )\n ).toBeFalsy()\n\n expect(\n (response.body as ResponseBody)?.paymentTerms.some(\n (item: PaymentTerm) => item.id === organizationPaymentTerms\n )\n ).toBeTruthy()\n })\n })\n})\n\n```"
}
] |
code_b2b-checkout-settings_d65d7d6f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/resolvers/Routes/queries.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const QUERIES = {\n getPermission: `query permissions {\n checkUserPermission {\n role {\n id\n name\n slug\n }\n permissions\n }\n }`,\n getOrganizationDetails: `query OrganizationDetails($id: ID!) {\n getOrganizationById(id: $id) {\n status\n paymentTerms {\n id\n name\n }\n customFields {\n name\n value\n }\n }\n }\n `,\n getAddresses: `query addressByCostCenter($id: ID!) {\n getCostCenterById(id: $id) {\n paymentTerms {\n id\n name\n }\n customFields {\n name\n value\n }\n addresses {\n addressId\n addressType\n addressQuery\n postalCode\n country\n receiverName\n city\n state\n street\n number\n complement\n neighborhood\n geoCoordinates\n reference\n }\n }\n }\n `,\n}\n\n```"
}
] |
code_b2b-checkout-settings_46524dff
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/node/resolvers/Routes/index.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { PaymentTerm } from 'vtex.b2b-organizations-graphql'\n\nimport { DEFAULTS, VBASE_BUCKET, VBASE_SETTINGS_FILE } from '../constants'\n\nconst CACHE = 180\n\nexport default {\n settings: async (ctx: Context) => {\n const {\n clients: {\n organizations,\n storefrontPermissions,\n checkout,\n session,\n vbase,\n },\n vtex: { host, logger, storeUserAuthToken, production },\n } = ctx\n\n const token: any = storeUserAuthToken\n\n ctx.set('Content-Type', 'application/json')\n ctx.set('Cache-Control', 'no-cache, no-store')\n\n if (!token && !host?.includes('myvtex.com')) {\n ctx.response.body = {\n error: 'User not authenticated',\n }\n ctx.response.status = 200\n\n ctx.set('cache-control', 'no-cache')\n } else {\n const accountSettings: any = await vbase\n .getJSON(VBASE_BUCKET, VBASE_SETTINGS_FILE, true)\n .catch((error) => {\n logger.error({\n message: 'settings-getJSON-error',\n error,\n })\n })\n\n if (accountSettings?.showPONumber && !accountSettings?.hasPONumber) {\n const checkoutConfig: any = await checkout\n .getOrderFormConfiguration()\n .catch((error) => {\n logger.error({\n message: 'settings-getOrderformConfiguration-error',\n error,\n })\n })\n\n accountSettings.hasPONumber = true\n\n // Check if checkout has b2b-checkout-settings app\n if (\n checkoutConfig?.apps.findIndex(\n (currApp: any) => currApp.id === 'b2b-checkout-settings'\n ) === -1\n ) {\n checkoutConfig.apps.push({\n major: 1,\n id: 'b2b-checkout-settings',\n fields: ['purchaseOrderNumber'],\n })\n\n const setCheckoutConfig: any = await checkout\n .setOrderFormConfiguration(checkoutConfig, ctx.vtex.authToken)\n .then(() => true)\n .catch((error) => {\n accountSettings.hasPONumber = false\n\n logger.error({\n message: 'settings-setOrderformConfiguration-error',\n error,\n })\n\n return false\n })\n\n if (setCheckoutConfig) {\n await vbase\n .saveJSON(VBASE_BUCKET, VBASE_SETTINGS_FILE, accountSettings)\n .catch((error) => {\n logger.error({\n message: 'settings-saveJSON-error',\n error,\n })\n })\n }\n }\n }\n\n const {\n data: { checkUserPermission },\n }: any = await storefrontPermissions\n .checkUserPermission()\n .catch((error: any) => {\n logger.error({\n message: 'checkUserPermission-error',\n error,\n })\n\n return {\n data: {\n checkUserPermission: {\n permissions: [],\n },\n },\n }\n })\n\n const sessionToken =\n ctx.vtex.sessionToken ?? ctx.request.header?.sessiontoken\n\n const userSession = await session\n .getSession(sessionToken as string, ['*'])\n .then((currentSession: any) => {\n return currentSession.sessionData\n })\n .catch((error) => {\n logger.error({\n message: 'getSession-error',\n error,\n })\n })\n\n let settings = {\n ...DEFAULTS,\n ...accountSettings,\n ...checkUserPermission,\n }\n\n // allow users without organization or cost center to access checkout\n if (\n !userSession?.namespaces?.['storefront-permissions']?.organization ||\n !userSession?.namespaces?.['storefront-permissions']?.costcenter\n ) {\n settings = {}\n }\n\n if (\n userSession?.namespaces?.['storefront-permissions']?.costcenter?.value\n ) {\n settings.costCenterId =\n userSession?.namespaces?.['storefront-permissions']?.costcenter?.value\n const {\n data: { getCostCenterById },\n }: any = await organizations\n .getAddresses(settings.costCenterId)\n .then((res: any) => {\n const { addresses, paymentTerms, customFields } =\n res?.data?.getCostCenterById ?? {}\n\n return {\n data: {\n getCostCenterById: {\n addresses,\n customFields,\n paymentTerms,\n },\n },\n }\n })\n .catch((error: any) => {\n logger.error({\n message: 'getCostCenterAddresses-error',\n error,\n })\n\n return {\n data: {\n getCostCenterById: null,\n },\n }\n })\n\n if (getCostCenterById?.addresses) {\n settings.addresses = getCostCenterById.addresses\n }\n\n if (getCostCenterById?.customFields) {\n settings.costCenterCustomFields = getCostCenterById.customFields\n }\n\n if (getCostCenterById?.paymentTerms?.length > 0) {\n settings.paymentTerms = getCostCenterById.paymentTerms\n }\n }\n\n if (\n userSession?.namespaces?.['storefront-permissions']?.organization?.value\n ) {\n settings.organizationId =\n userSession?.namespaces?.[\n 'storefront-permissions'\n ]?.organization?.value\n\n const {\n data: { getOrganizationById },\n }: any = await organizations\n .getOrganization(settings.organizationId)\n .then((res: any) => {\n const { customFields, status, paymentTerms } =\n res?.data?.getOrganizationById ?? {}\n\n return {\n data: {\n getOrganizationById: {\n customFields,\n paymentTerms,\n status,\n },\n },\n }\n })\n .catch((error: any) => {\n logger.error({\n message: 'getOrganizationById-error',\n error,\n })\n\n return {\n data: {\n getOrganizationById: null,\n },\n }\n })\n\n // fix to only show the payment terms that are in common between the organization and the cost center\n if (settings.paymentTerms && getOrganizationById?.paymentTerms) {\n const intersection = settings.paymentTerms.filter(\n (ccPaymentTerms: PaymentTerm) =>\n getOrganizationById.paymentTerms.some(\n (orgPaymentTerms: PaymentTerm) =>\n ccPaymentTerms.id === orgPaymentTerms.id &&\n ccPaymentTerms.name === orgPaymentTerms.name\n )\n )\n\n settings.paymentTerms = intersection\n }\n\n if (!settings.paymentTerms && getOrganizationById?.paymentTerms) {\n settings.paymentTerms = getOrganizationById.paymentTerms\n }\n\n if (!settings.customFields && getOrganizationById?.customFields) {\n settings.customFields = getOrganizationById.customFields\n }\n\n // if organization status is \"on-hold\" or \"inactive\", remove \"can-checkout\" permission\n if (getOrganizationById?.status !== 'active') {\n const newPermissions = settings.permissions?.filter(\n (permission: string) => permission !== 'can-checkout'\n )\n\n settings.permissions = newPermissions ?? []\n }\n }\n\n ctx.set(\n 'cache-control',\n `public, max-age=${production ? CACHE : 'no-cache'}`\n )\n\n ctx.response.body = settings\n\n ctx.response.status = 200\n }\n },\n}\n\n```"
}
] |
code_b2b-checkout-settings_69286aaa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/react/typings/graphql.d.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.graphql' {\n import type { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\ndeclare module '*.gql' {\n const gql: any\n export default gql\n}\n\n```"
}
] |
code_b2b-checkout-settings_4a50ae20
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/react/typings/vtex.styleguide.d.ts from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide' {\n export const PageHeader\n export const Alert\n export const Modal\n export const Box\n export const Card\n export const Checkbox\n export const Dropdown\n export const Spinner\n export const Table\n export const Button\n export const ButtonPlain\n export const IconWarning\n export const IconCheck\n export const Input\n export const InputButton\n export const InputSearch\n export const IconCaretDown\n export const IconCaretUp\n export const IconArrowDown\n export const IconArrowBack\n export const IconArrowUp\n export const IconClose\n export const IconExternalLink\n export const IconSearch\n export const IconSuccess\n export const IconCopy\n export const IconCog\n export const Tooltip\n export const ToastConsumer\n export const ToastProvider\n export const withToast\n export const ButtonWithIcon\n export const Pagination\n export const Collapsible\n export const Textarea\n export const NumericStepper\n export const EmptyState\n export const Tab\n export const Tag\n export const Toggle\n export const Layout\n export const Tabs\n export const Divider\n export const ModalDialog\n export const PageBlock\n}\n\n```"
}
] |
code_b2b-checkout-settings_c307db82
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/react/components/B2BCheckoutAdmin.tsx from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React, { useState, useEffect } from 'react'\nimport { useQuery, useMutation } from 'react-apollo'\nimport { useIntl, FormattedMessage } from 'react-intl'\nimport {\n Layout,\n PageHeader,\n PageBlock,\n Button,\n ToastConsumer,\n ToastProvider,\n Toggle,\n} from 'vtex.styleguide'\n\nimport APP_SETTINGS from '../graphql/appSettings.graphql'\nimport SAVE_APP_SETTINGS from '../graphql/saveAppSettings.graphql'\n\nconst AppSettings: FC = () => {\n const { formatMessage } = useIntl()\n\n const [settingsState, setSettingsState] = useState({\n showPONumber: false,\n hasPONumber: false,\n showQuoteButton: false,\n })\n\n const [settingsLoading, setSettingsLoading] = useState(false)\n\n const { data } = useQuery(APP_SETTINGS, {\n ssr: false,\n })\n\n const [saveSettings] = useMutation(SAVE_APP_SETTINGS)\n\n useEffect(() => {\n if (!data?.appSettings) return\n\n setSettingsState(data.appSettings)\n }, [data])\n\n const handleSaveSettings = async (showToast: any) => {\n setSettingsLoading(true)\n\n await saveSettings({\n variables: {\n settings: settingsState,\n },\n })\n .then(() => {\n showToast({\n message: formatMessage({\n id: 'admin/b2bCheckoutSettings.saveSettings.success',\n }),\n duration: 5000,\n })\n setSettingsLoading(false)\n })\n .catch((err) => {\n console.error(err)\n showToast({\n message: formatMessage({\n id: 'admin/b2bCheckoutSettings.saveSettings.failure',\n }),\n duration: 5000,\n })\n setSettingsLoading(false)\n })\n }\n\n return (\n <ToastProvider positioning=\"window\">\n <ToastConsumer>\n {({ showToast }: { showToast: any }) => (\n <Layout\n pageHeader={\n <PageHeader\n title={\n <FormattedMessage id=\"admin/b2bCheckoutSettings.settings.title\" />\n }\n />\n }\n >\n <PageBlock>\n <section className=\"pv4\">\n <Toggle\n semantic\n label={formatMessage({\n id: 'admin/b2bCheckoutSettings.settings.showPONumber.label',\n })}\n size=\"large\"\n checked={settingsState.showPONumber}\n onChange={() => {\n setSettingsState({\n ...settingsState,\n showPONumber: !settingsState.showPONumber,\n })\n }}\n helpText={formatMessage({\n id: 'admin/b2bCheckoutSettings.settings.showPONumber.helpText',\n })}\n />\n </section>\n <section className=\"pv4\">\n <Toggle\n semantic\n label={formatMessage({\n id: 'admin/b2bCheckoutSettings.settings.showQuoteButton.label',\n })}\n size=\"large\"\n checked={settingsState.showQuoteButton}\n onChange={() => {\n setSettingsState({\n ...settingsState,\n showQuoteButton: !settingsState.showQuoteButton,\n })\n }}\n helpText={formatMessage({\n id: 'admin/b2bCheckoutSettings.settings.showQuoteButton.helpText',\n })}\n />\n </section>\n <section className=\"pt4\">\n <Button\n variation=\"primary\"\n onClick={() => handleSaveSettings(showToast)}\n isLoading={settingsLoading}\n >\n {formatMessage({\n id: 'admin/b2bCheckoutSettings.saveSettings.buttonText',\n })}\n </Button>\n </section>\n </PageBlock>\n </Layout>\n )}\n </ToastConsumer>\n </ToastProvider>\n )\n}\n\nexport default AppSettings\n\n```"
}
] |
code_b2b-checkout-settings_9225797d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/react/graphql/saveAppSettings.graphql from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation SaveAppSettings($settings: SettingsInput!) {\n saveAppSettings(settings: $settings)\n @context(provider: \"vtex.b2b-checkout-settings\") {\n showPONumber\n hasPONumber\n showQuoteButton\n }\n}\n\n```"
}
] |
code_b2b-checkout-settings_6f059c8d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-checkout-settings/react/graphql/appSettings.graphql from the b2b-checkout-settings VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery AppSettings {\n appSettings @context(provider: \"vtex.b2b-checkout-settings\") {\n showPONumber\n hasPONumber\n showQuoteButton\n }\n}\n\n```"
}
] |
code_store-resources_930839d6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-resources/docs/README.md from the store-resources VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# store-resources\n\n> Common Store Resources\n\n\n**Upcoming documentation:**\n\n - [Added InstallmentCriteria variable](https://github.com/vtex-apps/store-resources/pull/104)\n```"
}
] |
code_store-resources_4f13653e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-resources/react/Mutations.js from the store-resources VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/** DEPRECATED, being kept just for retrocompatibility.\n * Create individual entry points for each mutation instead */\n\nimport addToCart from './mutations/addToCart.gql'\nimport updateItems from './mutations/updateItems.gql'\nimport updateOrderFormProfile from './mutations/updateOrderFormProfile.gql'\nimport updateOrderFormShipping from './mutations/updateOrderFormShipping.gql'\nimport updateOrderFormCheckin from './mutations/updateOrderFormCheckin.gql'\n\nexport default {\n addToCart,\n updateItems,\n updateOrderFormProfile,\n updateOrderFormShipping,\n updateOrderFormCheckin,\n}\n\n```"
}
] |
code_store-resources_98919220
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-resources/react/OrderFormContext.js from the store-resources VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { Component, useContext } from 'react'\nimport hoistNonReactStatics from 'hoist-non-react-statics'\nimport PropTypes from 'prop-types'\n\nconst OrderFormContext = React.createContext({})\nconst { Provider } = OrderFormContext\n\nfunction orderFormConsumer(WrappedComponent) {\n const WithOrderForm = props => {\n const { orderFormContext } = useContext(OrderFormContext)\n\n return <WrappedComponent {...props} orderFormContext={orderFormContext} />\n }\n\n WithOrderForm.displayName = `OrderFormContext(${\n Component.displayName || Component.name || 'Component'\n })`\n WithOrderForm.WrappedComponent = WrappedComponent\n\n return hoistNonReactStatics(WithOrderForm, WrappedComponent)\n}\n\nconst useOrderForm = () => {\n const context = useContext(OrderFormContext)\n\n return context.orderFormContext\n}\n\nconst contextPropTypes = PropTypes.shape({\n /* Toast message that will be displayed */\n\n message: PropTypes.shape({\n isSuccess: PropTypes.bool,\n message: PropTypes.string,\n }).isRequired,\n /* Is information still loading */\n\n loading: PropTypes.bool.isRequired,\n /* Function to refetch the orderForm query */\n\n refetch: PropTypes.func.isRequired,\n /* Function to add a new item into the orderForm */\n\n addItem: PropTypes.func.isRequired,\n /* Function to update the orderForm */\n\n updateOrderForm: PropTypes.func.isRequired,\n /* Function to update the orderForm profile data */\n\n updateOrderFormProfile: PropTypes.func.isRequired,\n /* Function to update the orderForm and refetch the data */\n\n updateAndRefetchOrderForm: PropTypes.func.isRequired,\n /* Function to update the message */\n\n updateToastMessage: PropTypes.func.isRequired,\n /* Function to update the shipping data */\n\n updateOrderFormShipping: PropTypes.func.isRequired,\n /* Order form */\n\n orderForm: PropTypes.shape({\n /* Order form id */\n\n orderFormId: PropTypes.string,\n /* Total price of the order */\n\n value: PropTypes.number,\n /* Items in the mini cart */\n\n items: PropTypes.arrayOf(PropTypes.object),\n /* CustomData in the OrderForm */\n\n customData: PropTypes.shape({\n customApps: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.string,\n fields: PropTypes.object,\n })\n ),\n }),\n /* Shipping Address */\n\n shippingData: PropTypes.shape({\n address: PropTypes.shape({\n addressName: PropTypes.string,\n addressType: PropTypes.string,\n city: PropTypes.string,\n complement: PropTypes.string,\n country: PropTypes.string,\n id: PropTypes.string,\n neighborhood: PropTypes.string,\n number: PropTypes.string,\n postalCode: PropTypes.string,\n receiverName: PropTypes.string,\n reference: PropTypes.string,\n state: PropTypes.string,\n street: PropTypes.string,\n userId: PropTypes.string,\n }),\n /* Available Addresses */\n\n availableAddresses: PropTypes.arrayOf(PropTypes.object),\n }),\n }),\n}).isRequired\n\nexport default {\n orderFormConsumer,\n contextPropTypes,\n Provider,\n useOrderForm,\n}\n\n```"
}
] |
code_store-resources_e0591d11
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-resources/react/useQueryProducts.tsx from the store-resources VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport type { QueryHookOptions } from 'react-apollo'\nimport { useQuery } from 'react-apollo'\n\nimport type { Data, Variables } from './QueryProductsTypes'\nimport products from './queries/products.gql'\n\nexport default function useQueryProducts(\n options: QueryHookOptions<Data, Variables>\n) {\n return useQuery<Data, Variables>(products, options)\n}\n\n```"
}
] |
code_store-resources_8b273c55
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-resources/react/QueryRecommendationsAndBenefits.js from the store-resources VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport recommendationsAndBenefits from './queries/recommendationsAndBenefits.gql'\n\nexport default recommendationsAndBenefits\n\n```"
}
] |
code_store-resources_a2ae34dd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-resources/react/QueryAddress.js from the store-resources VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport address from './queries/address.gql'\n\nexport default address\n\n```"
}
] |
code_store-resources_6e491b8d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-resources/react/QuerySuggestionProducts.js from the store-resources VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport productSuggestions from './queries/productSuggestions.gql'\n\nexport default productSuggestions\n\n```"
}
] |
code_store-resources_1267424e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-resources/react/MutationUpdateOrderFormCheckin.js from the store-resources VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport updateOrderFormCheckin from './mutations/updateOrderFormCheckin.gql'\n\nexport default updateOrderFormCheckin\n\n```"
}
] |
code_store-resources_4f15a607
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-resources/react/QuerySponsoredProducts.js from the store-resources VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport QuerySponsoredProducts from './queries/sponsoredProducts.gql'\n\nexport default QuerySponsoredProducts\n\n```"
}
] |
code_store-resources_9abac4ee
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-resources/react/QuerySession.js from the store-resources VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport session from './queries/session.gql'\n\nexport default session\n\n```"
}
] |
code_store-resources_45ae5987
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-resources/react/QueryBanners.js from the store-resources VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport banners from './queries/banners.gql'\n\nexport default banners\n\n```"
}
] |
code_store-resources_e3e26ee0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-resources/react/QueryProductSearchV2.js from the store-resources VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport productSearchV2 from './queries/productSearchV2.gql'\n\nexport default productSearchV2\n\n```"
}
] |
code_store-resources_589297bd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-resources/react/MutationAddToCart.js from the store-resources VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport addToCart from './mutations/addToCart.gql'\n\nexport default addToCart\n\n```"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.