id
stringlengths 12
53
| messages
listlengths 3
3
|
|---|---|
code_doc-prop_9e07666a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of doc-prop/react/typings/svg.d.ts from the doc-prop VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.svg' {\n const path: string\n export default path\n}\n\n```"
}
] |
code_doc-prop_e36ac176
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of doc-prop/react/typings/global.d.ts from the doc-prop VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface Window extends Window, GlobalThis {\n __RENDER_8_COMPONENTS__: any\n __RUNTIME__: any\n}\n\ninterface ObjSchemaInterface {\n type: string\n enum?: string[]\n enumNames?: string[]\n properties: Record<string, ObjSchemaInterface>\n items?: Record<string, ObjSchemaInterface>\n}\n\ninterface ComponentDataInterface {\n schema: Record<string, ObjSchemaInterface>\n messages: Record<string, Record<string, string>>\n}\n\ninterface CustomComponent {\n component?: JSX.Element\n typeName?: string\n}\n\n```"
}
] |
code_doc-prop_49b456d8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of doc-prop/react/typings/css.d.ts from the doc-prop VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n interface Style {\n [key: string]: string\n }\n const style: Style\n export default style\n}\n\n```"
}
] |
code_doc-prop_50cc9d7e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of doc-prop/react/typings/graphql.d.ts from the doc-prop 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_doc-prop_b5da86d1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of doc-prop/react/typings/vtex.styleguide.d.ts from the doc-prop VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/camelcase */\ndeclare module 'vtex.styleguide' {\n export const Alert\n export const Button\n export const ButtonWithIcon\n export const ButtonPlain\n export const PageBlock\n export const IconCaretDown\n export const IconCaretUp\n export const IconCaretRight\n export const IconBars\n export const IconCheck\n export const IconDeny\n export const Spinner\n export const EmptyState\n export const Card\n export const Dropdown\n export const Link\n export const InputSearch\n export const IconSearch\n export const EXPERIMENTAL_Table\n export const EXPERIMENTAL_useTableMeasures\n export const EXPERIMENTAL_useTableProportion\n}\n\n```"
}
] |
code_doc-prop_f79c9780
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of doc-prop/react/utils/capitalizeFirst.ts from the doc-prop VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport function capitalizeFirst(toCapitalize: string) {\n return toCapitalize.charAt(0).toUpperCase() + toCapitalize.slice(1)\n}\n\n```"
}
] |
code_doc-prop_ffbdfa8d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of doc-prop/react/utils/constants.ts from the doc-prop VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const IO_DOCUMENTATION = 'vtex.io-documentation@0.x'\nexport const CSE_CX = '017314625344810072686:u6y7vlxadyu'\nexport const CSE_KEY = 'AIzaSyBgix5AaPDcyu6QbboYdAYjQPsOJtZLOdw'\nexport const DOC_PROP_PLACEHOLDER_MATCH = '/%PROPS=([^%]+)/i'\nexport const DOC_PROP_PLACEHOLDER = '%PROPS'\nexport const LANG = 'en'\n\n```"
}
] |
code_doc-prop_cf9f1f57
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of doc-prop/react/components/ArrayTable.tsx from the doc-prop VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport {\n EXPERIMENTAL_Table as Table,\n EXPERIMENTAL_useTableMeasures as useMeasures,\n EXPERIMENTAL_useTableProportion as useProportion,\n} from 'vtex.styleguide'\n\nimport { titleCell, codeCell } from './TableCellComponents'\nimport { mapCustomTypes } from '../hooks/mapCustomTypes'\nimport { capitalizeFirst } from '../utils/capitalizeFirst'\n\n/** Columns definition, must be an array */\nconst columns = [\n {\n /** Prop that this column represents */\n id: 'title',\n cellRenderer: ({ data }: { data: string }) => {\n return titleCell({ title: data })\n },\n /** Title that will appear on Header */\n title: (\n <span className=\"t-body fw5 c-muted-1 bw1 pa2 pb3 b--muted-3 tl\">\n <FormattedMessage id=\"docProp.table.title\" />\n </span>\n ),\n /** Fixed width */\n maxWidth: 20,\n },\n {\n id: 'type',\n cellRenderer: ({ data }: { data: string }) => {\n return codeCell({ code: data })\n },\n title: (\n <p className=\"t-body fw5 c-muted-1 bw1 pa2 pb3 b--muted-3 tl\">\n <FormattedMessage id=\"docProp.table.type\" />\n </p>\n ),\n },\n]\n\nfunction mapArrayToNames(arrayProp: Record<string, ObjSchemaInterface>) {\n return Object.entries(arrayProp).map(([key, { type }]: any) => ({\n title: key,\n type,\n }))\n}\n\nconst ArrayTable: FC<ArrayTableProps> = ({\n propArray,\n propTitle,\n messages,\n}) => {\n const customTypes = mapCustomTypes(propArray, messages)\n const data = mapArrayToNames(customTypes.mappedProps)\n const measures = useMeasures({ size: data.length + 1 || 3 })\n const { sizedColumns } = useProportion({ columns, ratio: [0.5, 0.5] })\n\n return (\n <div className=\"overflow-x-auto\">\n <div className=\"t-body c-on-base mt1 lh-copy mb1 pb1\">\n <div className=\"mb4\">\n <FormattedMessage id=\"docProp.arrayTable.title\" />\n <span className=\"pv1 ph2 mw6 br2 bg-muted-5 ba b--muted-3 t-code c-emphasis\">\n {capitalizeFirst(propTitle)}\n </span>\n </div>\n <div className=\"mb7\">\n <Table\n measures={measures}\n items={data}\n columns={sizedColumns}\n highlightOnHover\n />\n </div>\n <div className=\"mt4 mb4\">{customTypes.mappedTypes}</div>\n </div>\n </div>\n )\n}\n\ninterface ArrayTableProps {\n propArray: Record<string, ObjSchemaInterface>\n messages: Record<string, Record<string, string>>\n propTitle: string\n}\n\nexport default ArrayTable\n\n```"
}
] |
code_doc-prop_4febfba2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of doc-prop/react/components/EnumTable.tsx from the doc-prop VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport {\n EXPERIMENTAL_Table as Table,\n EXPERIMENTAL_useTableMeasures as useMeasures,\n EXPERIMENTAL_useTableProportion as useProportion,\n} from 'vtex.styleguide'\n\nimport { descriptionCell, titleCell } from './TableCellComponents'\nimport { capitalizeFirst } from '../utils/capitalizeFirst'\nimport { LANG } from '../utils/constants'\n\n/** Columns definition, must be an array */\nconst columns = [\n {\n /** Prop that this column represents */\n id: 'title',\n cellRenderer: ({ data }: { data: string }) => {\n return titleCell({ title: data })\n },\n /** Title that will appear on Header */\n title: (\n <span className=\"t-body fw5 c-muted-1 bw1 pa2 pb3 b--muted-3 tl\">\n <FormattedMessage id=\"docProp.table.title\" />\n </span>\n ),\n /** Fixed width */\n maxWidth: 20,\n },\n {\n id: 'description',\n cellRenderer: ({ data }: { data: string }) => {\n return descriptionCell({ description: data })\n },\n title: (\n <p className=\"t-body fw5 c-muted-1 bw1 pa2 pb3 b--muted-3 tl\">\n <FormattedMessage id=\"docProp.table.type\" />\n </p>\n ),\n },\n]\n\nfunction mapEnumToNames(\n keys: string[],\n names: string[],\n messages: Record<string, Record<string, string>>\n) {\n return keys.map((key: string, index: number) => ({\n title: key,\n description: messages[LANG][names[index]],\n }))\n}\n\nconst EnumTable: FC<EnumTableProps> = ({ enumProps, messages, propTitle }) => {\n let data: { title: string; description: string }[] = []\n\n if (enumProps.enum && enumProps.enumNames) {\n data = mapEnumToNames(enumProps.enum, enumProps.enumNames, messages)\n }\n\n const measures = useMeasures({ size: data.length + 1 || 3 })\n const { sizedColumns } = useProportion({ columns, ratio: [0.5, 0.5] })\n\n return (\n <div className=\"overflow-x-auto\">\n <div className=\"t-body c-on-base mt1 lh-copy mb1 pb1\">\n <div className=\"mb4\">\n <FormattedMessage id=\"docProp.enumTable.title\" />\n <span className=\"pv1 ph2 mw6 br2 bg-muted-5 ba b--muted-3 t-code c-emphasis\">\n {capitalizeFirst(propTitle)}\n </span>\n </div>\n <div className=\"mb7\">\n <Table\n measures={measures}\n items={data}\n columns={sizedColumns}\n highlightOnHover\n />\n </div>\n </div>\n </div>\n )\n}\n\ninterface EnumTableProps {\n enumProps: ObjSchemaInterface\n messages: Record<string, Record<string, string>>\n propTitle: string\n}\n\nexport default EnumTable\n\n```"
}
] |
code_doc-prop_c387c7e7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of doc-prop/react/components/ObjectsTable.tsx from the doc-prop VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport {\n EXPERIMENTAL_Table as Table,\n EXPERIMENTAL_useTableMeasures as useMeasures,\n EXPERIMENTAL_useTableProportion as useProportion,\n} from 'vtex.styleguide'\n\nimport { titleCell, codeCell } from './TableCellComponents'\nimport { mapCustomTypes } from '../hooks/mapCustomTypes'\nimport { capitalizeFirst } from '../utils/capitalizeFirst'\n\nconst customTypes: JSX.Element[] = []\n\nconst columns = [\n {\n /** Prop that this column represents */\n id: 'title',\n cellRenderer: ({ data }: { data: string }) => {\n return titleCell({ title: data })\n },\n /** Title that will appear on Header */\n title: (\n <span className=\"t-body fw5 c-muted-1 bw1 pa2 pb3 b--muted-3 tl\">\n <FormattedMessage id=\"docProp.table.title\" />\n </span>\n ),\n /** Fixed width */\n maxWidth: 20,\n },\n {\n id: 'type',\n cellRenderer: ({ data }: { data: string }) => {\n return codeCell({ code: data })\n },\n title: (\n <p className=\"t-body fw5 c-muted-1 bw1 pa2 pb3 b--muted-3 tl\">\n <FormattedMessage id=\"docProp.table.type\" />\n </p>\n ),\n },\n]\n\nfunction mapObjectsToNames(objectProp: Record<string, ObjSchemaInterface>) {\n return Object.entries(objectProp).map(([key, { type }]: any) => ({\n title: key,\n type,\n }))\n}\n\nconst ObjectsTable: FC<ObjectTableProps> = ({\n objectProp,\n propTitle,\n messages,\n}) => {\n const data = mapObjectsToNames(\n mapCustomTypes(objectProp, messages).mappedProps\n )\n const measures = useMeasures({ size: data.length + 1 || 3 })\n const { sizedColumns } = useProportion({ columns, ratio: [0.5, 0.5] })\n\n return (\n <div className=\"overflow-x-auto\">\n <div className=\"t-body c-on-base mt1 lh-copy mb1 pb1\">\n <div className=\"mb4\">\n <FormattedMessage id=\"docProp.objectTable.title\" />\n <span className=\"pv1 ph2 mw6 br2 bg-muted-5 ba b--muted-3 t-code c-emphasis\">\n {capitalizeFirst(propTitle)}\n </span>\n </div>\n <div className=\"mb7\">\n <Table\n measures={measures}\n items={data}\n columns={sizedColumns}\n highlightOnHover\n />\n </div>\n <div className=\"mt4 mb4\">{customTypes}</div>\n </div>\n </div>\n )\n}\n\ninterface ObjectTableProps {\n objectProp: Record<string, ObjSchemaInterface>\n messages: Record<string, Record<string, string>>\n propTitle: string\n}\n\nexport default ObjectsTable\n\n```"
}
] |
code_doc-prop_383a88f0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of doc-prop/react/components/TableCellComponents.tsx from the doc-prop VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\n\nexport const titleCell: FC<{ title: string }> = ({ title }) => (\n <span\n className={'pv1 ph2 mw6 br2 bg-muted-5 ba b--muted-3 t-code c-emphasis'}>\n {title}\n </span>\n)\n\nexport const codeCell: FC<{ code: string }> = ({ code }) => (\n <span\n className={'pv1 ph2 mw6 br2 bg-muted-5 ba b--muted-3 t-code c-emphasis'}>\n {code}\n </span>\n)\n\nexport const descriptionCell: FC<{ description: string }> = ({\n description,\n}) => <span className={'pv1 ph2 br2 pv7'}>{description}</span>\n\n```"
}
] |
code_doc-prop_f1e46868
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of doc-prop/react/components/PropsTable.tsx from the doc-prop VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport {\n EXPERIMENTAL_Table as Table,\n EXPERIMENTAL_useTableMeasures as useMeasures,\n EXPERIMENTAL_useTableProportion as useProportion,\n} from 'vtex.styleguide'\n\nimport { titleCell, descriptionCell, codeCell } from './TableCellComponents'\nimport { mapCustomTypes } from '../hooks/mapCustomTypes'\nimport { capitalizeFirst } from '../utils/capitalizeFirst'\n\nconst lang = 'en'\n\n/** Columns definition, must be an array */\nconst columns = [\n {\n /** Prop that this column represents */\n id: 'title',\n cellRenderer: ({ data }: { data: string }) => {\n return titleCell({ title: data })\n },\n /** Title that will appear on Header */\n title: (\n <span className=\"t-body fw5 c-muted-1 bw1 pa2 pb3 b--muted-3 tl\">\n <FormattedMessage id=\"docProp.table.title\" />\n </span>\n ),\n /** Fixed width */\n maxWidth: 20,\n },\n {\n id: 'description',\n cellRenderer: ({ data }: { data: string }) => {\n return descriptionCell({ description: data })\n },\n title: (\n <p className=\"t-body fw5 c-muted-1 bw1 pa2 pb3 b--muted-3 tl\">\n <FormattedMessage id=\"docProp.table.description\" />\n </p>\n ),\n /** Fixed width */\n maxWidth: 50,\n },\n {\n id: 'type',\n cellRenderer: ({ data }: { data: string }) => {\n return codeCell({ code: data })\n },\n title: (\n <p className=\"t-body fw5 c-muted-1 bw1 pa2 pb3 b--muted-3 tl\">\n <FormattedMessage id=\"docProp.table.type\" />\n </p>\n ),\n },\n {\n id: 'default',\n cellRenderer: ({ data }: { data: string }) => {\n return codeCell({ code: data })\n },\n title: (\n <p className=\"t-body fw5 c-muted-1 tl\">\n <FormattedMessage id=\"docProp.table.defaultValue\" />\n </p>\n ),\n },\n]\n\nconst mapPropsToColumns = (\n propsObj: Record<string, ObjSchemaInterface>,\n messages: Record<string, Record<string, string>>\n) => {\n return Object.entries(propsObj).map(\n ([key, { description, type, default: defaultValue }]: any) => ({\n title: key,\n description: messages[lang][description],\n type: capitalizeFirst(type),\n default: defaultValue || 'null',\n })\n )\n}\n\nconst PropsTable: FC<PropTableProps> = ({ fetchedProps, fetchedMessages }) => {\n // help\n const customTypes = mapCustomTypes(fetchedProps, fetchedMessages)\n const data = mapPropsToColumns(\n customTypes.mappedProps,\n fetchedMessages\n ).map(data => ({ ...data, id: data.title }))\n const measures = useMeasures({ size: data.length + 1 || 3 })\n const { sizedColumns } = useProportion({ columns, ratio: [1, 0.5, 0.5, 1] })\n\n return (\n <div className=\"pa4\">\n <div className=\"overflow-x-auto mb7\">\n <Table\n measures={measures}\n items={data}\n columns={sizedColumns}\n highlightOnHover\n />\n </div>\n {customTypes.mappedTypes}\n </div>\n )\n}\n\ninterface PropTableProps {\n fetchedProps: Record<string, ObjSchemaInterface>\n fetchedMessages: Record<string, Record<string, string>>\n}\n\nexport default PropsTable\n\n```"
}
] |
code_doc-prop_bffdf7c8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of doc-prop/react/__tests__/index.test.tsx from the doc-prop VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\ndescribe('Placeholder test', () => {\n it('should work', () => {\n expect(1).toBe(1)\n })\n})\n\n```"
}
] |
code_doc-prop_e85b11ab
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of doc-prop/react/graphql/appAssets.graphql from the doc-prop VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery appAssets ($appId: String!, $renderMajor: Int!) {\n appAssets(appId:$appId, renderMajor: $renderMajor) {\n\t\tcomponentsJSON,\n interfacesJSON,\n messagesJSON\n }\n}\n\n```"
}
] |
code_doc-prop_78e0651c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of doc-prop/react/hooks/useComponentSchema.tsx from the doc-prop VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { useState, useEffect } from 'react'\nimport { useApolloClient } from 'react-apollo'\nimport { useRuntime } from 'vtex.render-runtime'\n\nimport appAssetsQuery from '../graphql/appAssets.graphql'\n\nconst RENDER_MAJOR = 8\n\nconst useComponentSchema = (appId: string, componentName: string) => {\n const [loading, setLoading] = useState(true)\n const [error, setError] = useState('')\n const [data, setData] = useState<ComponentDataInterface | null>(null)\n const { fetchComponents } = useRuntime()\n const client = useApolloClient()\n\n useEffect(() => {\n client\n .query({\n query: appAssetsQuery,\n variables: { appId, renderMajor: RENDER_MAJOR },\n })\n .then(({ data }: any) => {\n const {\n appAssets: { componentsJSON, messagesJSON },\n } = data\n const assetsList = JSON.parse(componentsJSON)\n const messagesFetched = JSON.parse(messagesJSON)\n\n const componentAssets = assetsList.length > 0 && assetsList[0]\n if (!componentAssets) {\n console.error(`Couldnt load component's asset`)\n }\n return fetchComponents(assetsList[0]).then(() => ({\n componentAssets,\n messagesFetched,\n }))\n })\n .then(({ componentAssets, messagesFetched }: any) => {\n if (!window.__RENDER_8_COMPONENTS__) {\n setError(error)\n }\n const componentData =\n window.__RENDER_8_COMPONENTS__[`${appId}/${componentName}`]\n if (componentData?.schema) {\n setData({\n schema: componentData.schema.properties,\n messages: messagesFetched,\n })\n }\n })\n .catch((error: { msg: any }) => {\n setError(error.msg)\n })\n .finally(() => {\n setLoading(false)\n })\n }, [])\n\n return {\n loading,\n error,\n data,\n }\n}\n\nexport default useComponentSchema\n\n```"
}
] |
code_doc-prop_2738f8b7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of doc-prop/react/hooks/mapCustomTypes.tsx from the doc-prop VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport EnumTable from '../components/EnumTable'\nimport ObjectsTable from '../components/ObjectsTable'\nimport ArrayTable from '../components/ArrayTable'\nimport { capitalizeFirst } from '../utils/capitalizeFirst'\n\nexport const mapCustomTypes = (\n propsObj: Record<string, ObjSchemaInterface>,\n messages: Record<string, Record<string, string>>\n) => {\n const mappedTypes: JSX.Element[] = []\n const mappedProps: Record<string, ObjSchemaInterface> = propsObj\n for (const key in mappedProps) {\n let currentComponent: JSX.Element | null = null\n const currentProp = mappedProps[key]\n if (currentProp.enum) {\n currentProp.type = `${capitalizeFirst(key)}Enum`\n currentComponent = (\n <EnumTable\n enumProps={currentProp}\n messages={messages}\n propTitle={currentProp.type}\n />\n )\n } else if (currentProp.type === 'object') {\n currentProp.type = capitalizeFirst(key)\n currentComponent = (\n <ObjectsTable\n objectProp={currentProp.properties}\n propTitle={currentProp.type}\n messages={messages}\n />\n )\n } else if (currentProp.type === 'array') {\n currentProp.type = `${capitalizeFirst(key)}[]`\n if (currentProp.items) {\n currentComponent = (\n <ArrayTable\n propArray={currentProp.items}\n propTitle={currentProp.type}\n messages={messages}\n />\n )\n }\n }\n currentProp.type = capitalizeFirst(currentProp.type)\n if (currentComponent) {\n mappedTypes.push(currentComponent)\n }\n }\n\n return { mappedTypes, mappedProps }\n}\n\n```"
}
] |
code_flow-finance-components_ff90ff4c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/messages/pt.json from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/flowFinance.accountCreate.introPage.title\": \"Financie sua compra sem complicações\",\n \"store/flowFinance.accountCreate.introPage.instructions\": \"Peça uma linha de crédito para pagar suas compras no {storePaymentName}\",\n \"store/flowFinance.accountCreate.introPage.leftIconTitle\": \"Fácil de pedir\",\n \"store/flowFinance.accountCreate.introPage.leftIconText\": \"Faça tudo online! Em até 24h seu crédito será analisado e liberado.\",\n \"store/flowFinance.accountCreate.introPage.rightIconTitle\": \"Simples de usar\",\n \"store/flowFinance.accountCreate.introPage.rightIconText\": \"Uma vez liberado, seu crédito aparecerá como uma opção de pagamento no {storePaymentName}\",\n \"store/flowFinance.accountCreate.introPage.continue\": \"Peça seu crédito\",\n \"store/flowFinance.accountCreate.introPage.poweredBy\": \"Desenvolvido por\",\n \"store/flowFinance.accountCreate.introPage.accountErrors.underReview\": \"Sua análise de crédito já está em andamento. Em breve você receberá uma mensagem com o resultado.\",\n \"store/flowFinance.accountCreate.introPage.accountErrors.approved\": \"Seu crédito foi aprovado e está disponível na página do checkout como Financiamento Gympass Plus.\",\n \"store/flowFinance.accountCreate.introPage.accountErrors.rejected\": \"Você tem um pedido de crédito rejeitado. Não é possível pedir uma nova linha de crédito no momento.\",\n \"store/flowFinance.accountCreate.cnpjLabel\": \"CNPJ\",\n \"store/flowFinance.accountCreate.cnpjError\": \"Insira um CNPJ válido.\",\n \"store/flowFinance.accountCreate.preQualify.notQualifiedMessage\": \"Infelizmente, você não é elegível para pedir uma linha de crédito {storePaymentName}.{lineBreak}{lineBreak}Mas você ainda pode fazer compras no nosso site, basta selecionar outra forma de pagamento no checkout.\",\n \"store/flowFinance.accountCreate.preQualify.instructions\": \"Confirme seu CNPJ e peça seu crédito. Se o CNPJ não está preenchido, informe o CNPJ (apenas números) associado a sua conta {storeName} antes de prosseguir.\",\n \"store/flowFinance.accountCreate.preQualify.submit\": \"Continuar\",\n \"store/flowFinance.accountCreate.continueShopping\": \"Continuar comprando\",\n \"store/flowFinance.accountCreate.companyNameLabel\": \"Razão social\",\n \"store/flowFinance.accountCreate.companyNameError\": \"Campo obrigatório.\",\n \"store/flowFinance.accountCreate.companyLegalNameLabel\": \"Nome fantasia\",\n \"store/flowFinance.accountCreate.companyLegalNameError\": \"Campo obrigatório.\",\n \"store/flowFinance.accountCreate.companyPhoneLabel\": \"Telefone\",\n \"store/flowFinance.accountCreate.companyPhoneError\": \"Insira um número de telefone válido.\",\n \"store/flowFinance.accountCreate.businessInfo.instructions\": \"Para fazer a análise de crédito, precisamos de algumas informações sobre seu negócio e o responsável pela empresa.\",\n \"store/flowFinance.accountCreate.businessInfo.submit\": \"Continuar\",\n \"store/flowFinance.accountCreate.addressNotApplicable\": \"Não aplicável\",\n \"store/flowFinance.accountCreate.personalInfo.instructions\": \"Para fazer a análise de crédito, precisamos de algumas informações sobre seu negócio e o responsável pela empresa.\",\n \"store/flowFinance.accountCreate.firstNameLabel\": \"Nome\",\n \"store/flowFinance.accountCreate.firstNameError\": \"Campo obrigatório.\",\n \"store/flowFinance.accountCreate.lastNameLabel\": \"Sobrenome\",\n \"store/flowFinance.accountCreate.lastNameError\": \"Campo obrigatório.\",\n \"store/flowFinance.accountCreate.cpfLabel\": \"CPF\",\n \"store/flowFinance.accountCreate.cpfError\": \"Digite um CPF válido.\",\n \"store/flowFinance.accountCreate.rgLabel\": \"RG\",\n \"store/flowFinance.accountCreate.rgError\": \"Campo obrigatório.\",\n \"store/flowFinance.accountCreate.rgExpLabel\": \"Data de expiração do RG (DD/MM/YYYY)\",\n \"store/flowFinance.accountCreate.rgExpError\": \"Campo obrigatório.\",\n \"store/flowFinance.accountCreate.personalPhoneLabel\": \"Telefone\",\n \"store/flowFinance.accountCreate.personalPhoneError\": \"Insira um número de telefone válido.\",\n \"store/flowFinance.accountCreate.pepLabel\": \"PEP (Pessoa Politicamente Exposta)\",\n \"store/flowFinance.accountCreate.pepText\": \"Conforme conceito definido na\",\n \"store/flowFinance.accountCreate.pepLinkText\": \"ICVM 301/99\",\n \"store/flowFinance.accountCreate.emailLabel\": \"E-mail\",\n \"store/flowFinance.accountCreate.emailError\": \"Insira um endereço de e-mail válido.\",\n \"store/flowFinance.accountCreate.maritalStatusLabel\": \"Estado civil\",\n \"store/flowFinance.accountCreate.maritalStatusError\": \"Campo obrigatório.\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.single\": \"Solteiro(a)\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.married\": \"Casado(a)\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.separated\": \"Separado(a)\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.divorced\": \"Divorciado(a)\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.widowed\": \"Viúvo(a)\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.other\": \"Outro\",\n \"store/flowFinance.accountCreate.personalInfo.submit\": \"Continuar\",\n \"store/flowFinance.accountCreate.documents.continueLabel\": \"Continuar\",\n \"store/flowFinance.accountCreate.documents.instructions\": \"Agora você precisa nos enviar uma cópia do contrato social e de um documento de identificação (CNH ou RG) com foto.\",\n \"store/flowFinance.accountCreate.documents.personalIdLabel\": \"Documento de identificação\",\n \"store/flowFinance.accountCreate.documents.uploadLabel\": \"Anexar\",\n \"store/flowFinance.accountCreate.documents.businessIdLabel\": \"Contrato social\",\n \"store/flowFinance.accountCreate.documents.fileSizeError\": \"Não conseguimos processar seu arquivo. Verifique o tamanho e o formato do arquivo selecionado.\",\n \"store/flowFinance.accountCreate.documents.genericError\": \"Ocorreu um erro. Por favor, tente novamente.\",\n \"store/flowFinance.accountCreate.documents.selectFileButton\": \"Selecione\",\n \"store/flowFinance.accountCreate.documents.cnhLabel\": \"CNH (carteira de motorista)\",\n \"store/flowFinance.accountCreate.documents.rgLabel\": \"RG (registro geral)\",\n \"store/flowFinance.accountCreate.documents.uploadInstructions\": \"Arraste o arquivo aqui{lineBreak}ou\",\n \"store/flowFinance.accountCreate.documents.fileRestrictions\": \"São permitidos apenas arquivos no formato {businessFileType}JPEG e PNG de no máximo {fileSize}MB.\",\n \"store/flowFinance.accountCreate.tosTitle\": \"Termos e Condições\",\n \"store/flowFinance.accountCreate.tosCheckboxLabel\": \"Aceitar os Termos de Uso e a Política de Privacidade\",\n \"store/flowFinance.accountCreate.submitApplication\": \"Enviar inscrição\",\n \"store/flowFinance.accountCreate.submitApplication.error\": \"Ocorreu um erro ao enviar sua inscrição. Por favor, tente novamente.\",\n \"store/flowFinance.accountCreate.successPage.title\": \"Estamos analisado o seu pedido\",\n \"store/flowFinance.accountCreate.successPage.message\": \"A análise de crédito pode levar até 24h.{lineBreak}{lineBreak}Em breve você receberá uma mensagem com o resultado da sua análise de crédito. Se aprovado, ele já estará disponível como opção de pagamento no {storePaymentName}.\",\n \"store/flowFinance.accountCreate.steps.businessInfo\": \"Dados da empresa\",\n \"store/flowFinance.accountCreate.steps.personalInfo\": \"Dados pessoais\",\n \"store/flowFinance.accountCreate.steps.documents\": \"Documentos\",\n \"store/flowFinance.productPromo.promoMessage\": \"Pague em até {installments}x de {pricePerInstallment}*\",\n \"store/flowFinance.productPromo.promoMessageLinkText\": \"Peça seu crédito agora\",\n \"store/flowFinance.productPromo.promoMessageSmallText\": \"* Parcela simulada com juros. As condições estão sujeitas à análise de crédito.\",\n \"admin/editor.flowFinance.promoMessageBlock.title\": \"Mensagem de promoção no fluxo de financiamento\",\n \"admin/editor.flowFinance.promoMessageBlock.description\": \"Mostra uma promoção com o preço parcelado e o link de cadastro da conta na página do produto.\",\n \"admin/editor.promoMessageBlock.interestRate.title\": \"Taxa de juros (1,5% = 0,015)\",\n \"admin/editor.promoMessageBlock.installments.title\": \"Número de parcelas\"\n}\n\n```"
}
] |
code_flow-finance-components_56301580
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/messages/en.json from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/flowFinance.accountCreate.introPage.title\": \"Finance your purchase hassle-free\",\n \"store/flowFinance.accountCreate.introPage.instructions\": \"Request a line of credit for your purchases with {storePaymentName}\",\n \"store/flowFinance.accountCreate.introPage.leftIconTitle\": \"Easy to apply\",\n \"store/flowFinance.accountCreate.introPage.leftIconText\": \"It's all online! Your credit is analyzed and approved in up to 24 hours.\",\n \"store/flowFinance.accountCreate.introPage.rightIconTitle\": \"Easy to use\",\n \"store/flowFinance.accountCreate.introPage.rightIconText\": \"Once approved, your credit will display as a payment option with {storePaymentName}\",\n \"store/flowFinance.accountCreate.introPage.continue\": \"Apply for credit\",\n \"store/flowFinance.accountCreate.introPage.poweredBy\": \"Powered by\",\n \"store/flowFinance.accountCreate.introPage.accountErrors.underReview\": \"Your credit analysis is processing. You will receive a message with the result soon.\",\n \"store/flowFinance.accountCreate.introPage.accountErrors.approved\": \"Your credit is approved and is available on the checkout page as Financiamento Gympass Plus.\",\n \"store/flowFinance.accountCreate.introPage.accountErrors.rejected\": \"You have a rejected credit application. You can't request a new line of credit at this time.\",\n \"store/flowFinance.accountCreate.cnpjLabel\": \"Company registration number\",\n \"store/flowFinance.accountCreate.cnpjError\": \"Please enter a valid company registration number.\",\n \"store/flowFinance.accountCreate.preQualify.notQualifiedMessage\": \"Unfortunately, you are not eligible to get a {storePaymentName} line of credit.{lineBreak}{lineBreak}However, you are still able to make purchases on our website by selecting a different payment method at checkout.\",\n \"store/flowFinance.accountCreate.preQualify.instructions\": \"Confirm your company registration number and apply for credit. If the company registration number is empty, please enter the company registration number (only numbers) associated with your {storeName} account before you continue.\",\n \"store/flowFinance.accountCreate.preQualify.submit\": \"Continue\",\n \"store/flowFinance.accountCreate.continueShopping\": \"Contnue shopping\",\n \"store/flowFinance.accountCreate.companyNameLabel\": \"Company name\",\n \"store/flowFinance.accountCreate.companyNameError\": \"Required field.\",\n \"store/flowFinance.accountCreate.companyLegalNameLabel\": \"Trade name\",\n \"store/flowFinance.accountCreate.companyLegalNameError\": \"Required field.\",\n \"store/flowFinance.accountCreate.companyPhoneLabel\": \"Phone\",\n \"store/flowFinance.accountCreate.companyPhoneError\": \"Please enter a valid phone number.\",\n \"store/flowFinance.accountCreate.businessInfo.instructions\": \"In order to run the credit analysis, we need some information about your business and the company representative.\",\n \"store/flowFinance.accountCreate.businessInfo.submit\": \"Continue\",\n \"store/flowFinance.accountCreate.addressNotApplicable\": \"N/A\",\n \"store/flowFinance.accountCreate.personalInfo.instructions\": \"In order to run the credit analysis, we need some information about your business and the company representative.\",\n \"store/flowFinance.accountCreate.firstNameLabel\": \"Name\",\n \"store/flowFinance.accountCreate.firstNameError\": \"Required field.\",\n \"store/flowFinance.accountCreate.lastNameLabel\": \"Last name\",\n \"store/flowFinance.accountCreate.lastNameError\": \"Required field.\",\n \"store/flowFinance.accountCreate.cpfLabel\": \"Taxpayer registration number\",\n \"store/flowFinance.accountCreate.cpfError\": \"Enter a valid taxpayer registration number.\",\n \"store/flowFinance.accountCreate.rgLabel\": \"ID document\",\n \"store/flowFinance.accountCreate.rgError\": \"Required field.\",\n \"store/flowFinance.accountCreate.rgExpLabel\": \"ID document expiration (DD/MM/YYYY)\",\n \"store/flowFinance.accountCreate.rgExpError\": \"Required field.\",\n \"store/flowFinance.accountCreate.personalPhoneLabel\": \"Phone\",\n \"store/flowFinance.accountCreate.personalPhoneError\": \"Please enter a valid phone number.\",\n \"store/flowFinance.accountCreate.pepLabel\": \"Politically Exposed Person (PEP)\",\n \"store/flowFinance.accountCreate.pepText\": \"As the term is defined in\",\n \"store/flowFinance.accountCreate.pepLinkText\": \"ICVM 301/99 (Brazil)\",\n \"store/flowFinance.accountCreate.emailLabel\": \"Email\",\n \"store/flowFinance.accountCreate.emailError\": \"Please enter a valid email address.\",\n \"store/flowFinance.accountCreate.maritalStatusLabel\": \"Marital status\",\n \"store/flowFinance.accountCreate.maritalStatusError\": \"Required field.\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.single\": \"Single\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.married\": \"Married\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.separated\": \"Separated\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.divorced\": \"Divorced\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.widowed\": \"Widowed\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.other\": \"Other\",\n \"store/flowFinance.accountCreate.personalInfo.submit\": \"Continue\",\n \"store/flowFinance.accountCreate.documents.continueLabel\": \"Continue\",\n \"store/flowFinance.accountCreate.documents.instructions\": \"Now you need to submit a copy of the articles of association and a photo identification (driver's license or ID document).\",\n \"store/flowFinance.accountCreate.documents.personalIdLabel\": \"ID document\",\n \"store/flowFinance.accountCreate.documents.uploadLabel\": \"Attach\",\n \"store/flowFinance.accountCreate.documents.businessIdLabel\": \"Article of association\",\n \"store/flowFinance.accountCreate.documents.fileSizeError\": \"We couldn't process your file. Check the size and format of the selected file.\",\n \"store/flowFinance.accountCreate.documents.genericError\": \"An error occurred. Please try again.\",\n \"store/flowFinance.accountCreate.documents.selectFileButton\": \"Select\",\n \"store/flowFinance.accountCreate.documents.cnhLabel\": \"Driver's license\",\n \"store/flowFinance.accountCreate.documents.rgLabel\": \"ID document\",\n \"store/flowFinance.accountCreate.documents.uploadInstructions\": \"Drag your file here{lineBreak}or\",\n \"store/flowFinance.accountCreate.documents.fileRestrictions\": \"Only {businessFileType}JPEG and PNG files with a maximum size of {fileSize}MB are allowed.\",\n \"store/flowFinance.accountCreate.tosTitle\": \"Terms and Conditions\",\n \"store/flowFinance.accountCreate.tosCheckboxLabel\": \"Accept the Terms of Use and the Privacy Policy\",\n \"store/flowFinance.accountCreate.submitApplication\": \"Submit application\",\n \"store/flowFinance.accountCreate.submitApplication.error\": \"An error occurred while submitting your application. Please try again.\",\n \"store/flowFinance.accountCreate.successPage.title\": \"We are analyzing your application\",\n \"store/flowFinance.accountCreate.successPage.message\": \"The credit analysis can take up to 24 hours.{lineBreak}{lineBreak}You will soon receive a message with the credit analysis result. If approved, the credit will be available as a payment option with {storePaymentName}.\",\n \"store/flowFinance.accountCreate.steps.businessInfo\": \"Company information\",\n \"store/flowFinance.accountCreate.steps.personalInfo\": \"Personal information\",\n \"store/flowFinance.accountCreate.steps.documents\": \"Documents\",\n \"store/flowFinance.productPromo.promoMessage\": \"Pay in up to {installments}x of {pricePerInstallment}*\",\n \"store/flowFinance.productPromo.promoMessageLinkText\": \"Apply for credit now\",\n \"store/flowFinance.productPromo.promoMessageSmallText\": \"* Installment simulated with interest. Conditions are subject to credit analysis.\",\n \"admin/editor.flowFinance.promoMessageBlock.title\": \"Flow Finance Promo Message\",\n \"admin/editor.flowFinance.promoMessageBlock.description\": \"Shows a promo with installment pricing and account signup link on the product page.\",\n \"admin/editor.promoMessageBlock.interestRate.title\": \"Interest rate (1.5% = 0.015)\",\n \"admin/editor.promoMessageBlock.installments.title\": \"Number of installments\"\n}\n\n```"
}
] |
code_flow-finance-components_d060714c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/messages/context.json from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store/flowFinance.accountCreate.introPage.title\": \"store/flowFinance.accountCreate.introPage.title\",\n \"store/flowFinance.accountCreate.introPage.instructions\": \"store/flowFinance.accountCreate.introPage.instructions\",\n \"store/flowFinance.accountCreate.introPage.leftIconTitle\": \"store/flowFinance.accountCreate.introPage.leftIconTitle\",\n \"store/flowFinance.accountCreate.introPage.leftIconText\": \"store/flowFinance.accountCreate.introPage.leftIconText\",\n \"store/flowFinance.accountCreate.introPage.rightIconTitle\": \"store/flowFinance.accountCreate.introPage.rightIconTitle\",\n \"store/flowFinance.accountCreate.introPage.rightIconText\": \"store/flowFinance.accountCreate.introPage.rightIconText\",\n \"store/flowFinance.accountCreate.introPage.continue\": \"store/flowFinance.accountCreate.introPage.continue\",\n \"store/flowFinance.accountCreate.introPage.poweredBy\": \"store/flowFinance.accountCreate.introPage.poweredBy\",\n \"store/flowFinance.accountCreate.introPage.accountErrors.underReview\": \"store/flowFinance.accountCreate.introPage.accountErrors.underReview\",\n \"store/flowFinance.accountCreate.introPage.accountErrors.approved\": \"store/flowFinance.accountCreate.introPage.accountErrors.approved\",\n \"store/flowFinance.accountCreate.introPage.accountErrors.rejected\": \"store/flowFinance.accountCreate.introPage.accountErrors.rejected\",\n \"store/flowFinance.accountCreate.cnpjLabel\": \"store/flowFinance.accountCreate.cnpjLabel\",\n \"store/flowFinance.accountCreate.cnpjError\": \"store/flowFinance.accountCreate.cnpjError\",\n \"store/flowFinance.accountCreate.preQualify.notQualifiedMessage\": \"store/flowFinance.accountCreate.preQualify.notQualifiedMessage\",\n \"store/flowFinance.accountCreate.preQualify.instructions\": \"store/flowFinance.accountCreate.preQualify.instructions\",\n \"store/flowFinance.accountCreate.preQualify.submit\": \"store/flowFinance.accountCreate.preQualify.submit\",\n \"store/flowFinance.accountCreate.continueShopping\": \"store/flowFinance.accountCreate.continueShopping\",\n \"store/flowFinance.accountCreate.companyNameLabel\": \"store/flowFinance.accountCreate.companyNameLabel\",\n \"store/flowFinance.accountCreate.companyNameError\": \"store/flowFinance.accountCreate.companyNameError\",\n \"store/flowFinance.accountCreate.companyLegalNameLabel\": \"store/flowFinance.accountCreate.companyLegalNameLabel\",\n \"store/flowFinance.accountCreate.companyLegalNameError\": \"store/flowFinance.accountCreate.companyLegalNameError\",\n \"store/flowFinance.accountCreate.companyPhoneLabel\": \"store/flowFinance.accountCreate.companyPhoneLabel\",\n \"store/flowFinance.accountCreate.companyPhoneError\": \"store/flowFinance.accountCreate.companyPhoneError\",\n \"store/flowFinance.accountCreate.businessInfo.instructions\": \"store/flowFinance.accountCreate.businessInfo.instructions\",\n \"store/flowFinance.accountCreate.businessInfo.submit\": \"store/flowFinance.accountCreate.businessInfo.submit\",\n \"store/flowFinance.accountCreate.addressNotApplicable\": \"store/flowFinance.accountCreate.addressNotApplicable\",\n \"store/flowFinance.accountCreate.personalInfo.instructions\": \"store/flowFinance.accountCreate.personalInfo.instructions\",\n \"store/flowFinance.accountCreate.firstNameLabel\": \"store/flowFinance.accountCreate.firstNameLabel\",\n \"store/flowFinance.accountCreate.firstNameError\": \"store/flowFinance.accountCreate.firstNameError\",\n \"store/flowFinance.accountCreate.lastNameLabel\": \"store/flowFinance.accountCreate.lastNameLabel\",\n \"store/flowFinance.accountCreate.lastNameError\": \"store/flowFinance.accountCreate.lastNameError\",\n \"store/flowFinance.accountCreate.cpfLabel\": \"store/flowFinance.accountCreate.cpfLabel\",\n \"store/flowFinance.accountCreate.cpfError\": \"store/flowFinance.accountCreate.cpfError\",\n \"store/flowFinance.accountCreate.rgLabel\": \"store/flowFinance.accountCreate.rgLabel\",\n \"store/flowFinance.accountCreate.rgError\": \"store/flowFinance.accountCreate.rgError\",\n \"store/flowFinance.accountCreate.rgExpLabel\": \"store/flowFinance.accountCreate.rgExpLabel\",\n \"store/flowFinance.accountCreate.rgExpError\": \"store/flowFinance.accountCreate.rgExpError\",\n \"store/flowFinance.accountCreate.personalPhoneLabel\": \"store/flowFinance.accountCreate.personalPhoneLabel\",\n \"store/flowFinance.accountCreate.personalPhoneError\": \"store/flowFinance.accountCreate.personalPhoneError\",\n \"store/flowFinance.accountCreate.pepLabel\": \"store/flowFinance.accountCreate.pepLabel\",\n \"store/flowFinance.accountCreate.pepText\": \"store/flowFinance.accountCreate.pepText\",\n \"store/flowFinance.accountCreate.pepLinkText\": \"store/flowFinance.accountCreate.pepLinkText\",\n \"store/flowFinance.accountCreate.emailLabel\": \"store/flowFinance.accountCreate.emailLabel\",\n \"store/flowFinance.accountCreate.emailError\": \"store/flowFinance.accountCreate.emailError\",\n \"store/flowFinance.accountCreate.maritalStatusLabel\": \"store/flowFinance.accountCreate.maritalStatusLabel\",\n \"store/flowFinance.accountCreate.maritalStatusError\": \"store/flowFinance.accountCreate.maritalStatusError\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.single\": \"store/flowFinance.accountCreate.maritalStatusOptions.single\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.married\": \"store/flowFinance.accountCreate.maritalStatusOptions.married\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.separated\": \"store/flowFinance.accountCreate.maritalStatusOptions.separated\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.divorced\": \"store/flowFinance.accountCreate.maritalStatusOptions.divorced\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.widowed\": \"store/flowFinance.accountCreate.maritalStatusOptions.widowed\",\n \"store/flowFinance.accountCreate.maritalStatusOptions.other\": \"store/flowFinance.accountCreate.maritalStatusOptions.other\",\n \"store/flowFinance.accountCreate.personalInfo.submit\": \"store/flowFinance.accountCreate.personalInfo.submit\",\n \"store/flowFinance.accountCreate.documents.continueLabel\": \"store/flowFinance.accountCreate.documents.continueLabel\",\n \"store/flowFinance.accountCreate.documents.instructions\": \"store/flowFinance.accountCreate.documents.instructions\",\n \"store/flowFinance.accountCreate.documents.personalIdLabel\": \"store/flowFinance.accountCreate.documents.personalIdLabel\",\n \"store/flowFinance.accountCreate.documents.uploadLabel\": \"store/flowFinance.accountCreate.documents.uploadLabel\",\n \"store/flowFinance.accountCreate.documents.businessIdLabel\": \"store/flowFinance.accountCreate.documents.businessIdLabel\",\n \"store/flowFinance.accountCreate.documents.fileSizeError\": \"store/flowFinance.accountCreate.documents.fileSizeError\",\n \"store/flowFinance.accountCreate.documents.genericError\": \"store/flowFinance.accountCreate.documents.genericError\",\n \"store/flowFinance.accountCreate.documents.selectFileButton\": \"store/flowFinance.accountCreate.documents.selectFileButton\",\n \"store/flowFinance.accountCreate.documents.cnhLabel\": \"store/flowFinance.accountCreate.documents.cnhLabel\",\n \"store/flowFinance.accountCreate.documents.rgLabel\": \"store/flowFinance.accountCreate.documents.rgLabel\",\n \"store/flowFinance.accountCreate.documents.uploadInstructions\": \"store/flowFinance.accountCreate.documents.uploadInstructions\",\n \"store/flowFinance.accountCreate.documents.fileRestrictions\": \"store/flowFinance.accountCreate.documents.fileRestrictions\",\n \"store/flowFinance.accountCreate.tosTitle\": \"store/flowFinance.accountCreate.tosTitle\",\n \"store/flowFinance.accountCreate.tosCheckboxLabel\": \"store/flowFinance.accountCreate.tosCheckboxLabel\",\n \"store/flowFinance.accountCreate.submitApplication\": \"store/flowFinance.accountCreate.submitApplication\",\n \"store/flowFinance.accountCreate.submitApplication.error\": \"store/flowFinance.accountCreate.submitApplication.error\",\n \"store/flowFinance.accountCreate.successPage.title\": \"store/flowFinance.accountCreate.successPage.title\",\n \"store/flowFinance.accountCreate.successPage.message\": \"store/flowFinance.accountCreate.successPage.message\",\n \"store/flowFinance.accountCreate.steps.businessInfo\": \"store/flowFinance.accountCreate.steps.businessInfo\",\n \"store/flowFinance.accountCreate.steps.personalInfo\": \"store/flowFinance.accountCreate.steps.personalInfo\",\n \"store/flowFinance.accountCreate.steps.documents\": \"store/flowFinance.accountCreate.steps.documents\",\n \"store/flowFinance.productPromo.promoMessage\": \"store/flowFinance.productPromo.promoMessage\",\n \"store/flowFinance.productPromo.promoMessageLinkText\": \"store/flowFinance.productPromo.promoMessageLinkText\",\n \"store/flowFinance.productPromo.promoMessageSmallText\": \"store/flowFinance.productPromo.promoMessageSmallText\",\n \"admin/editor.flowFinance.promoMessageBlock.title\": \"admin/editor.flowFinance.promoMessageBlock.title\",\n \"admin/editor.flowFinance.promoMessageBlock.description\": \"admin/editor.flowFinance.promoMessageBlock.description\",\n \"admin/editor.promoMessageBlock.interestRate.title\": \"admin/editor.promoMessageBlock.interestRate.title\",\n \"admin/editor.promoMessageBlock.installments.title\": \"admin/editor.promoMessageBlock.installments.title\"\n}\n\n```"
}
] |
code_flow-finance-components_361a3853
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/docs/README.md from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/vtex-apps/flow-finance-components) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# Flow Finance Components\n\nThis app provides store components related to the [Flow Finance payment method](https://github.com/vtex-apps/flow-finance-payment): an account sign-up form and a promo message for the PDP.\n\n:warning: The account sign-up form will not function unless the two [Flow Finance payment method](https://github.com/vtex-apps/flow-finance-payment) apps have been installed and configured (see instructions at link).\n\n## Configuration\n\n1. [Install](https://vtex.io/docs/recipes/store/installing-an-app) `vtex.flow-finance-components` in the desired account;\n2. Upload a PDF containing the Terms & Conditions that shoppers must agree to when applying for a Flow Finance account to the location of your choice and make a note of the URL.\n3. In the account's admin, access **Apps** and then select the **Flow Finance Components** box;\n4. Input your `Store Name` and `Store-branded Payment Name`, as well as the URL of the `Terms & Conditions PDF` from step 2, and click Save;\n5. Add this app as a dependency in your store-theme's `manifest.json`:\n\n```json\n\"dependencies\": {\n \"vtex.flow-finance-components\": \"1.x\"\n }\n```\n\nThis app creates a new store route: `/flow-finance`, which hosts the Flow Finance account sign-up form.\n\nThis app also provides a `flow-finance-promo-message` block which can be added to the PDP and accepts the following props:\n\n| Prop name | Type | Description | Default value |\n| -------------- | -------- | ---------------------------------------------------------- | ------------- |\n| `interestRate` | `number` | Interest rate for loan estimate calculation (1.5% = 0.015) | `0.0149` |\n| `installments` | `number` | Number of installments for loan estimate | `12` |\n\nThis block also includes a link which, when clicked, will open the Flow Finance account sign-up form as a modal directly on the PDP. The link is only shown if a shopper is logged in, and if they do not have a Flow Finance account.\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| PDP Promo Message CSS Handles |\n| ----------------------------- |\n| `promoMessageContainer` |\n| `promoMessageMainText` |\n| `promoMessageLink` |\n| `promoMessageLinkText` |\n| `promoMessageSmallText` |\n\n| Account Sign-up CSS Handles |\n| ---------------------------------- |\n| `accountCreateContainer` |\n| `accountCreatePageContainer` |\n| `accountCreatePageInnerContainer` |\n| `accountCreateStepsContainer` |\n| `accountCreateStep` |\n| `accountCreateStepNumberContainer` |\n| `accountCreateStepNumber` |\n| `accountCreateStepLabel` |\n| `businessInfoPageContainer` |\n| `businessInfoInstructions` |\n| `businessInfoSection` |\n| `businessAddressSection` |\n| `businessInfoPageButtonContainer` |\n| `documentsPageContainer` |\n| `documentsPageInstructions` |\n| `documentTypesContainer` |\n| `documentTypeContainer` |\n| `documentTypeIcon` |\n| `documentTypeLabel` |\n| `documentFilenameContainer` |\n| `documentFilenameText` |\n| `documentRemoveButton` |\n| `documentUploadButton` |\n| `documentUploadButtonText` |\n| `documentsPageButtonContainer` |\n| `documentsPageErrorContainer` |\n| `dropzoneContainer` |\n| `dropzoneRadioOptions` |\n| `dropzoneRadioOption` |\n| `dropzoneRadioOptionInput` |\n| `dropzoneRadioLabelText` |\n| `dropzoneErrorContainer` |\n| `dropzoneErrorIcon` |\n| `dropzoneErrorText` |\n| `dropzoneFilenameContainer` |\n| `dropzoneFilenameText` |\n| `dropzoneUploadContainer` |\n| `dropzoneUploadIcon` |\n| `dropzoneUploadInstructions` |\n| `dropzoneUploadButton` |\n| `dropzoneUploadButtonText` |\n| `introPageContainer` |\n| `introPageInstructions` |\n| `introPageTitle` |\n| `introPageIconsContainer` |\n| `introPageLeftIconContainer` |\n| `introPageLeftIcon` |\n| `introPageLeftIconTitle` |\n| `introPageLeftIconText` |\n| `introPageRightIconContainer` |\n| `introPageRightIcon` |\n| `introPageRightIconTitle` |\n| `introPageRightIconText` |\n| `introPageButtonContainer` |\n| `introPageAccountErrorContainer` |\n| `personalInfoPageContainer` |\n| `personalInfoInstructions` |\n| `personalInfoSection` |\n| `personalContactSection` |\n| `personalAddressSection` |\n| `personalInfoPageButtonContainer` |\n| `poweredByContainer` |\n| `preQualifyPageContainer` |\n| `preQualifyInstructions` |\n| `preQualifySection` |\n| `preQualifyPageButtonContainer` |\n| `successPageContainer` |\n| `successPageTitle` |\n| `successPageMessage` |\n| `successPageButtonContainer` |\n| `tosAcceptanceContainer` |\n| `tosAcceptanceCheckbox` |\n| `tosAcceptanceCheckboxLabel` |\n| `tosIframeContainer` |\n\n```"
}
] |
code_flow-finance-components_3464719d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/PromoMessage.tsx from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport PromoMessage from './components/PromoMessage'\n\nexport default PromoMessage\n\n```"
}
] |
code_flow-finance-components_d114ec6e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/AccountCreatePage.tsx from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport AccountCreatePage from './components/AccountCreatePage'\n\nexport default AccountCreatePage\n\n```"
}
] |
code_flow-finance-components_cc71af95
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/package.json from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"lint\": \"tsc --noEmit && eslint --ext ts,tsx .\"\n },\n \"dependencies\": {\n \"@vtex/css-handles\": \"^1.0.0\",\n \"apollo-cache\": \"^1.3.4\",\n \"apollo-link\": \"^1.2.13\",\n \"apollo-utilities\": \"^1.3.3\",\n \"classnames\": \"^2.2.6\",\n \"graphql\": \"^14.6.0\",\n \"react\": \"^16.8.3\",\n \"react-apollo\": \"^3.1.3\",\n \"react-dom\": \"^16.8.3\",\n \"react-dropzone\": \"^10.2.1\",\n \"react-intl\": \"^4.1.1\"\n },\n \"devDependencies\": {\n \"@types/classnames\": \"^2.2.7\",\n \"@types/jest\": \"^24.0.18\",\n \"@types/node\": \"^13.9.0\",\n \"@types/prop-types\": \"^15.7.0\",\n \"@types/ramda\": \"^0.26.5\",\n \"@types/react\": \"^16.9.2\",\n \"@types/react-intl\": \"^3.0.0\",\n \"apollo-client\": \"^2.5.1\",\n \"prop-types\": \"^15.7.2\",\n \"vtex.address-form\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.address-form@4.5.3/public/_types/react\",\n \"vtex.css-handles\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.css-handles@0.4.2/public/@types/vtex.css-handles\",\n \"vtex.product-context\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.product-context@0.7.1/public/@types/vtex.product-context\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.100.1/public/@types/vtex.render-runtime\",\n \"vtex.store\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store@2.95.4/public/@types/vtex.store\",\n \"vtex.store-components\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-components@3.113.0/public/_types/react\",\n \"vtex.store-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-graphql@2.122.0/public/@types/vtex.store-graphql\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.114.0/public/@types/vtex.styleguide\"\n },\n \"version\": \"1.0.5\"\n}\n\n```"
}
] |
code_flow-finance-components_b2beb7c3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/store/interfaces.json from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"flow-finance-account-create\": {\n \"component\": \"AccountCreatePage\"\n },\n \"flow-finance-promo-message\": {\n \"component\": \"PromoMessage\"\n },\n \"store.flow-finance\": {\n \"required\": [\"flow-finance-account-create\"]\n }\n}\n\n```"
}
] |
code_flow-finance-components_eef0c3c7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/store/routes.json from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"store.flow-finance\": {\n \"path\": \"/flow-finance\"\n }\n}\n\n```"
}
] |
code_flow-finance-components_3b7be0ef
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/typings/flow-finance.d.ts from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport interface BusinessInformation {\n businessId: string\n name: string\n legalName: string\n email: string\n phoneNumber: string\n docType: string\n physicalDocFile?: File\n physicalDocFileName: string\n}\n\nexport interface Address {\n addressId: string\n addressType: string\n city: string\n complement: string\n country: string\n geoCoordinates?: number[]\n receiverName?: string\n reference?: string\n neighborhood: string\n number: string\n postalCode: string\n state: string\n street: string\n}\n\nexport interface PersonalInformation {\n idNumber: string\n maritalStatus: string\n pep: boolean\n lastName: string\n firstName: string\n docType: string\n physicalDocFile?: File\n physicalDocFileName: string\n virtualDocValue: string\n virtualDocExp?: string\n virtualDocIssuer?: string\n email: string\n phoneNumber: string\n accountOpener: boolean\n}\n\nexport interface TOSAcceptance {\n date: string\n ip: string\n userAgent: string\n}\n\n```"
}
] |
code_flow-finance-components_3a3d173a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/typings/storefront.d.ts from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { FunctionComponent } from 'react'\n\ndeclare global {\n interface StorefrontFunctionComponent<P = {}> extends FunctionComponent<P> {\n getSchema?(props: P): object\n schema?: object\n }\n\n interface StorefrontComponent<P = {}, S = {}> extends Component<P, S> {\n getSchema?(props: P): object\n schema: object\n }\n}\n\n```"
}
] |
code_flow-finance-components_a530eea9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/typings/vtex.css-handles.d.ts from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.css-handles' {\n type CssHandlesInput = readonly string[]\n type ValueOf<T extends readonly any[]> = T[number]\n type CssHandles<T extends CssHandlesInput> = Record<ValueOf<T>, string>\n interface CssHandlesOptions {\n migrationFrom?: string | string[]\n }\n\n export const useCssHandles: <T extends CssHandlesInput>(\n handles: T,\n options: CssHandlesOptions = {}\n ) => CssHandles<T>\n export const applyModifiers: (\n handles: string,\n modifier: string | string[]\n ) => string\n}\n\n```"
}
] |
code_flow-finance-components_71a71f94
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/typings/vtex.store-components.d.ts from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.store-components' {\n export const Container\n}\n\n```"
}
] |
code_flow-finance-components_8b68a3cd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/typings/vtex.product-context.d.ts from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.product-context/useProduct' {\n import { Context } from 'react'\n\n interface ProductContext {\n product: any\n selectedItem: any\n }\n\n export default function useProduct(): ProductContext\n}\n\n```"
}
] |
code_flow-finance-components_0379f3bb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/typings/png.d.ts from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.png' {\n const path: string\n export default path\n}\n\n```"
}
] |
code_flow-finance-components_9dac7f82
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/typings/vtex.render-runtime.d.ts from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint @typescript-eslint/no-explicit-any: 0 */\n/* Typings for `render-runtime` */\ndeclare module 'vtex.render-runtime' {\n import { Component, ReactElement } from 'react'\n\n export interface NavigationOptions {\n page?: string\n to?: string\n params?: any\n fallbackToWindowLocation?: boolean\n }\n\n export interface RenderContext {\n culture: {\n locale: string\n currency: string\n }\n getSettings: (app: string) => any\n navigate: (options: NavigationOptions) => void\n }\n\n export interface RenderContextProps {\n runtime: {\n account: string\n navigate: (options: NavigationOptions) => void\n }\n }\n\n export interface InjectedRuntime {\n runtime: RenderRuntime\n }\n\n interface Pages {\n [name: string]: Page\n }\n\n interface Route {\n domain: string\n blockId: string\n canonicalPath?: string\n id: string\n params: Record<string, string>\n path: string\n title?: string\n }\n\n interface Culture {\n availableLocales: string[]\n locale: string\n language: string\n country: string\n currency: string\n }\n\n export interface RenderRuntime {\n account: string\n accountId: string\n appsEtag: string\n workspace: string\n disableSSR: boolean\n hints: {\n desktop: boolean\n mobile: boolean\n phone: boolean\n tablet: boolean\n }\n page: string\n route: Route\n version: string\n culture: Culture\n pages: Pages\n preview: boolean\n production: boolean\n publicEndpoint: string\n renderMajor: number\n query?: Record<string, string>\n start: boolean\n runtimeMeta: {\n version: string\n config?: any\n }\n settings: {\n [app: string]: any\n }\n segmentToken: string\n rootPath?: string\n workspaceCookie: string\n hasNewExtensions: boolean\n navigate: (options: NavigationOptions) => void\n }\n\n export const Link: any\n export const NoSSR: any\n export const RenderContextConsumer: ReactElement\n export const canUseDOM: boolean\n export const withRuntimeContext: any\n export const Helmet: any\n export const useRuntime: () => RenderRuntime\n}\n\n```"
}
] |
code_flow-finance-components_61baab51
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/typings/svg.d.ts from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.svg' {\n const svg: any\n export default svg\n}\n\n```"
}
] |
code_flow-finance-components_812e0746
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/typings/global.d.ts from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare global {\n interface AddressFormFields {\n [key: string]: {\n value: null | string | number | number[]\n valid?: boolean\n geolocationAutoCompleted?: boolean\n postalCodeAutoCompleted?: boolean\n }\n }\n}\nexport {}\n\n```"
}
] |
code_flow-finance-components_128c5731
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/typings/css.d.ts from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const css: any\n export default css\n}\n\n```"
}
] |
code_flow-finance-components_3ce790bb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/typings/graphql.d.ts from the flow-finance-components 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_flow-finance-components_d89cad2e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/typings/vtex.styleguide.d.ts from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide' {\n import { ComponentType } from 'react'\n\n export const PageBlock: ComponentType<Props>\n export const Modal: ComponentType<Props>\n export const Button: ComponentType<Props>\n export const ButtonPlain: ComponentType<Props>\n export const ButtonWithIcon: ComponentType<Props>\n export const Input: ComponentType<Props>\n export const Spinner: ComponentType<Props>\n export const Dropdown: ComponentType<Props>\n export const Checkbox: ComponentType<Props>\n export const Toggle: ComponentType<Props>\n export const Divider: ComponentType<Props>\n export const IconCheck: ComponentType<Props>\n export const IconClose: ComponentType<Props>\n export const IconDelete: ComponentType<Props>\n\n interface Props {\n [key: string]: any\n }\n}\n\n```"
}
] |
code_flow-finance-components_7fdaabfa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/components/PromoMessage.tsx from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport useProduct from 'vtex.product-context/useProduct'\n\nimport React, { useState, useEffect } from 'react'\nimport {\n FormattedMessage,\n defineMessages,\n injectIntl,\n WrappedComponentProps,\n} from 'react-intl'\nimport { useQuery } from 'react-apollo'\nimport { ButtonPlain, Modal } from 'vtex.styleguide'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport AccountCreate from './AccountCreate'\nimport Profile from '../graphql/Profile.graphql'\n\ninterface PromoProps {\n interestRate: number\n installments: number\n}\n\nconst CSS_HANDLES = [\n 'promoMessageContainer',\n 'promoMessageMainText',\n 'promoMessageLink',\n 'promoMessageLinkText',\n 'promoMessageSmallText',\n] as const\n\nconst FlowFinancePromo: StorefrontFunctionComponent<PromoProps &\n WrappedComponentProps> = ({ interestRate, installments, intl }) => {\n const [isModalOpen, setIsModalOpen] = useState(false)\n const [showLink, setShowLink] = useState(false)\n const [showPromo, setShowPromo] = useState(false)\n const handles = useCssHandles(CSS_HANDLES)\n const { product, selectedItem } = useProduct()\n const { data, refetch } = useQuery(Profile)\n\n async function postData(url = '', dataToPost = {}) {\n const response = await fetch(url, {\n method: 'POST',\n mode: 'cors',\n cache: 'no-cache',\n credentials: 'same-origin',\n headers: {\n 'Content-Type': 'application/json',\n },\n redirect: 'follow',\n referrerPolicy: 'no-referrer',\n body: JSON.stringify(dataToPost),\n })\n if (!response.ok) {\n console.error(response)\n return response\n }\n return response.json()\n }\n\n useEffect(() => {\n if (data?.profile) {\n postData(`/_v/api/connectors/flow-finance/get-loan-options`, {\n email: data.profile.email,\n total: 1000,\n }).then(response => {\n if (response.accountStatus !== 'rejected') {\n setShowPromo(true)\n }\n if (\n response.accountStatus === 'none' ||\n response.accountStatus === 'pending'\n )\n setShowLink(true)\n })\n }\n }, [data])\n\n if (!product || !selectedItem || !data) {\n return null\n }\n\n const price = selectedItem?.sellers[0].commertialOffer.Price\n\n function calculateInstallments(\n itemPrice: number,\n itemInterestRate: number,\n itemInstallments: number\n ) {\n if (!itemPrice || !itemInterestRate || !itemInstallments) return 0\n const pricePerInstallment =\n (itemPrice *\n (1 + itemInterestRate) ** itemInstallments *\n itemInterestRate) /\n ((1 + itemInterestRate) ** itemInstallments - 1)\n return intl.formatNumber(pricePerInstallment, {\n style: 'currency',\n currency: 'BRL',\n })\n }\n\n async function handleModalToggle() {\n setShowLink(false)\n setIsModalOpen(!isModalOpen)\n refetch().then((result: any) => {\n if (result?.data?.profile) {\n postData(`/_v/api/connectors/flow-finance/get-loan-options`, {\n email: result.data.profile.email,\n total: 1000,\n }).then(response => {\n if (response.accountStatus !== 'rejected') {\n setShowPromo(true)\n }\n if (\n response.accountStatus === 'none' ||\n response.accountStatus === 'pending'\n )\n setShowLink(true)\n })\n }\n })\n }\n\n if (showPromo)\n return (\n <div className={`${handles.promoMessageContainer} mt6 mb6`}>\n <span className={`${handles.promoMessageMainText}`}>\n <FormattedMessage\n id=\"store/flowFinance.productPromo.promoMessage\"\n values={{\n installments,\n pricePerInstallment: calculateInstallments(\n price,\n interestRate,\n installments\n ),\n }}\n />\n </span>{' '}\n {showLink && (\n <ButtonPlain\n onClick={handleModalToggle}\n className={`${handles.promoMessageLink}`}\n >\n <span className={`${handles.promoMessageLinkText}`}>\n <FormattedMessage id=\"store/flowFinance.productPromo.promoMessageLinkText\" />\n </span>\n </ButtonPlain>\n )}\n <div className={`${handles.promoMessageSmallText} t-mini`}>\n <FormattedMessage id=\"store/flowFinance.productPromo.promoMessageSmallText\" />\n </div>\n <Modal\n isOpen={isModalOpen}\n onClose={handleModalToggle}\n closeOnOverlayClick={false}\n >\n <AccountCreate handleExit={handleModalToggle} />\n </Modal>\n </div>\n )\n\n return null\n}\n\nconst messages = defineMessages({\n title: {\n defaultMessage: '',\n id: 'admin/editor.flowFinance.promoMessageBlock.title',\n },\n description: {\n defaultMessage: '',\n id: 'admin/editor.flowFinance.promoMessageBlock.description',\n },\n interestRateTitle: {\n defaultMessage: '',\n id: 'admin/editor.promoMessageBlock.interestRate.title',\n },\n installmentsTitle: {\n defaultMessage: '',\n id: 'admin/editor.promoMessageBlock.installments.title',\n },\n})\n\nFlowFinancePromo.schema = {\n title: messages.title.id,\n description: messages.description.id,\n type: 'object',\n properties: {\n interestRate: {\n title: messages.interestRateTitle.id,\n type: 'number',\n isLayout: false,\n default: 0.0149,\n },\n installments: {\n title: messages.installmentsTitle.id,\n type: 'number',\n isLayout: false,\n default: 24,\n },\n },\n}\nFlowFinancePromo.defaultProps = {\n interestRate: 0.0149,\n installments: 24,\n}\n\nexport default injectIntl(FlowFinancePromo)\n\n```"
}
] |
code_flow-finance-components_df6aa127
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/components/AccountCreatePage.tsx from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { PageBlock } from 'vtex.styleguide'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { useRuntime } from 'vtex.render-runtime'\n\nimport AccountCreate from './AccountCreate'\n\nconst CSS_HANDLES = [\n 'accountCreatePageContainer',\n 'accountCreatePageInnerContainer',\n] as const\n\nconst AccountCreatePage: StorefrontFunctionComponent = () => {\n const handles = useCssHandles(CSS_HANDLES)\n const { navigate } = useRuntime()\n\n async function handleExit() {\n navigate({ page: 'store.home' })\n }\n\n return (\n <div className={`${handles.accountCreatePageContainer} bg-muted-5 pa8`}>\n <div\n className={`${handles.accountCreatePageInnerContainer} m-auto`}\n style={{ maxWidth: 800, margin: '0 auto' }}\n >\n <PageBlock variation=\"full\">\n <AccountCreate handleExit={handleExit} checkAccount />\n </PageBlock>\n </div>\n </div>\n )\n}\n\nexport default AccountCreatePage\n\n```"
}
] |
code_flow-finance-components_1d024f9a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/components/AccountCreateContext.tsx from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FunctionComponent, useContext, useReducer } from 'react'\n\nimport {\n BusinessInformation,\n PersonalInformation,\n Address,\n TOSAcceptance,\n} from '../typings/flow-finance'\n\ninterface AccountCreateContextProps {\n businessInformation: BusinessInformation\n businessAddress: Address\n personalInformation: PersonalInformation\n personalAddress: Address\n tosAcceptance: TOSAcceptance\n currentPage: number\n businessInfoValid: boolean\n businessInfoComplete: boolean\n personalInfoValid: boolean\n personalInfoComplete: boolean\n documentsValid: boolean\n documentsComplete: boolean\n}\n\ntype ReducerActions =\n | {\n type: 'SET_BUSINESS_FIELD'\n args: { field: string; value: string | File }\n }\n | { type: 'SET_BUSINESS_ADDRESS'; args: { address: Address } }\n | {\n type: 'SET_PERSONAL_FIELD'\n args: { field: string; value: string | boolean | File }\n }\n | { type: 'SET_PERSONAL_ADDRESS'; args: { address: Address } }\n | { type: 'SET_TOS_FIELD'; args: { field: string; value: string } }\n | { type: 'SET_CURRENT_PAGE'; args: { page: number } }\n | { type: 'SET_BUSINESS_INFO_VALID'; args: { valid: boolean } }\n | { type: 'SET_PERSONAL_INFO_VALID'; args: { valid: boolean } }\n | { type: 'SET_DOCUMENTS_VALID'; args: { valid: boolean } }\n | { type: 'SET_BUSINESS_INFO_COMPLETE'; args: { complete: boolean } }\n | { type: 'SET_PERSONAL_INFO_COMPLETE'; args: { complete: boolean } }\n | { type: 'SET_DOCUMENTS_COMPLETE'; args: { complete: boolean } }\n\ntype Dispatch = (action: ReducerActions) => void\n\nconst initialAccountCreateState = {\n businessInformation: {\n businessId: '',\n name: '',\n legalName: '',\n email: '',\n phoneNumber: '',\n docType: 'CONTRATO-SOCIAL',\n physicalDocFileName: '',\n },\n businessAddress: {\n addressId: '',\n addressType: 'commercial',\n city: '',\n complement: '',\n country: 'BRA',\n geoCoordinates: [],\n receiverName: 'notApplicable',\n reference: '',\n neighborhood: '',\n number: '',\n postalCode: '',\n state: '',\n street: '',\n },\n personalInformation: {\n idNumber: '',\n maritalStatus: '',\n pep: false,\n lastName: '',\n firstName: '',\n docType: 'CNH',\n physicalDocFileName: '',\n virtualDocValue: '',\n virtualDocExp: '',\n virtualDocIssuer: '',\n email: '',\n phoneNumber: '',\n accountOpener: true,\n },\n personalAddress: {\n addressId: '',\n addressType: 'residential',\n city: '',\n complement: '',\n country: 'BRA',\n geoCoordinates: [],\n receiverName: 'notApplicable',\n reference: '',\n neighborhood: '',\n number: '',\n postalCode: '',\n state: '',\n street: '',\n },\n tosAcceptance: {\n date: '',\n ip: '',\n userAgent: '',\n },\n currentPage: 1,\n businessInfoValid: false,\n personalInfoValid: false,\n documentsValid: false,\n businessInfoComplete: false,\n personalInfoComplete: false,\n documentsComplete: false,\n}\n\nconst AccountCreateStateContext = React.createContext<\n AccountCreateContextProps\n>(initialAccountCreateState)\nconst AccountCreateDispatchContext = React.createContext<Dispatch | undefined>(\n undefined\n)\n\nfunction reducer(\n state: AccountCreateContextProps,\n action: ReducerActions\n): AccountCreateContextProps {\n switch (action.type) {\n case 'SET_BUSINESS_FIELD':\n return {\n ...state,\n businessInformation: {\n ...state.businessInformation,\n [action.args.field]: action.args.value,\n },\n }\n case 'SET_BUSINESS_ADDRESS':\n return {\n ...state,\n businessAddress: action.args.address,\n }\n case 'SET_PERSONAL_FIELD':\n return {\n ...state,\n personalInformation: {\n ...state.personalInformation,\n [action.args.field]: action.args.value,\n },\n }\n case 'SET_PERSONAL_ADDRESS':\n return {\n ...state,\n personalAddress: action.args.address,\n }\n case 'SET_TOS_FIELD':\n return {\n ...state,\n tosAcceptance: {\n ...state.tosAcceptance,\n [action.args.field]: action.args.value,\n },\n }\n case 'SET_CURRENT_PAGE':\n return {\n ...state,\n currentPage: action.args.page,\n }\n case 'SET_BUSINESS_INFO_VALID':\n return {\n ...state,\n businessInfoValid: action.args.valid,\n }\n case 'SET_PERSONAL_INFO_VALID':\n return {\n ...state,\n personalInfoValid: action.args.valid,\n }\n case 'SET_DOCUMENTS_VALID':\n return {\n ...state,\n documentsValid: action.args.valid,\n }\n case 'SET_BUSINESS_INFO_COMPLETE':\n return {\n ...state,\n businessInfoComplete: action.args.complete,\n }\n case 'SET_PERSONAL_INFO_COMPLETE':\n return {\n ...state,\n personalInfoComplete: action.args.complete,\n }\n case 'SET_DOCUMENTS_COMPLETE':\n return {\n ...state,\n documentsComplete: action.args.complete,\n }\n default:\n return state\n }\n}\n\nconst AccountCreateContextProvider: FunctionComponent<AccountCreateContextProps> = ({\n children,\n}) => {\n const [state, dispatch] = useReducer(reducer, initialAccountCreateState)\n return (\n <AccountCreateStateContext.Provider value={state}>\n <AccountCreateDispatchContext.Provider value={dispatch}>\n {children}\n </AccountCreateDispatchContext.Provider>\n </AccountCreateStateContext.Provider>\n )\n}\n\nfunction useAccountCreateState() {\n const context = useContext(AccountCreateStateContext)\n if (context === undefined) {\n throw new Error(\n 'useAccountCreateState must be used within a AccountCreateStateContextProvider'\n )\n }\n return context\n}\n\nfunction useAccountCreateDispatch() {\n const context = useContext(AccountCreateDispatchContext)\n\n if (context === undefined) {\n throw new Error(\n 'useAccountCreateDispatch must be used within a AccountCreateDispatchContextProvider'\n )\n }\n return context\n}\n\nexport {\n AccountCreateContextProvider,\n initialAccountCreateState,\n useAccountCreateDispatch,\n useAccountCreateState,\n}\n\n```"
}
] |
code_flow-finance-components_3158a341
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/components/AccountCreate.tsx from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport {\n AccountCreateContextProvider,\n initialAccountCreateState,\n} from './AccountCreateContext'\nimport AccountCreatePageController from './AccountCreatePageController'\nimport './AccountCreatePages/styles/global.css'\n\ninterface Props {\n handleExit(): Promise<void>\n checkAccount?: boolean\n}\n\nconst CSS_HANDLES = ['accountCreateContainer'] as const\n\nconst AccountCreate: StorefrontFunctionComponent<Props> = ({\n handleExit,\n checkAccount = false,\n}) => {\n const handles = useCssHandles(CSS_HANDLES)\n return (\n <AccountCreateContextProvider\n businessInformation={initialAccountCreateState.businessInformation}\n businessAddress={initialAccountCreateState.businessAddress}\n personalInformation={initialAccountCreateState.personalInformation}\n personalAddress={initialAccountCreateState.personalAddress}\n tosAcceptance={initialAccountCreateState.tosAcceptance}\n currentPage={initialAccountCreateState.currentPage}\n businessInfoValid={initialAccountCreateState.businessInfoValid}\n personalInfoValid={initialAccountCreateState.personalInfoValid}\n documentsValid={initialAccountCreateState.documentsValid}\n businessInfoComplete={initialAccountCreateState.businessInfoValid}\n personalInfoComplete={initialAccountCreateState.personalInfoValid}\n documentsComplete={initialAccountCreateState.documentsValid}\n >\n <div className={handles.accountCreateContainer}>\n <AccountCreatePageController\n handleExit={handleExit}\n checkAccount={checkAccount}\n />\n </div>\n </AccountCreateContextProvider>\n )\n}\n\nexport default AccountCreate\n\n```"
}
] |
code_flow-finance-components_01b6a86c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/components/AccountCreatePageController.tsx from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { AddressRules } from 'vtex.address-form'\n\nimport React, { Fragment } from 'react'\nimport { useQuery } from 'react-apollo'\n\nimport { useAccountCreateState } from './AccountCreateContext'\nimport AccountCreateSteps from './AccountCreatePages/AccountCreateSteps'\nimport IntroPage from './AccountCreatePages/IntroPage'\nimport PreQualifyPage from './AccountCreatePages/PreQualifyPage'\nimport BusinessInfoPage from './AccountCreatePages/BusinessInfoPage'\nimport PersonalInfoPage from './AccountCreatePages/PersonalInfoPage'\nimport DocumentsPage from './AccountCreatePages/DocumentsPage'\nimport SuccessPage from './AccountCreatePages/SuccessPage'\nimport AppSettings from '../graphql/AppSettings.graphql'\n\ninterface Props {\n handleExit: () => void\n checkAccount: boolean\n}\n\ninterface Settings {\n storeName: string\n storePaymentName: string\n tosPdfPath: string\n}\n\nconst AccountCreatePageController: StorefrontFunctionComponent<Props> = ({\n handleExit,\n checkAccount,\n}) => {\n const { currentPage } = useAccountCreateState()\n const { data } = useQuery(AppSettings, { ssr: false })\n\n if (!data?.appSettings?.message) return null\n\n const settings: Settings = JSON.parse(data.appSettings.message)\n\n return (\n <AddressRules country=\"BRA\" shouldUseIOFetching useGeolocation={false}>\n {currentPage === 1 && (\n <IntroPage settings={settings} checkAccount={checkAccount} />\n )}\n {currentPage === 2 && (\n <PreQualifyPage settings={settings} handleExit={handleExit} />\n )}\n {currentPage === 3 && (\n <Fragment>\n <AccountCreateSteps />\n <BusinessInfoPage />\n </Fragment>\n )}\n {currentPage === 4 && (\n <Fragment>\n <AccountCreateSteps />\n <PersonalInfoPage />\n </Fragment>\n )}\n {currentPage === 5 && (\n <Fragment>\n <AccountCreateSteps />\n <DocumentsPage settings={settings} />\n </Fragment>\n )}\n {currentPage === 6 && (\n <Fragment>\n <AccountCreateSteps />\n <SuccessPage settings={settings} handleExit={handleExit} />\n </Fragment>\n )}\n </AddressRules>\n )\n}\n\nexport default AccountCreatePageController\n\n```"
}
] |
code_flow-finance-components_c8eea623
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/graphql/Profile.graphql from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery Profile {\n profile @context(provider: \"vtex.store-graphql\") {\n firstName\n lastName\n email\n userId\n birthDate\n gender\n homePhone\n businessPhone\n corporateName\n tradeName\n corporateDocument\n stateRegistration\n }\n}\n\n```"
}
] |
code_flow-finance-components_0e073fc6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/graphql/ProcessApplication.graphql from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation ProcessApplication(\n $application: ApplicationInput!\n $businessInfoFile: Upload!\n $personalInfoFile: Upload!\n) {\n processApplication(\n application: $application\n businessInfoFile: $businessInfoFile\n personalInfoFile: $personalInfoFile\n ) @context(provider: \"vtex.flow-finance-api\") {\n success\n error\n }\n}\n\n```"
}
] |
code_flow-finance-components_59c766be
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/graphql/PreQualify.graphql from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation PreQualify($cnpj: String!) {\n checkPreQualify(cnpj: $cnpj) @context(provider: \"vtex.flow-finance-api\")\n}\n\n```"
}
] |
code_flow-finance-components_39f74ea2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/graphql/AppSettings.graphql from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery AppSettings {\n appSettings(app: \"vtex.flow-finance-components\", version: \"1.x\")\n @context(provider: \"vtex.apps-graphql\") {\n message\n }\n}\n\n```"
}
] |
code_flow-finance-components_0ae25367
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/components/AccountCreatePages/BusinessInfoPage.tsx from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport {\n AddressContainer,\n AddressForm as AddressFields,\n inputs,\n helpers,\n PostalCodeGetter,\n} from 'vtex.address-form'\n\nimport React, { useEffect, useState } from 'react'\nimport {\n defineMessages,\n injectIntl,\n WrappedComponentProps,\n FormattedMessage,\n} from 'react-intl'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { Input, Button, Divider } from 'vtex.styleguide'\n\nimport {\n useAccountCreateState,\n useAccountCreateDispatch,\n} from '../AccountCreateContext'\nimport { formatCNPJ, formatPhone } from './utils/formatters'\n\ninterface AddressProps {\n rules: any\n}\n\nconst { StyleguideInput } = inputs\nconst { addValidation, isValidAddress, injectRules, validateAddress } = helpers\n\nconst CSS_HANDLES = [\n 'businessInfoPageContainer',\n 'businessInfoInstructions',\n 'businessInfoSection',\n 'businessAddressSection',\n 'businessInfoPageButtonContainer',\n] as const\n\nconst messages = defineMessages({\n cnpjLabel: {\n defaultMessage: 'CNPJ',\n id: 'store/flowFinance.accountCreate.cnpjLabel',\n },\n cnpjError: {\n defaultMessage: 'Please enter a valid CNPJ',\n id: 'store/flowFinance.accountCreate.cnpjError',\n },\n companyNameLabel: {\n defaultMessage: 'Company Name',\n id: 'store/flowFinance.accountCreate.companyNameLabel',\n },\n companyNameError: {\n defaultMessage: 'This field is required.',\n id: 'store/flowFinance.accountCreate.companyNameError',\n },\n companyLegalNameLabel: {\n defaultMessage: 'Legal Name',\n id: 'store/flowFinance.accountCreate.companyLegalNameLabel',\n },\n companyLegalNameError: {\n defaultMessage: 'This field is required.',\n id: 'store/flowFinance.accountCreate.companyLegalNameError',\n },\n companyPhoneLabel: {\n defaultMessage: 'Phone Number',\n id: 'store/flowFinance.accountCreate.companyPhoneLabel',\n },\n companyPhoneError: {\n defaultMessage: 'Please enter a valid phone number.',\n id: 'store/flowFinance.accountCreate.companyPhoneError',\n },\n})\n\nlet gguid = 1\n\nfunction getGGUID() {\n return (gguid++ * new Date().getTime() * -1).toString()\n}\n\nconst BusinessInfoPage: StorefrontFunctionComponent<WrappedComponentProps &\n AddressProps> = ({ intl, rules }) => {\n const {\n businessInformation,\n businessAddress,\n businessInfoValid,\n currentPage,\n } = useAccountCreateState()\n const dispatch = useAccountCreateDispatch()\n const handles = useCssHandles(CSS_HANDLES)\n\n const addressWithValidation = addValidation({\n addressQuery: null,\n ...businessAddress,\n })\n addressWithValidation.addressId.value = getGGUID()\n addressWithValidation.receiverName.value = 'notApplicable'\n addressWithValidation.receiverName.postalCodeAutoCompleted = true\n const [address, setAddress] = useState(addressWithValidation)\n const [formattedPhone, setFormattedPhone] = useState(\n formatPhone(businessInformation.phoneNumber)\n )\n const [showErrors, setShowErrors] = useState(false)\n const [showPhoneError, setShowPhoneError] = useState(false)\n const [showNameError, setShowNameError] = useState(false)\n const [showLegalNameError, setShowLegalNameError] = useState(false)\n\n useEffect(() => {\n if (businessInformation.phoneNumber) setShowPhoneError(true)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n useEffect(() => {\n if (\n businessInformation.phoneNumber.length >= 10 &&\n businessInformation.phoneNumber.length <= 11 &&\n businessInformation.name !== '' &&\n businessInformation.legalName !== '' &&\n isValidAddress(address, rules).valid\n ) {\n dispatch({\n type: 'SET_BUSINESS_INFO_VALID',\n args: {\n valid: true,\n },\n })\n } else if (businessInfoValid) {\n dispatch({\n type: 'SET_BUSINESS_INFO_VALID',\n args: {\n valid: false,\n },\n })\n }\n }, [businessInfoValid, businessInformation, address, rules, dispatch])\n\n async function handleAddressChange(newAddress: AddressFormFields) {\n const curAddress = address\n const combinedAddress = { ...curAddress, ...newAddress }\n setAddress(combinedAddress)\n }\n\n async function handleAddressFieldChange(newAddress: AddressFormFields) {\n const [key] = Object.keys(newAddress)\n const curAddress = address\n const validatedField = newAddress[key].value\n ? validateAddress(newAddress, rules)\n : newAddress\n const combinedAddress = { ...curAddress, ...validatedField }\n setAddress(combinedAddress)\n }\n\n async function handleShowErrors() {\n const validatedAddress = validateAddress(address, rules)\n setAddress(validatedAddress)\n setShowErrors(true)\n }\n\n async function handleContinueClick() {\n const validAddress = {\n addressId: '',\n addressType: 'commercial',\n city: address.city.value,\n complement: address.complement.value || '',\n country: 'BRA',\n geoCoordinates: [],\n receiverName: '',\n reference: '',\n neighborhood: address.neighborhood.value,\n number: address.number.value,\n postalCode: address.postalCode.value,\n state: address.state.value,\n street: address.street.value,\n }\n dispatch({\n type: 'SET_BUSINESS_ADDRESS',\n args: {\n address: validAddress,\n },\n })\n dispatch({\n type: 'SET_BUSINESS_INFO_COMPLETE',\n args: {\n complete: true,\n },\n })\n dispatch({\n type: 'SET_CURRENT_PAGE',\n args: {\n page: currentPage + 1,\n },\n })\n window.scrollTo(0, 0)\n }\n\n return (\n <div className={handles.businessInfoPageContainer}>\n <div className={`${handles.businessInfoInstructions} mb7`}>\n <FormattedMessage id=\"store/flowFinance.accountCreate.businessInfo.instructions\" />\n </div>\n <section\n className={`${handles.businessInfoSection} flex flex-row flex-wrap mb7`}\n >\n <div className=\"w-50-ns w-100-s pa2 pb4\">\n <Input\n label={intl.formatMessage(messages.cnpjLabel)}\n value={formatCNPJ(businessInformation.businessId)}\n readOnly\n />\n </div>\n <div className=\"w-50-ns w-100-s pa2 pb4\">\n <Input\n label={intl.formatMessage(messages.companyPhoneLabel)}\n value={formattedPhone}\n onChange={(e: React.FormEvent<HTMLInputElement>) => {\n const newValue = e.currentTarget.value.replace(/[^\\d]/g, '')\n setFormattedPhone(() => formatPhone(newValue))\n dispatch({\n type: 'SET_BUSINESS_FIELD',\n args: {\n field: 'phoneNumber',\n value: newValue,\n },\n })\n }}\n onBlur={() => setShowPhoneError(true)}\n errorMessage={\n (showErrors || showPhoneError) &&\n (businessInformation.phoneNumber.length < 10 ||\n businessInformation.phoneNumber.length > 11)\n ? intl.formatMessage(messages.companyPhoneError)\n : ''\n }\n />\n </div>\n <div className=\"w-50-ns w-100-s pa2 pb4\">\n <Input\n label={intl.formatMessage(messages.companyNameLabel)}\n value={businessInformation.name}\n onChange={(e: React.FormEvent<HTMLInputElement>) => {\n dispatch({\n type: 'SET_BUSINESS_FIELD',\n args: {\n field: 'name',\n value: e.currentTarget.value,\n },\n })\n }}\n onBlur={() => setShowNameError(true)}\n errorMessage={\n (showErrors || showNameError) && businessInformation.name === ''\n ? intl.formatMessage(messages.companyNameError)\n : ''\n }\n />\n </div>\n <div className=\"w-50-ns w-100-s pa2 pb4\">\n <Input\n label={intl.formatMessage(messages.companyLegalNameLabel)}\n value={businessInformation.legalName}\n onChange={(e: React.FormEvent<HTMLInputElement>) => {\n dispatch({\n type: 'SET_BUSINESS_FIELD',\n args: {\n field: 'legalName',\n value: e.currentTarget.value,\n },\n })\n }}\n onBlur={() => setShowLegalNameError(true)}\n errorMessage={\n (showErrors || showLegalNameError) &&\n businessInformation.legalName === ''\n ? intl.formatMessage(messages.companyLegalNameError)\n : ''\n }\n />\n </div>\n </section>\n <Divider orientation=\"horizontal\" />\n <section className={`${handles.businessAddressSection} mt7 mb7`}>\n <AddressContainer\n address={address}\n Input={StyleguideInput}\n onChangeAddress={(newAddress: AddressFormFields) =>\n handleAddressChange(newAddress)\n }\n autoCompletePostalCode\n >\n <PostalCodeGetter />\n <AddressFields\n address={address}\n Input={StyleguideInput}\n omitAutoCompletedFields={false}\n omitPostalCodeFields\n onChangeAddress={(newAddress: AddressFormFields) =>\n handleAddressFieldChange(newAddress)\n }\n notApplicableLabel={intl.formatMessage({\n id: 'store/flowFinance.accountCreate.addressNotApplicable',\n })}\n />\n </AddressContainer>\n </section>\n <Divider orientation=\"horizontal\" />\n <div\n className={`${handles.businessInfoPageButtonContainer} mt6`}\n onClick={() => handleShowErrors()}\n >\n <Button\n variation=\"primary\"\n disabled={!businessInfoValid}\n onClick={() => handleContinueClick()}\n >\n <FormattedMessage id=\"store/flowFinance.accountCreate.businessInfo.submit\" />\n </Button>\n </div>\n </div>\n )\n}\n\nexport default injectIntl(injectRules(BusinessInfoPage))\n\n```"
}
] |
code_flow-finance-components_1b11054f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/components/AccountCreatePages/DocumentDropzone.tsx from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useState, Fragment } from 'react'\nimport { useIntl, defineMessages, FormattedMessage } from 'react-intl'\nimport { useDropzone } from 'react-dropzone'\nimport { ButtonWithIcon, IconDelete, Spinner, Divider } from 'vtex.styleguide'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport {\n useAccountCreateState,\n useAccountCreateDispatch,\n} from '../AccountCreateContext'\nimport IconUpload from '../../images/upload.svg'\nimport IconWarning from '../../images/warning.svg'\n\ninterface DropProps {\n maxSize: number\n documentType: string\n}\n\nconst messages = defineMessages({\n fileSizeError: {\n defaultMessage: 'File exceeds the size limit. Please choose a smaller one.',\n id: 'store/flowFinance.accountCreate.documents.fileSizeError',\n },\n genericError: {\n defaultMessage: 'Something went wrong. Please try again.',\n id: 'store/flowFinance.accountCreate.documents.genericError',\n },\n selectFileBtn: {\n defaultMessage: 'Select',\n id: 'store/flowFinance.accountCreate.documents.selectFileButton',\n },\n cnhLabel: {\n defaultMessage: 'CNH',\n id: 'store/flowFinance.accountCreate.documents.cnhLabel',\n },\n rgLabel: {\n defaultMessage: 'RG',\n id: 'store/flowFinance.accountCreate.documents.rgLabel',\n },\n})\n\nconst CSS_HANDLES = [\n 'dropzoneContainer',\n 'dropzoneRadioOptions',\n 'dropzoneRadioOption',\n 'dropzoneRadioOptionInput',\n 'dropzoneRadioLabelText',\n 'dropzoneErrorContainer',\n 'dropzoneErrorIcon',\n 'dropzoneErrorText',\n 'dropzoneFilenameContainer',\n 'dropzoneFilenameText',\n 'dropzoneUploadContainer',\n 'dropzoneUploadIcon',\n 'dropzoneUploadInstructions',\n 'dropzoneUploadButton',\n 'dropzoneUploadButtonText',\n] as const\n\nconst DocumentDropzone: StorefrontFunctionComponent<DropProps> = ({\n maxSize,\n documentType,\n}) => {\n const intl = useIntl()\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<string | null>()\n const { businessInformation, personalInformation } = useAccountCreateState()\n const dispatch = useAccountCreateDispatch()\n const handles = useCssHandles(CSS_HANDLES)\n\n // function getBase64(file: File) {\n // return new Promise((resolve, reject) => {\n // const reader = new FileReader()\n // reader.onload = () => {\n // resolve(reader.result)\n // }\n // reader.onerror = reject\n // reader.readAsDataURL(file)\n // })\n // }\n\n const onDropImage = async (files: File[]) => {\n setError(null)\n try {\n if (files?.[0]) {\n setIsLoading(true)\n\n // const base64EncodedFile = (await getBase64(files[0])) as string\n\n dispatch({\n type:\n documentType === 'business'\n ? 'SET_BUSINESS_FIELD'\n : 'SET_PERSONAL_FIELD',\n args: {\n field: 'physicalDocFile',\n value: files[0],\n // value: base64EncodedFile.split(',')[1],\n },\n })\n dispatch({\n type:\n documentType === 'business'\n ? 'SET_BUSINESS_FIELD'\n : 'SET_PERSONAL_FIELD',\n args: {\n field: 'physicalDocFileName',\n value: files[0].name,\n },\n })\n setIsLoading(false)\n } else {\n return setError(intl.formatMessage(messages.fileSizeError))\n }\n } catch (err) {\n setError(intl.formatMessage(messages.genericError))\n setIsLoading(false)\n }\n }\n\n const { getInputProps, getRootProps } = useDropzone({\n accept:\n documentType === 'business'\n ? ['.pdf', '.jpg', '.jpeg', '.png']\n : ['.jpg', '.jpeg', '.png'],\n maxSize,\n multiple: false,\n onDrop: onDropImage,\n })\n\n async function handlePersonalDocTypeChange(newType: string) {\n dispatch({\n type: 'SET_PERSONAL_FIELD',\n args: {\n field: 'docType',\n value: newType,\n },\n })\n }\n\n async function handleRemoveFile() {\n setError(null)\n setIsLoading(true)\n dispatch({\n type:\n documentType === 'business'\n ? 'SET_BUSINESS_FIELD'\n : 'SET_PERSONAL_FIELD',\n args: {\n field: 'physicalDocValue',\n value: '',\n },\n })\n dispatch({\n type:\n documentType === 'business'\n ? 'SET_BUSINESS_FIELD'\n : 'SET_PERSONAL_FIELD',\n args: {\n field: 'physicalDocFileName',\n value: '',\n },\n })\n setIsLoading(false)\n }\n\n return (\n <div\n className={`${handles.dropzoneContainer} pa7 br3 b--dashed b--muted-4 bw2 tc mb7`}\n >\n {documentType === 'personal' && (\n <Fragment>\n <div className={`${handles.dropzoneRadioOptions} mb5`}>\n <label className={`${handles.dropzoneRadioOption} pa4`}>\n <input\n type=\"radio\"\n name=\"document\"\n checked={personalInformation.docType === 'CNH'}\n value=\"CNH\"\n id=\"cnh\"\n onChange={() => handlePersonalDocTypeChange('CNH')}\n className={`${handles.dropzoneRadioOptionInput}`}\n />\n {` `}\n <span className={`${handles.dropzoneRadioLabelText}`}>\n {intl.formatMessage(messages.cnhLabel)}\n </span>\n </label>\n <label className={`${handles.dropzoneRadioOption} pa4`}>\n <input\n type=\"radio\"\n name=\"document\"\n checked={personalInformation.docType === 'RG'}\n value=\"RG\"\n id=\"rg\"\n onChange={() => handlePersonalDocTypeChange('RG')}\n className={`${handles.dropzoneRadioOptionInput}`}\n />\n {` `}\n <span className={`${handles.dropzoneRadioLabelText}`}>\n {intl.formatMessage(messages.rgLabel)}\n </span>\n </label>\n </div>\n <Divider orientation=\"horizontal\" />\n </Fragment>\n )}\n {error && (\n <Fragment>\n <div\n className={`${handles.dropzoneErrorContainer} flex flex-row c-danger t-small justify-center items-center mt7 mb7 ph7`}\n >\n <img\n className={`${handles.dropzoneErrorIcon}`}\n src={IconWarning}\n alt=\"Warning\"\n />\n <span className={`${handles.dropzoneErrorText}`}>{error}</span>\n </div>\n <Divider orientation=\"horizontal\" />\n </Fragment>\n )}\n <div {...getRootProps()}>\n {isLoading ? (\n <div>\n <Spinner size={32} />\n </div>\n ) : (documentType === 'business' &&\n businessInformation.physicalDocFileName) ||\n (documentType === 'personal' &&\n personalInformation.physicalDocFileName) ? (\n <div\n className={`${handles.dropzoneFilenameContainer} black-70 flex flex-row justify-between items-center`}\n >\n <span className={`${handles.dropzoneFilenameText}`}>\n {documentType === 'business' &&\n businessInformation.physicalDocFileName}\n {documentType === 'personal' &&\n personalInformation.physicalDocFileName}\n </span>\n <ButtonWithIcon\n onClick={() => handleRemoveFile()}\n variation=\"tertiary\"\n icon={<IconDelete />}\n />\n </div>\n ) : (\n <div className={`${handles.dropzoneUploadContainer} pt7 pb7`}>\n <input {...getInputProps()} />\n <img\n className={`${handles.dropzoneUploadIcon}`}\n src={IconUpload}\n alt=\"Upload Icon\"\n />\n <div className={`${handles.dropzoneUploadInstructions} ma3`}>\n <FormattedMessage\n id=\"store/flowFinance.accountCreate.documents.uploadInstructions\"\n values={{\n lineBreak: <br />,\n }}\n />\n </div>\n <button\n className={`${handles.dropzoneUploadButton} vtex-button bw1 ba fw5 v-mid relative pa0 lh-solid br2 min-h-small t-action--small bg-action-primary b--action-primary c-on-action-primary hover-bg-action-primary hover-b--action-primary hover-c-on-action-primary pointer`}\n type=\"button\"\n >\n <div\n className={`${handles.dropzoneUploadButtonText} vtex-button__label flex items-center justify-center h-100 ph5`}\n style={{ paddingTop: '.25em', paddingBottom: '.32em' }}\n >\n {intl.formatMessage(messages.selectFileBtn)}\n </div>\n </button>\n <div className=\"t-mini mt3\">\n <FormattedMessage\n id=\"store/flowFinance.accountCreate.documents.fileRestrictions\"\n values={{\n businessFileType: documentType === 'business' ? 'PDF, ' : '',\n fileSize: documentType === 'business' ? '10' : '3',\n }}\n />\n </div>\n </div>\n )}\n </div>\n </div>\n )\n}\n\nexport default DocumentDropzone\n\n```"
}
] |
code_flow-finance-components_24a6fd28
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/components/AccountCreatePages/AccountCreateSteps.tsx from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { injectIntl, WrappedComponentProps, FormattedMessage } from 'react-intl'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { Divider } from 'vtex.styleguide'\n\nimport {\n useAccountCreateState,\n useAccountCreateDispatch,\n} from '../AccountCreateContext'\nimport IconCheck from '../../images/check.svg'\n\nconst CSS_HANDLES = [\n 'accountCreateStepsContainer',\n 'accountCreateStep',\n 'accountCreateStepNumberContainer',\n 'accountCreateStepNumber',\n 'accountCreateStepLabel',\n] as const\n\nconst AccountCreateSteps: StorefrontFunctionComponent<WrappedComponentProps> = () => {\n const handles = useCssHandles(CSS_HANDLES)\n const {\n currentPage,\n businessInfoComplete,\n personalInfoComplete,\n documentsComplete,\n } = useAccountCreateState()\n const dispatch = useAccountCreateDispatch()\n\n if (currentPage < 3) return null\n\n async function handlePageChange(page: number) {\n if (currentPage === page) return\n dispatch({\n type: 'SET_CURRENT_PAGE',\n args: {\n page,\n },\n })\n window.scrollTo(0, 0)\n }\n\n return (\n <div\n className={`${handles.accountCreateStepsContainer} flex flex-row justify-between pb6 mb6`}\n style={{ borderBottom: '2px solid black' }}\n >\n <div className={`${handles.accountCreateStep} tc ph3`}>\n <div className={handles.accountCreateStepNumberContainer}>\n <button\n className={`input-reset button-reset br-100 mb2 b--none bg-base--inverted ${\n currentPage !== 6 ? 'pointer' : ''\n }`}\n style={{ width: 32, height: 32 }}\n onClick={() => handlePageChange(3)}\n disabled={currentPage === 6}\n >\n <span className={`${handles.accountCreateStepNumber} white`}>\n {!businessInfoComplete ? (\n '1'\n ) : (\n <img src={IconCheck} alt=\"Complete\" />\n )}\n </span>\n </button>\n </div>\n <div className={handles.accountCreateStepLabel}>\n <FormattedMessage id=\"store/flowFinance.accountCreate.steps.businessInfo\" />\n </div>\n </div>\n <div className=\"flex-grow-1 flex flex-column justify-center\">\n <Divider orientation=\"horizontal\" />\n </div>\n <div className={`${handles.accountCreateStep} tc ph3`}>\n <div className={handles.accountCreateStepNumberContainer}>\n <button\n className={`input-reset button-reset br-100 mb2 b--none ${\n currentPage > 3 ? 'bg-base--inverted' : 'bg-muted-3'\n } ${currentPage !== 6 && businessInfoComplete ? 'pointer' : ''}`}\n style={{ width: 32, height: 32 }}\n onClick={() => handlePageChange(4)}\n disabled={!businessInfoComplete || currentPage === 6}\n >\n <span className={`${handles.accountCreateStepNumber} white`}>\n {!personalInfoComplete ? (\n '2'\n ) : (\n <img src={IconCheck} alt=\"Complete\" />\n )}\n </span>\n </button>\n </div>\n <div\n className={`${handles.accountCreateStepLabel} ${\n currentPage > 3 ? '' : 'c-muted-4'\n }`}\n >\n <FormattedMessage id=\"store/flowFinance.accountCreate.steps.personalInfo\" />\n </div>\n </div>\n <div className=\"flex-grow-1 flex flex-column justify-center\">\n <Divider orientation=\"horizontal\" />\n </div>\n <div className={`${handles.accountCreateStep} tc ph3`}>\n <div className={handles.accountCreateStepNumberContainer}>\n <button\n className={`input-reset button-reset br-100 mb2 b--none ${\n currentPage > 4 ? 'bg-base--inverted' : 'bg-muted-3'\n } ${currentPage !== 6 && personalInfoComplete ? 'pointer' : ''}`}\n style={{ width: 32, height: 32 }}\n onClick={() => handlePageChange(5)}\n disabled={!personalInfoComplete || currentPage === 6}\n >\n <span className={`${handles.accountCreateStepNumber} white`}>\n {!documentsComplete ? (\n '3'\n ) : (\n <img src={IconCheck} alt=\"Complete\" />\n )}\n </span>\n </button>\n </div>\n <div\n className={`${handles.accountCreateStepLabel} ${\n currentPage > 4 ? '' : 'c-muted-4'\n }`}\n >\n <FormattedMessage id=\"store/flowFinance.accountCreate.steps.documents\" />\n </div>\n </div>\n </div>\n )\n}\n\nexport default injectIntl(AccountCreateSteps)\n\n```"
}
] |
code_flow-finance-components_6e349a89
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/components/AccountCreatePages/SuccessPage.tsx from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { FormattedMessage, injectIntl, WrappedComponentProps } from 'react-intl'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { Button, Divider } from 'vtex.styleguide'\n\ninterface SuccessProps {\n handleExit: () => void\n settings: Settings\n}\n\ninterface Settings {\n storeName: string\n storePaymentName: string\n}\n\nconst CSS_HANDLES = [\n 'successPageContainer',\n 'successPageTitle',\n 'successPageMessage',\n 'successPageButtonContainer',\n] as const\n\nconst SuccessPage: StorefrontFunctionComponent<SuccessProps &\n WrappedComponentProps> = ({ handleExit, settings }) => {\n const handles = useCssHandles(CSS_HANDLES)\n\n return (\n <div className={handles.successPageContainer}>\n <h1 className={handles.successPageTitle}>\n <FormattedMessage id=\"store/flowFinance.accountCreate.successPage.title\" />\n </h1>\n <div className={`${handles.successPageMessage} mb6`}>\n <FormattedMessage\n id=\"store/flowFinance.accountCreate.successPage.message\"\n values={{\n lineBreak: <br />,\n storePaymentName: settings.storePaymentName,\n }}\n />\n </div>\n <Divider orientation=\"horizontal\" />\n <div className={`${handles.successPageButtonContainer} mt6`}>\n <Button variation=\"primary\" onClick={() => handleExit()}>\n <FormattedMessage id=\"store/flowFinance.accountCreate.continueShopping\" />\n </Button>\n </div>\n </div>\n )\n}\n\nexport default injectIntl(SuccessPage)\n\n```"
}
] |
code_flow-finance-components_ffeb2d12
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/components/AccountCreatePages/IntroPage.tsx from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useEffect, useState } from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport { useQuery } from 'react-apollo'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { Button, Divider } from 'vtex.styleguide'\n\nimport {\n useAccountCreateState,\n useAccountCreateDispatch,\n} from '../AccountCreateContext'\nimport IconMouse from '../../images/mouse.svg'\nimport IconCart from '../../images/cart.svg'\nimport FlowFinanceLogo from '../../images/flow-finance-logo.png'\nimport Profile from '../../graphql/Profile.graphql'\n\ninterface Props {\n settings: Settings\n checkAccount: boolean\n}\n\ninterface Settings {\n storeName: string\n storePaymentName: string\n}\n\nconst CSS_HANDLES = [\n 'introPageContainer',\n 'introPageInstructions',\n 'introPageTitle',\n 'introPageIconsContainer',\n 'introPageLeftIconContainer',\n 'introPageLeftIcon',\n 'introPageLeftIconTitle',\n 'introPageLeftIconText',\n 'introPageRightIconContainer',\n 'introPageRightIcon',\n 'introPageRightIconTitle',\n 'introPageRightIconText',\n `introPageButtonContainer`,\n 'introPageAccountErrorContainer',\n `poweredByContainer`,\n] as const\n\nconst IntroPage: StorefrontFunctionComponent<Props> = ({\n settings,\n checkAccount,\n}) => {\n const { currentPage } = useAccountCreateState()\n const dispatch = useAccountCreateDispatch()\n const [accountStatus, setAccountStatus] = useState('none')\n const handles = useCssHandles(CSS_HANDLES)\n const { data } = useQuery(Profile, { skip: !checkAccount })\n\n async function postData(url = '', dataToPost = {}) {\n const response = await fetch(url, {\n method: 'POST',\n mode: 'cors',\n cache: 'no-cache',\n credentials: 'same-origin',\n headers: {\n 'Content-Type': 'application/json',\n },\n redirect: 'follow',\n referrerPolicy: 'no-referrer',\n body: JSON.stringify(dataToPost),\n })\n if (!response.ok) {\n console.error(response)\n return response\n }\n return response.json()\n }\n\n useEffect(() => {\n if (data?.profile) {\n postData(`/_v/api/connectors/flow-finance/get-loan-options`, {\n email: data.profile.email,\n total: 1000,\n }).then(response => {\n setAccountStatus(response.accountStatus)\n })\n }\n }, [data])\n\n return (\n <div className={handles.introPageContainer}>\n <h1 className={`${handles.introPageTitle} tc mb6`}>\n <FormattedMessage id=\"store/flowFinance.accountCreate.introPage.title\" />\n </h1>\n <div className={`${handles.introPageInstructions} tc mb6`}>\n <FormattedMessage\n id=\"store/flowFinance.accountCreate.introPage.instructions\"\n values={{\n storePaymentName: settings.storePaymentName,\n }}\n />\n </div>\n <div\n className={`${handles.introPageIconsContainer} flex flex-row justify-around mb6`}\n >\n <div className={`${handles.introPageLeftIconContainer} w-50 pa3 tc`}>\n <img\n src={IconMouse}\n alt=\"Mouse icon\"\n className={handles.introPageLeftIcon}\n />\n <div className={`${handles.introPageLeftIconTitle} b mt2`}>\n <FormattedMessage id=\"store/flowFinance.accountCreate.introPage.leftIconTitle\" />\n </div>\n <div className={handles.introPageLeftIconText}>\n <FormattedMessage id=\"store/flowFinance.accountCreate.introPage.leftIconText\" />\n </div>\n </div>\n <div className={`${handles.introPageRightIconContainer} w-50 pa3 tc`}>\n <img\n src={IconCart}\n alt=\"Cart icon\"\n className={handles.introPageRightIcon}\n />\n <div className={`${handles.introPageRightIconTitle} b mt2`}>\n <FormattedMessage id=\"store/flowFinance.accountCreate.introPage.rightIconTitle\" />\n </div>\n <div className={handles.introPageRightIconText}>\n <FormattedMessage\n id=\"store/flowFinance.accountCreate.introPage.rightIconText\"\n values={{\n storePaymentName: settings.storePaymentName,\n }}\n />\n </div>\n </div>\n </div>\n <Divider orientation=\"horizontal\" />\n <div\n className={`${handles.introPageButtonContainer} mt6 flex flex-row justify-between`}\n >\n <div>\n <Button\n variation=\"primary\"\n onClick={() => {\n dispatch({\n type: 'SET_CURRENT_PAGE',\n args: {\n page: currentPage + 1,\n },\n })\n window.scrollTo(0, 0)\n }}\n disabled={accountStatus !== 'none' && accountStatus !== 'pending'}\n >\n <FormattedMessage id=\"store/flowFinance.accountCreate.introPage.continue\" />\n </Button>\n <div\n className={`${handles.introPageAccountErrorContainer} mt2 red mw6`}\n >\n {accountStatus === 'under-review' && (\n <FormattedMessage id=\"store/flowFinance.accountCreate.introPage.accountErrors.underReview\" />\n )}\n {accountStatus === 'approved' && (\n <FormattedMessage id=\"store/flowFinance.accountCreate.introPage.accountErrors.approved\" />\n )}\n {accountStatus === 'rejected' && (\n <FormattedMessage id=\"store/flowFinance.accountCreate.introPage.accountErrors.rejected\" />\n )}\n </div>\n </div>\n <div className={`${handles.poweredByContainer} flex flex-row`}>\n <div className=\"flex flex-column justify-center\">\n <FormattedMessage id=\"store/flowFinance.accountCreate.introPage.poweredBy\" />\n </div>\n <img\n src={FlowFinanceLogo}\n alt=\"Flow Finance\"\n className=\"self-center\"\n />\n </div>\n </div>\n </div>\n )\n}\n\nexport default IntroPage\n\n```"
}
] |
code_flow-finance-components_ca9bf375
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/components/AccountCreatePages/PersonalInfoPage.tsx from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport {\n AddressContainer,\n AddressForm as AddressFields,\n inputs,\n helpers,\n PostalCodeGetter,\n} from 'vtex.address-form'\n\nimport React, { useEffect, useState } from 'react'\nimport {\n defineMessages,\n injectIntl,\n WrappedComponentProps,\n FormattedMessage,\n} from 'react-intl'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { Input, Dropdown, Button, Toggle, Divider } from 'vtex.styleguide'\n\nimport {\n useAccountCreateState,\n useAccountCreateDispatch,\n} from '../AccountCreateContext'\nimport {\n formatPhone,\n formatCPF,\n // formatRG,\n // formatRGExp,\n} from './utils/formatters'\n\ninterface AddressProps {\n rules: any\n}\n\nconst { StyleguideInput } = inputs\nconst { addValidation, isValidAddress, validateAddress, injectRules } = helpers\n\nconst CSS_HANDLES = [\n 'personalInfoPageContainer',\n 'personalInfoInstructions',\n 'personalInfoSection',\n 'personalContactSection',\n 'personalAddressSection',\n 'personalInfoPageButtonContainer',\n] as const\n\nconst messages = defineMessages({\n firstNameLabel: {\n defaultMessage: 'First Name',\n id: 'store/flowFinance.accountCreate.firstNameLabel',\n },\n firstNameError: {\n defaultMessage: 'This field is required.',\n id: 'store/flowFinance.accountCreate.firstNameError',\n },\n lastNameLabel: {\n defaultMessage: 'Last Name',\n id: 'store/flowFinance.accountCreate.lastNameLabel',\n },\n lastNameError: {\n defaultMessage: 'This field is required.',\n id: 'store/flowFinance.accountCreate.lastNameError',\n },\n cpfLabel: {\n defaultMessage: 'CPF',\n id: 'store/flowFinance.accountCreate.cpfLabel',\n },\n cpfError: {\n defaultMessage: 'This field is required.',\n id: 'store/flowFinance.accountCreate.cpfError',\n },\n rgLabel: {\n defaultMessage: 'RG',\n id: 'store/flowFinance.accountCreate.rgLabel',\n },\n rgError: {\n defaultMessage: 'This field is required.',\n id: 'store/flowFinance.accountCreate.rgError',\n },\n rgExpLabel: {\n defaultMessage: 'RG Expiration Date (DD/MM/YYYY)',\n id: 'store/flowFinance.accountCreate.rgExpLabel',\n },\n rgExpError: {\n defaultMessage: 'This field is required.',\n id: 'store/flowFinance.accountCreate.rgExpError',\n },\n phoneNumberLabel: {\n defaultMessage: 'Phone Number',\n id: 'store/flowFinance.accountCreate.personalPhoneLabel',\n },\n phoneNumberError: {\n defaultMessage: 'Please enter a valid phone number.',\n id: 'store/flowFinance.accountCreate.personalPhoneError',\n },\n pepLabel: {\n defaultMessage: 'PEP',\n id: 'store/flowFinance.accountCreate.pepLabel',\n },\n pepText: {\n defaultMessage: '',\n id: 'store/flowFinance.accountCreate.pepText',\n },\n pepLinkText: {\n defaultMessage: '',\n id: 'store/flowFinance.accountCreate.pepLinkText',\n },\n emailLabel: {\n defaultMessage: 'Email',\n id: 'store/flowFinance.accountCreate.emailLabel',\n },\n emailError: {\n defaultMessage: 'Please enter a valid email address.',\n id: 'store/flowFinance.accountCreate.emailError',\n },\n maritalStatusLabel: {\n defaultMessage: 'Marital Status',\n id: 'store/flowFinance.accountCreate.maritalStatusLabel',\n },\n maritalStatusError: {\n defaultMessage: 'Please choose a marital status.',\n id: 'store/flowFinance.accountCreate.maritalStatusError',\n },\n singleLabel: {\n defaultMessage: 'Single',\n id: 'store/flowFinance.accountCreate.maritalStatusOptions.single',\n },\n marriedLabel: {\n defaultMessage: 'Married',\n id: 'store/flowFinance.accountCreate.maritalStatusOptions.married',\n },\n separatedLabel: {\n defaultMessage: 'Legally Separated',\n id: 'store/flowFinance.accountCreate.maritalStatusOptions.separated',\n },\n divorcedLabel: {\n defaultMessage: 'Divorced',\n id: 'store/flowFinance.accountCreate.maritalStatusOptions.divorced',\n },\n widowedLabel: {\n defaultMessage: 'Widowed',\n id: 'store/flowFinance.accountCreate.maritalStatusOptions.widowed',\n },\n otherStatusLabel: {\n defaultMessage: 'Other',\n id: 'store/flowFinance.accountCreate.maritalStatusOptions.other',\n },\n})\n\nlet gguid = 1\n\nfunction getGGUID() {\n return (gguid++ * new Date().getTime() * -1).toString()\n}\n\nconst PersonalInfoPage: StorefrontFunctionComponent<WrappedComponentProps &\n AddressProps> = ({ intl, rules }) => {\n const {\n personalInformation,\n personalAddress,\n personalInfoValid,\n currentPage,\n } = useAccountCreateState()\n const dispatch = useAccountCreateDispatch()\n const handles = useCssHandles(CSS_HANDLES)\n const [formattedPhone, setFormattedPhone] = useState(\n formatPhone(personalInformation.phoneNumber)\n )\n const [formattedCPF, setFormattedCPF] = useState(\n formatCPF(personalInformation.idNumber)\n )\n const [showErrors, setShowErrors] = useState(false)\n const [showPhoneError, setShowPhoneError] = useState(false)\n const [showFirstNameError, setShowFirstNameError] = useState(false)\n const [showLastlNameError, setShowLastNameError] = useState(false)\n const [showEmailError, setShowEmailError] = useState(false)\n const [showCPFError, setShowCPFError] = useState(false)\n const [showMaritalStatusError, setShowMaritalStatusError] = useState(false)\n\n const addressWithValidation = addValidation({\n ...personalAddress,\n addressQuery: null,\n addressId: getGGUID(),\n })\n addressWithValidation.addressId.value = getGGUID()\n addressWithValidation.receiverName.value = 'notApplicable'\n addressWithValidation.receiverName.postalCodeAutoCompleted = true\n const [address, setAddress] = useState(addressWithValidation)\n\n useEffect(() => {\n if (personalInformation.phoneNumber) setShowPhoneError(true)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n useEffect(() => {\n if (\n personalInformation.phoneNumber.length >= 10 &&\n personalInformation.phoneNumber.length <= 11 &&\n personalInformation.email.indexOf('@') >= 0 &&\n personalInformation.email.indexOf('.') >= 0 &&\n personalInformation.firstName !== '' &&\n personalInformation.lastName !== '' &&\n personalInformation.idNumber.length === 11 &&\n personalInformation.maritalStatus !== '' &&\n isValidAddress(address, rules).valid\n ) {\n dispatch({\n type: 'SET_PERSONAL_INFO_VALID',\n args: {\n valid: true,\n },\n })\n } else if (personalInfoValid) {\n dispatch({\n type: 'SET_PERSONAL_INFO_VALID',\n args: {\n valid: false,\n },\n })\n }\n }, [personalInfoValid, personalInformation, address, rules, dispatch])\n\n async function storeAddress() {\n const validAddress = {\n addressId: '',\n addressType: 'residential',\n city: address.city.value,\n complement: address.complement.value || '',\n country: 'BRA',\n geoCoordinates: [],\n receiverName: '',\n reference: '',\n neighborhood: address.neighborhood.value,\n number: address.number.value,\n postalCode: address.postalCode.value,\n state: address.state.value,\n street: address.street.value,\n }\n dispatch({\n type: 'SET_PERSONAL_ADDRESS',\n args: {\n address: validAddress,\n },\n })\n }\n\n async function handleAddressChange(newAddress: AddressFormFields) {\n const curAddress = address\n const combinedAddress = { ...curAddress, ...newAddress }\n setAddress(combinedAddress)\n storeAddress()\n }\n\n async function handleAddressFieldChange(newAddress: AddressFormFields) {\n const [key] = Object.keys(newAddress)\n const curAddress = address\n const validatedField = newAddress[key].value\n ? validateAddress(newAddress, rules)\n : newAddress\n const combinedAddress = { ...curAddress, ...validatedField }\n setAddress(combinedAddress)\n storeAddress()\n }\n\n async function handleShowErrors() {\n const validatedAddress = validateAddress(address, rules)\n setAddress(validatedAddress)\n setShowErrors(true)\n }\n\n async function handleContinueClick() {\n dispatch({\n type: 'SET_PERSONAL_INFO_COMPLETE',\n args: {\n complete: true,\n },\n })\n dispatch({\n type: 'SET_CURRENT_PAGE',\n args: {\n page: currentPage + 1,\n },\n })\n window.scrollTo(0, 0)\n }\n\n return (\n <div className={handles.personalInfoPageContainer}>\n <div className={`${handles.personalInfoInstructions} mb7`}>\n <FormattedMessage id=\"store/flowFinance.accountCreate.personalInfo.instructions\" />\n </div>\n <section\n className={`${handles.personalInfoSection} flex flex-row flex-wrap mb7`}\n >\n <div className=\"w-50-ns w-100-s pa2 pb4\">\n <Input\n label={intl.formatMessage(messages.firstNameLabel)}\n value={personalInformation.firstName}\n onChange={(e: React.FormEvent<HTMLInputElement>) => {\n dispatch({\n type: 'SET_PERSONAL_FIELD',\n args: {\n field: 'firstName',\n value: e.currentTarget.value,\n },\n })\n }}\n onBlur={() => setShowFirstNameError(true)}\n errorMessage={\n (showErrors || showFirstNameError) &&\n personalInformation.firstName === ''\n ? intl.formatMessage(messages.firstNameError)\n : ''\n }\n />\n </div>\n <div className=\"w-50-ns w-100-s pa2 pb4\">\n <Input\n label={intl.formatMessage(messages.lastNameLabel)}\n value={personalInformation.lastName}\n onChange={(e: React.FormEvent<HTMLInputElement>) => {\n dispatch({\n type: 'SET_PERSONAL_FIELD',\n args: {\n field: 'lastName',\n value: e.currentTarget.value,\n },\n })\n }}\n onBlur={() => setShowLastNameError(true)}\n errorMessage={\n (showErrors || showLastlNameError) &&\n personalInformation.lastName === ''\n ? intl.formatMessage(messages.lastNameError)\n : ''\n }\n />\n </div>\n <div className=\"w-50-ns w-100-s pa2 pb4\">\n <Input\n label={intl.formatMessage(messages.cpfLabel)}\n value={formattedCPF}\n onChange={(e: React.FormEvent<HTMLInputElement>) => {\n const newValue = e.currentTarget.value.replace(/[^\\d]/g, '')\n setFormattedCPF(formatCPF(newValue))\n dispatch({\n type: 'SET_PERSONAL_FIELD',\n args: {\n field: 'idNumber',\n value: newValue,\n },\n })\n }}\n onBlur={() => setShowCPFError(true)}\n errorMessage={\n (showErrors || showCPFError) &&\n personalInformation.idNumber.length !== 11\n ? intl.formatMessage(messages.cpfError)\n : ''\n }\n />\n </div>\n <div className=\"w-50-ns w-100-s pa2 pb4\">\n <span className=\"vtex-input__label db mb3 w-100 c-on-base t-small \">\n \n </span>\n <Toggle\n label={intl.formatMessage(messages.pepLabel)}\n checked={personalInformation.pep}\n onChange={(e: React.FormEvent<HTMLInputElement>) =>\n dispatch({\n type: 'SET_PERSONAL_FIELD',\n args: {\n field: 'pep',\n value: e.currentTarget.checked,\n },\n })\n }\n helpText={\n <span>\n {intl.formatMessage(messages.pepText)}{' '}\n <a\n href=\"http://www.cvm.gov.br/legislacao/instrucoes/inst301.html\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {intl.formatMessage(messages.pepLinkText)}\n </a>\n </span>\n }\n />\n </div>\n </section>\n <Divider orientation=\"horizontal\" />\n <section\n className={`${handles.personalContactSection} flex flex-row flex-wrap mt7 mb7`}\n >\n <div className=\"w-50-ns w-100-s pa2 pb4\">\n <Input\n label={intl.formatMessage(messages.phoneNumberLabel)}\n value={formattedPhone}\n onChange={(e: React.FormEvent<HTMLInputElement>) => {\n const newValue = e.currentTarget.value.replace(/[^\\d]/g, '')\n setFormattedPhone(() => formatPhone(newValue))\n dispatch({\n type: 'SET_PERSONAL_FIELD',\n args: {\n field: 'phoneNumber',\n value: newValue,\n },\n })\n }}\n onBlur={() => setShowPhoneError(true)}\n errorMessage={\n (showErrors || showPhoneError) &&\n (personalInformation.phoneNumber.length < 10 ||\n personalInformation.phoneNumber.length > 11)\n ? intl.formatMessage(messages.phoneNumberError)\n : ''\n }\n />\n </div>\n <div className=\"w-50-ns w-100-s pa2 pb4\">\n <Input\n label={intl.formatMessage(messages.emailLabel)}\n value={personalInformation.email}\n onChange={(e: React.FormEvent<HTMLInputElement>) => {\n dispatch({\n type: 'SET_BUSINESS_FIELD',\n args: {\n field: 'email',\n value: e.currentTarget.value,\n },\n })\n dispatch({\n type: 'SET_PERSONAL_FIELD',\n args: {\n field: 'email',\n value: e.currentTarget.value,\n },\n })\n }}\n onBlur={() => setShowEmailError(true)}\n errorMessage={\n (showErrors || showEmailError) &&\n (personalInformation.email === '' ||\n personalInformation.email.indexOf('@') < 0 ||\n personalInformation.email.indexOf('.') < 0)\n ? intl.formatMessage(messages.emailError)\n : ''\n }\n />\n </div>\n <div className=\"w-50-ns w-100-s pa2 pb4\">\n <Dropdown\n label={intl.formatMessage(messages.maritalStatusLabel)}\n value={personalInformation.maritalStatus}\n options={[\n {\n value: 'single',\n label: intl.formatMessage(messages.singleLabel),\n },\n {\n value: 'married',\n label: intl.formatMessage(messages.marriedLabel),\n },\n {\n value: 'legally-separated',\n label: intl.formatMessage(messages.separatedLabel),\n },\n {\n value: 'divorced',\n label: intl.formatMessage(messages.divorcedLabel),\n },\n {\n value: 'widowed',\n label: intl.formatMessage(messages.widowedLabel),\n },\n {\n value: 'other',\n label: intl.formatMessage(messages.otherStatusLabel),\n },\n ]}\n onChange={(e: React.FormEvent<HTMLSelectElement>) => {\n setShowMaritalStatusError(true)\n dispatch({\n type: 'SET_PERSONAL_FIELD',\n args: {\n field: 'maritalStatus',\n value: e.currentTarget.value,\n },\n })\n }}\n errorMessage={\n (showErrors || showMaritalStatusError) &&\n personalInformation.maritalStatus === ''\n ? intl.formatMessage(messages.maritalStatusError)\n : ''\n }\n />\n </div>\n </section>\n <Divider orientation=\"horizontal\" />\n <section className={`${handles.personalAddressSection} mt7 mb7`}>\n <AddressContainer\n address={address}\n Input={StyleguideInput}\n onChangeAddress={(newAddress: AddressFormFields) =>\n handleAddressChange(newAddress)\n }\n autoCompletePostalCode\n >\n <PostalCodeGetter />\n <AddressFields\n address={address}\n Input={StyleguideInput}\n omitAutoCompletedFields={false}\n omitPostalCodeFields\n onChangeAddress={(newAddress: AddressFormFields) =>\n handleAddressFieldChange(newAddress)\n }\n notApplicableLabel={intl.formatMessage({\n id: 'store/flowFinance.accountCreate.addressNotApplicable',\n })}\n />\n </AddressContainer>\n </section>\n <Divider orientation=\"horizontal\" />\n <div\n className={`${handles.personalInfoPageButtonContainer} mt6`}\n onClick={() => handleShowErrors()}\n >\n <Button\n variation=\"primary\"\n disabled={!personalInfoValid}\n onClick={() => handleContinueClick()}\n >\n <FormattedMessage id=\"store/flowFinance.accountCreate.personalInfo.submit\" />\n </Button>\n </div>\n </div>\n )\n}\n\nexport default injectIntl(injectRules(PersonalInfoPage))\n\n```"
}
] |
code_flow-finance-components_2c12a38d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/components/AccountCreatePages/DocumentsPage.tsx from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useState, useEffect } from 'react'\nimport {\n injectIntl,\n defineMessages,\n WrappedComponentProps,\n FormattedMessage,\n} from 'react-intl'\nimport { useCssHandles } from 'vtex.css-handles'\nimport {\n Button,\n Divider,\n Checkbox,\n ButtonWithIcon,\n IconDelete,\n} from 'vtex.styleguide'\nimport { useMutation } from 'react-apollo'\n\nimport {\n useAccountCreateState,\n useAccountCreateDispatch,\n} from '../AccountCreateContext'\nimport { formatPhone } from './utils/formatters'\nimport DocumentDropzone from './DocumentDropzone'\nimport IconId from '../../images/id.svg'\nimport IconIdGray from '../../images/id-gray.svg'\nimport IconContrato from '../../images/contrato.svg'\nimport IconContratoGray from '../../images/contrato-gray.svg'\nimport ProcessApplication from '../../graphql/ProcessApplication.graphql'\n\ninterface DocumentsPageProps {\n settings: Settings\n}\n\ninterface Settings {\n tosPdfPath: string\n}\n\nconst CSS_HANDLES = [\n 'documentsPageContainer',\n 'documentsPageInstructions',\n 'documentTypesContainer',\n 'documentTypeContainer',\n 'documentTypeIcon',\n 'documentTypeLabel',\n 'documentFilenameContainer',\n 'documentFilenameText',\n 'documentRemoveButton',\n 'documentUploadButton',\n 'documentUploadButtonText',\n 'tosAcceptanceContainer',\n 'tosIframeContainer',\n 'tosAcceptanceCheckbox',\n 'tosAcceptanceCheckboxLabel',\n 'documentsPageButtonContainer',\n 'documentsPageErrorContainer',\n] as const\n\nconst messages = defineMessages({\n submitError: {\n defaultMessage:\n 'There was an error submitting your application. Please try again.',\n id: 'store/flowFinance.accountCreate.submitApplication.error',\n },\n})\n\nconst DocumentsPage: StorefrontFunctionComponent<DocumentsPageProps &\n WrappedComponentProps> = ({ settings: { tosPdfPath }, intl }) => {\n const handles = useCssHandles(CSS_HANDLES)\n const [pageMode, setPageMode] = useState('select')\n const [pdfLoaded, setPdfLoaded] = useState(false)\n const [tosAccepted, setTosAccepted] = useState(false)\n const [isLoading, setIsLoading] = useState(false)\n const [submitError, setSubmitError] = useState('')\n const {\n businessInformation,\n businessAddress,\n personalInformation,\n personalAddress,\n documentsValid,\n currentPage,\n } = useAccountCreateState()\n const dispatch = useAccountCreateDispatch()\n\n const [submitApplication] = useMutation(ProcessApplication)\n\n useEffect(() => {\n if (\n businessInformation.physicalDocFile &&\n personalInformation.physicalDocFile\n ) {\n dispatch({\n type: 'SET_DOCUMENTS_VALID',\n args: {\n valid: true,\n },\n })\n } else if (documentsValid) {\n dispatch({\n type: 'SET_DOCUMENTS_VALID',\n args: {\n valid: false,\n },\n })\n }\n }, [\n businessInformation.physicalDocFile,\n dispatch,\n documentsValid,\n personalInformation.physicalDocFile,\n ])\n\n async function handlePageModeChange(newPageMode: string) {\n setPageMode(newPageMode)\n window.scrollTo(0, 0)\n }\n\n async function handleRemoveFile(documentType: string) {\n dispatch({\n type:\n documentType === 'business'\n ? 'SET_BUSINESS_FIELD'\n : 'SET_PERSONAL_FIELD',\n args: {\n field: 'physicalDocValue',\n value: '',\n },\n })\n dispatch({\n type:\n documentType === 'business'\n ? 'SET_BUSINESS_FIELD'\n : 'SET_PERSONAL_FIELD',\n args: {\n field: 'physicalDocFileName',\n value: '',\n },\n })\n }\n\n async function handleContinueClick() {\n setIsLoading(true)\n submitApplication({\n variables: {\n application: {\n businessInfo: {\n businessId: businessInformation.businessId,\n name: businessInformation.name,\n legalName: businessInformation.legalName,\n address: {\n streetName: businessAddress.street,\n streetNumber: businessAddress.number,\n postalCode: businessAddress.postalCode,\n district: businessAddress.neighborhood,\n city: businessAddress.city,\n stateCode: businessAddress.state,\n country: businessAddress.country,\n extraAddressInfo: businessAddress.complement,\n },\n contactInfo: {\n email: businessInformation.email,\n phoneNumber: formatPhone(businessInformation.phoneNumber),\n },\n documents: {\n physicalDocument: [\n {\n type: businessInformation.docType,\n },\n ],\n },\n },\n personalInfo: {\n idNumber: personalInformation.idNumber,\n maritalStatus: personalInformation.maritalStatus,\n pep: personalInformation.pep,\n lastName: personalInformation.lastName,\n firstName: personalInformation.firstName,\n address: {\n streetName: personalAddress.street,\n streetNumber: personalAddress.number,\n postalCode: personalAddress.postalCode,\n district: personalAddress.neighborhood,\n city: personalAddress.city,\n stateCode: personalAddress.state,\n country: personalAddress.country,\n extraAddressInfo: personalAddress.complement,\n },\n documents: {\n physicalDocument: [\n {\n type: personalInformation.docType,\n },\n ],\n },\n contactInfo: {\n email: personalInformation.email,\n phoneNumber: formatPhone(personalInformation.phoneNumber),\n },\n accountOpener: personalInformation.accountOpener,\n },\n tosAcceptance: {\n userAgent: navigator.userAgent,\n },\n },\n businessInfoFile: businessInformation.physicalDocFile,\n personalInfoFile: personalInformation.physicalDocFile,\n },\n }).then(\n response => {\n if (\n !response.data ||\n !response.data.processApplication ||\n (!response.data.processApplication.success &&\n !response.data.processApplication.error)\n ) {\n setSubmitError(intl.formatMessage(messages.submitError))\n setIsLoading(false)\n return\n }\n if (\n !response.data.processApplication.success &&\n response.data.processApplication.error\n ) {\n setSubmitError(intl.formatMessage(messages.submitError))\n console.error(response.data.processApplication.error)\n setIsLoading(false)\n return\n }\n setSubmitError('')\n dispatch({\n type: 'SET_DOCUMENTS_COMPLETE',\n args: {\n complete: true,\n },\n })\n dispatch({\n type: 'SET_CURRENT_PAGE',\n args: {\n page: currentPage + 1,\n },\n })\n window.scrollTo(0, 0)\n },\n () => {\n setSubmitError(intl.formatMessage(messages.submitError))\n setIsLoading(false)\n }\n )\n }\n\n switch (pageMode) {\n case 'personal': {\n return (\n <div className={handles.documentsPageContainer}>\n <DocumentDropzone documentType=\"personal\" maxSize={3 * 1024 * 1024} />\n <Divider orientation=\"horizontal\" />\n <div className=\"mt6\">\n <Button\n variation=\"primary\"\n onClick={() => handlePageModeChange('select')}\n disabled={!personalInformation.physicalDocFile}\n >\n <FormattedMessage id=\"store/flowFinance.accountCreate.documents.continueLabel\" />\n </Button>\n </div>\n </div>\n )\n }\n case 'business': {\n return (\n <div className={handles.documentsPageContainer}>\n <DocumentDropzone\n documentType=\"business\"\n maxSize={10 * 1024 * 1024}\n />\n <Divider orientation=\"horizontal\" />\n <div className=\"mt6\">\n <Button\n variation=\"primary\"\n onClick={() => handlePageModeChange('select')}\n disabled={!businessInformation.physicalDocFile}\n >\n <FormattedMessage id=\"store/flowFinance.accountCreate.documents.continueLabel\" />\n </Button>\n </div>\n </div>\n )\n }\n default: {\n return (\n <div className={handles.documentsPageContainer}>\n <div className={`${handles.documentsPageInstructions} mb7`}>\n <FormattedMessage id=\"store/flowFinance.accountCreate.documents.instructions\" />\n </div>\n <div\n className={`${handles.documentTypesContainer} flex flex-row justify-between mb7`}\n >\n <div className={`${handles.documentTypeContainer} w-50 pa2 tc`}>\n <img\n src={!personalInformation.physicalDocFile ? IconIdGray : IconId}\n alt=\"ID Icon\"\n className={`${handles.documentTypeIcon}`}\n />\n <div\n className={`${handles.documentTypeLabel} ma3 ${\n !personalInformation.physicalDocFile ? 'c-muted-4' : ''\n }`}\n >\n <FormattedMessage id=\"store/flowFinance.accountCreate.documents.personalIdLabel\" />\n </div>\n {personalInformation.physicalDocFileName !== '' ? (\n <div\n className={`${handles.documentFilenameContainer} ma3 flex flex-row justify-center items-center`}\n >\n <span className={`${handles.documentFilenameText}`}>\n {personalInformation.physicalDocFileName}\n </span>\n <ButtonWithIcon\n onClick={() => handleRemoveFile('personal')}\n variation=\"tertiary\"\n icon={<IconDelete />}\n className={`${handles.documentRemoveButton}`}\n />\n </div>\n ) : (\n <button\n onClick={() => handlePageModeChange('personal')}\n className={`${handles.documentUploadButton} vtex-button bw1 ba fw5 v-mid relative pa0 lh-solid br2 min-h-regular t-action bg-action-secondary b--action-secondary c-on-action-secondary hover-bg-action-secondary hover-b--action-secondary hover-c-on-action-secondary pointer`}\n type=\"button\"\n >\n <div\n className={`${handles.documentUploadButtonText} vtex-button__label flex items-center justify-center h-100 ph6`}\n style={{ paddingTop: '0.25em', paddingBottom: '0.32em' }}\n >\n <FormattedMessage id=\"store/flowFinance.accountCreate.documents.uploadLabel\" />\n </div>\n </button>\n )}\n </div>\n <div className={`${handles.documentTypeContainer} w-50 pa2 tc`}>\n <img\n src={\n !businessInformation.physicalDocFile\n ? IconContratoGray\n : IconContrato\n }\n alt=\"ID Icon\"\n className={`${handles.documentTypeIcon}`}\n />\n <div\n className={`${handles.documentTypeLabel} ma3 ${\n !businessInformation.physicalDocFile ? 'c-muted-4' : ''\n }`}\n >\n <FormattedMessage id=\"store/flowFinance.accountCreate.documents.businessIdLabel\" />\n </div>\n {businessInformation.physicalDocFileName !== '' ? (\n <div\n className={`${handles.documentFilenameContainer} ma3 flex flex-row justify-center items-center`}\n >\n <span className={`${handles.documentFilenameText}`}>\n {businessInformation.physicalDocFileName}\n </span>\n <ButtonWithIcon\n onClick={() => handleRemoveFile('business')}\n variation=\"tertiary\"\n icon={<IconDelete />}\n className={`${handles.documentRemoveButton}`}\n />\n </div>\n ) : (\n <Button\n variation=\"secondary\"\n onClick={() => handlePageModeChange('business')}\n className={`${handles.documentUploadButton}`}\n >\n <span className={`${handles.documentUploadButtonText}`}>\n <FormattedMessage id=\"store/flowFinance.accountCreate.documents.uploadLabel\" />\n </span>\n </Button>\n )}\n </div>\n </div>\n <Divider orientation=\"horizontal\" />\n {documentsValid && (\n <div className={`${handles.tosAcceptanceContainer} mt7 mb7`}>\n <h2>\n <FormattedMessage id=\"store/flowFinance.accountCreate.tosTitle\" />\n </h2>\n <div className={`${handles.tosIframeContainer} mb7`}>\n <iframe\n title=\"Flow Finance Loan Agreement\"\n width=\"95%\"\n height={400}\n src={tosPdfPath}\n data-testid=\"embedded-pdf\"\n className=\"db center\"\n frameBorder=\"0\"\n onLoad={() => setPdfLoaded(true)}\n />\n </div>\n <Checkbox\n label={\n <span className={`${handles.tosAcceptanceCheckboxLabel}`}>\n <FormattedMessage id=\"store/flowFinance.accountCreate.tosCheckboxLabel\" />\n </span>\n }\n className={`${handles.tosAcceptanceCheckbox} mt4`}\n checked={tosAccepted}\n id=\"tos-accept\"\n name=\"tos-accept\"\n value=\"tos-accept\"\n onChange={() => setTosAccepted(!tosAccepted)}\n />\n </div>\n )}\n <div className={`${handles.documentsPageButtonContainer} mt6`}>\n <Button\n variation=\"primary\"\n disabled={!documentsValid || !tosAccepted || !pdfLoaded}\n isLoading={isLoading}\n onClick={() => handleContinueClick()}\n >\n <FormattedMessage id=\"store/flowFinance.accountCreate.submitApplication\" />\n </Button>\n </div>\n {submitError && (\n <div className={`${handles.documentsPageErrorContainer} mt2 red`}>\n {submitError}\n </div>\n )}\n </div>\n )\n }\n }\n}\n\nexport default injectIntl(DocumentsPage)\n\n```"
}
] |
code_flow-finance-components_8813f4b7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/components/AccountCreatePages/PreQualifyPage.tsx from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useEffect, useState } from 'react'\nimport {\n defineMessages,\n injectIntl,\n WrappedComponentProps,\n FormattedMessage,\n} from 'react-intl'\nimport { useQuery, useMutation } from 'react-apollo'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { Input, Spinner, Button, Divider } from 'vtex.styleguide'\n\nimport {\n useAccountCreateState,\n useAccountCreateDispatch,\n} from '../AccountCreateContext'\nimport { formatCNPJ } from './utils/formatters'\nimport Profile from '../../graphql/Profile.graphql'\nimport PreQualify from '../../graphql/PreQualify.graphql'\n\ninterface PreQualifyProps {\n handleExit: () => void\n settings: Settings\n}\n\ninterface Settings {\n storeName: string\n storePaymentName: string\n}\n\nconst CSS_HANDLES = [\n 'preQualifyPageContainer',\n 'preQualifyInstructions',\n 'preQualifySection',\n 'preQualifyPageButtonContainer',\n] as const\n\nconst messages = defineMessages({\n cnpjLabel: {\n defaultMessage: 'CNPJ',\n id: 'store/flowFinance.accountCreate.cnpjLabel',\n },\n cnpjError: {\n defaultMessage: 'Please enter a valid CNPJ',\n id: 'store/flowFinance.accountCreate.cnpjError',\n },\n})\n\nconst PreQualifyPage: StorefrontFunctionComponent<PreQualifyProps &\n WrappedComponentProps> = ({ intl, handleExit, settings }) => {\n const { data, loading } = useQuery(Profile)\n const [preQualified, setPreQualified] = useState(true)\n const { businessInformation, currentPage } = useAccountCreateState()\n const dispatch = useAccountCreateDispatch()\n const handles = useCssHandles(CSS_HANDLES)\n\n const [formattedCNPJ, setFormattedCNPJ] = useState('')\n const [isLoading, setIsLoading] = useState(false)\n const [showError, setShowError] = useState(false)\n\n const [checkPreQualify] = useMutation(PreQualify)\n\n useEffect(() => {\n if (!data?.profile) return\n if (data.profile.corporateDocument) {\n const cleanDocument = data.profile.corporateDocument.replace(/[^\\d]/g, '')\n dispatch({\n type: 'SET_BUSINESS_FIELD',\n args: {\n field: 'businessId',\n value: cleanDocument,\n },\n })\n setFormattedCNPJ(formatCNPJ(cleanDocument))\n setShowError(true)\n }\n dispatch({\n type: 'SET_BUSINESS_FIELD',\n args: {\n field: 'email',\n value: data.profile.email,\n },\n })\n dispatch({\n type: 'SET_PERSONAL_FIELD',\n args: {\n field: 'email',\n value: data.profile.email,\n },\n })\n if (data.profile.corporateName) {\n dispatch({\n type: 'SET_BUSINESS_FIELD',\n args: {\n field: 'name',\n value: data.profile.corporateName,\n },\n })\n }\n if (data.profile.tradeName) {\n dispatch({\n type: 'SET_BUSINESS_FIELD',\n args: {\n field: 'legalName',\n value: data.profile.tradeName,\n },\n })\n }\n if (data.profile.businessPhone) {\n dispatch({\n type: 'SET_BUSINESS_FIELD',\n args: {\n field: 'phoneNumber',\n value: data.profile.businessPhone.replace('+55', ''),\n },\n })\n }\n if (data.profile.firstName) {\n dispatch({\n type: 'SET_PERSONAL_FIELD',\n args: {\n field: 'firstName',\n value: data.profile.firstName,\n },\n })\n }\n if (data.profile.lastName) {\n dispatch({\n type: 'SET_PERSONAL_FIELD',\n args: {\n field: 'lastName',\n value: data.profile.lastName,\n },\n })\n }\n if (data.profile.homePhone) {\n dispatch({\n type: 'SET_PERSONAL_FIELD',\n args: {\n field: 'phoneNumber',\n value: data.profile.homePhone.replace('+55', ''),\n },\n })\n }\n }, [data, dispatch])\n\n async function submitPreQualify() {\n setIsLoading(true)\n checkPreQualify({\n variables: { cnpj: businessInformation.businessId },\n }).then(response => {\n setIsLoading(false)\n if (!response.data || !response.data.checkPreQualify) {\n setPreQualified(false)\n return\n }\n dispatch({\n type: 'SET_CURRENT_PAGE',\n args: {\n page: currentPage + 1,\n },\n })\n window.scrollTo(0, 0)\n })\n }\n\n if (loading) return <Spinner />\n\n if (!preQualified)\n return (\n <div className={handles.preQualifyPageContainer}>\n <div className={`${handles.preQualifyInstructions} mb6`}>\n <FormattedMessage\n id=\"store/flowFinance.accountCreate.preQualify.notQualifiedMessage\"\n values={{\n storePaymentName: settings.storePaymentName,\n lineBreak: <br />,\n }}\n />\n </div>\n <Divider orientation=\"horizontal\" />\n <div className={`${handles.preQualifyPageButtonContainer} mt6`}>\n <Button variation=\"primary\" onClick={() => handleExit()}>\n <FormattedMessage id=\"store/flowFinance.accountCreate.continueShopping\" />\n </Button>\n </div>\n </div>\n )\n\n return (\n <div className={handles.preQualifyPageContainer}>\n <div className={`${handles.preQualifyInstructions} mb6`}>\n <FormattedMessage\n id=\"store/flowFinance.accountCreate.preQualify.instructions\"\n values={{\n storeName: settings.storeName,\n }}\n />\n </div>\n <section className={`${handles.preQualifySection} mb6`}>\n <Input\n label={intl.formatMessage(messages.cnpjLabel)}\n value={formattedCNPJ}\n onChange={(e: React.FormEvent<HTMLInputElement>) => {\n const newValue = e.currentTarget.value\n .replace(/[^\\d]/g, '')\n .slice(0, 14)\n setFormattedCNPJ(() => formatCNPJ(newValue))\n dispatch({\n type: 'SET_BUSINESS_FIELD',\n args: {\n field: 'businessId',\n value: newValue,\n },\n })\n }}\n onBlur={() => setShowError(true)}\n errorMessage={\n showError && businessInformation.businessId.length !== 14\n ? intl.formatMessage(messages.cnpjError)\n : ''\n }\n />\n </section>\n <Divider orientation=\"horizontal\" />\n <div className={`${handles.preQualifyPageButtonContainer} mt6`}>\n <Button\n variation=\"primary\"\n disabled={businessInformation.businessId.length !== 14}\n isLoading={isLoading}\n onClick={() => submitPreQualify()}\n >\n <FormattedMessage id=\"store/flowFinance.accountCreate.preQualify.submit\" />\n </Button>\n </div>\n </div>\n )\n}\n\nexport default injectIntl(PreQualifyPage)\n\n```"
}
] |
code_flow-finance-components_b10d1fb8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/components/AccountCreatePages/utils/formatters.tsx from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nexport function formatCNPJ(value: string | undefined) {\n if (!value) return ''\n const currentValue = value.replace(/[^\\d]/g, '')\n const cvLength = currentValue.length\n\n if (cvLength < 3) return currentValue\n if (cvLength < 6)\n return `${currentValue.slice(0, 2)}.${currentValue.slice(2)}`\n if (cvLength < 9)\n return `${currentValue.slice(0, 2)}.${currentValue.slice(\n 2,\n 5\n )}.${currentValue.slice(5)}`\n if (cvLength < 13)\n return `${currentValue.slice(0, 2)}.${currentValue.slice(\n 2,\n 5\n )}.${currentValue.slice(5, 8)}/${currentValue.slice(8)}`\n return `${currentValue.slice(0, 2)}.${currentValue.slice(\n 2,\n 5\n )}.${currentValue.slice(5, 8)}/${currentValue.slice(\n 8,\n 12\n )}-${currentValue.slice(12)}`\n}\n\nexport function formatCPF(value: string | undefined) {\n if (!value) return ''\n const currentValue = value.replace(/[^\\d]/g, '')\n const cvLength = currentValue.length\n\n if (cvLength < 4) return currentValue\n if (cvLength < 7)\n return `${currentValue.slice(0, 3)}.${currentValue.slice(3)}`\n if (cvLength < 10)\n return `${currentValue.slice(0, 3)}.${currentValue.slice(\n 3,\n 6\n )}.${currentValue.slice(6)}`\n if (cvLength > 9)\n return `${currentValue.slice(0, 3)}.${currentValue.slice(\n 3,\n 6\n )}.${currentValue.slice(6, 9)}-${currentValue.slice(9)}`\n return ''\n}\n\nexport function formatRG(value: string | undefined) {\n if (!value) return ''\n const currentValue = value.replace(/[^\\d]/g, '')\n const cvLength = currentValue.length\n\n if (cvLength < 3) return currentValue\n if (cvLength < 4)\n return `${currentValue.slice(0, 2)}.${currentValue.slice(2)}`\n if (cvLength < 9)\n return `${currentValue.slice(0, 2)}.${currentValue.slice(\n 2,\n 5\n )}.${currentValue.slice(5)}`\n if (cvLength > 8)\n return `${currentValue.slice(0, 2)}.${currentValue.slice(\n 2,\n 5\n )}.${currentValue.slice(5, 8)}-${currentValue.slice(8)}`\n return ''\n}\n\nexport function formatRGExp(value: string | undefined) {\n if (!value) return ''\n const currentValue = value.replace(/[^\\d]/g, '')\n const cvLength = currentValue.length\n\n if (cvLength < 3) return currentValue\n if (cvLength < 4)\n return `${currentValue.slice(0, 2)}/${currentValue.slice(2)}`\n if (cvLength < 6)\n return `${currentValue.slice(0, 2)}/${currentValue.slice(\n 2,\n 4\n )}/${currentValue.slice(4)}`\n return ''\n}\n\nexport function formatPhone(value: string | undefined) {\n if (!value) return ''\n const currentValue = value.replace(/[^\\d]/g, '')\n const cvLength = currentValue.length\n\n if (cvLength < 3) return currentValue\n if (cvLength < 4)\n return `(${currentValue.slice(0, 2)}) ${currentValue.slice(2)}`\n if (parseInt(currentValue.slice(2, 3), 10) < 6) {\n if (cvLength < 7) {\n return `(${currentValue.slice(0, 2)}) ${currentValue.slice(2)}`\n }\n if (cvLength <= 10) {\n return `(${currentValue.slice(0, 2)}) ${currentValue.slice(\n 2,\n 6\n )}-${currentValue.slice(6)}`\n }\n }\n if (cvLength < 8) {\n return `(${currentValue.slice(0, 2)}) ${currentValue.slice(\n 2,\n 3\n )} ${currentValue.slice(3)}`\n }\n return `(${currentValue.slice(0, 2)}) ${currentValue.slice(\n 2,\n 3\n )} ${currentValue.slice(3, 7)}-${currentValue.slice(7)}`\n}\n\n```"
}
] |
code_flow-finance-components_3fdc32dc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of flow-finance-components/react/components/AccountCreatePages/styles/global.css from the flow-finance-components VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n.vtex-flow-finance-components-1-x-AccountCreatePageContainer\n .styleguide__pageBlock {\n max-width: 800px;\n margin: 0 auto;\n}\n\n.vtex-flow-finance-components-1-x-businessAddressSection > div,\n.vtex-flow-finance-components-1-x-personalAddressSection > div {\n display: -webkit-box;\n display: flex;\n flex-flow: row wrap;\n -webkit-box-direction: normal;\n -webkit-box-orient: horizontal;\n}\n\n.vtex-flow-finance-components-1-x-accountCreateStepNumber svg {\n color: white;\n}\n\n.vtex-flow-finance-components-1-x-businessAddressSection\n .vtex-address-form__receiverName,\n.vtex-flow-finance-components-1-x-personalAddressSection\n .vtex-address-form__receiverName {\n display: none;\n}\n\n.vtex-flow-finance-components-1-x-businessAddressSection\n .vtex-address-form__postalCode\n > div,\n.vtex-flow-finance-components-1-x-personalAddressSection\n .vtex-address-form__postalCode\n > div {\n display: none;\n}\n\n@media screen and (min-width: 20em) {\n .vtex-flow-finance-components-1-x-businessAddressSection > div > *,\n .vtex-flow-finance-components-1-x-personalAddressSection > div > *,\n .vtex-address-form__postalCode {\n width: 100%;\n padding: 0.25rem;\n }\n}\n\n@media screen and (min-width: 40em) {\n .vtex-flow-finance-components-1-x-businessAddressSection > div > *,\n .vtex-flow-finance-components-1-x-personalAddressSection > div > *,\n .vtex-address-form__postalCode {\n width: 50%;\n padding: 0.25rem;\n }\n}\n\n```"
}
] |
code_events-example-subscriber_21a3a996
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of events-example-subscriber/docs/README.md from the events-example-subscriber VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# Events Example\n\nApp in VTEX IO designed to send events using a time interval and IO's Events system.\n\n### How it works?\n\n```"
}
] |
code_events-example-subscriber_5fbf81c6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of events-example-subscriber/node/service.json from the events-example-subscriber VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"memory\": 128,\n \"ttl\": 10,\n \"timeout\": 2,\n \"minReplicas\": 2,\n \"maxReplicas\": 10,\n \"workers\": 4,\n \"events\": {\n \"listener\": {\n \"sender\": \"vtex.events-example-publisher\",\n \"topics\": [\"random-number-generated\"]\n }\n }\n}\n\n```"
}
] |
code_events-example-subscriber_52c5fe9d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of events-example-subscriber/node/package.json from the events-example-subscriber VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"co-body\": \"^6.0.0\",\n \"jwt-decode\": \"^3.1.2\"\n },\n \"devDependencies\": {\n \"@types/co-body\": \"^0.0.3\",\n \"@types/node\": \"12.x\",\n \"@vtex/api\": \"6.45.12\",\n \"eslint\": \"^6.3.0\",\n \"eslint-config-vtex\": \"^11.0.0\",\n \"prettier\": \"^1.18.2\",\n \"typescript\": \"3.9.7\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty && eslint -c .eslintrc.json --fix './**/*.ts'\"\n },\n \"version\": \"0.7.2\"\n}\n\n```"
}
] |
code_events-example-subscriber_d145bcc8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of events-example-subscriber/node/constants.ts from the events-example-subscriber VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const ENABLED_GLOBALLY = true\n\nexport const EVENT_EXAMPLE = 'batata'\n\nexport const TIME_INTERVAL = 10\n\n```"
}
] |
code_events-example-subscriber_378a7959
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of events-example-subscriber/node/index.ts from the events-example-subscriber VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {\n Service,\n IOClients,\n ParamsContext,\n ServiceContext,\n RecorderState,\n} from '@vtex/api'\nimport { listener } from './events/listenEvent'\n\ndeclare global {\n type Context = ServiceContext<IOClients, State>\n\n interface State extends RecorderState {\n code: number\n }\n}\n\nexport default new Service<IOClients, State, ParamsContext>({\n events: {\n listener,\n },\n})\n\n```"
}
] |
code_events-example-subscriber_06c81a30
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of events-example-subscriber/node/utils/randomNumber.ts from the events-example-subscriber VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport function getRandomNumber() {\n return Math.round(Math.random() * 100)\n}\n\n```"
}
] |
code_events-example-subscriber_16e3d013
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of events-example-subscriber/node/utils/cachedContext.ts from the events-example-subscriber VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nlet context: any = null\n\nexport const getCacheContext = () => {\n return context\n}\n\nexport function setCacheContext(ctx: any) {\n context = ctx\n}\n\n```"
}
] |
code_events-example-subscriber_1c767903
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of events-example-subscriber/node/events/listenEvent.ts from the events-example-subscriber VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { EventContext, IOClients } from '@vtex/api'\n\nexport async function listener(ctx: EventContext<IOClients>) {\n console.log('Evento recebido com o paylod ', ctx.body)\n return true\n}\n\n```"
}
] |
code_relevanc_0a7617b5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/docs/README.md from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# Template App\n\nThis app and all affiliated services are provided “as is”, without warranty of any kind, either express or implied. Neither the publisher nor its partners, affiliates, employees, or contractors guarantee that this app will meet your requirements, provide uninterrupted use, or operate without delay or without error. Neither the publisher nor its partners, affiliates, employees, or contractors assume any responsibility for any errors and malfunctions within the app and will not provide support or maintenance of any kind.\n\nAll provisions and warranties of any kind, express or implied, including but not limited to any guarantees of performance, process integrity, or particular functionalities, are hereby disclaimed and excluded unless otherwise prohibited or restricted by applicable law.\n\n# RelevanC\n\n### What is RelevanC\n\nRelevanC is an ad-tech SaaS provider based in Paris, France. It markets a customised retail media solution under a white label to retailers and advertisers worldwide. With Sponsored Products for marketplaces, it combines truly relevant ads and maximum reach using advanced AI for the best of both worlds.\n\n### RelevanC integration\n\n#### Search results and category pages\n\nUsing VTEX Intelligent Search Middleware feature, this integration connects to RelevanC AdServer to get Sponsored Products to promote them in the search results and the category[^1] pages.\n\n---\n\n### Integration Setup\n\n_Note: You must already have a RelevanC account set up and ready._\n\nAfter the app is installed on your VTEX account, you can set it up following these steps.\n\n#### Categories Map\n\nThe integration makes use of a categories map that is generated from the account's catalog to improve performance. This categories map is necessary for the integration to work.\n\nYou can check and generate/update this categories map using the following endpoint[^2].\n\n- Check the categories map\n\n```\nGET https://app.io.vtex.com/vtex.relevanc/v0/{{account}}/{{workspace}}/_v/relevanc/categories-map\n```\n\n- Generate/update the categories map:\n\n```\nPUT https://app.io.vtex.com/vtex.relevanc/v0/{{account}}/{{workspace}}/_v/relevanc/categories-map\n```\n\n#### Integration settings\n\nYou can customize the behaviour for the integration using the following settings:\n\n| Property name | Description |\n| -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| RelevanC AdServer name <br /> (`adServerName`) | This is the name of RelevanC's AdServer (without `ads.peps.relevanc.io`) |\n| Product property <br /> (`boostType`) | Product property to use to add/promote the products returned from the AdServer |\n| Max number of offers <br /> (`maxOffersToDisplay`) | Maximum number of products to be added to the search results |\n| Add all products <br />(`addAllProducts`) | By default, only products that are part of the search results are promoted. Check to add all products returned by the AdServer to the search result[^3] |\n\n[^1]: Category pages that use collections or are custom are not supported.\n[^2]: This endpoints is private and requires the `vtexIdClientAutCookie` header.\n[^3]: Only supported for search page.\n\n```"
}
] |
code_relevanc_27739dea
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/service.json from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"stack\": \"nodejs\",\n \"memory\": 512,\n \"minReplicas\": 3,\n \"workers\": 1,\n \"routes\": {\n \"categoriesMap\": {\n \"path\": \"/_v/relevanc/categories-map\",\n \"public\": false\n }\n }\n}\n\n```"
}
] |
code_relevanc_69a73824
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/package.json from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"is-api-middleware-resolver\",\n \"private\": true,\n \"license\": \"UNLICENSED\",\n \"dependencies\": {\n \"@vtex/clients\": \"^2.19.5\",\n \"graphql\": \"^14.5.8\",\n \"graphql-tools\": \"^4.0.6\",\n \"vtex.is-api-middleware-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.is-api-middleware-graphql@0.1.0-beta.6/public\"\n },\n \"devDependencies\": {\n \"@types/atob\": \"^2.1.2\",\n \"@types/node\": \"^12.12.21\",\n \"@vtex/api\": \"6.45.15\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"typescript\": \"3.9.7\",\n \"vtex.is-api-middleware-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.is-api-middleware-graphql@0.1.0-beta.5/public/@types/vtex.is-api-middleware-graphql\"\n },\n \"resolutions\": {\n \"@types/express-serve-static-core\": \"4.17.28\"\n },\n \"version\": \"1.0.5\"\n}\n\n```"
}
] |
code_relevanc_b6621ba2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/index.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n// eslint-disable-next-line prettier/prettier\nimport type { ParamsContext, RecorderState } from '@vtex/api'\nimport { Service } from '@vtex/api'\nimport schema from 'vtex.is-api-middleware-graphql/graphql'\n\nimport type { Clients } from './clients'\nimport { clientsConfig } from './clients'\nimport { routes } from './middleware/routes'\nimport { resolvers } from './resolvers'\n\nexport default new Service<Clients, RecorderState, ParamsContext>({\n clients: clientsConfig,\n routes,\n graphql: {\n resolvers,\n schema,\n },\n})\n\n```"
}
] |
code_relevanc_d4554aca
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/contants/index.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const PAGE_TYPE = {\n CATEGORY: 'category-page',\n SEARCH: 'search-page',\n}\n\nexport const CATEGORIES_MAP = 'categories-map'\nexport const ACCOUNT_BASE_URL = 'https://portal.vtexcommercestable.com.br/'\nexport const BUCKET = 'relevanc'\n\nexport const DESKTOP = 'PC_LR_PLR'\nexport const MOBILE = 'MOB_LR_PLR'\n\nexport const ACTION = {\n ADD: 'add',\n REMOVE: 'remove',\n PROMOTE: 'promote',\n DEMOTE: 'demote',\n} as const\n\n```"
}
] |
code_relevanc_8bbf89c7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/clients/categoriesMap.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { VBase } from '@vtex/api'\n\nimport { BUCKET, CATEGORIES_MAP } from '../contants'\n\nexport default class CategoriesMapClient extends VBase {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(context, {\n ...options,\n })\n }\n\n public getCategoriesMap = (): Promise<CategoriesMapRecord | null> =>\n this.getJSON(BUCKET, CATEGORIES_MAP, true)\n\n public updateCategoriesMap = (data: CategoriesMapRecord) =>\n this.saveJSON(BUCKET, CATEGORIES_MAP, data)\n}\n\n```"
}
] |
code_relevanc_2bc559fa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/clients/relevanC.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { ExternalClient, PRODUCTION } from '@vtex/api'\n\nexport default class RelevancClient extends ExternalClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super('https://ads.peps.relevanc.io', context, options)\n }\n\n private baseUrl(serverName: string) {\n return PRODUCTION\n ? `http://${serverName}.ads.peps.relevanc.io`\n : `http://${serverName}.staging-ads.peps.relevanc.io`\n }\n\n public async getSponsoredOffers(\n serverName: string,\n params: Relevanc.SponsoredProductsPayload\n ): Promise<Relevanc.SponsoredProductsResponse> {\n const URL = this.baseUrl(serverName)\n\n return this.http.get(`${URL}/sponsored-offers`, {\n headers: {\n 'x-vtex-use-https': 'true',\n },\n params,\n metric: 'relevanc-get-offers',\n })\n }\n}\n\n```"
}
] |
code_relevanc_80cde3b7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/clients/index.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { ClientsConfig } from '@vtex/api'\nimport { IOClients } from '@vtex/api'\n\nimport CatalogClient from './catalog'\nimport CategoriesMapClient from './categoriesMap'\nimport RelevancClient from './relevanc'\n\nconst MEDIUM_TIMEOUT_MS = 2 * 1000\n\nexport class Clients extends IOClients {\n public get relevanc() {\n return this.getOrSet('relevanc', RelevancClient)\n }\n\n public get catalog() {\n return this.getOrSet('catalog', CatalogClient)\n }\n\n public get categoriesMap() {\n return this.getOrSet('categoriesMap', CategoriesMapClient)\n }\n}\n\nexport const clientsConfig: ClientsConfig<Clients> = {\n implementation: Clients,\n options: {\n default: {\n retries: 2,\n timeout: MEDIUM_TIMEOUT_MS,\n },\n },\n}\n\n```"
}
] |
code_relevanc_299eaca8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/clients/catalog.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { JanusClient } from '@vtex/api'\n\nexport default class CatalogClient extends JanusClient {\n /**\n * We use a high number as default to be sure to get all levels in category tree\n * @see https://developers.vtex.com/docs/api-reference/catalog-api#get-/api/catalog_system/pub/category/tree/-categoryLevels-\n */\n public getCategoryTree = async (\n categoryLevels = 99\n ): Promise<CategoryTree> => {\n return this.http.get(\n `/api/catalog_system/pub/category/tree/${categoryLevels}`,\n {\n metric: 'catalog-get-category-tree',\n }\n )\n }\n}\n\n```"
}
] |
code_relevanc_e2e57f50
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/typings/appSettings.d.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ntype AppSettings = {\n adServerName: string\n boostType: BoostType\n maxOffersToDisplay: number\n addAllProducts: boolean\n}\n\n```"
}
] |
code_relevanc_b08f5f8f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/typings/relevanc.d.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare namespace Relevanc {\n type BaseSponsoredProductsPaylaod = {\n adSpaceId: 'PC_LR_PLR' | 'MOB_LR_PLR'\n sourcePageNumber: number\n }\n\n type KeyIdSponsoredProductsPayload = BaseSponsoredProductsPaylaod & {\n keyId: string\n filterCategoryCodePath: string\n }\n\n type KeyOriginSponsoredProductsPayload = BaseSponsoredProductsPaylaod & {\n keyOrigin: string\n filterCategoryCodePath?: string\n }\n\n type SponsoredProductsPayload =\n | KeyIdSponsoredProductsPayload\n | KeyOriginSponsoredProductsPayload\n\n type SponsoredOffer = {\n algoSelectionType:\n | 'NOTSELECTED'\n | 'EXPLORED'\n | 'UNEXPLORED'\n | 'LONGTAIL'\n | 'SHORTTAIL'\n isSponsored: boolean\n offerId: number\n productId: string\n tagName: string\n tag: string\n }\n\n type SponsoredProductsResponse = {\n nbResults: number\n tagName: string\n tag: string\n offers: SponsoredOffer[]\n }\n\n interface HandlerArgs {\n ctx: Context\n settings: AppSettings\n searchParams: SearchParams\n }\n\n interface SponsoredOffersMap {\n boostType: BoostType\n offers: {\n [offerId: string]: SponsoredOffer\n }\n }\n}\n\n```"
}
] |
code_relevanc_d02f6618
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/typings/global.d.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/consistent-type-imports */\nimport { ServiceContext } from '@vtex/api'\n\nimport { Clients } from '../clients/index'\n\ndeclare global {\n type Context = ServiceContext<Clients>\n\n type SelectedFacet = {\n key: string\n value: string\n }\n\n type Operator = 'AND' | 'OR'\n\n type Options = {\n allowRedirect: boolean\n }\n\n type BoostAction = 'add' | 'remove' | 'promote' | 'demote'\n\n type BoostType =\n | 'term'\n | 'id'\n | 'skuId'\n | 'skuEan'\n | 'skuReference'\n | 'productLink'\n | 'product'\n | 'sku'\n | 'productId'\n | 'attribute'\n\n type DynamicRule = {\n action: BoostAction\n type: BoostType\n value: string\n }\n\n type SearchParams = {\n query?: string\n page?: string\n count?: string\n sort?: string\n operator?: string\n fuzzy?: string\n locale?: string\n allowRedirect?: boolean\n regionId?: string\n simulationBehavior?: 'skip' | 'only1P' | 'default' | null\n hideUnavailableItems?: boolean | null\n productOriginVtex?: string\n selectedFacets?: SelectedFacet[]\n dynamicRules?: DynamicRule[]\n searchState?: string\n customPluginInfo?: string\n }\n\n type Category = {\n id: number\n name: string\n href: string\n children?: Category[]\n }\n\n type SearchImage = {\n cacheId: string\n imageId: string\n imageLabel: string | null\n imageTag: string\n imageUrl: string\n imageText: string\n }\n\n type Variation = {\n name: string\n values: string[]\n }\n\n type Seller = {\n sellerId: string\n sellerName: string\n addToCartLink: string\n sellerDefault: boolean\n commertialOffer: CommertialOffer\n error?: string\n }\n\n type SearchInstallment = {\n Value: number\n InterestRate: number\n TotalValuePlusInterestRate: number\n NumberOfInstallments: number\n PaymentSystemName: string\n PaymentSystemGroupName?: string\n Name: string\n }\n\n type CommertialOffer = {\n DeliverySlaSamplesPerRegion?: Record<\n string,\n { DeliverySlaPerTypes: any[]; Region: any | null }\n >\n Installments: SearchInstallment[]\n discountHighlights?: any[]\n GiftSkuIds?: string[]\n teasers: Teaser[]\n BuyTogether?: any[]\n ItemMetadataAttachment?: any[]\n Price: number\n ListPrice: number\n spotPrice: number\n taxPercentage: number\n PriceWithoutDiscount: number\n RewardValue: number\n PriceValidUntil: string\n AvailableQuantity: number\n Tax: number\n DeliverySlaSamples?: Array<{\n DeliverySlaPerTypes: any[]\n Region: any | null\n }>\n GetInfoErrorMessage?: any | null\n CacheVersionUsedToCallCheckout: string\n }\n type Teaser = {\n id?: string\n name: string\n conditions: TeaserCondition\n effects: TeaserEffects\n featured?: boolean\n teaserType?: string\n }\n\n type TeaserCondition = {\n minimumQuantity: number\n parameters: TeaserValue[]\n }\n\n type TeaserEffects = {\n parameters: TeaserValue[]\n }\n\n type TeaserValue = {\n name: string\n value: string\n }\n\n type SearchItem = {\n itemId: string\n name: string\n nameComplete: string\n complementName: string\n ean: string\n referenceId: Array<{ Key: string; Value: string }>\n measurementUnit: string\n unitMultiplier: number\n modalType?: any | null\n images: SearchImage[]\n videos?: string[]\n variations: Variation[]\n sellers: Seller[]\n attachments: Array<{\n id: number\n name: string\n required: boolean\n domainValues: string\n }>\n isKit?: boolean\n kitItems?: Array<{\n itemId: string\n amount: number\n }>\n }\n\n type SearchMetadataItem = {\n Name: string\n NameComplete: string\n MainImage: string\n BrandName: string\n CategoryId: number\n ProductId: number\n id: string\n seller: string\n assemblyOptions: AssemblyOption[]\n }\n\n type ProductProperty = {\n name: string\n originalName: string\n values: string[]\n }\n\n type AssemblyOption = {\n id: string\n name: string\n composition: Composition | null\n inputValues: InputValues\n }\n\n type Composition = {\n minQuantity: number\n maxQuantity: number\n items: CompositionItem[]\n }\n\n type CompositionItem = {\n id: string\n minQuantity: number\n maxQuantity: number\n initialQuantity: number\n priceTable: string\n seller: string\n }\n\n type InputValues = {\n [key: string]: RawInputValue\n }\n\n type RawInputValue = {\n maximumNumberOfCharacters: number\n domain: string[]\n }\n\n type CompleteSpecification = {\n Values: Array<{\n Id: string\n Position: number\n Value: string\n }>\n Name: string\n Position: number\n IsOnProductDetails: boolean\n FieldId: string\n }\n\n type SkuSpecification = {\n field: SKUSpecificationField\n values: SKUSpecificationValue[]\n }\n\n type SKUSpecificationField = {\n name: string\n originalName?: string\n id?: string\n }\n\n type SKUSpecificationValue = {\n name: string\n id?: string\n fieldId?: string\n originalName?: string\n }\n\n type SpecificationGroup = {\n originalName: string\n name: string\n specifications: SpecificationGroupProperty[]\n }\n\n type SpecificationGroupProperty = {\n originalName: string\n name: string\n values: string[]\n }\n\n type PriceRange = {\n sellingPrice: {\n highPrice: number\n lowPrice: number\n }\n listPrice: {\n highPrice: number\n lowPrice: number\n }\n }\n\n type Product = {\n cacheId: string\n productId: string\n productName: string\n brand: string\n brandId: number\n linkText: string\n productReference?: string\n categoryId: string\n categoryTree: Category[]\n productTitle?: string\n metaTagDescription: string\n clusterHighlights: Array<Record<string, string>>\n productClusters: Array<Record<string, string>>\n searchableClusters?: Record<string, string>\n categories: string[]\n categoriesIds?: string[]\n link: string\n description: string\n items: SearchItem[]\n itemMetadata?: {\n items: SearchMetadataItem[]\n }\n titleTag: string\n properties: ProductProperty[]\n Specifications?: string[]\n allSpecifications?: string[]\n allSpecificationsGroups?: string[]\n completeSpecifications?: CompleteSpecification[]\n skuSpecifications: SkuSpecification[]\n specificationGroups: SpecificationGroup[]\n priceRange: PriceRange\n rule: { id: string }\n }\n\n type Page = {\n index: number\n proxyUrl: string\n }\n\n type Pagination = {\n count: number\n current: Page\n before: Page[]\n after: Page[]\n perPage: number\n next: Page\n previous: Page\n first: { index: number }\n last: Page\n }\n\n type ProductSearchResult = {\n products: Product[]\n recordsFiltered: number\n correction: { misspelled: boolean }\n fuzzy: string\n operator: 'and' | 'or'\n translated: boolean\n pagination: Pagination\n }\n\n type AfterArgs = {\n args: {\n searchResult: ProductSearchResult\n params: SearchParams\n customPluginInfo: string\n }\n }\n}\n\n```"
}
] |
code_relevanc_91dcded8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/typings/catalog.d.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ntype CategoryTree = CategoryTreeItem[]\n\ninterface CategoryTreeItem {\n id: string\n name: string\n hasChildren: boolean\n url: string\n children: CategoryTreeItem[]\n Title: string\n MetaTagDescription: string\n}\n\ninterface CategoriesMap {\n [name: string]: CategoriesMapItem\n}\n\ninterface CategoriesMapItem {\n id: string\n name: string\n path: string\n}\n\ninterface CategoriesMapRecord {\n lastUpdated: string\n categories: CategoriesMap\n}\n\n```"
}
] |
code_relevanc_c248ef16
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/utils/customError.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ntype CustomErrorProps = {\n message: string\n reason: string\n status: number\n data?: unknown\n}\n\nexport class CustomError extends Error {\n constructor({ message, reason, status, data = null }: CustomErrorProps) {\n super(message)\n this.reason = reason ?? this.message\n this.status = status\n this.data = data\n }\n\n public readonly reason: string\n public readonly status: number\n public readonly data: unknown\n}\n\n```"
}
] |
code_relevanc_1c644cd1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/utils/createCategoriesMap.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { ACCOUNT_BASE_URL } from '../contants'\n\nexport const createCategoriesMap = (\n categoryTree: CategoryTree,\n path: string | null = null,\n result: CategoriesMap = {}\n): CategoriesMap => {\n for (const category of categoryTree) {\n // Remove base from category url\n const categoryPath = category.url.replace(ACCOUNT_BASE_URL, '')\n\n // Remove category parents\n const index = categoryPath.lastIndexOf('/')\n const categoryName =\n index > 0 ? categoryPath.slice(index + 1) : categoryPath\n\n // Add category to map\n const item = {\n id: String(category.id),\n name: categoryName,\n path: path ? `${path}/${category.id}` : `${category.id}`,\n }\n\n result[categoryName] = item\n\n // Check for sub categories\n if (category.hasChildren) {\n createCategoriesMap(category.children, item.path, result)\n }\n }\n\n return result\n}\n\n```"
}
] |
code_relevanc_9fcaeefd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/utils/dynamicRulesMapper.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { ACTION } from '../contants'\n\nexport const dynamicRulesMapper = (\n offer: Relevanc.SponsoredOffer,\n { addAllProducts, boostType }: AppSettings\n): DynamicRule => ({\n action: addAllProducts ? ACTION.ADD : ACTION.PROMOTE,\n type: boostType,\n value: offer.productId,\n})\n\n```"
}
] |
code_relevanc_8c32b8e2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/utils/index.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport * from './createCategoriesMap'\nexport * from './customError'\nexport * from './dynamicRulesMapper'\n\n```"
}
] |
code_relevanc_9c808e2e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/resolvers/after.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { addTrackingTag, errorHandler } from '../utils/resolvers'\n\nexport async function after(\n _: unknown,\n { args }: AfterArgs,\n ctx: Context\n): Promise<ProductSearchResult> {\n if (!args.customPluginInfo) {\n return args.searchResult\n }\n\n const { products } = args.searchResult\n const offersMap: Relevanc.SponsoredOffersMap = JSON.parse(\n args.customPluginInfo\n )\n\n if (!Object.keys(offersMap.offers).length) {\n return errorHandler('No offers not found', ctx)\n }\n\n for (const product of products) {\n addTrackingTag(offersMap, product)\n }\n\n return args.searchResult\n}\n\n```"
}
] |
code_relevanc_7e11c804
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/resolvers/index.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { after } from './after'\nimport { before } from './before'\n\nexport const resolvers = {\n Query: {\n before,\n after,\n },\n}\n\n```"
}
] |
code_relevanc_97908aea
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/resolvers/before.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { PAGE_TYPE } from '../contants'\nimport {\n errorHandler,\n getSettings,\n validateArgs,\n getSearchPageOffers,\n getCategoryPageOffers,\n} from '../utils/resolvers'\nimport { dynamicRulesMapper } from '../utils'\n\nexport async function before(\n _: unknown,\n args: SearchParams,\n ctx: Context\n): Promise<SearchParams> {\n if (!validateArgs(args)) {\n return errorHandler('Invalid search params', ctx)\n }\n\n const settings = await getSettings(ctx)\n\n if (!settings) {\n return errorHandler('Settings not found', ctx)\n }\n\n /**\n * The `query` param is only present for the Search Results page.\n * The selectedFacets can be present in both pages (Search Results and Categories)\n */\n const type = !args.query ? PAGE_TYPE.CATEGORY : PAGE_TYPE.SEARCH\n let offers: Relevanc.SponsoredOffer[] | null\n\n switch (type) {\n case PAGE_TYPE.SEARCH: {\n offers = await getSearchPageOffers({\n ctx,\n settings,\n searchParams: args,\n })\n\n break\n }\n\n case PAGE_TYPE.CATEGORY: {\n offers = await getCategoryPageOffers({\n ctx,\n settings,\n searchParams: args,\n })\n\n break\n }\n\n default: {\n return args\n }\n }\n\n if (!offers) {\n return { ...args }\n }\n\n const offersMap: Relevanc.SponsoredOffersMap = {\n boostType: settings.boostType,\n offers: {},\n }\n\n const dynamicRules = offers.map((offer) => {\n offersMap.offers[offer.offerId] = offer\n\n return dynamicRulesMapper(offer, settings)\n })\n\n return { ...args, dynamicRules, customPluginInfo: JSON.stringify(offersMap) }\n}\n\n```"
}
] |
code_relevanc_d8ac666f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/services/updateCategoriesMap.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { createCategoriesMap } from '../utils'\n\nexport const updateCategoriesMapService = async (ctx: Context) => {\n const {\n clients: { catalog, categoriesMap },\n vtex: { logger },\n } = ctx\n\n try {\n const categoryTree = await catalog.getCategoryTree()\n const categories = createCategoriesMap(categoryTree)\n\n const categoriesMapRecord: CategoriesMapRecord = {\n lastUpdated: Date(),\n categories,\n }\n\n categoriesMap.updateCategoriesMap(categoriesMapRecord)\n } catch (error) {\n logger.error({\n reason: error.message ?? 'Something went wrong',\n data: error.response?.data,\n })\n }\n}\n\n```"
}
] |
code_relevanc_160ccb2b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/middleware/routes/updateCategoriesMap.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { updateCategoriesMapService } from '../../services'\nimport { CustomError } from '../../utils'\n\nexport async function updateCategoriesMap(\n ctx: Context,\n next: () => Promise<void>\n) {\n try {\n await next()\n\n updateCategoriesMapService(ctx)\n } catch (error) {\n throw new CustomError({\n message: error.message,\n reason: 'Something went wrong updating the categories map',\n status: 500,\n })\n }\n}\n\n```"
}
] |
code_relevanc_37649412
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/middleware/routes/errorHandler.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport async function errorHandler(ctx: Context, next: () => Promise<void>) {\n const {\n vtex: { logger },\n } = ctx\n\n try {\n await next()\n } catch (error) {\n logger.error({\n message: error.message,\n reason: error.reason,\n status: error.status,\n data: error.data ?? error,\n })\n\n ctx.status = error.status || 500\n ctx.body = error.reason || 'Something went wrong'\n }\n}\n\n```"
}
] |
code_relevanc_b2b6f97a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/middleware/routes/getCategoriesMap.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { CustomError } from '../../utils'\n\nexport async function getCategoriesMap(ctx: Context) {\n const {\n clients: { categoriesMap },\n } = ctx\n\n try {\n const categoriesMapRecord = await categoriesMap.getCategoriesMap()\n\n if (!categoriesMapRecord) {\n ctx.body = 'Categories map has not been generated'\n\n return\n }\n\n ctx.body = categoriesMapRecord\n } catch (err) {\n throw new CustomError({\n message: err.message,\n reason: 'Unable to fetch categories map',\n status: 500,\n })\n }\n}\n\n```"
}
] |
code_relevanc_3ead0216
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/middleware/routes/sendResponse.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport function sendResponse(ctx: Context) {\n return (ctx.status = 204)\n}\n\n```"
}
] |
code_relevanc_c28761ef
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/middleware/routes/index.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { method } from '@vtex/api'\n\nimport { errorHandler } from './errorHandler'\nimport { getCategoriesMap } from './getCategoriesMap'\nimport { sendResponse } from './sendResponse'\nimport { updateCategoriesMap } from './updateCategoriesMap'\n\nexport const routes = {\n categoriesMap: method({\n GET: [errorHandler, getCategoriesMap],\n PUT: [errorHandler, updateCategoriesMap, sendResponse],\n }),\n}\n\n```"
}
] |
code_relevanc_dd501f8f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/utils/resolvers/errorHandler.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const errorHandler = (message: string, ctx: Context, error?: Error) => {\n if (process.env.VTEX_APP_LINK) {\n console.error(error ?? message)\n } else {\n ctx.vtex.logger.error({\n message,\n })\n }\n\n throw error ?? new Error(message)\n}\n\n```"
}
] |
code_relevanc_6a1f2d3e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/utils/resolvers/validateArgs.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/**\n * This utility function checks that we have at least one\n * of the SearchParams available.\n * `query` is needed for the search page.\n * `selectedFacets` array is needed for the category page.\n *\n * @param args object passed by the search resolver\n * @returns boolean\n */\nexport const validateArgs = (args: SearchParams) => {\n const { query, selectedFacets } = args\n\n return !(!query && !selectedFacets?.length)\n}\n\n```"
}
] |
code_relevanc_e99991f9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/utils/resolvers/getSearchPageOffers.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { DESKTOP } from '../../contants'\n\nexport const getSearchPageOffers = async (args: Relevanc.HandlerArgs) => {\n const {\n ctx: {\n clients: { relevanc },\n },\n settings: { adServerName, maxOffersToDisplay },\n searchParams: { page, query },\n } = args\n\n try {\n const { offers } = await relevanc.getSponsoredOffers(adServerName, {\n sourcePageNumber: page ? Number(page) : 0,\n keyOrigin: query as string,\n adSpaceId: DESKTOP,\n })\n\n offers.splice(maxOffersToDisplay)\n\n return offers\n } catch (error) {\n return null\n }\n}\n\n```"
}
] |
code_relevanc_2d3bd777
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/utils/resolvers/getCategoryPageOffers.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { DESKTOP } from '../../contants'\n\nexport const getCategoryPageOffers = async (args: Relevanc.HandlerArgs) => {\n const {\n ctx: {\n clients: { categoriesMap, relevanc },\n vtex: { logger },\n },\n settings: { adServerName, maxOffersToDisplay },\n searchParams: { page, selectedFacets },\n } = args\n\n if (!selectedFacets?.length || selectedFacets[0].key !== 'c') {\n return []\n }\n\n try {\n const categoriesMapRecord = await categoriesMap.getCategoriesMap()\n\n if (!categoriesMapRecord) {\n throw new Error('Unable to get category page offers')\n }\n\n const categoryName = selectedFacets[selectedFacets.length - 1].value\n const item = categoriesMapRecord.categories[categoryName]\n\n if (!item) {\n return null\n }\n\n const { offers } = await relevanc.getSponsoredOffers(adServerName, {\n sourcePageNumber: page ? Number(page) : 0,\n keyId: item.id,\n filterCategoryCodePath: item.path,\n adSpaceId: DESKTOP,\n })\n\n offers.splice(maxOffersToDisplay)\n\n return offers\n } catch (error) {\n logger.error({\n message: error.message,\n reason:\n 'No categories map was found. Check if it exists or generate a new one',\n })\n\n return null\n }\n}\n\n```"
}
] |
code_relevanc_78a89792
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/utils/resolvers/index.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport * from './addTrackingTag'\nexport * from './errorHandler'\nexport * from './getCategoryPageOffers'\nexport * from './getSearchPageOffers'\nexport * from './getSettings'\nexport * from './validateArgs'\n\n```"
}
] |
code_relevanc_9adfef68
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/utils/resolvers/addTrackingTag.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport function addTrackingTag(\n offersMap: Relevanc.SponsoredOffersMap,\n product: Product\n) {\n const { boostType, offers } = offersMap\n\n switch (boostType) {\n case 'productId': {\n const { productId } = product\n\n if (offers[productId]) {\n product.rule = {\n id: `dynamic:${productId}-${offers[productId].tag}`,\n }\n }\n\n return product\n }\n\n case 'skuId': {\n const [skuId] = product.items\n .map((item) => item.itemId)\n .filter((sku) => offers[sku])\n\n if (skuId) {\n product.rule = {\n id: `dynamic:${skuId}-${offers[skuId].tag}`,\n }\n }\n\n return product\n }\n\n default: {\n return product\n }\n }\n}\n\n```"
}
] |
code_relevanc_100b8f3e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of relevanc/node/utils/resolvers/getSettings.ts from the relevanc VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const getSettings = async (ctx: Context) => {\n const {\n clients: { apps },\n } = ctx\n\n const settings: AppSettings = await apps.getAppSettings(\n process.env.VTEX_APP_ID as string\n )\n\n if (!Object.keys(settings).length) {\n return null\n }\n\n return settings\n}\n\n```"
}
] |
code_marketingdata-session_e5800161
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of marketingdata-session/vtex.session/configuration.json from the marketingdata-session VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n\t\"marketingdata\": {\n\t\t\"input\": {\n\t\t\t\"public\": [ \n\t\t\t\t\"gclid\", \n\t\t\t\t\"utm_source\",\n\t\t\t\t\"utm_medium\",\n\t\t\t\t\"utm_campaign\",\n\t\t\t\t\"utmi_cp\",\n\t\t\t\t\"utmi_p\",\n\t\t\t\t\"utmi_pc\"\n\t\t\t]\t\t\t\n\t\t},\n\t\t\"output\": {\n\t\t\t\"marketingdata\": [ \n\t\t\t\t\"utm_source\",\n\t\t\t\t\"utm_medium\",\n\t\t\t\t\"utm_campaign\",\n\t\t\t\t\"utmi_cp\",\n\t\t\t\t\"utmi_p\",\n\t\t\t\t\"utmi_pc\"\n\t\t\t],\n\t\t\t\"public\": [ \"utm_source\" ]\n\t\t}\t\t\n\t}\n}\n```"
}
] |
code_marketingdata-session_a1bcbd5c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of marketingdata-session/node/service.json from the marketingdata-session VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"stack\": \"nodejs\",\n \"memory\": 128,\n \"routes\": { \n \"transform\": {\n \"path\": \"/_v/marketingdata/session/transform/\",\n \"public\": true\n }\n }\n}\n\n```"
}
] |
code_marketingdata-session_563ac823
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of marketingdata-session/node/package.json from the marketingdata-session VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"axios\": \"^0.18.0\",\n \"co-body\": \"^6.0.0\",\n \"ramda\": \"^0.25.0\"\n },\n \"devDependencies\": {\n \"@types/axios\": \"^0.14.0\",\n \"@types/co-body\": \"^0.0.3\",\n \"@types/koa\": \"^2.0.39\",\n \"@types/node\": \"8.x\",\n \"@types/ramda\": \"types/npm-ramda#dist\",\n \"@vtex/api\": \"3.8.1\",\n \"tslint\": \"^5.8.0\",\n \"tslint-config-vtex\": \"^2.0.0\",\n \"typescript\": \"3.8.3\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit && tslint -c tslint.json './**/*.ts'\"\n },\n \"version\": \"0.1.0\"\n}\n\n```"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.