id
stringlengths
12
53
messages
listlengths
3
3
code_b2b-organizations_15802645
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of b2b-organizations/react/components/UploadingScreen/UploadingScreen.tsx from the b2b-organizations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useState } from 'react'\nimport { UploadingScreen as BulkImportUploadingScreen } from '@vtex/bulk-import-ui'\n\nimport type { UploadFileData } from '../../types/BulkImport'\nimport ValidatingScreen from './ValidatingScreen'\nimport useValidateBulkImport from '../../hooks/useValidateBulkImport'\n\nexport type UploadingScreenProps = {\n name: string\n size: number\n uploadFile: () => Promise<UploadFileData>\n onUploadFinished: (data: UploadFileData) => void\n}\n\nexport type UploadingStep = 'UPLOADING' | 'VALIDATING'\n\nconst UploadingScreen = ({\n uploadFile,\n onUploadFinished: onUploadFinishedProp,\n ...otherProps\n}: UploadingScreenProps) => {\n const [step, setStep] = useState<UploadingStep>('UPLOADING')\n\n const [importId, setImportId] = useState<string | undefined>(undefined)\n\n const { startBulkImportValidation } = useValidateBulkImport({\n onSuccess: () => {\n setStep('VALIDATING')\n },\n })\n\n const onUploadFinished = (data: UploadFileData) => {\n if (data.status === 'error') {\n onUploadFinishedProp(data)\n\n return\n }\n\n startBulkImportValidation({ importId: data?.data?.fileData?.importId })\n setImportId(data?.data?.fileData?.importId)\n }\n\n return step === 'UPLOADING' ? (\n <BulkImportUploadingScreen\n {...otherProps}\n uploadFile={uploadFile}\n onUploadFinished={onUploadFinished}\n />\n ) : (\n <ValidatingScreen\n {...otherProps}\n importId={importId}\n onUploadFinished={onUploadFinishedProp}\n />\n )\n}\n\nexport default UploadingScreen\n\n```" } ]
code_b2b-organizations_628411f9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of b2b-organizations/react/components/CreateOrganizationModal/index.tsx from the b2b-organizations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nexport { default } from './CreateOrganizationModal'\n\n```" } ]
code_b2b-organizations_6e932f04
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of b2b-organizations/react/components/CreateOrganizationModal/CreateOrganizationModal.tsx from the b2b-organizations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useEffect, useState } from 'react'\nimport { useMutation, useQuery } from 'react-apollo'\nimport { FormattedMessage, useIntl } from 'react-intl'\nimport { useToast } from '@vtex/admin-ui'\nimport { Button, Input, Modal } from 'vtex.styleguide'\nimport {\n AddressContainer,\n AddressForm,\n AddressRules,\n CountrySelector,\n PostalCodeGetter,\n} from 'vtex.address-form'\nimport { StyleguideInput } from 'vtex.address-form/inputs'\nimport { addValidation } from 'vtex.address-form/helpers'\nimport { useRuntime } from 'vtex.render-runtime'\n\nimport { getEmptyAddress, isValidAddress } from '../../utils/addresses'\nimport { validatePhoneNumber } from '../../modules/formValidators'\nimport { organizationMessages as messages } from '../../admin/utils/messages'\nimport GET_LOGISTICS from '../../graphql/getLogistics.graphql'\nimport CREATE_ORGANIZATION from '../../graphql/createOrganization.graphql'\nimport GET_B2B_CUSTOM_FIELDS from '../../graphql/getB2BCustomFields.graphql'\nimport {\n INITIAL_FETCH_LIST_OPTIONS,\n useOrganizationsList,\n} from '../../organizations/hooks'\nimport CustomFieldInputList from '../CustomFieldInputList/CustomFieldInputList'\n\ninterface Props {\n open: boolean\n onOpenChange: (open: boolean) => void\n}\n\nconst CreateOrganizationModal: React.FC<Props> = ({ open, onOpenChange }) => {\n const { formatMessage } = useIntl()\n const {\n culture: { country },\n } = useRuntime()\n\n const showToast = useToast()\n\n const [loadingState, setLoadingState] = useState(false)\n\n const [newOrganizationName, setNewOrganizationName] = useState('')\n const [newCostCenterName, setNewCostCenterName] = useState('')\n const [newCostCenterPhoneNumber, setNewCostCenterPhoneNumber] = useState('')\n const [\n newCostCenterBusinessDocument,\n setNewCostCenterBusinessDocument,\n ] = useState('')\n\n const [\n newCostCenterStateRegistration,\n setNewCostCenterStateRegistration,\n ] = useState('')\n\n const [newCostCenterAddressState, setNewCostCenterAddressState] = useState(\n addValidation(getEmptyAddress(country))\n )\n\n const { data: logisticsData } = useQuery(GET_LOGISTICS, { ssr: false })\n const [createOrganization] = useMutation(CREATE_ORGANIZATION)\n const { refetch } = useOrganizationsList()\n\n const translateCountries = () => {\n const { shipsTo = [] } = logisticsData?.logistics ?? {}\n\n return shipsTo.map((code: string) => ({\n label: formatMessage({ id: `country.${code}` }),\n value: code,\n }))\n }\n\n //! CUSTOM FIELDS\n const {\n data: defaultCustomFieldsData,\n loading: defaultCustomFieldsDataLoading,\n } = useQuery(GET_B2B_CUSTOM_FIELDS, {\n ssr: false,\n })\n\n const [orgCustomFieldsState, setOrgCustomFieldsState] = useState<\n CustomField[]\n >([])\n\n const [\n costCenterCustomFieldsState,\n setCostCenterCustomFieldsState,\n ] = useState<CustomField[]>([])\n\n useEffect(() => {\n if (defaultCustomFieldsDataLoading) return\n\n const organizationFieldsToDisplay = defaultCustomFieldsData?.getB2BSettings.organizationCustomFields.filter(\n (item: CustomField) => item.useOnRegistration\n )\n\n const costCenterFieldsToDisplay = defaultCustomFieldsData?.getB2BSettings.costCenterCustomFields.filter(\n (item: CustomField) => item.useOnRegistration\n )\n\n setOrgCustomFieldsState(organizationFieldsToDisplay)\n setCostCenterCustomFieldsState(costCenterFieldsToDisplay)\n }, [defaultCustomFieldsData])\n //! CUSTOM FIELDS\n\n const resetNewOrganizationForm = () => {\n setNewOrganizationName('')\n setNewCostCenterName('')\n setNewCostCenterPhoneNumber('')\n setNewCostCenterBusinessDocument('')\n setNewCostCenterAddressState(addValidation(getEmptyAddress(country)))\n }\n\n const handleAddNewOrganization = () => {\n setLoadingState(true)\n const newAddress = {\n addressId: newCostCenterAddressState.addressId.value,\n addressType: newCostCenterAddressState.addressType.value,\n city: newCostCenterAddressState.city.value,\n complement: newCostCenterAddressState.complement.value,\n country: newCostCenterAddressState.country.value,\n receiverName: newCostCenterAddressState.receiverName.value,\n geoCoordinates: newCostCenterAddressState.geoCoordinates.value,\n neighborhood: newCostCenterAddressState.neighborhood.value,\n number: newCostCenterAddressState.number.value,\n postalCode: newCostCenterAddressState.postalCode.value,\n reference: newCostCenterAddressState.reference.value,\n state: newCostCenterAddressState.state.value,\n street: newCostCenterAddressState.street.value,\n addressQuery: newCostCenterAddressState.addressQuery.value,\n }\n\n const variables = {\n input: {\n name: newOrganizationName,\n customFields: orgCustomFieldsState,\n defaultCostCenter: {\n name: newCostCenterName,\n address: newAddress,\n phoneNumber: newCostCenterPhoneNumber,\n businessDocument: newCostCenterBusinessDocument,\n customFields: costCenterCustomFieldsState,\n stateRegistration: newCostCenterStateRegistration,\n },\n },\n }\n\n createOrganization({ variables })\n .then(() => {\n onOpenChange(false)\n setLoadingState(false)\n resetNewOrganizationForm()\n showToast({\n variant: 'positive',\n message: formatMessage(messages.toastAddOrgSuccess),\n })\n refetch(INITIAL_FETCH_LIST_OPTIONS)\n })\n .catch(error => {\n onOpenChange(false)\n setLoadingState(false)\n console.error(error)\n showToast({\n variant: 'critical',\n message: formatMessage(messages.toastAddOrgFailure),\n })\n })\n }\n\n const handleNewCostCenterAddressChange = (\n changedAddress: AddressFormFields\n ) => {\n const curAddress = newCostCenterAddressState\n\n const newAddress = { ...curAddress, ...changedAddress }\n\n setNewCostCenterAddressState(newAddress)\n }\n\n const handleCloseModal = () => {\n onOpenChange(false)\n resetNewOrganizationForm()\n }\n\n return (\n <>\n <Modal\n centered\n bottomBar={\n <div className=\"nowrap\">\n <span className=\"mr4\">\n <Button\n variation=\"tertiary\"\n onClick={() => handleCloseModal()}\n disabled={loadingState}\n >\n {formatMessage(messages.cancel)}\n </Button>\n </span>\n <span>\n <Button\n variation=\"primary\"\n onClick={() => handleAddNewOrganization()}\n isLoading={loadingState}\n disabled={\n !newOrganizationName ||\n !newCostCenterName ||\n !isValidAddress(newCostCenterAddressState) ||\n (newCostCenterPhoneNumber &&\n !validatePhoneNumber(newCostCenterPhoneNumber))\n }\n >\n {formatMessage(messages.add)}\n </Button>\n </span>\n </div>\n }\n isOpen={open}\n onClose={() => handleCloseModal()}\n closeOnOverlayClick={false}\n >\n <p className=\"f3 f1-ns fw3 gray\">\n <FormattedMessage id=\"admin/b2b-organizations.organizations-admin.add-organization\" />\n </p>\n <div className=\"w-100 mv6\">\n <Input\n size=\"large\"\n label={formatMessage(messages.organizationName)}\n value={newOrganizationName}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setNewOrganizationName(e.target.value)\n }}\n required\n />\n </div>\n <CustomFieldInputList\n customFields={\n defaultCustomFieldsDataLoading ? null : orgCustomFieldsState\n }\n onChange={setOrgCustomFieldsState}\n />\n <div className=\"w-100 mv6\">\n <FormattedMessage id=\"admin/b2b-organizations.organizations-admin.add-organization.default-costCenter.helpText\" />\n </div>\n <div className=\"w-100 mv6\">\n <Input\n size=\"large\"\n label={formatMessage(messages.defaultCostCenterName)}\n value={newCostCenterName}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setNewCostCenterName(e.target.value)\n }}\n required\n />\n </div>\n <div className=\"w-100 mv6\">\n <Input\n size=\"large\"\n label={formatMessage(messages.phoneNumber)}\n value={newCostCenterPhoneNumber}\n error={\n newCostCenterPhoneNumber &&\n !validatePhoneNumber(newCostCenterPhoneNumber)\n }\n helpText={formatMessage(messages.phoneNumberHelp)}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setNewCostCenterPhoneNumber(e.target.value)\n }}\n />\n </div>\n <div className=\"w-100 mv6\">\n <Input\n size=\"large\"\n label={formatMessage(messages.businessDocument)}\n value={newCostCenterBusinessDocument}\n helpText={formatMessage(messages.businessDocumentHelp)}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setNewCostCenterBusinessDocument(e.target.value)\n }}\n />\n </div>\n <CustomFieldInputList\n customFields={\n defaultCustomFieldsDataLoading ? null : costCenterCustomFieldsState\n }\n onChange={setCostCenterCustomFieldsState}\n />\n <div className=\"w-100 mv6\">\n <Input\n size=\"large\"\n label={formatMessage(messages.stateRegistration)}\n value={newCostCenterStateRegistration}\n helpText={formatMessage(messages.stateRegistrationHelp)}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setNewCostCenterStateRegistration(e.target.value)\n }}\n />\n </div>\n <AddressRules\n country={newCostCenterAddressState?.country?.value}\n shouldUseIOFetching\n useGeolocation={false}\n >\n <AddressContainer\n address={newCostCenterAddressState}\n Input={StyleguideInput}\n onChangeAddress={handleNewCostCenterAddressChange}\n autoCompletePostalCode\n >\n <CountrySelector shipsTo={translateCountries()} />\n\n <PostalCodeGetter />\n\n <AddressForm\n Input={StyleguideInput}\n omitAutoCompletedFields={false}\n omitPostalCodeFields\n />\n </AddressContainer>\n </AddressRules>\n </Modal>\n </>\n )\n}\n\nexport default CreateOrganizationModal\n\n```" } ]
code_b2b-organizations_714c06bc
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of b2b-organizations/react/components/ImportReportModal/ImportReportModal.tsx from the b2b-organizations VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { Divider, csx } from '@vtex/admin-ui'\nimport {\n ErrorScreen,\n ReportInformation,\n ReportModal,\n} from '@vtex/bulk-import-ui'\n\nimport ReportList from '../UploadModal/ReportList'\nimport ReportInformationDetails from '../UploadModal/ReportInformationDetails'\nimport { useTranslate } from '../../hooks'\nimport useBulkImportDetailsQuery from '../../hooks/useBulkImportDetailsQuery'\nimport ReportDownloadLink from '../ReportDownloadLink/ReportDownloadLink'\n\nexport type ImportReportModalProps = {\n /** The report data id */\n importId: string\n /** Flag indicating if the modal is open or not. * */\n open?: boolean\n /** Function called when the modal's open state changes. * */\n onOpenChange?: (open: boolean) => void\n}\n\nconst ImportReportModal = ({\n importId,\n open,\n ...otherProps\n}: ImportReportModalProps) => {\n const { translate: t, formatDate } = useTranslate()\n\n const { data, error } = useBulkImportDetailsQuery({ importId })\n\n const reportDownloadLink = data?.importResult?.reportDownloadLink\n\n return (\n <ReportModal showTabs={false} open={open} {...otherProps}>\n <ReportModal.Header showDismiss>\n {t('importReportTitle')}\n </ReportModal.Header>\n <ReportModal.Content>\n <ReportModal.TabPanel\n title={t('importReportTabTitle')}\n id=\"success\"\n className={csx({ height: '100%' })}\n >\n {error && <ErrorScreen />}\n {!error && data && (\n <>\n <ReportInformation\n title={t('reportInformationTitle', {\n fullPercentage: data?.percentage,\n })}\n description={t('reportInformationDescription', {\n fileName: data?.fileName,\n userName: data?.importedUserName,\n uploadDate: formatDate(data?.importedAt),\n })}\n status={data?.percentage >= 100 ? 'success' : 'warning'}\n className={csx({ marginY: '$space-4' })}\n />\n {data?.percentage < 100 && (\n <ReportInformationDetails\n variant=\"Import\"\n validationReportDownloadLink={\n data?.importResult?.reportDownloadLink\n }\n />\n )}\n <Divider className={csx({ marginY: '$space-4' })} />\n <ReportList data={data.importReportList} />\n </>\n )}\n </ReportModal.TabPanel>\n </ReportModal.Content>\n <ReportModal.Footer\n closeLabel={t('done')}\n actionButton={<ReportDownloadLink downloadLink={reportDownloadLink} />}\n />\n </ReportModal>\n )\n}\n\nexport default ImportReportModal\n\n```" } ]
code_store-block-course_3823b223
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/config.json from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"title\": \"VTEX Store Block course\",\n \"tagline\": \"Learn how to create custom blocks on VTEX Store Framework\",\n \"description\": \"Using React and Graphql, you can export your components as VTEX blocks\",\n \"languages\": [\n \"en\",\n \"pt\"\n ],\n \"steps\": [\n {\n \"folder\": \"01_manifest\",\n \"title\": {\n \"pt\": \"Curso de blocos customizados\",\n \"en\": \"Custom blocks course\"\n },\n \"description\": {\n \"pt\": \"Neste passo, você irá aprender como se organizam os arquivos em uma app VTEX IO e o que cada campo no manifest.json significa\",\n \"en\": \"In this step, you'll learn how an app's files are organized in VTEX IO and what each field of the manifest.json means\"\n },\n \"challenge\": \"none\"\n }\n ]\n}\n\n```" } ]
code_store-block-course_cb53ec26
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/README.md from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Store Block course\n\n> **This content was moved to another place. We no longer support these courses and learning portal**\n\nTo check out this course in our new platform, you can click [here](https://developers.vtex.com/learning/docs/course-store-block-lang-en). You can also have a look at [our new landing page](https://developers.vtex.com/learning), where you can find interesing content for you!\n\n\n\n```" } ]
code_store-block-course_3f27407f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/index.ts from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { IOClients, Service, ServiceContext } from \"@vtex/api\";\nimport { join } from 'path'\n\ndeclare global {\n type Context = ServiceContext<IOClients, {}>;\n}\n\nconst correctionHandler = async (ctx: Context) => {\n const step = ctx.query.step;\n\n const stepModule = await import(join(__dirname, `./${step}.js`));\n const suite = stepModule.default;\n\n const results = await Promise.all(\n suite.tests.map(async ({ test, description, failMsg }: any) => {\n try {\n const pass = await test({\n files: [],\n getFile: (name: string) => new Promise(resolve => resolve(name)),\n lib: { }\n });\n return {\n pass,\n ...{\n failMsg: pass ? undefined : failMsg,\n successMsg: description\n }\n };\n } catch (e) {\n return { pass: false, failMsg: e.message || failMsg };\n }\n })\n );\n\n // Add cache header here, please Mr.\n ctx.status = 200;\n ctx.body = results;\n};\n\nexport default new Service<any, any>({\n routes: {\n correction: [correctionHandler]\n }\n});\n\n```" } ]
code_store-block-course_ce8cf9a7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/README.md from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Store Block course template\n\nHere you'll learn how to create awesome Store Framework blocks!\n\n```" } ]
code_store-block-course_c714394e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/package.json from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"countdown\",\n \"private\": true,\n \"license\": \"UNLICENSED\",\n \"scripts\": {\n \"lint\": \"eslint --ext js,jsx,ts,tsx .\",\n \"format\": \"prettier --write \\\"**/*.{ts,js,json}\\\"\"\n },\n \"devDependencies\": {\n \"@vtex/prettier-config\": \"^0.1.3\",\n \"eslint\": \"^6.8.0\",\n \"eslint-config-vtex\": \"^12.2.1\",\n \"eslint-config-vtex-react\": \"^6.2.1\",\n \"prettier\": \"^1.19.1\",\n \"typescript\": \"^3.7.5\"\n }\n}\n\n```" } ]
code_store-block-course_6da40a8a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/manifest.json from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"vendor\": \"vtex\",\n \"name\": \"countdown\",\n \"version\": \"0.0.1\",\n \"title\": \"Countdown\",\n \"description\": \"Countdown component\",\n \"defaultLocale\": \"pt-BR\",\n \"builders\": {\n \"messages\": \"1.x\",\n \"store\": \"0.x\",\n \"react\": \"3.x\"\n },\n \"dependencies\": {\n \"vtex.styleguide\": \"9.x\",\n \"vtex.css-handles\": \"0.x\"\n },\n \"$schema\": \"https://raw.githubusercontent.com/vtex/node-vtex-api/master/gen/manifest.schema\"\n}\n\n```" } ]
code_store-block-course_1dc3f948
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/messages/pt.json from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"editor.countdown.title\": \"Contagem regressiva\",\n \"editor.countdown.description\": \"Componente de contagem regressiva\"\n}\n\n```" } ]
code_store-block-course_b0734891
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/messages/en.json from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"editor.countdown.title\": \"Countdown\",\n \"editor.countdown.description\": \"Countdown component\"\n}\n```" } ]
code_store-block-course_c0d83ce8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/messages/context.json from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"editor.countdown.title\": \"Countdown\",\n \"editor.countdown.description\": \"Countdown component\"\n}\n```" } ]
code_store-block-course_2a0b775c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/messages/es.json from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"editor.countdown.title\": \"Cuenta regresiva\",\n \"editor.countdown.description\": \"Cuenta regresiva component\"\n}\n```" } ]
code_store-block-course_c076022b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/node/package.json from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"@vtex/api\": \"^3.0.0\"\n },\n \"devDependencies\": {\n \"@types/node\": \"8.x\",\n \"@vtex/api\": \"^3.0.0\",\n \"typescript\": \"3.9.4\"\n },\n \"resolutions\": {\n \"**/**/minimist\": \"^0.2.1\",\n \"**/**/lodash\": \"^4.17.17\"\n }\n}\n\n```" } ]
code_store-block-course_d803757c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/node/index.ts from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ClientsConfig, LRUCache, Service, ServiceContext } from '@vtex/api'\n\nimport { Clients } from './clients'\n\nconst TIMEOUT_MS = 5000\n\nconst memoryCache = new LRUCache<string, any>({ max: 5000 })\n\nmetrics.trackCache('status', memoryCache)\n\nconst clients: ClientsConfig<Clients> = {\n implementation: Clients,\n options: {\n default: {\n retries: 2,\n timeout: TIMEOUT_MS,\n },\n status: {\n memoryCache,\n },\n },\n}\n\ndeclare global {\n type Context = ServiceContext<Clients>\n}\n\n// Export a service that defines route handlers and client options.\nexport default new Service<Clients, {}>({\n clients,\n graphql: {\n resolvers: {\n Query: {},\n },\n },\n})\n\n```" } ]
code_store-block-course_186823f0
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/react/Countdown.tsx from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\ninterface CountdownProps {}\n\nconst Countdown: StorefrontFunctionComponent<CountdownProps> = ({}) => {\n return <div />\n}\n\nCountdown.schema = {\n title: 'editor.countdown.title',\n description: 'editor.countdown.description',\n type: 'object',\n properties: {},\n}\n\nexport default Countdown\n\n```" } ]
code_store-block-course_270428ac
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/react/package.json from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"@vtex/css-handles\": \"^1.0.0\",\n \"classnames\": \"^2.2.6\",\n \"ramda\": \"^0.26.1\",\n \"react\": \"^16.12.0\",\n \"react-apollo\": \"^3.1.3\",\n \"react-dom\": \"^16.12.0\",\n \"react-intl\": \"^3.12.0\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^3.1.3\",\n \"@types/classnames\": \"^2.2.7\",\n \"@types/jest\": \"^24.0.18\",\n \"@types/node\": \"^12.7.5\",\n \"@types/prop-types\": \"^15.7.0\",\n \"@types/ramda\": \"^0.26.5\",\n \"@types/react\": \"^16.9.31\",\n \"@vtex/test-tools\": \"^3.3.2\",\n \"@vtex/tsconfig\": \"^0.4.4\",\n \"apollo-cache-inmemory\": \"^1.6.5\",\n \"apollo-client\": \"^2.5.1\",\n \"graphql\": \"^14.6.0\",\n \"typescript\": \"^3.9.6\",\n \"vtex.css-handles\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.css-handles@0.4.4/public/@types/vtex.css-handles\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.120.0/public/@types/vtex.render-runtime\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.129.0/public/@types/vtex.styleguide\"\n }\n}\n\n```" } ]
code_store-block-course_10563728
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/store/interfaces.json from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"countdown\": {\n \"component\": \"Countdown\"\n }\n}\n```" } ]
code_store-block-course_ba331b5f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/node/clients/index.ts from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\n\nexport class Clients extends IOClients {}\n\n```" } ]
code_store-block-course_cc1d9020
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/node/typings/global.d.ts from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare const metrics\n\ntype GenericObject = Record<string, any>\n\n```" } ]
code_store-block-course_8b00dc1b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/react/typings/storefront.d.ts from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { FunctionComponent } from 'react'\n\ndeclare global {\n interface StorefrontFunctionComponent<P = GenericObject>\n extends FunctionComponent<P> {\n getSchema?(props: P): GenericObject\n schema?: GenericObject\n }\n\n interface StorefrontComponent<P = GenericObject, S = GenericObject>\n extends Component<P, S> {\n getSchema?(props: P): GenericObject\n schema: GenericObject\n }\n}\n\n```" } ]
code_store-block-course_8bafd655
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/react/typings/vtex.render-runtime.d.ts from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* Typings for `render-runtime` */\ndeclare module 'vtex.render-runtime' {\n import { Component, ComponentType, ReactElement, ReactType } from 'react'\n\n export interface NavigationOptions {\n page: string\n params?: any\n }\n\n export interface RenderContextProps {\n runtime: {\n navigate: (options: NavigationOptions) => void\n }\n }\n\n interface ExtensionPointProps {\n id: string\n [key: string]: any\n }\n\n export const ExtensionPoint: ComponentType<ExtensionPointProps>\n\n interface ChildBlockProps {\n id: string\n }\n\n export const ChildBlock: ComponentType<ChildBlockProps>\n export const useChildBlock = ({ id: string }) => GenericObject\n\n export const Helmet: ReactElement\n export const Link: ReactType\n export const NoSSR: ReactElement\n export const RenderContextConsumer: ReactElement\n export const canUseDOM: boolean\n export const withRuntimeContext: <TOriginalProps extends GenericObject>(\n Component: ComponentType<TOriginalProps & RenderContextProps>\n ) => ComponentType<TOriginalProps>\n}\n\n```" } ]
code_store-block-course_5e447b3b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/react/typings/global.d.ts from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport interface TimeSplit {\n hours: string\n minutes: string\n seconds: string\n}\n\ntype GenericObject = Record<string, any>\n\n```" } ]
code_store-block-course_4cb2877e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/react/typings/css.d.ts from the store-block-course 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_store-block-course_08b83ac6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/react/typings/graphql.d.ts from the store-block-course 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_store-block-course_33529144
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/react/typings/vtex.styleguide.d.ts from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide' {\n import { ComponentType } from 'react'\n\n export const Input: ComponentType<InputProps>\n\n interface InputProps {\n [key: string]: any\n }\n}\n\n```" } ]
code_store-block-course_adb6703a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/react/utils/time.ts from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { TimeSplit } from '../typings/global'\n\nconst SECONDS_IN_MINUTE = 60\nconst SECONDS_IN_HOUR = 60 * SECONDS_IN_MINUTE\n\nconst fillWithZero = (digits: number, number: number): string => {\n const filled = `${'0'.repeat(digits - 1)}${number}`\n\n return filled.slice(filled.length - digits)\n}\n\nexport const parseTimeRemaining = (totalSeconds: number): TimeSplit => {\n const hours = Math.floor(totalSeconds / SECONDS_IN_HOUR)\n const minutes = Math.floor(\n (totalSeconds % SECONDS_IN_HOUR) / SECONDS_IN_MINUTE\n )\n\n const seconds = Math.floor(\n (totalSeconds % SECONDS_IN_HOUR) % SECONDS_IN_MINUTE\n )\n\n return {\n hours: fillWithZero(2, hours),\n minutes: fillWithZero(2, minutes),\n seconds: fillWithZero(2, seconds),\n }\n}\n\n/**\n *\n * @param targetDate ISOString for the date that the countdown will expire\n * @param dispatchFn A function that updates the state of the component\n */\nexport const tick = (\n targetDate: string,\n dispatchFn: React.Dispatch<React.SetStateAction<TimeSplit>>\n) => {\n const ONE_SECOND_IN_MILLIS = 1000\n const finalDate = new Date(targetDate)\n const now = new Date()\n\n const secondsLeft =\n (finalDate.getTime() - now.getTime()) / ONE_SECOND_IN_MILLIS\n\n setTimeout(() => {\n dispatchFn(parseTimeRemaining(secondsLeft))\n }, ONE_SECOND_IN_MILLIS)\n}\n\nexport const getTwoDaysFromNow = () => {\n const today = new Date()\n\n today.setDate(today.getDate() + 2)\n\n return today.toISOString()\n}\n\n```" } ]
code_store-block-course_cb09276b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-block-course/course/template/react/__tests__/index.test.tsx from the store-block-course VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { render } from '@vtex/test-tools/react'\n\nimport Component from '../components/index'\n\ndescribe('HelloWorld Component', () => {\n const { getByText } = render(<Component />)\n\n it('should render the example in TypeScript', () => {\n expect(getByText(/This is an example/)).toBeDefined()\n })\n})\n\n```" } ]
code_storefront-permissions-ui_9d14fa0d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/messages/nl.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"B2B-informatie\",\n \"admin/storefront-permissions.button.cancel\": \"Annuleren\",\n \"admin/storefront-permissions.button.delete\": \"B2B-info verwijderen\",\n \"admin/storefront-permissions.button.save\": \"Opslaan\",\n \"admin/storefront-permissions.description\": \"Rollen en gebruikersbeheer\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, rollen, profielen\",\n \"admin/storefront-permissions.navigation.label\": \"Storefront-machtigingen\",\n \"admin/storefront-permissions.required\": \"Vereist\",\n \"admin/storefront-permissions.tab.new.button\": \"Nieuw\",\n \"admin/storefront-permissions.tab.roles\": \"Rollen\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"Kan geen apps vinden die verbonden zijn met de storefront-machtigingen\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"Rol\",\n \"admin/storefront-permissions.tab.roles.category.label\": \"Category\",\n \"admin/storefront-permissions.tab.users\": \"Gebruikers\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"Kan imiteren\",\n \"admin/storefront-permissions.tab.users.email.label\": \"E-mailadres\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"Organisatie\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"Kostencentrum\",\n \"admin/storefront-permissions.tab.users.error\": \"Fout bij opslaan B2B-info\",\n \"admin/storefront-permissions.tab.users.name.label\": \"Naam\",\n \"admin/storefront-permissions.tab.users.success\": \"B2B-info opgeslagen\",\n \"admin/storefront-permissions.title\": \"Storefront-machtigingen\",\n \"admin/storefront-permissions.alert-pick\": \"U moet een kostencentrum kiezen voordat u wijzigingen kunt opslaan\",\n \"admin/storefront-permissions.searchOrganizations\": \"Organisaties zoeken...\",\n \"admin/storefront-permissions.help.title\": \"How it works\",\n \"admin/storefront-permissions.help.text1\": \"Role Names can be renamed, but categories are fixed.\",\n \"admin/storefront-permissions.help.text2\": \"There are three categories available:\",\n \"admin/storefront-permissions.help.category1\": \"Store Admin\",\n \"admin/storefront-permissions.help.category1.text1\": \"Full access\",\n \"admin/storefront-permissions.help.category2\": \"Sales\",\n \"admin/storefront-permissions.help.category2.text1\": \"Can manage quotations, sales, and users from the its Organization.\",\n \"admin/storefront-permissions.help.category2.text2\": \"It can have different access levels.\",\n \"admin/storefront-permissions.help.category2.text3\": \"Can belong to one or many organizations.\",\n \"admin/storefront-permissions.help.category2.text4\": \"Sales users can only manage Sales roles.\",\n \"admin/storefront-permissions.help.category2.text5\": \"Sales user hierarchy: sales-admin > sales-manager > sales-representative\",\n \"admin/storefront-permissions.help.category3\": \"Customers\",\n \"admin/storefront-permissions.help.category3.text1\": \"Have access and can manage its own organization.\",\n \"admin/storefront-permissions.help.category3.text2\": \"Customers users can only manage users under the Customers roles.\",\n \"admin/storefront-permissions.help.category3.text3\": \"Customers users hierarchy: customer-amin > customer-approver > customer-buyer\"\n}\n\n```" } ]
code_storefront-permissions-ui_08bba0b4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/messages/ja.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"B2B 情報\",\n \"admin/storefront-permissions.button.cancel\": \"キャンセル\",\n \"admin/storefront-permissions.button.delete\": \"B2B 情報を削除する\",\n \"admin/storefront-permissions.button.save\": \"保存\",\n \"admin/storefront-permissions.description\": \"役割およびユーザー管理\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, 役割, プロファイル\",\n \"admin/storefront-permissions.navigation.label\": \"店頭権限\",\n \"admin/storefront-permissions.required\": \"必須\",\n \"admin/storefront-permissions.tab.new.button\": \"新規\",\n \"admin/storefront-permissions.tab.roles\": \"役割\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"店頭権限に接続したアプリは見つかりませんでした\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"役割\",\n \"admin/storefront-permissions.tab.roles.category.label\": \"Category\",\n \"admin/storefront-permissions.tab.users\": \"ユーザー\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"偽装することができます\",\n \"admin/storefront-permissions.tab.users.email.label\": \"メール\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"組織\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"コストセンター\",\n \"admin/storefront-permissions.tab.users.error\": \"B2B 情報を保存する時にエラーが発生しました\",\n \"admin/storefront-permissions.tab.users.name.label\": \"名前\",\n \"admin/storefront-permissions.tab.users.success\": \"B2B 情報を保存しました\",\n \"admin/storefront-permissions.title\": \"店頭権限\",\n \"admin/storefront-permissions.alert-pick\": \"変更を保存する前にコストセンターを選ばなければなりません\",\n \"admin/storefront-permissions.searchOrganizations\": \"組織を検索…\",\n \"admin/storefront-permissions.help.title\": \"How it works\",\n \"admin/storefront-permissions.help.text1\": \"Role Names can be renamed, but categories are fixed.\",\n \"admin/storefront-permissions.help.text2\": \"There are three categories available:\",\n \"admin/storefront-permissions.help.category1\": \"Store Admin\",\n \"admin/storefront-permissions.help.category1.text1\": \"Full access\",\n \"admin/storefront-permissions.help.category2\": \"Sales\",\n \"admin/storefront-permissions.help.category2.text1\": \"Can manage quotations, sales, and users from the its Organization.\",\n \"admin/storefront-permissions.help.category2.text2\": \"It can have different access levels.\",\n \"admin/storefront-permissions.help.category2.text3\": \"Can belong to one or many organizations.\",\n \"admin/storefront-permissions.help.category2.text4\": \"Sales users can only manage Sales roles.\",\n \"admin/storefront-permissions.help.category2.text5\": \"Sales user hierarchy: sales-admin > sales-manager > sales-representative\",\n \"admin/storefront-permissions.help.category3\": \"Customers\",\n \"admin/storefront-permissions.help.category3.text1\": \"Have access and can manage its own organization.\",\n \"admin/storefront-permissions.help.category3.text2\": \"Customers users can only manage users under the Customers roles.\",\n \"admin/storefront-permissions.help.category3.text3\": \"Customers users hierarchy: customer-amin > customer-approver > customer-buyer\"\n}\n\n```" } ]
code_storefront-permissions-ui_339c520f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/messages/pt.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"Informações B2B\",\n \"admin/storefront-permissions.button.cancel\": \"Cancelar\",\n \"admin/storefront-permissions.button.delete\": \"Remover informações B2B\",\n \"admin/storefront-permissions.button.save\": \"Salvar\",\n \"admin/storefront-permissions.description\": \"Gerenciamento de perfis de acesso e usuários\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, perfis de acesso, usuários\",\n \"admin/storefront-permissions.navigation.label\": \"Permissões da loja\",\n \"admin/storefront-permissions.required\": \"Obrigatório\",\n \"admin/storefront-permissions.tab.new.button\": \"Criar nova\",\n \"admin/storefront-permissions.tab.roles\": \"Perfis de acesso\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"Não foi possível encontrar nenhum app conectado às permissões da loja\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"Perfil de acesso\",\n \"admin/storefront-permissions.tab.roles.category.label\": \"Category\",\n \"admin/storefront-permissions.tab.users\": \"Usuários\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"Pode personificar\",\n \"admin/storefront-permissions.tab.users.email.label\": \"Email\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"Organização\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"Centro de custo\",\n \"admin/storefront-permissions.tab.users.error\": \"Erro ao salvar informações B2B\",\n \"admin/storefront-permissions.tab.users.name.label\": \"Nome\",\n \"admin/storefront-permissions.tab.users.success\": \"Informações B2B salvas\",\n \"admin/storefront-permissions.title\": \"Permissões da loja\",\n \"admin/storefront-permissions.alert-pick\": \"Você precisa selecionar um centro de custo antes de salvar as alterações\",\n \"admin/storefront-permissions.searchOrganizations\": \"Buscar organizações...\",\n \"admin/storefront-permissions.help.title\": \"How it works\",\n \"admin/storefront-permissions.help.text1\": \"Role Names can be renamed, but categories are fixed.\",\n \"admin/storefront-permissions.help.text2\": \"There are three categories available:\",\n \"admin/storefront-permissions.help.category1\": \"Store Admin\",\n \"admin/storefront-permissions.help.category1.text1\": \"Full access\",\n \"admin/storefront-permissions.help.category2\": \"Sales\",\n \"admin/storefront-permissions.help.category2.text1\": \"Can manage quotations, sales, and users from the its Organization.\",\n \"admin/storefront-permissions.help.category2.text2\": \"It can have different access levels.\",\n \"admin/storefront-permissions.help.category2.text3\": \"Can belong to one or many organizations.\",\n \"admin/storefront-permissions.help.category2.text4\": \"Sales users can only manage Sales roles.\",\n \"admin/storefront-permissions.help.category2.text5\": \"Sales user hierarchy: sales-admin > sales-manager > sales-representative\",\n \"admin/storefront-permissions.help.category3\": \"Customers\",\n \"admin/storefront-permissions.help.category3.text1\": \"Have access and can manage its own organization.\",\n \"admin/storefront-permissions.help.category3.text2\": \"Customers users can only manage users under the Customers roles.\",\n \"admin/storefront-permissions.help.category3.text3\": \"Customers users hierarchy: customer-amin > customer-approver > customer-buyer\"\n}\n\n```" } ]
code_storefront-permissions-ui_30cb65f4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/messages/en.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"B2B Information\",\n \"admin/storefront-permissions.button.cancel\": \"Cancel\",\n \"admin/storefront-permissions.button.delete\": \"Remove B2B Info\",\n \"admin/storefront-permissions.button.save\": \"Save\",\n \"admin/storefront-permissions.description\": \"Roles Management\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, Roles, Profiles\",\n \"admin/storefront-permissions.navigation.label\": \"Storefront Permissions\",\n \"admin/storefront-permissions.required\": \"Required\",\n \"admin/storefront-permissions.tab.new.button\": \"New\",\n \"admin/storefront-permissions.tab.roles\": \"Roles\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"Couldn't find any apps connected to the storefront permissions\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"Role Name\",\n \"admin/storefront-permissions.tab.roles.category.label\": \"Category\",\n \"admin/storefront-permissions.tab.users\": \"Users\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"Can impersonate\",\n \"admin/storefront-permissions.tab.users.email.label\": \"Email\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"Organization\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"Cost Center\",\n \"admin/storefront-permissions.tab.users.error\": \"Error saving B2B info\",\n \"admin/storefront-permissions.tab.users.name.label\": \"Name\",\n \"admin/storefront-permissions.tab.users.success\": \"B2B info saved\",\n \"admin/storefront-permissions.title\": \"Storefront Permissions\",\n \"admin/storefront-permissions.alert-pick\": \"You need to choose a cost center before saving changes\",\n \"admin/storefront-permissions.searchOrganizations\": \"Search organizations...\",\n \"admin/storefront-permissions.help.title\": \"How it works\",\n \"admin/storefront-permissions.help.text1\": \"Role Names can be renamed, but categories are fixed.\",\n \"admin/storefront-permissions.help.text2\": \"There are three categories available:\",\n \"admin/storefront-permissions.help.category1\": \"Store Admin\",\n \"admin/storefront-permissions.help.category1.text1\": \"Full access\",\n \"admin/storefront-permissions.help.category2\": \"Sales\",\n \"admin/storefront-permissions.help.category2.text1\": \"Can manage quotations, sales, and users from the its Organization.\",\n \"admin/storefront-permissions.help.category2.text2\": \"It can have different access levels.\",\n \"admin/storefront-permissions.help.category2.text3\": \"Can belong to one or many organizations.\",\n \"admin/storefront-permissions.help.category2.text4\": \"Sales users can only manage Sales roles.\",\n \"admin/storefront-permissions.help.category2.text5\": \"Sales user hierarchy: sales-admin > sales-manager > sales-representative\",\n \"admin/storefront-permissions.help.category3\": \"Customers\",\n \"admin/storefront-permissions.help.category3.text1\": \"Have access and can manage its own organization.\",\n \"admin/storefront-permissions.help.category3.text2\": \"Customers users can only manage users under the Customers roles.\",\n \"admin/storefront-permissions.help.category3.text3\": \"Customers users hierarchy: customer-amin > customer-approver > customer-buyer\"\n}\n\n```" } ]
code_storefront-permissions-ui_f3e6dd7a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/messages/it.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"Informazioni B2B\",\n \"admin/storefront-permissions.button.cancel\": \"Annulla\",\n \"admin/storefront-permissions.button.delete\": \"Rimuovi informazioni B2B\",\n \"admin/storefront-permissions.button.save\": \"Salva\",\n \"admin/storefront-permissions.description\": \"Ruoli e gestione utenti\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, ruoli, profili\",\n \"admin/storefront-permissions.navigation.label\": \"Permessi del negozio\",\n \"admin/storefront-permissions.required\": \"Obbligatorio\",\n \"admin/storefront-permissions.tab.new.button\": \"Nuovo\",\n \"admin/storefront-permissions.tab.roles\": \"Ruoli\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"Non è stato possibile trovare nessuna app associata ai permessi del negozio\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"Ruolo\",\n \"admin/storefront-permissions.tab.roles.category.label\": \"Category\",\n \"admin/storefront-permissions.tab.users\": \"Utenti\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"Può impersonare\",\n \"admin/storefront-permissions.tab.users.email.label\": \"Email\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"Organizzazione\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"Centro di costo\",\n \"admin/storefront-permissions.tab.users.error\": \"Errore durante il salvataggio delle informazioni B2B\",\n \"admin/storefront-permissions.tab.users.name.label\": \"Nome\",\n \"admin/storefront-permissions.tab.users.success\": \"Informazioni B2B salvate\",\n \"admin/storefront-permissions.title\": \"Permessi del negozio\",\n \"admin/storefront-permissions.alert-pick\": \"È necessario scegliere un centro di costo prima di salvare le modifiche\",\n \"admin/storefront-permissions.searchOrganizations\": \"Cerca organizzazioni...\",\n \"admin/storefront-permissions.help.title\": \"How it works\",\n \"admin/storefront-permissions.help.text1\": \"Role Names can be renamed, but categories are fixed.\",\n \"admin/storefront-permissions.help.text2\": \"There are three categories available:\",\n \"admin/storefront-permissions.help.category1\": \"Store Admin\",\n \"admin/storefront-permissions.help.category1.text1\": \"Full access\",\n \"admin/storefront-permissions.help.category2\": \"Sales\",\n \"admin/storefront-permissions.help.category2.text1\": \"Can manage quotations, sales, and users from the its Organization.\",\n \"admin/storefront-permissions.help.category2.text2\": \"It can have different access levels.\",\n \"admin/storefront-permissions.help.category2.text3\": \"Can belong to one or many organizations.\",\n \"admin/storefront-permissions.help.category2.text4\": \"Sales users can only manage Sales roles.\",\n \"admin/storefront-permissions.help.category2.text5\": \"Sales user hierarchy: sales-admin > sales-manager > sales-representative\",\n \"admin/storefront-permissions.help.category3\": \"Customers\",\n \"admin/storefront-permissions.help.category3.text1\": \"Have access and can manage its own organization.\",\n \"admin/storefront-permissions.help.category3.text2\": \"Customers users can only manage users under the Customers roles.\",\n \"admin/storefront-permissions.help.category3.text3\": \"Customers users hierarchy: customer-amin > customer-approver > customer-buyer\"\n}\n\n```" } ]
code_storefront-permissions-ui_98740124
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/messages/fr.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"Information B2B\",\n \"admin/storefront-permissions.button.cancel\": \"Annuler\",\n \"admin/storefront-permissions.button.delete\": \"Supprimer les infos B2B\",\n \"admin/storefront-permissions.button.save\": \"Sauvegarder\",\n \"admin/storefront-permissions.description\": \"Rôles et gestion des utilisateurs\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, rôles, profiles\",\n \"admin/storefront-permissions.navigation.label\": \"Autorisations de la vitrine\",\n \"admin/storefront-permissions.required\": \"Requis\",\n \"admin/storefront-permissions.tab.new.button\": \"Nouveau\",\n \"admin/storefront-permissions.tab.roles\": \"Rôles\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"Impossible de trouver les applications connectées aux autorisations de la vitrine\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"Rôle\",\n \"admin/storefront-permissions.tab.roles.category.label\": \"Category\",\n \"admin/storefront-permissions.tab.users\": \"Utilisateurs\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"Peut se faire passer pour\",\n \"admin/storefront-permissions.tab.users.email.label\": \"Email\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"Organisation\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"Centre de coûts\",\n \"admin/storefront-permissions.tab.users.error\": \"Erreur lors de l’enregistrement des infos B2B\",\n \"admin/storefront-permissions.tab.users.name.label\": \"Nom\",\n \"admin/storefront-permissions.tab.users.success\": \"Infos B2B enregistrées\",\n \"admin/storefront-permissions.title\": \"Autorisations de la vitrine\",\n \"admin/storefront-permissions.alert-pick\": \"Vous devez choisir un centre de coûts avant d’enregistrer les modifications\",\n \"admin/storefront-permissions.searchOrganizations\": \"Rechercher des organisations...\",\n \"admin/storefront-permissions.help.title\": \"How it works\",\n \"admin/storefront-permissions.help.text1\": \"Role Names can be renamed, but categories are fixed.\",\n \"admin/storefront-permissions.help.text2\": \"There are three categories available:\",\n \"admin/storefront-permissions.help.category1\": \"Store Admin\",\n \"admin/storefront-permissions.help.category1.text1\": \"Full access\",\n \"admin/storefront-permissions.help.category2\": \"Sales\",\n \"admin/storefront-permissions.help.category2.text1\": \"Can manage quotations, sales, and users from the its Organization.\",\n \"admin/storefront-permissions.help.category2.text2\": \"It can have different access levels.\",\n \"admin/storefront-permissions.help.category2.text3\": \"Can belong to one or many organizations.\",\n \"admin/storefront-permissions.help.category2.text4\": \"Sales users can only manage Sales roles.\",\n \"admin/storefront-permissions.help.category2.text5\": \"Sales user hierarchy: sales-admin > sales-manager > sales-representative\",\n \"admin/storefront-permissions.help.category3\": \"Customers\",\n \"admin/storefront-permissions.help.category3.text1\": \"Have access and can manage its own organization.\",\n \"admin/storefront-permissions.help.category3.text2\": \"Customers users can only manage users under the Customers roles.\",\n \"admin/storefront-permissions.help.category3.text3\": \"Customers users hierarchy: customer-amin > customer-approver > customer-buyer\"\n}\n\n```" } ]
code_storefront-permissions-ui_65128c23
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/messages/bg.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"Информация за B2B\",\n \"admin/storefront-permissions.button.cancel\": \"Отказ\",\n \"admin/storefront-permissions.button.delete\": \"Премахване на информация за B2B\",\n \"admin/storefront-permissions.button.save\": \"Запазване\",\n \"admin/storefront-permissions.description\": \"Управление на роли и потребители\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, роли, профили\",\n \"admin/storefront-permissions.navigation.label\": \"Разрешения на витрината\",\n \"admin/storefront-permissions.required\": \"Задължително\",\n \"admin/storefront-permissions.tab.new.button\": \"Ново\",\n \"admin/storefront-permissions.tab.roles\": \"Роли\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"Не са открити приложения, свързани с разрешенията за витрината\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"Роля\",\n \"admin/storefront-permissions.tab.roles.category.label\": \"Category\",\n \"admin/storefront-permissions.tab.users\": \"Потребители\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"Може да въплъщава\",\n \"admin/storefront-permissions.tab.users.email.label\": \"Имейл адрес\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"Организация\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"Разходен център\",\n \"admin/storefront-permissions.tab.users.error\": \"Грешка при запазването на информацията за B2B\",\n \"admin/storefront-permissions.tab.users.name.label\": \"Име\",\n \"admin/storefront-permissions.tab.users.success\": \"Информацията за B2B е запазена\",\n \"admin/storefront-permissions.title\": \"Разрешения на витрината\",\n \"admin/storefront-permissions.alert-pick\": \"Трябва да изберете разходен център, преди да запазите промените\",\n \"admin/storefront-permissions.searchOrganizations\": \"Търсене на организации...\",\n \"admin/storefront-permissions.help.title\": \"How it works\",\n \"admin/storefront-permissions.help.text1\": \"Role Names can be renamed, but categories are fixed.\",\n \"admin/storefront-permissions.help.text2\": \"There are three categories available:\",\n \"admin/storefront-permissions.help.category1\": \"Store Admin\",\n \"admin/storefront-permissions.help.category1.text1\": \"Full access\",\n \"admin/storefront-permissions.help.category2\": \"Sales\",\n \"admin/storefront-permissions.help.category2.text1\": \"Can manage quotations, sales, and users from the its Organization.\",\n \"admin/storefront-permissions.help.category2.text2\": \"It can have different access levels.\",\n \"admin/storefront-permissions.help.category2.text3\": \"Can belong to one or many organizations.\",\n \"admin/storefront-permissions.help.category2.text4\": \"Sales users can only manage Sales roles.\",\n \"admin/storefront-permissions.help.category2.text5\": \"Sales user hierarchy: sales-admin > sales-manager > sales-representative\",\n \"admin/storefront-permissions.help.category3\": \"Customers\",\n \"admin/storefront-permissions.help.category3.text1\": \"Have access and can manage its own organization.\",\n \"admin/storefront-permissions.help.category3.text2\": \"Customers users can only manage users under the Customers roles.\",\n \"admin/storefront-permissions.help.category3.text3\": \"Customers users hierarchy: customer-amin > customer-approver > customer-buyer\"\n}\n\n```" } ]
code_storefront-permissions-ui_8a53891c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/messages/ro.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"Informații B2B\",\n \"admin/storefront-permissions.button.cancel\": \"Anulare\",\n \"admin/storefront-permissions.button.delete\": \"Ștergere informații B2B\",\n \"admin/storefront-permissions.button.save\": \"Salvare\",\n \"admin/storefront-permissions.description\": \"Funcții și gestionare utilizatori\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, funcții și profiluri\",\n \"admin/storefront-permissions.navigation.label\": \"Permisiuni magazin\",\n \"admin/storefront-permissions.required\": \"Obligatoriu\",\n \"admin/storefront-permissions.tab.new.button\": \"Nou\",\n \"admin/storefront-permissions.tab.roles\": \"Funcții\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"Nu am putut găsi nicio aplicație conectată la permisiunile magazinului\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"Funcții\",\n \"admin/storefront-permissions.tab.roles.category.label\": \"Category\",\n \"admin/storefront-permissions.tab.users\": \"Utilizatori\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"Pot înlocui\",\n \"admin/storefront-permissions.tab.users.email.label\": \"E-mail\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"Organizație\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"Centru de Cost\",\n \"admin/storefront-permissions.tab.users.error\": \"Eroare la salvarea informațiilor B2B\",\n \"admin/storefront-permissions.tab.users.name.label\": \"Nume\",\n \"admin/storefront-permissions.tab.users.success\": \"Informații B2B salvate\",\n \"admin/storefront-permissions.title\": \"Permisiuni magazin\",\n \"admin/storefront-permissions.alert-pick\": \"Trebuie să alegi un centru de cost înainte de a salva modificările\",\n \"admin/storefront-permissions.searchOrganizations\": \"Căutare organizații...\",\n \"admin/storefront-permissions.help.title\": \"How it works\",\n \"admin/storefront-permissions.help.text1\": \"Role Names can be renamed, but categories are fixed.\",\n \"admin/storefront-permissions.help.text2\": \"There are three categories available:\",\n \"admin/storefront-permissions.help.category1\": \"Store Admin\",\n \"admin/storefront-permissions.help.category1.text1\": \"Full access\",\n \"admin/storefront-permissions.help.category2\": \"Sales\",\n \"admin/storefront-permissions.help.category2.text1\": \"Can manage quotations, sales, and users from the its Organization.\",\n \"admin/storefront-permissions.help.category2.text2\": \"It can have different access levels.\",\n \"admin/storefront-permissions.help.category2.text3\": \"Can belong to one or many organizations.\",\n \"admin/storefront-permissions.help.category2.text4\": \"Sales users can only manage Sales roles.\",\n \"admin/storefront-permissions.help.category2.text5\": \"Sales user hierarchy: sales-admin > sales-manager > sales-representative\",\n \"admin/storefront-permissions.help.category3\": \"Customers\",\n \"admin/storefront-permissions.help.category3.text1\": \"Have access and can manage its own organization.\",\n \"admin/storefront-permissions.help.category3.text2\": \"Customers users can only manage users under the Customers roles.\",\n \"admin/storefront-permissions.help.category3.text3\": \"Customers users hierarchy: customer-amin > customer-approver > customer-buyer\"\n}\n\n```" } ]
code_storefront-permissions-ui_e70763fb
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/messages/context.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.navigation.label\": \"admin/storefront-permissions.navigation.label\",\n \"admin/storefront-permissions.navigation.keywords\": \"admin/storefront-permissions.navigation.keywords\",\n \"admin/storefront-permissions.title\": \"admin/storefront-permissions.title\",\n \"admin/storefront-permissions.description\": \"admin/storefront-permissions.description\",\n \"admin/storefront-permissions.required\": \"admin/storefront-permissions.required\",\n \"admin/storefront-permissions.tab.new.button\": \"admin/storefront-permissions.tab.new.button\",\n \"admin/storefront-permissions.button.save\": \"admin/storefront-permissions.button.save\",\n \"admin/storefront-permissions.button.delete\": \"admin/storefront-permissions.button.delete\",\n \"admin/storefront-permissions.button.cancel\": \"admin/storefront-permissions.button.cancel\",\n \"admin/storefront-permissions.tab.users\": \"admin/storefront-permissions.tab.users\",\n \"admin/storefront-permissions.tab.users.email.label\": \"admin/storefront-permissions.tab.users.email.label\",\n \"admin/storefront-permissions.tab.users.name.label\": \"admin/storefront-permissions.tab.users.name.label\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"admin/storefront-permissions.tab.users.canImpersonate.label\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"admin/storefront-permissions.tab.roles.name.label\",\n \"admin/storefront-permissions.tab.roles.category.label\": \"admin/storefront-permissions.tab.roles.category.label\",\n \"admin/storefront-permissions.tab.roles\": \"admin/storefront-permissions.tab.roles\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"admin/storefront-permissions.tab.roles.featuresNotFound\",\n \"admin/storefront-permissions.help.title\": \"admin/storefront-permissions.help.title\",\n \"admin/storefront-permissions.help.text1\": \"admin/storefront-permissions.help.text1\",\n \"admin/storefront-permissions.help.text2\": \"admin/storefront-permissions.help.text2\",\n \"admin/storefront-permissions.help.category1\": \"admin/storefront-permissions.help.category1\",\n \"admin/storefront-permissions.help.category1.text1\": \"admin/storefront-permissions.help.category1.text1\",\n \"admin/storefront-permissions.help.category2\": \"admin/storefront-permissions.help.category2\",\n \"admin/storefront-permissions.help.category2.text1\": \"admin/storefront-permissions.help.category2.text1\",\n \"admin/storefront-permissions.help.category2.text2\": \"admin/storefront-permissions.help.category2.text2\",\n \"admin/storefront-permissions.help.category2.text3\": \"admin/storefront-permissions.help.category2.text3\",\n \"admin/storefront-permissions.help.category2.text4\": \"admin/storefront-permissions.help.category2.text4\",\n \"admin/storefront-permissions.help.category2.text5\": \"admin/storefront-permissions.help.category2.text5\",\n \"admin/storefront-permissions.help.category3\": \"admin/storefront-permissions.help.category3\",\n \"admin/storefront-permissions.help.category3.text1\": \"admin/storefront-permissions.help.category3.text1\",\n \"admin/storefront-permissions.help.category3.text2\": \"admin/storefront-permissions.help.category3.text2\",\n \"admin/storefront-permissions.help.category3.text3\": \"admin/storefront-permissions.help.category3.text3\"\n}\n\n```" } ]
code_storefront-permissions-ui_10fbe3ac
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/messages/ko.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"B2B 정보\",\n \"admin/storefront-permissions.button.cancel\": \"취소\",\n \"admin/storefront-permissions.button.delete\": \"B2B 정보 제거\",\n \"admin/storefront-permissions.button.save\": \"저장\",\n \"admin/storefront-permissions.description\": \"역할 및 사용자 관리\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, 역할, 프로필\",\n \"admin/storefront-permissions.navigation.label\": \"스토어프론트 권한\",\n \"admin/storefront-permissions.required\": \"필수\",\n \"admin/storefront-permissions.tab.new.button\": \"추가\",\n \"admin/storefront-permissions.tab.roles\": \"역할\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"스토어프론트 권한에 연결된 앱을 찾을 수 없습니다.\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"역할\",\n \"admin/storefront-permissions.tab.roles.category.label\": \"Category\",\n \"admin/storefront-permissions.tab.users\": \"사용자\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"가장할 수 있음\",\n \"admin/storefront-permissions.tab.users.email.label\": \"이메일\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"조직\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"비용 센터\",\n \"admin/storefront-permissions.tab.users.error\": \"B2B 정보를 저장하는 동안 오류가 발생했습니다.\",\n \"admin/storefront-permissions.tab.users.name.label\": \"이름\",\n \"admin/storefront-permissions.tab.users.success\": \"B2B 정보 저장됨\",\n \"admin/storefront-permissions.title\": \"스토어프론트 권한\",\n \"admin/storefront-permissions.alert-pick\": \"변경 사항을 저장하기 전에 비용 센터를 선택해야 합니다.\",\n \"admin/storefront-permissions.searchOrganizations\": \"조직 검색...\",\n \"admin/storefront-permissions.help.title\": \"How it works\",\n \"admin/storefront-permissions.help.text1\": \"Role Names can be renamed, but categories are fixed.\",\n \"admin/storefront-permissions.help.text2\": \"There are three categories available:\",\n \"admin/storefront-permissions.help.category1\": \"Store Admin\",\n \"admin/storefront-permissions.help.category1.text1\": \"Full access\",\n \"admin/storefront-permissions.help.category2\": \"Sales\",\n \"admin/storefront-permissions.help.category2.text1\": \"Can manage quotations, sales, and users from the its Organization.\",\n \"admin/storefront-permissions.help.category2.text2\": \"It can have different access levels.\",\n \"admin/storefront-permissions.help.category2.text3\": \"Can belong to one or many organizations.\",\n \"admin/storefront-permissions.help.category2.text4\": \"Sales users can only manage Sales roles.\",\n \"admin/storefront-permissions.help.category2.text5\": \"Sales user hierarchy: sales-admin > sales-manager > sales-representative\",\n \"admin/storefront-permissions.help.category3\": \"Customers\",\n \"admin/storefront-permissions.help.category3.text1\": \"Have access and can manage its own organization.\",\n \"admin/storefront-permissions.help.category3.text2\": \"Customers users can only manage users under the Customers roles.\",\n \"admin/storefront-permissions.help.category3.text3\": \"Customers users hierarchy: customer-amin > customer-approver > customer-buyer\"\n}\n\n```" } ]
code_storefront-permissions-ui_3ff3fff9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/messages/th.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"ข้อมูล B2B\",\n \"admin/storefront-permissions.button.cancel\": \"ยกเลิก\",\n \"admin/storefront-permissions.button.delete\": \"ลบข้อมูล B2B\",\n \"admin/storefront-permissions.button.save\": \"บันทึก\",\n \"admin/storefront-permissions.description\": \"บทบาทและการบริหารจัดการผู้ใช้\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, บทบาท, โปรไฟล์\",\n \"admin/storefront-permissions.navigation.label\": \"สิทธิ์หน้าร้าน\",\n \"admin/storefront-permissions.required\": \"บังคับ\",\n \"admin/storefront-permissions.tab.new.button\": \"ใหม่\",\n \"admin/storefront-permissions.tab.roles\": \"บทบาท\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"ไม่พบว่ามีแอปใดเชือมต่อกับสิทธิ์หน้าร้าน\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"บทบาท\",\n \"admin/storefront-permissions.tab.roles.category.label\": \"Category\",\n \"admin/storefront-permissions.tab.users\": \"ผู้ใช้\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"สามารถเลียนแบบ\",\n \"admin/storefront-permissions.tab.users.email.label\": \"อีเมล\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"องค์กร\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"ศูนย์ต้นทุน\",\n \"admin/storefront-permissions.tab.users.error\": \"มีข้อผิดพลาดขณะบันทึกข้อมูล B2B\",\n \"admin/storefront-permissions.tab.users.name.label\": \"ชื่อ\",\n \"admin/storefront-permissions.tab.users.success\": \"บันทึกข้อมูล B2B แล้ว\",\n \"admin/storefront-permissions.title\": \"สิทธิ์หน้าร้าน\",\n \"admin/storefront-permissions.alert-pick\": \"คุณต้องเลือกศูนย์ต้นทุนก่อนบันทึกการเปลี่ยนแปลง\",\n \"admin/storefront-permissions.searchOrganizations\": \"ค้นหาองค์กร...\",\n \"admin/storefront-permissions.help.title\": \"How it works\",\n \"admin/storefront-permissions.help.text1\": \"Role Names can be renamed, but categories are fixed.\",\n \"admin/storefront-permissions.help.text2\": \"There are three categories available:\",\n \"admin/storefront-permissions.help.category1\": \"Store Admin\",\n \"admin/storefront-permissions.help.category1.text1\": \"Full access\",\n \"admin/storefront-permissions.help.category2\": \"Sales\",\n \"admin/storefront-permissions.help.category2.text1\": \"Can manage quotations, sales, and users from the its Organization.\",\n \"admin/storefront-permissions.help.category2.text2\": \"It can have different access levels.\",\n \"admin/storefront-permissions.help.category2.text3\": \"Can belong to one or many organizations.\",\n \"admin/storefront-permissions.help.category2.text4\": \"Sales users can only manage Sales roles.\",\n \"admin/storefront-permissions.help.category2.text5\": \"Sales user hierarchy: sales-admin > sales-manager > sales-representative\",\n \"admin/storefront-permissions.help.category3\": \"Customers\",\n \"admin/storefront-permissions.help.category3.text1\": \"Have access and can manage its own organization.\",\n \"admin/storefront-permissions.help.category3.text2\": \"Customers users can only manage users under the Customers roles.\",\n \"admin/storefront-permissions.help.category3.text3\": \"Customers users hierarchy: customer-amin > customer-approver > customer-buyer\"\n}\n\n```" } ]
code_storefront-permissions-ui_02c43436
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/messages/es.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/storefront-permissions.b2bInfo.title\": \"Información B2B\",\n \"admin/storefront-permissions.button.cancel\": \"Cancelar\",\n \"admin/storefront-permissions.button.delete\": \"Eliminar información B2B\",\n \"admin/storefront-permissions.button.save\": \"Guardar\",\n \"admin/storefront-permissions.description\": \"Gestión de roles y usuarios\",\n \"admin/storefront-permissions.navigation.keywords\": \"B2B, roles, perfiles\",\n \"admin/storefront-permissions.navigation.label\": \"Permisos del storefront\",\n \"admin/storefront-permissions.required\": \"Obligatorio\",\n \"admin/storefront-permissions.tab.new.button\": \"Nuevo\",\n \"admin/storefront-permissions.tab.roles\": \"Roles\",\n \"admin/storefront-permissions.tab.roles.featuresNotFound\": \"No pudo encontrar ninguna aplicación conectada a los permisos del storefront\",\n \"admin/storefront-permissions.tab.roles.name.label\": \"Rol\",\n \"admin/storefront-permissions.tab.roles.category.label\": \"Category\",\n \"admin/storefront-permissions.tab.users\": \"Usuarios\",\n \"admin/storefront-permissions.tab.users.canImpersonate.label\": \"Puede suplantar\",\n \"admin/storefront-permissions.tab.users.email.label\": \"Email\",\n \"admin/storefront-permissions.tab.users.organization.label\": \"Organización\",\n \"admin/storefront-permissions.tab.users.costCenter.label\": \"Centro de costos\",\n \"admin/storefront-permissions.tab.users.error\": \"Error al guardar información B2B\",\n \"admin/storefront-permissions.tab.users.name.label\": \"Nombre\",\n \"admin/storefront-permissions.tab.users.success\": \"Información B2B guardada\",\n \"admin/storefront-permissions.title\": \"Permisos del storefront\",\n \"admin/storefront-permissions.alert-pick\": \"Debes elegir un centro de costos antes de guardar los cambios\",\n \"admin/storefront-permissions.searchOrganizations\": \"Buscar organizaciones...\",\n \"admin/storefront-permissions.help.title\": \"How it works\",\n \"admin/storefront-permissions.help.text1\": \"Role Names can be renamed, but categories are fixed.\",\n \"admin/storefront-permissions.help.text2\": \"There are three categories available:\",\n \"admin/storefront-permissions.help.category1\": \"Store Admin\",\n \"admin/storefront-permissions.help.category1.text1\": \"Full access\",\n \"admin/storefront-permissions.help.category2\": \"Sales\",\n \"admin/storefront-permissions.help.category2.text1\": \"Can manage quotations, sales, and users from the its Organization.\",\n \"admin/storefront-permissions.help.category2.text2\": \"It can have different access levels.\",\n \"admin/storefront-permissions.help.category2.text3\": \"Can belong to one or many organizations.\",\n \"admin/storefront-permissions.help.category2.text4\": \"Sales users can only manage Sales roles.\",\n \"admin/storefront-permissions.help.category2.text5\": \"Sales user hierarchy: sales-admin > sales-manager > sales-representative\",\n \"admin/storefront-permissions.help.category3\": \"Customers\",\n \"admin/storefront-permissions.help.category3.text1\": \"Have access and can manage its own organization.\",\n \"admin/storefront-permissions.help.category3.text2\": \"Customers users can only manage users under the Customers roles.\",\n \"admin/storefront-permissions.help.category3.text3\": \"Customers users hierarchy: customer-amin > customer-approver > customer-buyer\"\n}\n\n```" } ]
code_storefront-permissions-ui_26dd1799
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/admin/navigation.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"section\": \"accountSettings\",\n \"path\": \"/admin/storefront-permissions/roles/list\",\n \"icon\": \"extensions-ic\",\n \"titleId\": \"admin/storefront-permissions.navigation.label\",\n \"searchKeyWordsHelpers\": \"admin/storefront-permissions.navigation.keywords\"\n}\n\n```" } ]
code_storefront-permissions-ui_36db99a2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/admin/routes.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin.app.storefront-permissions\": {\n \"around\": [\"layout\"],\n \"path\": \"/admin/app/storefront-permissions/*\"\n },\n \"admin.app.storefront-permissions.users-list\": {\n \"component\": \"userList\",\n \"path\": \"/admin/app/storefront-permissions/user/list\"\n },\n \"admin.app.storefront-permissions.users-new\": {\n \"component\": \"userNew\",\n \"path\": \"/admin/app/storefront-permissions/user/new\"\n },\n \"admin.app.storefront-permissions.users-edit\": {\n \"component\": \"userEdit\",\n \"path\": \"/admin/app/storefront-permissions/user/*id\"\n },\n \"admin.app.storefront-permissions.roles-list\": {\n \"component\": \"rolesList\",\n \"path\": \"/admin/app/storefront-permissions/roles/list\"\n },\n \"admin.app.storefront-permissions.roles-new\": {\n \"component\": \"roleNew\",\n \"path\": \"/admin/app/storefront-permissions/role/new\"\n },\n \"admin.app.storefront-permissions.roles-edit\": {\n \"component\": \"roleEdit\",\n \"path\": \"/admin/app/storefront-permissions/role/*id\"\n },\n \"layout\": {\n \"component\": \"index\"\n }\n}\n\n```" } ]
code_storefront-permissions-ui_bd233266
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/docs/README.md from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Storefront Permissions UI\n\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n\n[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)\n\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\n**Storefront Permissions UI** provides an interface for the [Storefront Permissions](https://developers.vtex.com/vtex-developer-docs/docs/vtex-storefront-permissions) app, which is part of VTEX’s [B2B Suite](https://developers.vtex.com/vtex-developer-docs/docs/vtex-b2b-suite) solution, a collection of apps that allow stores to manage organizations, storefront roles and permissions, and checkout settings for B2B commerce relationships. \n\nB2B customers often play distinct roles within their organization, such as professional buyer, manager, or supervisor. Each role is associated with a different set of permissions, depending on the actions the user needs to perform.\n\nThis app communicates with the backstage **Storefront Permissions** app and provides the following features for this scenario:\n\n* [Roles management](#roles-management): allow VTEX Admin users to manage B2B roles and associated app permissions through an interface.\n* [Theme blocks configuration](#theme-blocks-configuration): enable conditional theme blocks so that only users with the required permissions can access determined parts of the content in your storefront.\n\nWe recommend that you use it alongside the other apps in the [B2B Suite](https://developers.vtex.com/vtex-developer-docs/docs/vtex-b2b-suite) for all functionalities to work as expected.\n\n\n## Before you start\n\nMake sure you have the [VTEX IO CLI (Command Line Interface)](https://developers.vtex.com/vtex-developer-docs/docs/vtex-io-documentation-vtex-io-cli-install) installed in your machine.\n\n\n## Installation\n\nYou can install the app by running `vtex install vtex.storefront-permissions-ui` in your terminal, using the [VTEX IO CLI](https://developers.vtex.com/vtex-developer-docs/docs/vtex-io-documentation-vtex-io-cli-installation-and-command-reference).\n\nAfter this command, the app will be installed in your VTEX Admin, and you can access it on **Apps** > **Storefront Permissions**.\n\n> ℹ Installing **Storefront Permissions UI** has the effect of automatically installing the [Storefront Permissions](https://developers.vtex.com/vtex-developer-docs/docs/vtex-storefront-permissions) app as a dependency, in case it is not already installed.\n\n## Roles management\n\nTo manage roles and their respective app permissions using the Storefront Permissions UI, follow the steps below after installing the app.\n\n1. At the VTEX Admin, navigate to **Apps** > **Storefront Permissions**.\n2. Click on one of the [available storefront roles](#available-storefront-roles).\n3. Click on one of the listed apps.\n\n > ℹ Only apps that are integrated with **Storefront Permissions** will be on the list – check our [Storefront Permissions](https://developers.vtex.com/vtex-developer-docs/docs/vtex-storefront-permissions#advanced-app-integration-optional) documentation for more information.\n\n4. Select which permissions you want to enable for the role, as illustrated below.\n5. Once you are done, click on `Save`.\n\n![storefront-permissions-ui](https://raw.githubusercontent.com/vtex-apps/storefront-permissions-ui/master/docs/images/storefront-en.gif)\n\nAfter associating roles with the desired permissions, you may then assign roles to users. To learn more about this, read our [B2B Organizations documentation](https://developers.vtex.com/vtex-developer-docs/docs/vtex-b2b-organizations#users).\n\n\n### Available storefront roles\n\nIn the following table, you can see the available storefront roles, their key used for identification in the app’s code, and their description.\n\n\n| **Role** | **Key** | **Description** |\n|---|---|---|\n| Store Admin | `store-admin` | Store administrator, that is, a user who has access to the VTEX Admin. |\n| Sales Admin | `sales-admin` | Sales administrator user who can manage all sales users. |\n| Sales Manager | `sales-manager` | Sales manager user who can manage sales users in the same organization, as well as assist or impersonate buyers during navigation or purchase. |\n| Sales Representative | `sales-representative` | Sales representative user who can assist or impersonate buyers in the same cost center during navigation or purchase. |\n| Organization Admin | `customer-admin` | Main organization user who manages the organization information, as well as its members and cost centers. |\n| Organization Approver | `customer-approver` | Organization user who can take a saved cart or quote that was created by an **Organization Buyer** and use it to place an order. |\n| Organization Buyer | `customer-buyer` | Organization user who has the ability to add items to cart. If the **B2B Quotes** app is installed, they are also able to save their cart for future use or create a quote. |\n\n\n## Theme blocks configuration\n\nIf you only want users with roles that have the required permissions to be able to access determined parts of the content in your storefront, you can also configure conditional blocks in your store’s theme. These types of blocks allow you to validate information in order to display or hide content in your storefront.\n\nIn case you need more information on how to start building your own theme, read our [documentation](https://developers.vtex.com/vtex-developer-docs/docs/vtex-io-documentation-1-basicsetup) before you proceed.\n\nIf you are experienced in developing and customizing your store’s theme, follow the steps below to declare the conditional blocks enabled by **Storefront Permissions UI**.\n\n1. Open your store theme app’s repository in your local files.\n2. In the `manifest.json` file, under `dependencies`, add `\"vtex.storefront-permissions-ui\": \"1.x\"`, like in the example below.\n\n ```json\n \"dependencies\": {\n \"vtex.storefront-permissions-ui\": \"1.x\"\n },\n ```\n\n3. Now, you can use the `check-permission`, `allowed-content` and `disallowed-content` blocks on any files you want in your store’s theme. See more information on these blocks below.\n\n | **Block name** | **Description** | |\n |---|---|---|\n | `check-permission` | Checks if the current user has the required permissions to access the content wrapped with this block.<br>You can wrap content blocks with check-permission when declaring them to validate if the user has the required permissions to see that content. Example: `check-permission#carousel` | |\n | `allowed-content` | Allows you to define on children blocks the content that will be shown for allowed users – users with roles that have the required permissions to view the block. | |\n | `disallowed-content` | Optional block that allows you to define on children blocks the content that will be shown for disallowed users – users with roles that do not have the required permissions to view the block. | |\n | `loading-content` | Optional block that allows you to define a loading content while permissions are loading. | |\n \n\n This component will check if the user has permission to see the `allowed-content`, otherwise they will see the `disallowed-content`.\n \n The `check-permission` block has a prop named `roles`, which lets you define an array of roles that are allowed to see the blocks defined under the children blocks of `allowed-content`.\n \n | **Prop name** | **Type** | **Description** | **Required** | **Example** |\n |---|---|---|---|---|\n | `roles` | array of strings | List of the allowed roles, identified by their key. Learn more about each role and its key in the [Available storefront roles](#available-storefront-roles) section. | true | `[\"store-admin\", \"sales-admin\"]` |\n\n\n#### Example\n\nIn the example below, in a store’s home, a carousel with banners will only be visible to logged in users with the `store-admin` or `sales-admin` roles. Users with other roles will see a warning message (`**You don't have access to this content**`) instead.\n\n```diff\n{\n \"store.home\": {\n \"blocks\": [\n+ \"check-permission#carousel\",\n \"shelf#home\",\n \"info-card#home\",\n \"rich-text#question\",\n \"rich-text#link\"\n ]\n },\n+ \"check-permission#carousel\": {\n+ \"props\": {\n+ \"roles\": [\"store-admin\", \"sales-admin\"]\n+ },\n+ \"blocks\": [\"allowed-content#carousel\",\"disallowed-content#carousel\", \"loading-content#carousel\"]\n+ },\n+ \"allowed-content#carousel\": {\n+ \"children\": [\"carousel#home\"]\n+ },\n+ \"disallowed-content#carousel\": {\n+ \"children\": [\"rich-text#disallowed\"]\n+ },\n+ \"loading-content#carousel\": {\n+ \"children\": [\"rich-text#loading\"]\n+ },\n+ \"rich-text#disallowed\": {\n+ \"props\": {\n+ \"text\": \"**You don't have access to this content**\"\n+ }\n+ },\n+ \"rich-text#loading\": {\n+ \"props\": {\n+ \"text\": \"Waiting for permissions...\"\n+ }\n+ },\n \"carousel#home\": {\n \"props\": {\n \"autoPlay\": false,\n \"banners\": [\n {\n \"image\": \"https://storecomponents.vteximg.com.br/arquivos/banner-principal.png\",\n \"mobileImage\": \"https://storecomponents.vteximg.com.br/arquivos/banner-principal-mobile.jpg\"\n },\n {\n \"image\": \"https://storecomponents.vteximg.com.br/arquivos/banner.jpg\",\n \"mobileImage\": \"https://storecomponents.vteximg.com.br/arquivos/banner-principal-mobile.jpg\"\n }\n ],\n \"height\": 720,\n \"showArrows\": true,\n \"showDots\": true\n }\n },\n```\n\n```" } ]
code_storefront-permissions-ui_d44ef27d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/index.tsx from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { FC } from 'react'\nimport React, { useState } from 'react'\nimport type { WrappedComponentProps } from 'react-intl'\nimport { FormattedMessage, injectIntl } from 'react-intl'\nimport { useQuery } from 'react-apollo'\nimport { Layout, PageBlock, PageHeader } from 'vtex.styleguide'\n\nimport GET_CONFIG from './queries/getAppSettings.gql'\n\nconst AdminB2bWaffle: FC<WrappedComponentProps> = (props) => {\n const [state, setState] = useState<any>({\n missingConfig: true,\n })\n\n useQuery(GET_CONFIG, {\n onCompleted: (res: any) => {\n setState({\n ...state,\n missingConfig: res.getAppSettings,\n })\n },\n })\n\n return (\n <Layout\n pageHeader={\n <PageHeader\n title={<FormattedMessage id=\"admin/storefront-permissions.title\" />}\n subtitle={\n <FormattedMessage id=\"admin/storefront-permissions.description\" />\n }\n />\n }\n >\n <PageBlock>\n <>{props.children}</>\n </PageBlock>\n </Layout>\n )\n}\n\nexport default injectIntl(AdminB2bWaffle)\n\n```" } ]
code_storefront-permissions-ui_ab1c5e0f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/userEdit.tsx from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport UserEdit from './components/userEdit'\n\nexport default UserEdit\n\n```" } ]
code_storefront-permissions-ui_bd0d0d27
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/rolesList.tsx from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport Roles from './components/rolesList'\n\nexport default Roles\n\n```" } ]
code_storefront-permissions-ui_21eb9199
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/roleEdit.tsx from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport RoleEdit from './components/roleEdit'\n\nexport default RoleEdit\n\n```" } ]
code_storefront-permissions-ui_dee79fca
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/CheckOrganizationPermission.tsx from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport type { ElementType } from 'react'\nimport { ExtensionPoint } from 'vtex.render-runtime'\nimport { useQuery } from 'react-apollo'\n\nimport getOrganizationPermissions from './queries/getOrganizationPermissions.gql'\n\ntype OrganizationRole = 'createQuote'\n\ninterface Props {\n roles: OrganizationRole[]\n AllowedContent?: ElementType\n DisallowedContent?: ElementType\n LoadingContent?: ElementType\n}\n\nfunction CheckOrganizationPermission({\n roles = [],\n AllowedContent,\n DisallowedContent,\n LoadingContent,\n}: Props) {\n const { data, called, error, loading } = useQuery(\n getOrganizationPermissions,\n {\n ssr: false,\n skip: !roles.length,\n onCompleted(insideData) {\n if (insideData?.getOrganizationByIdStorefront?.permissions) {\n sessionStorage.setItem(\n 'checkout.createQuote',\n JSON.stringify(\n insideData?.getOrganizationByIdStorefront?.permissions.createQuote\n )\n )\n }\n },\n }\n )\n\n if (error) {\n console.error('CheckOrganizationPermission component error:', error)\n\n return null\n }\n\n if (called && loading) {\n return LoadingContent ? (\n <LoadingContent />\n ) : (\n <ExtensionPoint id=\"loading-content\" />\n )\n }\n\n if (!roles.length || !data) {\n return null\n }\n\n const hasPermission = roles.every(\n (key) => data.getOrganizationByIdStorefront.permissions[key] === true\n )\n\n if (hasPermission) {\n return AllowedContent ? (\n <AllowedContent />\n ) : (\n <ExtensionPoint id=\"allowed-content\" />\n )\n }\n\n return DisallowedContent ? (\n <DisallowedContent />\n ) : (\n <ExtensionPoint id=\"disallowed-content\" />\n )\n}\n\nexport default CheckOrganizationPermission\n\n```" } ]
code_storefront-permissions-ui_cb76da1b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/BlockContent.tsx from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport type { PropsWithChildren } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\nimport type { CssHandlesTypes } from 'vtex.css-handles'\n\nconst CSS_HANDLES = ['checkPermissionsBlock'] as const\n\ninterface Props {\n classes?: CssHandlesTypes.CustomClasses<typeof CSS_HANDLES>\n}\n\nfunction BlockContent({ children, classes }: PropsWithChildren<Props>) {\n const { handles } = useCssHandles(CSS_HANDLES, { classes })\n\n return <div className={`${handles.checkPermissionsBlock}`}>{children}</div>\n}\n\nexport default BlockContent\n\n```" } ]
code_storefront-permissions-ui_b8f9b823
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/roleNew.tsx from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport RoleNew from './components/roleNew'\n\nexport default RoleNew\n\n```" } ]
code_storefront-permissions-ui_fadaafe3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/package.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtexus.storefront-permissions\",\n \"version\": \"3.0.1\",\n \"scripts\": {\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n },\n \"devDependencies\": {\n \"@types/faker\": \"^4.1.5\",\n \"@types/node\": \"^11.12.1\",\n \"@types/react\": \"^16.8.10\",\n \"apollo-client\": \"^2.4.7\",\n \"graphql\": \"^14.0.2\",\n \"prop-types\": \"^15.7.2\",\n \"react\": \"^16.8.6\",\n \"react-dom\": \"^16.8.6\",\n \"typescript\": \"3.9.7\",\n \"vtex.admin-customers-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.admin-customers-graphql@3.0.2/public/@types/vtex.admin-customers-graphql\",\n \"vtex.css-handles\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.css-handles@1.0.0/public/@types/vtex.css-handles\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.132.4/public/@types/vtex.render-runtime\",\n \"vtex.store\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store@2.131.1/public/@types/vtex.store\",\n \"vtex.storefront-permissions\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.storefront-permissions@1.34.1/public/@types/vtex.storefront-permissions\",\n \"vtex.storefront-permissions-ui\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.storefront-permissions-ui@1.1.0/public/@types/vtex.storefront-permissions-ui\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.146.4/public/@types/vtex.styleguide\"\n },\n \"dependencies\": {\n \"faker\": \"^4.1.0\",\n \"react-apollo\": \"^3.1.5\",\n \"react-intl\": \"^5.24.6\"\n }\n}\n\n```" } ]
code_storefront-permissions-ui_e074c24c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/userNew.tsx from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport UserNew from './components/userNew'\n\nexport default UserNew\n\n```" } ]
code_storefront-permissions-ui_34f590f8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/userList.tsx from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport Users from './components/usersList'\n\nexport default Users\n\n```" } ]
code_storefront-permissions-ui_c6e068d2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/CheckPermission.tsx from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport type { ElementType } from 'react'\nimport { ExtensionPoint } from 'vtex.render-runtime'\nimport { useQuery } from 'react-apollo'\n\nimport getPermissions from './queries/permissions.gql'\n\ninterface Props {\n roles: string[]\n AllowedContent?: ElementType\n DisallowedContent?: ElementType\n LoadingContent?: ElementType\n}\n\nfunction CheckPermission({\n roles = [],\n AllowedContent,\n DisallowedContent,\n LoadingContent,\n}: Props) {\n const { data, called, error, loading } = useQuery(getPermissions, {\n ssr: false,\n skip: !roles.length,\n })\n\n if (error) {\n console.error('CheckPermission error:', error)\n\n return null\n }\n\n if (called && loading) {\n return LoadingContent ? (\n <LoadingContent />\n ) : (\n <ExtensionPoint id=\"loading-content\" />\n )\n }\n\n if (!roles.length || !data) {\n return null\n }\n\n const hasPermission = roles?.length\n ? roles.indexOf(data?.checkUserPermission?.role?.slug) !== -1\n : false\n\n if (hasPermission) {\n return AllowedContent ? (\n <AllowedContent />\n ) : (\n <ExtensionPoint id=\"allowed-content\" />\n )\n }\n\n return DisallowedContent ? (\n <DisallowedContent />\n ) : (\n <ExtensionPoint id=\"disallowed-content\" />\n )\n}\n\nexport default CheckPermission\n\n```" } ]
code_storefront-permissions-ui_d84c7955
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/store/interfaces.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"check-organization-permission\": {\n \"component\": \"CheckOrganizationPermission\",\n \"allowed\": [\"allowed-content\", \"disallowed-content\", \"loading-content\"]\n },\n \"check-permission\": {\n \"component\": \"CheckPermission\",\n \"allowed\": [\"allowed-content\", \"disallowed-content\", \"loading-content\"]\n },\n \"allowed-content\": {\n \"component\": \"BlockContent\",\n \"composition\": \"children\",\n \"allowed\": \"*\"\n },\n \"disallowed-content\": {\n \"component\": \"BlockContent\",\n \"composition\": \"children\",\n \"allowed\": \"*\"\n },\n \"loading-content\": {\n \"component\": \"BlockContent\",\n \"composition\": \"children\",\n \"allowed\": \"*\"\n }\n}\n\n```" } ]
code_storefront-permissions-ui_85766df8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/public/metadata/messages/es-AR.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"B2B Admin\",\n \"headline\": \"B2B Admin\",\n \"overview\": \"B2B Admin\",\n \"features\": [\"B2B Admin\"],\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_storefront-permissions-ui_8c3f0e01
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/public/metadata/messages/pt-BR.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"B2B Admin\",\n \"headline\": \"B2B Admin\",\n \"overview\": \"B2B Admin\",\n \"features\": [\"B2B Admin\"],\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_storefront-permissions-ui_dd5a9f01
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/public/metadata/messages/en-US.json from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"B2B Admin\",\n \"headline\": \"B2B Admin\",\n \"overview\": \"B2B Admin\",\n \"features\": [\"B2B Admin\"],\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_storefront-permissions-ui_7754eb56
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/mutations/deleteUser.gql from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation delete($id: ID!, $email: String!, $userId: ID) {\n deleteUser(id: $id, email: $email, userId: $userId)\n @context(provider: \"vtex.storefront-permissions\") {\n status\n message\n }\n}\n\n```" } ]
code_storefront-permissions-ui_e7886d94
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/mutations/deleteRole.gql from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation delete($id: ID!) {\n deleteRole(id: $id) @context(provider: \"vtex.storefront-permissions\") {\n status\n message\n }\n}\n\n```" } ]
code_storefront-permissions-ui_b5eefabc
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/mutations/saveRole.gql from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation save(\n $id: ID\n $name: String!\n $slug: String\n $features: [FeatureInput]!\n) {\n saveRole(id: $id, name: $name, slug: $slug, features: $features)\n @context(provider: \"vtex.storefront-permissions\") {\n id\n status\n message\n }\n}\n\n```" } ]
code_storefront-permissions-ui_03da715e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/mutations/saveUser.gql from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation save(\n $id: ID\n $roleId: ID!\n $userId: ID!\n $canImpersonate: Boolean\n $name: String!\n $email: String!\n) {\n saveUser(\n id: $id\n roleId: $roleId\n userId: $userId\n canImpersonate: $canImpersonate\n name: $name\n email: $email\n ) @context(provider: \"vtex.storefront-permissions\") {\n id\n status\n message\n }\n}\n\n```" } ]
code_storefront-permissions-ui_65c1531e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/mutations/saveConfiguration.gql from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation save(\n $accountID: String\n $clientID: String\n $clientSecret: String\n $refreshToken: String\n $submit: Boolean\n) {\n saveAppSettings(\n accountID: $accountID\n clientID: $clientID\n clientSecret: $clientSecret\n refreshToken: $refreshToken\n submit: $submit\n ) @context(provider: \"vtex.storefront-permissions\") {\n status\n message\n }\n}\n\n```" } ]
code_storefront-permissions-ui_7489fd84
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/typings/graphql.d.ts from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.graphql' {\n import type { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\ndeclare module '*.gql' {\n const gql: any\n export default gql\n}\n\n```" } ]
code_storefront-permissions-ui_43db8d10
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/queries/getOrganizationPermissions.gql from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery GetOrganizationStorefront($id: ID) {\n getOrganizationByIdStorefront(id: $id)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n permissions {\n createQuote\n }\n }\n}\n\n```" } ]
code_storefront-permissions-ui_86db4e4a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/queries/ListUsers.gql from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery ListUsers {\n listUsers @context(provider: \"vtex.storefront-permissions\") {\n id\n roleId\n userId\n clId\n name\n email\n canImpersonate\n }\n}\n\n```" } ]
code_storefront-permissions-ui_173d6c0d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/queries/getUser.gql from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery GetUser($id: ID!) {\n getUser(id: $id) @context(provider: \"vtex.storefront-permissions\") {\n id\n roleId\n userId\n name\n email\n canImpersonate\n }\n}\n\n```" } ]
code_storefront-permissions-ui_b68a3983
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/queries/getRole.gql from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery GetRole($id: ID!) {\n getRole(id: $id) @context(provider: \"vtex.storefront-permissions\") {\n id\n name\n slug\n features {\n module\n features\n }\n }\n}\n\n```" } ]
code_storefront-permissions-ui_7c7dcd02
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/queries/ListFeatures.gql from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery ListFeatures {\n listFeatures @context(provider: \"vtex.storefront-permissions\") {\n module\n name\n features {\n label\n value\n }\n }\n}\n\n```" } ]
code_storefront-permissions-ui_aad48639
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/queries/permissions.gql from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery permissions {\n checkUserPermission @context(provider: \"vtex.storefront-permissions\") {\n role {\n id\n name\n slug\n }\n permissions\n }\n}\n\n```" } ]
code_storefront-permissions-ui_428ab937
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/queries/ListProfiles.gql from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery ListProfiles {\n listProfiles @context(provider: \"vtex.storefront-permissions\") {\n id\n name\n features {\n module\n features\n }\n roleId\n }\n}\n\n```" } ]
code_storefront-permissions-ui_d889d3a3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/queries/SearchUsers.gql from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery SearchUsers($perPage: Int!, $pageNumber: Int!, $filter: String) {\n users(perPage: $perPage, pageNumber: $pageNumber, filter: $filter)\n @context(provider: \"vtex.admin-customers-graphql\") {\n data {\n id\n email\n firstName\n lastName\n gender\n userId\n document\n documentType\n birthDate\n corporateName\n isCorporate\n corporateDocument\n corporateName\n phone\n homePhone\n businessPhone\n isNewsletterOptIn\n stateRegistration\n }\n pagination {\n page\n pageSize\n total\n }\n }\n}\n\n```" } ]
code_storefront-permissions-ui_fb47b38d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/queries/ListRoles.gql from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery ListRoles {\n listRoles @context(provider: \"vtex.storefront-permissions\") {\n id\n name\n slug\n }\n}\n\n```" } ]
code_storefront-permissions-ui_95630dc5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/queries/getAppSettings.gql from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery GetAppSettings {\n getAppSettings @context(provider: \"vtex.storefront-permissions\") {\n adminSetup\n }\n}\n\n```" } ]
code_storefront-permissions-ui_ccb46363
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/components/userEdit.tsx from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { FC } from 'react'\nimport React from 'react'\nimport { injectIntl } from 'react-intl'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { StorefrontPermissions } from 'vtex.storefront-permissions'\n\nconst UserEdit: FC = () => {\n const { navigate, route } = useRuntime()\n\n const redirect = () => {\n navigate({\n page: 'admin.app.storefront-permissions.users-list',\n fetchPage: true,\n })\n }\n\n return (\n <>\n <StorefrontPermissions\n id={route.params.id}\n showName={true}\n showEmail={true}\n showCancel={true}\n onCancel={redirect}\n onSave={redirect}\n />\n </>\n )\n}\n\nexport default injectIntl(UserEdit)\n\n```" } ]
code_storefront-permissions-ui_f95d5d9c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/components/rolesList.tsx from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { FC } from 'react'\nimport React, { useState } from 'react'\nimport type { WrappedComponentProps } from 'react-intl'\nimport { injectIntl, defineMessages } from 'react-intl'\nimport { useQuery } from 'react-apollo'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { Table, Card } from 'vtex.styleguide'\n\nimport QUERY_LIST_ROLES from '../queries/ListRoles.gql'\n\nconst messages = defineMessages({\n name: {\n id: 'admin/storefront-permissions.tab.roles.name.label',\n defaultMessage: 'Name',\n },\n slug: {\n id: 'admin/storefront-permissions.tab.roles.category.label',\n defaultMessage: 'Category',\n },\n new: {\n id: 'admin/storefront-permissions.tab.new.button',\n defaultMessage: 'New',\n },\n delete: {\n id: 'admin/storefront-permissions.button.delete',\n defaultMessage: 'Delete',\n },\n helpTitle: {\n id: 'admin/storefront-permissions.help.title',\n defaultMessage: 'How it works',\n },\n helpText1: {\n id: 'admin/storefront-permissions.help.text1',\n defaultMessage: 'Role Names can be renamed, but categories are fixed.',\n },\n helpText2: {\n id: 'admin/storefront-permissions.help.text2',\n defaultMessage: 'There are three categories available:',\n },\n category1: {\n id: 'admin/storefront-permissions.help.category1',\n defaultMessage: 'Store Admin',\n },\n category1Text1: {\n id: 'admin/storefront-permissions.help.category1.text1',\n defaultMessage: 'Full access',\n },\n category2: {\n id: 'admin/storefront-permissions.help.category2',\n defaultMessage: 'Sales',\n },\n category2Text1: {\n id: 'admin/storefront-permissions.help.category2.text1',\n defaultMessage:\n 'Can manage quotations, sales, and users from the its Organization.',\n },\n category2Text2: {\n id: 'admin/storefront-permissions.help.category2.text2',\n defaultMessage: 'It can have different access levels.',\n },\n category2Text3: {\n id: 'admin/storefront-permissions.help.category2.text3',\n defaultMessage: 'Can belong to one or many organizations.',\n },\n category2Text4: {\n id: 'admin/storefront-permissions.help.category2.text4',\n defaultMessage: 'Sales users can only manage Sales roles.',\n },\n category2Text5: {\n id: 'admin/storefront-permissions.help.category2.text5',\n defaultMessage:\n 'Sales user hierarchy: sales-admin > sales-manager > sales-representative',\n },\n category3: {\n id: 'admin/storefront-permissions.help.category3',\n defaultMessage: 'Customers',\n },\n category3Text1: {\n id: 'admin/storefront-permissions.help.category3.text1',\n defaultMessage: 'Have access and can manage its own organization.',\n },\n category3Text2: {\n id: 'admin/storefront-permissions.help.category3.text2',\n defaultMessage:\n 'Customers users can only manage users under the Customers roles.',\n },\n category3Text3: {\n id: 'admin/storefront-permissions.help.category3.text3',\n defaultMessage:\n 'Customers users hierarchy: customer-amin > customer-approver > customer-buyer',\n },\n})\n\nconst Roles: FC<any & WrappedComponentProps> = ({ intl }: any) => {\n const [state, setState] = useState({\n items: [],\n })\n\n const { loading, data } = useQuery(QUERY_LIST_ROLES)\n\n const { navigate, route } = useRuntime()\n\n const { params } = route\n\n const { items } = state\n\n const customSchema = {\n properties: {\n name: {\n title: intl.formatMessage(messages.name),\n },\n slug: {\n title: intl.formatMessage(messages.slug),\n },\n },\n }\n\n if (data?.listRoles && !state.items.length) {\n const newItems: any = data?.listRoles\n\n if (\n params?.id &&\n !newItems.filter((item: any) => {\n return item.id === params.id\n }).length\n ) {\n newItems.push(params)\n }\n\n setState({\n ...state,\n items: newItems,\n })\n }\n\n return (\n <div className=\"w-100 pt6\">\n <Table\n fullWidth\n loading={loading}\n schema={customSchema}\n items={items}\n onRowClick={({ rowData: { id } }: any) => {\n navigate({\n page: 'admin.app.storefront-permissions.roles-edit',\n params: {\n id,\n },\n })\n }}\n />\n <div className=\"mt6\">\n <Card>\n <h3>{intl.formatMessage(messages.helpTitle)}</h3>\n <p>{intl.formatMessage(messages.helpText1)}</p>\n <p>\n {intl.formatMessage(messages.helpText2)}\n <ul>\n <li>\n <strong>{intl.formatMessage(messages.category1)}</strong>:{' '}\n {intl.formatMessage(messages.category1Text1)}\n </li>\n <li>\n <strong>{intl.formatMessage(messages.category2)}</strong>:\n <ul>\n <li>{intl.formatMessage(messages.category2Text1)}</li>\n <li>{intl.formatMessage(messages.category2Text2)}</li>\n <li>{intl.formatMessage(messages.category2Text3)}</li>\n <li>{intl.formatMessage(messages.category2Text4)}</li>\n <li>{intl.formatMessage(messages.category2Text5)}</li>\n </ul>\n </li>\n <li>\n <strong>{intl.formatMessage(messages.category3)}</strong>:\n <ul>\n <li>{intl.formatMessage(messages.category3Text1)}</li>\n <li>{intl.formatMessage(messages.category3Text2)}</li>\n <li>{intl.formatMessage(messages.category3Text3)}</li>\n </ul>\n </li>\n </ul>\n </p>\n </Card>\n </div>\n </div>\n )\n}\n\nexport default injectIntl(Roles)\n\n```" } ]
code_storefront-permissions-ui_5c7ed20a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/components/roleEdit.tsx from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { FC } from 'react'\nimport React, { useState } from 'react'\nimport type { WrappedComponentProps } from 'react-intl'\nimport { injectIntl, defineMessages } from 'react-intl'\nimport { useQuery, useMutation } from 'react-apollo'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { Input, Button, Divider, Checkbox, Collapsible } from 'vtex.styleguide'\n\nimport GET_FEATURES from '../queries/ListFeatures.gql'\nimport SAVE_ROLE from '../mutations/saveRole.gql'\nimport GET_ROLE from '../queries/getRole.gql'\n\nconst messages = defineMessages({\n name: {\n id: 'admin/storefront-permissions.tab.roles.name.label',\n defaultMessage: 'Role',\n },\n required: {\n id: 'admin/storefront-permissions.required',\n defaultMessage: 'Required',\n },\n cancel: {\n id: 'admin/storefront-permissions.button.cancel',\n defaultMessage: 'Cancel',\n },\n save: {\n id: 'admin/storefront-permissions.button.save',\n defaultMessage: 'Save',\n },\n notFound: {\n id: 'admin/storefront-permissions.tab.roles.featuresNotFound',\n defaultMessage:\n \"Could't find any apps connected to the Storefront Permissions\",\n },\n})\n\nconst RoleNew: FC<any & WrappedComponentProps> = ({ intl }: any) => {\n const { navigate, route } = useRuntime()\n const [state, setState] = useState<any>({\n id: null,\n name: null,\n slug: null,\n features: [],\n toggle: {},\n })\n\n const { id, name, features, toggle, slug } = state\n const {\n loading: loadingFeatures,\n data: dataFeatures,\n called: calledFeatures,\n } = useQuery(GET_FEATURES)\n\n const { loading } = useQuery(GET_ROLE, {\n skip: !route?.params?.id,\n variables: {\n id: route?.params?.id,\n },\n fetchPolicy: 'network-only',\n onCompleted: (res: any) => {\n setState({\n ...state,\n ...res.getRole,\n })\n },\n })\n\n const [saveRole, { loading: saveRoleLoading }] = useMutation(SAVE_ROLE, {\n onCompleted: (res: any) => {\n navigate({\n page: 'admin.app.storefront-permissions.roles-list',\n fetchPage: true,\n params: {\n id: res.saveRole.id,\n name,\n },\n })\n },\n })\n\n const handleSaveRole = () => {\n saveRole({\n variables: {\n id,\n name,\n slug,\n features,\n },\n })\n }\n\n const toggleApp = (app: string) => {\n const newToggle = toggle\n\n newToggle[app] = !toggle[app]\n setState({\n ...state,\n toggle: newToggle,\n })\n }\n\n const handleFeature = (module: string, feature: string) => {\n const newFeatures = features ?? []\n const hasModule = newFeatures.findIndex((item: any) => {\n return item.module === module\n })\n\n if (hasModule !== -1) {\n const hasFeature = newFeatures[hasModule].features.indexOf(feature)\n\n if (hasFeature !== -1) {\n newFeatures[hasModule].features.splice(hasFeature, 1)\n } else {\n newFeatures[hasModule].features.push(feature)\n }\n } else {\n newFeatures.push({\n module,\n features: [feature],\n })\n }\n\n setState({\n ...state,\n features: newFeatures,\n })\n }\n\n const checkChecked = (module: string, feature: string) => {\n if (features) {\n const hasModule = features.findIndex((item: any) => {\n return item.module === module\n })\n\n if (hasModule !== -1) {\n const hasFeature = features[hasModule].features.indexOf(feature)\n\n if (hasFeature !== -1) {\n return true\n }\n }\n }\n\n return false\n }\n\n return (\n <div className=\"w-100 pt6\">\n <div className=\"mb5\">\n <Input\n label={intl.formatMessage(messages.name)}\n value={name}\n errorMessage={\n name === '' ? intl.formatMessage(messages.required) : ''\n }\n disabled={loading || loadingFeatures || saveRoleLoading}\n onChange={(e: any) => {\n setState({ ...state, name: e.target.value })\n }}\n />\n </div>\n\n <div className=\"mb5\">\n {!loadingFeatures &&\n calledFeatures &&\n !dataFeatures?.listFeatures.length && (\n <div>{intl.formatMessage(messages.notFound)}</div>\n )}\n\n {dataFeatures?.listFeatures?.map((app: any) => {\n return (\n <div key={`key-${app.module}`}>\n <Collapsible\n header={\n <div className=\"pv2 hover-c-on-action-secondary\">\n {app.name}\n </div>\n }\n onClick={() => {\n toggleApp(app.module)\n }}\n isOpen={!!toggle[app.module]}\n >\n <div className=\"pb2\">\n {app.features.map((feature: any) => {\n return (\n <div\n key={`option-${app.module}-${feature.value}`}\n className=\"pv2\"\n >\n <Checkbox\n checked={checkChecked(app.module, feature.value)}\n id={`option-${app.module}-${feature.value}`}\n label={feature.label}\n name=\"default-checkbox-group\"\n onChange={() => {\n handleFeature(app.module, feature.value)\n }}\n value={feature.value}\n />\n </div>\n )\n })}\n </div>\n </Collapsible>\n <div className=\"mv2\">\n <Divider orientation=\"horizontal\" />\n </div>\n </div>\n )\n })}\n </div>\n\n <div className=\"mv4 flex justify-between\">\n <Button\n variation=\"tertiary\"\n disabled={loadingFeatures || saveRoleLoading}\n collapseLeft\n onClick={() => {\n navigate({ page: 'admin.app.storefront-permissions.roles-list' })\n }}\n >\n {intl.formatMessage(messages.cancel)}\n </Button>\n <Button\n variation=\"primary\"\n disabled={\n loading || loadingFeatures || saveRoleLoading || !state.name\n }\n collapseRight\n onClick={() => {\n handleSaveRole()\n }}\n >\n {intl.formatMessage(messages.save)}\n </Button>\n </div>\n </div>\n )\n}\n\nexport default injectIntl(RoleNew)\n\n```" } ]
code_storefront-permissions-ui_134d9e47
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/components/roleNew.tsx from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { FC } from 'react'\nimport React, { useState } from 'react'\nimport type { WrappedComponentProps } from 'react-intl'\nimport { injectIntl, defineMessages } from 'react-intl'\nimport { useQuery, useMutation } from 'react-apollo'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { Input, Button, Divider, Checkbox, Collapsible } from 'vtex.styleguide'\n\nimport GET_FEATURES from '../queries/ListFeatures.gql'\nimport SAVE_ROLE from '../mutations/saveRole.gql'\n\nconst messages = defineMessages({\n name: {\n id: 'admin/storefront-permissions.tab.roles.name.label',\n defaultMessage: 'Role',\n },\n required: {\n id: 'admin/storefront-permissions.required',\n defaultMessage: 'Required',\n },\n cancel: {\n id: 'admin/storefront-permissions.button.cancel',\n defaultMessage: 'Cancel',\n },\n save: {\n id: 'admin/storefront-permissions.button.save',\n defaultMessage: 'Save',\n },\n notFound: {\n id: 'admin/storefront-permissions.tab.roles.featuresNotFound',\n defaultMessage:\n \"Could't find any apps connected to the Storefront Permissions\",\n },\n})\n\nconst RoleNew: FC<any & WrappedComponentProps> = ({ intl }) => {\n const { navigate } = useRuntime()\n const [state, setState] = useState<any>({\n name: null,\n features: [],\n toggle: {},\n })\n\n const { name, toggle, features } = state\n const {\n loading: loadingFeatures,\n data: dataFeatures,\n called: calledFeatures,\n } = useQuery(GET_FEATURES)\n\n const [saveRole, { loading: saveRoleLoading }] = useMutation(SAVE_ROLE, {\n onCompleted: (res: any) => {\n navigate({\n page: 'admin.app.storefront-permissions.roles-list',\n fetchPage: true,\n params: {\n id: res.saveRole.id,\n name,\n },\n })\n },\n })\n\n const handleSaveRole = () => {\n saveRole({\n variables: {\n name,\n features,\n },\n })\n }\n\n const toggleApp = (app: string) => {\n const newToggle = toggle\n\n newToggle[app] = !toggle[app]\n setState({\n ...state,\n toggle: newToggle,\n })\n }\n\n const handleFeature = (module: string, feature: string) => {\n const newFeatures = features\n const hasModule = newFeatures.findIndex((item: any) => {\n return item.module === module\n })\n\n if (hasModule !== -1) {\n const hasFeature = newFeatures[hasModule].features.indexOf(feature)\n\n if (hasFeature !== -1) {\n newFeatures[hasModule].features.splice(hasFeature, 1)\n } else {\n newFeatures[hasModule].features.push(feature)\n }\n } else {\n newFeatures.push({\n module,\n features: [feature],\n })\n }\n\n setState({\n ...state,\n features: newFeatures,\n })\n }\n\n const checkChecked = (module: string, feature: string) => {\n const hasModule = features.findIndex((item: any) => {\n return item.module === module\n })\n\n if (hasModule !== -1) {\n const hasFeature = features[hasModule].features.indexOf(feature)\n\n if (hasFeature !== -1) {\n return true\n }\n }\n\n return false\n }\n\n return (\n <div className=\"w-100 pt6\">\n <div className=\"mb5\">\n <Input\n label={intl.formatMessage(messages.name)}\n value={name}\n errorMessage={\n name === '' ? intl.formatMessage(messages.required) : ''\n }\n disabled={loadingFeatures || saveRoleLoading}\n onChange={(e: any) => {\n setState({ ...state, name: e.target.value })\n }}\n />\n </div>\n\n <div className=\"mb5\">\n {!loadingFeatures &&\n calledFeatures &&\n !dataFeatures.listFeatures.length && (\n <div>{intl.formatMessage(messages.notFound)}</div>\n )}\n\n {dataFeatures?.listFeatures?.map((app: any) => {\n return (\n <div key={`key-${app.module}`}>\n <Collapsible\n header={\n <div className=\"pv2 hover-c-on-action-secondary\">\n {app.name}\n </div>\n }\n onClick={() => {\n toggleApp(app.module)\n }}\n isOpen={!!toggle[app.module]}\n >\n <div className=\"pb2\">\n {app.features.map((feature: any) => {\n return (\n <div\n key={`option-${app.module}-${feature.value}`}\n className=\"pv2\"\n >\n <Checkbox\n checked={checkChecked(app.module, feature.value)}\n id={`option-${app.module}-${feature.value}`}\n label={feature.label}\n name=\"default-checkbox-group\"\n onChange={() => {\n handleFeature(app.module, feature.value)\n }}\n value={feature.value}\n />\n </div>\n )\n })}\n </div>\n </Collapsible>\n <div className=\"mv2\">\n <Divider orientation=\"horizontal\" />\n </div>\n </div>\n )\n })}\n </div>\n\n <div className=\"mv4 flex justify-between\">\n <Button\n variation=\"tertiary\"\n disabled={loadingFeatures || saveRoleLoading}\n collapseLeft\n onClick={() => {\n navigate({ page: 'admin.app.storefront-permissions.roles-list' })\n }}\n >\n {intl.formatMessage(messages.cancel)}\n </Button>\n <Button\n variation=\"primary\"\n disabled={loadingFeatures || saveRoleLoading || !state.name}\n collapseRight\n onClick={() => {\n handleSaveRole()\n }}\n >\n {intl.formatMessage(messages.save)}\n </Button>\n </div>\n </div>\n )\n}\n\nexport default injectIntl(RoleNew)\n\n```" } ]
code_storefront-permissions-ui_e4b9d2b6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/components/userNew.tsx from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { FC } from 'react'\nimport React, { useState } from 'react'\nimport type { WrappedComponentProps } from 'react-intl'\nimport { injectIntl, defineMessages } from 'react-intl'\nimport { useQuery, useMutation, useLazyQuery } from 'react-apollo'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { Button, Dropdown, Toggle, AutocompleteInput } from 'vtex.styleguide'\n\nimport GET_ROLES from '../queries/ListRoles.gql'\nimport SEARCH_USERS from '../queries/SearchUsers.gql'\nimport SAVE_USER from '../mutations/saveUser.gql'\n\nconst messages = defineMessages({\n role: {\n id: 'admin/storefront-permissions.tab.roles.name.label',\n defaultMessage: 'Role',\n },\n canImpersonate: {\n id: 'admin/storefront-permissions.tab.users.canImpersonate.label',\n defaultMessage: 'Can impersonate',\n },\n name: {\n id: 'admin/storefront-permissions.tab.users.name.label',\n defaultMessage: 'Name',\n },\n email: {\n id: 'admin/storefront-permissions.tab.users.email.label',\n defaultMessage: 'Email',\n },\n required: {\n id: 'admin/storefront-permissions.required',\n defaultMessage: 'Required',\n },\n cancel: {\n id: 'admin/storefront-permissions.button.cancel',\n defaultMessage: 'Cancel',\n },\n save: {\n id: 'admin/storefront-permissions.button.save',\n defaultMessage: 'Save',\n },\n})\n\nlet _timeout: any = null\n\nconst UserNew: FC<any & WrappedComponentProps> = ({ intl }) => {\n const { navigate } = useRuntime()\n const [state, setState] = useState<any>({\n userId: null,\n roleId: null,\n name: null,\n email: null,\n canImpersonate: false,\n })\n\n const [term, setTerm] = useState('')\n\n const { loading: loadingRoles, data: dataRoles } = useQuery(GET_ROLES)\n const [searchUsers, { loading, data: usersData }] = useLazyQuery(SEARCH_USERS)\n const [saveUser, { loading: saveUserLoading }] = useMutation(SAVE_USER, {\n onCompleted: (res: any) => {\n navigate({\n page: 'admin.app.storefront-permissions.users-list',\n fetchPage: true,\n params: {\n ...state,\n id: res.saveUser.id,\n },\n })\n },\n })\n\n const handleSaveUser = () => {\n saveUser({\n variables: {\n userId: state.userId,\n roleId: state.roleId,\n name: state.name,\n email: state.email,\n canImpersonate: state.canImpersonate,\n },\n })\n }\n\n const options = {\n onSelect: (args: any) => {\n const selectedUser = usersData.users.data.find((user: any) => {\n return user.userId === args.value\n })\n\n const { userId, firstName, lastName, email } = selectedUser\n\n setState({\n ...state,\n userId,\n name: `${firstName} ${lastName}`,\n email,\n })\n },\n loading,\n value: usersData?.users?.data?.length\n ? usersData.users.data.map((user: any) => {\n return {\n value: user.userId,\n label: `${user.firstName} ${user.lastName}<${user.email}>`,\n }\n })\n : [],\n // --- This is what makes the Last Searched Terms work!\n // This can be stored anywhere the dev wants. To be persistent, for example.\n }\n\n const input = {\n onChange: (value: any) => {\n setTerm(value)\n clearTimeout(_timeout)\n _timeout = setTimeout(() => {\n searchUsers({\n variables: {\n perPage: 10,\n pageNumber: 1,\n filter: `(email=*${term}* OR firstName=*${term}* OR lastName=*${term}*)`,\n },\n })\n }, 1000)\n },\n onClear: () => {\n setTerm('')\n setState({\n ...state,\n userId: null,\n name: null,\n email: null,\n })\n },\n placeholder: 'Search user... (e.g.: Ana)',\n value: term,\n }\n\n return (\n <div className=\"w-100 pt6\">\n <div className=\"mb5\">\n <AutocompleteInput input={input} options={options} />\n </div>\n {!!state.userId && (\n <>\n <div className=\"mb5\">{state.name}</div>\n\n <div className=\"mb5\">{state.email}</div>\n <div className=\"mb5\">\n <Dropdown\n label={intl.formatMessage(messages.role)}\n disabled={loadingRoles || saveUserLoading}\n options={\n dataRoles?.listRoles?.map((role: any) => {\n return {\n value: role.id,\n label: role.name,\n }\n }) ?? []\n }\n value={state.roleId}\n onChange={(_: any, v: any) => {\n setState({ ...state, roleId: v })\n }}\n />\n </div>\n\n <div className=\"mb5\">\n <Toggle\n label={intl.formatMessage(messages.canImpersonate)}\n size=\"large\"\n disabled={loadingRoles || saveUserLoading}\n checked={state.canImpersonate}\n onChange={() => {\n setState({ ...state, canImpersonate: !state.canImpersonate })\n }}\n />\n </div>\n </>\n )}\n\n <div className=\"mv4 flex justify-between\">\n <Button\n variation=\"tertiary\"\n disabled={loadingRoles || saveUserLoading}\n collapseLeft\n onClick={() => {\n navigate({ page: 'admin.app.storefront-permissions.users-list' })\n }}\n >\n {intl.formatMessage(messages.cancel)}\n </Button>\n {!!state.userId && (\n <Button\n variation=\"primary\"\n disabled={loadingRoles || saveUserLoading}\n collapseRight\n onClick={() => {\n handleSaveUser()\n }}\n >\n {intl.formatMessage(messages.save)}\n </Button>\n )}\n </div>\n </div>\n )\n}\n\nexport default injectIntl(UserNew)\n\n```" } ]
code_storefront-permissions-ui_2e773153
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of storefront-permissions-ui/react/components/usersList.tsx from the storefront-permissions-ui VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { FC } from 'react'\nimport React, { useState } from 'react'\nimport type { WrappedComponentProps } from 'react-intl'\nimport { injectIntl, defineMessages } from 'react-intl'\nimport { useQuery, useMutation } from 'react-apollo'\nimport { Table } from 'vtex.styleguide'\nimport { useRuntime } from 'vtex.render-runtime'\n\nimport QUERY_LIST_USERS from '../queries/ListUsers.gql'\nimport DELETE_USER from '../mutations/deleteUser.gql'\n\nlet deleteId: any = null\nconst messages = defineMessages({\n email: {\n id: 'admin/storefront-permissions.tab.users.email.label',\n defaultMessage: 'Email',\n },\n name: {\n id: 'admin/storefront-permissions.tab.users.name.label',\n defaultMessage: 'Name',\n },\n new: {\n id: 'admin/storefront-permissions.tab.new.button',\n defaultMessage: 'New',\n },\n delete: {\n id: 'admin/storefront-permissions.button.delete',\n defaultMessage: 'Delete',\n },\n})\n\nconst Users: FC<any & WrappedComponentProps> = ({ intl }: any) => {\n const [state, setState] = useState({\n items: [],\n })\n\n const { loading, data } = useQuery(QUERY_LIST_USERS, {\n fetchPolicy: 'network-only',\n })\n\n const [deleteUser, { loading: deleteLoading }] = useMutation(DELETE_USER, {\n onCompleted: () => {\n setState({\n ...state,\n items: state.items.filter((item: any) => {\n return item.id !== deleteId\n }),\n })\n deleteId = null\n },\n })\n\n const { navigate, route } = useRuntime()\n\n navigate({\n page: 'admin.app.storefront-permissions.roles-list',\n })\n\n const { params } = route\n\n const { items } = state\n\n const customSchema = {\n properties: {\n name: {\n title: intl.formatMessage(messages.name),\n },\n email: {\n title: intl.formatMessage(messages.email),\n },\n },\n }\n\n if (data?.listUsers && !state.items.length) {\n const newItems: any = data?.listUsers\n\n if (\n params?.id &&\n !newItems.filter((item: any) => {\n return item.id === params.id\n }).length\n ) {\n newItems.push(params)\n }\n\n if (newItems.length) {\n setState({\n ...state,\n items: newItems,\n })\n }\n }\n\n const lineActions = [\n {\n label: ({ rowData }: any) =>\n `${intl.formatMessage(messages.delete)} ${rowData.name}`,\n isDangerous: true,\n onClick: ({ rowData }: any) => {\n deleteId = rowData.id\n deleteUser({\n variables: {\n id: rowData.id,\n email: rowData.email,\n userId: rowData.userId,\n },\n })\n },\n },\n ]\n\n return (\n <div className=\"w-100 pt6\">\n <Table\n fullWidth\n loading={loading || deleteLoading}\n schema={customSchema}\n items={items}\n lineActions={lineActions}\n onRowClick={({ rowData: { clId: id } }: any) => {\n navigate({\n page: 'admin.app.storefront-permissions.users-edit',\n params: {\n id,\n },\n })\n }}\n toolbar={{\n newLine: {\n label: intl.formatMessage(messages.new),\n handleCallback: () => {\n navigate({ page: 'admin.app.storefront-permissions.users-new' })\n },\n },\n }}\n />\n </div>\n )\n}\n\nexport default injectIntl(Users)\n\n```" } ]
code_formula-graphql_2feabe88
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/docs/README.md from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# vtex.formula-graphql\n\nGraphQL schema and resolvers for the VTEX Formula Hackathon Manager.\n\n```" } ]
code_formula-graphql_65a0854e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/graphql/schema.graphql from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype Project {\n demoURL: String\n description: String\n edition: String\n id: String\n name: String\n owner: String\n team: [ProfileData]\n}\n\ntype ProfileData {\n name: String\n email: String\n picture: String\n id: String\n}\n\ntype Vote {\n projectID: String\n userID: String\n execution: Int\n relevance: Int\n}\n\ntype Score {\n projectID: String\n score: Int\n}\n\nenum FormulaStatus {\n REGISTRATION\n RUNNING\n VOTING\n RESULTS\n}\n\ntype InfoData {\n status: FormulaStatus\n timeRemainingSeconds: Int\n timeTotalSeconds: Int\n}\n\ntype Query {\n project(\n edition: String!\n id: String!\n ): Project @cacheControl(scope: PRIVATE)\n\n projects(\n edition: String!\n ): [Project] @cacheControl(scope: PRIVATE)\n\n profile: ProfileData @cacheControl(scope: PRIVATE)\n\n votes(\n edition: String!\n ): [Vote] @cacheControl(scope: PRIVATE)\n\n scores(\n edition: String!\n ): [Score] @cacheControl(scope: PRIVATE)\n\n info(\n edition: String!\n ): InfoData @cacheControl(scope: PRIVATE)\n\n finalists(\n edition: String!\n ): [Project] @cacheControl(scope: PRIVATE)\n}\n\ntype Mutation {\n updateVote(\n edition: String\n projectID: String\n execution: Int\n relevance: Int\n ): Vote\n\n updateProject(\n edition: String!\n id: String\n demoURL: String\n description: String\n name: String\n ): Project\n\n deleteProject(\n edition: String!\n id: String!\n ): Boolean\n\n joinProject(\n edition: String!\n id: String!\n ): Project\n\n leaveProject(\n edition: String!\n id: String!\n ): Project\n\n updateScores(\n edition: String!\n ): [Score]\n}\n\n```" } ]
code_formula-graphql_0c497556
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/node/errors.ts from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {\n AuthenticationError as ApolloAuthenticationError,\n ForbiddenError as ApolloForbiddenError\n} from 'apollo-server-errors'\n\nexport class AuthenticationError extends ApolloAuthenticationError {\n constructor() {\n super('User is not authenticated')\n }\n}\n\n// tslint:disable-next-line\nexport class NotVTEXUserError extends ApolloForbiddenError {\n constructor() {\n super('VTEX Formula is only available to VTEX employees - sorry!')\n }\n}\n\n```" } ]
code_formula-graphql_2bf8669b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/node/service.json from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"stack\": \"nodejs\",\n \"memory\": 512,\n \"ttl\": 30,\n \"timeout\": 10,\n \"minReplicas\": 1,\n \"maxReplicas\": 1\n}\n\n```" } ]
code_formula-graphql_21a869fe
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/node/typings.d.ts from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {IOContext as ClientsContext} from '@vtex/api'\nimport {Context} from 'koa'\nimport {Dictionary} from 'ramda'\n\nimport Resources from './resources/index'\n\ndeclare global {\n type LogLevel = 'info' | 'error' | 'warn' | 'debug'\n\n interface LicenseManagerUser {\n IsPersisted: boolean,\n IsRemoved: boolean,\n UserId: string,\n Login: string,\n Name: string,\n IsAdmin: boolean,\n IsReliable: boolean,\n IsBlocked: boolean\n }\n}\n\n```" } ]
code_formula-graphql_fda5865e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/node/package.json from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.formula-graphql\",\n \"version\": \"0.2.3\",\n \"dependencies\": {\n \"@vtex/api\": \"1.0.0\",\n \"apollo-server-errors\": \"^2.0.2\",\n \"ramda\": \"^0.25.0\",\n \"uuid\": \"^3.3.2\"\n },\n \"devDependencies\": {\n \"@types/koa\": \"^2.0.39\",\n \"@types/mime-types\": \"^2.1.0\",\n \"@types/node\": \"^7.0.8\",\n \"@types/ramda\": \"^0.25.38\",\n \"tslint\": \"^5.8.0\",\n \"tslint-config-vtex\": \"^2.0.0\",\n \"typescript\": \"^3.0.3\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit && tslint -c tslint.json './**/*.ts'\"\n },\n \"license\": \"UNLICENSED\"\n}\n\n```" } ]
code_formula-graphql_5ed45a13
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/node/globals.ts from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {MetricsAccumulator, ServiceContext} from '@vtex/api'\nimport Resources from './resources'\n\nglobal.metrics = new MetricsAccumulator()\n\ndeclare global {\n const metrics: MetricsAccumulator\n\n type Resolver<A, R, P = any> = (parent: P, args: A, ctx: ResolverContext, info: any) => Promise<R>\n\n interface ProfileData {\n name: string\n email: string\n picture: string | null\n id: string\n }\n\n interface ResolverContext extends ServiceContext {\n resources: Resources\n profile: ProfileData\n }\n\n namespace NodeJS {\n interface Global {\n metrics: MetricsAccumulator\n }\n }\n}\n\n```" } ]
code_formula-graphql_f5469503
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/node/index.ts from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport './globals'\n\nimport {ServiceContext} from '@vtex/api'\nimport {mapObjIndexed} from 'ramda'\n\nimport {infoQueries} from './resolvers/info'\nimport {profileQueries} from './resolvers/profile'\nimport {projectsMutations, projectsQueries} from './resolvers/projects'\nimport {scoreMutations, scoreQueries} from './resolvers/scores'\nimport {votesMutations, votesQueries} from './resolvers/votes'\nimport Resources from './resources'\n\nconst log = (\n {vtex: {account, workspace}}: ServiceContext,\n resolver: string,\n [sec, ns],\n err?: Error,\n) => [\n new Date().toISOString(),\n err ? '❌' : '✅',\n `${account}/${workspace}`,\n resolver,\n Math.trunc(sec * 1e3 + ns / 1e6) + 'ms',\n].join(' ')\n\nconst statusLabel = (e?: Error) =>\n e ? `error${e.name ? `-${e.name}` : ''}` : 'success'\n\nconst prepare = <A, R, P>(resolver: Resolver<A, R, P>) => async (parent: P, args: A, ctx: ResolverContext, info: any) => {\n if (!resolver.name) {\n throw new Error('Resolvers must be named')\n }\n\n let err\n const start = process.hrtime()\n ctx.resources = new Resources(ctx)\n\n try {\n ctx.profile = await ctx.resources.profile.getProfile()\n return resolver(parent, args, ctx, info)\n } catch (e) {\n err = e\n console.error(e)\n ctx.resources.logger.error(e, {resolver: resolver.name})\n throw e\n } finally {\n const end = process.hrtime(start)\n console.log(log(ctx, resolver.name, end, err))\n metrics.batchHrTimeMetricFromEnd(`resolver-${resolver.name}-${statusLabel(err)}`, end, ctx.vtex.production)\n }\n}\n\nexport default {\n graphql: {\n resolvers: {\n Mutation: mapObjIndexed(prepare, {\n ...projectsMutations,\n ...votesMutations,\n ...scoreMutations,\n }),\n Query: mapObjIndexed(prepare, {\n ...infoQueries,\n ...profileQueries,\n ...projectsQueries,\n ...votesQueries,\n ...scoreQueries,\n }),\n },\n },\n statusTrack: metrics.statusTrack,\n}\n\n```" } ]
code_formula-graphql_46800d50
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/node/resources/projects.ts from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {Logger, VBase} from '@vtex/api'\nimport {ForbiddenError, UserInputError} from 'apollo-server-errors'\nimport {pluck} from 'ramda'\nimport uuidv4 from 'uuid/v4'\n\nexport interface Project {\n demoURL?: string\n description?: string\n edition?: string\n id?: string\n name?: string\n owner?: string\n team?: ProfileData[]\n}\n\nexport default class Projects {\n constructor (\n public ctx: ResolverContext,\n public vbase: VBase,\n public logger: Logger,\n ) {}\n\n public find = async (edition: string, id: string): Promise<Project> => {\n const project = await this.vbase.getJSON<Project>(encodeURIComponent(edition), `${id}.json`, true)\n return project\n }\n\n public list = async (edition: string): Promise<Project[]> => {\n const projectIds = await this.vbase.listFiles(encodeURIComponent(edition))\n const paths = pluck('path', projectIds.data).map(p => p.replace('.json', ''))\n const projects = await Promise.all(paths.map(p => this.find(edition, p)))\n return projects\n }\n\n public update = async (edition: string, id?: string, project?: Partial<Project>) => {\n const email = this.ctx.profile.email\n await this.logger.info({edition, id, project, action: 'update', email})\n\n // Create new project\n if (!id) {\n const generated = uuidv4()\n const newProject = {\n ...project,\n edition,\n id: generated,\n owner: email,\n team: [this.ctx.profile],\n }\n\n await this.vbase.saveJSON(encodeURIComponent(edition), `${generated}.json`, newProject)\n return newProject\n }\n\n if (!project || !project.owner || !project.id) {\n throw new UserInputError('Project is invalid.')\n }\n\n await this.vbase.saveJSON(encodeURIComponent(edition), `${id}.json`, project)\n\n return project\n }\n\n public delete = async (edition: string, id: string) => {\n const savedProject = await this.find(encodeURIComponent(edition), id)\n const email = this.ctx.profile.email\n\n if (!savedProject) {\n return\n }\n\n if (savedProject.owner !== email) {\n throw new ForbiddenError(`Project ${id} is owned by ${savedProject.owner} and cannot be deleted by ${email}`)\n }\n\n await this.logger.info({edition, id, action: 'delete', email})\n await this.vbase.deleteFile(encodeURIComponent(edition), `${id}.json`)\n return true\n }\n}\n\n```" } ]
code_formula-graphql_c2947fc9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/node/resources/scores.ts from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {Logger, VBase} from '@vtex/api'\nimport {compose, equals, findIndex, keysIn, map, mapObjIndexed, mergeWith, reduce, slice, sort, sum, values} from 'ramda'\n\nimport Votes, {UserVotes} from './votes'\n\nconst SCORE_RECEIVING_PROJECTS = 3\n\ninterface ScoresByProject {\n [projectID: string]: number\n}\n\nexport interface ScoreData {\n projectID: string\n score: number\n}\n\nexport default class Score {\n private static file = 'scores.json'\n private static getBucket = (edition: string) => `${edition}-score`\n\n private static calculateUserScore(votes: UserVotes): ScoresByProject {\n const summedVotes = mapObjIndexed(compose(sum,values), votes)\n const favouriteProjects = slice(0, SCORE_RECEIVING_PROJECTS, sort((a,b) => summedVotes[b] - summedVotes[a], keysIn(summedVotes)))\n return mapObjIndexed((_, projectID) => {\n const position = findIndex(equals(projectID), favouriteProjects)\n return position === -1 ? 0 : SCORE_RECEIVING_PROJECTS - position\n }, votes)\n }\n\n constructor (\n public ctx: ResolverContext,\n public vbase: VBase,\n public logger: Logger,\n ) {}\n\n public updateScores = async (edition: string): Promise<ScoreData[]> => {\n const voteFiles = await this.vbase.listFiles(Votes.getBucket(edition))\n const votes = await Promise.all(map(\n voteFile => this.vbase.getJSON<UserVotes>(Votes.getBucket(edition), voteFile.path, true) || {},\n voteFiles.data\n ))\n const scoresByUser = map(Score.calculateUserScore, votes)\n const scores: ScoresByProject = reduce(mergeWith((a,b) => a+b), {}, scoresByUser)\n const scoreData = values(mapObjIndexed((score, projectID) => ({score,projectID}), scores))\n const sortedScoreData = sort((a,b) => b.score - a.score, scoreData)\n\n await this.vbase.saveJSON(Score.getBucket(edition), Score.file, sortedScoreData)\n return sortedScoreData\n }\n\n public getScores = async (edition: string): Promise<ScoreData[]> => {\n const scoreData = await this.vbase.getJSON<ScoreData[]>(Score.getBucket(edition), Score.file, true) || []\n return scoreData\n }\n}\n\n```" } ]
code_formula-graphql_3b85093e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/node/resources/votes.ts from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {Logger, VBase} from '@vtex/api'\n\nexport interface Vote {\n execution: number\n relevance: number\n}\n\nexport interface UserVotes {\n [projectID: string]: Vote\n}\n\nexport default class Votes {\n public static getBucket = (edition: string) => `${edition}-votes`\n public static getUserFile = (id: string) => `${id}.json`\n\n constructor (\n public ctx: ResolverContext,\n public vbase: VBase,\n public logger: Logger,\n ) {}\n\n public getVotes = async (edition: string) => {\n const { id } = this.ctx.profile\n const votes = await this.vbase.getJSON<UserVotes>(Votes.getBucket(edition), Votes.getUserFile(id), true) || {}\n return votes\n }\n\n public setVote = async (edition: string, projectID: string, vote: Vote) => {\n const { id } = this.ctx.profile\n const votes = await this.getVotes(edition)\n votes[projectID] = vote\n await this.vbase.saveJSON<UserVotes>(Votes.getBucket(edition), Votes.getUserFile(id), votes)\n return vote\n }\n}\n\n```" } ]
code_formula-graphql_cd79a663
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/node/resources/profile.ts from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {HttpClient, LRUCache, ServiceContext} from '@vtex/api'\n\nimport {AuthenticationError, NotVTEXUserError} from '../errors'\n\ninterface VtexIdUser {\n userId: string\n user: string\n userType: string\n}\n\nconst FIVE_MIN_MS = 5 * 60 * 1000\nconst VTEX_ID_COOKIE = 'VtexIdclientAutCookie'\nconst VTEX_EMAIL_REGEX = /\\@vtex\\.com(\\.br)?$/\n\nconst profileCache = new LRUCache<string, any>({\n max: 2000,\n maxAge: FIVE_MIN_MS,\n stale: true,\n})\n\nmetrics.trackCache('profile', profileCache)\n\nconst capitalizeFirstLetter = (s: string) => {\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\nconst emailToName = (email: string) => {\n const [user] = email.split('@')\n const maybeWords = user.split('.')\n return maybeWords.map(capitalizeFirstLetter).join(' ')\n}\n\nexport default class Profile {\n private http: HttpClient\n private vtexIdToken: string\n private headers: Record<string, string>\n private topbarPath: string\n private vtexIdPath: string\n\n public constructor(ctx: ServiceContext) {\n this.http = new HttpClient({\n metrics,\n userAgent: process.env.VTEX_APP_ID,\n })\n\n this.vtexIdToken = ctx.cookies.get(VTEX_ID_COOKIE)\n\n this.topbarPath = `http://${ctx.vtex.account}.vtexcommercestable.com.br/api/license-manager/site/pvt/newtopbar`\n this.vtexIdPath = `http://vtexid.vtex.com.br/api/vtexid/pub/authenticated/user?authToken=${this.vtexIdToken}`\n\n this.headers = {\n 'Proxy-Authorization': ctx.vtex.authToken,\n VtexIdclientAutCookie: this.vtexIdToken,\n }\n }\n\n public getProfile = async () => {\n if (!this.vtexIdToken) {\n throw new AuthenticationError()\n }\n\n let profile\n\n const topbarResponse: {profile: ProfileData} = await profileCache.getOrSet(this.vtexIdToken, this.fetchProfile)\n\n profile = topbarResponse.profile\n\n if (!profile) {\n profile = await this.fetchFallbackProfile()\n profileCache.set(this.vtexIdToken, {profile})\n }\n\n if (!profile || !profile.email || !VTEX_EMAIL_REGEX.test(profile.email)) {\n throw new NotVTEXUserError()\n }\n\n return profile\n }\n\n private fetchProfile = () => this.http.get(this.topbarPath, {headers: this.headers})\n\n private fetchFallbackProfile = () =>\n this.http.get(this.vtexIdPath, {headers: {'Proxy-Authorization': this.headers['Proxy-Authorization']}})\n .then((vtexIdUser: VtexIdUser) => ({\n email: vtexIdUser.user,\n id: vtexIdUser.userId.replace(/\\-/g, '').toLowerCase(),\n name: emailToName(vtexIdUser.user),\n picture: null,\n }))\n .catch((e) => {\n console.error(e)\n return null\n })\n}\n\n```" } ]
code_formula-graphql_3bae39b9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/node/resources/index.ts from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {Logger, LRUCache, VBase} from '@vtex/api'\n\nimport Profile from './profile'\nimport Projects from './projects'\nimport Scores from './scores'\nimport Votes from './votes'\n\nconst vbaseCache = new LRUCache<string, any>({\n max: 200,\n})\n\nmetrics.trackCache('vbase', vbaseCache)\n\nexport default class Resources {\n public logger: Logger\n public profile: Profile\n public projects: Projects\n public votes: Votes\n public scores: Scores\n\n private vbase: VBase\n\n constructor (ctx: ResolverContext) {\n this.logger = new Logger(ctx.vtex)\n this.vbase = new VBase(ctx.vtex, {cacheStorage: vbaseCache})\n\n this.profile = new Profile(ctx)\n this.projects = new Projects(ctx, this.vbase, this.logger)\n this.votes = new Votes(ctx, this.vbase, this.logger)\n this.scores = new Scores(ctx, this.vbase, this.logger)\n }\n}\n\n```" } ]
code_formula-graphql_55457b18
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/node/resolvers/info.ts from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nenum FormulaStatus {\n REGISTRATION = 'REGISTRATION',\n RUNNING = 'RUNNING',\n VOTING = 'VOTING',\n RESULTS = 'RESULTS',\n}\n\ninterface FormulaInfo {\n status: FormulaStatus\n timeRemainingSeconds: number\n timeTotalSeconds: number\n}\n\nconst editions = {\n '2018.10': {\n startDate: new Date('2018-10-18T12:00:00.000Z'),\n timeTotalSeconds: 32 * 60 * 60,\n }\n}\n\nasync function info(_: any, {edition}: any, ctx: any): Promise<FormulaInfo> {\n const {startDate, timeTotalSeconds} = editions[edition]\n const {resources: {scores: scoresResource}} = ctx\n\n const scores = await scoresResource.getScores(edition)\n\n const nowMillis = (new Date()).getTime()\n const startDateMillis = startDate.getTime()\n const finishDateMillis = startDateMillis + timeTotalSeconds * 1000\n\n const status = nowMillis < startDateMillis\n ? FormulaStatus.REGISTRATION\n : nowMillis < finishDateMillis\n ? FormulaStatus.RUNNING\n : scores.length === 0\n ? FormulaStatus.VOTING\n : FormulaStatus.RESULTS\n\n const timeRemainingMillis = status === FormulaStatus.REGISTRATION\n ? startDateMillis - nowMillis\n : status === FormulaStatus.RUNNING\n ? finishDateMillis - nowMillis\n : 0\n\n return {\n status,\n timeRemainingSeconds: Math.round(timeRemainingMillis / 1000),\n timeTotalSeconds,\n }\n}\n\nexport const infoQueries = {\n info,\n}\n\n```" } ]
code_formula-graphql_036bcf32
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/node/resolvers/projects.ts from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {concat, difference, uniq} from 'ramda'\n\nimport {Project} from '../resources/projects'\n\ninterface ProjectArgs {\n edition: string\n id?: string\n demoURL?: string\n description?: string\n name?: string\n}\n\ninterface ProjectsArgs {\n edition: string\n}\n\nasync function project(_: any, {edition, id}: ProjectArgs, ctx: ResolverContext): Promise<Project> {\n return ctx.resources.projects.find(edition, id)\n}\n\nasync function projects(_: any, {edition}: ProjectsArgs, ctx: ResolverContext): Promise<Project[]> {\n return ctx.resources.projects.list(edition)\n}\n\nasync function updateProject(_: any, {edition, id, demoURL, description, name}: ProjectArgs, ctx: ResolverContext): Promise<Project> {\n if (!id) {\n return ctx.resources.projects.update(edition, id, {demoURL, description, name})\n }\n\n const saved = await ctx.resources.projects.find(edition, id)\n\n const updated = {\n ...saved,\n demoURL,\n description,\n edition,\n id,\n name,\n }\n\n await ctx.resources.projects.update(edition, id, updated)\n\n return updated\n}\n\nasync function deleteProject(_: any, {edition, id}: ProjectArgs, ctx: ResolverContext): Promise<boolean> {\n return ctx.resources.projects.delete(edition, id)\n}\n\nasync function joinProject(_: any, {edition, id}: ProjectArgs, ctx: ResolverContext): Promise<Project> {\n const saved = await ctx.resources.projects.find(edition, id)\n\n const updated = {\n ...saved,\n team: uniq(concat([ctx.profile], saved.team)),\n }\n\n return ctx.resources.projects.update(edition, id, updated)\n}\n\nasync function leaveProject(_: any, {edition, id}: ProjectArgs, ctx: ResolverContext): Promise<Project> {\n const saved = await ctx.resources.projects.find(edition, id)\n\n const updated = {\n ...saved,\n team: difference(saved.team, [ctx.profile]),\n }\n\n return ctx.resources.projects.update(edition, id, updated)\n}\n\nexport const projectsMutations = {\n deleteProject,\n joinProject,\n leaveProject,\n updateProject,\n}\n\nexport const projectsQueries = {\n project,\n projects,\n}\n\n```" } ]
code_formula-graphql_3cedbe81
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/node/resolvers/scores.ts from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {map} from 'ramda'\nimport {ScoreData} from '../resources/scores'\n\ninterface ScoresArgs {\n edition: string\n}\n\nasync function updateScores(_: any, {edition}: ScoresArgs, ctx: ResolverContext): Promise<ScoreData[]> {\n const {scores: scoresResource} = ctx.resources\n const projectScores = await scoresResource.updateScores(edition)\n return projectScores\n}\n\nasync function scores(_: any, {edition}: ScoresArgs, ctx: ResolverContext): Promise<ScoreData[]> {\n const {scores: scoresResource} = ctx.resources\n const scoreData = await scoresResource.getScores(edition)\n return scoreData\n}\n\nasync function finalists(_: any, {edition}: ScoresArgs, ctx: ResolverContext): Promise<any[]> {\n const {scores: scoresResource, projects: projectsResource} = ctx.resources\n const scoreData = await scoresResource.getScores(edition)\n const initialCutPosition = Math.min(3, scoreData.length)\n let cutPosition = initialCutPosition\n while (cutPosition < scoreData.length && scoreData[cutPosition].score === scoreData[initialCutPosition-1].score) {\n cutPosition++\n }\n const finalistsData = scoreData.slice(0,cutPosition)\n const finalistsPromises = map(finalist => projectsResource.find(edition, finalist.projectID), finalistsData)\n const finalistProjects = await Promise.all(finalistsPromises)\n return finalistProjects || []\n}\n\nexport const scoreQueries = {\n finalists,\n scores,\n}\n\nexport const scoreMutations = {\n updateScores,\n}\n\n```" } ]
code_formula-graphql_eba1eeba
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/node/resolvers/votes.ts from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {mapObjIndexed,values} from 'ramda'\n\nexport interface Vote {\n execution: number\n relevance: number\n projectID: string\n userID: string\n}\n\ninterface VotesArgs {\n edition: string\n}\n\ninterface UpdateVoteArgs {\n edition: string\n projectID: string\n execution: number\n relevance: number\n}\n\nasync function votes(_: any, {edition}: VotesArgs, ctx: ResolverContext): Promise<Vote[]> {\n const {profile: {id}, resources: {votes: votesResource} } = ctx\n const userVotes = await votesResource.getVotes(edition)\n return values(mapObjIndexed((vote,projectID) => ({...vote,projectID,userID:id}), userVotes))\n}\n\nasync function updateVote(_: any, {edition,projectID,execution,relevance}: UpdateVoteArgs, ctx: ResolverContext): Promise<Vote> {\n const {profile: {id}, resources: {votes: votesResource} } = ctx\n const vote = await votesResource.setVote(edition, projectID, {execution,relevance})\n return {...vote,projectID,userID:id}\n}\n\nexport const votesMutations = {\n updateVote,\n}\n\nexport const votesQueries = {\n votes,\n}\n\n```" } ]
code_formula-graphql_2304662c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of formula-graphql/node/resolvers/profile.ts from the formula-graphql VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nfunction profile(_: any, __: any, ctx: ResolverContext): ProfileData {\n return ctx.profile\n}\n\nexport const profileQueries = {\n profile,\n}\n\n```" } ]
code_store-locator_82b1442e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-locator/messages/pt.json from the store-locator VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/more-details\": \"Mais detalhes\",\n \"store/none-stores\": \"Nenhuma loja por perto\",\n \"store/load-all\": \"Listar todas as lojas\",\n \"store/back-link\": \"Voltar para lista de lojas\",\n \"store/address-label\": \"Endereço\",\n \"store/information-label\": \"Informações\",\n \"store/store-closed\": \"Fechado\",\n \"store/hours-label\": \"Horário de funcionamento\",\n \"store/day-of-week-sunday\": \"Domingo\",\n \"store/day-of-week-monday\": \"Segunda\",\n \"store/day-of-week-tuesday\": \"Terça\",\n \"store/day-of-week-wednesday\": \"Quarta\",\n \"store/day-of-week-thursday\": \"Quinta\",\n \"store/day-of-week-friday\": \"Sexta\",\n \"store/day-of-week-saturday\": \"Sábado\"\n}\n```" } ]