id
stringlengths 12
53
| messages
listlengths 3
3
|
|---|---|
code_order-form-courier_4b91c878
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-form-courier/react/typings/global.d.ts from the order-form-courier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { OrderForm } from '@vtex/clients'\n\ndeclare global {\n interface Window extends Window {\n vtexjs: {\n checkout: {\n orderForm: OrderForm\n }\n }\n }\n}\n\n```"
}
] |
code_order-form-courier_1e3edc98
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-form-courier/react/typings/css.d.ts from the order-form-courier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n type Styles = {\n [selector: string]: string\n }\n\n const styles: Styles\n\n export default styles\n}\n\n```"
}
] |
code_order-form-courier_fcc62edf
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of order-form-courier/react/hooks/useOrderFormMonitor.tsx from the order-form-courier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport type { OrderForm } from '@vtex/clients'\nimport { useCallback, useState } from 'react'\n\nimport type { OrderFormEventHandler } from '../typings/orderFormEvent'\n\nexport const useOrderFormMonitor = (handlers: OrderFormEventHandler[]) => {\n const [orderForm, setOrderForm] = useState<OrderForm>(\n // This is used to clone the orderForm state and prevent referencing it directly.\n JSON.parse(JSON.stringify(window?.vtexjs.checkout.orderForm))\n )\n\n const handleOrderFormChange = useCallback(\n (eventOrderForm: OrderForm) => {\n const changes = handlers.map((handler) =>\n handler(orderForm, eventOrderForm)\n )\n\n setOrderForm(JSON.parse(JSON.stringify(eventOrderForm)))\n\n return changes\n },\n [orderForm]\n )\n\n return handleOrderFormChange\n}\n\n```"
}
] |
code_auth-challenge_8f71b567
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of auth-challenge/messages/pt.json from the auth-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/test\": \"teste\",\n \"store/test\": \"teste\"\n}\n```"
}
] |
code_auth-challenge_d8b6b8fa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of auth-challenge/messages/en.json from the auth-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/test\": \"test\",\n \"store/test\": \"test\"\n}\n\n```"
}
] |
code_auth-challenge_85279e9d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of auth-challenge/messages/es.json from the auth-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/test\": \"teste\",\n \"store/test\": \"teste\"\n}\n```"
}
] |
code_auth-challenge_2cfdc5f2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of auth-challenge/docs/README.md from the auth-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/vtex-apps/auth-challenge) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# Auth Challenge\n\n<!-- DOCS-IGNORE:start -->\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n<!-- DOCS-IGNORE:end -->\n\nThe Auth Challenge app is an essential B2B feature responsible for checking if a user is allowed to access the store's content. It helps define which components should be displayed for users that are allowed and users that are not.\n\n## Example Use Case\n\nAdd a condition to a TP that applies to your user. As an anonymous user, you should not see the real content. When you log in, and if and only if the condition you added above matches your profile, you should see the real content.\n\nNow remove the condition from the TP that applies to your user. Now as an anonymous user, you should not see the real content. When you login, you should see the real content.\n\n:information_source: This check is made according to the Condition Rule specified in the Trade Policy configuration, one of the steps needed to [**configure a B2B environment in VTEX IO**](https://vtex.io/docs/recipes/store/configuring-a-b2b-environment).\n\n\n*In the example above, the `Become a parter` link in the Header is only displayed for anonymous users. Once the user is authenticated (second image), he become able to see the `Quick Order` and the `Order quote` links.*\n\n## Configuration\n\n1. Add `auth-challenge` app to your theme's dependencies in the `manifest.json`, for example:\n\n```diff\n \"dependencies\": {\n+ \"vtex.auth-challenge\": \"1.x\"\n }\n```\n\nNow, you are able to use all blocks exported by the `auth-challenge` app. Check out the full list below:\n\n| Block name | Description |\n| -------------- | ----------------------------------------------- |\n| `challenge-block` | Logical block responsible for checking whether an user is authenticated or not. It does not render any component, but mandatorily defines as children the `challenge-content` and the `challenge-fallback` blocks. |\n| `challenge-content` | Defines (via its children blocks) which components will be displayed in the UI for authenticated users. | \n| `challenge-fallback` | Defines (via its children blocks) which components will be displayed for anonymous users. |\n\n2. In the desired store template, such as `store.product`, declare the `challenge-block`, listing the `challenge-content` and the `challenge-fallback` as its children. For example:\n\n```diff\n \"store.product\": {\n \"blocks\": [\n \"flex-layout.row#product-main\",\n+ \"challenge-block#description\",\n \"shelf.relatedProducts#accessories\"\n ],\n },\n+\"challenge-block#description\": {\n+ \"blocks\": [\n+ \"challenge-content#description\",\n+ \"challenge-fallback#description\"\n+ ]\n+},\n```\n\n3. Now, declare the children blocks `challenge-content` and `challenge-fallback`. Remember that they define, respectively, which components will be displayed for authenticated and anonymous users;\n\n```diff\n \"store.product\": {\n \"blocks\": [\n \"flex-layout.row#product-main\",\n \"challenge-block#description\",\n \"shelf.relatedProducts#accessories\"\n ],\n },\n \"challenge-block#description\": {\n \"blocks\": [\n \"challenge-content#description\",\n \"challenge-fallback#description\"\n ]\n },\n+ \"challenge-content#description\": {\n+ \"children\": [\n+ \"product-description\"\n+ ]\n+ },\n+ \"challenge-fallback#description\": {\n+ \"children\": [\n+ \"rich-text#challenge-description\"\n+ ]\n+ },\n+ \"rich-text#challenge-description\": {\n+ \"props\": {\n+ \"text\": \"Please login to see the description\",\n+ \"blockClass\": \"challengeDescription\"\n+ }\n+ }\n```\n\nAccording to the example above, users that have the attached trade policy will see the component rendered by the `product-description` block. Others, in turn, will see a Rich Text component (`challenge-fallback`'s child block).\n\n## Customization\n\nIn order to apply CSS customizations in this and other blocks, follow the instructions given in the recipe on [Using CSS Handles for store customization](https://vtex.io/docs/recipes/style/using-css-handles-for-store-customization).\n\n\n| CSS Handles | \n| ------------------------ | \n| `challengeContentWrapper` | \n\n\n<!-- DOCS-IGNORE:start -->\n\n## Contributors ✨\n\nThanks goes to these wonderful people:\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!\n\n<!-- DOCS-IGNORE:end -->\n\n\n```"
}
] |
code_auth-challenge_ca5189ec
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of auth-challenge/react/BlockChallenge.tsx from the auth-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport {\n ExtensionPoint,\n Session,\n SessionResponse,\n SessionUnauthorized,\n SessionForbidden,\n} from 'vtex.render-runtime'\n\nimport useSessionResponse from './hooks/useSessionResponse'\n\nconst isSessionUnauthorized = (\n session: SessionResponse | undefined\n): session is SessionUnauthorized =>\n (session as SessionUnauthorized)?.type?.toLowerCase() === 'unauthorized'\n\nconst isSessionForbidden = (\n session: SessionResponse | undefined\n): session is SessionForbidden =>\n (session as SessionForbidden)?.type?.toLowerCase() === 'forbidden'\n\nconst isProfileAllowed = (sessionResponse: SessionResponse | undefined) => {\n if (sessionResponse == null) {\n return null\n }\n\n const hasAccessToTradePolicy = (sessionResponse as Session).namespaces?.store\n ?.channel\n\n const isLoggedIn = (sessionResponse as Session).namespaces?.profile?.email\n\n if (isLoggedIn && hasAccessToTradePolicy) {\n return 'authorized'\n }\n\n if (isLoggedIn) {\n return 'forbidden'\n }\n\n return 'unauthorized'\n}\n\nconst BlockChallenge = () => {\n const sessionResponse = useSessionResponse()\n\n const isUnauthorized = isSessionUnauthorized(sessionResponse)\n const isForbidden = isSessionForbidden(sessionResponse)\n const profileCondition = isProfileAllowed(sessionResponse)\n\n if (!sessionResponse) {\n return null\n }\n\n const defaultHidden = sessionResponse == null\n\n if (\n defaultHidden ||\n isUnauthorized === true ||\n isForbidden === true ||\n profileCondition === 'unauthorized' ||\n profileCondition === 'forbidden'\n ) {\n return <ExtensionPoint id=\"challenge-fallback\" />\n }\n\n return <ExtensionPoint id=\"challenge-content\" />\n}\n\nexport default BlockChallenge\n\n```"
}
] |
code_auth-challenge_7c17e966
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of auth-challenge/react/BlockContent.tsx from the auth-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\n\nconst CSS_HANDLES = ['challengeContentWrapper'] as const\n\nconst BlockContent: FC<ChallengeProps> = ({ children }: ChallengeProps) => {\n const handles = useCssHandles(CSS_HANDLES)\n\n return (\n <div className={`mw9 center ${handles.challengeContentWrapper}`}>\n {children}\n </div>\n )\n}\n\nexport default BlockContent\n\n```"
}
] |
code_auth-challenge_767a77c2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of auth-challenge/react/package.json from the auth-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"lint\": \"tsc --noEmit && eslint --quiet --fix --ext ts,tsx .\",\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"apollo-client\": \"^2.6.3\",\n \"graphql\": \"^14.5.8\",\n \"ramda\": \"^0.26.1\",\n \"react\": \"^16.8.6\",\n \"react-apollo\": \"^3.1.3\",\n \"react-dom\": \"^16.8.6\",\n \"react-intl\": \"^2.9.0\"\n },\n \"devDependencies\": {\n \"@types/graphql\": \"^14.5.0\",\n \"@types/jest\": \"^24.0.21\",\n \"@types/node\": \"^12.12.3\",\n \"@types/ramda\": \"^0.26.33\",\n \"@types/react\": \"^16.8.22\",\n \"@types/react-intl\": \"^2.3.18\",\n \"@vtex/prettier-config\": \"^0.3.1\",\n \"@vtex/test-tools\": \"^0.3.2\",\n \"@vtex/tsconfig\": \"^0.2.0\",\n \"eslint\": \"^7.6.0\",\n \"eslint-config-vtex-react\": \"^6.7.3\",\n \"prettier\": \"^2.0.5\",\n \"prop-types\": \"^15.7.2\",\n \"typescript\": \"3.8.3\"\n },\n \"version\": \"1.1.1\"\n}\n\n```"
}
] |
code_auth-challenge_f7604e7f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of auth-challenge/store/interfaces.json from the auth-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"challenge-block\": {\n \"component\": \"BlockChallenge\",\n \"allowed\": [\"challenge-content\", \"challenge-fallback\"]\n },\n \"challenge-content\": {\n \"component\": \"BlockContent\",\n \"composition\": \"children\",\n \"allowed\": \"*\"\n },\n \"challenge-fallback\": {\n \"component\": \"BlockContent\",\n \"composition\": \"children\",\n \"allowed\": \"*\"\n }\n}\n\n```"
}
] |
code_auth-challenge_72eb2038
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of auth-challenge/react/typings/globals.d.ts from the auth-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { ReactNode } from 'react'\n\ndeclare global {\n interface ChallengeProps {\n children: ReactNode[]\n }\n}\n\n```"
}
] |
code_auth-challenge_ee7c465e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of auth-challenge/react/typings/vtex.render-runtime.d.ts from the auth-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/ban-types */\n/* Typings for `render-runtime` */\ndeclare module 'vtex.render-runtime' {\n import { Component, ComponentType, ReactElement, ReactType } from 'react'\n\n export interface NavigationOptions {\n page: string\n params?: any\n }\n\n export interface RenderContextProps {\n runtime: {\n navigate: (options: NavigationOptions) => void\n }\n }\n\n interface ExtensionPointProps {\n id: string\n [key: string]: any\n }\n\n interface ChildBlock<BlockProps> {\n props: BlockProps\n }\n\n export const ExtensionPoint: ComponentType<ExtensionPointProps>\n export const useChildBlock: <BlockProps>({\n id,\n }: {\n id: string\n }) => ChildBlock<BlockProps> | null\n export const Helmet: ReactElement\n export const Link: ReactType\n export const NoSSR: ReactElement\n export const RenderContextConsumer: any\n export const TreePathContextConsumer: any\n export const useTreePath: any\n export const useRuntime: any\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 interface KeyValue {\n value: string\n }\n\n interface Session {\n id: string\n namespaces: {\n store: {\n channel: string\n }\n profile: {\n isAuthenticated: KeyValue\n email: string\n }\n }\n }\n\n interface SessionUnauthorized {\n type: 'Unauthorized'\n message: string\n }\n\n interface SessionForbidden {\n type: 'Forbidden'\n message: string\n }\n\n export interface RenderSession {\n sessionPromise: Promise<SessionPromise>\n }\n\n export interface SessionPromise {\n response: Session | SessionUnauthorized | SessionForbidden\n }\n\n export type SessionResponse = Session | SessionUnauthorized | SessionForbidden\n}\n\n```"
}
] |
code_auth-challenge_c47ccf69
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of auth-challenge/react/typings/graphql.d.ts from the auth-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.graphql' {\n import { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\n```"
}
] |
code_auth-challenge_d89e457c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of auth-challenge/react/__tests__/index.test.tsx from the auth-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\ndescribe('Product description scenario', () => {\n it('should work', () => {\n expect(1).toBe(1)\n })\n})\n\n```"
}
] |
code_auth-challenge_668aa012
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of auth-challenge/react/hooks/useSessionResponse.tsx from the auth-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { useEffect, useState } from 'react'\nimport { SessionResponse } from 'vtex.render-runtime'\n\nimport { getSession } from '../modules/session'\n\nconst useSessionResponse = () => {\n const [session, setSession] = useState<SessionResponse>()\n const sessionPromise = getSession()\n\n useEffect(() => {\n if (!sessionPromise) {\n return\n }\n\n sessionPromise.then((sessionResponse) => {\n const response = sessionResponse.response as SessionResponse\n\n setSession(response)\n })\n }, [sessionPromise])\n\n return session\n}\n\nexport default useSessionResponse\n\n```"
}
] |
code_auth-challenge_8c5ce427
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of auth-challenge/react/modules/session.ts from the auth-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { SessionPromise } from 'vtex.render-runtime'\n\nexport function getSession() {\n return window &&\n (window as any).__RENDER_8_SESSION__ &&\n (window as any).__RENDER_8_SESSION__.sessionPromise\n ? ((window as any).__RENDER_8_SESSION__.sessionPromise as Promise<\n SessionPromise\n >)\n : null\n}\n\n```"
}
] |
code_b2b-login-challenge_d14581f4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-login-challenge/messages/pt.json from the b2b-login-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/test\": \"teste\",\n \"store/test\": \"teste\"\n}\n```"
}
] |
code_b2b-login-challenge_b2e1b198
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-login-challenge/messages/en.json from the b2b-login-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/test\": \"test\",\n \"store/test\": \"test\"\n}\n\n```"
}
] |
code_b2b-login-challenge_9c3e23d8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-login-challenge/messages/es.json from the b2b-login-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/test\": \"teste\",\n \"store/test\": \"teste\"\n}\n```"
}
] |
code_b2b-login-challenge_7819cc73
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-login-challenge/docs/README.md from the b2b-login-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/{OrganizationName}/{AppName}) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# APP NAME\n\n<!-- DOCS-IGNORE:start -->\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n<!-- DOCS-IGNORE:end -->\n\nUnder the app's name, you should explain the topic, giving a **brief description** of its **functionality** in a store when installed.\n\nNext, **add media** (either an image of a GIF) with the rendered components, so that users can better understand how the app works in practice. \n\n\n\n## Configuration \n\nIn this section, you first must **add the primary instructions** that will allow users to use the app's blocks in their store, such as:\n\n1. Adding the app as a theme dependency in the `manifest.json` file;\n2. Declaring the app's main block in a given theme template or inside another block from the theme.\n\nRemember to add a table with all blocks exported by the app and their descriptions. You can verify an example of it on the [Search Result documentation](https://vtex.io/docs/components/all/vtex.search-result@3.56.1/). \n\nNext, add the **props table** containing your block's props. \n\nIf the app exports more than one block, create several tables - one for each block. For example:\n\n### `block-1` props\n\n| Prop name | Type | Description | Default value |\n| ------------ | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | \n| `XXXXX` | `XXXXXX` | XXXXXXXX | `XXXXXX` |\n\n\n### `block-2` props\n\n| Prop name | Type | Description | Default value |\n| ------------ | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | \n| `XXXXX` | `XXXXXX` | XXXXXXXX | `XXXXXX` |\n\nProp types are: \n\n- `string` \n- `enum` \n- `number` \n- `boolean` \n- `object` \n- `array` \n\nWhen documenting a prop whose type is `object` or `array` another prop table will be needed. You can create it following the example below:\n\n- `propName` object:\n\n| Prop name | Type | Description | Default value |\n| ------------ | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | \n| `XXXXX` | `XXXXXX` | XXXXXXXX | `XXXXXX` |\n\n\nRemember to also use this Configuration section to **showcase any necessary disclaimer** related to the app and its blocks, such as the different behavior it may display during its configuration. \n\n## Modus Operandi *(not mandatory)*\n\nThere are scenarios in which an app can behave differently in a store, according to how it was added to the catalog, for example. It's crucial to go through these **behavioral changes** in this section, allowing users to fully understand the **practical application** of the app in their store.\n\nIf you feel compelled to give further details about the app, such as it's **relationship with the VTEX admin**, don't hesitate to use this section. \n\n## Customization\n\nThe first thing that should be present in this section is the sentence below, showing users the recipe pertaining to CSS customization in apps:\n\n`In 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\nThereafter, you should add a single column table with the available CSS handles for the app, like the one below. Note that the Handles must be ordered alphabetically.\n\n| CSS Handles |\n| ----------- | \n| `XXXXX` | \n| `XXXXX` | \n| `XXXXX` | \n| `XXXXX` | \n| `XXXXX` |\n\n\nIf there are none, add the following sentence instead:\n\n`No CSS Handles are available yet for the app customization.`\n\n<!-- DOCS-IGNORE:start -->\n\n## Contributors ✨\n\nThanks goes to these wonderful people:\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!\n\n<!-- DOCS-IGNORE:end -->\n\n---- \n\nCheck out some documentation models that are already live: \n- [Breadcrumb](https://github.com/vtex-apps/breadcrumb)\n- [Image](https://vtex.io/docs/components/general/vtex.store-components/image)\n- [Condition Layout](https://vtex.io/docs/components/all/vtex.condition-layout@1.1.6/)\n- [Add To Cart Button](https://vtex.io/docs/components/content-blocks/vtex.add-to-cart-button@0.9.0/)\n- [Store Form](https://vtex.io/docs/components/all/vtex.store-form@0.3.4/)\n\n```"
}
] |
code_b2b-login-challenge_4e09cd0e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-login-challenge/react/ChallengeLoginCondition.tsx from the b2b-login-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, {\n FC,\n Fragment,\n useEffect,\n useState\n} from 'react'\nimport {\n useRuntime,\n canUseDOM,\n SessionUnauthorized,\n Session,\n SessionForbidden,\n} from 'vtex.render-runtime'\n\nimport { getSession } from './modules/session'\n\ntype ContentVisibility = 'visible' | 'hidden'\n\nconst useRedirect = (condition: boolean, path: string) => {\n const { navigate } = useRuntime()\n\n useEffect(() => {\n if (!condition) {\n return\n }\n\n const url = canUseDOM\n ? window.location.pathname + window.location.hash\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (global as any).__pathname__\n\n navigate({\n to: `${path}?returnUrl=${encodeURIComponent(url)}`,\n })\n }, [condition, navigate, path])\n}\n\ntype SessionResponse = Session | SessionUnauthorized | SessionForbidden\n\nconst useSessionResponse = () => {\n const [session, setSession] = useState<SessionResponse>()\n const sessionPromise = getSession()\n\n useEffect(() => {\n if (!sessionPromise) {\n return\n }\n\n sessionPromise.then(sessionResponse => {\n const response = sessionResponse.response as SessionResponse\n\n setSession(response)\n })\n }, [sessionPromise])\n\n return session\n}\n\nconst isSessionUnauthorized = (\n session: SessionResponse | undefined\n): session is SessionUnauthorized =>\n (session as SessionUnauthorized)?.type?.toLowerCase() === 'unauthorized'\n\nconst isSessionForbidden = (\n session: SessionResponse | undefined\n): session is SessionForbidden =>\n (session as SessionForbidden)?.type?.toLowerCase() === 'forbidden'\n\ninterface Props {\n redirectPath: string\n forbiddenRedirectPath: string\n defaultContentVisibility: ContentVisibility\n}\n\nconst isProfileAllowed = (sessionResponse: SessionResponse | undefined) => {\n if (sessionResponse == null) {\n return null\n }\n\n const hasAccessToTradePolicy = (sessionResponse as Session).namespaces?.store\n ?.channel\n\n // const channelFromUser = item.response.namespaces.store.channel.value\n // const pattern = /:\\s|,\\s/\n // const tradePolicyValue = challengeTradePolicy.split(pattern)\n // const result = tradePolicyValue.includes(String(channelFromUser))\n\n\n const isLoggedIn = (sessionResponse as Session).namespaces?.profile?.email\n\n if (hasAccessToTradePolicy) {\n return 'authorized'\n }\n if (isLoggedIn) {\n return 'forbidden'\n }\n return 'unauthorized'\n}\n\nconst ChallengeLoginCondition: FC<Props> = ({\n redirectPath = '/login',\n forbiddenRedirectPath = redirectPath,\n defaultContentVisibility = 'visible',\n children,\n}) => {\n\n console.log(\"---------- CHAMOU O CHALLENGE LOGIN CONDITION\")\n\n const sessionResponse = useSessionResponse()\n const isUnauthorized = isSessionUnauthorized(sessionResponse)\n const isForbidden = isSessionForbidden(sessionResponse)\n const profileCondition = isProfileAllowed(sessionResponse)\n\n useRedirect(\n isUnauthorized === true || profileCondition === 'unauthorized',\n redirectPath\n )\n useRedirect(\n isForbidden === true || profileCondition === 'forbidden',\n forbiddenRedirectPath\n )\n\n const defaultHidden =\n defaultContentVisibility === 'hidden' && sessionResponse == null\n\n if (\n defaultHidden ||\n isUnauthorized === true ||\n isForbidden === true ||\n profileCondition === 'unauthorized' ||\n profileCondition === 'forbidden'\n ) {\n return null\n }\n\n\n\n return <Fragment>{children}</Fragment>\n}\n\nexport default React.memo(ChallengeLoginCondition)\n```"
}
] |
code_b2b-login-challenge_722ef56e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-login-challenge/react/package.json from the b2b-login-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"b2b-login-challenge\",\n \"version\": \"0.1.0\",\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"apollo-client\": \"^2.6.8\",\n \"react\": \"^16.12.0\",\n \"react-apollo\": \"^3.1.3\",\n \"react-dom\": \"^16.12.0\",\n \"react-intl\": \"^3.12.0\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^3.1.3\",\n \"@types/jest\": \"^25.1.4\",\n \"@types/node\": \"^13.9.8\",\n \"@types/react\": \"^16.9.31\",\n \"@vtex/test-tools\": \"^3.3.2\",\n \"@vtex/tsconfig\": \"^0.4.4\",\n \"apollo-cache-inmemory\": \"^1.6.5\",\n \"graphql\": \"^14.6.0\",\n \"typescript\": \"3.9.7\"\n }\n}\n\n```"
}
] |
code_b2b-login-challenge_aeb98ad3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-login-challenge/store/interfaces.json from the b2b-login-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"challenge.login-condition\": {\n \"component\": \"ChallengeLoginCondition\"\n }\n}\n\n```"
}
] |
code_b2b-login-challenge_d9d144e7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-login-challenge/react/typings/globals.d.ts from the b2b-login-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { ReactNode } from 'react'\n\ndeclare global {\n interface ChallengeProps {\n children: ReactNode[]\n }\n}\n\n```"
}
] |
code_b2b-login-challenge_1320baf6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-login-challenge/react/typings/vtex.render-runtime.d.ts from the b2b-login-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/ban-types */\n/* Typings for `render-runtime` */\ndeclare module 'vtex.render-runtime' {\n import { Component, ComponentType, ReactElement, ReactType } from 'react'\n\n export interface NavigationOptions {\n page: string\n params?: any\n }\n\n export interface RenderContextProps {\n runtime: {\n navigate: (options: NavigationOptions) => void\n }\n }\n\n interface ExtensionPointProps {\n id: string\n [key: string]: any\n }\n\n interface ChildBlock<BlockProps> {\n props: BlockProps\n }\n\n export const ExtensionPoint: ComponentType<ExtensionPointProps>\n export const useChildBlock: <BlockProps>({\n id,\n }: {\n id: string\n }) => ChildBlock<BlockProps> | null\n export const Helmet: ReactElement\n export const Link: ReactType\n export const NoSSR: ReactElement\n export const RenderContextConsumer: any\n export const TreePathContextConsumer: any\n export const useTreePath: any\n export const useRuntime: any\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 interface KeyValue {\n value: string\n }\n\n interface Session {\n id: string\n namespaces: {\n store: {\n channel: string\n }\n profile: {\n isAuthenticated: KeyValue\n email: string\n }\n }\n }\n\n interface SessionUnauthorized {\n type: 'Unauthorized'\n message: string\n }\n\n interface SessionForbidden {\n type: 'Forbidden'\n message: string\n }\n\n export interface RenderSession {\n sessionPromise: Promise<SessionPromise>\n }\n\n export interface SessionPromise {\n response: Session | SessionUnauthorized | SessionForbidden\n }\n\n export type SessionResponse = Session | SessionUnauthorized | SessionForbidden\n}\n\n```"
}
] |
code_b2b-login-challenge_dbc6b599
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-login-challenge/react/typings/gql.d.ts from the b2b-login-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { DocumentNode } from 'graphql'\n\ndeclare module '*.gql' {\n const Schema: DocumentNode\n export = Schema\n}\n\ndeclare module '*.graphql' {\n const Schema: DocumentNode\n export = Schema\n}\n\n```"
}
] |
code_b2b-login-challenge_4ed1a7ec
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-login-challenge/react/typings/css.d.ts from the b2b-login-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n type Styles = {\n [selector: string]: string\n }\n\n export default Styles\n}\n\n```"
}
] |
code_b2b-login-challenge_fac07e0e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-login-challenge/react/hooks/useSessionResponse.tsx from the b2b-login-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { useEffect, useState } from 'react'\nimport { SessionResponse } from 'vtex.render-runtime'\n\nimport { getSession } from '../modules/session'\n\nconst useSessionResponse = () => {\n const [session, setSession] = useState<SessionResponse>()\n const sessionPromise = getSession()\n\n useEffect(() => {\n if (!sessionPromise) {\n return\n }\n\n sessionPromise.then((sessionResponse) => {\n const response = sessionResponse.response as SessionResponse\n\n setSession(response)\n })\n }, [sessionPromise])\n\n return session\n}\n\nexport default useSessionResponse\n\n```"
}
] |
code_b2b-login-challenge_762f4fd1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-login-challenge/react/modules/session.ts from the b2b-login-challenge VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { SessionPromise } from 'vtex.render-runtime'\n\nexport function getSession() {\n return window &&\n (window as any).__RENDER_8_SESSION__ &&\n (window as any).__RENDER_8_SESSION__.sessionPromise\n ? ((window as any).__RENDER_8_SESSION__.sessionPromise as Promise<\n SessionPromise\n >)\n : null\n}\n\n```"
}
] |
code_category-menu_581a36be
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/messages/pt.json from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.category-menu.departments.items.id\": \"Id do Departamento\",\n \"admin/editor.category-menu.departments.items.title\": \"Departamento\",\n \"admin/editor.category-menu.description\": \"Um menu mostrando uma lista de categorias disponíveis na loja\",\n \"admin/editor.category-menu.disposition-type.center\": \"Centro\",\n \"admin/editor.category-menu.disposition-type.left\": \"Esquerda\",\n \"admin/editor.category-menu.disposition-type.right\": \"Direita\",\n \"admin/editor.category-menu.disposition-type.title\": \"Posição do menu\",\n \"admin/editor.category-menu.show-departments-category.title\": \"Mostrar a categoria de departamentos\",\n \"admin/editor.category-menu.show-subcategories.title\": \"Mostrar subcategorias\",\n \"admin/editor.category-menu.sort-subcategories.title\": \"Ordenar subcategorias\",\n \"admin/editor.category-menu.sort-type.default\": \"Padrão\",\n \"admin/editor.category-menu.sort-type.name\": \"Nome\",\n \"admin/editor.category-menu.title\": \"Menu de categorias\",\n \"store/category-menu.all-category.title\": \"Ver Todos\",\n \"store/category-menu.departments.title\": \"Departamentos\"\n}\n\n```"
}
] |
code_category-menu_abca431b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/messages/en.json from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.category-menu.departments.items.id\": \"Department Id\",\n \"admin/editor.category-menu.departments.items.title\": \"Department\",\n \"admin/editor.category-menu.description\": \"A menu showing a list of the available categories on the store\",\n \"admin/editor.category-menu.disposition-type.center\": \"Middle\",\n \"admin/editor.category-menu.disposition-type.left\": \"Left\",\n \"admin/editor.category-menu.disposition-type.right\": \"Right\",\n \"admin/editor.category-menu.disposition-type.title\": \"Menu position\",\n \"admin/editor.category-menu.show-departments-category.title\": \"Show the departments category\",\n \"admin/editor.category-menu.show-subcategories.title\": \"Show subcategories\",\n \"admin/editor.category-menu.sort-subcategories.title\": \"Sort subcategories\",\n \"admin/editor.category-menu.sort-type.default\": \"Default\",\n \"admin/editor.category-menu.sort-type.name\": \"Name\",\n \"admin/editor.category-menu.title\": \"Category menu\",\n \"store/category-menu.all-category.title\": \"See All\",\n \"store/category-menu.departments.title\": \"Departments\"\n}\n\n```"
}
] |
code_category-menu_a33cb9e5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/messages/context.json from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.category-menu.departments.items.id\": \"Department Id\",\n \"admin/editor.category-menu.departments.items.title\": \"Department\",\n \"admin/editor.category-menu.description\": \"A menu showing a list of the available categories on the store\",\n \"admin/editor.category-menu.disposition-type.center\": \"Middle\",\n \"admin/editor.category-menu.disposition-type.left\": \"Left\",\n \"admin/editor.category-menu.disposition-type.right\": \"Right\",\n \"admin/editor.category-menu.disposition-type.title\": \"Menu position\",\n \"admin/editor.category-menu.show-departments-category.title\": \"Show the departments category\",\n \"admin/editor.category-menu.show-subcategories.title\": \"Show subcategories\",\n \"admin/editor.category-menu.sort-subcategories.title\": \"Sort subcategories\",\n \"admin/editor.category-menu.sort-type.default\": \"Default\",\n \"admin/editor.category-menu.sort-type.name\": \"Name\",\n \"admin/editor.category-menu.title\": \"Category menu\",\n \"store/category-menu.all-category.title\": \"See All\",\n \"store/category-menu.departments.title\": \"Departments\"\n}\n\n```"
}
] |
code_category-menu_e8d72aa0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/messages/id.json from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.category-menu.departments.items.id\": \"Id Departemen\",\n \"admin/editor.category-menu.departments.items.title\": \"Departemen\",\n \"admin/editor.category-menu.description\": \"Menu yang menampilkan daftar kategori yang tersedia di toko\",\n \"admin/editor.category-menu.disposition-type.center\": \"Tengah\",\n \"admin/editor.category-menu.disposition-type.left\": \"Kiri\",\n \"admin/editor.category-menu.disposition-type.right\": \"Kanan\",\n \"admin/editor.category-menu.disposition-type.title\": \"Posisi menu\",\n \"admin/editor.category-menu.show-departments-category.title\": \"Tampilkan kategori departemen\",\n \"admin/editor.category-menu.show-subcategories.title\": \"Tampilkan subkategori\",\n \"admin/editor.category-menu.sort-subcategories.title\": \"Urutkan subkategori\",\n \"admin/editor.category-menu.sort-type.default\": \"Default\",\n \"admin/editor.category-menu.sort-type.name\": \"Nama\",\n \"admin/editor.category-menu.title\": \"Menu kategori\",\n \"store/category-menu.all-category.title\": \"Lihat Semua\",\n \"store/category-menu.departments.title\": \"Departemen\"\n}\n\n```"
}
] |
code_category-menu_2f0b1f2c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/messages/th.json from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.category-menu.departments.items.id\": \"รหัสแผนก\",\n \"admin/editor.category-menu.departments.items.title\": \"แผนก\",\n \"admin/editor.category-menu.description\": \"เมนูแสดงรายการหมวดหมู่ที่มีในร้านค้า\",\n \"admin/editor.category-menu.disposition-type.center\": \"กลาง\",\n \"admin/editor.category-menu.disposition-type.left\": \"ซ้าย\",\n \"admin/editor.category-menu.disposition-type.right\": \"ขวา\",\n \"admin/editor.category-menu.disposition-type.title\": \"ตำแหน่งเมนู\",\n \"admin/editor.category-menu.show-departments-category.title\": \"แสดงหมวดหมู่ของแผนก\",\n \"admin/editor.category-menu.show-subcategories.title\": \"แสดงหมวดหมู่ย่อย\",\n \"admin/editor.category-menu.sort-subcategories.title\": \"จัดเรียงหมวดหมู่ย่อย\",\n \"admin/editor.category-menu.sort-type.default\": \"ค่าเริ่มต้น\",\n \"admin/editor.category-menu.sort-type.name\": \"ชื่อ\",\n \"admin/editor.category-menu.title\": \"เมนูหมวดหมู่\",\n \"store/category-menu.all-category.title\": \"ดูทั้งหมด\",\n \"store/category-menu.departments.title\": \"แผนก\"\n}\n\n```"
}
] |
code_category-menu_6a11cbe0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/messages/es.json from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.category-menu.departments.items.id\": \"Id del Departamento\",\n \"admin/editor.category-menu.departments.items.title\": \"Departamento\",\n \"admin/editor.category-menu.description\": \"Un menú que muestra una lista de categorías disponibles en la tienda\",\n \"admin/editor.category-menu.disposition-type.center\": \"Centro\",\n \"admin/editor.category-menu.disposition-type.left\": \"Izquierda\",\n \"admin/editor.category-menu.disposition-type.right\": \"Derecho\",\n \"admin/editor.category-menu.disposition-type.title\": \"Posición del menú\",\n \"admin/editor.category-menu.show-departments-category.title\": \"Mostrar la categoría de departamentos\",\n \"admin/editor.category-menu.show-subcategories.title\": \"Mostrar subcategorías\",\n \"admin/editor.category-menu.sort-subcategories.title\": \"Ordenar subcategorías\",\n \"admin/editor.category-menu.sort-type.default\": \"Predeterminado\",\n \"admin/editor.category-menu.sort-type.name\": \"Nombre\",\n \"admin/editor.category-menu.title\": \"Menú de categorías\",\n \"store/category-menu.all-category.title\": \"Ver Todos\",\n \"store/category-menu.departments.title\": \"Departamentos\"\n}\n\n```"
}
] |
code_category-menu_f3fce484
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/messages/ar.json from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.category-menu.departments.items.id\": \"معرف القسم\",\n \"admin/editor.category-menu.departments.items.title\": \"القسم 1\",\n \"admin/editor.category-menu.description\": \"قائمة تظهر لائحة الفئات المتاحة في المتجر\",\n \"admin/editor.category-menu.disposition-type.center\": \"متوسط\",\n \"admin/editor.category-menu.disposition-type.left\": \"اليسار\",\n \"admin/editor.category-menu.disposition-type.right\": \"اليمين\",\n \"admin/editor.category-menu.disposition-type.title\": \"موضع القائمة\",\n \"admin/editor.category-menu.show-departments-category.title\": \"إظهار فئة الأقسام\",\n \"admin/editor.category-menu.show-subcategories.title\": \"إظهار الفئات الفرعية\",\n \"admin/editor.category-menu.sort-subcategories.title\": \"فرز الفئات الفرعية\",\n \"admin/editor.category-menu.sort-type.default\": \"العنوان الرئيسي\",\n \"admin/editor.category-menu.sort-type.name\": \"الاسم\",\n \"admin/editor.category-menu.title\": \"قائمة الفئة\",\n \"store/category-menu.all-category.title\": \"شاهد الكل\",\n \"store/category-menu.departments.title\": \"الأقسام\"\n}\n\n```"
}
] |
code_category-menu_f3016f54
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/docs/README.md from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/vtex-apps/category-menu) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# Category Menu\n\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\nThe Category Menu is a store component that displays a list of departments in a configurable menu layout. It helps organize and present categories and subcategories to improve navigation.\n\n\n\n## Configuration\n\n1. Add the app to your store theme's dependencies in the `manifest.json`.\n\n```json\n dependencies: {\n \"vtex.category-menu\": \"2.x\"\n }\n```\n\n2. Add the `category-menu` block to your store theme.\n\n```json\n{\n \"category-menu\": {\n \"props\": {\n \"showAllDepartments\": true,\n \"showSubcategories\": true,\n \"menuDisposition\": \"center\",\n \"departments\": [],\n \"sortSubcategories\": \"name\"\n }\n }\n}\n```\n\n### `category-menu` props\n\n| Prop name | Type | Description | Default Value |\n| -------------------- | -------------- | ----------------------------------------------------------------------------------------------- | ------------- |\n| `showAllDepartments` | `Boolean` | Shows all department categories in the menu | `true` |\n| `menuDisposition` | `Enum` | Indicates the menu's position on the screen. Possible values: `left`, `center`, `right` | `center` |\n| `showSubcategories` | `Boolean` | Defines if the subcategories will be displayed | `true` |\n| `departments` | `Array(items)` | List of department `items` to be displayed on the menu | `[]` |\n| `mobileMode` | `Boolean` | Renders the category menu in a sidebar if set to `true` | `false` |\n| `sortSubcategories` | `Enum` | Determines how subcategories are sorted. Possible value: `name` | |\n\n### `category-menu` items\n\n| Prop name | Type | Description |\n| --------- | -------- | --------------------------------------------- |\n| `id` | `Number` | The department ID to be displayed on the menu |\n\n## Customization\n\nIn order to apply CSS customizations in this and other blocks, follow the instructions on [Using CSS Handles for store customization](https://vtex.io/docs/recipes/style/using-css-handles-for-store-customization).\n\n| CSS Handles |\n| --------------------------- |\n| `container` |\n| `departmentLink` |\n| `departmentList` |\n| `firstLevelLink` |\n| `firstLevelLinkContainer` |\n| `firstLevelList` |\n| `itemContainer` |\n| `itemContainer--category` |\n| `itemContainer--department` |\n| `menuContainer` |\n| `secondLevelLink` |\n| `secondLevelLinkContainer` |\n| `secondLevelList` |\n| `section--category` |\n| `section--department` |\n| `sidebar` |\n| `sidebarContainer` |\n| `sidebarContent` |\n| `sidebarHeader` |\n| `sidebarItem` |\n| `sidebarItemContainer` |\n| `sidebarOpen` |\n| `sidebarScrim` |\n| `submenuItem` |\n| `submenuList` |\n\n<!-- DOCS-IGNORE:start -->\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n <tr>\n <td align=\"center\"><a href=\"https://github.com/khrizzcristian\"><img src=\"https://avatars.githubusercontent.com/u/43498488?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>khrizzcristian</b></sub></a><br /><a href=\"https://github.com/vtex-apps/category-menu/commits?author=khrizzcristian\" title=\"Code\">💻</a></td>\n </tr>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!\n<!-- DOCS-IGNORE:end -->\n\n```"
}
] |
code_category-menu_42f286d4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/react/index.js from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\nimport React, { Fragment, useState } from 'react'\nimport { graphql } from 'react-apollo'\nimport { injectIntl, intlShape } from 'react-intl'\nimport { IconMenu } from 'vtex.store-icons'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { compose, path } from 'ramda'\nimport classNames from 'classnames'\nimport { Container } from 'vtex.store-components'\n\nimport CategoryItem from './components/CategoryItem'\nimport SideBar from './components/SideBar'\nimport { categoryPropType } from './propTypes'\nimport getCategories from './queries/categoriesQuery.gql'\n\nimport styles from './categoryMenu.css'\nimport categoryMenuPosition, {\n getMenuPositionNames,\n getMenuPositionValues,\n} from './utils/categoryMenuPosition'\nimport sortSubcategoriesItems, {\n getSortSubcategoriesNames,\n getSortSubcategoriesValues,\n} from './utils/sortSubcategoriesItems'\n\nconst DEFAULT_SUBCATEGORIES_LEVELS = 1\n\n/**\n * Component that represents the menu containing the categories of the store\n */\nconst CategoryMenu = ({\n mobileMode = false,\n showAllDepartments = true,\n showSubcategories = true,\n menuPosition = categoryMenuPosition.DISPLAY_CENTER.value,\n sortSubcategories = sortSubcategoriesItems.SORT_DEFAULT.value,\n departments = [],\n data: { categories = [] },\n intl,\n}) => {\n const runtime = useRuntime()\n const [sideBarVisible, setSidebarVisible] = useState(false)\n\n const handleSidebarToggle = () => {\n setSidebarVisible(prevVisible => !prevVisible)\n }\n\n const departmentsIds = departments.map(dept => dept.id)\n const departmentsSelected = categories.filter(category =>\n departmentsIds.includes(category.id)\n )\n\n const visibleDepartments =\n (departmentsSelected.length && departmentsSelected) || categories\n\n if (mobileMode) {\n return (\n <div className={`${styles.sidebarContainer} ${styles.mobile}`}>\n <SideBar\n visible={sideBarVisible}\n title={intl.formatMessage({\n id: 'store/category-menu.departments.title',\n })}\n departments={visibleDepartments}\n onClose={handleSidebarToggle}\n showSubcategories={showSubcategories}\n />\n <div className=\"flex pa4 pointer\" onClick={handleSidebarToggle}>\n <IconMenu size={20} />\n </div>\n </div>\n )\n }\n\n const pathName = path(['route', 'params', 'department'], runtime)\n\n const department = pathName ? pathName : ''\n\n const desktopClasses = classNames(\n `${styles.container} w-100 bg-base dn flex-m`,\n {\n 'justify-start': menuPosition === categoryMenuPosition.DISPLAY_LEFT.value,\n 'justify-end': menuPosition === categoryMenuPosition.DISPLAY_RIGHT.value,\n 'justify-center':\n menuPosition === categoryMenuPosition.DISPLAY_CENTER.value,\n }\n )\n\n return (\n <nav className={desktopClasses}>\n <Container\n className={`${styles['section--department']} justify-center flex`}\n >\n <ul\n className={`${styles.departmentList} pa0 list ma0 flex flex-wrap flex-row t-action overflow-hidden h3`}\n >\n {showAllDepartments && (\n <CategoryItem\n noRedirect\n menuPosition={menuPosition}\n subcategoryLevels={\n DEFAULT_SUBCATEGORIES_LEVELS + showSubcategories\n }\n sortSubcategories={sortSubcategories}\n category={{\n children: categories,\n name: intl.formatMessage({\n id: 'store/category-menu.departments.title',\n }),\n }}\n />\n )}\n {visibleDepartments.map(category => (\n <Fragment key={category.id}>\n <CategoryItem\n menuPosition={menuPosition}\n category={category}\n subcategoryLevels={\n DEFAULT_SUBCATEGORIES_LEVELS + showSubcategories\n }\n isCategorySelected={department === category.slug}\n sortSubcategories={sortSubcategories}\n />\n </Fragment>\n ))}\n </ul>\n </Container>\n </nav>\n )\n}\n\nCategoryMenu.propTypes = {\n /** Categories query data */\n data: PropTypes.shape({\n loading: PropTypes.bool.isRequired,\n categories: PropTypes.arrayOf(categoryPropType),\n }),\n /** Set mobile mode */\n mobileMode: PropTypes.bool,\n /** Whether to show the departments category or not */\n showAllDepartments: PropTypes.bool,\n /** Whether to show subcategories or not */\n showSubcategories: PropTypes.bool,\n /** Defines the position of the category menu */\n menuPosition: PropTypes.oneOf(getMenuPositionValues()),\n /** Intl */\n intl: intlShape,\n /** Departments to be shown in the desktop mode. */\n departments: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.number,\n })\n ),\n sortSubcategories: PropTypes.oneOf(getSortSubcategoriesValues()),\n}\n\nCategoryMenu.schema = {\n title: 'admin/editor.category-menu.title',\n description: 'admin/editor.category-menu.description',\n type: 'object',\n properties: {\n showAllDepartments: {\n type: 'boolean',\n title: 'admin/editor.category-menu.show-departments-category.title',\n default: true,\n },\n menuPosition: {\n title: 'admin/editor.category-menu.disposition-type.title',\n type: 'string',\n enum: getMenuPositionValues(),\n enumNames: getMenuPositionNames(),\n default: categoryMenuPosition.DISPLAY_CENTER.value,\n isLayout: true,\n },\n showSubcategories: {\n type: 'boolean',\n title: 'admin/editor.category-menu.show-subcategories.title',\n default: true,\n },\n sortSubcategories: {\n title: 'admin/editor.category-menu.sort-subcategories.title',\n type: 'string',\n enum: getSortSubcategoriesValues(),\n enumNames: getSortSubcategoriesNames(),\n default: sortSubcategoriesItems.SORT_DEFAULT.value,\n },\n departments: {\n title: 'store/category-menu.departments.title',\n type: 'array',\n minItems: 0,\n items: {\n title: 'admin/editor.category-menu.departments.items.title',\n type: 'object',\n properties: {\n id: {\n title: 'admin/editor.category-menu.departments.items.id',\n type: 'number',\n },\n },\n },\n },\n },\n}\n\nexport default compose(\n graphql(getCategories),\n injectIntl\n)(CategoryMenu)\n\n```"
}
] |
code_category-menu_9be1136a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/react/categoryMenu.css from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n.itemContainer {\n max-height: 21.875rem;\n}\n.itemContainer--department {}\n.itemContainer--category {}\n\n.animation {\n left: -0.5rem;\n}\n\n@media only screen and (max-width: 40rem) {\n body.sidebarOpen {\n overflow-y: hidden;\n }\n}\n\n.container {}\n\n.section--department {}\n.section--category {}\n\n.departmentList {}\n.departmentLink {}\n\n.firstLevelList {}\n.firstLevelLinkContainer {}\n.firstLevelLink {}\n\n.secondLevelList {}\n.secondLevelLinkContainer {}\n.secondLevelLink {}\n\n.submenuList {}\n.submenuItem {}\n\n.sidebarOpen {}\n\n.sidebarScrim {}\n\n.sidebar {}\n\n.sidebarHeader {}\n\n.sidebarContent {}\n\n.sidebarItem {}\n\n.sidebarContainer {}\n\n.menuContainer {}\n\n.sidebarItemContainer {}\n\n```"
}
] |
code_category-menu_a63f1bca
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/react/package.json from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.category-menu\",\n \"version\": \"2.18.1\",\n \"scripts\": {\n \"pretest\": \"yarn\",\n \"test\": \"vtex-test-tools test\",\n \"lint\": \"eslint --ext js,jsx,ts,tsx .\"\n },\n \"dependencies\": {\n \"apollo-cache-inmemory\": \"^1.6.3\",\n \"classnames\": \"^2.2.6\",\n \"graphql\": \"^14.0.2\",\n \"jsdom\": \"^11.8.0\",\n \"ramda\": \"^0.26.1\",\n \"react-apollo\": \"^2.5.8\",\n \"react-intl\": \"^2.4.0\"\n },\n \"devDependencies\": {\n \"@types/classnames\": \"^2.2.9\",\n \"@types/jest\": \"^24.0.18\",\n \"@vtex/test-tools\": \"^0.1.2\",\n \"@vtex/tsconfig\": \"^0.1.1\",\n \"apollo-client\": \"^2.5.1\"\n },\n \"vtexTestTools\": {\n \"defaultLocale\": \"en\"\n }\n}\n\n```"
}
] |
code_category-menu_56bc285f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/react/propTypes.js from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\n\nfunction lazyFunction(f) {\n return function() {\n return f.apply(this, arguments)\n }\n}\n\nexport const categoryPropType = PropTypes.shape({\n id: PropTypes.number.isRequired,\n name: PropTypes.string.isRequired,\n slug: PropTypes.string.isRequired,\n children: PropTypes.arrayOf(lazyFunction(() => categoryPropType)),\n})\n\nexport const categoryItemShape = PropTypes.shape({\n name: PropTypes.string.isRequired,\n slug: PropTypes.string,\n children: PropTypes.arrayOf(lazyFunction(() => categoryPropType)),\n})\n\n```"
}
] |
code_category-menu_fc931f04
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/react/setupTests.js from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport Enzyme from 'enzyme'\nimport Adapter from 'enzyme-adapter-react-16'\nimport { JSDOM } from 'jsdom'\n\nconst jsdom = new JSDOM('<!doctype html><html><body></body></html>')\n\nglobal.window = jsdom.window\nglobal.document = window.document\n\nEnzyme.configure({ adapter: new Adapter() })\n\n```"
}
] |
code_category-menu_77722602
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/store/interfaces.json from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"category-menu\": {\n \"component\": \"index\"\n }\n}\n```"
}
] |
code_category-menu_79db50b3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/react/queries/categoriesQuery.gql from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery {\n categories(treeLevel: 2) {\n id\n name\n href\n slug\n hasChildren\n children {\n id\n name\n href\n slug\n hasChildren\n children {\n id\n name\n href\n slug\n }\n }\n }\n}\n\n```"
}
] |
code_category-menu_daa6985b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/react/utils/categoryMenuPosition.js from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { values, pluck } from 'ramda'\n\nconst categoryMenuPosition = {\n DISPLAY_CENTER: {\n name: 'admin/editor.category-menu.disposition-type.center',\n value: 'center',\n },\n DISPLAY_LEFT: {\n name: 'admin/editor.category-menu.disposition-type.left',\n value: 'left',\n },\n DISPLAY_RIGHT: {\n name: 'admin/editor.category-menu.disposition-type.right',\n value: 'right',\n },\n}\n\nexport function getMenuPositionNames() {\n return pluck('name', values(categoryMenuPosition))\n}\n\nexport function getMenuPositionValues() {\n return pluck('value', values(categoryMenuPosition))\n}\n\nexport default categoryMenuPosition\n\n```"
}
] |
code_category-menu_451dc1de
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/react/utils/sortSubcategoriesItems.js from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { values, pluck } from 'ramda'\n\nconst sortSubcategoriesItems = {\n SORT_DEFAULT: {\n name: 'admin/editor.category-menu.sort-type.default',\n value: '',\n },\n SORT_NAME: {\n name: 'admin/editor.category-menu.sort-type.name',\n value: 'name',\n },\n}\n\nexport function getSortSubcategoriesNames() {\n return pluck('name', values(sortSubcategoriesItems))\n}\n\nexport function getSortSubcategoriesValues() {\n return pluck('value', values(sortSubcategoriesItems))\n}\n\nexport default sortSubcategoriesItems\n\n```"
}
] |
code_category-menu_f3b4e109
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/react/components/SideBarItem.js from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { useState, Fragment } from 'react'\nimport PropTypes from 'prop-types'\nimport classNames from 'classnames'\nimport { FormattedMessage } from 'react-intl'\n\nimport { useRuntime } from 'vtex.render-runtime'\nimport { IconMinus, IconPlus } from 'vtex.store-icons'\n\nimport styles from '../categoryMenu.css'\n\nconst SideBarItem = ({\n treeLevel = 1,\n item: { children },\n showSubcategories,\n onClose,\n linkValues,\n item,\n}) => {\n const runtime = useRuntime()\n const [open, setOpen] = useState(false)\n\n const subCategoriesVisible =\n showSubcategories && children && children.length > 0\n\n const navigateToPage = () => {\n const [department, category, subcategory] = linkValues\n const params = { department }\n\n if (category) params.category = category\n if (subcategory) params.subcategory = subcategory\n\n const page = category\n ? subcategory\n ? 'store.search#subcategory'\n : 'store.search#category'\n : 'store.search#department'\n\n runtime.navigate({\n page,\n params,\n fallbackToWindowLocation: false,\n })\n onClose()\n }\n\n const handleItemClick = () => {\n if (subCategoriesVisible) {\n setOpen(prevOpen => !prevOpen)\n } else {\n navigateToPage()\n }\n }\n\n const sideBarContainerClasses = classNames(\n styles.sidebarItemContainer,\n 'flex justify-between items-center pa5 pointer list ma0'\n )\n const sideBarItemTitleClasses = classNames('', {\n 't-body lh-solid': treeLevel === 1,\n })\n\n const sideBarSpanClasses = classNames(\n treeLevel === 1 ? 'c-on-base' : 'c-muted-3'\n )\n\n const sideBarItemClasses = classNames(`${styles.sidebarItem} list pa0 ma0`, {\n 'c-muted-2 t-body pl4': treeLevel > 1,\n 'c-on-base': treeLevel === 1,\n })\n\n return (\n <ul className={sideBarItemClasses}>\n <li className={sideBarContainerClasses} onClick={handleItemClick}>\n <span className={sideBarItemTitleClasses}>{item.name}</span>\n {subCategoriesVisible && (\n <span className={sideBarSpanClasses}>\n {open ? <IconMinus size={16} /> : <IconPlus size={16} />}\n </span>\n )}\n </li>\n {subCategoriesVisible && open && (\n <>\n <li\n className=\"pa5 pointer t-body c-muted-2 ma0 list\"\n onClick={navigateToPage}\n >\n <FormattedMessage id=\"store/category-menu.all-category.title\">\n {txt => <span className=\"pl4\">{txt}</span>}\n </FormattedMessage>\n </li>\n {children.map(child => (\n <li key={child.id} className=\"list ma0 pa0\">\n <SideBarItem\n showSubcategories={showSubcategories}\n item={child}\n linkValues={[...linkValues, child.slug]}\n onClose={onClose}\n treeLevel={treeLevel + 1}\n runtime={runtime}\n />\n </li>\n ))}\n </>\n )}\n </ul>\n )\n}\n\nSideBarItem.propTypes = {\n /** Sidebar's item. */\n item: PropTypes.object.isRequired,\n /** Link values to create the redirect. */\n linkValues: PropTypes.arrayOf(PropTypes.string).isRequired,\n /** Closes sidebar. */\n onClose: PropTypes.func.isRequired,\n /** Runtime context. */\n runtime: PropTypes.shape({\n navigate: PropTypes.func,\n }),\n /** Tree level. */\n treeLevel: PropTypes.number,\n /** Whether to show subcategories or not */\n showSubcategories: PropTypes.bool,\n}\n\nexport default SideBarItem\n\n```"
}
] |
code_category-menu_dfa35093
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/react/components/CategoryItem.js from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { useState, useRef } from 'react'\nimport { Link } from 'vtex.render-runtime'\nimport PropTypes from 'prop-types'\nimport { categoryItemShape } from '../propTypes'\n\nimport ItemContainer from './ItemContainer'\nimport classNames from 'classnames'\nimport styles from '../categoryMenu.css'\nimport categoryMenuPosition, {\n getMenuPositionValues,\n} from '../utils/categoryMenuPosition'\nimport { getSortSubcategoriesValues } from '../utils/sortSubcategoriesItems'\n\n/**\n * Component that represents a single category displayed in the menu, also displays\n * the subcategories, if the provided category has them\n */\nconst CategoryItem = ({\n category,\n subcategoryLevels,\n menuPosition,\n category: { name, slug },\n noRedirect,\n isCategorySelected,\n sortSubcategories,\n}) => {\n const [isHover, setHover] = useState(false)\n const itemRef = useRef(null)\n\n const handleCloseMenu = () => {\n setHover(false)\n }\n\n const categoryClasses = classNames(\n styles.departmentLink,\n 'w-100 pv5 no-underline t-small outline-0 db tc link truncate bb bw1 c-muted-1',\n {\n 'b--transparent': !isHover && !isCategorySelected,\n 'b--action-primary pointer': isHover || isCategorySelected,\n mr8: menuPosition === categoryMenuPosition.DISPLAY_LEFT.value,\n ml8: menuPosition === categoryMenuPosition.DISPLAY_RIGHT.value,\n mh6: menuPosition === categoryMenuPosition.DISPLAY_CENTER.value,\n }\n )\n\n const containerStyle = {\n top:\n itemRef.current &&\n itemRef.current.offsetTop + itemRef.current.clientHeight,\n display: isHover ? 'flex' : 'none',\n }\n\n return (\n <li\n className={`${styles.itemContainer} ${\n styles['itemContainer--department']\n } flex items-center db list`}\n ref={itemRef}\n onMouseEnter={() => setHover(true)}\n onMouseLeave={handleCloseMenu}\n >\n {noRedirect ? (\n <span className={categoryClasses}>{name}</span>\n ) : (\n <Link\n onClick={handleCloseMenu}\n page=\"store.search#department\"\n params={{ department: slug }}\n className={categoryClasses}\n >\n {name}\n </Link>\n )}\n\n {subcategoryLevels > 0 && category.children.length > 0 && (\n <ItemContainer\n menuPosition={menuPosition}\n containerStyle={containerStyle}\n categories={category.children}\n parentSlug={category.slug}\n onCloseMenu={handleCloseMenu}\n showSecondLevel={subcategoryLevels === 2}\n sortSubcategories={sortSubcategories}\n />\n )}\n </li>\n )\n}\n\nCategoryItem.propTypes = {\n /** Category to be displayed */\n category: categoryItemShape.isRequired,\n /** Set use of Link component */\n noRedirect: PropTypes.bool,\n /** Number of subcategory levels */\n subcategoryLevels: PropTypes.oneOf([0, 1, 2]),\n /** Defines the position of the category menu */\n menuPosition: PropTypes.oneOf(getMenuPositionValues()),\n /** Menu category selection */\n isCategorySelected: PropTypes.bool,\n sortSubcategories: PropTypes.oneOf(getSortSubcategoriesValues()),\n}\n\nexport default CategoryItem\n\n```"
}
] |
code_category-menu_8d8ff9f6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/react/components/SideBar.js from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { Fragment, useEffect } from 'react'\nimport PropTypes from 'prop-types'\nimport classNames from 'classnames'\nimport { Animation } from 'vtex.store-components'\nimport { IconClose } from 'vtex.store-icons'\n\nimport SideBarItem from './SideBarItem'\nimport styles from '../categoryMenu.css'\n\nconst OPEN_SIDEBAR_CLASS = styles.sidebarOpen\n\nconst SideBar = ({\n title = 'Departments',\n visible,\n onClose = () => {},\n showSubcategories,\n departments = [],\n}) => {\n useEffect(() => {\n if (visible) {\n document.body.classList.add(OPEN_SIDEBAR_CLASS)\n\n return () => document.body.classList.remove(OPEN_SIDEBAR_CLASS)\n } else {\n document.body.classList.remove(OPEN_SIDEBAR_CLASS)\n }\n }, [visible])\n\n const scrimClasses = classNames(\n styles.sidebarScrim,\n 'fixed dim bg-base--inverted top-0 z-1 vw-100 vh-100 o-40',\n {\n dn: !visible,\n }\n )\n\n return (\n <Fragment>\n <div className={scrimClasses} onClick={onClose} />\n <Animation\n isActive={visible}\n type=\"drawerRight\"\n className={`${styles.animation} fixed w-80 top-0 z-max`}\n >\n <aside\n className={`${styles.sidebar} w-100 bg-base z-max vh-100 shadow-5 overflow-scroll`}\n >\n <div\n className={`${styles.sidebarHeader} flex justify-between items-center pa5 pointer`}\n onClick={onClose}\n >\n <IconClose size={24} activeClassName=\"c-muted-1\" />\n </div>\n <ul className={`${styles.sidebarContent} pb7 list ma0 pa0`}>\n {departments.map(department => (\n <li key={department.id} className=\"list ma0 pa0\">\n <SideBarItem\n item={department}\n linkValues={[department.slug]}\n onClose={onClose}\n showSubcategories={showSubcategories}\n />\n </li>\n ))}\n </ul>\n </aside>\n </Animation>\n </Fragment>\n )\n}\n\nSideBar.propTypes = {\n /** Sidebar's departments. */\n departments: PropTypes.arrayOf(PropTypes.object),\n /** Closes sidebar. */\n onClose: PropTypes.func,\n /** Sidebar's visibility. */\n visible: PropTypes.bool,\n /** Whether to show subcategories or not */\n showSubcategories: PropTypes.bool,\n}\n\nexport default SideBar\n\n```"
}
] |
code_category-menu_fee36a77
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/react/components/ItemContainer.js from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport { Link } from 'vtex.render-runtime'\nimport { categoryPropType } from '../propTypes'\nimport classNames from 'classnames'\nimport { Container } from 'vtex.store-components'\n\nimport PropTypes from 'prop-types'\nimport styles from '../categoryMenu.css'\nimport categoryMenuPosition, {\n getMenuPositionValues,\n} from '../utils/categoryMenuPosition'\nimport sortSubcategoriesItems from '../utils/sortSubcategoriesItems'\n\nconst getLinkParams = (parentSlug, item) => {\n const params = {\n department: parentSlug || item.slug,\n }\n\n if (parentSlug) params.category = item.slug\n\n return params\n}\n\n/**\n * Component responsible dor rendering an array of categories and its respective subcategories\n */\nconst ItemContainer = ({\n containerStyle,\n categories,\n parentSlug,\n menuPosition,\n onCloseMenu,\n showSecondLevel,\n sortSubcategories,\n}) => {\n const shouldRenderSecondLevel = category => {\n const { children } = category\n\n return children && children.length > 0 && showSecondLevel\n }\n\n const containerClasses = classNames(\n styles.submenuList,\n 'w-100 flex flex-wrap pa0 list mw9',\n {\n 'justify-start': menuPosition === categoryMenuPosition.DISPLAY_LEFT.value,\n 'justify-end': menuPosition === categoryMenuPosition.DISPLAY_RIGHT.value,\n 'justify-center':\n menuPosition === categoryMenuPosition.DISPLAY_CENTER.value,\n }\n )\n\n const columnItemClasses = classNames(styles.firstLevelList, {\n 'pl0 pr7': menuPosition === categoryMenuPosition.DISPLAY_LEFT.value,\n 'pr0 pl7': menuPosition === categoryMenuPosition.DISPLAY_RIGHT.value,\n })\n\n const firstLevelLinkClasses = classNames(\n styles.firstLevelLink,\n 'db pv4 link no-underline outline-0 tl t-small truncate c-on-base underline-hover',\n {\n pr4: menuPosition === categoryMenuPosition.DISPLAY_LEFT.value,\n pl4: menuPosition === categoryMenuPosition.DISPLAY_RIGHT.value,\n ph4: menuPosition === categoryMenuPosition.DISPLAY_CENTER.value,\n }\n )\n\n const secondLevelLinkClasses = classNames(\n styles.secondLevelLink,\n 'db pv3 no-underline outline-0 tl link t-small truncate c-muted-1 underline-hover',\n {\n pr5: menuPosition === categoryMenuPosition.DISPLAY_LEFT.value,\n pl5: menuPosition === categoryMenuPosition.DISPLAY_RIGHT.value,\n ph5: menuPosition === categoryMenuPosition.DISPLAY_CENTER.value,\n }\n )\n\n return (\n <div\n className={`${styles.itemContainer} ${\n styles['itemContainer--category']\n } absolute w-100 left-0 bg-base pb2 bw1 bb b--muted-3`}\n style={containerStyle}\n >\n <Container\n className={`${styles['section--category']} justify-center w-100 flex`}\n >\n <ul className={containerClasses}>\n {categories\n .sort((a, b) => {\n if (\n sortSubcategories === sortSubcategoriesItems.SORT_NAME.value\n ) {\n return a.name > b.name ? 1 : -1\n }\n return 0\n })\n .map(category => (\n <li key={category.id} className={`${styles.submenuItem} dib`}>\n <ul className={columnItemClasses}>\n <li className={`${styles.firstLevelLinkContainer} list pa0`}>\n <Link\n onClick={onCloseMenu}\n page={\n parentSlug\n ? 'store.search#category'\n : 'store.search#department'\n }\n className={firstLevelLinkClasses}\n params={getLinkParams(parentSlug, category)}\n >\n {category.name}\n </Link>\n </li>\n\n {shouldRenderSecondLevel(category) &&\n category.children\n .sort((a, b) => {\n if (\n sortSubcategories ===\n sortSubcategoriesItems.SORT_NAME.value\n ) {\n return a.name > b.name ? 1 : -1\n }\n return 0\n })\n .map(subCategory => {\n const params = {\n department: parentSlug || category.slug,\n category: parentSlug\n ? category.slug\n : subCategory.slug,\n }\n if (parentSlug) params.subcategory = subCategory.slug\n\n return (\n <li\n key={subCategory.id}\n className={`${styles.secondLevelLinkContainer} list pa0`}\n >\n <Link\n onClick={onCloseMenu}\n page={\n parentSlug\n ? 'store.search#subcategory'\n : 'store.search#category'\n }\n className={secondLevelLinkClasses}\n params={params}\n >\n {subCategory.name}\n </Link>\n </li>\n )\n })}\n </ul>\n </li>\n ))}\n </ul>\n </Container>\n </div>\n )\n}\n\nItemContainer.propTypes = {\n /** Category to be displayed */\n categories: PropTypes.arrayOf(categoryPropType),\n /** Department slug */\n parentSlug: PropTypes.string,\n /** Close menu callback */\n onCloseMenu: PropTypes.func.isRequired,\n /** Whether to show second level links or not */\n showSecondLevel: PropTypes.bool,\n /** Defines the position of the category menu */\n menuPosition: PropTypes.oneOf(getMenuPositionValues()),\n /** Custom styles to item container */\n containerStyle: PropTypes.object,\n sortSubcategories: PropTypes.oneOf(getMenuPositionValues()),\n}\n\nexport default ItemContainer\n\n```"
}
] |
code_category-menu_7cc6ab41
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/react/__tests__/SideBar.test.js from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport { render } from '@vtex/test-tools/react'\nimport SideBar from '../components/SideBar'\n\ndescribe('SideBar component', () => {\n const renderComponent = customProps => {\n return render(\n <SideBar\n departments={[]}\n onClose={() => {}}\n showSubcategories\n visible={false}\n {...customProps}\n />\n )\n }\n\n it('should be rendered', () => {\n expect(renderComponent()).toBeDefined()\n })\n\n it('should match snapshot', () => {\n expect(renderComponent({ visible: true }).asFragment()).toMatchSnapshot()\n })\n})\n\n```"
}
] |
code_category-menu_4b05f788
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/react/__tests__/CategoryMenu.test.js from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport { render, wait } from '@vtex/test-tools/react'\nimport CategoryMenu from '../index'\nimport categoriesQuery from '../queries/categoriesQuery.gql'\n\ndescribe('CategoryMenu component', () => {\n const mockedCategories = [\n {\n id: 1,\n href: '#1',\n name: 'Category 1',\n slug: 'category-1',\n hasChildren: false,\n children: [],\n },\n {\n id: 2,\n href: '#2',\n name: 'Category 2',\n slug: 'category-2',\n hasChildren: false,\n children: [],\n },\n {\n id: 3,\n href: '#3',\n name: 'Category 3',\n slug: 'category-3',\n hasChildren: false,\n children: [],\n },\n ]\n\n const renderComponent = customProps => {\n const departments = mockedCategories.map(category => ({ id: category.id }))\n\n const mocks = [\n {\n request: {\n query: categoriesQuery,\n },\n result: {\n data: { categories: mockedCategories },\n },\n },\n ]\n\n return render(<CategoryMenu departments={departments} {...customProps} />, {\n graphql: { mocks },\n })\n }\n\n it('should be rendered', () => {\n expect(renderComponent()).toBeDefined()\n })\n\n it('should match snapshot', async () => {\n const { asFragment } = renderComponent()\n\n await wait(() => {})\n\n expect(asFragment()).toMatchSnapshot()\n })\n\n it(\"shouldn't be able to find a `Category 4` item\", async () => {\n const element = renderComponent().queryByText(/Category 4/)\n\n await wait(() => expect(element).toBeNull())\n })\n})\n\n```"
}
] |
code_category-menu_ab1a721d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of category-menu/react/__tests__/CategoryItem.test.js from the category-menu VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport { render } from '@vtex/test-tools/react'\n\nimport CategoryItem from '../components/CategoryItem'\n\ndescribe('CategoryItem component', () => {\n let wrapper\n\n beforeEach(() => {\n const categoryMock = {\n id: 1,\n name: 'Category',\n slug: 'category',\n hasChildren: true,\n children: [\n {\n id: 2,\n name: 'Sub-category',\n slug: 'sub-category',\n },\n ],\n }\n\n wrapper = render(<CategoryItem category={categoryMock} />)\n })\n\n it('should have the correct href', () => {\n const element = wrapper.getByText(/CATEGORY/i)\n\n expect(element.href).toMatch(/\\/category\\/s$/i)\n })\n\n it('should match snapshot', () => {\n expect(wrapper.asFragment()).toMatchSnapshot()\n })\n})\n\n```"
}
] |
code_amp-store_ffe55d9f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of amp-store/react/AmpProvider.tsx from the amp-store VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { Helmet } from 'react-helmet'\nimport { useRuntime } from 'vtex.render-runtime'\nimport * as Amp from 'react-amphtml'\n\nconst CONTENT_TYPE = 'text/html; charset=utf-8'\nconst META_ROBOTS = 'index, follow'\n\nconst joinKeywords = (keywords: string[]) => keywords && keywords.join(', ')\n\nconst AmpProvider: React.FC = ({ children }) => {\n const runtime = useRuntime()\n const {\n getSettings,\n culture: { country, locale, currency },\n route: { title: pageTitle, metaTags },\n } = runtime\n\n const storeSettings = getSettings('vtex.store')\n\n const {\n titleTag,\n metaTagDescription,\n metaTagKeywords,\n metaTagRobots,\n storeName,\n } = storeSettings\n\n const description = (metaTags && metaTags.description) || metaTagDescription\n const keywords =\n joinKeywords(metaTags && metaTags.keywords) || metaTagKeywords\n\n const title = pageTitle || titleTag\n\n return (\n <React.Fragment>\n <Helmet\n title={title}\n meta={[\n { name: 'description', content: description },\n { name: 'keywords', content: keywords },\n { name: 'copyright', content: storeName },\n { name: 'author', content: storeName },\n { name: 'country', content: country },\n { name: 'language', content: locale },\n { name: 'currency', content: currency },\n { name: 'robots', content: metaTagRobots || META_ROBOTS },\n { httpEquiv: 'Content-Type', content: CONTENT_TYPE },\n ].filter(meta => !!meta.content)}\n />\n <Amp.AmpState id=\"__RUNTIME__\" specName=\"amp-state\">\n {runtime}\n </Amp.AmpState>\n {children}\n </React.Fragment>\n )\n}\n\nexport default AmpProvider\n\n```"
}
] |
code_amp-store_7dbc5f83
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of amp-store/react/package.json from the amp-store VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"private\": true,\n \"dependencies\": {\n \"react\": \"^16.8.6\",\n \"react-amphtml\": \"^4.0.1\",\n \"react-dom\": \"^16.8.6\",\n \"react-helmet\": \"^5.2.1\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^12.7.0\",\n \"@types/react\": \"^16.8.24\",\n \"@types/react-dom\": \"^16.8.5\",\n \"@types/react-helmet\": \"^5.0.9\"\n },\n \"version\": \"0.1.5\"\n}\n\n```"
}
] |
code_amp-store_0f60533e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of amp-store/store/interfaces.json from the amp-store VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"amp-store\": {\n \"component\": \"*\",\n \"before\": [\"header.full\"],\n \"after\": [\"footer\"],\n \"around\": [\"ampProvider\"]\n },\n \"amp-store.home\": {},\n \"ampProvider\": {\n \"component\": \"AmpProvider\"\n }\n}\n\n```"
}
] |
code_amp-store_a4163d70
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of amp-store/store/routes.json from the amp-store VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"amp-store.home\": {\n \"path\": \"/amp/\",\n \"canonical\": \"/\"\n }\n}\n\n```"
}
] |
code_amp-store_2d4c3f6f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of amp-store/react/typings/vtex.render-runtime.d.ts from the amp-store VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.render-runtime' {\n export function useRuntime(): any\n}\n\n```"
}
] |
code_mkp-seller-auth_6543d173
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mkp-seller-auth/docs/README.md from the mkp-seller-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# TODO - Document this app\n\n\n# Service Example\n\nA reference app implementing a VTEX IO service with HTTP route handlers.\n\n\n\nWe use [**KoaJS**](https://koajs.com/) as the web framework, so you might want to get into that\n\nWe also use the [**node-vtex-api**](https://github.com/vtex/node-vtex-api), a VTEX set of utilities for Node services. You can import this package using NPM from `@vtex/api` (already imported on this project)\n\n- Start from `node/index.ts` and follow the comments and imports :)\n\n## Recipes\n\n### Defining routes on _service.json_ \n```json\n{\n \"memory\": 256,\n \"ttl\": 10,\n \"timeout\": 2,\n \"minReplicas\": 2,\n \"maxReplicas\": 4,\n \"routes\": {\n \"status\": {\n \"path\": \"/_v/status/:code\",\n \"public\": true\n }\n }\n}\n```\n\nThe `service.json` file that sits on the root of the `node` folder holds informations about this service, like the maximum timeout and number of replicas, what might be discontinued on the future, but also **sets its routes**. \n\nKoa uses the [path-to-regexp](https://github.com/pillarjs/path-to-regexp) format for defining routes and, as seen on the example, we use the `:code` notation for declaring a **route param** named code, in this case. A HTTP request for `https://{{workspace}}--{{account}}.myvtex.com/_v/status/500` will match the route we've defined. \n\nFor cach _key_ on the `routes` object, there should be a **corresponding entry** on the exported Service object on `node/index.ts`, this will hook your code to a specific route.\n\n### Access Control\nYou can also provide a `public` option for each route. If `true`, that resource will be reachable for everyone on the internet. If `false`, VTEX credentials will be requested as well.\n\nAnother way of controlling access to specific routes is using **ReBACs (Resource-based access)**, that supports more robust configuration. You can read more [on this document](https://docs.google.com/document/d/1ZxNHMFIXfXz3BgTN9xyrHL3V5dYz14wivYgQjRBZ6J8/edit#heading=h.z7pad3qd2qw7) (VTEX only).\n\n#### Query String\nFor `?accepting=query-string`, you **don't need to declare anything**, as any query provided to the URL will already be available for you to use on the code as `ctx.query`, already parsed as an object, or `ctx.queryString`, taken directly from the URL as a string.\n\n#### Route Params\nRoute Params will be available for you to use on the code as `ctx.vtex.params`, already parsed as an object.\nFor a path like `/_v/status/:code`, if you receive the request `/_v/status/200`, `ctx.vtex.params` will return `{ code: '200' }`\n\n#### HTTP methods\nWhen you define a route on the `service.json`, your NodeJS handlers for that route will be triggered **on every HTTP method** (GET, POST, PUT...), so, if you need to handle them separately you need to implement a \"sub-router\". Fortunately, the _node-vtex-api_ provides a helper function `method`, exported from `@vtex/api`, to accomplish that behaviour. Instead of passing your handlers directly to the corresponding route on `index.ts`, you pass a `method` call passing **an object with the desired method as key and one handler as its corresponding value**. Check this example:\n```typescript\nimport { method } from '@vtex/api'\n...\n\nexport default new Service<Clients, State>({\n clients,\n routes: {\n status: method({\n GET: statusGetHandler,\n POST: statusPostHandler,\n }),\n },\n})\n```\n\n### Throwing errors\n\nWhen building a HTTP service, we should follow HTTP rules regarding data types, cache, authorization, and status code. Our example app sets a `ctx.status` value that will be used as a HTTP status code return value, but often we also want to give proper information about errors as well.\n\nThe **node-vtex-api** already exports a handful of **custom error classes** that can be used for that purpose, like the `NotFoundError`. You just need to throw them inside one of the the route handlers that the appropriate response will be sent to the server.\n\n```typescript\nimport { UserInputError } from '@vtex/api'\n\nexport async function validate(ctx: Context, next: () => Promise<any>) {\n const { code } = ctx.vtex.route.params\n if (isNaN(code) || code < 100 || code > 600) {\n throw new UserInputError('Code must be a number between 100 and 600')\n }\n...\n```\n\nYou can check all the available errors [here](https://github.com/vtex/node-vtex-api/tree/fd6139349de4e68825b1074f1959dd8d0c8f4d5b/src/errors), but some are not useful for just-HTTP services. Check the most useful ones:\n\n|Error Class | HTTP Code |\n|--|:--:|\n| `UserInputError` | 400 |\n| `AuthenticationError` | 401 |\n| `ForbiddenError` | 403 |\n| `NotFoundError` | 404 |\n\nYou can also **create your custom error**, just see how it's done above ;)\n\n### Reading a JSON body\n\nWhen writing POST or PUT handlers, for example, often you need to have access to the **request body** that comes as a JSON format, which is not provided directly by the handler function.\n\nFor this, you have to use the [co-body](https://www.npmjs.com/package/co-body) package that will parse the request into a readable JSON object, used as below: \n```typescript\nimport { json } from 'co-body'\nexport async function method(ctx: Context, next: () => Promise<any>) {\n const body = await json(ctx.req)\n```\n\n### Other example apps\n\nWe use Node services across all VTEX, and there are a lot inspiring examples. If you want to dive deeper on learning about this subject, don't miss those internal apps: [builder-hub](https://github.com/vtex/builder-hub) or [store-sitemap](https://github.com/vtex-apps/store-sitemap)\n\n\n## Testing\n\n`@vtex/test-tools` and `@types/jest` should be installed on `./node` package as `devDependencies`.\n\nRun `vtex test` and [Jest](https://jestjs.io/) will do its thing.\n\nCheck the `node/__tests__/simple.test.ts` test case and also [Jest's Documentation](https://jestjs.io/docs/en/getting-started).\n\n## Splunk Dashboard\n\nWe have an (for now, VTEX-only, internal) Splunk dashboard to show all metrics related to your app. You can find it [here](https://splunk7.vtex.com/en-US/app/vtex_colossus/node_app_metrics).\n\nAfter linking this app and making some requests, you can select `vtex.service-example` and see the metrics for your app. **Don't forget to check the box Development, as you are linking your app in a development workspace**.\n\nFor convenience, the link for the current version: https://splunk7.vtex.com/en-US/app/vtex_colossus/node_app_metrics?form.time.earliest=-30m%40m&form.time.latest=%40m&form.picked_context=false&form.picked_region=aws-us-east-*&form.picked_service=vtex.service-example\n\n```"
}
] |
code_mkp-seller-auth_5f4a38f0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mkp-seller-auth/node/service.json from the mkp-seller-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"memory\": 256,\n \"ttl\": 10,\n \"timeout\": 10000,\n \"minReplicas\": 2,\n \"maxReplicas\": 4,\n \"workers\": 1,\n \"routes\": {\n \"healthcheck\": {\n \"path\": \"/mkp-seller-auth/v0/healthcheck\",\n \"public\": true\n },\n \"executeCall\": {\n \"path\": \"/mkp-seller-auth/v0/executeCall\",\n \"public\": true\n }\n }\n}\n\n```"
}
] |
code_mkp-seller-auth_8dfd420b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mkp-seller-auth/node/package.json from the mkp-seller-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"co-body\": \"^6.0.0\",\n \"ramda\": \"^0.25.0\",\n \"atob\": \"^2.1.2\"\n },\n \"devDependencies\": {\n \"@types/co-body\": \"^0.0.3\",\n \"@types/jest\": \"^24.0.18\",\n \"@types/node\": \"^12.0.0\",\n \"@types/ramda\": \"types/npm-ramda#dist\",\n \"@vtex/api\": \"6.45.12\",\n \"@vtex/test-tools\": \"^1.0.0\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"typescript\": \"3.9.7\",\n \"@types/atob\": \"^2.1.2\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty\"\n },\n \"version\": \"0.2.0\"\n}\n\n```"
}
] |
code_mkp-seller-auth_254b518d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mkp-seller-auth/node/index.ts from the mkp-seller-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { ClientsConfig, ServiceContext, RecorderState } from '@vtex/api'\nimport { LRUCache, method, Service } from '@vtex/api'\n\nimport { Clients } from './clients'\nimport { validateRequest } from './middlewares/validateRequest'\nimport { checkConfiguration } from './middlewares/checkConfiguration'\nimport { validateVtexIdclientAutCookie } from './middlewares/validateVtexIdclientAutCookie'\nimport { executeCall } from './middlewares/executeCall'\nimport { healthcheck } from './middlewares/healthcheck'\n\nconst TIMEOUT_MS = 6000\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, any>({ 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 // We declare a global Context type just to avoid re-writing ServiceContext<Clients, State> in every handler and resolver\n type Context = ServiceContext<Clients, State>\n\n // The shape of our State object found in `ctx.state`. This is used as state bag to communicate between middlewares.\n interface State extends RecorderState {\n code: number\n params: any\n requestBody: any\n requestHeaders: any\n requesterTokenDetails: any\n }\n}\n\n// Export a service that defines route handlers and client options.\nexport default new Service({\n clients,\n routes: {\n healthcheck: method({\n GET: [healthcheck],\n }),\n executeCall: method({\n POST: [\n validateRequest,\n checkConfiguration,\n validateVtexIdclientAutCookie,\n executeCall,\n ],\n }),\n },\n})\n\n```"
}
] |
code_mkp-seller-auth_9d3a481f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mkp-seller-auth/node/clients/vtexid.ts from the mkp-seller-auth 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 default class VtexID extends JanusClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(context, {\n ...options,\n headers: {\n ...options?.headers,\n 'x-vtex-user-agent': context.userAgent,\n },\n })\n }\n\n // https://developers.vtex.com/vtex-rest-api/reference/catalog-api-get-seller-list\n public async validate(token: string, account: string): Promise<any> {\n const url = `/api/vtexid/credential/validate?an=${account}`\n\n return this.http.post(url, { token }, { metric: 'vtexid-validate' })\n }\n}\n\n```"
}
] |
code_mkp-seller-auth_a50e06b0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mkp-seller-auth/node/clients/executeCall.ts from the mkp-seller-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext, IOResponse } from '@vtex/api'\nimport { JanusClient } from '@vtex/api'\n\nexport default class ExecuteCall extends JanusClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(context, {\n ...options,\n headers: {\n ...options?.headers,\n VtexIdclientAutCookie:\n context.adminUserAuthToken ?? context.authToken ?? '',\n 'x-vtex-user-agent': context.userAgent,\n },\n })\n }\n\n public async get(url: string): Promise<IOResponse<string>> {\n return this.http.getRaw(url, {\n metric: 'mkp-seller-auth-get',\n })\n }\n\n public async post(url: string, body: any): Promise<IOResponse<string>> {\n return this.http.postRaw(url, body, {\n metric: 'mkp-seller-auth-post',\n })\n }\n\n public async put(url: string, body: any): Promise<IOResponse<string>> {\n return this.http.putRaw(url, body, {\n metric: 'mkp-seller-auth-put',\n })\n }\n}\n\n```"
}
] |
code_mkp-seller-auth_33224a45
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mkp-seller-auth/node/clients/sellers.ts from the mkp-seller-auth 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 default class Sellers extends JanusClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(context, {\n ...options,\n headers: {\n ...options?.headers,\n VtexIdclientAutCookie:\n context.adminUserAuthToken ?? context.authToken ?? '',\n 'x-vtex-user-agent': context.userAgent,\n },\n })\n }\n\n // https://developers.vtex.com/vtex-rest-api/reference/catalog-api-get-seller-list\n public async getSellerList(\n tradePolicy?: string,\n sellerType?: string,\n isBetterScope?: boolean\n ): Promise<any> {\n let url = `/api/catalog_system/pvt/seller/list?an=${this.context.account}`\n\n if (tradePolicy) {\n url += `&${tradePolicy}`\n }\n\n if (sellerType) {\n url += `&${sellerType}`\n }\n\n if (isBetterScope) {\n url += `&${isBetterScope}`\n }\n\n return this.http.getRaw(url, { metric: 'seller-list' })\n }\n}\n\n```"
}
] |
code_mkp-seller-auth_4a41caf1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mkp-seller-auth/node/clients/index.ts from the mkp-seller-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\n\nimport ExecuteCall from './executeCall'\nimport Sellers from './sellers'\nimport Affiliations from './affiliations'\nimport VtexID from './vtexid'\n\n// Extend the default IOClients implementation with our own custom clients.\nexport class Clients extends IOClients {\n public get executeCallClient() {\n return this.getOrSet('executeCallClient', ExecuteCall)\n }\n\n public get vtexid() {\n return this.getOrSet('vtexid', VtexID)\n }\n\n public get sellers() {\n return this.getOrSet('sellers', Sellers)\n }\n\n public get affiliations() {\n return this.getOrSet('affiliations', Affiliations)\n }\n}\n\n```"
}
] |
code_mkp-seller-auth_be190dc5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mkp-seller-auth/node/clients/affiliations.ts from the mkp-seller-auth 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 default class Affiliations extends JanusClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(context, {\n ...options,\n headers: {\n ...options?.headers,\n VtexIdclientAutCookie:\n context.adminUserAuthToken ?? context.authToken ?? '',\n 'x-vtex-user-agent': context.userAgent,\n },\n })\n }\n\n // https://developers.vtex.com/vtex-rest-api/reference/affiliations\n public async getAffiliationsList(): Promise<any> {\n const url = `/api/fulfillment/pvt/affiliates`\n\n return this.http.getRaw(url, { metric: 'seller-list' })\n }\n}\n\n```"
}
] |
code_mkp-seller-auth_72a885d3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mkp-seller-auth/node/middlewares/executeCall.ts from the mkp-seller-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { UserInputError } from '@vtex/api'\n\nexport async function executeCall(ctx: Context, next: () => Promise<any>) {\n const {\n vtex: { logger },\n state: { requestBody },\n clients: { executeCallClient },\n } = ctx\n\n // console.info('executeCall Received requestHeaders:', requestHeaders)\n // console.info('executeCall Received requestBody:', requestBody)\n\n let response\n\n switch (requestBody.method) {\n case 'get':\n response = await executeCallClient.get(requestBody.url)\n break\n\n case 'post':\n response = await executeCallClient.post(requestBody.url, requestBody.body)\n break\n\n case 'put':\n response = await executeCallClient.put(requestBody.url, requestBody.body)\n break\n\n default:\n logger.error({\n message: 'Invalid body',\n data: {\n requestBody,\n },\n })\n throw new UserInputError('Invalid method. It must be get, post or put')\n }\n\n ctx.body = response.data\n ctx.status = response.status\n\n await next()\n}\n\n```"
}
] |
code_mkp-seller-auth_fbb7de72
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mkp-seller-auth/node/middlewares/healthcheck.ts from the mkp-seller-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport async function healthcheck(ctx: Context, next: () => Promise<any>) {\n ctx.status = 200\n ctx.body = { timestamp: Date.now() }\n\n await next()\n}\n\n```"
}
] |
code_mkp-seller-auth_0d5eaf19
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mkp-seller-auth/node/middlewares/validateRequest.ts from the mkp-seller-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { json } from 'co-body'\nimport { UserInputError } from '@vtex/api'\n\nexport async function validateRequest(ctx: Context, next: () => Promise<any>) {\n const {\n vtex: {\n logger,\n route: { params },\n },\n } = ctx\n\n const body = await json(ctx.req)\n // console.info('validateRequest Received params:', params)\n // console.info('validateRequest Received body: ', body)\n\n if (body.accountType !== 'seller' && body.accountType !== 'marketplace') {\n logger.error({\n message: 'Invalid body',\n data: {\n body,\n },\n })\n throw new UserInputError(\n 'Invalid accountType. It must be seller or marketplace'\n )\n }\n\n if (\n body.method !== 'get' &&\n body.method !== 'post' &&\n body.method !== 'put'\n ) {\n logger.error({\n message: 'Invalid body',\n data: {\n body,\n },\n })\n throw new UserInputError('Invalid method. It must be get, post or put')\n }\n\n ctx.state.params = params\n ctx.state.requestBody = body\n ctx.state.requestHeaders = ctx.headers\n\n // console.info('validateRequest passed')\n\n await next()\n}\n\n```"
}
] |
code_mkp-seller-auth_5c50c54a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mkp-seller-auth/node/middlewares/validateVtexIdclientAutCookie.ts from the mkp-seller-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { AuthenticationError } from '@vtex/api'\n\nexport async function validateVtexIdclientAutCookie(\n ctx: Context,\n next: () => Promise<any>\n) {\n const {\n vtex: { logger },\n state: { requestHeaders, requesterTokenDetails },\n clients: { vtexid },\n } = ctx\n\n const tokenValidation = await vtexid.validate(\n requestHeaders.requestervtexidclientautcookie,\n requesterTokenDetails.account\n )\n\n if (tokenValidation.authStatus !== 'Success') {\n logger.error({\n message: 'Invalid RequesterVtexIdclientAutCookie',\n data: {\n requesterTokenDetails,\n },\n })\n throw new AuthenticationError(\n 'Invalid RequesterVtexIdclientAutCookie Header'\n )\n }\n\n // TODO\n // also review policies to align with this url to have a double validation\n // check params url to see if it's an url it can hit\n\n // const { url } = requestBody\n\n // if (url !== 'valid url to hit' && url !== 'other valid url to hit') {\n // throw new AuthenticationError('Invalid url')\n // }\n\n await next()\n}\n\n```"
}
] |
code_mkp-seller-auth_7d316779
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mkp-seller-auth/node/middlewares/checkConfiguration.ts from the mkp-seller-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport atob from 'atob'\nimport { NotFoundError } from '@vtex/api'\n\nfunction parseJwt(token: string) {\n const base64Url = token.split('.')[1]\n const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/')\n const jsonPayload = decodeURIComponent(\n atob(base64)\n .split('')\n .map((c: string) => {\n return `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`\n })\n .join('')\n )\n\n return JSON.parse(jsonPayload)\n}\n\n// TODO optimize this to avoid always iterating the whole array\nfunction listContainsAccountId(list: [], accountId: string) {\n // console.info('checkConfiguration accountId: ', accountId)\n const mapped = list.map((elem: any) => {\n console.info('checkConfiguration SellerId: ', elem.SellerId)\n\n return accountId === elem.SellerId\n })\n\n return mapped.includes(true)\n}\n\nexport async function checkConfiguration(\n ctx: Context,\n next: () => Promise<any>\n) {\n const {\n vtex: { logger },\n state: { requestBody, requestHeaders },\n clients: { sellers, affiliations },\n } = ctx\n\n const requesterTokenDetails = parseJwt(\n requestHeaders.requestervtexidclientautcookie\n )\n\n // console.warn(\n // 'checkConfiguration requesterTokenDetails: ',\n // requesterTokenDetails\n // )\n\n ctx.state.requesterTokenDetails = requesterTokenDetails\n\n let validConfig = false\n\n if (requestBody.accountType === 'seller') {\n // check account seller list\n const sellersListResponse = await sellers.getSellerList()\n\n validConfig = listContainsAccountId(\n sellersListResponse.data,\n requesterTokenDetails.account\n )\n } else if (requestBody.accountType === 'marketplace') {\n // check account affiliations\n const affiliationsListResponse = await affiliations.getAffiliationsList()\n const affiliatedMarketplaces = affiliationsListResponse.data.map( (affiliation: any) => {\n const splittedUri = affiliation.searchURIEndpoint.split('/')\n return { SellerId: splittedUri[splittedUri.length-2] }\n })\n validConfig = listContainsAccountId(\n affiliatedMarketplaces,\n requesterTokenDetails.account\n )\n }\n\n if (!validConfig) {\n logger.error({\n message: 'Invalid configuration',\n data: {\n requesterTokenDetails,\n },\n })\n throw new NotFoundError(\n 'Configuration for account not found. If seller check affiliations (https://{account}.myvtex.com/admin/checkout/#/affiliates). If marketplace check sellers list (https://{account}.myvtex.com/admin/Site/Seller.aspx)'\n )\n }\n\n await next()\n}\n\n```"
}
] |
code_mkp-seller-auth_7b5ba5e5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mkp-seller-auth/node/__tests__/simple.test.ts from the mkp-seller-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n// You can import your files here for testing them\n//\n// More info: https://github.com/sapegin/jest-cheat-sheet\n\ndescribe('simpleTest', () => {\n it('one test case', async () => {\n expect(0.2 + 0.1).not.toBe(0.3)\n })\n})\n\n```"
}
] |
code_cybersource-payer-auth_df364d8d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cybersource-payer-auth/pages/pages.json from the cybersource-payer-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"extensions\": {\n \"checkout/transactions/cybersource-payer-auth\": {\n \"component\": \"index\"\n }\n }\n}\n\n```"
}
] |
code_cybersource-payer-auth_a1ee9008
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cybersource-payer-auth/react/index.tsx from the cybersource-payer-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n/* eslint-disable no-console */\nimport React, { Component } from 'react'\nimport { Modal, Alert, Spinner } from 'vtex.styleguide'\n\ninterface CyberSourceAuthenticationProps {\n appPayload: string\n}\n\ndeclare const $: any\ndeclare const vtex: any\n\nclass CybersourcePayerAuth extends Component<CyberSourceAuthenticationProps> {\n private formRef: React.RefObject<HTMLFormElement>\n private formRefStepUp: React.RefObject<HTMLFormElement>\n\n constructor(\n props:\n | CyberSourceAuthenticationProps\n | Readonly<CyberSourceAuthenticationProps>\n ) {\n super(props)\n this.formRef = React.createRef<HTMLFormElement>()\n this.formRefStepUp = React.createRef<HTMLFormElement>()\n }\n\n public state = {\n submitted: false,\n renderStepUp: false,\n showAlert: false,\n height: '',\n width: '',\n stepUpUrl: '',\n stepUpAccessToken: '',\n createPaymentRequestReference: '',\n alertMessage: '',\n showSpinner: false,\n }\n\n public componentDidMount() {\n if (this.state.submitted) {\n return\n }\n\n window.addEventListener(\n 'message',\n async event => {\n if (\n event.origin !== 'https://centinelapistag.cardinalcommerce.com' &&\n event.origin !== 'https://centinelapi.cardinalcommerce.com'\n ) {\n return\n }\n\n const { createPaymentRequestReference } = JSON.parse(\n this.props.appPayload\n )\n\n this.setState({\n ...this.state,\n createPaymentRequestReference,\n })\n\n const payAuthRequest = await fetch(\n `/cybersource/payer-auth/${createPaymentRequestReference}`,\n {\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n 'Cache-Control': 'no-cache',\n },\n }\n )\n\n const payAuthResponse = await payAuthRequest.json()\n\n if (\n payAuthResponse.status === 'AUTHENTICATION_SUCCESSFUL' ||\n payAuthResponse.status === 'AUTHORIZED'\n ) {\n this.respondTransaction(true)\n } else if (\n payAuthResponse.status === 'DECLINED' ||\n payAuthResponse.status === 'REFUSED' ||\n payAuthResponse.status === 'AUTHENTICATION_FAILED'\n ) {\n this.verifyStatus(createPaymentRequestReference)\n } else if (payAuthResponse.status === 'PENDING_AUTHENTICATION') {\n const dec = atob(\n payAuthResponse.consumerAuthenticationInformation.pareq\n )\n\n const decObj = JSON.parse(dec)\n\n this.renderStepUp(\n decObj.challengeWindowSize,\n payAuthResponse.consumerAuthenticationInformation.stepUpUrl,\n payAuthResponse.consumerAuthenticationInformation.accessToken\n )\n\n if (this.formRefStepUp.current) {\n this.formRefStepUp.current.submit()\n this.setState({ submitted: true })\n }\n\n this.verifyStatus(createPaymentRequestReference)\n } else {\n this.verifyStatus(createPaymentRequestReference)\n }\n },\n false\n )\n\n if (this.formRef.current) {\n this.formRef.current.submit()\n this.setState({ submitted: true })\n }\n }\n\n public respondTransaction(status: boolean) {\n $(window).trigger('transactionValidation.vtex', [status])\n }\n\n public render() {\n const { deviceDataCollectionUrl, accessToken } = JSON.parse(\n this.props.appPayload\n )\n\n return (\n <>\n <iframe\n id=\"cardinal_collection_iframe\"\n title=\"Cardinal Collection Iframe\"\n name=\"collectionIframe\"\n height=\"10\"\n width=\"10\"\n style={{ display: 'none' }}\n />\n <form\n ref={this.formRef}\n id=\"cardinal_collection_form\"\n method=\"POST\"\n target=\"collectionIframe\"\n action={deviceDataCollectionUrl}\n >\n <input\n id=\"cardinal_collection_form_input\"\n type=\"hidden\"\n name=\"JWT\"\n value={accessToken}\n />\n </form>\n {this.state.renderStepUp && (\n <Modal isOpen={true} showCloseIcon={false}>\n <iframe\n name=\"step-up-iframe\"\n height={this.state.height}\n width={this.state.width}\n />\n <form\n ref={this.formRefStepUp}\n id=\"step-up-form\"\n method=\"POST\"\n target=\"step-up-iframe\"\n action={this.state.stepUpUrl}\n >\n <input\n type=\"hidden\"\n name=\"JWT\"\n value={this.state.stepUpAccessToken}\n />\n <input\n type=\"hidden\"\n name=\"MD\"\n value={this.state.createPaymentRequestReference}\n />\n </form>\n </Modal>\n )}\n {this.state.showAlert && (\n <Alert type=\"error\" onClose={() => this.respondTransaction(false)}>\n {this.state.alertMessage}\n </Alert>\n )}\n {this.state.showSpinner && <Spinner />}\n </>\n )\n }\n\n public renderStepUp(\n challengeWindowSize: string,\n stepUpUrl: string,\n accessToken: string\n ) {\n // Width x Height\n // 01 250 x 400\n // 02 390 x 400\n // 03 500 x 600\n // 04 600 x 400\n // 05 Full screen\n const widthArr = [250, 390, 500, 600, 1200]\n const heightArr = [400, 400, 600, 400, 800]\n let windowSize = +challengeWindowSize\n\n windowSize -= 1\n this.setState({\n ...this.state,\n height: heightArr[windowSize].toString(),\n width: widthArr[windowSize].toString(),\n stepUpUrl,\n stepUpAccessToken: accessToken,\n renderStepUp: true,\n })\n vtex.checkout.MessageUtils.hidePaymentMessage()\n }\n\n public showAlert(alertMessage: string) {\n this.setState({\n ...this.state,\n alertMessage,\n showAlert: true,\n renderStepUp: false,\n })\n }\n\n public verifyStatus(createPaymentRequestReference: string) {\n const checkAuthStatus = setInterval(async () => {\n const authStatus = await fetch(\n `/cybersource/payer-auth/status/${createPaymentRequestReference}`,\n {\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n 'Cache-Control': 'no-cache',\n },\n }\n )\n\n const authStatusResponse = await authStatus.json()\n\n if (authStatusResponse === 'approved') {\n this.respondTransaction(true)\n clearInterval(checkAuthStatus)\n } else if (authStatusResponse === 'denied') {\n this.respondTransaction(false)\n clearInterval(checkAuthStatus)\n }\n\n this.setState({ ...this.state, showSpinner: true })\n }, 3000)\n }\n}\n\nexport default CybersourcePayerAuth\n\n```"
}
] |
code_cybersource-payer-auth_885c2054
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cybersource-payer-auth/react/index.css from the cybersource-payer-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n.wrapper {\n align-items: center;\n background: white;\n display: flex;\n flex-direction: column;\n height: 500px;\n justify-content: center;\n left: 0;\n margin-left: auto;\n margin-right: auto;\n position: absolute;\n right: 0;\n width: 500px;\n top: 0;\n box-shadow: 0px 0px 26px 0px rgba(0, 0, 0, 0.42);\n z-index: 999;\n}\n\n.buttonDanger {\n color: #fff;\n background-color: #d9534f;\n border-color: #d43f3a;\n}\n\n.buttonSuccess {\n color: #fff;\n background-color: #8bc34a;\n border-color: #8bc34a;\n}\n\n.appPayload {\n width: 100%;\n word-break: break-word;\n}\n\n```"
}
] |
code_cybersource-payer-auth_02f44aab
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cybersource-payer-auth/react/package.json from the cybersource-payer-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"cybersource-payer-auth\",\n \"version\": \"0.0.6\",\n \"main\": \"index.js\",\n \"license\": \"UNLICENSED\",\n \"dependencies\": {\n \"react\": \"^16.8.6\",\n \"react-apollo\": \"^3.1.5\",\n \"apollo-client\": \"^2.6.4\",\n \"graphql\": \"^14.3.1\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^10.14.4\",\n \"@types/react\": \"^16.8.8\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@7.45.0/public/@types/vtex.render-runtime\"\n }\n}\n\n```"
}
] |
code_cybersource-payer-auth_caaf6001
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cybersource-payer-auth/react/mutations/payerAuthorize.gql from the cybersource-payer-auth VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation PayerAuthorize($paymentId: String) {\n payerAuthorize(app: \"vtex.cybersource\", paymentId: $paymentId)\n @context(provider: \"vtex.apps-graphql\") {\n message\n }\n}\n\n```"
}
] |
code_b2b-supplier_1c3b92e7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/sl.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"Vaša organizacija trenutno ni odobrena za oddajanje naročil v tej trgovini. Če je tako že nekaj časa in menite, da gre za napako, se obrnite na nas.\",\n \"store/b2b-auth.signup\": \"Vpis\",\n \"store/b2b-supplier.creating-buyer-org\": \"Ustvarjanje organizacije kupcev pri dobavitelju\"\n}\n\n```"
}
] |
code_b2b-supplier_298903de
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/nl.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"Uw organisatie is momenteel niet goedgekeurd om bestellingen te plaatsen op deze winkel. Als dit al een tijdje zo is en u denkt dat dit een fout is, neem dan contact met ons op.\",\n \"store/b2b-auth.signup\": \"Registreren\",\n \"store/b2b-supplier.creating-buyer-org\": \"Koperorganisatie aanmaken in de leverancier\"\n}\n\n```"
}
] |
code_b2b-supplier_abac9e47
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/ru.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"В настоящее время ваша организация не имеет права размещать заказы в этом магазине. Свяжитесь с нами, если такая ситуация продолжается довольно долго, и вы считаете это ошибкой.\",\n \"store/b2b-auth.signup\": \"Зарегистрироваться\",\n \"store/b2b-supplier.creating-buyer-org\": \"Создание организации-покупателя у поставщика\"\n}\n\n```"
}
] |
code_b2b-supplier_ddda0d48
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/pl.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"Twoja organizacja nie jest obecnie zatwierdzona do składania zamówień w tym sklepie. Jeśli tak jest od jakiegoś czasu i uważasz, że to błąd, prosimy o kontakt.\",\n \"store/b2b-auth.signup\": \"Zarejestruj się\",\n \"store/b2b-supplier.creating-buyer-org\": \"Tworzenie organizacji nabywcy w dostawcy\"\n}\n\n```"
}
] |
code_b2b-supplier_086a59a8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/uk.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"Наразі ваша організація не має права розміщувати замовлення в цьому магазині. Зв’яжіться з нами, якщо така ситуація триває доволі довго, і ви вважаєте це помилкою.\",\n \"store/b2b-auth.signup\": \"Зареєструватися\",\n \"store/b2b-supplier.creating-buyer-org\": \"Створення організації-покупця у постачальника\"\n}\n\n```"
}
] |
code_b2b-supplier_185b5834
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/fi.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"Organisaatiosi ei ole saanut hyväksyntää tehdä tilauksia tässä kaupassa juuri nyt. Jos tilanne on kestänyt jo hetken ja uskot tämän olevan virhe, ota meihin yhteyttä.\",\n \"store/b2b-auth.signup\": \"Rekisteröidy\",\n \"store/b2b-supplier.creating-buyer-org\": \"Ostajaorganisaation luonti toimittajalle\"\n}\n\n```"
}
] |
code_b2b-supplier_79da1b55
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/sk.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"Vaša organizácia momentálne nie je schválená na zadávanie objednávok v tomto obchode. Ak je to tak už nejaký čas a myslíte si, že ide o chybu, kontaktujte nás.\",\n \"store/b2b-auth.signup\": \"Registrovať sa\",\n \"store/b2b-supplier.creating-buyer-org\": \"Vytvorenie organizácie nákupcu u dodávateľa\"\n}\n\n```"
}
] |
code_b2b-supplier_19ad589c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/pt.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"Sua organização não foi aprovada para fazer pedidos nesta loja. Se essa situação já está assim há algum tempo e você acha que pode ser um erro, entre em contato conosco.\",\n \"store/b2b-auth.signup\": \"Cadastre-se\",\n \"store/b2b-supplier.creating-buyer-org\": \"Criando organização de compradores no fornecedor\"\n}\n\n```"
}
] |
code_b2b-supplier_eda779d0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/en.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"Your organization is not approved to place orders in this store right now. If it’s been like this for a while and you think this is a mistake, please contact us.\",\n \"store/b2b-auth.signup\": \"Sign Up\",\n \"store/b2b-supplier.creating-buyer-org\": \"Creating buyer organization in supplier\"\n}\n\n```"
}
] |
code_b2b-supplier_124d13c3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/it.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"Al momento, la tua azienda non è autorizzata a effettuare ordini su questo negozio. Se la situazione si protrae da tempo e pensi a un errore, ti preghiamo di contattarci.\",\n \"store/b2b-auth.signup\": \"Registrati\",\n \"store/b2b-supplier.creating-buyer-org\": \"Creazione di un'organizzazione di acquirenti presso i fornitori\"\n}\n\n```"
}
] |
code_b2b-supplier_6d429060
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/fr.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"Votre organisation n'est pas autorisée à passer des commandes sur ce magasin pour le moment. Si cela a été comme ça pendant un certain temps et que vous pensez que c'est une erreur, veuillez nous contacter.\",\n \"store/b2b-auth.signup\": \"S'inscrire\",\n \"store/b2b-supplier.creating-buyer-org\": \"Créer une organisation d'acheteurs dans fournisseur\"\n}\n\n```"
}
] |
code_b2b-supplier_6cf40552
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/el.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"Ο οργανισμός σας δεν είναι εγκεκριμένος για παραγγελίες σε αυτό το κατάστημα αυτή τη στιγμή. Εάν αυτό συμβαίνει εδώ και καιρό και πιστεύετε ότι πρόκειται για λάθος, παρακαλούμε επικοινωνήστε μαζί μας.\",\n \"store/b2b-auth.signup\": \"Εγγραφή\",\n \"store/b2b-supplier.creating-buyer-org\": \"Δημιουργία οργάνωσης αγοραστών στον προμηθευτή\"\n}\n\n```"
}
] |
code_b2b-supplier_5a3d4094
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/bg.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"Организацията ви не е одобрена да прави поръчки в този магазин в момента. Ако това е така от известно време и смятате, че става въпрос за грешка, моля, свържете се с нас.\",\n \"store/b2b-auth.signup\": \"Регистриране\",\n \"store/b2b-supplier.creating-buyer-org\": \"Създаване на организация на купувача при доставчика\"\n}\n\n```"
}
] |
code_b2b-supplier_5120fb29
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/ro.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"În acest moment, organizația ta nu are aprobare să plaseze comenzi în acest magazin. În cazul în care acest lucru persistă de mai mult timp, te rugăm să ne contactezi.\",\n \"store/b2b-auth.signup\": \"Înregistrare\",\n \"store/b2b-supplier.creating-buyer-org\": \"Crearea unei organizații de cumpărători în furnizor\"\n}\n\n```"
}
] |
code_b2b-supplier_c4d0b824
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/ca.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"La vostra empresa no disposa de l'aprovació necessària per fer comandes a aquesta botiga ara mateix. Si aquesta situació fa temps que es produeix i creieu que es tracta d'un error, poseu-vos en contacte amb nosaltres.\",\n \"store/b2b-auth.signup\": \"Registra't\",\n \"store/b2b-supplier.creating-buyer-org\": \"S'està creant l'empresa del comprador a la base de dades del proveïdor\"\n}\n\n```"
}
] |
code_b2b-supplier_34668262
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/ko.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"귀하의 조직은 현재 이 스토어에서 주문하도록 승인되지 않았습니다. 한동안 이러다가 실수라고 생각되시면 연락주세요.\",\n \"store/b2b-auth.signup\": \"등록\",\n \"store/b2b-supplier.creating-buyer-org\": \"공급자에서 구매자 조직 생성\"\n}\n\n```"
}
] |
code_b2b-supplier_a006ba51
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/cs.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"Vaše organizace aktuálně nemůže zadávat objednávky v tomto obchodě. Pokud se tak děje již delší dobu a myslíte si, že se jedná o chybu, kontaktujte nás.\",\n \"store/b2b-auth.signup\": \"Zaregistrujte se\",\n \"store/b2b-supplier.creating-buyer-org\": \"Vytvoření organizace odběratelů u dodavatele\"\n}\n\n```"
}
] |
code_b2b-supplier_8bfec9c1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/id.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"Organisasi Anda tidak disetujui untuk membuat pesanan di toko ini saat ini. Jika hal ini telah lama terjadi dan menurut Anda ini kesalahan, harap hubungi kami.\",\n \"store/b2b-auth.signup\": \"Daftar\",\n \"store/b2b-supplier.creating-buyer-org\": \"Membuat organisasi pembeli di pemasok\"\n}\n\n```"
}
] |
code_b2b-supplier_17d585bf
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/no.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"Organisasjonen din er ikke godkjent for å legge inn bestillinger i denne butikken akkurat nå. Ta kontakt med oss hvis det har vært slik en stund og du tror dette er en feil.\",\n \"store/b2b-auth.signup\": \"Registrer deg\",\n \"store/b2b-supplier.creating-buyer-org\": \"Oppretter innkjøperorganisasjon i leverandør\"\n}\n\n```"
}
] |
code_b2b-supplier_cbd511f1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/da.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"Din organisation er ikke godkendt til at placere ordrer i denne butik lige nu. Hvis det har været sådan i et stykke tid, og du mener, at der er tale om en fejl, bedes du kontakte os.\",\n \"store/b2b-auth.signup\": \"Tilmeld\",\n \"store/b2b-supplier.creating-buyer-org\": \"Oprettelse af en køberorganisation hos leverandøren\"\n}\n\n```"
}
] |
code_b2b-supplier_311bca4e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-supplier/messages/th.json from the b2b-supplier VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/b2b-approved-message.message\": \"ขณะนี้ องค์กรของคุณไม่ได้รับอนุญาตให้ออกคำสั่งซื้อในร้านค้าแห่งนี้ หากเป็นเช่นนี้นานเกินไปและคุณคิดว่าระบบมีข้อผิดพลาด โปรดติดต่อเรา\",\n \"store/b2b-auth.signup\": \"ลงชื่อ\",\n \"store/b2b-supplier.creating-buyer-org\": \"การสร้างองค์กรผู้ซื้อสำหรับซัพพลายเออร์\"\n}\n\n```"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.