id
stringlengths 12
53
| messages
listlengths 3
3
|
|---|---|
code_binding-selector_7bec8c68
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/graphql/types/OrderForm.graphql from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ntype PartialOrderForm {\n orderFormId: ID!\n salesChannel: String!\n items: [Item!]!\n canEditData: Boolean!\n loggedIn: Boolean!\n userProfileId: String\n value: Float!\n clientPreferencesData: ClientPreferencesData\n allowManualPrice: Boolean\n}\n\ntype ClientPreferencesData {\n locale: String\n optinNewsletter: Boolean\n}\n\ninput ClientPreferencesDataInput {\n optinNewsletter: Boolean\n locale: String\n}\n\n```"
}
] |
code_binding-selector_f3d1265c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/graphql/types/BindingTranslations.graphql from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ninput BindingsInput {\n bindingId: String\n show: Boolean\n translatedLocales: [BindingsTranslationInput]\n externalRedirectData: ExternalRedirectDataInput\n customFlagData: CustomFlagDataInput\n}\n\ninput BindingsTranslationInput {\n id: String\n label: String\n defaultLocale: String\n canonicalBaseAddress: String\n salesChannel: String\n hide: Boolean\n}\n\ninput ExternalRedirectDataInput {\n redirectUrl: Boolean\n url: String\n}\n\ntype BindingsTranslation {\n id: String\n label: String\n defaultLocale: String\n canonicalBaseAddress: String\n salesChannel: String\n hide: Boolean\n}\n\ntype TranslatedInfoOutput {\n bindingId: String\n show: Boolean\n translatedLocales: [BindingsTranslation]\n externalRedirectData: ExternalRedirectData\n customFlagData: CustomFlagData\n}\n\ntype ExternalRedirectData {\n redirectUrl: Boolean\n url: String\n}\n\ninput CustomFlagDataInput {\n isCustom: Boolean\n url: String\n}\n\ntype CustomFlagData {\n isCustom: Boolean\n url: String\n}\n\n```"
}
] |
code_binding-selector_9822b5f4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/graphql/types/Item.graphql from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nscalar InputValues\n\n\"\"\"\nProductCategoriesObject is a Record<string, string>, in the following format:\n{ '<categoryNumber>': '<categoryName>' }\n\"\"\"\nscalar ProductCategoriesObject\n\ntype Item {\n additionalInfo: ItemAdditionalInfo\n assemblyOptions: AssemblyOptionItem\n availability: String\n attachmentOfferings: [AttachmentOffering!]!\n attachments: [Attachment!]!\n bundleItems: [Item!]!\n detailUrl: String\n id: ID!\n imageUrls: ImageUrls\n listPrice: Float\n manualPrice: Float\n measurementUnit: String\n name: String @translatableV2\n offerings: [Offering!]!\n options: [AssemblyOptionType]\n parentAssemblyBinding: String\n parentItemIndex: Int\n price: Float\n productCategories: ProductCategoriesObject\n productCategoryIds: String\n \"\"\"\n Id of the product. Can be null if included inside bundle items.\n \"\"\"\n productId: String\n productRefId: String\n quantity: Float!\n refId: String\n \"\"\"\n Product's seller. Can be null if included inside bundle items.\n \"\"\"\n seller: String\n sellingPrice: Float\n sellingPriceWithAssemblies: Float\n skuName: String @translatableV2\n skuSpecifications: [SKUSpecification!]!\n uniqueId: String!\n unitMultiplier: Float\n priceTags: [PriceTag!]!\n}\n\ntype ImageUrls {\n at1x: String!\n at2x: String!\n at3x: String!\n}\n\ntype AssemblyOptionItem {\n added: [AddedOptionItem]!\n removed: [RemovedOptionItem]!\n parentPrice: Float\n}\n\ntype RemovedOptionItem {\n initialQuantity: Int\n removedQuantity: Int\n name: String @translatableV2\n}\n\ntype AddedOptionItem {\n item: Item\n compositionItem: CompositionItem\n normalizedQuantity: Int\n choiceType: String\n extraQuantity: Int\n}\n\ntype CompositionItem {\n id: ID\n minQuantity: Int\n maxQuantity: Int\n initialQuantity: Int\n priceTable: String\n seller: String\n}\n\ntype ItemAdditionalInfo {\n brandName: String @translatableV2\n}\n\ntype SKUSpecification {\n fieldName: String @translatableV2\n fieldValues: [String]! @translatableV2\n}\n\ntype AssemblyOptionType {\n assemblyId: String!\n id: ID\n quantity: Int\n seller: String\n inputValues: InputValues\n options: [AssemblyOptionType!]\n}\n\ntype Offering {\n id: String!\n name: String! @translatableV2\n price: Int!\n type: String!\n attachmentOfferings: [AttachmentOffering!]!\n}\n\nscalar AttachmentSchema\n\ntype AttachmentOffering {\n name: String @translatableV2\n required: Boolean\n schema: AttachmentSchema\n}\n\nscalar AttachmentContent\n\ntype Attachment {\n name: String @translatableV2\n content: AttachmentContent\n}\n\ninput ItemInput {\n id: Int\n index: Int\n quantity: Float\n seller: ID\n uniqueId: String\n inputValues: InputValues\n options: [AssemblyOptionInput]\n}\n\ninput AssemblyOptionInput {\n assemblyId: String!\n id: ID\n quantity: Int\n seller: String\n inputValues: InputValues\n options: [AssemblyOptionInput!]\n}\n\nscalar OfferingInfo\n\ninput OfferingInput {\n itemIndex: Int!\n offeringId: String!\n offeringInfo: OfferingInfo\n}\n\ninput BundleItemAttachmentInput {\n itemIndex: Int!\n bundleItemId: String!\n attachmentName: String!\n attachmentContent: AttachmentContent!\n}\n\ninput ManualPriceInput {\n itemIndex: Int!\n price: Float!\n}\n\ntype PriceTag {\n identifier: String\n isPercentual: Boolean\n name: String\n ratesAndBenefitsIdentifier: RatesAndBenefitsIdentifier\n rawValue: Float\n value: Int\n}\n\ntype RatesAndBenefitsIdentifier {\n description: String\n featured: Boolean\n id: String\n matchedParameters: MatchedParameters\n name: String\n}\n\nscalar MatchedParameters\n\n```"
}
] |
code_binding-selector_7161a15b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/node/clients/checkout.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext, RequestConfig } from '@vtex/api'\nimport { JanusClient } from '@vtex/api'\nimport type { OrderForm as CheckoutOrderForm } from 'vtex.checkout-graphql'\n\nimport { statusToError } from '../utils'\n\nexport class Checkout extends JanusClient {\n constructor(ctx: IOContext, options?: InstanceOptions) {\n super(ctx, {\n ...options,\n headers: {\n ...options?.headers,\n ...(ctx.storeUserAuthToken\n ? { VtexIdclientAutCookie: ctx.storeUserAuthToken }\n : null),\n },\n })\n }\n\n public getOrderForm = (orderFormId: string) => {\n return this.get<CheckoutOrderForm>(this.routes.getOrderForm(orderFormId), {\n metric: 'checkout-orderForm',\n })\n }\n\n public addItems = (\n orderFormId: string,\n items: CheckoutOrderForm['items'],\n salesChannel: string\n ) =>\n this.post<CheckoutOrderForm, { orderItems: CheckoutOrderForm['items'] }>(\n this.routes.addItems(orderFormId, salesChannel),\n {\n orderItems: items,\n },\n { metric: 'checkout-AddItem' }\n )\n\n protected get = <T>(url: string, config: RequestConfig = {}) => {\n try {\n return this.http.get<T>(url, config)\n } catch (e) {\n return (statusToError(e) as unknown) as CheckoutOrderForm\n }\n }\n\n protected post = async <T, D>(\n url: string,\n data?: D,\n config: RequestConfig = {}\n ) => {\n config.headers = {\n ...config.headers,\n }\n try {\n return this.http.post<T>(url, data, config)\n } catch (e) {\n return (statusToError(e) as unknown) as CheckoutOrderForm\n }\n }\n\n private get routes() {\n const base = '/api/checkout/pub'\n\n return {\n addItems: (orderFormId: string, salesChannel: string) =>\n `${base}/orderForm/${orderFormId}/items?sc=${salesChannel}`,\n getOrderForm: (orderFormId: string) => `${base}/orderForm/${orderFormId}`,\n }\n }\n}\n\n```"
}
] |
code_binding-selector_1721c3bb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/node/clients/index.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\n\nimport { Checkout } from './checkout'\n\nexport class Clients extends IOClients {\n public get checkout() {\n return this.getOrSet('checkout', Checkout)\n }\n}\n\n```"
}
] |
code_binding-selector_c19cf37e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/node/constants/index.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const CLOUDFRONT_VIEWER_COUNTRY = 'cloudfront-viewer-country'\nexport const VTEX_IO_VIEWER_COUNTRY = 'vtex-io-viewer-country'\n\n```"
}
] |
code_binding-selector_aef80d26
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/node/middlewares/viewerCountry.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { CLOUDFRONT_VIEWER_COUNTRY, VTEX_IO_VIEWER_COUNTRY } from '../constants'\n\nexport async function viewerCountry(ctx: Context) {\n const {\n request: { header },\n } = ctx\n\n const countryCode =\n header[CLOUDFRONT_VIEWER_COUNTRY] || header[VTEX_IO_VIEWER_COUNTRY] || null\n\n ctx.body = countryCode\n}\n\n```"
}
] |
code_binding-selector_4e5bf7fd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/node/resolvers/Bindings.d.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface TranslatedInfo {\n id: string\n label: string\n canonicalBaseAddress: string\n defaultLocale: string\n hide: boolean\n}\n\ninterface TranslatedBinding {\n bindingId: string\n show: boolean\n translatedLocales: [TranslatedInfo]\n}\n\ninterface GetResponse {\n data: [TranslatedBinding]\n}\n\ninterface GetSalesChannel {\n salesChannel: boolean\n}\n\n```"
}
] |
code_binding-selector_172396d7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/node/resolvers/bindingInfo.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const bindingInfo = async (_: unknown, __: unknown, ctx: Context) => {\n const { clients } = ctx\n\n const { vbase } = clients\n\n try {\n const savedTranslations: GetResponse = await vbase.getJSON(\n 'account.binding',\n 'configs'\n )\n\n return savedTranslations.data\n } catch (e) {\n const { status } = e.response\n\n if (status === 404) {\n return []\n }\n\n throw e\n }\n}\n\n```"
}
] |
code_binding-selector_5e2f79ad
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/node/resolvers/orderForm.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { OrderForm as CheckoutOrderForm } from 'vtex.checkout-graphql'\n\nexport const updateSalesChannel = async (\n _: unknown,\n args: {\n orderFormId: string\n salesChannel: string\n locale: string\n },\n ctx: Context\n): Promise<CheckoutOrderForm> => {\n const { clients } = ctx\n const { orderFormId, salesChannel } = args\n const { checkout } = clients\n const orderForm = await checkout.getOrderForm(orderFormId)\n\n if (!orderForm.items.length) {\n return orderForm\n }\n\n return checkout.addItems(orderFormId, orderForm.items, salesChannel)\n}\n\n```"
}
] |
code_binding-selector_8889f296
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/node/resolvers/toggleSalesChannel.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const toggleSalesChannel = async (\n _: unknown,\n args: {\n salesChannel: boolean\n },\n ctx: Context\n) => {\n const { clients } = ctx\n const { salesChannel } = args\n const { vbase } = clients\n\n await vbase.saveJSON('account.salesChannel', 'configs', {\n salesChannel,\n })\n\n return salesChannel\n}\n\n```"
}
] |
code_binding-selector_c39f9fbe
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/node/resolvers/saveBindingInfo.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const saveBindingInfo = async (\n _: unknown,\n args: {\n data: [TranslatedBinding]\n },\n ctx: Context\n) => {\n const { clients } = ctx\n const { data } = args\n const { vbase } = clients\n\n await vbase.saveJSON('account.binding', 'configs', {\n data,\n })\n\n return data\n}\n\n```"
}
] |
code_binding-selector_0b05a607
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/node/resolvers/isSalesChannelUpdate.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const isSalesChannelUpdate = async (\n _: unknown,\n __: unknown,\n ctx: Context\n) => {\n const { clients } = ctx\n const { vbase } = clients\n\n try {\n const salesChannelData: GetSalesChannel = await vbase.getJSON(\n 'account.salesChannel',\n 'configs'\n )\n\n return salesChannelData.salesChannel\n } catch (e) {\n const { status } = e.response\n\n if (status === 404) {\n return null\n }\n\n throw e\n }\n}\n\n```"
}
] |
code_binding-selector_aae21b65
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/node/resolvers/index.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { bindingInfo } from './bindingInfo'\nimport { saveBindingInfo } from './saveBindingInfo'\nimport { updateSalesChannel } from './orderForm'\nimport { toggleSalesChannel } from './toggleSalesChannel'\nimport { isSalesChannelUpdate } from './isSalesChannelUpdate'\n\nexport const mutations = {\n updateSalesChannel,\n saveBindingInfo,\n toggleSalesChannel,\n}\n\nexport const queries = {\n bindingInfo,\n isSalesChannelUpdate,\n}\n\n```"
}
] |
code_binding-selector_bb3a8233
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/typings/bindings.d.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface Binding {\n id: string\n defaultLocale: string\n canonicalBaseAddress: string\n extraContext: {\n portal: {\n salesChannel: string\n }\n }\n}\n\ninterface SalesChannelResponse {\n isSalesChannelUpdate: boolean\n}\n\ninterface TenantInfoResponse {\n tenantInfo: {\n bindings: Binding[]\n }\n}\n\ninterface BindingInfoResponse {\n bindingInfo: BindingsSaved[]\n}\n\ninterface BindingTranslation {\n id: string\n label: string\n salesChannel: string\n defaultLocale: string\n canonicalBaseAddress: string\n hide: boolean\n}\n\ninterface DataLocaleTypes {\n [key: string]: string\n}\n\ninterface BindingsSaved {\n bindingId: string\n show: boolean\n translatedLocales: BindingTranslation[]\n externalRedirectData: ExternalRedirectData | null\n customFlagData: CustomFlagData | null\n}\n\ninterface UpdateSalesChannelVariables {\n salesChannel: string\n orderFormId: string\n}\n\ninterface AlternateHrefsVariables {\n id: string\n type: string\n}\n\ninterface BindingsByBindingId {\n [bindingId: string]: TranslationsAndSettings[]\n}\n\ninterface ExternalRedirectData {\n url: string\n redirectUrl: boolean\n}\n\ninterface CustomFlagData {\n url: string\n isCustom: boolean\n}\n\ninterface TranslationsAndSettings extends BindingTranslation {\n externalRedirectData: ExternalRedirectData | null\n customFlagData: CustomFlagData | null\n}\n\ninterface ShowBindings {\n [key: string]: boolean\n}\n\ntype FlagDisplay = 'text' | 'flag' | 'combined'\n\ntype SettingType = 'externalRedirectData' | 'customFlagData'\n\n```"
}
] |
code_binding-selector_77a1da87
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/typings/rewriter.d.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface QueryInternal {\n internal: {\n routes: [RoutesByBinding]\n }\n}\n\ninterface RoutesByBinding {\n binding: string\n route: string\n}\n\n```"
}
] |
code_binding-selector_1d9a5637
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/typings/window.d.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface Window extends Window {\n __RUNTIME__: {\n segmentToken: string\n }\n}\n\n```"
}
] |
code_binding-selector_677b64f0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/typings/graphql.d.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.gql' {\n import type { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\n```"
}
] |
code_binding-selector_58db5d29
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/utils/index.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/**\n * filterBingings function filters out the bindings that should not be displayed based on admin setting.\n * It returns an array with objects that have the binding Id's as keys and an array with the translations for that binding as values.\n */\n\nconst filterBindings = ({\n bindingInfo = [],\n}: BindingInfoResponse): BindingsByBindingId[] => {\n const bindingsById = []\n\n const bindnigsToShow: Record<string, boolean> = {}\n\n const bindingExternalRedirect: Record<\n string,\n ExternalRedirectData | null\n > = {}\n\n const bindingCustomFlag: Record<string, CustomFlagData | null> = {}\n\n for (const binding of bindingInfo) {\n if (binding.show) {\n bindnigsToShow[binding.bindingId] = true\n bindingExternalRedirect[binding.bindingId] = binding.externalRedirectData\n bindingCustomFlag[binding.bindingId] = binding.customFlagData\n }\n }\n\n for (const binding of bindingInfo) {\n if (binding.show) {\n const bindingIdAndLabels = {\n [binding.bindingId]: binding.translatedLocales\n // filter out translations for bindings set to not show\n .filter(({ id }) => bindnigsToShow[id])\n // map over the left ones to add externalRedirect info\n .map((translation) => {\n const externalRedirectData = bindingExternalRedirect[translation.id]\n const customFlagData = bindingCustomFlag[translation.id]\n\n return {\n ...translation,\n externalRedirectData,\n customFlagData,\n }\n }),\n }\n\n bindingsById.push(bindingIdAndLabels)\n }\n }\n\n return bindingsById\n}\n\n/**\n * Based on a binding Id, this function returns the information for all bindings for the binding Id passed in, with the translated labels as its value\n */\nconst findBinding = ({\n filteredBindings,\n selectedBindingId,\n}: {\n filteredBindings: BindingsByBindingId[]\n selectedBindingId: string\n}) => {\n return filteredBindings.find(\n (binding) => Object.keys(binding)[0] === selectedBindingId\n )\n}\n\n/**\n * This function gets the translation for the current binding, returning the selected one and all information for the other binidngs\n */\n\nconst filterCurrentAndListBinding = ({\n bindingsById,\n selectedBindingId,\n}: {\n bindingsById: BindingsByBindingId\n selectedBindingId: string\n}) => {\n const currentList = bindingsById[selectedBindingId]\n const currentBinding = currentList.find(({ id }) => id === selectedBindingId)\n\n return { currentList, currentBinding }\n}\n\nexport const getCurrentBindingAndList = ({\n bindingData,\n selectedBindingId,\n}: {\n bindingData: BindingInfoResponse\n selectedBindingId: string\n}) => {\n const filteredBindings = filterBindings(bindingData)\n const bindindFound = findBinding({\n filteredBindings,\n selectedBindingId,\n })\n\n if (bindindFound) {\n return filterCurrentAndListBinding({\n bindingsById: bindindFound,\n selectedBindingId,\n })\n }\n}\n\nexport const removeBindingAdmin = (bindings: Binding[] = []): Binding[] => {\n return bindings.filter(\n (binding) => binding.canonicalBaseAddress.split('/')[1] !== 'admin'\n )\n}\n\ninterface CreateQueryStringArgs {\n isMyVtex: boolean\n canonicalBaseAddress: string\n keepSalesChannel: boolean\n salesChannel?: string\n}\n\nconst createQueryString = ({\n isMyVtex,\n canonicalBaseAddress,\n keepSalesChannel,\n salesChannel,\n}: CreateQueryStringArgs): string => {\n const bindingAddressQueryString = `__bindingAddress=${canonicalBaseAddress}`\n\n // Add `sc` search string will force the session to be that salesChannel\n const salesChannelQueryString = keepSalesChannel ? `sc=${salesChannel}` : ''\n\n if (isMyVtex) {\n return keepSalesChannel\n ? `?${bindingAddressQueryString}&${salesChannelQueryString}`\n : `?${bindingAddressQueryString}`\n }\n\n return keepSalesChannel ? `?${salesChannelQueryString}` : ''\n}\n\ninterface RedirectUrlArgs {\n canonicalBaseAddress: string\n hostname: Window['location']['hostname']\n protocol: Window['location']['protocol']\n path: string\n hash: string\n pageType: string\n keepSalesChannel?: boolean\n salesChannel?: string\n}\n\nexport const isMyAccount = (pageType: string): boolean =>\n pageType === 'store.account'\n\nexport const createRedirectUrl = ({\n canonicalBaseAddress,\n hostname,\n protocol,\n path,\n hash,\n pageType,\n keepSalesChannel = false,\n salesChannel,\n}: RedirectUrlArgs): string => {\n const isMyVtex = hostname.indexOf('myvtex') !== -1\n\n const myAccount = isMyAccount(pageType)\n\n const queryString = createQueryString({\n keepSalesChannel,\n salesChannel,\n canonicalBaseAddress,\n isMyVtex,\n })\n\n return `${protocol}//${\n isMyVtex ? hostname : canonicalBaseAddress.replace(/\\/$/, '')\n }${!myAccount ? path : '/account'}${queryString}${hash}`\n}\n\ninterface MatchRoute {\n currentBindingId: string\n routes: [RoutesByBinding] | []\n}\n\nexport const getMatchRoute = ({\n currentBindingId,\n routes,\n}: MatchRoute): string => {\n const { route } =\n routes.find(\n ({ binding }: { binding: string }) => binding === currentBindingId\n ) ?? {}\n\n return route ?? ''\n}\n\nexport const transformUserRouteId = (id: string): string => {\n return id.replace('custom#', 'custom::')\n}\n\nexport const setShowValues = (bindingList: BindingsSaved[]): ShowBindings => {\n return bindingList.reduce((acc, cur) => {\n return {\n ...acc,\n [cur.bindingId]: cur.show,\n }\n }, {})\n}\n\nexport const hasAllTranslations = ({\n bindingsToShow,\n translatedBindings,\n}: {\n bindingsToShow: string[]\n translatedBindings: BindingTranslation[]\n}): boolean => {\n const labelMap = new Map<string, string>()\n const hideLabelMap = new Map<string, boolean>()\n\n for (const { id, label, hide } of translatedBindings) {\n labelMap.set(id, label)\n hideLabelMap.set(id, hide)\n }\n\n for (const bindingId of bindingsToShow) {\n if (\n !labelMap.has(bindingId) ||\n (!hideLabelMap.get(bindingId) && !labelMap.get(bindingId))\n ) {\n return false\n }\n }\n\n return true\n}\n\nexport const createBindingsToLabel = (\n bindings: Binding[],\n currentTranslations: BindingTranslation[]\n): Record<string, BindingTranslation> => {\n const translationsMap: Record<string, Partial<BindingTranslation>> = {}\n\n for (const translation of currentTranslations) {\n translationsMap[translation.id] = {\n id: translation.id,\n label: translation.label,\n hide: !!translation.hide,\n }\n }\n\n return bindings.reduce((map, binding) => {\n const staticInfo = {\n canonicalBaseAddress: binding.canonicalBaseAddress,\n salesChannel: String(binding.extraContext.portal.salesChannel),\n defaultLocale: binding.defaultLocale,\n }\n\n if (translationsMap[binding.id]) {\n return {\n ...map,\n [binding.id]: {\n ...translationsMap[binding.id],\n ...staticInfo,\n },\n }\n }\n\n return {\n ...map,\n [binding.id]: {\n id: binding.id,\n label: '',\n hide: false,\n ...staticInfo,\n },\n }\n }, {})\n}\n\n```"
}
] |
code_binding-selector_826498d7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/components/BindingSelectorDropdown.tsx from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useState, useRef, useEffect } from 'react'\nimport type { FC } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport Spinner from './Spinner'\nimport LabelOption from './LabelsFlags'\n\ninterface Props {\n currentBinding: TranslationsAndSettings\n bindingInfo: TranslationsAndSettings[]\n onSelectBinding: (selectedBinding: TranslationsAndSettings) => void\n isLoading: boolean\n display: FlagDisplay\n}\n\nconst CSS_HANDLES = [\n 'list',\n 'listElement',\n 'container',\n 'active',\n 'relativeContainer',\n 'button',\n 'buttonText',\n] as const\n\nconst BindingSelectorDropdown: FC<Props> = ({\n currentBinding,\n bindingInfo,\n onSelectBinding,\n isLoading,\n display,\n}) => {\n const [open, setOpen] = useState<boolean>(false)\n const handles = useCssHandles(CSS_HANDLES)\n const relativeContainer = useRef<HTMLDivElement | null>(null)\n\n const handleOutsideClick = (e: MouseEvent) => {\n if (!relativeContainer.current?.contains(e.target as Node)) {\n setOpen(false)\n }\n }\n\n useEffect(() => {\n document.addEventListener('mousedown', handleOutsideClick)\n\n return () => {\n document.removeEventListener('mousedown', handleOutsideClick)\n }\n }, [])\n\n const handleClick = () => {\n setOpen(!open)\n }\n\n const handleSelection = (binding: TranslationsAndSettings) => {\n setOpen(false)\n onSelectBinding(binding)\n }\n\n return (\n <div\n className={`${handles.container} ${\n open ? handles.active : ''\n } flex items-center justify-center w3 relative`}\n >\n <div\n ref={relativeContainer}\n className={`${handles.relativeContainer} relative flex justify-center`}\n >\n {isLoading ? (\n <Spinner />\n ) : (\n <>\n <button\n type=\"button\"\n onClick={handleClick}\n className={`${handles.button} link pa3 bg-transparent bn flex items-center pointer c-on-base`}\n >\n <span className={`${handles.buttonText}`}>\n <LabelOption\n binding={currentBinding}\n display={display}\n flag={currentBinding.customFlagData}\n />\n </span>\n </button>\n <ul\n hidden={!open}\n className={`absolute z-9999 list top-1 ph0 mh0 mt5 bg-base ${handles.list}`}\n >\n {bindingInfo\n .filter((binding) => {\n return binding.id !== currentBinding.id && !binding.hide\n })\n .map((binding) => (\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n <li\n key={binding.id}\n className={`${handles.listElement} t-action--small pointer f5 pa3 hover-bg-muted-5 tc`}\n onClick={() => {\n handleSelection(binding)\n }}\n onKeyDown={() => {\n handleSelection(binding)\n }}\n onMouseDown={(e) => e.preventDefault()}\n >\n <LabelOption\n binding={binding}\n display={display}\n flag={binding.customFlagData}\n />\n </li>\n ))}\n </ul>\n </>\n )}\n </div>\n </div>\n )\n}\n\nexport default BindingSelectorDropdown\n\n```"
}
] |
code_binding-selector_150daea5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/components/BindingSelectorSelect.tsx from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useState, useEffect } from 'react'\nimport { EXPERIMENTAL_Select as Select } from 'vtex.styleguide'\n\ninterface Props {\n bindingList: TranslationsAndSettings[]\n currentBinding: TranslationsAndSettings\n onSelectBinding: (selectedBinding: TranslationsAndSettings) => void\n isLoading: boolean\n}\n\nconst BindingSelectorSelect = ({\n bindingList,\n currentBinding,\n onSelectBinding,\n isLoading,\n}: Props) => {\n const [currentBindingId, setCurrentBindingId] = useState(currentBinding.id)\n\n useEffect(() => {\n setCurrentBindingId(currentBinding.id)\n }, [currentBinding.id])\n\n /* memoize it */\n const bindings = bindingList.map((binding) => {\n return { label: binding.label, value: binding.id }\n })\n\n /* Value of the select.\n value: PropTypes.oneOfType([OptionShape, OptionsShape]) */\n const selectedBinding = bindings.find(({ value }) => {\n return value === currentBindingId\n })\n\n const handleChange = (selectedBindingId: string) => {\n setCurrentBindingId(selectedBindingId)\n onSelectBinding(\n bindingList[bindingList.findIndex(({ id }) => id === selectedBindingId)]\n )\n }\n\n return (\n <Select\n size=\"small\"\n options={bindings}\n value={[selectedBinding]}\n loading={isLoading}\n multi={false}\n clearable={false}\n searchable={false}\n onChange={(e: any) => {\n handleChange(e.value)\n }}\n />\n )\n}\n\nexport default BindingSelectorSelect\n\n```"
}
] |
code_binding-selector_e6a8b6b7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/components/BindingSelectorList.tsx from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useState } from 'react'\nimport type { FC } from 'react'\nimport { Button, ButtonGroup } from 'vtex.styleguide'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport LabelOption from './LabelsFlags'\n\nconst CSS_HANDLES = ['listContainer'] as const\n\ninterface Props {\n bindingList: TranslationsAndSettings[]\n onSelectBinding: (selectedBinding: TranslationsAndSettings) => void\n currentBinding: TranslationsAndSettings\n display: FlagDisplay\n isLoading: boolean\n}\n\nconst BindingSelectorList: FC<Props> = ({\n bindingList,\n onSelectBinding,\n currentBinding,\n display,\n isLoading,\n}) => {\n const [loading, setLoading] = useState(false)\n const handles = useCssHandles(CSS_HANDLES)\n\n const mappedBindings = bindingList\n .filter((binding) => {\n return !binding.hide\n })\n .map((binding) => {\n const flag = binding.customFlagData\n\n return (\n <Button\n key={binding.id}\n disabled={binding.id === currentBinding.id}\n isLoading={(loading && binding.id === currentBinding.id) || isLoading}\n onClick={() => {\n onSelectBinding(binding)\n setLoading(true)\n }}\n >\n <LabelOption binding={binding} display={display} flag={flag} />\n </Button>\n )\n })\n\n return (\n <div className={`${handles.listContainer}`}>\n <ButtonGroup buttons={mappedBindings} />\n </div>\n )\n}\n\nexport default BindingSelectorList\n\n```"
}
] |
code_binding-selector_611ef4fe
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/components/LabelsFlags.tsx from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { CountryFlag } from 'vtex.country-flags'\n\ninterface Props {\n binding: TranslationsAndSettings\n display: FlagDisplay\n flag: CustomFlagData | null\n}\n\nconst LabelOption = ({ binding, display, flag }: Props) => {\n const locale = binding.defaultLocale.substring(3, 5).toUpperCase()\n\n const flagToDisplay = () =>\n flag?.isCustom && flag.url ? (\n <img\n src={flag.url}\n alt=\"A flag of the binding's locale\"\n width=\"24\"\n height=\"24\"\n style={{ maxWidth: 24, maxHeight: 24 }}\n />\n ) : (\n <CountryFlag iso2={locale} />\n )\n\n if (display === 'flag') {\n return flagToDisplay()\n }\n\n if (display === 'combined') {\n return (\n <>\n {flagToDisplay()}\n <span className=\"ml3\">{binding.label}</span>\n </>\n )\n }\n\n return <span>{binding.label}</span>\n}\n\nexport default LabelOption\n\n```"
}
] |
code_binding-selector_4890d293
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/components/Spinner.tsx from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { Spinner as VtexSpinner } from 'vtex.styleguide'\n\nconst CSS_HANDLES = ['loadingContainer'] as const\n\nconst Spinner = () => {\n const handles = useCssHandles(CSS_HANDLES)\n\n return (\n <div className={handles.loadingContainer}>\n <VtexSpinner color=\"currentColor\" size={26} />\n </div>\n )\n}\n\nexport default Spinner\n\n```"
}
] |
code_binding-selector_f20accbe
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/graphql/saveBindingInfo.gql from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\n#import './bindingInfoFragment.gql'\n\nmutation saveBindingInfo($data: [BindingsInput]) {\n saveBindingInfo(data: $data) {\n ...BindingInfoFragment\n }\n}\n\n```"
}
] |
code_binding-selector_6219c8b5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/graphql/toggleSalesChannel.gql from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation toggleSalesChannel($salesChannel: Boolean) {\n toggleSalesChannel(salesChannel: $salesChannel)\n}\n\n```"
}
] |
code_binding-selector_fd589c42
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/graphql/bindingInfo.gql from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\n#import './bindingInfoFragment.gql'\n\nquery bindingInfo {\n bindingInfo @context(provider: \"vtex.binding-selector\") {\n ...BindingInfoFragment\n }\n}\n\n```"
}
] |
code_binding-selector_55db0cfa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/graphql/getOrderForm.gql from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery getOrderForm {\n orderForm @context(provider: \"vtex.store-graphql\") {\n salesChannel\n orderFormId\n items {\n id\n }\n }\n}\n\n```"
}
] |
code_binding-selector_e041064b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/graphql/uploadFile.gql from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation UploadFile($file: Upload!) {\n uploadFile(file: $file) {\n fileUrl\n }\n}\n\n```"
}
] |
code_binding-selector_a75a93d8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/graphql/updateSalesChannel.gql from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation updateSalesChannel($orderFormId: ID, $salesChannel: String) {\n updateSalesChannel(orderFormId: $orderFormId, salesChannel: $salesChannel)\n @context(provider: \"vtex.binding-selector\") {\n orderFormId\n items {\n quantity\n uniqueId\n }\n }\n}\n\n```"
}
] |
code_binding-selector_c11ecddb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/graphql/isSalesChannelUpdate.gql from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery isSalesChannelUpdate {\n isSalesChannelUpdate\n}\n\n```"
}
] |
code_binding-selector_beca407b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/graphql/bindingInfoFragment.gql from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nfragment BindingInfoFragment on TranslatedInfoOutput {\n bindingId\n show\n translatedLocales {\n id\n label\n defaultLocale\n canonicalBaseAddress\n salesChannel\n hide\n }\n externalRedirectData {\n url\n redirectUrl\n }\n customFlagData {\n isCustom\n url\n }\n}\n\n```"
}
] |
code_binding-selector_c175feba
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/graphql/getSalesChannel.gql from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery getSalesChannel {\n tenantInfo @context(provider: \"vtex.tenant-graphql\") {\n bindings {\n id\n defaultLocale\n extraContext\n canonicalBaseAddress\n }\n }\n}\n\n```"
}
] |
code_binding-selector_e608485f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/graphql/alternateHrefs.gql from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery alternateHrefs($id: String!, $type: String!) {\n internal @context(provider: \"vtex.rewriter\") {\n routes(locator: { id: $id, type: $type }) {\n binding\n route\n }\n }\n}\n\n```"
}
] |
code_binding-selector_ebc6ade9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/hooks/useBindings.ts from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useCallback, useEffect, useState } from 'react'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { useQuery } from 'react-apollo'\n\nimport getBindingInfo from '../graphql/bindingInfo.gql'\nimport { getCurrentBindingAndList } from '../utils'\n\nexport const useBinding = () => {\n const [bindingList, setBindingList] = useState<TranslationsAndSettings[]>([])\n\n const [currentBinding, setCurrentBinding] = useState<TranslationsAndSettings>(\n {} as TranslationsAndSettings\n )\n\n const {\n data: bindingData,\n loading: loadingBindings,\n error: bindingsError,\n } = useQuery<BindingInfoResponse>(getBindingInfo, {\n ssr: false,\n })\n\n const { binding: runtimeBinding } = useRuntime()\n\n const setCurrentBindingInfo = useCallback(\n (selectedBindingId: string): void => {\n if (bindingData) {\n const bindingInfo = getCurrentBindingAndList({\n bindingData,\n selectedBindingId,\n })\n\n if (bindingInfo) {\n setBindingList(bindingInfo.currentList)\n setCurrentBinding(\n bindingInfo.currentBinding ?? ({} as TranslationsAndSettings)\n )\n }\n }\n },\n [bindingData]\n )\n\n /**\n * This effects uses sets the current binding user is on\n */\n useEffect(() => {\n if (bindingData && runtimeBinding?.id) {\n setCurrentBindingInfo(runtimeBinding.id)\n }\n }, [bindingData, runtimeBinding, setCurrentBindingInfo])\n\n return {\n data: {\n currentBinding,\n bindingList,\n bindingsError,\n loadingBindings,\n },\n actions: {\n setCurrentBindingInfo,\n },\n }\n}\n\n```"
}
] |
code_binding-selector_72f0a0dc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/components/admin/AdminBindingSection.tsx from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useState, useEffect } from 'react'\nimport type { FC, SyntheticEvent, FormEvent } from 'react'\nimport { FormattedMessage, useIntl } from 'react-intl'\nimport {\n Toggle,\n Button,\n Divider,\n Collapsible,\n Input,\n Tooltip,\n IconExternalLink,\n} from 'vtex.styleguide'\nimport { CountryFlag } from 'vtex.country-flags'\n\nimport CustomFlagSetting from './CustomFlagSetting'\n\nexport interface BindingSectionProps {\n modalControl: (modalOpen: boolean) => void\n modalOpen: boolean\n setChosenBinding: (binding: Binding) => void\n setShowBindings: (id: string) => void\n setAdvancedSettings: (\n bindingId: string,\n type: SettingType,\n extraData: ExternalRedirectData | CustomFlagData\n ) => Promise<void>\n}\n\ninterface BindingSectionPropsLocal extends BindingSectionProps {\n i: number\n binding: Binding\n configSettings: BindingsSaved\n hasAllabels: boolean\n}\n\nconst AdminBindingSection: FC<BindingSectionPropsLocal> = ({\n binding,\n modalControl,\n modalOpen,\n setChosenBinding,\n setShowBindings,\n setAdvancedSettings,\n configSettings,\n hasAllabels,\n i,\n}) => {\n const [showAdvConfig, setShowAdvConfig] = useState(false)\n const [showRedirectUrl, setShowRedirectUrl] = useState(false)\n const [urlToRedirect, setUrlToRedirect] = useState('')\n const [edit, setEdit] = useState(false)\n const intl = useIntl()\n\n const flag = configSettings.customFlagData\n\n useEffect(() => {\n const { externalRedirectData } = configSettings\n\n if (externalRedirectData) {\n const { redirectUrl, url } = externalRedirectData\n\n if (redirectUrl) {\n setShowRedirectUrl(redirectUrl)\n setUrlToRedirect(url)\n setEdit(true)\n\n return\n }\n }\n\n setShowRedirectUrl(false)\n setUrlToRedirect('')\n }, [configSettings, showAdvConfig])\n\n const handleShowRedirectToggle = () => {\n setShowRedirectUrl(!showRedirectUrl)\n if (showRedirectUrl) {\n setAdvancedSettings(binding.id, 'externalRedirectData', {\n url: '',\n redirectUrl: false,\n })\n } else {\n setEdit(false)\n }\n }\n\n const handleChangeRedirectUrl = (event: SyntheticEvent) => {\n setUrlToRedirect((event.currentTarget as HTMLInputElement).value)\n }\n\n const handleFlagToggle = (active: boolean) => {\n /* We should always try to keep the original url */\n setAdvancedSettings(binding.id, 'customFlagData', {\n ...(flag?.url ? { url: flag.url } : { url: '' }),\n isCustom: active,\n })\n }\n\n const handleSubmitRedirect = (e: FormEvent) => {\n e.preventDefault()\n setAdvancedSettings(binding.id, 'externalRedirectData', {\n url: urlToRedirect,\n redirectUrl: showRedirectUrl,\n })\n }\n\n const handleSubmitFlag = async (inmutableUrl: string) => {\n await setAdvancedSettings(binding.id, 'customFlagData', {\n url: inmutableUrl,\n isCustom: true,\n })\n }\n\n const handleEditMode = (e: MouseEvent) => {\n e.preventDefault()\n setEdit(!edit)\n }\n\n return (\n <>\n <div className=\"mt6\">\n <Divider orientation=\"horizontal\" />\n </div>\n <section\n key={binding.id}\n className=\"flex items-center justify-between mb3\"\n >\n <div className=\"flex items-center flex-basis-50\">\n <span className=\"mr4\">\n <Button disabled size=\"small\">\n {flag?.isCustom && flag?.url ? (\n <img\n src={flag.url}\n alt=\"A flag of the binding's locale\"\n width=\"24\"\n height=\"24\"\n style={{ maxWidth: 24, maxHeight: 24 }}\n />\n ) : (\n <CountryFlag\n iso2={binding.defaultLocale.substring(3, 5).toUpperCase()}\n />\n )}\n </Button>\n </span>\n <div className=\"flex flex-column mv5 flex-grow-1 flex-basis-33\">\n <span className=\"b\">\n <FormattedMessage\n id=\"admin/store\"\n values={{\n index: i + 1,\n address: binding.canonicalBaseAddress,\n }}\n />\n </span>\n <span>\n <FormattedMessage\n id=\"admin/locale\"\n values={{ locale: binding.defaultLocale }}\n />\n </span>\n </div>\n </div>\n\n <div className=\"flex items-center flex-basis-50 justify-end\">\n {showRedirectUrl && (\n <div>\n <Tooltip\n label={\n <FormattedMessage id=\"admin/redirect-url.tooltip-label\" />\n }\n >\n <span className=\"c-on-base pointer\">\n <IconExternalLink />\n </span>\n </Tooltip>\n </div>\n )}\n\n <div className=\"flex-basis-50 tc\">\n <Button\n disabled={!configSettings.show}\n onClick={() => {\n modalControl(!modalOpen)\n setChosenBinding(binding)\n }}\n size=\"small\"\n variation=\"secondary\"\n >\n <FormattedMessage id=\"admin/action\" />\n </Button>\n {configSettings.show && !hasAllabels ? (\n <p className=\"absolute c-danger i-s\">\n <FormattedMessage id=\"admin/missing-labels\" />\n </p>\n ) : null}\n </div>\n\n <div className=\"flex flex-basis-25 justify-end\">\n <Toggle\n checked={configSettings.show}\n semantic\n label={\n configSettings.show ? (\n <FormattedMessage id=\"admin/hide-binding\" />\n ) : (\n <FormattedMessage id=\"admin/show-binding\" />\n )\n }\n onChange={() => {\n setShowBindings(binding.id)\n if (!configSettings.show) {\n setChosenBinding(binding)\n } else {\n setChosenBinding({} as Binding)\n }\n }}\n />\n </div>\n </div>\n </section>\n <Collapsible\n header={\n <span className=\"c-action-primary hover-c-action-primary fw5\">\n <FormattedMessage id=\"admin/advanced-settings\" />\n </span>\n }\n isOpen={showAdvConfig}\n onClick={() => setShowAdvConfig(!showAdvConfig)}\n >\n <div className=\"mt7\">\n <Toggle\n checked={showRedirectUrl}\n label={<FormattedMessage id=\"admin/set-external-url\" />}\n onChange={handleShowRedirectToggle}\n />\n <form onSubmit={handleSubmitRedirect} className=\"mt4 flex\">\n <div className=\"width-70\">\n <Input\n value={urlToRedirect}\n disabled={!showRedirectUrl || edit}\n placeholder={intl.formatMessage({\n id: 'admin/external-url-placeholder',\n })}\n onChange={handleChangeRedirectUrl}\n pattern=\"^https?:\\/\\/.+\"\n helpText={<FormattedMessage id=\"admin/external-url-helper-text\" />}\n />\n </div>\n <div className=\"ml5\">\n {edit ? (\n <Button\n type=\"button\"\n variation=\"secondary\"\n disabled={!urlToRedirect}\n onClick={handleEditMode}\n >\n <FormattedMessage id=\"admin/edit-url\" />\n </Button>\n ) : (\n <Button type=\"submit\" disabled={!urlToRedirect}>\n <FormattedMessage id=\"admin/save-url\" />\n </Button>\n )}\n </div>\n </form>\n </div>\n <div className=\"mt7\">\n <CustomFlagSetting\n customFlag={Boolean(flag?.isCustom)}\n handleFlagToggle={handleFlagToggle}\n handleSubmitFlag={handleSubmitFlag}\n />\n </div>\n </Collapsible>\n </>\n )\n}\n\nexport default AdminBindingSection\n\n```"
}
] |
code_binding-selector_1981b364
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/components/admin/Selector.tsx from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React, { useState, useEffect } from 'react'\nimport { useQuery, useMutation } from 'react-apollo'\nimport { FormattedMessage } from 'react-intl'\nimport { Toggle } from 'vtex.styleguide'\n\nimport Spinner from '../Spinner'\nimport FormDialog from './FormDialog'\nimport { removeBindingAdmin } from '../../utils'\nimport AdminBindingList from './AdminBindingList'\nimport bindingInfo from '../../graphql/bindingInfo.gql'\nimport saveBindingInfo from '../../graphql/saveBindingInfo.gql'\nimport getSalesChannel from '../../graphql/getSalesChannel.gql'\nimport toggleSalesChannel from '../../graphql/toggleSalesChannel.gql'\nimport isSalesChannelUpdate from '../../graphql/isSalesChannelUpdate.gql'\n\ninterface DataMutation {\n data: BindingsSaved[]\n}\n\ninterface MutationResponse {\n saveBindingInfo: BindingsSaved[]\n}\n\nconst Selector: FC = () => {\n const [updateSalesChannel, setUpdateSalesChannel] = useState<boolean>(false)\n const [modalOpen, setModalOpen] = useState<boolean>(false)\n const [chosenBinding, setChosenBinding] = useState<Binding>({} as Binding)\n const [fetchedData, setFetchedData] = useState<BindingsSaved[]>([])\n const { data: bindingData } = useQuery<TenantInfoResponse>(getSalesChannel, {\n ssr: false,\n })\n\n const [toggleSales] = useMutation<SalesChannelResponse>(toggleSalesChannel)\n\n const { data: translatedData, loading } = useQuery<BindingInfoResponse>(\n bindingInfo,\n {\n ssr: false,\n }\n )\n\n const [saveTranslatedInfo] = useMutation<MutationResponse, DataMutation>(\n saveBindingInfo\n )\n\n const { data: salesData } = useQuery<SalesChannelResponse>(\n isSalesChannelUpdate,\n {\n ssr: false,\n }\n )\n\n useEffect(() => {\n if (translatedData) {\n setFetchedData(translatedData?.bindingInfo ?? [])\n }\n }, [translatedData])\n\n useEffect(() => {\n if (salesData) {\n const salesChannelValue = salesData?.isSalesChannelUpdate ?? false\n\n setUpdateSalesChannel(salesChannelValue)\n }\n }, [salesData])\n\n const handleUpdateSalesChannel = () => {\n setUpdateSalesChannel(!updateSalesChannel)\n toggleSales({ variables: { salesChannel: !updateSalesChannel } })\n }\n\n const handleOnClose = () => setModalOpen(!modalOpen)\n\n const filteredBindings = removeBindingAdmin(bindingData?.tenantInfo.bindings)\n\n const handleShowBindings = async (bindingId: string) => {\n let bindingFound = false\n let currentToggleStatus = false\n const modifiedBindings = fetchedData.map((binding) => {\n if (binding.bindingId === bindingId) {\n bindingFound = true\n currentToggleStatus = binding.show\n const modifiedBinding = {\n ...binding,\n show: !binding.show,\n }\n\n return modifiedBinding\n }\n\n return binding\n })\n\n if (!currentToggleStatus) {\n setModalOpen(true)\n }\n\n const bindingsToSave = bindingFound\n ? modifiedBindings\n : [\n ...fetchedData,\n {\n bindingId,\n show: true,\n translatedLocales: [],\n externalRedirectData: null,\n customFlagData: null,\n },\n ]\n\n try {\n const savedData = await saveTranslatedInfo({\n variables: { data: bindingsToSave },\n })\n\n if (savedData.data) {\n setFetchedData(savedData.data.saveBindingInfo)\n }\n } catch (e) {\n console.error('error saving data', { e })\n }\n }\n\n const handleSetAdvancedSettings = async (\n bindingId: string,\n type: SettingType,\n extraData: ExternalRedirectData | CustomFlagData\n ): Promise<void> => {\n const transformedData = fetchedData.map((binding) => {\n if (binding.bindingId === bindingId) {\n return {\n ...binding,\n ...(extraData && { [type]: extraData }),\n }\n }\n\n return binding\n })\n\n await saveTranslatedInfo({ variables: { data: transformedData } })\n setFetchedData(transformedData)\n }\n\n const bindingsToShow = fetchedData\n .filter(({ show }) => show)\n .map(({ bindingId }) => bindingId)\n\n return (\n <div>\n <FormDialog\n open={modalOpen}\n handleOnClose={handleOnClose}\n chosenBinding={chosenBinding}\n bindings={filteredBindings ?? []}\n bindingInfoQueryData={fetchedData ?? []}\n setFetchedData={setFetchedData}\n />\n <Toggle\n checked={updateSalesChannel}\n label={<FormattedMessage id=\"admin/label\" />}\n onChange={handleUpdateSalesChannel}\n helpText={<FormattedMessage id=\"admin/description\" />}\n />\n {loading ? (\n <div className=\"w100 flex justify-center align-center pa7 ma7\">\n <Spinner />\n </div>\n ) : (\n <AdminBindingList\n bindings={filteredBindings}\n modalControl={setModalOpen}\n modalOpen={modalOpen}\n setChosenBinding={setChosenBinding}\n setShowBindings={handleShowBindings}\n setAdvancedSettings={handleSetAdvancedSettings}\n configSettingsList={fetchedData}\n bindingsToShow={bindingsToShow}\n />\n )}\n </div>\n )\n}\n\nexport default Selector\n\n```"
}
] |
code_binding-selector_0403085a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/components/admin/FormDialog.tsx from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport type { SyntheticEvent, FC } from 'react'\nimport React, { useState, useEffect } from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport { Modal, Button } from 'vtex.styleguide'\nimport { useMutation } from 'react-apollo'\n\nimport saveBindingInfo from '../../graphql/saveBindingInfo.gql'\nimport {\n removeBindingAdmin,\n setShowValues,\n createBindingsToLabel,\n} from '../../utils'\nimport AdminBindingLabelsList from './AdminBindingLabelsList'\n\ninterface FormDialogProps {\n open: boolean\n handleOnClose: () => void\n bindings: Binding[]\n chosenBinding: Binding\n bindingInfoQueryData: BindingsSaved[]\n setFetchedData: (binding: BindingsSaved[]) => void\n}\n\ninterface DataMutation {\n data: BindingsSaved[]\n}\n\nconst FormDialog: FC<FormDialogProps> = (props: FormDialogProps) => {\n const {\n open,\n handleOnClose,\n bindings,\n chosenBinding,\n bindingInfoQueryData,\n setFetchedData,\n } = props\n\n const [saveTranslatedInfo] = useMutation<BindingsSaved, DataMutation>(\n saveBindingInfo\n )\n\n const [translationsMap, setTranslationMap] = useState<\n Record<string, BindingTranslation>\n >({})\n\n const showBindings = setShowValues(bindingInfoQueryData)\n\n useEffect(() => {\n const bindingsToLabel = createBindingsToLabel(\n bindings,\n bindingInfoQueryData.find(\n (binding) => binding.bindingId === chosenBinding.id\n )?.translatedLocales ?? []\n )\n\n setTranslationMap(bindingsToLabel)\n }, [bindingInfoQueryData, bindings, chosenBinding.id])\n\n const handleChange = (event: SyntheticEvent) => {\n const { name, value } = event.target as HTMLInputElement\n\n setTranslationMap({\n ...translationsMap,\n [name]: {\n ...translationsMap[name],\n label: value,\n },\n })\n }\n\n const handleOnSave = () => {\n const transformedData = bindingInfoQueryData.map<BindingsSaved>(\n (binding) => {\n if (binding.bindingId === chosenBinding.id) {\n return {\n ...binding,\n translatedLocales: Object.values(translationsMap),\n }\n }\n\n return binding\n }\n )\n\n saveTranslatedInfo({ variables: { data: transformedData } })\n\n setFetchedData(transformedData)\n\n handleOnClose()\n }\n\n const bindingsToBeLabeled = removeBindingAdmin(bindings)\n\n const handleHideLabel = ({\n bindingId,\n status,\n }: {\n bindingId: string\n status: boolean\n }) => {\n setTranslationMap({\n ...translationsMap,\n [bindingId]: {\n ...translationsMap[bindingId],\n hide: status,\n },\n })\n }\n\n return (\n <Modal\n isOpen={open}\n title={<FormattedMessage id=\"admin/modal\" />}\n onClose={handleOnClose}\n bottomBar={\n <div className=\"flex\">\n <div className=\"pr4\">\n <Button variation=\"tertiary\" onClick={handleOnClose}>\n <FormattedMessage id=\"admin/cancel\" />\n </Button>\n </div>\n <div>\n <Button onClick={handleOnSave}>\n <FormattedMessage id=\"admin/save\" />\n </Button>\n </div>\n </div>\n }\n >\n <div className=\"pb6 pt3 flex w-100 flex-column justify-center items-center\">\n <AdminBindingLabelsList\n bindings={bindingsToBeLabeled}\n activeBindings={showBindings}\n handleChange={handleChange}\n translationsMap={translationsMap}\n handleHideLabel={handleHideLabel}\n />\n </div>\n </Modal>\n )\n}\n\nexport default FormDialog\n\n```"
}
] |
code_binding-selector_994c1f9e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/components/admin/AdminBindingLabelsList.tsx from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport type { SyntheticEvent } from 'react'\nimport React from 'react'\n\nimport FieldInput from './FieldInput'\n\nconst AdminBindingLabelsList = ({\n bindings = [],\n activeBindings,\n translationsMap,\n ...props\n}: {\n bindings: Binding[]\n activeBindings: Record<string, boolean>\n translationsMap: Record<string, BindingTranslation>\n handleChange: (e: SyntheticEvent) => void\n handleHideLabel: ({\n bindingId,\n status,\n }: {\n bindingId: string\n status: boolean\n }) => void\n}) => {\n return (\n <>\n {bindings.map((binding) => {\n return (\n <FieldInput\n key={binding.id}\n binding={binding}\n showValue={activeBindings[binding.id]}\n translationInfo={translationsMap[binding.id]}\n {...props}\n />\n )\n })}\n </>\n )\n}\n\nexport default AdminBindingLabelsList\n\n```"
}
] |
code_binding-selector_4825de26
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/components/admin/FieldInput.tsx from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport type { FC, SyntheticEvent } from 'react'\nimport React from 'react'\nimport { Input, Checkbox } from 'vtex.styleguide'\nimport { FormattedMessage } from 'react-intl'\n\ninterface FieldInputProps {\n binding: Binding\n handleChange: (e: SyntheticEvent) => void\n showValue: boolean\n translationInfo: BindingTranslation\n handleHideLabel: ({\n bindingId,\n status,\n }: {\n bindingId: string\n status: boolean\n }) => void\n}\n\nconst FieldInput: FC<FieldInputProps> = (props: FieldInputProps) => {\n const {\n binding,\n handleChange,\n showValue,\n handleHideLabel,\n translationInfo,\n } = props\n\n return (\n <div className=\"flex items-center justify-center w-100\">\n <div className=\"pa4 w-40\">\n <label>\n {binding.canonicalBaseAddress} ({binding.defaultLocale})\n </label>\n </div>\n <div className=\"pa4 w-50 flex items-center\">\n <Input\n disabled={!showValue || translationInfo.hide}\n required={showValue || !translationInfo.hide}\n name={binding.id}\n onChange={(e: SyntheticEvent) => handleChange(e)}\n value={translationInfo.label}\n />\n <div className=\"ml3 flex items-center\">\n <Checkbox\n disabled={!showValue}\n id={`hide-label-${binding.id}`}\n checked={!!translationInfo.hide}\n onChange={() =>\n handleHideLabel({\n status: !translationInfo.hide,\n bindingId: binding.id,\n })\n }\n />\n <label htmlFor={`hide-label-${binding.id}`} className=\"ml3\">\n <FormattedMessage id=\"admin/hide-label\" />\n </label>\n </div>\n </div>\n </div>\n )\n}\n\nexport default FieldInput\n\n```"
}
] |
code_binding-selector_cb209e65
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/components/admin/AdminBindingList.tsx from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport type { FC } from 'react'\n\nimport type { BindingSectionProps } from './AdminBindingSection'\nimport AdminBindingSection from './AdminBindingSection'\nimport { hasAllTranslations } from '../../utils'\n\ninterface BindingListProps extends BindingSectionProps {\n bindings: Binding[]\n configSettingsList: BindingsSaved[]\n bindingsToShow: string[]\n}\n\nconst BindingList: FC<BindingListProps> = ({\n bindings,\n configSettingsList,\n bindingsToShow,\n ...props\n}) => {\n return (\n <div>\n {bindings.map((binding, i) => {\n const configSettings =\n configSettingsList.find(\n ({ bindingId }) => bindingId === binding.id\n ) ?? ({} as BindingsSaved)\n\n const hasAllLabels = hasAllTranslations({\n bindingsToShow,\n translatedBindings: configSettings.translatedLocales ?? [],\n })\n\n return (\n <div key={binding.id}>\n <AdminBindingSection\n binding={binding}\n configSettings={configSettings}\n i={i}\n hasAllabels={hasAllLabels}\n {...props}\n />\n </div>\n )\n })}\n </div>\n )\n}\n\nexport default BindingList\n\n```"
}
] |
code_binding-selector_9f1751e1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of binding-selector/react/components/admin/CustomFlagSetting.tsx from the binding-selector VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useState } from 'react'\nimport type { FC } from 'react'\nimport { useMutation } from 'react-apollo'\nimport { FormattedMessage } from 'react-intl'\nimport {\n Toggle,\n ButtonWithIcon,\n IconEdit,\n Modal,\n Button,\n Dropzone,\n Alert,\n} from 'vtex.styleguide'\n\nimport UPLOAD_MUTATION from '../../graphql/uploadFile.gql'\n\nconst edit = <IconEdit />\n\n/* 512 KB */\nconst MAX_SIZE = 512000 as const\n\nconst RESET_ERROR = {\n error: false,\n size: 0,\n type: '',\n}\n\ninterface IncomingFile {\n uploadFile: { fileUrl: string }\n}\n\ntype Props = {\n customFlag: boolean\n handleFlagToggle: (active: boolean) => void\n handleSubmitFlag: (inmutableUrl: string) => Promise<void>\n}\n\n/**\n * Enables the advanced setting to upload a custom 'flag' as\n * an icon for the bindings.\n * @note Even when the user closes the modal when\n * uploading a file, it will still run on the background.\n * @param customFlag - controls weather the setting is\n * activated; a side effect of the display of the custom icon on\n * the binding summary\n * @param handleSubmitFlag - handler to update binding's settings\n */\nconst CustomFlagSetting: FC<Props> = ({\n customFlag = false,\n handleFlagToggle,\n handleSubmitFlag,\n}) => {\n const [hasCustomFlag, toggleSetting] = useState(customFlag)\n const [isOpen, toggleModal] = useState(false)\n const [canUpload, setCanUpload] = useState(false)\n const [uploadingFile, setUploading] = useState(false)\n const [flag, prepareFile] = useState({})\n const [alert, handleAlert] = useState(RESET_ERROR)\n\n /**\n * Save file (returns file's immutable URL)\n * @see file-manager-graphql\n */\n const [saveFile] = useMutation<IncomingFile>(UPLOAD_MUTATION, {\n variables: { file: flag },\n })\n\n const handleToggle = () => {\n toggleSetting(!hasCustomFlag)\n handleFlagToggle(!hasCustomFlag)\n }\n\n const dropRejected = (file: File[]) => {\n setCanUpload(false)\n handleAlert({\n error: true,\n size: Math.floor(file[0].size / 1000),\n type: file[0].type,\n })\n }\n\n const dropAccepted = (file: File[]) => {\n setCanUpload(true)\n prepareFile(file[0])\n }\n /**\n * @todo: Add toast to display success or error for the user\n * Not only here, but for all other saving operations\n */\n\n const handleUpload = async () => {\n setUploading(true)\n\n try {\n const { data, errors } = await saveFile()\n\n if (errors) {\n throw new Error('Error saving custom flag')\n }\n\n const { fileUrl } = data?.uploadFile ?? {}\n\n if (fileUrl) {\n /* This will trigger a parent re-render */\n await handleSubmitFlag(fileUrl)\n }\n } catch (e) {\n console.error('Error saving data', { e })\n } finally {\n setUploading(false)\n toggleModal(false)\n }\n }\n\n return (\n <>\n <Toggle\n label={<FormattedMessage id=\"admin/custom-flag.toggle\" />}\n checked={hasCustomFlag}\n onChange={() => handleToggle()}\n helpText={<FormattedMessage id=\"admin/custom-flag.helpText\" />}\n />\n {hasCustomFlag && (\n <div className=\"mt4\">\n <ButtonWithIcon\n onClick={() => toggleModal(!isOpen)}\n icon={edit}\n size=\"small\"\n >\n {<FormattedMessage id=\"admin/custom-flag.cta\" />}\n </ButtonWithIcon>\n </div>\n )}\n <Modal\n isOpen={isOpen}\n title={<FormattedMessage id=\"admin/custom-flag.modal-title\" />}\n size=\"auto\"\n onClose={() => {\n toggleModal(!isOpen)\n }}\n bottomBar={\n <Button onClick={() => handleUpload()} disabled={!canUpload}>\n <FormattedMessage id=\"admin/save\" />\n </Button>\n }\n >\n <div className=\"mb4\">\n {alert.error && (\n <div className=\"mb4\">\n <Alert onClose={() => handleAlert(RESET_ERROR)} type=\"error\">\n <FormattedMessage\n id=\"admin/custom-flag.modal-error\"\n values={{\n size: alert.size,\n type: alert.type,\n }}\n />\n </Alert>\n </div>\n )}\n <Dropzone\n accept=\"image/*\"\n onDropRejected={dropRejected}\n onDropAccepted={dropAccepted}\n onFileReset={() => {\n setCanUpload(false)\n }}\n isLoading={uploadingFile}\n maxSize={MAX_SIZE}\n >\n <div className=\"pt7\">\n <div id=\"modal-description\">\n <span className=\"f4\">\n <FormattedMessage id=\"admin/custom-flag.modal-dropzone-title\" />{' '}\n </span>\n <span className=\"f4 c-link\" style={{ cursor: 'pointer' }}>\n <FormattedMessage id=\"admin/custom-flag.modal-dropzone-cta\" />\n </span>\n <p className=\"f6 c-muted-2 tc\">\n <FormattedMessage\n id=\"admin/custom-flag.modal-dropzone-limit\"\n values={{\n max_size: MAX_SIZE / 1000,\n }}\n />\n </p>\n </div>\n </div>\n </Dropzone>\n </div>\n </Modal>\n </>\n )\n}\n\nexport default CustomFlagSetting\n\n```"
}
] |
code_store-newsletter_15cc0dde
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/messages/pt.json from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.newsletter-form.title\": \"Newsletter\",\n \"admin/editor.newsletter-input-email.title\": \"Campo de email\",\n \"admin/editor.newsletter-input-email.placeholderText.title\": \"Placeholder para campo de email\",\n \"admin/editor.newsletter-input-email.inputLabel.title\": \"Label para o campo de entrada de email\",\n \"admin/editor.newsletter-input-email.errorMessage.title\": \"Mensagem de erro\",\n \"admin/editor.newsletter-input-name.title\": \"Campo de nome\",\n \"admin/editor.newsletter-input-name.placeholderText.title\": \"Placeholder para campo de nome\",\n \"admin/editor.newsletter-input-name.inputLabel.title\": \"Label para o campo de entrada de nome\",\n \"admin/editor.newsletter-input-name.errorMessage.title\": \"Mensagem de erro\",\n \"admin/editor.newsletter-input-phone.title\": \"Campo de telefone\",\n \"admin/editor.newsletter-input-phone.placeholderText.title\": \"Placeholder para campo de telefone\",\n \"admin/editor.newsletter-input-phone.inputLabel.title\": \"Label para o campo de entrada de telefone\",\n \"admin/editor.newsletter-input-phone.errorMessage.title\": \"Mensagem de erro\",\n \"admin/editor.newsletter-checkbox-confirmation.title\": \"Confirmação\",\n \"admin/editor.newsletter-checkout-confirmation.checkboxLabel.title\": \"Label para a checkbox de confirmação\",\n \"admin/editor.newsletter-checkout-confirmation.firstLink.title\": \"Primeiro link a ser interpolado na label\",\n \"admin/editor.newsletter-checkout-confirmation.firstLink.url\": \"URL do primeiro link\",\n \"admin/editor.newsletter-checkout-confirmation.firstLink.text\": \"Texto do primeiro link\",\n \"admin/editor.newsletter-checkout-confirmation.secondLink.title\": \"Segundo link a ser interpolado na label\",\n \"admin/editor.newsletter-checkout-confirmation.secondLink.url\": \"URL do segundo link\",\n \"admin/editor.newsletter-checkout-confirmation.secondLink.text\": \"Texto do segundo link\",\n \"admin/editor.newsletter-submit.title\": \"Botão de submissão do formulário\",\n \"admin/editor.newsletter-submit.submitButtonLabel.title\": \"Texto do botão de submissão\",\n \"store/newsletter-input-email.placeholderText.default\": \"Endereço de email\",\n \"store/newsletter-input-email.errorMessage.default\": \"Email inválido\",\n \"store/newsletter-input-name.placeholderText.default\": \"Nome\",\n \"store/newsletter-input-name.errorMessage.default\": \"Nome inválido\",\n \"store/newsletter-input-phone.placeholderText.default\": \"Telefone\",\n \"store/newsletter-input-phone.errorMessage.default\": \"Telefone inválido\",\n \"store/newsletter-checkbox-confirmation.checkboxLabel.default\": \"Eu aceito receber essa newsletter.\",\n \"store/newsletter-submit.submitButtonLabel.default\": \"Inscrever-se\",\n \"store/newsletter-submit-success.default\": \"Obrigado!\",\n \"store/newsletter-submit-error.default\": \"Algo deu errado e não conseguimos efetuar seu cadastro.\"\n}\n\n```"
}
] |
code_store-newsletter_16c35790
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/messages/en.json from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.newsletter-form.title\": \"Newsletter\",\n \"admin/editor.newsletter-input-email.title\": \"Newsletter email input\",\n \"admin/editor.newsletter-input-email.placeholderText.title\": \"Email input placeholder\",\n \"admin/editor.newsletter-input-email.inputLabel.title\": \"Label for the email input\",\n \"admin/editor.newsletter-input-email.errorMessage.title\": \"\\\"Invalid email\\\" error message\",\n \"admin/editor.newsletter-input-name.title\": \"Newsletter name input\",\n \"admin/editor.newsletter-input-name.placeholderText.title\": \"Name input placeholder\",\n \"admin/editor.newsletter-input-name.inputLabel.title\": \"Label for the name input\",\n \"admin/editor.newsletter-input-name.errorMessage.title\": \"\\\"Invalid name\\\" error message\",\n \"admin/editor.newsletter-input-phone.title\": \"Newsletter phone input\",\n \"admin/editor.newsletter-input-phone.placeholderText.title\": \"Phone input placeholder\",\n \"admin/editor.newsletter-input-phone.inputLabel.title\": \"Label for the phone input\",\n \"admin/editor.newsletter-input-phone.errorMessage.title\": \"\\\"Invalid phone\\\" error message\",\n \"admin/editor.newsletter-checkbox-confirmation.title\": \"Newsletter confirmation\",\n \"admin/editor.newsletter-checkout-confirmation.checkboxLabel.title\": \"Label for the confirmation checkbox\",\n \"admin/editor.newsletter-checkout-confirmation.firstLink.title\": \"First link to be interpolated into the label\",\n \"admin/editor.newsletter-checkout-confirmation.firstLink.url\": \"First link url\",\n \"admin/editor.newsletter-checkout-confirmation.firstLink.text\": \"First link text\",\n \"admin/editor.newsletter-checkout-confirmation.secondLink.title\": \"Second link to be interpolated into the label\",\n \"admin/editor.newsletter-checkout-confirmation.secondLink.url\": \"Second link url\",\n \"admin/editor.newsletter-checkout-confirmation.secondLink.text\": \"Second link text\",\n \"admin/editor.newsletter-submit.title\": \"Newsletter form submit\",\n \"admin/editor.newsletter-submit.submitButtonLabel.title\": \"Label for the submit button\",\n \"store/newsletter-input-email.placeholderText.default\": \"Enter your email address\",\n \"store/newsletter-input-email.errorMessage.default\": \"Invalid email address\",\n \"store/newsletter-input-name.placeholderText.default\": \"Enter your name\",\n \"store/newsletter-input-name.errorMessage.default\": \"Invalid name\",\n \"store/newsletter-input-phone.placeholderText.default\": \"Enter your phone number\",\n \"store/newsletter-input-phone.errorMessage.default\": \"Invalid phone number\",\n \"store/newsletter-checkbox-confirmation.checkboxLabel.default\": \"I agree to received this newsletter.\",\n \"store/newsletter-submit.submitButtonLabel.default\": \"Subscribe\",\n \"store/newsletter-submit-success.default\": \"Thanks for subscribing!\",\n \"store/newsletter-submit-error.default\": \"Sorry, something went wrong.\"\n}\n\n```"
}
] |
code_store-newsletter_385572b4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/messages/context.json from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.newsletter-form.title\": \"Newsletter\",\n \"admin/editor.newsletter-input-email.title\": \"Newsletter email input\",\n \"admin/editor.newsletter-input-email.placeholderText.title\": \"Email input placeholder\",\n \"admin/editor.newsletter-input-email.inputLabel.title\": \"Label for the email input\",\n \"admin/editor.newsletter-input-email.errorMessage.title\": \"\\\"Invalid email\\\" error message\",\n \"admin/editor.newsletter-input-name.title\": \"Newsletter name input\",\n \"admin/editor.newsletter-input-name.placeholderText.title\": \"Name input placeholder\",\n \"admin/editor.newsletter-input-name.inputLabel.title\": \"Label for the name input\",\n \"admin/editor.newsletter-input-name.errorMessage.title\": \"\\\"Invalid name\\\" error message\",\n \"admin/editor.newsletter-input-phone.title\": \"Newsletter phone input\",\n \"admin/editor.newsletter-input-phone.placeholderText.title\": \"Phone input placeholder\",\n \"admin/editor.newsletter-input-phone.inputLabel.title\": \"Label for the phone input\",\n \"admin/editor.newsletter-input-phone.errorMessage.title\": \"\\\"Invalid phone\\\" error message\",\n \"admin/editor.newsletter-checkbox-confirmation.title\": \"Newsletter confirmation\",\n \"admin/editor.newsletter-checkout-confirmation.checkboxLabel.title\": \"Label for the confirmation checkbox\",\n \"admin/editor.newsletter-checkout-confirmation.firstLink.title\": \"First link to be interpolated into the label\",\n \"admin/editor.newsletter-checkout-confirmation.firstLink.url\": \"First link url\",\n \"admin/editor.newsletter-checkout-confirmation.firstLink.text\": \"First link text\",\n \"admin/editor.newsletter-checkout-confirmation.secondLink.title\": \"Second link to be interpolated into the label\",\n \"admin/editor.newsletter-checkout-confirmation.secondLink.url\": \"Second link url\",\n \"admin/editor.newsletter-checkout-confirmation.secondLink.text\": \"Second link text\",\n \"admin/editor.newsletter-submit.title\": \"Newsletter form submit\",\n \"admin/editor.newsletter-submit.submitButtonLabel.title\": \"Label for the submit button\",\n \"store/newsletter-input-email.placeholderText.default\": \"Enter your email address\",\n \"store/newsletter-input-email.errorMessage.default\": \"Invalid email address\",\n \"store/newsletter-input-name.placeholderText.default\": \"Enter your name\",\n \"store/newsletter-input-name.errorMessage.default\": \"Invalid name\",\n \"store/newsletter-input-phone.placeholderText.default\": \"Enter your phone number\",\n \"store/newsletter-input-phone.errorMessage.default\": \"Invalid phone number\",\n \"store/newsletter-checkbox-confirmation.checkboxLabel.default\": \"I agree to received this newsletter.\",\n \"store/newsletter-submit.submitButtonLabel.default\": \"Subscribe\",\n \"store/newsletter-submit-success.default\": \"Thanks for subscribing!\",\n \"store/newsletter-submit-error.default\": \"Sorry, something went wrong.\"\n}\n\n```"
}
] |
code_store-newsletter_d17807ae
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/messages/es.json from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.newsletter-form.title\": \"Newsletter\",\n \"admin/editor.newsletter-input-email.title\": \"Entrada de correo electrónico\",\n \"admin/editor.newsletter-input-email.placeholderText.title\": \"Marcador de posición de entrada de correo electrónico\",\n \"admin/editor.newsletter-input-email.inputLabel.title\": \"Etiqueta para la entrada de correo electrónico\",\n \"admin/editor.newsletter-input-email.errorMessage.title\": \"Mensaje de error \\\"Correo electrónico no válido\\\"\",\n \"admin/editor.newsletter-input-name.title\": \"Entrada del nombre\",\n \"admin/editor.newsletter-input-name.placeholderText.title\": \"Marcador de posición de entrada de nombre\",\n \"admin/editor.newsletter-input-name.inputLabel.title\": \"Etiqueta para la entrada del nombre\",\n \"admin/editor.newsletter-input-name.errorMessage.title\": \"Mensaje de error \\\"Nombre no válido\\\"\",\n \"admin/editor.newsletter-input-phone.title\": \"Entrada telefónica al boletín\",\n \"admin/editor.newsletter-input-phone.placeholderText.title\": \"Marcador de posición de entrada de teléfono\",\n \"admin/editor.newsletter-input-phone.inputLabel.title\": \"Etiqueta para la entrada del teléfono\",\n \"admin/editor.newsletter-input-phone.errorMessage.title\": \"Mensaje de error \\\"teléfono no válido\\\"\",\n \"admin/editor.newsletter-checkbox-confirmation.title\": \"Confirmación del boletín\",\n \"admin/editor.newsletter-checkout-confirmation.checkboxLabel.title\": \"Etiqueta para la casilla de verificación de confirmación\",\n \"admin/editor.newsletter-checkout-confirmation.firstLink.title\": \"Primer enlace que se interpolará en la etiqueta\",\n \"admin/editor.newsletter-checkout-confirmation.firstLink.url\": \"URL del primer enlace\",\n \"admin/editor.newsletter-checkout-confirmation.firstLink.text\": \"Texto del primer enlace\",\n \"admin/editor.newsletter-checkout-confirmation.secondLink.title\": \"Segundo enlace que se interpolará en la etiqueta\",\n \"admin/editor.newsletter-checkout-confirmation.secondLink.url\": \"URL del segundo enlace\",\n \"admin/editor.newsletter-checkout-confirmation.secondLink.text\": \"Texto del segundo enlace\",\n \"admin/editor.newsletter-submit.title\": \"Enviar formulario de boletín\",\n \"admin/editor.newsletter-submit.submitButtonLabel.title\": \"Etiqueta para el botón enviar\",\n \"store/newsletter-input-email.placeholderText.default\": \"Ingrese su dirección de correo electrónico\",\n \"store/newsletter-input-email.errorMessage.default\": \"Dirección de correo electrónico inválida\",\n \"store/newsletter-input-name.placeholderText.default\": \"Introduzca su nombre\",\n \"store/newsletter-input-name.errorMessage.default\": \"Nombre inválido\",\n \"store/newsletter-input-phone.placeholderText.default\": \"Ingrese su número telefónico\",\n \"store/newsletter-input-phone.errorMessage.default\": \"Numero de telefono invalido\",\n \"store/newsletter-checkbox-confirmation.checkboxLabel.default\": \"Acepto recibir este boletín.\",\n \"store/newsletter-submit.submitButtonLabel.default\": \"Suscribir\",\n \"store/newsletter-submit-success.default\": \"¡Gracias por suscribirte!\",\n \"store/newsletter-submit-error.default\": \"Perdón, algo salió mal.\"\n}\n\n```"
}
] |
code_store-newsletter_8d8ee9a3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/docs/README.md from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/vtex-apps/store-newsletter) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# Store Newsletter\n\n<!-- DOCS-IGNORE:start -->\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n<!-- DOCS-IGNORE:end -->\n\nThe Store Newsletter app provides a set of blocks that you can use to create a newsletter subscription form.\n\n\n\n## Configuration\n\n1. Add `vtex.store-newsletter` to your app's dependencies in the `manifest.json` file:\n\n```diff\n \"dependencies\": {\n+ \"vtex.store-newsletter\": \"1.x\"\n }\n```\n\nNow, you are able to use all blocks exported by the `store-newsletter` app. Check out the full list below:\n\n| Block name | Description |\n| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------- |\n| `newsletter-form` |  Top level block that provides context to all its children. |\n| `newsletter-input-email` |  Renders an email input in the newsletter form. |\n| `newsletter-input-name` | Renders an name input in the newsletter form. |\n| `newsletter-input-phone` | Renders an phone input in the newsletter form. |\n| `newsletter-checkbox-confirmation` | Renders a confirmation checkbox in the newsletter form. |\n| `newsletter-hidden-field` | Doesn't render anything, but enables hidden fields on the form to fetch custom data and save them in the store's [Master Data](https://help.vtex.com/en/tutorial/what-is-master-data--4otjBnR27u4WUIciQsmkAw) whenever a user subscribes to the newsletter. |\n| `newsletter-submit` |  Renders a `Submit` button for the newsletter form. |\n\n2. In the desired store template, such as the `store.home`, add the `newsletter-form` block and its desired children:\n\n```json\n{\n \"store.home\": {\n \"children\": [\"newsletter-form\"]\n },\n\n \"newsletter-form\": {\n \"children\": [\n \"newsletter-input-email\",\n \"newsletter-input-name\",\n \"newsletter-submit\"\n ]\n }\n}\n```\n\n### `newsletter-form` props\n\n| Prop name | Type | Description | Default value |\n| -------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |\n| `ErrorState` | `block` | Block to be rendered if the submission of the form fails. If none is passed, a default error component will be rendered. | `undefined` |\n| `SuccessState` | `block` | Block to be rendered if form submission succeeds. If none is passed, a default success component will be rendered. | `undefined` |\n| `LoadingState` | `block` | Block to be rendered while the form submission is loading. If none is passed, the default behavior is for the submit button to show a spinner during this loading period. | `undefined` |\n| `classes` | `CustomCSSClasses` | Used to override default CSS handles. To better understand how this prop works, we recommend reading about it [here](https://github.com/vtex-apps/css-handles#usecustomclasses). Note that this is only useful if you're importing this block as a React component. | `undefined` |\n\n### `newsletter-input-email` props\n\n| Prop name | Type | Description | Default value |\n| ----------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |\n| `placeholderText` | `string` | Placeholder text for the email input. | `Enter your email address` (translated according to the store's locale). |\n| `inputLabel` | `string` | Label for the email input. | `null` |\n| `errorMessage` | `string` | Error message to be shown if email is invalid. | `Invalid email address` (translated according to the store's locale). |\n| `classes` | `CustomCSSClasses` | Used to override default CSS handles. To better understand how this prop works, we recommend reading about it [here](https://github.com/vtex-apps/css-handles#usecustomclasses). Note that this is only useful if you're importing this block as a React component. | `undefined` |\n\n### `newsletter-input-name` props\n\n| Prop name | Type | Description | Default value |\n| ----------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |\n| `placeholderText` | `string` | Placeholder text for name input. | `Enter your name` (translated according to the store's locale). |\n| `inputLabel` | `string` | Label for the name input. | `null` |\n| `errorMessage` | `string` | Error message to be shown if name input is empty. | `Invalid name` (translated according to the store's locale). |\n| `classes` | `CustomCSSClasses` | Used to override default CSS handles. To better understand how this prop works, we recommend reading about it [here](https://github.com/vtex-apps/css-handles#usecustomclasses). Note that this is only useful if you're importing this block as a React component. | `undefined` |\n\n### `newsletter-input-phone` props\n\n| Prop name | Type | Description | Default value |\n| ----------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |\n| `placeholderText` | `string` | Placeholder text for phone input. | `Enter your phone` (translated according to the store's locale). |\n| `inputLabel` | `string` | Label for the phone input. | `null` |\n| `errorMessage` | `string` | Error message to be shown if phone input is empty. | `Invalid phone` (translated according to the store's locale). |\n| `classes` | `CustomCSSClasses` | Used to override default CSS handles. To better understand how this prop works, we recommend reading about it [here](https://github.com/vtex-apps/css-handles#usecustomclasses). Note that this is only useful if you're importing this block as a React component. | `undefined` |\n\n### `newsletter-checkbox-confirmation` props\n\n| Prop name | Type | Description | Default value |\n| --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |\n| `checkboxLabel` | `string` | Label for the confirmation checkbox. This prop supports the [ICU Message Format](https://format-message.github.io/icu-message-format-for-translators/), exposing two variables for you to interpolate: `firstLink` and `secondLink`. | `I agree to received this newsletter.` (translated according to the store's locale). |\n| `firstLabelLink` | `Object` | Configures the `firstLink` variable to be interpolated by the text passed to `checkboxLabel`. checkbox. | `undefined`. |\n| `secondLabelLink` | `Object` | Configures the `secondLink` variable to be interpolated by the text passed to `checkboxLabel`. checkbox. | `undefined` |\n| `classes` | `CustomCSSClasses` | Used to override default CSS handles. To better understand how this prop works, we recommend reading about it [here](https://github.com/vtex-apps/css-handles#usecustomclasses). Note that this is only useful if you're importing this block as a React component. | `undefined` |\n\n- `firstLabelLink` and `secondLabelLink` objects:\n\n| Prop name | Type | Description | Default value |\n| --------- | -------- | --------------------------- | ------------- |\n| `url` | `string` | The link's URL. | `undefined` |\n| `text` | `string` | Text displayed on the link. | `undefined` |\n\n### `newsletter-hidden-field` props\n\n| Prop name | Type | Description | Default value |\n| --------- | -------- | --------------------------- | ------------- |\n| `dynamicFields` | `[enum]` | Desired hidden fields responsible for saving the user's custom data on [Master Data](https://help.vtex.com/en/tutorial/what-is-master-data--4otjBnR27u4WUIciQsmkAw) once the newsletter form is submitted. Notice that the name of the fields must be written in an array and represent which user data they save. Possible values are: `bindingUrl` and `bindingId`. *Caution*: To properly save the data, you must also [create the desired filters](https://help.vtex.com/en/tutorial/how-can-i-create-a-field-in-master-data--frequentlyAskedQuestions_1829) in the Master Data's `Client` entity. | `undefined` |\n\n### `newsletter-submit` props\n\n| Prop name | Type | Description | Default value |\n| ------------------- | -------- | ------------------------------------ | --------------------------------------------------------- |\n| `submitButtonLabel` | `string` | Text displayed on the submit button. | `Subscribe` (translated according to the store's locale). |\n| `classes` | `CustomCSSClasses` | Used to override default CSS handles. To better understand how this prop works, we recommend reading about it [here](https://github.com/vtex-apps/css-handles#usecustomclasses). Note that this is only useful if you're importing this block as a React component. | `undefined` |\n\n## Customization\n\nIn order to apply CSS customizations in this and other blocks, follow the instructions given in the recipe on [Using CSS Handles for store customization](https://vtex.io/docs/recipes/style/using-css-handles-for-store-customization).\n\n| CSS Handles |\n| ------------------------------- |\n| `confirmationCheckboxContainer` |\n| `confirmationCheckboxLabel` |\n| `defaultErrorMessage` |\n| `defaultSuccessMessage` |\n| `emailInputContainer` |\n| `emailInputContainer--invalid` |\n| `emailInputLabel` |\n| `formSubmitContainer` |\n| `formSubmitContainer--invalid` |\n| `nameInputContainer` |\n| `nameInputContainer--invalid` |\n| `nameInputLabel` |\n| `newsletterForm` |\n| `phoneInputContainer` |\n| `phoneInputContainer--invalid` |\n| `phoneInputLabel` |\n\n<!-- DOCS-IGNORE:start -->\n\n## Contributors ✨\n\nThanks goes to these wonderful people:\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n <tr>\n <td align=\"center\"><a href=\"https://github.com/gutogama\"><img src=\"https://avatars.githubusercontent.com/u/70643210?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Luiz Gama</b></sub></a><br /><a href=\"https://github.com/vtex-apps/store-newsletter/commits?author=gutogama\" title=\"Code\">💻</a></td>\n </tr>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!\n\n<!-- DOCS-IGNORE:end -->\n\n```"
}
] |
code_store-newsletter_9a44b3b0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/react/Newsletter.tsx from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { ComponentType, PropsWithChildren, FormEvent } from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport { useCssHandles, CssHandlesTypes } from 'vtex.css-handles'\nimport { usePixel } from 'vtex.pixel-manager'\nimport type { PixelEventTypes } from 'vtex.pixel-manager'\n\nimport {\n NewsletterContextProvider,\n useNewsletterDispatch,\n useNewsletterState,\n MutationArguments,\n State,\n} from './components/NewsletterContext'\nimport {\n validateEmail,\n validatePhoneNumber,\n validateUserName,\n} from './modules/formValidators'\n\nexport const CSS_HANDLES = [\n 'newsletterForm',\n 'defaultSuccessMessage',\n 'defaultErrorMessage',\n] as const\n\ninterface Props {\n ErrorState?: ComponentType\n SuccessState?: ComponentType<{\n subscribedUserData?: {\n email: State['email']\n name: State['name']\n phone: State['phone']\n }\n }>\n LoadingState?: ComponentType\n classes?: CssHandlesTypes.CustomClasses<typeof CSS_HANDLES>\n customEventId?: string\n}\n\ninterface CustomField {\n name: string\n value: string | null | undefined\n}\n\nfunction generateMutationVariables({\n email,\n name,\n phone,\n customFields,\n}: {\n email: string\n name: string | undefined | null\n phone: string | undefined | null\n customFields: CustomField[] | null\n}) {\n const variables: MutationArguments = { email, fields: {} }\n\n if (name) {\n variables.fields.name = name\n }\n\n if (phone) {\n variables.fields.phone = phone\n }\n\n if (customFields) {\n customFields.forEach((customField) => {\n variables.fields[customField.name] = customField.value\n })\n }\n\n return variables\n}\n\nfunction Newsletter(props: PropsWithChildren<Props>) {\n const {\n ErrorState,\n SuccessState,\n LoadingState,\n classes,\n children,\n customEventId,\n } = props\n\n const {\n email,\n name,\n phone,\n submission,\n subscribe,\n customFields,\n } = useNewsletterState()\n\n const dispatch = useNewsletterDispatch()\n const { push } = usePixel()\n const { handles } = useCssHandles(CSS_HANDLES, { classes })\n\n if (submission.loading && LoadingState) {\n return <LoadingState />\n }\n\n if (submission.error) {\n return ErrorState ? (\n <ErrorState />\n ) : (\n <p className={handles.defaultErrorMessage}>\n <FormattedMessage id=\"store/newsletter-submit-error.default\" />\n </p>\n )\n }\n\n if (submission.data?.subscribeNewsletter) {\n return SuccessState ? (\n <SuccessState subscribedUserData={{ email, name, phone }} />\n ) : (\n <p className={handles.defaultSuccessMessage}>\n <FormattedMessage id=\"store/newsletter-submit-success.default\" />\n </p>\n )\n }\n\n function validateFormInputs() {\n const isEmailValid = validateEmail(email)\n\n // name === null is valid because it means there is no name input in the\n // newsletter form.\n const isNameValid = name === null || validateUserName(name)\n\n // phone === null is valid because it means there is no phone input in the\n // newsletter form.\n const isPhoneValid = phone === null || validatePhoneNumber(phone)\n\n dispatch({\n type: 'SET_INVALID_EMAIL',\n value: !isEmailValid,\n })\n\n dispatch({\n type: 'SET_INVALID_NAME',\n value: !isNameValid,\n })\n\n dispatch({\n type: 'SET_INVALID_PHONE',\n value: !isPhoneValid,\n })\n\n return isNameValid && isPhoneValid && isEmailValid\n }\n\n function handleSubmit(e: FormEvent) {\n e.preventDefault()\n\n const areUserInputsValid = validateFormInputs()\n\n if (!areUserInputsValid) {\n return\n }\n\n const pixelData = {\n name,\n email,\n phone,\n }\n\n const pixelEvent: PixelEventTypes.PixelData = customEventId\n ? {\n id: customEventId,\n event: 'newsletterSubscription',\n data: pixelData,\n }\n : {\n event: 'newsletterSubscription',\n data: pixelData,\n }\n\n push(pixelEvent)\n\n const mutationVariables = generateMutationVariables({\n email,\n name,\n phone,\n customFields,\n })\n\n // The '.catch' here is to prevent 'unhandled promise rejection'.\n // Proper error handling for this is implemented by NewsletterContext\n // using the variables returned by the 'useMutation' call it performs.\n subscribe({ variables: mutationVariables }).catch(() => {})\n }\n\n return (\n <form className={handles.newsletterForm} onSubmit={handleSubmit}>\n {children}\n </form>\n )\n}\n\nfunction WrappedNewsletter(props: PropsWithChildren<Props>) {\n return (\n <NewsletterContextProvider>\n <Newsletter {...props}>{props.children}</Newsletter>\n </NewsletterContextProvider>\n )\n}\n\nWrappedNewsletter.schema = {\n title: 'admin/editor.newsletter-form.title',\n}\n\nexport default WrappedNewsletter\n\n```"
}
] |
code_store-newsletter_2f583980
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/react/FormNameInput.tsx from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { ChangeEvent, useEffect } from 'react'\nimport { useIntl } from 'react-intl'\nimport { Input } from 'vtex.styleguide'\nimport { formatIOMessage } from 'vtex.native-types'\nimport { useCssHandles, CssHandlesTypes } from 'vtex.css-handles'\n\nimport {\n useNewsletterDispatch,\n useNewsletterState,\n} from './components/NewsletterContext'\n\nconst CSS_HANDLES = ['nameInputContainer'] as const\n\ninterface Props {\n placeholderText?: string\n inputLabel?: string\n errorMessage?: string\n classes?: CssHandlesTypes.CustomClasses<typeof CSS_HANDLES>\n}\n\nfunction FormNameInput(props: Props) {\n const {\n placeholderText = 'store/newsletter-input-name.placeholderText.default',\n errorMessage = 'store/newsletter-input-name.errorMessage.default',\n inputLabel,\n classes,\n } = props\n\n const { invalidName } = useNewsletterState()\n const dispatch = useNewsletterDispatch()\n const { withModifiers } = useCssHandles(CSS_HANDLES, { classes })\n const intl = useIntl()\n\n // Initialize `name` context value to signal that there is a FormNameInput\n // being rendered inside the newsletter form.\n useEffect(() => dispatch({ type: 'UPDATE_NAME', value: '' }), [dispatch])\n\n const handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n dispatch({ type: 'UPDATE_NAME', value: e.target.value.trim() })\n }\n\n return (\n <div\n className={`${withModifiers(\n 'nameInputContainer',\n invalidName ? 'invalid' : ''\n )}`}\n >\n <Input\n id=\"newsletter-input-name\"\n name=\"newsletter\"\n onChange={handleChange}\n label={formatIOMessage({ id: inputLabel, intl })}\n errorMessage={\n invalidName ? formatIOMessage({ id: errorMessage, intl }) : null\n }\n placeholder={formatIOMessage({ id: placeholderText, intl })}\n />\n </div>\n )\n}\n\nFormNameInput.schema = {\n title: 'admin/editor.newsletter-input-name.title',\n}\n\nexport default FormNameInput\n\n```"
}
] |
code_store-newsletter_32e88c0f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/react/FormSubmit.tsx from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { useCssHandles, CssHandlesTypes } from 'vtex.css-handles'\nimport { IOMessage } from 'vtex.native-types'\nimport { Button } from 'vtex.styleguide'\n\nimport { useNewsletterState } from './components/NewsletterContext'\n\nconst CSS_HANDLES = ['formSubmitContainer'] as const\n\ninterface Props {\n submitButtonLabel?: string\n classes?: CssHandlesTypes.CustomClasses<typeof CSS_HANDLES>\n}\n\nfunction FormSubmit(props: Props) {\n const {\n submitButtonLabel = 'store/newsletter-submit.submitButtonLabel.default',\n classes,\n } = props\n\n const {\n submission,\n invalidEmail,\n invalidName,\n invalidPhone,\n } = useNewsletterState()\n\n const formHasInvalidFields = invalidEmail || invalidName || invalidPhone\n\n const { withModifiers } = useCssHandles(CSS_HANDLES, { classes })\n\n return (\n <div\n className={`${withModifiers(\n 'formSubmitContainer',\n formHasInvalidFields ? 'invalid' : ''\n )}`}\n >\n <Button type=\"submit\" isLoading={submission.loading}>\n <IOMessage id={submitButtonLabel} />\n </Button>\n </div>\n )\n}\n\nFormSubmit.schema = {\n title: 'admin/editor.newsletter-submit.title',\n}\n\nexport default FormSubmit\n\n```"
}
] |
code_store-newsletter_38a2a3e1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/react/FormConfirmationCheckbox.tsx from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { ChangeEvent, useEffect } from 'react'\nimport { Checkbox } from 'vtex.styleguide'\nimport { IOMessage } from 'vtex.native-types'\nimport { useCssHandles, CssHandlesTypes } from 'vtex.css-handles'\n\nimport {\n useNewsletterDispatch,\n useNewsletterState,\n} from './components/NewsletterContext'\n\nconst CSS_HANDLES = [\n 'confirmationCheckboxContainer',\n 'confirmationCheckboxLabel',\n 'labelLink',\n] as const\n\ninterface Props {\n checkboxLabel?: string\n classes?: CssHandlesTypes.CustomClasses<typeof CSS_HANDLES>\n firstLabelLink?: {\n url: string\n text: string\n }\n secondLabelLink?: {\n url: string\n text: string\n }\n}\n\nfunction FormConfirmationCheckbox(props: Props) {\n const {\n checkboxLabel = 'store/newsletter-checkbox-confirmation.checkboxLabel.default',\n firstLabelLink,\n secondLabelLink,\n classes,\n } = props\n\n const dispatch = useNewsletterDispatch()\n const { confirmation } = useNewsletterState()\n\n const { handles, withModifiers } = useCssHandles(CSS_HANDLES, { classes })\n\n // Initialize `confirmation` context value to signal that there is a\n // FormConfirmationCheckbox being rendered inside the newsletter form.\n useEffect(() => dispatch({ type: 'UPDATE_CONFIRMATION', value: false }), [\n dispatch,\n ])\n\n const handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n dispatch({ type: 'UPDATE_CONFIRMATION', value: e.target.checked })\n }\n\n return (\n <div className={handles.confirmationCheckboxContainer}>\n <Checkbox\n id=\"newsletter-checkbox-confirmation\"\n name=\"newsletter-confirmation\"\n label={\n <IOMessage\n id={checkboxLabel}\n values={{\n firstLink: (\n <a\n className={withModifiers('labelLink', 'first')}\n href={firstLabelLink?.url}\n >\n {firstLabelLink?.text}\n </a>\n ),\n secondLink: (\n <a\n className={withModifiers('labelLink', 'second')}\n href={secondLabelLink?.url}\n >\n {secondLabelLink?.text}\n </a>\n ),\n }}\n />\n }\n onChange={handleChange}\n checked={confirmation}\n required\n />\n </div>\n )\n}\n\nFormConfirmationCheckbox.schema = {\n title: 'admin/editor.newsletter-checkbox-confirmation.title',\n}\n\nexport default FormConfirmationCheckbox\n\n```"
}
] |
code_store-newsletter_d8f9ca69
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/react/FormHiddenField.tsx from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { useEffect } from 'react'\nimport { useRuntime } from 'vtex.render-runtime'\n\nimport { useNewsletterDispatch } from './components/NewsletterContext'\n\ntype DynamicField = 'bindingUrl' | 'bindingId'\n\ninterface Props {\n dynamicFields: DynamicField[]\n}\n\ninterface ResolvedCustomField {\n name: string\n value: string | undefined | null\n}\n\nfunction FormHiddenField({ dynamicFields = [] }: Props) {\n const dispatch = useNewsletterDispatch()\n const runtime = useRuntime()\n\n const resolvedCustomFields = dynamicFields.map((field) => {\n const resolvedCustomField: ResolvedCustomField = {\n name: field,\n value: null,\n }\n\n if (field === 'bindingUrl') {\n resolvedCustomField.value = runtime.binding?.canonicalBaseAddress ?? null\n }\n\n if (field === 'bindingId') {\n resolvedCustomField.value = runtime.binding?.id ?? null\n }\n\n return resolvedCustomField\n })\n\n useEffect(() => {\n dispatch({\n type: 'SET_CUSTOM_VALUES',\n value: resolvedCustomFields,\n })\n }, [resolvedCustomFields, dispatch])\n\n return null\n}\n\nexport default FormHiddenField\n\n```"
}
] |
code_store-newsletter_f049d5ea
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/react/FormPhoneInput.tsx from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { ChangeEvent, useEffect } from 'react'\nimport { useIntl } from 'react-intl'\nimport { Input } from 'vtex.styleguide'\nimport { formatIOMessage } from 'vtex.native-types'\nimport { useCssHandles, CssHandlesTypes } from 'vtex.css-handles'\n\nimport {\n useNewsletterDispatch,\n useNewsletterState,\n} from './components/NewsletterContext'\n\nconst CSS_HANDLES = ['phoneInputContainer'] as const\n\ninterface Props {\n placeholderText?: string\n inputLabel?: string\n errorMessage?: string\n classes?: CssHandlesTypes.CustomClasses<typeof CSS_HANDLES>\n}\n\nfunction FormPhoneInput(props: Props) {\n const {\n placeholderText = 'store/newsletter-input-phone.placeholderText.default',\n errorMessage = 'store/newsletter-input-phone.errorMessage.default',\n inputLabel,\n classes,\n } = props\n\n const { invalidPhone } = useNewsletterState()\n const dispatch = useNewsletterDispatch()\n const { withModifiers } = useCssHandles(CSS_HANDLES, { classes })\n const intl = useIntl()\n\n // Initialize `phone` context value to signal that there is a FormPhoneInput\n // being rendered inside the newsletter form.\n useEffect(() => dispatch({ type: 'UPDATE_PHONE', value: '' }), [dispatch])\n\n const handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n dispatch({ type: 'UPDATE_PHONE', value: e.target.value.trim() })\n }\n\n return (\n <div\n className={`${withModifiers(\n 'phoneInputContainer',\n invalidPhone ? 'invalid' : ''\n )}`}\n >\n <Input\n id=\"newsletter-input-phone\"\n name=\"newsletter\"\n type=\"tel\"\n label={formatIOMessage({ id: inputLabel, intl })}\n onChange={handleChange}\n errorMessage={\n invalidPhone ? formatIOMessage({ id: errorMessage, intl }) : null\n }\n placeholder={formatIOMessage({ id: placeholderText, intl })}\n />\n </div>\n )\n}\n\nFormPhoneInput.schema = {\n title: 'admin/editor.newsletter-input-phone.title',\n}\n\nexport default FormPhoneInput\n\n```"
}
] |
code_store-newsletter_a02b0a09
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/react/FormEmailInput.tsx from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { ChangeEvent } from 'react'\nimport { useIntl } from 'react-intl'\nimport { Input } from 'vtex.styleguide'\nimport { formatIOMessage } from 'vtex.native-types'\nimport { useCssHandles, CssHandlesTypes } from 'vtex.css-handles'\n\nimport {\n useNewsletterDispatch,\n useNewsletterState,\n} from './components/NewsletterContext'\n\nconst CSS_HANDLES = ['emailInputContainer'] as const\n\ninterface Props {\n placeholderText?: string\n inputLabel?: string\n errorMessage?: string\n classes?: CssHandlesTypes.CustomClasses<typeof CSS_HANDLES>\n}\n\nfunction FormEmailInput(props: Props) {\n const {\n placeholderText = 'store/newsletter-input-email.placeholderText.default',\n errorMessage = 'store/newsletter-input-email.errorMessage.default',\n inputLabel,\n classes,\n } = props\n\n const { invalidEmail } = useNewsletterState()\n const dispatch = useNewsletterDispatch()\n const { withModifiers } = useCssHandles(CSS_HANDLES, { classes })\n const intl = useIntl()\n\n const handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n dispatch({ type: 'UPDATE_EMAIL', value: e.target.value.trim() })\n }\n\n return (\n <div\n className={`${withModifiers(\n 'emailInputContainer',\n invalidEmail ? 'invalid' : ''\n )}`}\n >\n <Input\n id=\"newsletter-input-email\"\n type=\"email\"\n name=\"newsletter\"\n label={formatIOMessage({ id: inputLabel, intl })}\n onChange={handleChange}\n errorMessage={\n invalidEmail ? formatIOMessage({ id: errorMessage, intl }) : null\n }\n placeholder={formatIOMessage({ id: placeholderText, intl })}\n />\n </div>\n )\n}\n\nFormEmailInput.schema = {\n title: 'admin/editor.newsletter-input-email.title',\n}\n\nexport default FormEmailInput\n\n```"
}
] |
code_store-newsletter_e15556dc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/react/package.json from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"store-newsletter\",\n \"version\": \"1.3.0\",\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"apollo-client\": \"^2.6.8\",\n \"react\": \"^16.12.0\",\n \"react-apollo\": \"^3.1.3\",\n \"react-dom\": \"^16.12.0\",\n \"react-intl\": \"^3.12.0\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^3.1.3\",\n \"@types/jest\": \"^25.1.4\",\n \"@types/node\": \"^13.9.8\",\n \"@types/react\": \"^16.9.31\",\n \"@vtex/test-tools\": \"^3.3.2\",\n \"@vtex/tsconfig\": \"^0.4.4\",\n \"apollo-cache-inmemory\": \"^1.6.5\",\n \"graphql\": \"^14.6.0\",\n \"typescript\": \"3.9.7\",\n \"vtex.css-handles\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.css-handles@1.0.0/public/@types/vtex.css-handles\",\n \"vtex.native-types\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.native-types@0.7.5/public/@types/vtex.native-types\",\n \"vtex.pixel-manager\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.pixel-manager@1.7.0/public/@types/vtex.pixel-manager\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.128.2/public/@types/vtex.render-runtime\",\n \"vtex.store-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-graphql@2.139.0/public/@types/vtex.store-graphql\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.136.2/public/@types/vtex.styleguide\"\n }\n}\n\n```"
}
] |
code_store-newsletter_69b37be7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/store/contentSchemas.json from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"definitions\": {\n \"EmailInput\": {\n \"properties\": {\n \"placeholderText\": {\n \"title\": \"admin/editor.newsletter-input-email.placeholderText.title\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n },\n \"inputLabel\": {\n \"title\": \"admin/editor.newsletter-input-email.inputLabel.title\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n },\n \"errorMessage\": {\n \"title\": \"admin/editor.newsletter-input-email.errorMessage.title\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n }\n }\n },\n\n \"NameInput\": {\n \"properties\": {\n \"placeholderText\": {\n \"title\": \"admin/editor.newsletter-input-name.placeholderText.title\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n },\n \"inputLabel\": {\n \"title\": \"admin/editor.newsletter-input-name.inputLabel.title\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n },\n \"errorMessage\": {\n \"title\": \"admin/editor.newsletter-input-name.errorMessage.title\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n }\n }\n },\n\n \"PhoneInput\": {\n \"properties\": {\n \"placeholderText\": {\n \"title\": \"admin/editor.newsletter-input-phone.placeholderText.title\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n },\n \"inputLabel\": {\n \"title\": \"admin/editor.newsletter-input-phone.inputLabel.title\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n },\n \"errorMessage\": {\n \"title\": \"admin/editor.newsletter-input-phone.errorMessage.title\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n }\n }\n },\n\n \"ConfirmationCheckbox\": {\n \"properties\": {\n \"checkboxLabel\": {\n \"title\": \"admin/editor.newsletter-checkout-confirmation.checkboxLabel.title\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n },\n \"firstLink\": {\n \"title\": \"admin/editor.newsletter-checkout-confirmation.firstLink.title\",\n \"properties\": {\n \"url\": {\n \"title\": \"admin/editor.newsletter-checkout-confirmation.firstLink.url\",\n \"$ref\": \"app:vtex.native-types#/definitions/url\"\n },\n \"text\": {\n \"title\": \"admin/editor.newsletter-checkout-confirmation.firstLink.text\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n }\n }\n },\n \"secondLink\": {\n \"title\": \"admin/editor.newsletter-checkout-confirmation.secondLink.title\",\n \"properties\": {\n \"url\": {\n \"title\": \"admin/editor.newsletter-checkout-confirmation.secondLink.url\",\n \"$ref\": \"app:vtex.native-types#/definitions/url\"\n },\n \"text\": {\n \"title\": \"admin/editor.newsletter-checkout-confirmation.secondLink.text\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n }\n }\n }\n }\n },\n\n \"NewsletterSubmit\": {\n \"properties\": {\n \"submitButtonLabel\": {\n \"title\": \"admin/editor.newsletter-submit.submitButtonLabel.title\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n }\n }\n }\n }\n}\n\n```"
}
] |
code_store-newsletter_5dcf2167
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/store/interfaces.json from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"newsletter-form\": {\n \"component\": \"Newsletter\",\n \"composition\": \"children\"\n },\n \"newsletter-hidden-field\": {\n \"component\": \"FormHiddenField\"\n },\n \"newsletter-input-email\": {\n \"component\": \"FormEmailInput\",\n \"content\": {\n \"$ref\": \"app:vtex.store-newsletter#/definitions/EmailInput\"\n }\n },\n \"newsletter-input-name\": {\n \"component\": \"FormNameInput\",\n \"content\": {\n \"$ref\": \"app:vtex.store-newsletter#/definitions/NameInput\"\n }\n },\n \"newsletter-input-phone\": {\n \"component\": \"FormPhoneInput\",\n \"content\": {\n \"$ref\": \"app:vtex.store-newsletter#/definitions/PhoneInput\"\n }\n },\n \"newsletter-checkbox-confirmation\": {\n \"component\": \"FormConfirmationCheckbox\",\n \"content\": {\n \"$ref\": \"app:vtex.store-newsletter#/definitions/ConfirmationCheckbox\"\n }\n },\n \"newsletter-submit\": {\n \"component\": \"FormSubmit\",\n \"content\": {\n \"$ref\": \"app:vtex.store-newsletter#/definitions/NewsletterSubmit\"\n }\n }\n}\n\n```"
}
] |
code_store-newsletter_ee139e3f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/react/typings/graphql.d.ts from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.gql' {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const graphql: any\n export default graphql\n}\n\ndeclare module '*.graphql' {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const graphql: any\n export default graphql\n}\n\n```"
}
] |
code_store-newsletter_9660427b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/react/typings/vtex.styleguide.d.ts from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-explicit-any */\ndeclare module 'vtex.styleguide' {\n export const Button: any\n export const Input: any\n export const Checkbox: any\n}\n\n```"
}
] |
code_store-newsletter_f8fb323a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/react/components/NewsletterContext.tsx from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { ApolloError } from 'apollo-client'\nimport React, {\n createContext,\n useReducer,\n useContext,\n PropsWithChildren,\n useEffect,\n} from 'react'\nimport { MutationFunction, useMutation } from 'react-apollo'\n\nimport subscribeNewsletterMutation from '../graphql/subscribeNewsletter.gql'\n\ninterface SubmissionState {\n error: undefined | ApolloError\n data: { subscribeNewsletter: boolean } | undefined\n loading: boolean\n}\n\nexport interface MutationArguments {\n email: string\n fields: {\n name?: string\n phone?: string\n bindingUrl?: string\n bindingId?: string\n [key: string]: string | undefined | null\n }\n}\n\ninterface CustomField {\n name: string\n value: string | undefined | null\n}\n\nexport interface State {\n email: string\n name: string | null\n phone: string | null\n customFields: CustomField[] | null\n confirmation: boolean | null\n invalidEmail: boolean\n invalidName: boolean\n invalidPhone: boolean\n submission: SubmissionState\n subscribe: MutationFunction<\n { subscribeNewsletter: boolean },\n MutationArguments\n >\n}\n\ninterface UpdateEmailAction {\n type: 'UPDATE_EMAIL'\n value: State['email']\n}\n\ninterface UpdateNameAction {\n type: 'UPDATE_NAME'\n value: State['name']\n}\n\ninterface UpdatePhoneAction {\n type: 'UPDATE_PHONE'\n value: State['phone']\n}\n\ninterface UpdateConfirmationAction {\n type: 'UPDATE_CONFIRMATION'\n value: State['confirmation']\n}\n\ninterface SetInvalidEmailAction {\n type: 'SET_INVALID_EMAIL'\n value: State['invalidEmail']\n}\n\ninterface SetInvalidNameAction {\n type: 'SET_INVALID_NAME'\n value: State['invalidName']\n}\n\ninterface SetInvalidPhoneAction {\n type: 'SET_INVALID_PHONE'\n value: State['invalidPhone']\n}\n\ninterface SetCustomValuesAction {\n type: 'SET_CUSTOM_VALUES'\n value: State['customFields']\n}\n\ninterface SetMutationValues {\n type: 'SET_MUTATION_VALUES'\n value: SubmissionState\n}\n\ntype Action =\n | UpdateEmailAction\n | UpdateNameAction\n | UpdatePhoneAction\n | UpdateConfirmationAction\n | SetInvalidEmailAction\n | SetMutationValues\n | SetInvalidNameAction\n | SetInvalidPhoneAction\n | SetCustomValuesAction\ntype Dispatch = (action: Action) => void\n\nconst NewsletterStateContext = createContext<State | undefined>(undefined)\nconst NewsletterDispatchContext = createContext<Dispatch | undefined>(undefined)\n\nfunction newsletterContextReducer(state: State, action: Action): State {\n switch (action.type) {\n case 'UPDATE_EMAIL':\n return {\n ...state,\n email: action.value,\n }\n\n case 'UPDATE_NAME':\n return {\n ...state,\n name: action.value,\n }\n\n case 'UPDATE_PHONE':\n return {\n ...state,\n phone: action.value,\n }\n\n case 'UPDATE_CONFIRMATION':\n return {\n ...state,\n confirmation: action.value,\n }\n\n case 'SET_INVALID_EMAIL':\n return {\n ...state,\n invalidEmail: action.value,\n }\n\n case 'SET_INVALID_NAME':\n return {\n ...state,\n invalidName: action.value,\n }\n\n case 'SET_INVALID_PHONE':\n return {\n ...state,\n invalidPhone: action.value,\n }\n\n case 'SET_MUTATION_VALUES': {\n return {\n ...state,\n submission: action.value,\n }\n }\n\n case 'SET_CUSTOM_VALUES': {\n return {\n ...state,\n customFields: action.value,\n }\n }\n\n default:\n return state\n }\n}\n\nfunction NewsletterContextProvider(props: PropsWithChildren<{}>) {\n const [subscribeToNewsletter, { data, loading, error }] = useMutation<\n { subscribeNewsletter: boolean },\n MutationArguments\n >(subscribeNewsletterMutation)\n\n const [state, dispatch] = useReducer(newsletterContextReducer, {\n email: '',\n name: null,\n phone: null,\n customFields: null,\n confirmation: null,\n invalidEmail: false,\n invalidName: false,\n invalidPhone: false,\n subscribe: subscribeToNewsletter,\n submission: {\n data,\n loading,\n error,\n },\n })\n\n // Update mutation variables in State\n useEffect(() => {\n dispatch({\n type: 'SET_MUTATION_VALUES',\n value: { loading, error, data },\n })\n }, [error, loading, data])\n\n return (\n <NewsletterStateContext.Provider value={state}>\n <NewsletterDispatchContext.Provider value={dispatch}>\n {props.children}\n </NewsletterDispatchContext.Provider>\n </NewsletterStateContext.Provider>\n )\n}\n\nfunction useNewsletterState() {\n const context = useContext(NewsletterStateContext)\n\n if (context === undefined) {\n throw new Error(\n 'useNewsletterState must be used within a NewsletterContextProvider'\n )\n }\n\n return context\n}\n\nfunction useNewsletterDispatch() {\n const context = useContext(NewsletterDispatchContext)\n\n if (context === undefined) {\n throw new Error(\n 'useNewsletterDispatch must be used within a NewsletterContextProvider'\n )\n }\n\n return context\n}\n\nexport { NewsletterContextProvider, useNewsletterDispatch, useNewsletterState }\n\n```"
}
] |
code_store-newsletter_6e74fa98
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/react/__tests__/index.test.tsx from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { render, fireEvent, waitFor } from '@vtex/test-tools/react'\nimport { usePixel } from 'vtex.pixel-manager'\n\nimport Newsletter from '../Newsletter'\nimport FormEmailInput from '../FormEmailInput'\nimport FormNameInput from '../FormNameInput'\nimport FormPhoneInput from '../FormPhoneInput'\nimport FormSubmit from '../FormSubmit'\nimport subscribeNewsletter from '../graphql/subscribeNewsletter.gql'\n\nconst mockedUsePixel = usePixel as jest.Mock<ReturnType<typeof usePixel>>\n\nbeforeEach(() => {\n mockedUsePixel().push.mockReset()\n})\n\nconst EMAIL_PLACEHOLDER_MESSAGE_ID =\n 'store/newsletter-input-email.placeholderText.default'\n\nconst NAME_PLACEHOLDER_MESSAGE_ID =\n 'store/newsletter-input-name.placeholderText.default'\n\nconst PHONE_PLACEHOLDER_MESSAGE_ID =\n 'store/newsletter-input-phone.placeholderText.default'\n\ndescribe('Basic rendering', () => {\n it('should render complete newsletter subscribe form', () => {\n const { getByPlaceholderText, getByText } = render(\n <Newsletter>\n <FormNameInput />\n <FormEmailInput />\n <FormSubmit />\n </Newsletter>\n )\n\n // newsletter-input-email block\n expect(getByPlaceholderText(EMAIL_PLACEHOLDER_MESSAGE_ID)).toBeTruthy()\n\n // newsletter-input-name block\n expect(getByPlaceholderText(NAME_PLACEHOLDER_MESSAGE_ID)).toBeTruthy()\n\n // newsletter-submit block\n expect(getByText('Subscribe')).toBeTruthy()\n })\n})\n\ndescribe('Form validation', () => {\n it('should show error message if email is not a valid one', () => {\n const { getByPlaceholderText, getByText } = render(\n <Newsletter>\n <FormEmailInput />\n <FormSubmit />\n </Newsletter>\n )\n\n const mockedInput = getByPlaceholderText(EMAIL_PLACEHOLDER_MESSAGE_ID)\n\n const submit = getByText('Subscribe')\n\n const wrongEmail = 'foobar'\n\n fireEvent.change(mockedInput, { target: { value: wrongEmail } })\n fireEvent.click(submit)\n\n expect(mockedInput).toHaveAttribute('data-errormessage')\n })\n\n it('should show error message if name is empty', () => {\n const { getByPlaceholderText, getByText } = render(\n <Newsletter>\n <FormNameInput />\n <FormSubmit />\n </Newsletter>\n )\n\n const mockedInput = getByPlaceholderText(NAME_PLACEHOLDER_MESSAGE_ID)\n\n const submit = getByText('Subscribe')\n\n fireEvent.click(submit)\n\n expect(mockedInput).toHaveAttribute('data-errormessage')\n })\n})\n\ndescribe('Reacting to mutation results', () => {\n it('should show success message if everything went well', async () => {\n const validEmail = 'foobar@vtex.com'\n const validPhone = '+5511123456789'\n const validName = 'Ted'\n\n const mocks = [\n {\n request: {\n query: subscribeNewsletter,\n variables: {\n email: validEmail,\n fields: { name: validName, phone: validPhone },\n },\n },\n result: {\n data: {\n subscribeNewsletter: {},\n },\n },\n },\n ]\n\n const { getByPlaceholderText, getByText } = render(\n <Newsletter>\n <FormEmailInput />\n <FormNameInput />\n <FormPhoneInput />\n <FormSubmit />\n </Newsletter>,\n {\n graphql: { mocks, addTypename: false },\n }\n )\n\n const mockedEmailInput = getByPlaceholderText(EMAIL_PLACEHOLDER_MESSAGE_ID)\n const mockedNameInput = getByPlaceholderText(NAME_PLACEHOLDER_MESSAGE_ID)\n const mockedPhoneInput = getByPlaceholderText(PHONE_PLACEHOLDER_MESSAGE_ID)\n\n const submit = getByText('Subscribe')\n\n fireEvent.change(mockedEmailInput, { target: { value: validEmail } })\n fireEvent.change(mockedNameInput, { target: { value: validName } })\n fireEvent.change(mockedPhoneInput, { target: { value: validPhone } })\n\n fireEvent.click(submit)\n\n const thanks = await waitFor(() => getByText('Thanks for subscribing!'))\n\n expect(mockedUsePixel().push).toHaveBeenCalledWith({\n event: 'newsletterSubscription',\n data: { email: validEmail, name: validName, phone: validPhone },\n })\n\n expect(thanks).toBeTruthy()\n })\n\n it('should show error message if something went wrong', async () => {\n const validEmail = 'foobar@vtex.com'\n const validName = 'Ted'\n\n const mocks = [\n {\n request: {\n query: subscribeNewsletter,\n variables: { email: validEmail, name: validName },\n },\n error: new Error('Something went wrong'),\n },\n ]\n\n const { getByPlaceholderText, getByText } = render(\n <Newsletter>\n <FormEmailInput />\n <FormNameInput />\n <FormSubmit />\n </Newsletter>,\n {\n graphql: { mocks, addTypename: false },\n }\n )\n\n const mockedEmailInput = getByPlaceholderText(EMAIL_PLACEHOLDER_MESSAGE_ID)\n const mockedNameInput = getByPlaceholderText(NAME_PLACEHOLDER_MESSAGE_ID)\n\n const submit = getByText('Subscribe')\n\n fireEvent.change(mockedEmailInput, { target: { value: validEmail } })\n fireEvent.change(mockedNameInput, { target: { value: validName } })\n\n fireEvent.click(submit)\n\n const sorry = await waitFor(() => getByText('Sorry, something went wrong.'))\n\n expect(sorry).toBeTruthy()\n })\n})\n\n```"
}
] |
code_store-newsletter_c650313e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/react/graphql/subscribeNewsletter.gql from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation subscribeNewsletter($email: String, $fields: NewsletterFieldsInput)\n @context(provider: \"vtex.store-graphql\") {\n subscribeNewsletter(email: $email, fields: $fields)\n}\n\n```"
}
] |
code_store-newsletter_964dc7fd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building 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-newsletter/react/modules/formValidators.ts from the store-newsletter VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n// https://regex101.com/r/926sxf/1\n// If you change the regex, don't forget to go to the link above, update it there and save.\nconst EMAIL_REGEX = /^[A-z0-9\"+_-]+(?:\\.[A-z0-9+_-]+)*@(?:[A-z0-9](?:[A-z0-9-]*[A-z0-9])?\\.)+[A-z0-9](?:[A-z0-9-]*[A-z0-9])?$/\n\n// https://regex101.com/r/5dVM9R/1\n// If you change the regex, don't forget to go to the link above, update it there and save.\nconst PHONE_REGEX = /([0-9]|\\(|\\)|\\+| |-)+/\n\nexport function validateEmail(email: string) {\n return EMAIL_REGEX.test(email)\n}\n\nexport function validatePhoneNumber(phone: string) {\n return PHONE_REGEX.test(phone)\n}\n\nexport function validateUserName(name: string) {\n return name.length > 0\n}\n\n```"
}
] |
code_mycheckout-portal-cms_21ad3ce7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-portal-cms/src/index.tsx from the mycheckout-portal-cms VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { infiniteScroll } from './InfinityScroll'\nimport { pagination } from './Pagination'\n\nconst render = (seeMore: string) => {\n switch (seeMore) {\n case 'pagination': {\n pagination()\n break\n }\n\n case 'infinite': {\n infiniteScroll()\n break\n }\n\n default: {\n infiniteScroll()\n }\n }\n}\n\nrender('infinite')\n\n```"
}
] |
code_mycheckout-portal-cms_4b53b1fe
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-portal-cms/src/Pagination.tsx from the mycheckout-portal-cms VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport ReactDOM from 'react-dom'\n\nimport Button from './QuickpayButton'\nimport Wrapper from './KuikpayWrapper'\nimport { search } from './services'\nimport { formatItems, useRender } from './utils'\n\nexport const pagination = () => {\n const { elements, item, wrapper, items } = useRender()\n\n if (!wrapper) return\n\n ReactDOM.render(<Wrapper />, wrapper)\n\n if (elements.length) {\n const searchQuery = items\n .map((parameter: string) => `fq=skuId:${parameter}&`)\n .join('')\n\n search(searchQuery, 0, 49).then((products) => {\n const sortedProducts: any = []\n\n items.forEach((itemId: string) => {\n products.forEach((product: any) => {\n product.items.forEach((sku: any) => {\n if (sku.itemId === itemId) sortedProducts.push(product)\n })\n })\n })\n\n sortedProducts.forEach((product: any, index: number) => {\n const { selectedItem, itemsFormatted, variations } = formatItems(\n product,\n items[index]\n )\n\n if (selectedItem) {\n const itemInfo = {\n id: selectedItem.itemId,\n seller: selectedItem.sellers[0].sellerId,\n }\n\n ReactDOM.render(\n <Button\n key={selectedItem.itemId}\n itemInfo={itemInfo}\n product={{ ...product, items: itemsFormatted }}\n selectedItem={{ ...selectedItem, variations }}\n />,\n elements[index]\n )\n }\n })\n })\n }\n\n if (item) {\n ReactDOM.render(<Button />, item)\n }\n}\n\nconst observer = new MutationObserver((mutations) => {\n mutations.forEach((mutation) => {\n if (mutation.addedNodes.length) {\n pagination()\n }\n })\n})\n\nconst list = document.getElementsByClassName('prateleira')[0]\n\nif (list) {\n observer.observe(list, {\n childList: true,\n })\n}\n\n```"
}
] |
code_mycheckout-portal-cms_02ccf3d3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-portal-cms/src/KuikpayQuotaInformation.tsx from the mycheckout-portal-cms VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { KuikpayQuotaInformative } from 'kuikpay-sdk'\nimport type { ProductItem } from 'kuikpay-sdk/dist/interfaces'\n\nimport { CONSTANTS } from './utils'\n\nconst LANGUAGE = 'es'\nconst THEME = 'kuikpay'\nconst windowInfo: any = window\nconst { vtxctx } = windowInfo\nconst RUNTIME = {\n account: vtxctx.url.split('.')[0],\n workspace: CONSTANTS.workspace,\n platform: CONSTANTS.platform,\n}\n\ninterface Props {\n selectedItem?: ProductItem\n}\n\nexport const KuikpayQuotaInformation = ({ selectedItem }: Props) => {\n return (\n <div>\n <KuikpayQuotaInformative\n language={LANGUAGE}\n theme={THEME}\n selectedItem={selectedItem}\n runtime={RUNTIME}\n />\n </div>\n )\n}\n\n```"
}
] |
code_mycheckout-portal-cms_7f911bb5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-portal-cms/src/QuickpayButton.tsx from the mycheckout-portal-cms VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useState, useEffect } from 'react'\nimport { Kuikpay } from 'kuikpay-sdk'\nimport 'kuikpay-sdk/dist/index.css'\nimport type {\n ItemToAdd,\n Product,\n ProductItem,\n} from 'kuikpay-sdk/dist/interfaces'\n\nimport type { ItemInfo } from './interfaces'\nimport { CONSTANTS } from './utils'\n\ninterface Props {\n itemInfo?: ItemInfo\n product?: Product\n selectedItem?: ProductItem\n onClickBehavior?: 'ensure-sku-selection'\n}\n\nconst windowInfo: any = window\nconst { vtexjs, vtxctx } = windowInfo\n\nconst Button = (props: Props) => {\n const {\n itemInfo,\n product,\n selectedItem: mainSelectedItem,\n onClickBehavior = 'ensure-sku-selection',\n } = props\n\n const [selectedItem, setSelectedItem] = useState(mainSelectedItem)\n const [skuInfo, setSkuInfo] = useState(\n windowInfo.skuJson_0\n ? {\n id: windowInfo.skuJson_0.skus[0]?.sku,\n quantity: 1,\n seller: windowInfo.skuJson_0.skus[0]?.sellerId,\n }\n : {\n id: itemInfo?.id,\n quantity: 1,\n seller: itemInfo?.seller,\n }\n )\n\n const [visible, setVisible] = useState(true)\n\n const changeSkuId = (skuId: string) => {\n setSkuInfo((prevState) => ({\n ...prevState,\n id: skuId,\n }))\n }\n\n useEffect(() => {\n if (!windowInfo.skuJson_0) return\n\n // This detects new sku selection from PDP\n $(window).on('vtex.sku.selected', (evt, productId, sku) => {\n changeSkuId(sku.sku)\n setVisible(sku.available)\n })\n\n return () => {\n $(window).off('vtex.sku.selected', (evt, productId, sku) => {\n changeSkuId(sku.sku)\n })\n }\n }, [])\n\n // useEffect(() => {\n // \tvtexjs.checkout.getOrderForm().done(orderForm => {\n // \t\tsetOrderForm(orderForm)\n // \t});\n\n useEffect(() => {\n if (!selectedItem) return\n changeSkuId(selectedItem?.itemId)\n }, [selectedItem])\n\n // const handleOrderFormUpdated = (_: any, orderFormData: any) => {\n // setOrderForm(orderFormData)\n // }\n\n // useEffect(() => {\n // $(window).on('orderFormUpdated.vtex', handleOrderFormUpdated)\n\n // return () => {\n // $(window).off('orderFormUpdated.vtex', handleOrderFormUpdated)\n // }\n // }, [])\n\n const handleAddToCart = (item: ItemToAdd) => {\n vtexjs.checkout.getOrderForm().then(() => {\n return vtexjs.checkout.addToCart([item])\n })\n }\n\n // Item to add to cart\n const itemToAdd = skuInfo\n ? {\n id: skuInfo.id,\n quantity: 1,\n seller: skuInfo.seller,\n }\n : null\n\n // Function to update order form selected address\n // const handleUpdateSelectedAddress = (address: any) => {\n // vtexjs.checkout.getOrderForm().then(function () {\n // return vtexjs.checkout.sendAttachment('shippingData', {\n // address,\n // clearAddressIfPostalCodeNotFound: false,\n // })\n // })\n // }\n\n const itemsLength = product?.items?.length ?? 0\n const multipleAvailableSKUs = itemsLength > 1\n\n const handleSelectedItem = (item: ProductItem) => {\n setSelectedItem(item)\n }\n\n const runtime = {\n account: vtxctx.url.split('.')[0],\n workspace: CONSTANTS.workspace,\n platform: CONSTANTS.platform,\n }\n\n return (\n <Kuikpay\n addToCart={handleAddToCart}\n itemToAdd={itemToAdd}\n isVisible={visible}\n // validateItems={validateItems}\n // customData={customData}\n // config={config}\n // validateBeforeOfAdd={validateBeforeOfAdd}\n multipleAvailableSKUs={multipleAvailableSKUs}\n onClickBehavior={onClickBehavior}\n product={product}\n selectedItem={selectedItem}\n handleSelectedItem={handleSelectedItem}\n runtime={runtime}\n sandbox={false}\n />\n )\n}\n\nexport default Button\n\n```"
}
] |
code_mycheckout-portal-cms_f28ed950
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-portal-cms/src/KuikpayWrapper.tsx from the mycheckout-portal-cms VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useEffect, useState } from 'react'\nimport { KuikpayWrapper } from 'kuikpay-sdk'\nimport type {\n Item,\n ItemToAdd,\n ItemToRemove,\n OfferingInput,\n Totalizer,\n} from 'kuikpay-sdk/dist/interfaces'\n\nimport { cartSimulation } from './services'\nimport type { Profile } from './interfaces'\nimport { CONSTANTS } from './utils'\n\nconst LANGUAGE = 'es'\nconst THEME = 'kuikpay'\nconst windowInfo: any = window\nconst { vtexjs, jsnomeLoja } = windowInfo\nconst RUNTIME = {\n account: jsnomeLoja,\n workspace: CONSTANTS.workspace,\n platform: CONSTANTS.platform,\n}\n\nconst Kuikpaywrapper = () => {\n const [order, setOrder] = useState(null)\n const [orderForm, setOrderForm] = useState<any>({})\n\n const listendCheckout = (_: any, orderFormData: any) => {\n setOrderForm(orderFormData)\n }\n\n useEffect(() => {\n $(window).on('orderFormUpdated.vtex', listendCheckout)\n\n return () => {\n $(window).off('orderFormUpdated.vtex', listendCheckout)\n }\n }, [])\n\n useEffect(() => {\n const formattedOrderForm = {\n clientProfileData: {\n email: orderForm.clientProfileData?.email,\n },\n shippingData: {\n selectedAddress: {\n addressId: orderForm.selectedAddress?.addressId || '',\n addressType: orderForm.selectedAddress?.addressType || '',\n city: orderForm.selectedAddress?.city || '',\n complement: orderForm.selectedAddress?.complement || '',\n country: orderForm.selectedAddress?.country || '',\n geoCoordinates: orderForm.selectedAddress?.geoCoordinates || '',\n isDisposable: orderForm.selectedAddress?.isDisposable || '',\n neighborhood: orderForm.selectedAddress?.neighborhood || '',\n number: orderForm.selectedAddress?.number || '',\n postalCode: orderForm.selectedAddress?.postalCode || '',\n receiverName: orderForm.selectedAddress?.receiverName || '',\n reference: orderForm.selectedAddress?.reference || '',\n state: orderForm.selectedAddress?.state || '',\n street: orderForm.selectedAddress?.street || '',\n completed: false || '',\n },\n },\n items: orderForm?.items?.map((item: Item, index: number) => ({\n ...item,\n sellingPrice: item.sellingPrice / 100,\n price: item.price / 100,\n listPrice: item?.listPrice / 100,\n index,\n })),\n totalizers: orderForm.totalizers,\n value: orderForm.value / 100,\n messages: orderForm.messages?.couponMessages\n ? orderForm.messages?.couponMessages\n : orderForm.messages,\n marketingData: {\n coupon: orderForm.marketingData?.coupon,\n },\n }\n\n setOrder(formattedOrderForm)\n }, [orderForm])\n\n const handleInsertCoupon = (text: string) => {\n vtexjs.checkout.getOrderForm().then(() => {\n return vtexjs.checkout.addDiscountCoupon(text)\n })\n }\n\n const handleAddItemOffering = ({ offeringId, itemIndex }: OfferingInput) => {\n vtexjs.checkout.getOrderForm().then(() => {\n return vtexjs.checkout.addOffering(offeringId, itemIndex)\n })\n }\n\n const handleRemoveItemOffering = ({\n offeringId,\n itemIndex,\n }: OfferingInput) => {\n vtexjs.checkout.getOrderForm().then(() => {\n return vtexjs.checkout.removeOffering(offeringId, itemIndex)\n })\n }\n\n const handleUpdateOrderFormProfile = (profile: Profile) => {\n vtexjs.checkout.getOrderForm().then(() => {\n return vtexjs.checkout.sendAttachment('clientProfileData', profile)\n })\n }\n\n const handleUpdateItems = (items: ItemToRemove[]) => {\n const itemsInfo = items.map((item: ItemToRemove) => {\n return { index: item.index, quantity: item.quantity }\n })\n\n vtexjs.checkout.getOrderForm().then(() => {\n return vtexjs.checkout.updateItems(itemsInfo, null, false)\n })\n }\n\n const handleClearItems = (_items: ItemToRemove[]) => {\n vtexjs.checkout.getOrderForm().then(() => {\n return vtexjs.checkout.removeAllItems()\n })\n }\n\n const handleAddToCart = (item: ItemToAdd) => {\n vtexjs.checkout.getOrderForm().then(() => {\n return vtexjs.checkout.addToCart([item])\n })\n }\n\n const clearOrderFormProfile = async () => {\n const clientProfileData = orderForm?.clientProfileData\n\n if (clientProfileData) {\n const changeToAnonymousUserURL =\n await vtexjs.checkout.getChangeToAnonymousUserURL()\n\n fetch(changeToAnonymousUserURL, {\n method: 'GET',\n redirect: 'follow',\n }).then(() => {\n vtexjs.checkout.getOrderForm().then((e: any) => {\n listendCheckout('', e)\n })\n })\n }\n }\n\n return (\n <KuikpayWrapper\n updateSelectedAddress={() => {}}\n cartSimulation={cartSimulation}\n language={LANGUAGE}\n theme={THEME}\n runtime={RUNTIME}\n insertCoupon={handleInsertCoupon}\n addItemOffering={handleAddItemOffering}\n removeItemOffering={handleRemoveItemOffering}\n updateOrderFormProfile={handleUpdateOrderFormProfile}\n updateItems={handleUpdateItems}\n clearData={handleClearItems}\n orderForm={order}\n addToCart={handleAddToCart}\n sandbox={false}\n clearOrderFormProfile={clearOrderFormProfile}\n />\n )\n}\n\nexport default Kuikpaywrapper\n\n```"
}
] |
code_mycheckout-portal-cms_03e0b34c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-portal-cms/src/InfinityScroll.tsx from the mycheckout-portal-cms VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport ReactDOM from 'react-dom'\n\nimport Button from './QuickpayButton'\nimport { renderWrapper } from './Wrapper'\nimport { search } from './services'\nimport { formatItems, useRender } from './utils'\n\nconst container = document.currentScript.getAttribute('container')\n\nrenderWrapper()\n\nexport const infiniteScroll = () => {\n const { elements, item, items, undockedElements } = useRender()\n\n if (elements.length) {\n const intervalItems: any = []\n const interval = 50\n\n for (let i = 0; i < items.length; i += interval) {\n const intervalItem = items.slice(i, i + interval)\n\n intervalItems.push(intervalItem)\n }\n\n const searchQueries = intervalItems.map((intervalItem: string[]) => {\n return intervalItem\n .map((parameter: string) => `fq=skuId:${parameter}&`)\n .join('')\n })\n\n searchQueries.forEach(async (searchQuery: string) => {\n const products = await search(searchQuery, 0, 49)\n\n const sortedProducts: any = []\n\n intervalItems.forEach((intervalItem: any) => {\n intervalItem.forEach((itemId: string) => {\n products.forEach((product: any) => {\n product.items.forEach((sku: any) => {\n if (sku.itemId === itemId) sortedProducts.push(product)\n })\n })\n })\n })\n\n sortedProducts.forEach((product: any, index: number) => {\n const { selectedItem, itemsFormatted, variations } = formatItems(\n product,\n items[index]\n )\n\n if (selectedItem) {\n const itemInfo = {\n id: selectedItem.itemId,\n seller: selectedItem.sellers[0].sellerId,\n }\n\n ReactDOM.render(\n <Button\n key={selectedItem.itemId}\n itemInfo={itemInfo}\n product={{ ...product, items: itemsFormatted }}\n selectedItem={{ ...selectedItem, variations }}\n />,\n elements[index]\n )\n }\n\n elements[index].className = 'kuikpay-rendered'\n })\n })\n }\n\n if (item) {\n ReactDOM.render(<Button />, item)\n }\n\n if (undockedElements) {\n undockedElements.forEach((undockedElement: any) =>\n ReactDOM.render(<Button />, undockedElement)\n )\n }\n}\n\nconst observer = new MutationObserver((mutations) => {\n if (mutations.length) {\n infiniteScroll()\n }\n})\n\n// const list = document.getElementsByClassName('showcases__grid')[1]\nconst list = document.getElementsByClassName(container)[0]\n\nif (list) {\n observer.observe(list, {\n childList: true,\n subtree: true,\n })\n}\n\n```"
}
] |
code_mycheckout-portal-cms_b38ee45f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-portal-cms/src/Wrapper.tsx from the mycheckout-portal-cms VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport ReactDOM from 'react-dom'\n\nimport Wrapper from './KuikpayWrapper'\nimport { useRender } from './utils'\n\nexport const renderWrapper = () => {\n const { wrapper } = useRender()\n\n if (!wrapper) return\n ReactDOM.render(<Wrapper />, wrapper)\n}\n\n```"
}
] |
code_mycheckout-portal-cms_42eb0c0d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-portal-cms/src/utils/index.ts from the mycheckout-portal-cms VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const CONSTANTS = {\n workspace: 'master',\n platform: 'vtex-cms',\n}\n\nexport const useRender = () => {\n const elements = Array.from(document.getElementsByClassName('kuikpay'))\n const undockedElements = Array.from(\n document.getElementsByClassName('kuikpay-undocked')\n )\n\n const item = document.getElementById('kuikpay')\n const wrapper = document.getElementById('kuikpayWrapper')\n const items = elements.map((e) => e.id.split('-')[1])\n\n return {\n elements,\n item,\n wrapper,\n items,\n undockedElements,\n }\n}\n\nexport const formatItems = (product: any, itemId: any) => {\n const selectedItem = product.items.find(\n (itemInfo: any) => itemInfo.itemId === itemId\n )\n\n const itemsFormatted = product?.items?.map((sku: any) => {\n const variations = sku?.variations?.map((variation: any) => {\n return {\n name: variation,\n values: sku[variation],\n }\n })\n\n return {\n ...sku,\n variations,\n }\n })\n\n const variations = selectedItem?.variations?.map((variation: any) => {\n return {\n name: variation,\n values: selectedItem[variation],\n }\n })\n\n return {\n selectedItem,\n itemsFormatted,\n variations,\n }\n}\n\n```"
}
] |
code_mycheckout-portal-cms_89102d8b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-portal-cms/src/services/index.ts from the mycheckout-portal-cms VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { CartSimulation } from 'kuikpay-sdk/dist/interfaces'\n\nexport const search = async (query: string, from = 0, to = 12) => {\n const myHeaders = new Headers()\n\n myHeaders.append('Accept', 'application/json')\n myHeaders.append('Content-Type', 'application/json')\n\n const requestOptions = {\n method: 'GET',\n headers: myHeaders,\n redirect: 'follow' as const,\n }\n\n const response = await fetch(\n `/api/catalog_system/pub/products/search/?${query}_from=${from}&_to=${to}`,\n requestOptions\n )\n\n return response.json()\n}\n\nexport const cartSimulation = async (body: CartSimulation) => {\n const myHeaders = new Headers()\n\n myHeaders.append('Accept', 'application/json')\n myHeaders.append('Content-Type', 'application/json')\n\n const raw = JSON.stringify(body)\n\n const requestOptions = {\n method: 'POST',\n headers: myHeaders,\n body: raw,\n redirect: 'follow' as const,\n }\n\n const response = await fetch(\n '/api/checkout/pub/orderforms/simulation',\n requestOptions\n )\n\n return response\n}\n\n```"
}
] |
code_mycheckout-portal-cms_b606e0d2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of mycheckout-portal-cms/src/interfaces/index.ts from the mycheckout-portal-cms VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport interface ItemInfo {\n id: string\n seller: string\n}\n\nexport interface Profile {\n email?: string\n firstName?: string\n lastName?: string\n document?: string\n phone?: string\n documentType?: string\n isCorporate?: boolean\n corporateName?: string\n tradeName?: string\n corporateDocument?: string\n stateInscription?: string\n}\n\n```"
}
] |
code_file-manager-graphql_dce3432e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of file-manager-graphql/docs/README.md from the file-manager-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# File Manager GraphQL\n\nA GraphQL service for managing files in VTEX applications. This service provides a simple interface for uploading, retrieving, and deleting files with support for image resizing.\n\nThis API is a GraphQL abstraction of the [vtex.file-manager@0.x](https://github.com/vtex/file-manager) app, providing a unified interface for file management.\nUsage\n\n## Features\n\n- File uploads with automatic UUID-based naming\n- File retrieval with optional image resizing\n- File URL generation for direct access\n- File deletion\n- Authentication requirements for sensitive operations\n- Support for different storage buckets\n\n\n## Usage\nTo use this API, declare it in your manifest.json file:\n\n```JSON\n\"dependencies\": {\n \"file-manager-graphql\": \"0.x\"\n}\n```\n\n## Queries\n\n### getFileUrl\nReturns the immutable URL of a file.\n\n| Arguments | Type | Description |\n| --- | --- | --- |\n| path | [String](#string) | File path |\n| bucket | [String](#string) | Bucket name |\n\n### getFile\n\n| Arguments | Type | Description |\n| --- | --- | --- |\n| path | [String](#string) | File path |\n| bucket | [String](#string) | Bucket name |\n| width | [Int](#int) | Image width |\n| height | [Int](#int) | Image height |\n| aspect | [Boolean](#boolean) | Maintain image aspect ratio |\n\n\n### settings\nReturns the API settings.\n\n## Mutations\n\n### uploadFile\nSaves a file and returns its immutable URL.\n\n| Arguments | Type | Description |\n| --- | --- | --- |\n| file | [File](#file) | File to be uploaded |\n| bucket | [String](#string) | Bucket name |\n\n\n\n### deleteFile\nDeletes a file from a bucket.\n\n| Arguments | Type | Description |\n| --- | --- | --- |\n| path | [String](#string) | File path |\n| bucket | [String](#string) | Bucket name |\n\n\n## Types\n\n### File\n\n| Field | Type | Description |\n| --- | --- | --- |\n| fileUrl | [String](#string) | File URL |\n| mimetype | [String](#string) | File MIME type |\n| encoding | [String](#string) | File encoding |\n\n### Settings\n\n| Field | Type | Description |\n| --- | --- | --- |\n| maxFileSizeMB | [Int](#int) | Maximum allowed file size (in MB) |\n\n\n### Examples\n\nGetting a file URL\n\n```graphql\nquery {\n getFileUrl(path: \"path/to/file\", bucket: \"images\") {\n fileUrl\n }\n}\n```\n\nGetting a file\n\n```graphql\nquery {\n getFile(path: \"path/to/file\", width: 100, height: 100, bucket: \"images\") {\n file\n }\n}\n```\n\nUploading a file\n\n```graphql\n\nmutation {\n uploadFile(file: ..., bucket: \"images\") {\n fileUrl\n }\n}\n```\n\n## Scalars\n\n### Boolean\n\nThe `Boolean` scalar type represents `true` or `false`.\n\n### Int\n\nThe `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.\n\n### String\n\nThe `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.\n\n## Security\n\nThis service implements authentication directives to ensure that sensitive operations like file uploads and deletions are properly authorized.\n\n## License\n\nThis project is licensed under the terms specified in the `package.json` file.\n```"
}
] |
code_file-manager-graphql_a8b47354
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of file-manager-graphql/graphql/schema.graphql from the file-manager-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ntype File {\n fileUrl: String!\n mimetype: String!\n encoding: String!\n}\n\ntype Settings {\n maxFileSizeMB: Int\n}\n\ntype Mutation {\n \"\"\"Save file (returns file's immutable URL)\"\"\"\n uploadFile(file: Upload!, bucket: String = \"images\"): File @requiresAuth\n \"\"\"Delete file from bucket\"\"\"\n deleteFile(path: String!, bucket: String = \"images\"): Boolean! @requiresAuth\n}\n\ntype Query {\n \"\"\"Get file’s immutable URL\"\"\"\n getFileUrl(path: String!, bucket: String = \"images\"): String\n \"\"\"Get file\"\"\"\n getFile(path: String!, width: Int = 1, height: Int = 2, aspect: Boolean = false, bucket: String = \"images\"): String\n \"\"\"Settings\"\"\"\n settings: Settings\n}\n\n```"
}
] |
code_file-manager-graphql_f5490ffb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of file-manager-graphql/node/FileManager.ts from the file-manager-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { ExternalClient } from '@vtex/api'\n\nimport { FileNotFound } from './exceptions/fileNotFound'\nimport { InternalServerError } from './exceptions/internalServerError'\n\nconst appId = process.env.VTEX_APP_ID\nconst [runningAppName] = appId ? appId.split('@') : ['']\n\nconst FORWARD_FIELDS = ['status', 'statusText', 'data', 'stack', 'stackTrace']\n\nconst pickForwardFields = (object: any) => \n ({ ...Object.fromEntries(FORWARD_FIELDS.map(field => [field, object[field]])) })\n\nconst routes = {\n Assets: () => `/assets/${runningAppName}`,\n FileUpload: (bucket: string, path: string) =>\n `${routes.Assets()}/save/${bucket}/${path}`,\n FileUrl: (bucket: string, path: string) =>\n `${routes.Assets()}/route/${bucket}/${path}`,\n FileDelete: (bucket: string, path: string) =>\n `${routes.Assets()}/delete/${bucket}/${path}`,\n File: (\n path: string,\n width: number,\n height: number,\n aspect: boolean,\n bucket: string\n ) =>\n `${routes.Assets()}/${bucket}/${path}?width=${width}&height=${height}&aspect=${aspect}`,\n}\n\nexport default class FileManager extends ExternalClient {\n \n constructor(protected context: IOContext, options?: InstanceOptions) {\n super(\n `http://app.io.vtex.com/vtex.file-manager/v0/${context.account}/${context.workspace}`,\n context,\n {\n ...(options ?? {}),\n headers: {\n ...(options?.headers ?? {}),\n 'VtexIdclientAutCookie': context.authToken,\n 'Content-Type': 'application/json',\n 'X-Vtex-Use-Https': 'true',\n },\n }\n )\n }\n\n public getFile = async ({\n path,\n width,\n height,\n aspect,\n bucket,\n }: {\n path: string\n width: number\n height: number\n aspect: boolean\n bucket: string\n }) => {\n try {\n return await this.http.get(\n routes.File(path, width, height, aspect, bucket)\n )\n } catch (e) {\n if (e.statusCode === 404 || e.response?.status === 404) {\n throw new FileNotFound(pickForwardFields(e.response))\n } else {\n throw e\n }\n }\n }\n\n getFileUrl = async (path: string, bucket: string) => {\n try {\n const fileUrl = routes.FileUrl(bucket, path)\n const file = await this.http.get(fileUrl)\n return file\n } catch (e) {\n if (e.statusCode === 404 || e.response?.status === 404) {\n throw new FileNotFound(pickForwardFields(e.response))\n } else {\n throw e\n }\n }\n }\n\n saveFile = async (file: IncomingFile, stream: any, bucket: string) => {\n try {\n const { filename, encoding, mimetype } = file\n const headers = {\n 'Content-Type': mimetype,\n 'Content-Encoding': encoding,\n }\n\n return await this.http.put(routes.FileUpload(bucket, filename), stream, {\n headers,\n metric: 'file-manager-save-file',\n })\n } catch (e) {\n const status = e.statusCode || e.response?.status || 500\n const extensions = pickForwardFields(e.response)\n\n throw new InternalServerError(extensions, 'Fail to save file', status)\n }\n }\n\n deleteFile = async (path: string, bucket: string) => {\n try {\n return await this.http.delete(routes.FileDelete(bucket, path), {\n metric: 'file-manager-delete-file',\n })\n } catch (e) {\n if (e.statusCode === 404 || e.response?.status === 404) {\n throw new FileNotFound(pickForwardFields(e.response))\n } else {\n throw e\n }\n }\n }\n}\n\n```"
}
] |
code_file-manager-graphql_0b10b2a1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of file-manager-graphql/node/service.json from the file-manager-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"stack\": \"nodejs\",\n \"memory\": 128,\n \"ttl\": 60,\n \"timeout\": 60,\n \"minReplicas\": 4,\n \"maxReplicas\": 10,\n \"runtimeArgs\": [\"--max_old_space_size=400\"]\n}\n\n```"
}
] |
code_file-manager-graphql_f24dea0e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of file-manager-graphql/node/typings.d.ts from the file-manager-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare global {\n interface IncomingFile {\n filename: string\n mimetype: string\n encoding: string\n }\n}\n\nexport {}\n\n```"
}
] |
code_file-manager-graphql_625e9898
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of file-manager-graphql/node/package.json from the file-manager-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.file-manager-graphql\",\n \"description\": \"GraphQL resolvers. Any required dependencies should be defined in this file.\",\n \"version\": \"0.7.6\",\n \"dependencies\": {\n \"@vtex/api\": \"^7.0.0\",\n \"apollo-upload-server\": \"^5.0.0\",\n \"dompurify\": \"^3.2.6\",\n \"jsdom\": \"21\",\n \"ramda\": \"^0.25.0\",\n \"uuid\": \"^8.2.0\"\n },\n \"resolutions\": {\n \"@types/express\": \"4.16.0\",\n \"@types/express-serve-static-core\": \"4.16.0\"\n },\n \"devDependencies\": {\n \"@types/jest\": \"^24.0.24\",\n \"@types/jsdom\": \"^21.1.7\",\n \"@types/node\": \"^20.0.0\",\n \"@types/uuid\": \"^10.0.0\",\n \"tslint\": \"^5.14.0\",\n \"tslint-config-vtex\": \"^2.1.0\",\n \"typescript\": \"5.5.3\",\n \"vtex.file-manager\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.file-manager@0.11.0/public/_types/react\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit && tslint -c tslint.json './**/*.ts'\"\n }\n}\n\n```"
}
] |
code_file-manager-graphql_73e151f9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of file-manager-graphql/node/index.ts from the file-manager-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { ParamsContext, RecorderState } from '@vtex/api'\nimport { Service } from '@vtex/api'\n\nimport { resolvers } from './resolvers'\nimport type { Clients } from './clients'\nimport { clients } from './clients'\nimport { Authorization } from './directives/auth'\n\nexport default new Service<Clients, RecorderState, ParamsContext>({\n clients,\n graphql: {\n resolvers,\n schemaDirectives: {\n requiresAuth: Authorization,\n },\n },\n})\n\n```"
}
] |
code_file-manager-graphql_956005ad
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of file-manager-graphql/node/directives/auth.ts from the file-manager-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { defaultFieldResolver, GraphQLField } from 'graphql'\nimport { SchemaDirectiveVisitor } from 'graphql-tools'\n\nimport { ALLOW_LIST } from '../config/allowList'\n\nexport const authFromCookie = async (ctx: any, operationName: string) => {\n const {\n clients: { sphinx, vtexID },\n vtex: { authToken },\n } = ctx\n\n const vtexIdToken =\n ctx.cookies.get('VtexIdclientAutCookie') ??\n ctx.request.header.vtexidclientautcookie ??\n ctx.cookies.get('VtexIdclientAutCookie_' + ctx.vtex.account)\n\n if (!vtexIdToken) {\n return 'User must be logged to access this resource'\n }\n\n const { user: email } = (await vtexID.getIdUser(vtexIdToken, authToken)) || {\n user: '',\n }\n\n if (!email) {\n return 'Could not find user specified by token.'\n }\n\n if (operationName === 'deleteFile') {\n // Only admin users can delete files\n const isAdminUser = await sphinx.isAdmin(email)\n\n if (!isAdminUser) {\n return 'User is not admin and can not access resource.'\n }\n }\n\n return true\n}\n\nexport class Authorization extends SchemaDirectiveVisitor {\n public visitFieldDefinition(field: GraphQLField<any, any>) {\n const { resolve = defaultFieldResolver } = field\n\n // eslint-disable-next-line max-params\n field.resolve = async (root, args, ctx, info) => {\n const operationName = info.fieldName\n let isAllowed = false\n\n if (operationName === 'uploadFile') {\n const isInAllowList = ALLOW_LIST.includes(ctx.vtex.account)\n\n if (isInAllowList) {\n isAllowed = true\n }\n }\n\n if (!isAllowed) {\n const cookieAllowsAccess = await authFromCookie(ctx, operationName)\n\n if (cookieAllowsAccess !== true) {\n throw new Error(cookieAllowsAccess)\n }\n }\n\n return resolve(root, args, ctx, info)\n }\n }\n}\n\n```"
}
] |
code_file-manager-graphql_0326a9d2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of file-manager-graphql/node/clients/index.ts from the file-manager-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { ClientsConfig } from '@vtex/api'\nimport { Sphinx, IOClients } from '@vtex/api'\n\nimport { VtexID } from './id'\n\nconst DEFAULT_CLIENT_TIMEOUT = 2 * 60000\n\nexport class Clients extends IOClients {\n public get vtexID() {\n return this.getOrSet('vtexID', VtexID)\n }\n\n public get sphinx() {\n return this.getOrSet('sphinx', Sphinx)\n }\n}\n\nexport const clients: ClientsConfig<Clients> = {\n implementation: Clients,\n options: {\n default: {\n retries: 1,\n timeout: DEFAULT_CLIENT_TIMEOUT,\n },\n },\n}\n\n```"
}
] |
code_file-manager-graphql_bd2aa213
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of file-manager-graphql/node/clients/id.ts from the file-manager-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { ExternalClient, InstanceOptions, IOContext } from '@vtex/api'\n\nconst userAgent = process.env.VTEX_APP_ID!\n\nexport class VtexID extends ExternalClient {\n public constructor(context: IOContext, options?: InstanceOptions) {\n super('http://vtexid.vtex.com.br/api/vtexid', context, options)\n }\n\n public getIdUser = (token: string, authToken: string) =>\n this.http.get(`pub/authenticated/user`, {\n headers: {\n Accept: 'application/json',\n Authorization: authToken,\n 'Content-Type': 'application/json',\n 'User-Agent': userAgent,\n 'X-VTEX-Proxy-To': 'https://vtexid.vtex.com.br',\n 'X-Vtex-Use-Https': true,\n },\n metric: 'vtexid-authtoken',\n params: {\n authToken: token,\n },\n })\n}\n```"
}
] |
code_file-manager-graphql_22fa7e4a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of file-manager-graphql/node/config/allowList.ts from the file-manager-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const ALLOW_LIST = [\n 'storecomponents',\n 'adidasuy',\n 'amakha',\n 'ambientegourmetb2b',\n 'americanas',\n 'amoedo',\n 'animalcare',\n 'animalsveterinaria',\n 'arcaplanetqa',\n 'arraisjoalheria',\n 'artwalk',\n 'asicsar',\n 'aureliusarg',\n 'authogar',\n 'batistellaar',\n 'b2bextratosdaterra',\n 'b2cdistraves',\n 'b2ctrendy',\n 'bellapiel',\n 'bemol',\n 'bosico',\n 'bremenar',\n 'caffarenacl',\n 'calcadosbibi',\n 'calimaxmx',\n 'calzadobucaramanga',\n 'canadiennecl',\n 'carrefourar',\n 'carsaperupoc',\n 'casatema',\n 'cellarvinhos',\n 'cemacogt',\n 'ceramicaitalia',\n 'chedrauimx',\n 'ciatoy',\n 'cnutresa',\n 'cocinailko',\n 'coffeemarleycl',\n 'cograb2b',\n 'colchonesfantasiacol',\n 'columbiaar',\n 'corona',\n 'cutis',\n 'cynthiapamplona',\n 'dallabernardina',\n 'damasco',\n 'dartelcl',\n 'dbebesec',\n 'delupo',\n 'diafer',\n 'discoargentina',\n 'distrollermx',\n 'drogasmil',\n 'electroluxb2bcc',\n 'elbalconar',\n 'exitocol',\n 'extrafarmav2',\n 'farmaonline',\n 'farmaciaindiana',\n 'farmaciasklyns',\n 'farmaciasdelpueblo',\n 'farmaciauniversalpe',\n 'filaar',\n 'fstudio',\n 'furzaiarg',\n 'geant',\n 'gersamex',\n 'ginebra',\n 'gruposoares',\n 'hacebco',\n 'hering',\n 'hopelingerie',\n 'hospinet',\n 'hrojoyas',\n 'imegab2c',\n 'inpostfresh',\n 'irmaossoares',\n 'isesacl',\n 'jorgebischoff',\n 'jorlan',\n 'jumbocolombiaio',\n 'jwpepper',\n 'keralty',\n 'keybiscaynear',\n 'kidsmadehereperu',\n 'kiplingco',\n 'kiplingmexico',\n 'krosscl',\n 'lamarinamx',\n 'lasirena',\n 'ledstudiocl',\n 'levisarg',\n 'levisuy',\n 'librerialerner',\n 'lojaobramax',\n 'lojaspompeia',\n 'lojaspeedo',\n 'lojasrede',\n 'lojavivara',\n 'lojahr',\n 'lotodelsur',\n 'loucossantos',\n 'lunettes',\n 'magazzinoar',\n 'magherar',\n 'marshallmoffat',\n 'mateuarg',\n 'mcxhoreca',\n 'medipielsa',\n 'melimeloparis',\n 'micco',\n 'mkchile',\n 'monumentalar',\n 'mpower',\n 'multicenter',\n 'multitop',\n 'muralsyourway',\n 'murataar',\n 'negrarosaloja',\n 'nespressouy',\n 'newiwcstore',\n 'novaikesaki',\n 'nuevaamericanapy',\n 'officemax',\n 'pandoraar',\n 'panamericanaeditorial',\n 'paguemenos',\n 'paulette',\n 'pcbox',\n 'pedidosfarma',\n 'pentruanimalero',\n 'pepeganga',\n 'pilatos21',\n 'pillin',\n 'pinataar',\n 'plataformaamtres',\n 'privilege',\n 'puntodeportivoar',\n 'ramasamx',\n 'realplaza',\n 'reebokpe',\n 'renawarecolombia',\n 'renawareperu',\n 'roddos',\n 'rocamadour',\n 'rosario',\n 'rsconnect',\n 'safetystoremx',\n 'sallybeautymx',\n 'samsungar',\n 'samsclub',\n 'scandinavianar',\n 'sbslibreria',\n 'sedinternationalb2b',\n 'servicomglobalar',\n 'simanguatemala',\n 'simannicor',\n 'sjdigital',\n 'sportingio',\n 'springstep',\n 'stanleypm',\n 'startar',\n 'tekielar',\n 'tennis',\n 'tfcz36',\n 'tfcqf0',\n 'tfcvgc',\n 'tfcr83',\n 'thinkpinkperub2b',\n 'timesquare',\n 'tommyperu',\n 'tommycostarica',\n 'tonypapelerias',\n 'tosel',\n 'totouy',\n 'tottoecuador',\n 'tpvcl',\n 'tuaar',\n 'tuachlb2b',\n 't55018',\n 't06512',\n 'underarmourcl',\n 'unidrogas',\n 'vansuy',\n 'vitrioenhancedpartnerbr',\n 'wokerio',\n 'xuss',\n 'yagmourio',\n 'yuhmak',\n]\n\n```"
}
] |
code_file-manager-graphql_cddaa109
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of file-manager-graphql/node/exceptions/fileNotFound.ts from the file-manager-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport class FileNotFound extends Error {\n constructor(\n public extensions: any,\n public message = 'File Not Found',\n public statusCode = 404\n ) {\n super(message)\n }\n}\n\n```"
}
] |
code_file-manager-graphql_dac10203
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of file-manager-graphql/node/exceptions/internalServerError.ts from the file-manager-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport class InternalServerError extends Error {\n constructor(\n public extensions: any,\n public message = 'Internal Server Error',\n public statusCode = 500\n ) {\n super(message)\n }\n}\n\n```"
}
] |
code_file-manager-graphql_714a58f5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of file-manager-graphql/node/resolvers/index.ts from the file-manager-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { v4 as uuidv4 } from 'uuid'\nimport { JSDOM } from 'jsdom'\nimport createDOMPurify from 'dompurify'\n// eslint-disable-next-line prettier/prettier \nimport type { ServiceContext } from '@vtex/api'\n\nimport FileManager from '../FileManager'\nimport { Readable } from 'stream'\n\n\ntype FileManagerArgs = {\n path: string\n width: number\n height: number\n aspect: boolean\n bucket: string\n}\n\ntype UploadFileArgs = {\n file: Promise<any>\n bucket: string\n}\n\nconst isValidFileFormat = (extension: string, mimetype: string) => {\n\n if (!extension || !mimetype) {\n return false\n }\n\n // Normalize extension to lowercase\n const normalizedExtension = extension.toLowerCase()\n\n // Define allowed file types with their corresponding MIME types\n const allowedFileTypes = {\n png: 'image/png',\n jpg: 'image/jpeg',\n jpeg: 'image/jpeg',\n gif: 'image/gif',\n webp: 'image/webp',\n svg: 'image/svg+xml',\n pdf: 'application/pdf',\n doc: 'application/msword',\n docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n xls: 'application/vnd.ms-excel',\n xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n txt: 'text/plain',\n}\n\n if(!(extension in allowedFileTypes)) {\n return false\n }\n\n return normalizedExtension in allowedFileTypes && allowedFileTypes[normalizedExtension as keyof typeof allowedFileTypes] === mimetype\n}\n\nconst sanitizeSvgFile = async (loadedFile: any) => {\n const fileBuffer = await loadedFile.createReadStream().toArray()\n const fileString = Buffer.concat(fileBuffer).toString('utf8')\n \n const {window} = new JSDOM('')\n const DOMPurify = createDOMPurify(window)\n\n const cleanSvgString = DOMPurify.sanitize(fileString, {\n USE_PROFILES: { svg: true },\n })\n \n return {\n isSafe: typeof cleanSvgString === 'string' &&\n cleanSvgString.trim().length > 0 &&\n cleanSvgString.includes('<svg'),\n sanitizedContent: cleanSvgString,\n }\n}\n\nexport const resolvers = {\n Query: {\n getFile: async (_: unknown, args: FileManagerArgs, ctx: ServiceContext) => {\n const fileManager = new FileManager(ctx.vtex)\n const { path, width, height, aspect, bucket } = args\n\n const file = await fileManager.getFile({path, width, height, aspect, bucket})\n\n return file\n },\n getFileUrl: async (_: unknown, args: FileManagerArgs, ctx: ServiceContext) => {\n const fileManager = new FileManager(ctx.vtex)\n const { path, bucket } = args\n\n const file = await fileManager.getFileUrl(path, bucket)\n\n return file\n },\n settings: async () => ({\n maxFileSizeMB: 4,\n }),\n },\n Mutation: {\n uploadFile: async (_: unknown, args: UploadFileArgs, ctx: ServiceContext) => {\n const fileManager = new FileManager(ctx.vtex)\n const { file, bucket } = args\n let loadedFile = await file\n const {filename: name, mimetype, encoding } = loadedFile\n const [extension] = name?.split('.')?.reverse()\n\n if (!isValidFileFormat(extension, mimetype)) {\n throw new Error('Invalid file format') \n }\n\n // Validate SVG files separately\n // SVG files require additional validation to prevent XSS attacks\n // and other security issues, so we check if the file is SVG\n // and sanitize it if necessary. \n\n if (mimetype === 'image/svg+xml') { \n const {isSafe, sanitizedContent} = await sanitizeSvgFile(loadedFile)\n if (!isSafe) { \n throw new Error('Forced attempt to upload unsafe SVG file with no valid content')\n }\n \n const sanitizedBuffer = Buffer.from(sanitizedContent, 'utf8')\n\n loadedFile.createReadStream = () => Readable.from(sanitizedBuffer) \n }\n\n const filename = `${uuidv4()}.${extension}`\n const stream = loadedFile.createReadStream()\n\n const incomingFile = { filename, mimetype, encoding }\n\n return {\n encoding,\n mimetype,\n fileUrl: await fileManager.saveFile(incomingFile, stream, bucket),\n }\n },\n deleteFile: async (_: unknown, args: FileManagerArgs, ctx: ServiceContext) => {\n const fileManager = new FileManager(ctx.vtex)\n const { path, bucket } = args\n\n await fileManager.deleteFile(path, bucket)\n\n return true\n },\n },\n}\n\n```"
}
] |
code_io-landing_e04a44f4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of io-landing/messages/pt.json from the io-landing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"io.page-title\": \"VTEX IO\",\n \"io.navbar.learn\": \"Learn\",\n \"io.navbar.feature-list\": \"Our Components\",\n \"io.navbar.keepup\": \"Keep Up\",\n \"io.navbar.build\": \"Build with IO\",\n \"io.navbar.faq\": \"FAQ\",\n \"io.hero.globalbrands\": \"Build for global brands.\",\n \"io.hero.resources\": \"With right resources at hand, you will help expand the possibilities of businesses around the world.\",\n \"io.hero.cta\": \"Build stores with IO\",\n \"io.hero.partners\": \"Learn about our Partner Program\",\n \"io.cards.first.title\": \"Get Started with IO\",\n \"io.cards.first.text\": \"Learn the basics and start building apps, extensions and integrations.\",\n \"io.cards.second.title\": \"IO Master Class\",\n \"io.cards.second.text\": \"Watch videos and take a deep dive into all things IO: tools, tips, and possibilities.\",\n \"io.cards.third.title\": \"Explore our Components\",\n \"io.cards.third.text\": \"Explore the components we've developed and explore our available and upcoming features.\",\n \"io.cards.fourth.title\": \"Frequently Asked Questions\",\n \"io.cards.fourth.text\": \"Find the answers you are looking for.\",\n \"io.product.deliver\": \"Deliver more, deliver better\",\n \"io.product.scale\": \"Tailor-made meets scale.\",\n \"io.product.cloud\": \"With a cloud environment and an integrated commerce-drive toolset, it's a lot easier for retailers and developers to scale solutions for specific needs.\",\n \"io.howitworks.appstore\": \"App Store\",\n \"io.howitworks.appstore.scale\": \"Solutions that scale\",\n \"io.howitworks.appstore.solutions\": \"Make your business-driven solutions available to 2.500+ stores in 25 countries through our exclusive distribution channel.\",\n \"io.howitworks.abtesting\": \"A/B Testing\",\n \"io.howitworks.abtesting.decisions\": \"Informed business decisions\",\n \"io.howitworks.abtesting.tests\": \"Perform tests on every aspect of your business to learn what works best. Use the isolated Test Workspaces to iterate faster, increase sales, and raise conversion rates.\",\n \"io.howitworks.storeframework\": \"Store Framework\",\n \"io.howitworks.storeframework.build\": \"Build faster, grow better\",\n \"io.howitworks.storeframework.develop\": \"Reduce loading time, improve usability, and make the best of SEO. Developing scalable components with a comprehensive, easy-to-use toolset, you can build stores faster than ever.\",\n \"io.evolution.focus\": \"Focus on what matters\",\n \"io.evolution.evolution\": \"Seamless evolution.\",\n \"io.evolution.perspective\": \"VTEX IO delivers a new paradigm for cloud software development that’s heavily integrated into the environment where your code will actually run. This shift in perspective unlocks new capabilities that were impossible on the traditional, local development model.\",\n \"io.evolution.vtexio\": \"VTEX IO\",\n \"io.evolution.vtexio.description\": \"It's our serverless development platform, designed to help you create scalable, production-ready web applications – and never have to worry about any infrastructure complexity again.\",\n \"io.features.title\": \"Powerful tools to power-up your solutions.\",\n \"io.features.title.small\": \"Make the most out of your work\",\n \"io.features.cloud\": \"Works on the cloud\",\n \"io.features.cloud.description\": \"It's the end of the mismatch between local and production environments. No code runs on your computer: The source gets synced to the cloud, where it is built and deployed in real-time.\",\n \"io.features.setupless\": \"Setupless\",\n \"io.features.setupless.description\": \"No need to oldfashioned developer environment setup anymore. All you need to start building apps is a lightweight console application and a developer account.\",\n \"io.features.workspaces\": \"Workspaces\",\n \"io.features.workspaces.description\": \"Instantaneous app deploy and rollback with a single command. Manage different versions of your apps and test new features in isolation, with the peace of mind you need to experiment and evolve to quickly.\",\n \"io.features.serverless\": \"Serverless\",\n \"io.features.serverless.description\": \"Our infrastructure is designed to scale your code according to traffic. CDN distribution and the SmartCacheⓇ system guarantees high performance and low latency.\",\n \"io.startbuilding.title\": \"Start building the future of commerce.\",\n \"io.startbuilding.text\": \"Build apps with cutting-edge technology, meet the needs of world-class brands and expand the possibilities of retail.\",\n \"io.startbuilding.cta\": \"BECOME A PARTNER\",\n \"io.footer.vtex\": \"Accelerating Commerce Transformation.\",\n \"io.footer.pricing\": \"Pricing\",\n \"io.footer.company\": \"Company\",\n \"io.footer.company.carrers\": \"Carrers\",\n \"io.footer.company.partnersAWS\": \"Partners AWS\",\n \"io.footer.company.dmca\": \"DMCA Policy\",\n \"io.footer.company.blog\": \"Blog\",\n \"io.footer.resources\": \"Resources\",\n \"io.footer.resources.devdocs\": \"Development Docs\",\n \"io.footer.resources.support\": \"Support\",\n \"io.footer.resources.announcements\": \"Announcements\",\n \"io.footer.resources.releases\": \"Releases\",\n \"io.footer.resources.status\": \"Status\",\n \"io.footer.resources.health\": \"Health Check\",\n \"io.footer.resources.vtexio\": \"VTEX IO\",\n \"io.footer.partners\": \"Partners\",\n \"io.footer.partners.vtex\": \"VTEX Partners\",\n \"io.footer.partners.find\": \"Find a partner\",\n \"io.footer.partners.program\": \"Partner Program\",\n \"io.footer.partners.appstore\": \"VTEX App Store\",\n \"io.faq.page-title\": \"FAQ - VTEX IO\",\n \"io.faq.basic-concepts.vtex-vtexio.summary\": \"What's the difference between VTEX and VTEX IO?\",\n \"io.faq.basic-concepts.vtex-vtexio.ans\": \"\",\n \"io.faq.migrate.why-v1-no-more.summary\": \"Why was v1 discontinued?\",\n \"io.faq.migrate.why-v1-no-more.ans\": \"\",\n \"io.faq.migrate.why-migrate.summary\": \"Why should I upgrade to v2?\",\n \"io.faq.migrate.why-migrate.ans\": \"You should upgrade so that you have access to the full power and capabilities of VTEX IO and Store Framework, the latest and greatest VTEX has to offer. Also, stay up to date with every new feature we develop in a seamless way, just as described at https://vtex.io .\",\n \"io.faq.migrate.advantages-v2.summary\": \"What are the advantages of using Store v2?\",\n \"io.faq.migrate.advantages-v2.ans\": \"\",\n \"io.faq.migrate.unavailable-features.summary\": \"Are there functionalities that were available in v1 but not in v2?\",\n \"io.faq.migrate.unavailable-features.ans\": \"For a full feature comparison between our new CMS and our old one, you can check out https://vtex.io/store-features .\",\n \"io.faq.migrate.how-to.summary\": \"How can I get started with migrating to v2?\",\n \"io.faq.migrate.how-to.ans\": \"Currently there is not an automated process to migrate a store from v1 to v2. Basically the front-end needs to be rebuilt using our Store Framework.\",\n \"io.faq.create-store.components.summary\": \"What components already exist?\",\n \"io.faq.create-store.components.ans\": \"Quite a few! And new ones are coming. You can check out a list at https://vtex.io/store-features#store-component-apps .\",\n \"io.faq.create-store.components-functionality.summary\": \"Will I be able to implement functionalities I need using the components already provided by VTEX or should I build my own?\",\n \"io.faq.create-store.components-functionality.ans\": \"We strongly recommend everyone to use the components already provided by VTEX, as they already offer a certain degree of customization and are fully supported by the Store Framework team. If you want some new feature that we do not support yet, please check our contributing guidelines so that you can maybe add this feature to our components and make it available to everyone (open-source rules!). \",\n \"io.faq.create-store.unsupported.summary\": \"What is not supported by Store v2?\",\n \"io.faq.create-store.unsupported.ans\": \"We don't fully support (for now) exclusive features for: marketplaces, B2B, delivery and grocery. For the time being we will not be making any modification to our components so that they support those specific use cases.\",\n \"io.faq.create-store.supported.summary\": \"What is supported by Store v2?\",\n \"io.faq.create-store.supported.ans\": \"We support all common features for basic stores that sell items which don't require a great degree of personalization, such as: fashion, home appliances, cosmedics and sporting goods.\",\n \"io.faq.create-store.to-PR-or-not-to-PR.summary\": \"How do I know if I should create a new app or send a PR to make an existing app better?\",\n \"io.faq.create-store.to-PR-or-not-to-PR.ans\": \"We always encourage everyone to contribute to the development of all components we build, that's why they are all open-source! Check out our contributing guidelines for a better guide on how to send that PR or discuss a new feature you want to implement, they live at: https://github.com/vtex-apps/awesome-io .\",\n \"io.faq.create-store.component-docs.summary\": \"Where can I find documentation on which props (or blocks) can be passed to each block?\",\n \"io.faq.create-store.component-docs.ans\": \"Each block is exported by a component built by the Store Framework team, and their documentation lives in each one of their GitHub repositories. You can check out our list of available components and the links to each repository at https://vtex.io/store-features#store-component-apps .\",\n \"io.faq.extend-store-framework.summary\": \"How can I extend the provided functionalities from Store Framework?\",\n \"io.faq.extend-store-framework.ans\": \"Due to a recent change in the way VTEX is handling extensibility with VTEX IO, in order to garantee quality support to every client by VTEX support team, agencies that do not have enterprise accounts will have limited access to extensibility features and can only publish and install apps into their VTEX accounts, but not create apps extending features provided by Store Framework.\",\n \"io.faq.create-front-end-app.already-exists.summary\": \"How do I know if an app I want to create already exists?\",\n \"io.faq.create-front-end-app.already-exists.ans\": \"\",\n \"io.faq.create-front-end-app.getting-started.summary\": \"How can I get started developing front-end apps?\",\n \"io.faq.create-front-end-app.getting-started.ans\": \"\",\n \"io.faq.create-front-end-app.how-to-whitelist.summary\": \"What is the criteria I need to meet in order to get into the whitelist?\",\n \"io.faq.create-front-end-app.how-to-whitelist.ans\": \"\",\n \"io.faq.create-back-end-app.permission.summary\": \"Can I develop Node + GraphQL apps?\",\n \"io.faq.create-back-end-app.permission.ans\": \"The use of Node and GraphQL will only be allowed to enterprise accounts that want to create new features that support their store development.\"\n}\n\n```"
}
] |
code_io-landing_e7d492c2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of io-landing/messages/en.json from the io-landing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"io.page-title\": \"VTEX IO\",\n \"io.navbar.learn\": \"Learn\",\n \"io.navbar.feature-list\": \"Our Components\",\n \"io.navbar.keepup\": \"Keep Up\",\n \"io.navbar.build\": \"Build with IO\",\n \"io.navbar.faq\": \"FAQ\",\n \"io.hero.globalbrands\": \"Build for global brands.\",\n \"io.hero.resources\": \"With right resources at hand, you will help expand the possibilities of businesses around the world.\",\n \"io.hero.cta\": \"Build stores with IO\",\n \"io.hero.partners\": \"Learn about our Partner Program\",\n \"io.cards.first.title\": \"Get Started with IO\",\n \"io.cards.first.text\": \"Learn the basics and start building apps, extensions and integrations.\",\n \"io.cards.second.title\": \"IO Master Class\",\n \"io.cards.second.text\": \"Watch videos and take a deep dive into all things IO: tools, tips, and possibilities.\",\n \"io.cards.third.title\": \"Explore our Components\",\n \"io.cards.third.text\": \"Explore the components we've developed and explore our available and upcoming features.\",\n \"io.cards.fourth.title\": \"Frequently Asked Questions\",\n \"io.cards.fourth.text\": \"Find the answers you are looking for.\",\n \"io.product.deliver\": \"Deliver more, deliver better\",\n \"io.product.scale\": \"Tailor-made meets scale.\",\n \"io.product.cloud\": \"With a cloud environment and an integrated commerce-drive toolset, it's a lot easier for retailers and developers to scale solutions for specific needs.\",\n \"io.howitworks.appstore\": \"App Store\",\n \"io.howitworks.appstore.scale\": \"Solutions that scale\",\n \"io.howitworks.appstore.solutions\": \"Make your business-driven solutions available to 2.500+ stores in 25 countries through our exclusive distribution channel.\",\n \"io.howitworks.abtesting\": \"A/B Testing\",\n \"io.howitworks.abtesting.decisions\": \"Informed business decisions\",\n \"io.howitworks.abtesting.tests\": \"Perform tests on every aspect of your business to learn what works best. Use the isolated Test Workspaces to iterate faster, increase sales, and raise conversion rates.\",\n \"io.howitworks.storeframework\": \"Store Framework\",\n \"io.howitworks.storeframework.build\": \"Build faster, grow better\",\n \"io.howitworks.storeframework.develop\": \"Reduce loading time, improve usability, and make the best of SEO. Developing scalable components with a comprehensive, easy-to-use toolset, you can build stores faster than ever.\",\n \"io.evolution.focus\": \"Focus on what matters\",\n \"io.evolution.evolution\": \"Seamless evolution.\",\n \"io.evolution.perspective\": \"VTEX IO delivers a new paradigm for cloud software development that’s heavily integrated into the environment where your code will actually run. This shift in perspective unlocks new capabilities that were impossible on the traditional, local development model.\",\n \"io.evolution.vtexio\": \"VTEX IO\",\n \"io.evolution.vtexio.description\": \"It's our serverless development platform, designed to help you create scalable, production-ready web applications – and never have to worry about any infrastructure complexity again.\",\n \"io.features.title\": \"Powerful tools to power-up your solutions.\",\n \"io.features.title.small\": \"Make the most out of your work\",\n \"io.features.cloud\": \"Works on the cloud\",\n \"io.features.cloud.description\": \"It's the end of the mismatch between local and production environments. No code runs on your computer: The source gets synced to the cloud, where it is built and deployed in real-time.\",\n \"io.features.setupless\": \"Setupless\",\n \"io.features.setupless.description\": \"No need to oldfashioned developer environment setup anymore. All you need to start building apps is a lightweight console application and a developer account.\",\n \"io.features.workspaces\": \"Workspaces\",\n \"io.features.workspaces.description\": \"Instantaneous app deploy and rollback with a single command. Manage different versions of your apps and test new features in isolation, with the peace of mind you need to experiment and evolve to quickly.\",\n \"io.features.serverless\": \"Serverless\",\n \"io.features.serverless.description\": \"Our infrastructure is designed to scale your code according to traffic. CDN distribution and the SmartCacheⓇ system guarantees high performance and low latency.\",\n \"io.startbuilding.title\": \"Start building the future of commerce.\",\n \"io.startbuilding.text\": \"Build apps with cutting-edge technology, meet the needs of world-class brands and expand the possibilities of retail.\",\n \"io.startbuilding.cta\": \"BECOME A PARTNER\",\n \"io.footer.vtex\": \"Accelerating Commerce Transformation.\",\n \"io.footer.pricing\": \"Pricing\",\n \"io.footer.company\": \"Company\",\n \"io.footer.company.carrers\": \"Carrers\",\n \"io.footer.company.partnersAWS\": \"Partners AWS\",\n \"io.footer.company.dmca\": \"DMCA Policy\",\n \"io.footer.company.blog\": \"Blog\",\n \"io.footer.resources\": \"Resources\",\n \"io.footer.resources.devdocs\": \"Development Docs\",\n \"io.footer.resources.support\": \"Support\",\n \"io.footer.resources.announcements\": \"Announcements\",\n \"io.footer.resources.releases\": \"Releases\",\n \"io.footer.resources.status\": \"Status\",\n \"io.footer.resources.health\": \"Health Check\",\n \"io.footer.resources.vtexio\": \"VTEX IO\",\n \"io.footer.partners\": \"Partners\",\n \"io.footer.partners.vtex\": \"VTEX Partners\",\n \"io.footer.partners.find\": \"Find a partner\",\n \"io.footer.partners.program\": \"Partner Program\",\n \"io.footer.partners.appstore\": \"VTEX App Store\",\n \"io.faq.page-title\": \"FAQ - VTEX IO\",\n \"io.faq.basic-concepts.vtex-vtexio.summary\": \"What's the difference between VTEX and VTEX IO?\",\n \"io.faq.basic-concepts.vtex-vtexio.ans\": \"\",\n \"io.faq.migrate.why-v1-no-more.summary\": \"Why was v1 discontinued?\",\n \"io.faq.migrate.why-v1-no-more.ans\": \"\",\n \"io.faq.migrate.why-migrate.summary\": \"Why should I upgrade to v2?\",\n \"io.faq.migrate.why-migrate.ans\": \"You should upgrade so that you have access to the full power and capabilities of VTEX IO and Store Framework, the latest and greatest VTEX has to offer. Also, stay up to date with every new feature we develop in a seamless way, just as described at https://vtex.io .\",\n \"io.faq.migrate.advantages-v2.summary\": \"What are the advantages of using Store v2?\",\n \"io.faq.migrate.advantages-v2.ans\": \"\",\n \"io.faq.migrate.unavailable-features.summary\": \"Are there functionalities that were available in v1 but not in v2?\",\n \"io.faq.migrate.unavailable-features.ans\": \"For a full feature comparison between our new CMS and our old one, you can check out https://vtex.io/store-features .\",\n \"io.faq.migrate.how-to.summary\": \"How can I get started with migrating to v2?\",\n \"io.faq.migrate.how-to.ans\": \"Currently there is not an automated process to migrate a store from v1 to v2. Basically the front-end needs to be rebuilt using our Store Framework.\",\n \"io.faq.create-store.components.summary\": \"What components already exist?\",\n \"io.faq.create-store.components.ans\": \"Quite a few! And new ones are coming. You can check out a list at https://vtex.io/store-features#store-component-apps .\",\n \"io.faq.create-store.components-functionality.summary\": \"Will I be able to implement functionalities I need using the components already provided by VTEX or should I build my own?\",\n \"io.faq.create-store.components-functionality.ans\": \"We strongly recommend everyone to use the components already provided by VTEX, as they already offer a certain degree of customization and are fully supported by the Store Framework team. If you want some new feature that we do not support yet, please check our contributing guidelines so that you can maybe add this feature to our components and make it available to everyone (open-source rules!). \",\n \"io.faq.create-store.unsupported.summary\": \"What is not supported by Store v2?\",\n \"io.faq.create-store.unsupported.ans\": \"We don't fully support (for now) exclusive features for: marketplaces, B2B, delivery and grocery. For the time being we will not be making any modification to our components so that they support those specific use cases.\",\n \"io.faq.create-store.supported.summary\": \"What is supported by Store v2?\",\n \"io.faq.create-store.supported.ans\": \"We support all common features for basic stores that sell items which don't require a great degree of personalization, such as: fashion, home appliances, cosmedics and sporting goods.\",\n \"io.faq.create-store.to-PR-or-not-to-PR.summary\": \"How do I know if I should create a new app or send a PR to make an existing app better?\",\n \"io.faq.create-store.to-PR-or-not-to-PR.ans\": \"We always encourage everyone to contribute to the development of all components we build, that's why they are all open-source! Check out our contributing guidelines for a better guide on how to send that PR or discuss a new feature you want to implement, they live at: https://github.com/vtex-apps/awesome-io .\",\n \"io.faq.create-store.component-docs.summary\": \"Where can I find documentation on which props (or blocks) can be passed to each block?\",\n \"io.faq.create-store.component-docs.ans\": \"Each block is exported by a component built by the Store Framework team, and their documentation lives in each one of their GitHub repositories. You can check out our list of available components and the links to each repository at https://vtex.io/store-features#store-component-apps .\",\n \"io.faq.extend-store-framework.summary\": \"How can I extend the provided functionalities from Store Framework?\",\n \"io.faq.extend-store-framework.ans\": \"Due to a recent change in the way VTEX is handling extensibility with VTEX IO, in order to garantee quality support to every client by VTEX support team, agencies that do not have enterprise accounts will have limited access to extensibility features and can only publish and install apps into their VTEX accounts, but not create apps extending features provided by Store Framework.\",\n \"io.faq.create-front-end-app.already-exists.summary\": \"How do I know if an app I want to create already exists?\",\n \"io.faq.create-front-end-app.already-exists.ans\": \"\",\n \"io.faq.create-front-end-app.getting-started.summary\": \"How can I get started developing front-end apps?\",\n \"io.faq.create-front-end-app.getting-started.ans\": \"\",\n \"io.faq.create-front-end-app.how-to-whitelist.summary\": \"What is the criteria I need to meet in order to get into the whitelist?\",\n \"io.faq.create-front-end-app.how-to-whitelist.ans\": \"\",\n \"io.faq.create-back-end-app.permission.summary\": \"Can I develop Node + GraphQL apps?\",\n \"io.faq.create-back-end-app.permission.ans\": \"The use of Node and GraphQL will only be allowed to enterprise accounts that want to create new features that support their store development.\"\n}\n\n```"
}
] |
code_io-landing_1a916ab2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of io-landing/messages/context.json from the io-landing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"io.page-title\": \"VTEX IO\",\n \"io.navbar.learn\": \"Learn\",\n \"io.navbar.feature-list\": \"Store Features\",\n \"io.navbar.keepup\": \"Keep Up\",\n \"io.navbar.build\": \"Build with IO\",\n \"io.navbar.faq\": \"FAQ\",\n \"io.hero.globalbrands\": \"Build for global brands.\",\n \"io.hero.resources\": \"With right resources at hand, you will help expand the possibilities of businesses around the world.\",\n \"io.hero.cta\": \"Build stores with IO\",\n \"io.hero.partners\": \"Learn about our Partner Program\",\n \"io.cards.first.title\": \"Get Started with IO\",\n \"io.cards.first.text\": \"Learn the basics and start building apps, extensions and integrations.\",\n \"io.cards.second.title\": \"IO Master Class\",\n \"io.cards.second.text\": \"Watch videos and take a deep dive into all things IO: tools, tips, and possibilities.\",\n \"io.cards.third.title\": \"Explore our Components\",\n \"io.cards.third.text\": \"Explore the components we've developed and explore our available and upcoming features.\",\n \"io.cards.fourth.title\": \"Frequently Asked Questions\",\n \"io.cards.fourth.text\": \"Find the answers you are looking for.\",\n \"io.product.deliver\": \"Deliver more, deliver better\",\n \"io.product.scale\": \"Tailor-made meets scale.\",\n \"io.product.cloud\": \"With a cloud environment and an integrated commerce-drive toolset, it's a lot easier for retailers and developers to scale solutions for specific needs.\",\n \"io.howitworks.appstore\": \"App Store\",\n \"io.howitworks.appstore.scale\": \"Solutions that scale\",\n \"io.howitworks.appstore.solutions\": \"Make your business-driven solutions available to 2.500+ stores in 25 countries through our exclusive distribution channel.\",\n \"io.howitworks.abtesting\": \"A/B Testing\",\n \"io.howitworks.abtesting.decisions\": \"Informed business decisions\",\n \"io.howitworks.abtesting.tests\": \"Perform tests on every aspect of your business to learn what works best. Use the isolated Test Workspaces to iterate faster, increase sales, and raise conversion rates.\",\n \"io.howitworks.storeframework\": \"Store Framework\",\n \"io.howitworks.storeframework.build\": \"Build faster, grow better\",\n \"io.howitworks.storeframework.develop\": \"Reduce loading time, improve usability, and make the best of SEO. Developing scalable components with a comprehensive, easy-to-use toolset, you can build stores faster than ever.\",\n \"io.evolution.focus\": \"Focus on what matters\",\n \"io.evolution.evolution\": \"Seamless evolution.\",\n \"io.evolution.perspective\": \"VTEX IO delivers a new paradigm for cloud software development that’s heavily integrated into the environment where your code will actually run. This shift in perspective unlocks new capabilities that were impossible on the traditional, local development model.\",\n \"io.evolution.vtexio\": \"VTEX IO\",\n \"io.evolution.vtexio.description\": \"It's our serverless development platform, designed to help you create scalable, production-ready web applications – and never have to worry about any infrastructure complexity again.\",\n \"io.features.title\": \"Powerful tools to power-up your solutions.\",\n \"io.features.title.small\": \"Make the most out of your work\",\n \"io.features.cloud\": \"Works on the cloud\",\n \"io.features.cloud.description\": \"It's the end of the mismatch between local and production environments. No code runs on your computer: The source gets synced to the cloud, where it is built and deployed in real-time.\",\n \"io.features.setupless\": \"Setupless\",\n \"io.features.setupless.description\": \"No need to oldfashioned developer environment setup anymore. All you need to start building apps is a lightweight console application and a developer account.\",\n \"io.features.workspaces\": \"Workspaces\",\n \"io.features.workspaces.description\": \"Instantaneous app deploy and rollback with a single command. Manage different versions of your apps and test new features in isolation, with the peace of mind you need to experiment and evolve to quickly.\",\n \"io.features.serverless\": \"Serverless\",\n \"io.features.serverless.description\": \"Our infrastructure is designed to scale your code according to traffic. CDN distribution and the SmartCacheⓇ system guarantees high performance and low latency.\",\n \"io.startbuilding.title\": \"Start building the future of commerce.\",\n \"io.startbuilding.text\": \"Build apps with cutting-edge technology, meet the needs of world-class brands and expand the possibilities of retail.\",\n \"io.startbuilding.cta\": \"BECOME A PARTNER\",\n \"io.footer.vtex\": \"Accelerating Commerce Transformation.\",\n \"io.footer.pricing\": \"Pricing\",\n \"io.footer.company\": \"Company\",\n \"io.footer.company.carrers\": \"Carrers\",\n \"io.footer.company.partnersAWS\": \"Partners AWS\",\n \"io.footer.company.dmca\": \"DMCA Policy\",\n \"io.footer.company.blog\": \"Blog\",\n \"io.footer.resources\": \"Resources\",\n \"io.footer.resources.devdocs\": \"Development Docs\",\n \"io.footer.resources.support\": \"Support\",\n \"io.footer.resources.announcements\": \"Announcements\",\n \"io.footer.resources.releases\": \"Releases\",\n \"io.footer.resources.status\": \"Status\",\n \"io.footer.resources.health\": \"Health Check\",\n \"io.footer.resources.vtexio\": \"VTEX IO\",\n \"io.footer.partners\": \"Partners\",\n \"io.footer.partners.vtex\": \"VTEX Partners\",\n \"io.footer.partners.find\": \"Find a partner\",\n \"io.footer.partners.program\": \"Partner Program\",\n \"io.footer.partners.appstore\": \"VTEX App Store\",\n \"io.faq.page-title\": \"FAQ - VTEX IO\",\n \"io.faq.basic-concepts.vtex-vtexio.summary\": \"What's the difference between VTEX and VTEX IO?\",\n \"io.faq.basic-concepts.vtex-vtexio.ans\": \"\",\n \"io.faq.migrate.why-v1-no-more.summary\": \"Why was v1 discontinued?\",\n \"io.faq.migrate.why-v1-no-more.ans\": \"\",\n \"io.faq.migrate.why-migrate.summary\": \"Why should I upgrade to v2?\",\n \"io.faq.migrate.why-migrate.ans\": \"You should upgrade so that you have access to the full power and capabilities of VTEX IO and Store Framework, the latest and greatest VTEX has to offer. Also, stay up to date with every new feature we develop in a seamless way, just as described at https://vtex.io .\",\n \"io.faq.migrate.advantages-v2.summary\": \"What are the advantages of using Store v2?\",\n \"io.faq.migrate.advantages-v2.ans\": \"\",\n \"io.faq.migrate.unavailable-features.summary\": \"Are there functionalities that were available in v1 but not in v2?\",\n \"io.faq.migrate.unavailable-features.ans\": \"For a full feature comparison between our new CMS and our old one, you can check out https://vtex.io/store-features .\",\n \"io.faq.migrate.how-to.summary\": \"How can I get started with migrating to v2?\",\n \"io.faq.migrate.how-to.ans\": \"Currently there is not an automated process to migrate a store from v1 to v2. Basically the front-end needs to be rebuilt using our Store Framework.\",\n \"io.faq.create-store.components.summary\": \"What components already exist?\",\n \"io.faq.create-store.components.ans\": \"Quite a few! And new ones are coming. You can check out a list at https://vtex.io/store-features#store-component-apps .\",\n \"io.faq.create-store.components-functionality.summary\": \"Will I be able to implement functionalities I need using the components already provided by VTEX or should I build my own?\",\n \"io.faq.create-store.components-functionality.ans\": \"We strongly recommend everyone to use the components already provided by VTEX, as they already offer a certain degree of customization and are fully supported by the Store Framework team. If you want some new feature that we do not support yet, please check our contributing guidelines so that you can maybe add this feature to our components and make it available to everyone (open-source rules!). \",\n \"io.faq.create-store.unsupported.summary\": \"What is not supported by Store v2?\",\n \"io.faq.create-store.unsupported.ans\": \"We don't fully support (for now) exclusive features for: marketplaces, B2B, delivery and grocery. For the time being we will not be making any modification to our components so that they support those specific use cases.\",\n \"io.faq.create-store.supported.summary\": \"What is supported by Store v2?\",\n \"io.faq.create-store.supported.ans\": \"We support all common features for basic stores that sell items which don't require a great degree of personalization, such as: fashion, home appliances, cosmedics and sporting goods.\",\n \"io.faq.create-store.to-PR-or-not-to-PR.summary\": \"How do I know if I should create a new app or send a PR to make an existing app better?\",\n \"io.faq.create-store.to-PR-or-not-to-PR.ans\": \"We always encourage everyone to contribute to the development of all components we build, that's why they are all open-source! Check out our contributing guidelines for a better guide on how to send that PR or discuss a new feature you want to implement, they live at: https://github.com/vtex-apps/awesome-io .\",\n \"io.faq.create-store.component-docs.summary\": \"Where can I find documentation on which props (or blocks) can be passed to each block?\",\n \"io.faq.create-store.component-docs.ans\": \"Each block is exported by a component built by the Store Framework team, and their documentation lives in each one of their GitHub repositories. You can check out our list of available components and the links to each repository at https://vtex.io/store-features#store-component-apps .\",\n \"io.faq.extend-store-framework.summary\": \"How can I extend the provided functionalities from Store Framework?\",\n \"io.faq.extend-store-framework.ans\": \"Due to a recent change in the way VTEX is handling extensibility with VTEX IO, in order to garantee quality support to every client by VTEX support team, agencies that do not have enterprise accounts will have limited access to extensibility features and can only publish and install apps into their VTEX accounts, but not create apps extending features provided by Store Framework.\",\n \"io.faq.create-front-end-app.already-exists.summary\": \"How do I know if an app I want to create already exists?\",\n \"io.faq.create-front-end-app.already-exists.ans\": \"\",\n \"io.faq.create-front-end-app.getting-started.summary\": \"How can I get started developing front-end apps?\",\n \"io.faq.create-front-end-app.getting-started.ans\": \"\",\n \"io.faq.create-front-end-app.how-to-whitelist.summary\": \"What is the criteria I need to meet in order to get into the whitelist?\",\n \"io.faq.create-front-end-app.how-to-whitelist.ans\": \"\",\n \"io.faq.create-back-end-app.permission.summary\": \"Can I develop Node + GraphQL apps?\",\n \"io.faq.create-back-end-app.permission.ans\": \"The use of Node and GraphQL will only be allowed to enterprise accounts that want to create new features that support their store development.\"\n}\n\n```"
}
] |
code_io-landing_75a24ac7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of io-landing/docs/README.md from the io-landing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# VTEX IO\n\nIt's our serverless development platform, designed to help you create scalable, production-ready web applications – and never have to worry about any infrastructure complexity again.\n\nThis repository is for the source code of the VTEX IO landing on https://www.vtex.io.\n\n```"
}
] |
code_io-landing_8be474b6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of io-landing/react/Features.tsx from the io-landing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment, FunctionComponent } from 'react'\nimport { Helmet } from 'vtex.render-runtime'\n\nimport Navbar from './components/Navbar'\nimport Footer from './components/Footer'\nimport favicon from './images/favicon.png'\n\nimport { storeComponents, storePixel } from './FeaturesData'\n\nconst FeaturesDisplay: FunctionComponent = () => {\n return (\n <Fragment>\n <Helmet>\n <title>Store</title>\n <meta name=\"theme-color\" content=\"#F71963\" />\n <link rel=\"icon\" href={favicon} />\n </Helmet>\n <Navbar />\n <main className=\"w-100 pv10\">\n <div className=\"flex-ns items-baseline w-90 w-80-ns center mb8\">\n <h1 className=\"c-base t-heading-1 pr7\">Store Features</h1>\n <nav>\n <ul className=\"flex-ns list t-heading-5 pl0\">\n <li className=\"pr6 pb4 pb0-ns\">\n <a\n href=\"/store-features#store-component-apps\"\n className=\"no-underline c-emphasis dim\"\n >\n Store Component Apps\n </a>\n </li>\n <li>\n <a\n href=\"/store-features#store-pixel-apps\"\n className=\"no-underline c-emphasis dim\"\n >\n Store Pixel Apps\n </a>\n </li>\n </ul>\n </nav>\n </div>\n <section\n id=\"store-component-apps\"\n className=\"flex flex-column w-90 w-80-ns center pt8\"\n >\n <h2 className=\"c-base t-heading-3 fw3 mb0 mt4\">\n Store Component Apps\n </h2>\n <ul className=\"t-body list pl0 mt0\">\n {storeComponents.map(component => (\n <li className=\"mv7 bb b--muted-2\" key={component.name}>\n <p>\n {component.name}{' '}\n {component.construction && '[Under Construction] 🚧'}\n </p>\n <p>\n <a className=\"link\" href={component.docs}>\n {component.docs}\n </a>\n </p>\n </li>\n ))}\n </ul>\n </section>\n <section\n id=\"store-pixel-apps\"\n className=\"flex flex-column w-90 w-80-ns center pt8\"\n >\n <h2 className=\"c-base t-heading-3 fw3 mb0 mt4\">Store Pixel Apps</h2>\n <ul className=\"t-body list pl0 mt0\">\n {storePixel.map(app => (\n <li className=\"mv7 bb b--muted-2\" key={app.name}>\n <p>{app.name}</p>\n <p>\n <a className=\"link\" href={app.docs}>\n {app.docs}\n </a>\n </p>\n </li>\n ))}\n </ul>\n </section>\n </main>\n <Footer />\n </Fragment>\n )\n}\n\nexport default FeaturesDisplay\n\n```"
}
] |
code_io-landing_e957af3d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of io-landing/react/FeaturesData.ts from the io-landing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const storeComponents = [\n {\n name: 'Store Components',\n docs: 'https://github.com/vtex-apps/store-components',\n },\n {\n name: 'Store Header',\n docs: 'https://github.com/vtex-apps/store-header',\n },\n {\n name: 'Store Footer',\n docs: 'https://github.com/vtex-apps/store-footer',\n },\n {\n name: 'Shelf',\n docs: 'https://github.com/vtex-apps/shelf',\n },\n {\n name: 'Carousel',\n docs: 'https://github.com/vtex-apps/carousel',\n },\n {\n name: 'Menu',\n docs: 'https://github.com/vtex-apps/menu',\n },\n {\n name: 'Minicart',\n docs: 'https://github.com/vtex-apps/minicart',\n },\n {\n name: 'Telemarketing',\n docs: 'https://github.com/vtex-apps/telemarketing',\n },\n {\n name: 'Login',\n docs: 'https://github.com/vtex-apps/login',\n },\n {\n name: 'Category Menu',\n docs: 'https://github.com/vtex-apps/category-menu',\n },\n {\n name: 'Breadcrumb',\n docs: 'https://github.com/vtex-apps/breadcrumb',\n },\n {\n name: 'Search Result',\n docs: 'https://github.com/vtex-apps/search-result',\n },\n {\n name: 'Product Details',\n docs: 'https://github.com/vtex-apps/product-details',\n },\n {\n name: 'Address Locator (for deliveries)',\n docs: 'https://github.com/vtex-apps/address-locator',\n },\n {\n name: 'Flex Layout',\n docs: 'https://github.com/vtex-apps/flex-layout',\n },\n {\n name: 'My Account',\n docs: 'https://github.com/vtex-apps/my-account',\n },\n {\n name: 'My Account Commons',\n docs: 'https://github.com/vtex-apps/my-account-commons',\n },\n {\n name: 'Product Customizer',\n docs: 'https://github.com/vtex-apps/product-customizer',\n },\n {\n name: 'Product Kit',\n docs: 'https://github.com/vtex-apps/product-kit',\n },\n {\n name: 'Product Summary',\n docs: 'https://github.com/vtex-apps/product-summary',\n },\n {\n name: 'Store Icons',\n docs: 'https://github.com/vtex-apps/store-icons',\n },\n {\n name: 'Rich Text',\n docs: 'https://github.com/vtex-apps/rich-text',\n },\n {\n name: 'Wishlist',\n docs: 'https://github.com/vtex-apps/wishlist',\n construction: true,\n },\n {\n name: 'Order Placed',\n docs: 'https://github.com/vtex-apps/order-placed',\n construction: true,\n },\n]\n\nexport const storePixel = [\n {\n name: 'Facebook Pixel',\n docs: 'https://github.com/vtex-apps/facebook-pixel',\n },\n {\n name: 'Google Adwords',\n docs: 'https://github.com/vtex-apps/google-adwords',\n },\n {\n name: 'Google Tag Manager',\n docs: 'https://github.com/vtex-apps/google-tag-manager',\n },\n]\n\n```"
}
] |
code_io-landing_d5f95eb0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of io-landing/react/IO.tsx from the io-landing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment, FunctionComponent } from 'react'\nimport { injectIntl, InjectedIntlProps } from 'react-intl'\nimport { Helmet } from 'vtex.render-runtime'\n\nimport Navbar from './components/Navbar'\nimport Hero from './components/Hero'\nimport CardGrid from './components/CardGrid'\nimport ProductDisplay from './components/Product'\nimport HowItWorks from './components/HowItWorks'\nimport EvolutionSection from './components/Evolution'\nimport KeyFeatures from './components/KeyFeatures'\nimport StartBuilding from './components/StartBuilding'\nimport Footer from './components/Footer'\nimport favicon from './images/favicon.png'\n\nconst Landing: FunctionComponent<InjectedIntlProps> = ({ intl }) => {\n return (\n <Fragment>\n <Helmet>\n <title>{intl.formatMessage({ id: 'io.page-title' })}</title>\n <meta\n name=\"description\"\n content=\"A serverless development platform from VTEX.\"\n />\n <meta name=\"theme-color\" content=\"#F71963\" />\n <link rel=\"icon\" href={favicon} />\n </Helmet>\n <Navbar />\n <main className=\"w-100 bg-base--inverted\">\n <Hero />\n <CardGrid />\n <ProductDisplay />\n <HowItWorks />\n <EvolutionSection />\n <KeyFeatures />\n <StartBuilding />\n </main>\n <Footer />\n </Fragment>\n )\n}\n\nexport default injectIntl(Landing)\n\n```"
}
] |
code_io-landing_3c42e1e2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of io-landing/react/package.json from the io-landing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.io-landing\",\n \"version\": \"1.3.1\",\n \"scripts\": {\n \"lint\": \"tsc --noEmit && eslint --ext ts,tsx .\",\n \"lint:locales\": \"intl-equalizer\"\n },\n \"devDependencies\": {\n \"@types/graphql\": \"^0.13.3\",\n \"@types/node\": \"^9.4.7\",\n \"@types/react\": \"^16.3.16\",\n \"@types/react-dom\": \"^16.0.5\",\n \"@types/react-helmet\": \"^5.0.5\",\n \"@types/react-intl\": \"^2.3.5\",\n \"@vtex/intl-equalizer\": \"^2.3.0\",\n \"eslint\": \"^5.15.1\",\n \"eslint-config-vtex\": \"^10.1.0\",\n \"eslint-config-vtex-react\": \"^4.1.0\",\n \"graphql\": \"^0.13.0\",\n \"prettier\": \"^1.16.1\",\n \"react\": \"^16.2.0\",\n \"react-apollo\": \"^2.0.4\",\n \"react-dom\": \"^16.2.0\",\n \"react-intl\": \"^2.4.0\",\n \"typescript\": \"3.9.7\"\n }\n}\n\n```"
}
] |
code_io-landing_caf38e14
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of io-landing/react/VTEXOffices.json from the io-landing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"Offices\": [\n {\n \"short\": \"Barcelona\",\n \"address1\": \"Carrer de Provença, 339\",\n \"address2\": \"08037\",\n \"city\": \"Barcelona, Spain\"\n },\n {\n \"short\": \"Bogotá\",\n \"address1\": \"Carrera 19 # 100-45, Oficina 14w-106\",\n \"address2\": \"110121\",\n \"city\": \"Bogotá, Colombia\"\n },\n {\n \"short\": \"Bucharest\",\n \"address1\": \"6, Iuliu Maniu Boulevard\",\n \"address2\": \"Campus 6 Building 6.1, floor 1\",\n \"address3\": \"011886\",\n \"city\": \"Bucharest, Romania\"\n },\n {\n \"short\": \"Buenos Aires\",\n \"address1\": \"Av. Chiclana, 3578\",\n \"address2\": \"4 andar, Distrito Tecnológico\",\n \"address3\": \"CABA C1260ACP\",\n \"city\": \"Buenos Aires, Argentina\"\n },\n {\n \"short\": \"Ciudad de México\",\n \"address1\": \"Blvd. Miguel De Cervantes Saavedra 169 Granada\",\n \"address2\": \"11520, Miguel Hidalgo\",\n \"city\": \"Ciudad de México, Mexico\"\n },\n {\n \"short\": \"Curitiba\",\n \"address1\": \"R. Prefeito Ângelo Lopes, 1528\",\n \"address2\": \"Hugo Lange\",\n \"address3\": \"PR 82590-300\",\n \"city\": \"Curitiba, Brazil\"\n },\n {\n \"short\": \"Fort Lauderdale\",\n \"address1\": \"501 East Las Olas Blv\",\n \"address2\": \"Suite 300\",\n \"address3\": \"FL 33301\",\n \"city\": \"Fort Lauderdale, USA\"\n },\n {\n \"short\": \"João Pessoa\",\n \"address1\": \"R. Antônio Rabelo Júnior, 161\",\n \"address2\": \"25 andar, Jardim Rosas\",\n \"address3\": \"PB 58032-090\",\n \"city\": \"João Pessoa, Brazil\"\n },\n {\n \"short\": \"London\",\n \"address1\": \"Aviation House, 125 Kingsway\",\n \"address2\": \"Holborn\",\n \"address3\": \"WC2B 6NH\",\n \"city\": \"London, United Kingdom\"\n },\n {\n \"short\": \"Medellín\",\n \"address1\": \"Edificio Ofi7 La Francia\",\n \"address2\": \"Carrera 42 #5 Sur-145, Antioquia\",\n \"city\": \"Medellín, Colombia\"\n },\n {\n \"short\": \"Milan\",\n \"address1\": \"Via Copernico, 28A\",\n \"city\": \"Milan, Italy\"\n },\n {\n \"short\": \"New York\",\n \"address1\": \"12 E 49th St\",\n \"address2\": \"Midtown Manhattan\",\n \"address3\": \"NY 10017\",\n \"city\": \"New York, USA\"\n },\n {\n \"short\": \"Rio de Janeiro\",\n \"address1\": \"Praia de Botafogo, 300\",\n \"address2\": \"2 andar, Botafogo\",\n \"address3\": \"RJ 22250-040\",\n \"city\": \"Rio de Janeiro, Brazil\"\n },\n {\n \"short\": \"Santiago de Chile\",\n \"address1\": \"Av. Apoquindo 5950\",\n \"address2\": \"Piso 3, Oficina 124, Las Condes\",\n \"address3\": \"Región Metropolitana 7560949\",\n \"city\": \"Santiago de Chile, Chile\"\n },\n {\n \"short\": \"São Paulo\",\n \"address1\": \"Av. Brigadeiro Faria Lima, 4440\",\n \"address2\": \"10 andar, Itaim Bibi\",\n \"address3\": \"SP 04538-132\",\n \"city\": \"São Paulo, Brazil\"\n },\n {\n \"short\": \"Teresópolis\",\n \"address1\": \"R. Antônio Rabelo Júnior, 161\",\n \"address2\": \"Sala 604, Várzea\",\n \"address3\": \"RJ 25963-081\",\n \"city\": \"Teresópolis, Brazil\"\n }\n ]\n}\n\n```"
}
] |
code_io-landing_f3bd7add
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of io-landing/react/Onboarding.tsx from the io-landing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useEffect, FunctionComponent, Fragment } from 'react'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { urls } from './constants/URLs'\n\nconst Onboarding: FunctionComponent = () => {\n const {\n query: { account, code, state },\n } = useRuntime()\n\n useEffect(() => {\n if (account && code && state) {\n window.location.assign(`${urls.STOREFRONT_ONBOARDING_PAGE(account)}?account=${account}&code=${code}&state=${state}`)\n }\n }, [code, account, state])\n\n return <Fragment></Fragment>\n}\n\nexport default Onboarding\n\n```"
}
] |
code_io-landing_0dd409c3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of io-landing/react/FAQ.tsx from the io-landing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useEffect, FunctionComponent, Fragment } from 'react'\n\nconst FAQ: FunctionComponent = () => {\n useEffect(() => {\n window.location.assign('https://vtex.io/docs')\n })\n\n return <Fragment></Fragment>\n}\n\nexport default FAQ\n\n```"
}
] |
code_io-landing_17f9b658
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of io-landing/store/interfaces.json from the io-landing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"io\": {\n \"blocks\": [\n \"io.landing\"\n ]\n },\n \"io.landing\": {\n \"component\": \"IO\"\n },\n \"io.landing-old\": {\n \"component\": \"IO\"\n },\n \"io.faq\": {\n \"component\": \"FAQ\"\n },\n \"io.store-features\": {\n \"component\": \"Features\"\n },\n \"io.storefront-onboarding\": {\n \"component\": \"Onboarding\"\n }\n}\n\n```"
}
] |
code_io-landing_35b733e5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of io-landing/store/routes.json from the io-landing VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"io.landing\": {\n \"path\": \"/io\",\n \"cname\": \"www.vtex.io\"\n },\n \"io.landing-old\": {\n \"path\": \"/io-old\",\n \"cname\": \"vtex.io\"\n },\n \"io.faq\": {\n \"path\": \"/faq\"\n },\n \"io.store-features\": {\n \"path\": \"/store-features\"\n },\n \"io.storefront-onboarding\": {\n \"path\": \"/storefront-onboarding\"\n }\n}\n\n```"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.