id
stringlengths
12
53
messages
listlengths
3
3
code_mega-menu_534052a2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/graphql/types/settings.graphql from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype Settings {\n idMenu: ID!\n orientation: String\n}\n\ninput SettingsInput {\n idMenu: ID!\n orientation: String\n}\n\n```" } ]
code_mega-menu_d8848ae8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/graphql/types/menu.graphql from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype Menu {\n id: ID!\n name: String!\n icon: String!\n slug: String!\n styles: String\n menu: [Menu]\n display: Boolean!\n enableSty: Boolean!\n order: Int\n slugRoot: String\n slugRelative: String\n mobile: Boolean\n desktop: Boolean\n}\n\ninput MenuInput {\n id: ID!\n name: String!\n icon: String!\n slug: String!\n styles: String!\n menu: [MenuInput]\n display: Boolean\n enableSty: Boolean\n order: Int\n firstLevel: String\n secondLevel: String\n slugRoot: String\n slugRelative: String\n mobile: Boolean\n desktop: Boolean\n}\n\n```" } ]
code_mega-menu_824f676d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/node/clients/index.ts from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\n\nexport class Clients extends IOClients {}\n\n```" } ]
code_mega-menu_74cc0a60
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/node/typings/custom.d.ts from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport interface Menu {\n id: string\n name: string\n icon: string\n slug: string\n styles: string\n menu: Menu[]\n display: boolean\n enableSty: boolean\n order: number\n slugRoot?: string\n slugRelative?: string\n mobile?: boolean\n desktop?: boolean\n}\n\nexport interface Settings {\n idMenu: string\n orientation: string\n}\n\ninterface Args {\n menuInput: Menu\n}\ninterface ArgsUpload {\n menuData: [Menu]\n}\ninterface ArgsSettings {\n settingsInput: Settings\n}\n\nexport type Maybe<T> = T | void\n\n```" } ]
code_mega-menu_61d6dad8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/node/typings/global.d.ts from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { ServiceContext } from '@vtex/api'\nimport type { Clients } from '../clients'\n\ndeclare global {\n // We declare a global Context type just to avoid re-writing ServiceContext<Clients, State> in every handler and resolver\n type Context = ServiceContext<Clients>\n}\n\nexport {}\n\n```" } ]
code_mega-menu_e8f84c5b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/node/resolvers/settings.ts from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { Settings, ArgsSettings } from '../typings/custom'\n\nconst settings = async (_: unknown, __: unknown, ctx: Context) => {\n const {\n clients: { vbase },\n } = ctx\n\n let settingsItems: Settings[] = []\n\n try {\n settingsItems = await vbase.getJSON<Settings[]>('settings', 'menuSettings')\n } catch (err) {\n const errStr = err.toString()\n\n // If there are no menus, it is initialized empty\n if (errStr === 'Error: Request failed with status code 404') {\n await vbase.saveJSON('settings', 'menuSettings', [])\n } else {\n throw err\n }\n }\n\n return settingsItems\n}\n\nconst createEditSettings = async (\n _: unknown,\n { settingsInput }: ArgsSettings,\n { clients: { vbase } }: Context\n) => {\n let settingsItems: Settings[] = []\n\n // eslint-disable-next-line vtex/prefer-early-return\n if (settingsInput.idMenu) {\n try {\n settingsItems = await vbase.getJSON<Settings[]>(\n 'settings',\n 'menuSettings'\n )\n } catch (err) {\n const errStr = err.toString()\n\n if (errStr !== 'Error: Request failed with status code 404') {\n throw err\n }\n }\n\n const deleteDuplicates = settingsItems.map((obj) =>\n obj.idMenu === settingsInput.idMenu\n ? { ...obj, orientation: settingsInput.orientation }\n : obj\n )\n\n const saveData =\n deleteDuplicates.length > 0 ? deleteDuplicates : [settingsInput]\n\n return vbase\n .saveJSON('settings', 'menuSettings', saveData)\n .then(() => settingsInput)\n }\n\n return 'Error creating the item'\n}\n\nexport const settingsQueries = {\n settings,\n}\n\nexport const settingsMutations = {\n createEditSettings,\n}\n\n```" } ]
code_mega-menu_35997c25
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/node/resolvers/menu.ts from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { Menu, Args, ArgsUpload } from '../typings/custom'\n\nconst sortMenusByOrder = (menus: Menu[]) => {\n return menus.sort((menuA: Menu, menuB: Menu) => menuA.order - menuB.order)\n}\n\nconst orderArray = (menuList: Menu[]) => {\n menuList.forEach((currentValue: Menu) => {\n if (!currentValue.menu || !currentValue.menu.length) return\n\n sortMenusByOrder(currentValue.menu)\n })\n\n menuList.forEach((item: Menu) => {\n if (item.menu) {\n item.menu.forEach((subitem: Menu) => {\n if (subitem.menu) {\n if (!subitem.menu.length) return\n sortMenusByOrder(subitem.menu)\n }\n })\n }\n })\n\n return sortMenusByOrder(menuList)\n}\n\nconst convertToJson = (menuString: string) => {\n menuString = menuString.replace(/\\s+/g, '')\n\n return `{${menuString.replace(\n /([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)/g,\n '\"$1\":\"$2\"'\n )}}`\n}\n\nconst replaceStyles = (menuStyle: Menu[]) => {\n menuStyle.forEach((firstMenu: Menu) => {\n if (firstMenu.styles) {\n firstMenu.styles = convertToJson(firstMenu.styles)\n }\n\n if (firstMenu.menu) {\n firstMenu.menu.forEach((secondMenu: Menu) => {\n if (secondMenu.styles) {\n secondMenu.styles = convertToJson(secondMenu.styles)\n }\n\n if (secondMenu.menu) {\n secondMenu.menu.forEach((thirdMenu: Menu) => {\n if (thirdMenu.styles) {\n thirdMenu.styles = convertToJson(thirdMenu.styles)\n }\n })\n }\n })\n }\n })\n}\n\nconst filterDataDevice = (key: string, menuItems: Menu[]) => {\n let dataToFilter = [...menuItems]\n\n dataToFilter = dataToFilter.filter(\n (item) =>\n item[key as keyof Menu] === true || item[key as keyof Menu] === null\n )\n\n dataToFilter.forEach((subitem) => {\n subitem.menu = subitem.menu.filter(\n (sub) =>\n sub[key as keyof Menu] === true || sub[key as keyof Menu] === null\n )\n subitem.menu.forEach((thrditem) => {\n thrditem.menu &&\n (thrditem.menu = thrditem.menu.filter(\n (thrd) =>\n thrd[key as keyof Menu] === true || thrd[key as keyof Menu] === null\n ))\n })\n })\n\n if (!dataToFilter.length) dataToFilter = [...menuItems]\n\n return dataToFilter\n}\n\nexport const menus = async (\n _: unknown,\n { isMobile }: { isMobile: boolean },\n ctx: Context\n) => {\n const {\n clients: { vbase },\n } = ctx\n\n let menuItems: Menu[] = []\n\n try {\n menuItems = await vbase.getJSON<Menu[]>('menu', 'menuItems')\n } catch (err) {\n const errStr = err.toString()\n\n // If there are no menus, it is initialized empty\n if (errStr === 'Error: Request failed with status code 404') {\n await vbase.saveJSON('menu', 'menuItems', [])\n } else {\n throw err\n }\n }\n\n replaceStyles(menuItems)\n orderArray(menuItems)\n\n if (isMobile !== undefined) {\n if (isMobile) menuItems = filterDataDevice('mobile', menuItems)\n else menuItems = filterDataDevice('desktop', menuItems)\n }\n\n return menuItems\n}\n\nexport const menu = async (\n _: unknown,\n { id }: { id: string },\n ctx: Context\n) => {\n const menusId = await ctx.clients.vbase.getJSON<Menu[]>('menu', 'menuItems')\n const response = menusId.filter((menuId: Menu) => menuId.id === id)\n\n return response[0]\n}\n\nexport const createMenu = async (\n _: unknown,\n { menuInput }: Args,\n { clients: { vbase } }: Context\n) => {\n let menuItems: Menu[] = []\n\n // eslint-disable-next-line vtex/prefer-early-return\n if (menuInput.id) {\n try {\n menuItems = await vbase.getJSON<Menu[]>('menu', 'menuItems')\n } catch (err) {\n const errStr = err.toString()\n\n if (errStr !== 'Error: Request failed with status code 404') {\n throw err\n }\n }\n\n menuInput.order = menuItems.length + 1\n\n return vbase\n .saveJSON('menu', 'menuItems', [...menuItems, menuInput])\n .then(() => menuInput)\n }\n\n return 'Error creating the item'\n}\n\nexport const uploadMenu = async (\n _: unknown,\n { menuData }: ArgsUpload,\n { clients: { vbase } }: Context\n) => {\n const menuItems = await vbase.getJSON<Menu[]>('menu', 'menuItems')\n\n if (menuItems.length > 0) {\n menuItems.forEach((item) => menuData.push(item))\n }\n\n return vbase.saveJSON('menu', 'menuItems', menuData).then(() => menuData)\n}\n\nexport const editMenu = async (\n _: unknown,\n { menuInput }: Args,\n { clients: { vbase } }: Context\n) => {\n const menuEdit = await vbase.getJSON<Menu[]>('menu', 'menuItems')\n\n const newArray = orderArray([\n ...menuEdit.filter((menuItem: Menu) => menuItem.id !== menuInput.id),\n menuInput,\n ])\n\n return vbase.saveJSON('menu', 'menuItems', newArray).then(() => newArray)\n}\n\nexport const deleteMenu = async (\n _: unknown,\n { id, idSecond, idThird }: { id: string; idSecond: string; idThird: string },\n { clients: { vbase } }: Context\n) => {\n const menuDelete = await vbase.getJSON<Menu[]>('menu', 'menuItems')\n let deleteArray: Menu[] = []\n\n if (!id && !idSecond && !idThird) {\n deleteArray = menuDelete.filter(\n (itemArray: Menu) =>\n itemArray.id !== '' &&\n itemArray.id !== undefined &&\n itemArray.id !== null\n )\n const sortnewArray = deleteArray.sort((a, b) => a.order - b.order)\n let count = 1\n\n sortnewArray.map((as) => (as.order = count++))\n deleteArray = sortnewArray\n } else if (id && !idSecond && !idThird) {\n deleteArray = menuDelete.filter((itemArray: Menu) => itemArray.id !== id)\n const getMenuOrder = menuDelete.filter(\n (menuOrder: Menu) => menuOrder.id === id\n )\n\n for (let i = 0; i < menuDelete.length; i++) {\n const valueOrder = menuDelete[i].order\n\n if (menuDelete[i].order > getMenuOrder[0].order) {\n menuDelete[i].order = valueOrder - 1\n }\n }\n } else if (id && idSecond && !idThird) {\n deleteArray = menuDelete.filter((itemArray: Menu) => itemArray.id === id)\n const tempSecondArray = deleteArray[0].menu.filter(\n (i: Menu) => i.id !== idSecond\n )\n\n const getMenuOrder = deleteArray[0].menu.filter(\n (menuOrder: Menu) => menuOrder.id === idSecond\n )\n\n for (let i = 0; i < tempSecondArray.length; i++) {\n const valueOrder = tempSecondArray[i].order\n\n if (tempSecondArray[i].order > getMenuOrder[0].order) {\n tempSecondArray[i].order = valueOrder - 1\n }\n }\n\n deleteArray[0].menu = tempSecondArray\n\n menuDelete.forEach((itemDelete: Menu) => {\n if (itemDelete.id === deleteArray[0].id) {\n itemDelete.menu = deleteArray[0].menu\n }\n })\n\n deleteArray = menuDelete\n } else {\n deleteArray = menuDelete.filter((itemArray: Menu) => itemArray.id === id)\n const tempSecondArray = deleteArray[0].menu.filter(\n (seconItem: Menu) => seconItem.id === idSecond\n )\n\n const tempThirdArray = tempSecondArray[0].menu.filter(\n (thirdItem: Menu) => thirdItem.id !== idThird\n )\n\n const getMenuOrder = tempSecondArray[0].menu.filter(\n (menuOrder: Menu) => menuOrder.id === idThird\n )\n\n for (let i = 0; i < tempThirdArray.length; i++) {\n const valueOrder = tempThirdArray[i].order\n\n if (tempThirdArray[i].order > getMenuOrder[0].order) {\n tempThirdArray[i].order = valueOrder - 1\n }\n }\n\n tempSecondArray[0].menu = tempThirdArray\n\n menuDelete.forEach((itemDelete: Menu) => {\n if (itemDelete.id === deleteArray[0].id) {\n itemDelete.menu.forEach((subItemDelete: Menu) => {\n if (subItemDelete.id === idSecond) {\n subItemDelete.menu = tempSecondArray[0].menu\n }\n })\n }\n })\n\n deleteArray = menuDelete\n }\n\n return vbase\n .saveJSON('menu', 'menuItems', deleteArray)\n .then(() => deleteArray)\n}\n\nexport const menuQueries = {\n menu,\n menus,\n}\n\nexport const menuMutations = {\n createMenu,\n editMenu,\n deleteMenu,\n uploadMenu,\n}\n\n```" } ]
code_mega-menu_8632f669
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/node/resolvers/index.ts from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { menuQueries, menuMutations } from './menu'\nimport { settingsQueries, settingsMutations } from './settings'\n\nexport const resolvers = {\n Mutation: {\n ...menuMutations,\n ...settingsMutations,\n },\n Query: {\n ...menuQueries,\n ...settingsQueries,\n },\n}\n\n```" } ]
code_mega-menu_a2102194
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/Category/CategoryContainer.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable vtex/prefer-early-return */\nimport type { FC } from 'react'\nimport React, { useState, useEffect } from 'react'\nimport type { InjectedIntlProps } from 'react-intl'\nimport { useQuery, useMutation } from 'react-apollo'\nimport { injectIntl } from 'react-intl'\nimport { ButtonWithIcon } from 'vtex.styleguide'\nimport { ExportToCsv } from 'export-to-csv'\nimport CSVReader from 'react-csv-reader'\nimport { formatIOMessage } from 'vtex.native-types'\n\nimport IconDownload from '../icons/IconDownload'\nimport IconUpload from '../icons/IconUpload'\nimport { MessagesBackupData } from '../shared'\nimport type {\n MenusResponse,\n MenuItemSave,\n MenuItem,\n ShowAlertFunction,\n DataMenu,\n} from '../shared'\nimport GET_MENUS from '../graphql/queries/getMenus.graphql'\nimport UPLOAD from '../graphql/mutations/uploadData.graphql'\nimport styles from './category.css'\n\ninterface PropsCategory {\n setDataItems: (dataItems: { menus: DataMenu[] }) => void\n showAlert: ShowAlertFunction\n dataMenu: {\n menus: MenuItem[]\n }\n}\n\nconst CategoryContainer: FC<InjectedIntlProps & PropsCategory> = (props) => {\n const options = {\n fieldSeparator: ',',\n quoteStrings: '\"',\n decimalSeparator: '.',\n showLabels: false,\n showTitle: false,\n useTextFile: false,\n useBom: false,\n useKeysAsHeaders: false,\n }\n\n const [showButtonDownload, setShowButtonDownload] = useState(true)\n\n const { data, refetch } = useQuery<MenusResponse>(GET_MENUS, {\n fetchPolicy: 'no-cache',\n })\n\n const [uploadData, { data: dataSaved }] = useMutation(UPLOAD, {\n fetchPolicy: 'no-cache',\n })\n\n if (props.dataMenu.menus) {\n if (!props.dataMenu.menus.length && showButtonDownload) {\n setShowButtonDownload(false)\n }\n }\n\n useEffect(() => {\n if (data?.menus.length) setShowButtonDownload(true)\n else setShowButtonDownload(false)\n }, [data])\n\n useEffect(() => {\n // eslint-disable-next-line vtex/prefer-early-return\n if (dataSaved) {\n props.setDataItems({ menus: dataSaved.uploadMenu })\n setShowButtonDownload(true)\n props.showAlert(\n true,\n formatIOMessage({\n id: MessagesBackupData.uploadAlert.id,\n intl: props.intl,\n }).toString(),\n { deleteMenu: [] }\n )\n window.location.reload()\n }\n }, [dataSaved]) // eslint-disable-line react-hooks/exhaustive-deps\n\n const downloadData = () => {\n refetch()\n if (data?.menus.length) {\n setShowButtonDownload(true)\n const dataToSave: MenuItemSave[] = [...data.menus]\n\n dataToSave.forEach((item) => {\n if (item.menu?.length) {\n item.menu = JSON.stringify(item.menu)\n }\n\n if (item.styles !== '') {\n item.styles = item.styles.replace(/[{}\"]/g, '')\n }\n })\n\n const csvExporter = new ExportToCsv(options)\n\n csvExporter.generateCsv(dataToSave)\n } else {\n setShowButtonDownload(false)\n }\n }\n\n return (\n <div className=\"flex\">\n <div className=\"mr3\">\n {showButtonDownload && (\n <div className={styles.tooltipDownload}>\n <ButtonWithIcon\n icon={<IconDownload />}\n variation=\"secondary\"\n onClick={() => downloadData()}\n >\n <span className={styles.tooltiptext}>\n {formatIOMessage({\n id: MessagesBackupData.download.id,\n intl: props.intl,\n }).toString()}\n </span>\n </ButtonWithIcon>\n </div>\n )}\n </div>\n <div>\n <CSVReader\n accept=\".csv, text/csv\"\n inputStyle={{ display: 'none' }}\n onFileLoaded={(dataCsv) => {\n let allowSave = true\n\n if (dataCsv.length) {\n const DataUpload: DataMenu[] = []\n\n dataCsv.forEach((x) => {\n if (x.length > 1) {\n const findInData = props.dataMenu.menus.filter(\n (item) => item.id === x[0]\n )\n\n if (findInData.length <= 0) {\n DataUpload.push({\n id: x[0],\n name: x[1],\n icon: x[2],\n slug: x[3],\n styles: x[4],\n display: x[5] === 'TRUE',\n enableSty: x[6] === 'TRUE',\n order: parseInt(x[7], 10),\n menu: x[10] === '' ? [] : JSON.parse(x[10]),\n })\n } else {\n allowSave = false\n props.showAlert(\n true,\n formatIOMessage({\n id: MessagesBackupData.duplicateData.id,\n intl: props.intl,\n }).toString(),\n { deleteMenu: [] },\n 'warning'\n )\n }\n }\n })\n if (allowSave) {\n uploadData({\n variables: {\n uploadData: DataUpload,\n },\n })\n refetch()\n }\n }\n\n // eslint-disable-next-line prettier/prettier\n ;(\n document.getElementById(\n 'react-csv-reader-input'\n ) as HTMLInputElement\n ).value = ''\n }}\n />\n {!showButtonDownload ? (\n <div className={styles.tooltipDownload} id={styles.upload}>\n <ButtonWithIcon\n icon={<IconUpload />}\n variation=\"secondary\"\n onClick={() => {\n document.getElementById('react-csv-reader-input')?.click()\n }}\n >\n <span className={styles.tooltiptext}>\n {formatIOMessage({\n id: MessagesBackupData.upload.id,\n intl: props.intl,\n }).toString()}\n </span>\n </ButtonWithIcon>\n </div>\n ) : (\n <div />\n )}\n </div>\n </div>\n )\n}\n\nexport default injectIntl(CategoryContainer)\n\n```" } ]
code_mega-menu_5df3dfc5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/Category/category.css from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.tooltipDownload:hover .tooltiptext {\n display: block;\n}\n\n.tooltiptext {\n display: none;\n text-transform: lowercase;\n}\n\n#upload:hover svg g {\n fill: #dce8f7 !important;\n}\n\n```" } ]
code_mega-menu_6674de3c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/Category/ThirdLevelContainer.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React, { useEffect, useState } from 'react'\nimport { Card, Dropdown } from 'vtex.styleguide'\nimport type { InjectedIntlProps } from 'react-intl'\nimport { injectIntl } from 'react-intl'\nimport { formatIOMessage } from 'vtex.native-types'\n\nimport type { DataMenu } from '../shared'\nimport { useDataMenu, messageThirdLevel } from '../shared'\nimport NewButtonComponent from './Components/NewButtonComponent'\nimport SearchComponent from './Components/SearchComponent'\nimport TableComponent from './Components/TableComponent'\n\ninterface TempArrayType {\n id: string\n label: string\n menu?: DataMenu[]\n value: string\n}\n\ninterface TypeLevel {\n value: string\n label: string\n id: string\n}\n\nconst messages = messageThirdLevel\n\nconst ThirdLevelContainer: FC<InjectedIntlProps> = ({ intl }) => {\n const { dataMenu, showAlert, updateData, loading } = useDataMenu()\n\n const [level1, setLevel1] = useState('')\n const [level2, setLevel2] = useState('')\n const [idFirstlvl, setIdFirstlvl] = useState('')\n const [idSecondlvl, setIdSecondlvl] = useState('')\n const [secondLevel, setSecondLevel] = useState<TempArrayType[]>([])\n const [thirdLevel, setThirdLevel] = useState<DataMenu[]>([])\n const [dataMenuFilter, setdataMenuFilter] = useState<DataMenu[]>([])\n const [dataMainMenu, setDataMainMenu] = useState<DataMenu[]>([])\n let dataMenus: DataMenu[] = []\n\n dataMenus = dataMenu\n const firstLevel: TypeLevel[] = []\n\n useEffect(() => {\n if (!thirdLevel.length) return\n\n dataMenus.forEach((i: DataMenu) => {\n if (i.id === idFirstlvl) {\n if (i.menu) {\n const tempDelete = i.menu.filter(\n (j: DataMenu) => j.id === idSecondlvl\n )\n\n if (tempDelete.length) {\n setThirdLevel(tempDelete[0].menu ? tempDelete[0].menu : [])\n }\n }\n }\n })\n }, [dataMenus]) // eslint-disable-line react-hooks/exhaustive-deps\n\n if (dataMenus) {\n dataMenus.forEach((menuValue: DataMenu) => {\n const bodyLevel1 = {\n value: menuValue.name,\n label: menuValue.name,\n id: menuValue.id,\n }\n\n firstLevel.push(bodyLevel1)\n })\n }\n\n const getValueMenu = (data: DataMenu[], idName: string) => {\n const getSubMenu = data.filter(\n (subMenuItem: DataMenu) => subMenuItem.name === idName\n )\n\n setDataMainMenu(data)\n\n const tempArray: TempArrayType[] = []\n\n if (getSubMenu[0].menu) {\n getSubMenu[0].menu.forEach((menuItem: DataMenu) => {\n const bodyLevel = {\n value: menuItem.name,\n label: menuItem.name,\n id: menuItem.id,\n menu: menuItem.menu,\n }\n\n tempArray.push(bodyLevel)\n })\n }\n\n return tempArray\n }\n\n const onChangeLevel1 = (menu: string) => {\n setLevel1(menu)\n setThirdLevel([])\n setLevel2('')\n localStorage.setItem('idFirstlvl', menu)\n\n const idFirstLevel = firstLevel.find(\n (firstMenu: TypeLevel) => firstMenu.value === menu\n )\n\n if (idFirstLevel) {\n setIdFirstlvl(idFirstLevel.id)\n localStorage.setItem('idlvl1', idFirstLevel.id)\n setIdSecondlvl('')\n }\n\n setSecondLevel(getValueMenu(dataMenus, menu))\n }\n\n const onChangeLevel2 = (submenu: string) => {\n let arraySL: DataMenu[] = []\n\n setThirdLevel([])\n\n localStorage.setItem('idSecondlvl', submenu)\n\n setLevel2(submenu)\n\n const idSecondLevel = secondLevel.find(\n (menuSecond: TypeLevel) => menuSecond.value === submenu\n )\n\n const arrayFL = dataMenus.filter(\n (flMenu: DataMenu) =>\n flMenu.name === (level1 || localStorage.getItem('idFirstlvl'))\n )\n\n if (idSecondLevel) {\n localStorage.setItem('idlvl2', idSecondLevel.id)\n setIdSecondlvl(idSecondLevel.id)\n } else if (localStorage.getItem('idlvl2')) {\n setIdSecondlvl(localStorage.getItem('idlvl2') ?? '')\n }\n\n if (arrayFL[0].menu) {\n arraySL = arrayFL[0].menu.filter((i: DataMenu) => i.name === submenu)\n }\n\n if (arraySL[0]) {\n if (arraySL[0].menu) {\n arraySL[0].menu.forEach((i: DataMenu) => {\n i.firstLevel = idFirstlvl\n i.secondLevel = idSecondlvl\n })\n setThirdLevel(arraySL[0].menu)\n }\n } else {\n setThirdLevel([])\n }\n }\n\n const responseFilter = (filterArray: DataMenu[]) => {\n setdataMenuFilter(filterArray)\n }\n\n if (!level1 && !level2) {\n const idFirstLocal = localStorage.getItem('idFirstlvl')\n const idSecondLocal = localStorage.getItem('idSecondlvl')\n\n if (idFirstLocal && idSecondLocal) {\n onChangeLevel1(idFirstLocal)\n onChangeLevel2(idSecondLocal)\n }\n }\n\n const secondSearch = formatIOMessage({\n id: messages.thirdSearch.id,\n intl,\n }).toString()\n\n const titleBtnNew = formatIOMessage({\n id: messages.newButton.id,\n intl,\n }).toString()\n\n return (\n <div className=\"mt8\">\n <div className=\"flex\">\n <div className=\"mr5 w-50\">\n <Card>\n <div className=\"mb5 pr4 pl4\">\n <Dropdown\n label={formatIOMessage({\n id: messages.dropdownSecondLevel.id,\n intl,\n })}\n options={firstLevel}\n value={level1}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n onChangeLevel1(e.target.value)\n }}\n />\n </div>\n </Card>\n </div>\n <div className=\"ml5 w-50\">\n <Card>\n <div className=\"mb5 pr4 pl4\">\n <Dropdown\n label={formatIOMessage({\n id: messages.dropDownThird.id,\n intl,\n })}\n options={secondLevel}\n value={level2}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n onChangeLevel2(e.target.value)\n }}\n />\n </div>\n </Card>\n </div>\n </div>\n <div className=\"mt5\">\n <Card>\n <div className=\"containerTableCat\">\n <div className=\"flex\">\n <div className=\"w-60 mr12\">\n <SearchComponent\n placeholder={secondSearch}\n dataItems={thirdLevel}\n responseFilter={responseFilter}\n />\n </div>\n <div className=\"w-40 ml10\">\n <NewButtonComponent\n obj={{\n level: 'thirdLevel',\n id: idFirstlvl,\n secondLevel: idSecondlvl,\n namebutton: titleBtnNew,\n }}\n />\n </div>\n </div>\n <div>\n <TableComponent\n dataMenu={\n dataMenuFilter.length === 0 ? thirdLevel : dataMenuFilter\n }\n level=\"thirdLevel\"\n showAlert={showAlert}\n updateData={updateData}\n idLevels={{ idFirstlvl, idSecondlvl }}\n mainData={dataMainMenu}\n loading={loading}\n titleColumn={{\n name: formatIOMessage({\n id: messages.firstColumn.id,\n intl,\n }).toString(),\n slug: formatIOMessage({\n id: messages.secondColumn.id,\n intl,\n }).toString(),\n icon: formatIOMessage({\n id: messages.thirdColumn.id,\n intl,\n }).toString(),\n action: formatIOMessage({\n id: messages.fourColumn.id,\n intl,\n }).toString(),\n visibility: formatIOMessage({\n id: messages.fiveColumn.id,\n intl,\n }).toString(),\n emptyTitle: formatIOMessage({\n id: messages.emptyTitle.id,\n intl,\n }).toString(),\n empty: formatIOMessage({\n id: messages.empty.id,\n intl,\n }).toString(),\n modalTitle: formatIOMessage({\n id: messages.titleModal.id,\n intl,\n }).toString(),\n modalBody: formatIOMessage({\n id: messages.bodyModal.id,\n intl,\n }).toString(),\n cancel: formatIOMessage({\n id: messages.btnCancelModal.id,\n intl,\n }).toString(),\n confirm: formatIOMessage({\n id: messages.btnRemoveModal.id,\n intl,\n }).toString(),\n loading: formatIOMessage({\n id: messages.loading.id,\n intl,\n }).toString(),\n deleteConfirm: formatIOMessage({\n id: messages.deleteItem.id,\n intl,\n }).toString(),\n }}\n />\n </div>\n </div>\n </Card>\n </div>\n </div>\n )\n}\n\nexport default injectIntl(ThirdLevelContainer)\n\n```" } ]
code_mega-menu_4b418b75
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/Category/SettingsMenu.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { InjectedIntlProps } from 'react-intl'\nimport type { FC } from 'react'\nimport React, { useState, useEffect } from 'react'\nimport { injectIntl } from 'react-intl'\nimport { formatIOMessage } from 'vtex.native-types'\nimport { ModalDialog, Toggle, Spinner } from 'vtex.styleguide'\nimport { useQuery, useMutation } from 'react-apollo'\nimport { useRuntime } from 'vtex.render-runtime'\n\nimport { messageSettings } from '../shared'\nimport GET_SETTINGS from '../graphql/queries/getSettings.graphql'\nimport CREATE_EDIT_SETTINGS from '../graphql/mutations/createEditSettings.graphql'\n\ninterface SettingsMenuProps {\n showSettings: boolean\n setShowSettings: (v: boolean) => void\n}\n\nconst messages = messageSettings\n\nconst SettingsMenu: FC<SettingsMenuProps & InjectedIntlProps> = (props) => {\n const [orientation, setOrientation] = useState(true)\n const { loading, data } = useQuery(GET_SETTINGS, {\n fetchPolicy: 'no-cache',\n })\n\n const { account } = useRuntime()\n\n const [settingsInput, { data: dataSettings }] = useMutation(\n CREATE_EDIT_SETTINGS,\n {\n fetchPolicy: 'no-cache',\n }\n )\n\n const addSettings = () => {\n settingsInput({\n variables: {\n settingsInput: {\n idMenu: account,\n orientation: orientation ? 'horizontal' : 'vertical',\n },\n },\n })\n }\n\n useEffect(() => {\n if (data) {\n data.settings.length > 0 &&\n setOrientation(data.settings[0].orientation === 'horizontal')\n }\n }, [data])\n\n useEffect(() => {\n if (dataSettings) {\n props.setShowSettings(!props.showSettings)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [dataSettings])\n\n const settingsCaution = formatIOMessage({\n id: messages.caution.id,\n intl: props.intl,\n }).toString()\n\n const settingsOrientationHV = formatIOMessage({\n id: messages.orientationHV.id,\n intl: props.intl,\n }).toString()\n\n return (\n <ModalDialog\n centered\n loading={false}\n confirmation={{\n label: 'Confirm',\n isDangerous: true,\n onClick: () => addSettings(),\n }}\n cancelation={{\n label: 'Close',\n onClick: () => props.setShowSettings(!props.showSettings),\n }}\n isOpen\n onClose={() => props.setShowSettings(!props.showSettings)}\n >\n <div className=\"\">\n <p>{settingsCaution}</p>\n {!loading ? (\n <div>\n <p className=\"mt7\">{settingsOrientationHV}</p>\n <Toggle\n label={orientation ? 'Horizontal' : 'Vertical'}\n checked={orientation}\n id=\"orientation\"\n onChange={() => setOrientation(!orientation)}\n />\n </div>\n ) : (\n <div className=\"flex justify-center\">\n <Spinner />\n </div>\n )}\n </div>\n </ModalDialog>\n )\n}\n\nexport default injectIntl(SettingsMenu)\n\n```" } ]
code_mega-menu_ac52d070
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/Category/SecondLevelContainer.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React, { useState, useEffect } from 'react'\nimport { Card, Dropdown } from 'vtex.styleguide'\nimport type { InjectedIntlProps } from 'react-intl'\nimport { injectIntl } from 'react-intl'\nimport { formatIOMessage } from 'vtex.native-types'\n\nimport TableComponent from './Components/TableComponent'\nimport NewButtonComponent from './Components/NewButtonComponent'\nimport SearchComponent from './Components/SearchComponent'\nimport type { DataMenu } from '../shared'\nimport { useDataMenu, messageSecondLevel } from '../shared'\n\ninterface OptionsBody {\n value: string\n label: string\n id: string\n}\n\nconst messages = messageSecondLevel\n\nconst SecondLevelContainer: FC<InjectedIntlProps> = ({ intl }) => {\n const { dataMenu, showAlert, updateData, loading } = useDataMenu()\n\n const [dataMenuSel, setDataMenuSel] = useState<DataMenu[]>([])\n const [dataMenuFilter, setdataMenuFilter] = useState<DataMenu[]>([])\n const [dataMainMenu, setDataMainMenu] = useState<DataMenu[]>([])\n const [idFirstLevel, setidFirstLevel] = useState('')\n const [dataOptions, setdataOptions] = useState('')\n\n const dataMenus = dataMenu\n const options: OptionsBody[] = []\n const tempDelete: DataMenu[] = []\n\n const onChangeDropdown = (menu: string) => {\n setdataOptions(menu)\n\n const getSubMenu = dataMenus.filter(\n (secondMenu: DataMenu) => secondMenu.name === menu\n )\n\n localStorage.setItem('idFirstLevel', getSubMenu[0].id)\n\n setDataMainMenu(getSubMenu)\n\n setidFirstLevel(getSubMenu[0].id)\n if (getSubMenu[0].menu) {\n getSubMenu[0].menu.map((m: DataMenu) => (m.firstLevel = getSubMenu[0].id))\n setDataMenuSel(getSubMenu[0].menu)\n } else {\n setDataMenuSel([])\n }\n }\n\n if (!idFirstLevel && localStorage.getItem('idFirstLevel')) {\n const valueIdTemp = localStorage.getItem('idFirstLevel')\n\n if (valueIdTemp) {\n const secondLevelLocal = dataMenus.filter(\n (dm: DataMenu) => dm.id === valueIdTemp\n )\n\n if (secondLevelLocal[0]) onChangeDropdown(secondLevelLocal[0].name)\n }\n }\n\n const compareItems = dataMenus.filter(\n (item: DataMenu) => item.id === idFirstLevel\n )\n\n if (dataMenuSel.length > 0) {\n if (JSON.stringify(compareItems[0].menu) !== JSON.stringify(dataMenuSel)) {\n setDataMenuSel([])\n }\n }\n\n useEffect(() => {\n if (!dataMenuSel.length) return\n\n dataMenuSel.forEach((i: DataMenu) => {\n const firstDataMenu = dataMenus[0].menu\n\n if (!firstDataMenu) {\n return\n }\n\n firstDataMenu.forEach((j: DataMenu) => {\n if (i.id === j.id) {\n tempDelete.push(i)\n }\n })\n })\n\n setDataMenuSel(tempDelete)\n }, [dataMenus]) // eslint-disable-line react-hooks/exhaustive-deps\n\n if (dataMenus) {\n dataMenus.forEach((cat: DataMenu) => {\n const body = { value: cat.name, label: cat.name, id: cat.id }\n\n options.push(body)\n })\n }\n\n if (idFirstLevel && dataMenuSel.length === 0) {\n const secondData = dataMenus.filter(\n (secondItem: DataMenu) => secondItem.id === idFirstLevel\n )\n\n const responseData = secondData[0].menu ? secondData[0].menu : []\n\n if (responseData.length > 0) {\n setDataMenuSel(responseData)\n }\n }\n\n const responseFilter = (filterArray: DataMenu[]) => {\n setdataMenuFilter(filterArray)\n }\n\n const secondSearch = formatIOMessage({\n id: messages.secondSearch.id,\n intl,\n }).toString()\n\n const titleBtnNew = formatIOMessage({\n id: messages.newButton.id,\n intl,\n }).toString()\n\n return (\n <div className=\"mt8\">\n <Card>\n <div className=\"mb5\">\n <Dropdown\n label={formatIOMessage({\n id: messages.dropdownSecondLevel.id,\n intl,\n })}\n options={options}\n value={dataOptions}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n onChangeDropdown(e.target.value)\n }}\n />\n </div>\n </Card>\n <div className=\"mt5\">\n <Card>\n <div className=\"containerTableCat\">\n <div className=\"flex\">\n <div className=\"w-60 mr12\">\n <SearchComponent\n placeholder={secondSearch}\n dataItems={dataMenuSel}\n responseFilter={responseFilter}\n />\n </div>\n <div className=\"w-40 ml10\">\n <NewButtonComponent\n obj={{\n level: 'secondLevel',\n id: idFirstLevel,\n namebutton: titleBtnNew,\n }}\n />\n </div>\n </div>\n <div>\n <TableComponent\n dataMenu={\n dataMenuFilter.length === 0 ? dataMenuSel : dataMenuFilter\n }\n level=\"secondLevel\"\n showAlert={showAlert}\n updateData={updateData}\n idLevels={{ idFirstlvl: idFirstLevel }}\n mainData={dataMainMenu}\n loading={loading}\n titleColumn={{\n name: formatIOMessage({\n id: messages.firstColumn.id,\n intl,\n }).toString(),\n slug: formatIOMessage({\n id: messages.secondColumn.id,\n intl,\n }).toString(),\n icon: formatIOMessage({\n id: messages.thirdColumn.id,\n intl,\n }).toString(),\n action: formatIOMessage({\n id: messages.fourColumn.id,\n intl,\n }).toString(),\n visibility: formatIOMessage({\n id: messages.fiveColumn.id,\n intl,\n }).toString(),\n emptyTitle: formatIOMessage({\n id: messages.emptyTitle.id,\n intl,\n }).toString(),\n empty: formatIOMessage({\n id: messages.empty.id,\n intl,\n }).toString(),\n modalTitle: formatIOMessage({\n id: messages.titleModal.id,\n intl,\n }).toString(),\n modalBody: formatIOMessage({\n id: messages.bodyModal.id,\n intl,\n }).toString(),\n cancel: formatIOMessage({\n id: messages.btnCancelModal.id,\n intl,\n }).toString(),\n confirm: formatIOMessage({\n id: messages.btnRemoveModal.id,\n intl,\n }).toString(),\n loading: formatIOMessage({\n id: messages.loading.id,\n intl,\n }).toString(),\n deleteConfirm: formatIOMessage({\n id: messages.deleteItem.id,\n intl,\n }).toString(),\n }}\n />\n </div>\n </div>\n </Card>\n </div>\n </div>\n )\n}\n\nexport default injectIntl(SecondLevelContainer)\n\n```" } ]
code_mega-menu_ed4349be
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/Category/FirstLevelContainer.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React, { useState } from 'react'\nimport { Card } from 'vtex.styleguide'\nimport type { InjectedIntlProps } from 'react-intl'\nimport { injectIntl } from 'react-intl'\nimport { formatIOMessage } from 'vtex.native-types'\n\nimport type { DataMenu } from '../shared'\nimport { useDataMenu, messagesFirstLevel } from '../shared'\nimport NewButtonComponent from './Components/NewButtonComponent'\nimport SearchComponent from './Components/SearchComponent'\nimport TableComponent from './Components/TableComponent'\n\nconst messages = messagesFirstLevel\n\nconst FirsLevelContainer: FC<InjectedIntlProps> = ({ intl }) => {\n const { dataMenu, showAlert, updateData, loading } = useDataMenu()\n const [dataMenuFilter, setDataMenuFilter] = useState<DataMenu[]>(dataMenu)\n\n const responseFilter = (filterArray: DataMenu[]) => {\n setDataMenuFilter(dataMenu)\n updateData(filterArray, 'search')\n }\n\n const placeholderTitle = formatIOMessage({\n id: messages.firstLevelTab.id,\n intl,\n }).toString()\n\n const titleBtnNew = formatIOMessage({\n id: messages.newButton.id,\n intl,\n }).toString()\n\n return (\n <div className=\"mt8\">\n <div>\n <Card>\n <div className=\"containerTableCat\">\n <div className=\"flex\">\n <div className=\"w-60 mr12\">\n <SearchComponent\n placeholder={placeholderTitle}\n dataItems={dataMenuFilter}\n responseFilter={responseFilter}\n />\n </div>\n <div className=\"w-40 ml10\">\n <NewButtonComponent\n obj={{ level: 'firstLevel', namebutton: titleBtnNew }}\n />\n </div>\n </div>\n <div>\n <TableComponent\n dataMenu={dataMenu}\n level=\"firstLevel\"\n showAlert={showAlert}\n updateData={updateData}\n mainData={[]}\n loading={loading}\n titleColumn={{\n name: formatIOMessage({\n id: messages.firstColumn.id,\n intl,\n }).toString(),\n slug: formatIOMessage({\n id: messages.secondColumn.id,\n intl,\n }).toString(),\n icon: formatIOMessage({\n id: messages.thirdColumn.id,\n intl,\n }).toString(),\n action: formatIOMessage({\n id: messages.fourColumn.id,\n intl,\n }).toString(),\n visibility: formatIOMessage({\n id: messages.fiveColumn.id,\n intl,\n }).toString(),\n emptyTitle: formatIOMessage({\n id: messages.emptyTitle.id,\n intl,\n }).toString(),\n empty: formatIOMessage({\n id: messages.empty.id,\n intl,\n }).toString(),\n modalTitle: formatIOMessage({\n id: messages.titleModal.id,\n intl,\n }).toString(),\n modalBody: formatIOMessage({\n id: messages.bodyModal.id,\n intl,\n }).toString(),\n cancel: formatIOMessage({\n id: messages.btnCancelModal.id,\n intl,\n }).toString(),\n confirm: formatIOMessage({\n id: messages.btnRemoveModal.id,\n intl,\n }).toString(),\n loading: formatIOMessage({\n id: messages.loading.id,\n intl,\n }).toString(),\n deleteConfirm: formatIOMessage({\n id: messages.deleteItem.id,\n intl,\n }).toString(),\n }}\n />\n </div>\n </div>\n </Card>\n </div>\n </div>\n )\n}\n\nexport default injectIntl(FirsLevelContainer)\n\n```" } ]
code_mega-menu_ea29c90c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/typings/files.d.ts from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.svg'\ndeclare module '*.png'\ndeclare module '*.jpg'\ndeclare module '*.jpeg'\ndeclare module '*.gif'\ndeclare module '*.bmp'\ndeclare module '*.tiff'\ndeclare module '*.gql'\ndeclare module '*.css'\ndeclare module '*.graphql'\n\n```" } ]
code_mega-menu_f2ccd605
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/typings/global.d.ts from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/ban-types */\nimport type { FunctionComponent } from 'react'\n\ndeclare global {\n interface StorefrontFunctionComponent<P = {}> extends FunctionComponent<P> {\n schema?: object\n getSchema?(props?: P): object\n }\n\n interface StorefrontComponent<P = {}, S = {}> extends Component<P, S> {\n schema?: object\n getSchema?(props: P): object\n }\n\n interface StorefrontElement extends ReactElement {\n schema?: object\n getSchema?(props: P): object\n }\n}\n\n```" } ]
code_mega-menu_cf7dc448
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/typings/vtex.styleguide.d.ts from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type PropTypes from 'prop-types'\nimport type React from 'react'\nimport 'vtex.styleguide'\n\ndeclare const propTypes: any\ndeclare const Progress: React.FC<PropTypes.InferProps<typeof propTypes>>\n\ndeclare module 'vtex.styleguide' {\n export const Button: React.FC<PropTypes.InferProps<any>>\n export const Card: React.FC<PropTypes.InferProps<any>>\n export const Checkbox: React.FC<PropTypes.InferProps<any>>\n export const Input: React.FC<PropTypes.InferProps<any>>\n export const Tag: React.FC<PropTypes.InferProps<any>>\n export const Alert: React.FC<PropTypes.InferProps<any>>\n export const Layout: React.FC<PropTypes.InferProps<any>>\n export const PageHeader: React.FC<PropTypes.InferProps<any>>\n export const Dropdown: React.FC<PropTypes.InferProps<any>>\n export const ButtonWithIcon: React.FC<PropTypes.InferProps<any>>\n export const InputSearch: React.FC<PropTypes.InferProps<any>>\n export const Table: React.FC<PropTypes.InferProps<any>>\n export const Toggle: React.FC<PropTypes.InferProps<any>>\n export const PageBlock: React.FC<PropTypes.InferProps<any>>\n export const Tabs: React.FC<PropTypes.InferProps<any>>\n export const Tab: React.FC<PropTypes.InferProps<any>>\n export const Collapsible: React.FC<PropTypes.InferProps<any>>\n export const Textarea: React.FC<PropTypes.InferProps<any>>\n export const Spinner: React.FC<PropTypes.InferProps<any>>\n export const ModalDialog: React.FC<PropTypes.InferProps<any>>\n export const Modal: React.FC<PropTypes.InferProps<any>>\n export const EmptyState: React.FC<PropTypes.InferProps<any>>\n /* eslint-disable @typescript-eslint/naming-convention */\n export const EXPERIMENTAL_Select: React.FC<PropTypes.InferProps<any>>\n}\n\n```" } ]
code_mega-menu_04ec70b1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/shared/messages.ts from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { defineMessages } from 'react-intl'\n\nexport const messagesForm = defineMessages({\n titleForm: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.titleForm',\n },\n backBtnForm: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.backBtnForm',\n },\n subTitleForm: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.subTitleForm',\n },\n infoForm: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.infoForm',\n },\n input1Form: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.input1Form',\n },\n input2Form: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.input2Form',\n },\n input3Form: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.input3Form',\n },\n input4Form: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.input4Form',\n },\n titleSubBlock: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.titleSubBlock',\n },\n check1Block: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.check1Block',\n },\n subCheck1Block: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.subCheck1Block',\n },\n subCheck2Block: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.subCheck2Block',\n },\n btnSaveForm: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.btnSaveForm',\n },\n infoFormTitle: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.infoFormTitle',\n },\n infoFormSubtitle: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.infoFormSubtitle',\n },\n infoForm2Title: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.infoForm2Title',\n },\n infoForm2Subtitle: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.infoForm2Subtitle',\n },\n loading: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.loading',\n },\n tooltip: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.tooltip',\n },\n tooltip2: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.tooltip2',\n },\n tooltip3: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.tooltip3',\n },\n newItemFirst: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.newItemFirst',\n },\n newItemSecond: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.newItemSecond',\n },\n newItemThird: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.newItemThird',\n },\n validateName: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.validateName',\n },\n validateSlug: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.validateSlug',\n },\n createItem: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.createItem',\n },\n editItem: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.editItem',\n },\n})\n\nexport const messagesFirstLevel = defineMessages({\n firstLevelTab: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.firstSearch',\n },\n newButton: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.newButton',\n },\n firstColumn: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.firstColumn',\n },\n secondColumn: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.secondColumn',\n },\n thirdColumn: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.thirdColumn',\n },\n fourColumn: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.fourColumn',\n },\n fiveColumn: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.fiveColumn',\n },\n emptyTitle: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.emptyTitle',\n },\n empty: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.empty',\n },\n titleModal: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.titleModal',\n },\n bodyModal: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.bodyModal',\n },\n btnCancelModal: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.btnCancelModal',\n },\n btnRemoveModal: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.btnRemoveModal',\n },\n loading: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.loading',\n },\n deleteItem: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.deleteItem',\n },\n})\n\nexport const messageSecondLevel = defineMessages({\n dropdownSecondLevel: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.dropdownSecondLevel',\n },\n secondSearch: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.secondSearch',\n },\n newButton: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.newButton',\n },\n firstColumn: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.firstColumn',\n },\n secondColumn: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.secondColumn',\n },\n thirdColumn: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.thirdColumn',\n },\n fourColumn: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.fourColumn',\n },\n fiveColumn: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.fiveColumn',\n },\n emptyTitle: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.emptyTitle',\n },\n empty: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.empty',\n },\n titleModal: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.titleModal',\n },\n bodyModal: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.bodyModal',\n },\n btnCancelModal: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.btnCancelModal',\n },\n btnRemoveModal: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.btnRemoveModal',\n },\n loading: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.loading',\n },\n deleteItem: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.deleteItem',\n },\n})\n\nexport const messageThirdLevel = defineMessages({\n dropdownSecondLevel: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.dropdownSecondLevel',\n },\n dropDownThird: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.dropDownThird',\n },\n thirdSearch: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.thirdSearch',\n },\n newButton: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.newButton',\n },\n firstColumn: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.firstColumn',\n },\n secondColumn: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.secondColumn',\n },\n thirdColumn: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.thirdColumn',\n },\n fourColumn: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.fourColumn',\n },\n fiveColumn: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.fiveColumn',\n },\n emptyTitle: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.emptyTitle',\n },\n empty: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.empty',\n },\n titleModal: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.titleModal',\n },\n bodyModal: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.bodyModal',\n },\n btnCancelModal: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.btnCancelModal',\n },\n btnRemoveModal: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.btnRemoveModal',\n },\n loading: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.loading',\n },\n deleteItem: {\n defaultMessage: '',\n id: 'admin/mega-menu.items.deleteItem',\n },\n})\n\nexport const MessagesBackupData = defineMessages({\n download: {\n defaultMessage: '',\n id: 'admin/mega-menu.backup.download',\n },\n upload: {\n defaultMessage: '',\n id: 'admin/mega-menu.backup.upload',\n },\n uploadAlert: {\n defaultMessage: '',\n id: 'admin/mega-menu.backup.uploadAlert',\n },\n duplicateData: {\n defaultMessage: '',\n id: 'admin/mega-menu.backup.duplicateData',\n },\n})\n\nexport const messageSettings = defineMessages({\n caution: {\n defaultMessage: '',\n id: 'admin/mega-menu.settings.caution',\n },\n orientationHV: {\n defaultMessage: '',\n id: 'admin/mega-menu.settings.orientationHV',\n },\n horizontal: {\n defaultMessage: '',\n id: 'admin/mega-menu.settings.horizontal',\n },\n vertical: {\n defaultMessage: '',\n id: 'admin/mega-menu.settings.vertical',\n },\n close: {\n defaultMessage: '',\n id: 'admin/mega-menu.settings.close',\n },\n confirm: {\n defaultMessage: '',\n id: 'admin/mega-menu.settings.confirm',\n },\n})\n\n```" } ]
code_mega-menu_9f565cad
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/shared/utils.ts from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport function shortId() {\n let firstPart: string | number = (Math.random() * 46656) | 0\n let secondPart: string | number = (Math.random() * 46656) | 0\n\n firstPart = `000${firstPart.toString(36)}`.slice(-3)\n secondPart = `000${secondPart.toString(36)}`.slice(-3)\n\n return firstPart + secondPart\n}\n\n```" } ]
code_mega-menu_5eda198b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/shared/types.ts from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport type MenuItem = {\n id: string\n icon: string\n name: string\n slug: string\n styles: string\n menu?: MenuItem[]\n display: boolean\n enableSty: boolean\n order?: number\n slugRoot?: string\n slugRelative?: string\n mobile?: boolean\n desktop?: boolean\n}\n\nexport type MenuItemSave = {\n id: string\n icon: string\n name: string\n slug: string\n styles: string\n menu?: MenuItem[] | string\n display: boolean\n enableSty: boolean\n order?: number\n slugRoot?: string\n slugRelative?: string\n mobile?: boolean\n desktop?: boolean\n}\n\nexport type MenusResponse = {\n menus: MenuItem[]\n}\n\nexport type DataMenu = MenuItem & {\n firstLevel?: string\n secondLevel?: string\n}\n\nexport type DeleteArrayType = {\n deleteMenu: DataMenu[]\n}\n\nexport type ShowAlertFunction = (\n show: boolean,\n messageAlert: string,\n newData: DeleteArrayType,\n type?: string\n) => void\n\nexport type UpdateData = (data: DataMenu[], type: string) => void\n\nexport type ResponseFilterFunction = (filterArray: DataMenu[]) => void\n\nexport type Orientation = 'vertical' | 'horizontal'\nexport interface GlobalConfig {\n title?: string\n orientation?: Orientation\n defaultDepartmentActive?: string\n openOnly?: string\n}\n\nexport interface IconProps {\n id: string\n size?: number\n isActive?: boolean\n viewBox?: string\n activeClassName?: string\n mutedClassName?: string\n Drawer?: any\n}\n\nexport interface SettingsType {\n settings: [\n {\n idMenu: string\n orientation: string\n }\n ]\n}\n\n```" } ]
code_mega-menu_0980d04b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/shared/index.ts from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport * from './components'\nexport * from './contexts'\nexport * from './types'\nexport * from './messages'\n\n```" } ]
code_mega-menu_7c86a2ff
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/icons/IconInfo.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React from 'react'\n\nconst IconInfo: FC = () => {\n return (\n <svg version=\"1.1\" width=\"20\" height=\"20\" x=\"0\" y=\"0\" viewBox=\"0 0 512 512\">\n <g>\n <g>\n <path\n d=\"M165,0.008C74.019,0.008,0,74.024,0,164.999c0,90.977,74.019,164.992,165,164.992s165-74.015,165-164.992 C330,74.024,255.981,0.008,165,0.008z M165,299.992c-74.439,0-135-60.557-135-134.992S90.561,30.008,165,30.008 s135,60.557,135,134.991C300,239.436,239.439,299.992,165,299.992z\"\n fill=\"#134cd8\"\n data-original=\"#000000\"\n className=\"\"\n />\n <path\n d=\"M165,130.008c-8.284,0-15,6.716-15,15v99.983c0,8.284,6.716,15,15,15s15-6.716,15-15v-99.983 C180,136.725,173.284,130.008,165,130.008z\"\n fill=\"#134cd8\"\n data-original=\"#000000\"\n className=\"\"\n />\n <path\n d=\"M165,70.011c-3.95,0-7.811,1.6-10.61,4.39c-2.79,2.79-4.39,6.66-4.39,10.61s1.6,7.81,4.39,10.61 c2.79,2.79,6.66,4.39,10.61,4.39s7.81-1.6,10.609-4.39c2.79-2.8,4.391-6.66,4.391-10.61s-1.601-7.82-4.391-10.61 C172.81,71.61,168.95,70.011,165,70.011z\"\n fill=\"#134cd8\"\n data-original=\"#000000\"\n className=\"\"\n />\n </g>\n </g>\n </svg>\n )\n}\n\nexport default IconInfo\n\n```" } ]
code_mega-menu_623f7b3a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/icons/IconAdd.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React from 'react'\n\nconst IconAdd: FC = () => {\n return (\n <svg version=\"1.1\" width=\"20\" height=\"20\" x=\"0\" y=\"0\" viewBox=\"0 0 512 512\">\n <g>\n <path\n xmlns=\"http://www.w3.org/2000/svg\"\n d=\"m256 0c-141.164062 0-256 114.835938-256 256s114.835938 256 256 256 256-114.835938 256-256-114.835938-256-256-256zm112 277.332031h-90.667969v90.667969c0 11.777344-9.554687 21.332031-21.332031 21.332031s-21.332031-9.554687-21.332031-21.332031v-90.667969h-90.667969c-11.777344 0-21.332031-9.554687-21.332031-21.332031s9.554687-21.332031 21.332031-21.332031h90.667969v-90.667969c0-11.777344 9.554687-21.332031 21.332031-21.332031s21.332031 9.554687 21.332031 21.332031v90.667969h90.667969c11.777344 0 21.332031 9.554687 21.332031 21.332031s-9.554687 21.332031-21.332031 21.332031zm0 0\"\n fill=\"#ffffff\"\n data-original=\"#000000\"\n />\n </g>\n </svg>\n )\n}\n\nexport default IconAdd\n\n```" } ]
code_mega-menu_99ec9160
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/icons/IconUp.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React from 'react'\n\ninterface ColorIcon {\n color: string\n}\n\nconst IconUp: FC<ColorIcon> = (props) => {\n return (\n <svg\n version=\"1.1\"\n width=\"20\"\n height=\"20\"\n x=\"0\"\n y=\"0\"\n viewBox=\"0 0 528.899 528.899\"\n >\n <g>\n <path\n d=\"M374.176,110.386l-104-104.504c-0.006-0.006-0.013-0.011-0.019-0.018c-7.818-7.832-20.522-7.807-28.314,0.002 c-0.006,0.006-0.013,0.011-0.019,0.018l-104,104.504c-7.791,7.829-7.762,20.493,0.068,28.285 c7.829,7.792,20.492,7.762,28.284-0.067L236,68.442V492c0,11.046,8.954,20,20,20c11.046,0,20-8.954,20-20V68.442l69.824,70.162 c7.792,7.829,20.455,7.859,28.284,0.067C381.939,130.878,381.966,118.214,374.176,110.386z\"\n fill={props.color}\n data-original=\"#000000\"\n className=\"\"\n />\n </g>\n </svg>\n )\n}\n\nexport default IconUp\n\n```" } ]
code_mega-menu_5e77421b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/icons/IconDown.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React from 'react'\n\ninterface ColorIcon {\n color: string\n}\nconst IconDown: FC<ColorIcon> = (props) => {\n return (\n <svg\n version=\"1.1\"\n width=\"20\"\n height=\"20\"\n x=\"0\"\n y=\"0\"\n viewBox=\"0 0 528.899 528.899\"\n >\n <g>\n <path\n d=\"M374.108,373.328c-7.829-7.792-20.492-7.762-28.284,0.067L276,443.557V20c0-11.046-8.954-20-20-20 c-11.046,0-20,8.954-20,20v423.558l-69.824-70.164c-7.792-7.829-20.455-7.859-28.284-0.067c-7.83,7.793-7.859,20.456-0.068,28.285 l104,104.504c0.006,0.007,0.013,0.012,0.019,0.018c7.792,7.809,20.496,7.834,28.314,0.001c0.006-0.007,0.013-0.012,0.019-0.018 l104-104.504C381.966,393.785,381.939,381.121,374.108,373.328z\"\n fill={props.color}\n data-original=\"#000000\"\n className=\"\"\n />\n </g>\n </svg>\n )\n}\n\nexport default IconDown\n\n```" } ]
code_mega-menu_35430892
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/icons/IconDelete.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React from 'react'\n\nconst IconDelete: FC = () => {\n return (\n <svg version=\"1.1\" width=\"20\" height=\"20\" x=\"0\" y=\"0\" viewBox=\"0 0 430 510\">\n <g>\n <g xmlns=\"http://www.w3.org/2000/svg\" id=\"XMLID_1473_\">\n <path\n xmlns=\"http://www.w3.org/2000/svg\"\n d=\"m416.875 114.441406-11.304688-33.886718c-4.304687-12.90625-16.339843-21.578126-29.941406-21.578126h-95.011718v-30.933593c0-15.460938-12.570313-28.042969-28.027344-28.042969h-87.007813c-15.453125 0-28.027343 12.582031-28.027343 28.042969v30.933593h-95.007813c-13.605469 0-25.640625 8.671876-29.945313 21.578126l-11.304687 33.886718c-2.574219 7.714844-1.2695312 16.257813 3.484375 22.855469 4.753906 6.597656 12.445312 10.539063 20.578125 10.539063h11.816406l26.007813 321.605468c1.933594 23.863282 22.183594 42.558594 46.109375 42.558594h204.863281c23.921875 0 44.175781-18.695312 46.105469-42.5625l26.007812-321.601562h6.542969c8.132812 0 15.824219-3.941407 20.578125-10.535157 4.753906-6.597656 6.058594-15.144531 3.484375-22.859375zm-249.320312-84.441406h83.0625v28.976562h-83.0625zm162.804687 437.019531c-.679687 8.402344-7.796875 14.980469-16.203125 14.980469h-204.863281c-8.40625 0-15.523438-6.578125-16.203125-14.980469l-25.816406-319.183593h288.898437zm-298.566406-349.183593 9.269531-27.789063c.210938-.640625.808594-1.070313 1.484375-1.070313h333.082031c.675782 0 1.269532.429688 1.484375 1.070313l9.269531 27.789063zm0 0\"\n fill=\"#ffffff\"\n data-original=\"#000000\"\n />\n <path\n xmlns=\"http://www.w3.org/2000/svg\"\n d=\"m282.515625 465.957031c.265625.015625.527344.019531.792969.019531 7.925781 0 14.550781-6.210937 14.964844-14.21875l14.085937-270.398437c.429687-8.273437-5.929687-15.332031-14.199219-15.761719-8.292968-.441406-15.328125 5.925782-15.761718 14.199219l-14.082032 270.398437c-.429687 8.273438 5.925782 15.332032 14.199219 15.761719zm0 0\"\n fill=\"#ffffff\"\n data-original=\"#000000\"\n />\n <path\n xmlns=\"http://www.w3.org/2000/svg\"\n d=\"m120.566406 451.792969c.4375 7.996093 7.054688 14.183593 14.964844 14.183593.273438 0 .554688-.007812.832031-.023437 8.269531-.449219 14.609375-7.519531 14.160157-15.792969l-14.753907-270.398437c-.449219-8.273438-7.519531-14.613281-15.792969-14.160157-8.269531.449219-14.609374 7.519532-14.160156 15.792969zm0 0\"\n fill=\"#ffffff\"\n data-original=\"#000000\"\n />\n <path\n xmlns=\"http://www.w3.org/2000/svg\"\n d=\"m209.253906 465.976562c8.285156 0 15-6.714843 15-15v-270.398437c0-8.285156-6.714844-15-15-15s-15 6.714844-15 15v270.398437c0 8.285157 6.714844 15 15 15zm0 0\"\n fill=\"#ffffff\"\n data-original=\"#000000\"\n />\n </g>\n </g>\n </svg>\n )\n}\n\nexport default IconDelete\n\n```" } ]
code_mega-menu_c8c66c2a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/icons/IconSettings.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React from 'react'\n\nconst IconSettings: FC = () => {\n return (\n <svg version=\"1.1\" width=\"35\" height=\"35\" x=\"0\" y=\"0\" viewBox=\"0 0 512 512\">\n <g\n transform=\"translate(0.000000,512.000000) scale(0.100000,-0.100000)\"\n fill=\"#134CD8\"\n stroke=\"none\"\n >\n <path\n d=\"M0 2560 l0 -2560 2560 0 2560 0 0 2560 0 2560 -2560 0 -2560 0 0\n -2560z m1935 2254 c37 -13 74 -42 159 -123 88 -84 128 -114 189 -144 181 -88\n 376 -88 554 0 57 28 103 62 188 144 131 124 174 145 279 136 140 -11 483 -185\n 703 -356 111 -86 136 -114 165 -176 30 -67 29 -166 -2 -250 -31 -83 -39 -254\n -15 -345 63 -248 249 -419 514 -474 38 -8 83 -22 100 -30 48 -25 101 -84 127\n -140 77 -171 79 -757 3 -961 -14 -39 -36 -68 -75 -104 -57 -52 -64 -55 -229\n -95 -231 -55 -407 -233 -461 -464 -25 -104 -14 -252 26 -372 36 -108 36 -154\n -1 -240 -29 -67 -116 -147 -287 -261 -135 -90 -352 -203 -450 -235 -125 -40\n -244 2 -340 118 -171 208 -438 288 -685 204 -134 -45 -213 -105 -329 -248 -24\n -30 -60 -57 -99 -77 -88 -44 -159 -43 -281 4 -119 46 -331 156 -438 227 -316\n 210 -361 299 -276 543 35 99 39 120 39 210 1 186 -51 312 -183 446 -103 104\n -188 149 -325 174 -123 23 -166 39 -217 84 -85 75 -112 175 -124 461 -10 232\n 22 524 67 612 49 96 131 149 259 169 244 37 439 202 513 434 34 108 31 271 -8\n 385 -50 150 -31 265 60 353 88 86 325 234 505 317 198 91 277 107 375 74z\"\n />\n <path\n d=\"M2425 3349 c-349 -69 -597 -323 -656 -673 -40 -234 51 -505 226 -681\n 154 -154 340 -230 565 -230 225 0 411 76 565 230 154 154 230 340 230 565 0\n 174 -36 297 -125 433 -112 173 -271 287 -480 344 -68 18 -258 25 -325 12z\"\n />\n </g>\n </svg>\n )\n}\n\nexport default IconSettings\n\n```" } ]
code_mega-menu_312d5343
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/icons/IconDownload.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React from 'react'\n\nconst IconDownload: FC = () => {\n return (\n <svg\n version=\"1.1\"\n width=\"20\"\n height=\"20\"\n x=\"0\"\n y=\"0\"\n viewBox=\"0 0 512 512\"\n style={{\n marginLeft: '15px',\n marginTop: '6px',\n marginBottom: '7px',\n }}\n >\n <g\n transform=\"translate(0.000000,512.000000) scale(0.100000,-0.100000)\"\n fill=\"#134CD8\"\n stroke=\"none\"\n >\n <path\n d=\"M2313 5099 c-24 -12 -52 -37 -65 -57 l-23 -37 -5 -1244 -5 -1244\n-338 296 c-185 163 -351 304 -367 312 -44 23 -121 19 -161 -8 -45 -30 -278\n-294 -295 -334 -8 -18 -14 -46 -14 -62 0 -82 -5 -77 721 -712 379 -331 701\n-611 717 -621 31 -21 121 -25 155 -6 12 6 336 286 719 621 733 641 728 636\n728 718 0 16 -6 44 -14 62 -17 40 -250 304 -295 334 -40 27 -117 31 -161 8\n-16 -8 -182 -149 -367 -312 l-338 -296 -5 1244 -5 1244 -23 37 c-13 21 -40 45\n-66 57 -39 19 -60 21 -247 21 -187 0 -208 -2 -246 -21z\"\n />\n <path\n d=\"M600 659 c-20 -11 -47 -37 -60 -56 -24 -35 -25 -43 -28 -237 -4 -218\n2 -255 45 -307 53 -63 -86 -59 2003 -59 2089 0 1950 -4 2003 59 43 52 49 89\n45 307 -3 195 -4 202 -28 237 -13 20 -41 45 -61 56 -37 21 -38 21 -1960 21\n-1920 0 -1924 0 -1959 -21z\"\n />\n </g>\n </svg>\n )\n}\n\nexport default IconDownload\n\n```" } ]
code_mega-menu_33323e01
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/icons/IconUpload.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React from 'react'\n\nconst IconUpload: FC = () => {\n return (\n <svg\n version=\"1.1\"\n width=\"25\"\n height=\"25\"\n x=\"0\"\n y=\"0\"\n viewBox=\"0 0 512 512\"\n style={{\n backgroundColor: '#134CD8',\n marginTop: '8px',\n marginLeft: '15px',\n }}\n >\n <g\n transform=\"translate(0.000000,512.000000) scale(0.100000,-0.100000)\"\n fill=\"#F2F4F5\"\n stroke=\"none\"\n >\n <path\n d=\"M1 4023 c1 -935 3 -1088 14 -1033 54 268 233 520 465 656 83 49 203\n 99 278 115 l49 10 13 57 c89 407 345 780 694 1014 201 134 401 214 651 258 99\n 18 88 18 -1032 19 l-1133 1 1 -1097z\"\n />\n <path\n d=\"M2725 5100 c185 -33 321 -77 481 -158 256 -129 508 -360 654 -601\n l54 -89 104 -11 c148 -17 278 -53 398 -110 141 -67 242 -138 349 -246 173\n -172 284 -378 335 -620 l19 -90 0 973 1 972 -1247 -1 c-1232 -1 -1247 -1\n -1148 -19z\"\n />\n <path\n d=\"M2495 3541 c-16 -10 -168 -158 -337 -327 -262 -264 -308 -314 -313\n -346 -16 -87 52 -168 140 -168 20 0 46 5 58 11 12 6 100 88 195 182 l172 172\n 0 -638 0 -637 -739 0 c-476 0 -767 4 -817 11 -141 19 -309 84 -422 161 -209\n 143 -367 382 -417 628 -11 55 -13 -138 -14 -1262 l-1 -1328 2560 0 2560 0 -1\n 1433 c0 1431 0 1432 -19 1342 -91 -431 -402 -785 -808 -919 -182 -60 -159 -59\n -899 -63 l-683 -4 0 638 0 638 173 -172 c94 -94 182 -176 194 -182 12 -6 38\n -11 58 -11 88 0 156 81 140 168 -6 32 -51 82 -318 350 -172 172 -324 320 -339\n 328 -37 19 -87 18 -123 -5z\"\n />\n </g>\n </svg>\n )\n}\n\nexport default IconUpload\n\n```" } ]
code_mega-menu_1a3769c2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/icons/IconEdit.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React from 'react'\n\nconst IconEdit: FC = () => {\n return (\n <svg\n version=\"1.1\"\n width=\"20\"\n height=\"20\"\n x=\"0\"\n y=\"0\"\n viewBox=\"0 0 528.899 528.899\"\n >\n <g>\n <path\n d=\"M496.063,62.299l-46.396-46.4c-21.199-21.199-55.689-21.198-76.888,0C352.82,35.86,47.964,340.739,27.591,361.113 c-2.17,2.17-3.624,5.054-4.142,7.875L0.251,494.268c-0.899,4.857,0.649,9.846,4.142,13.339c3.497,3.497,8.487,5.042,13.338,4.143 L143,488.549c2.895-0.54,5.741-2.008,7.875-4.143l345.188-345.214C517.311,117.944,517.314,83.55,496.063,62.299z M33.721,478.276 l14.033-75.784l61.746,61.75L33.721,478.276z M140.269,452.585L59.41,371.721L354.62,76.488l80.859,80.865L140.269,452.585z M474.85,117.979l-18.159,18.161l-80.859-80.865l18.159-18.161c9.501-9.502,24.96-9.503,34.463,0l46.396,46.4 C484.375,93.039,484.375,108.453,474.85,117.979z\"\n fill=\"#134cd8\"\n />\n </g>\n </svg>\n )\n}\n\nexport default IconEdit\n\n```" } ]
code_mega-menu_5b718bb6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/icons/IconArrowLeft.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React from 'react'\n\nconst IconArrowLeft: FC = () => {\n return (\n <svg version=\"1.1\" width=\"20\" height=\"20\" x=\"0\" y=\"0\" viewBox=\"0 0 512 512\">\n <g>\n <path\n d=\"M492,236H68.442l70.164-69.824c7.829-7.792,7.859-20.455,0.067-28.284c-7.792-7.83-20.456-7.859-28.285-0.068 l-104.504,104c-0.007,0.006-0.012,0.013-0.018,0.019c-7.809,7.792-7.834,20.496-0.002,28.314c0.007,0.006,0.012,0.013,0.018,0.019 l104.504,104c7.828,7.79,20.492,7.763,28.285-0.068c7.792-7.829,7.762-20.492-0.067-28.284L68.442,276H492 c11.046,0,20-8.954,20-20C512,244.954,503.046,236,492,236z\"\n fill=\"#134cd8\"\n data-original=\"#000000\"\n />\n </g>\n </svg>\n )\n}\n\nexport default IconArrowLeft\n\n```" } ]
code_mega-menu_964e24a7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/MegaMenu/State.ts from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { makeAutoObservable } from 'mobx'\n\nimport type { DataMenu, GlobalConfig, MenuItem } from '../shared'\n\ntype ChangeOpenMenu = boolean | ((isOpen: boolean) => boolean)\n\nclass MegaMenuState {\n public config: GlobalConfig = {}\n public departments: MenuItem[] = []\n public departmentActive: MenuItem | null = null\n public isOpenMenu = false\n\n constructor() {\n makeAutoObservable(this)\n }\n\n public setConfig = (config: GlobalConfig) => {\n this.config = config\n }\n\n public setDepartments = (departments: MenuItem[]) => {\n this.departments = departments\n }\n\n public setDepartmentActive = (department: MenuItem | null) => {\n this.departmentActive = department\n }\n\n public openMenu = (value: ChangeOpenMenu = true) => {\n if (typeof value === 'boolean') {\n this.isOpenMenu = value\n } else {\n this.isOpenMenu = value(this.isOpenMenu)\n }\n }\n\n public getCategories = (departmentId?: string) => {\n let categories: DataMenu[] = []\n let department: DataMenu | null | undefined\n\n if (departmentId) {\n department = this.departments.find((x) => x.id === departmentId)\n } else {\n department = this.departmentActive\n }\n\n if (department?.menu?.length) {\n categories = department.menu\n }\n\n return categories\n }\n}\n\nexport const megaMenuState = new MegaMenuState()\n\n```" } ]
code_mega-menu_84b969e8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/MegaMenu/styles.css from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.menuContainer,\n.submenuContainer {\n overflow: auto;\n max-height: 50vh;\n}\n\n.menuContainer {\n width: 300px;\n}\n\n.submenuList {\n display: grid;\n gap: 2rem;\n grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));\n}\n\n.submenuList > .submenuItem {\n max-width: 200px;\n}\n\n.styledLink,\n.goBackButton,\n.triggerContainer {\n border: none;\n background: transparent;\n outline: transparent;\n}\n\n.hideArrow svg {\n display: none;\n}\n\n```" } ]
code_mega-menu_6ee546ae
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/MegaMenu/wrapper.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useEffect, useState } from 'react'\nimport { useQuery } from 'react-apollo'\nimport { useDevice } from 'vtex.device-detector'\n\nimport GET_MENUS from '../graphql/queries/getMenus.graphql'\nimport GET_SETTINGS from '../graphql/queries/getSettings.graphql'\nimport type { GlobalConfig, MenusResponse, Orientation } from '../shared'\nimport HorizontalMenu from './components/HorizontalMenu'\nimport VerticalMenu from './components/VerticalMenu'\nimport { megaMenuState } from './State'\n\nconst Wrapper: StorefrontFunctionComponent<MegaMenuProps> = (props) => {\n const { openOnly } = props\n const { isMobile } = useDevice()\n const { data } = useQuery<MenusResponse>(GET_MENUS, {\n fetchPolicy: 'no-cache',\n variables: {\n isMobile,\n },\n })\n\n const { data: dataSettings } = useQuery(GET_SETTINGS, {\n fetchPolicy: 'no-cache',\n })\n\n const [orientationMenu, setOrientationMenu] = useState('')\n\n const { setDepartments, setConfig } = megaMenuState\n\n const currentOrientation: Orientation = isMobile ? 'vertical' : 'horizontal'\n\n useEffect(() => {\n // eslint-disable-next-line vtex/prefer-early-return\n if (data?.menus.length) {\n setConfig({\n ...props,\n orientation: currentOrientation,\n })\n setDepartments(data.menus)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [data])\n\n useEffect(() => {\n if (dataSettings) {\n if (dataSettings.settings && dataSettings.settings.length > 0) {\n setOrientationMenu(dataSettings.settings[0].orientation)\n } else {\n setOrientationMenu('horizontal')\n }\n }\n }, [dataSettings])\n\n if (isMobile) {\n return (\n <VerticalMenu\n openOnly={openOnly ?? 'vertical'}\n orientation={orientationMenu}\n />\n )\n }\n\n if (orientationMenu === 'vertical') {\n return (\n <VerticalMenu\n openOnly={openOnly ?? 'vertical'}\n orientation={orientationMenu}\n />\n )\n }\n\n return (\n <HorizontalMenu\n openOnly={openOnly ?? 'horizontal'}\n orientation={orientationMenu}\n />\n )\n}\n\nWrapper.defaultProps = {\n title: 'Departments',\n}\n\nWrapper.displayName = 'MegaMenu'\n\nexport type MegaMenuProps = GlobalConfig\n\nexport default Wrapper\n\n```" } ]
code_mega-menu_568d8c44
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/Category/Components/NewButtonComponent.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React from 'react'\nimport { ButtonWithIcon } from 'vtex.styleguide'\nimport { useRuntime } from 'vtex.render-runtime'\n\nimport IconAdd from '../../icons/IconAdd'\n\ninterface NewButtonComponentProps {\n obj: {\n id?: string\n level?: string\n secondLevel?: string\n namebutton?: string\n }\n}\n\nconst NewButtonComponent: FC<NewButtonComponentProps> = (props) => {\n const { navigate } = useRuntime()\n const { obj } = props\n let statusButton = true\n\n if (obj.level === 'firstLevel') {\n statusButton = false\n } else if (obj.level === 'secondLevel' && obj.id !== '') {\n statusButton = false\n } else if (\n obj.level === 'thirdLevel' &&\n obj.id !== '' &&\n obj.secondLevel !== ''\n ) {\n statusButton = false\n }\n\n const newItem = () => {\n navigate({\n to: `/admin/app/mega-menu/form-menu/${encodeURIComponent(\n JSON.stringify({\n level: obj.level,\n type: 'new',\n id: obj.id,\n secondLevel: obj.secondLevel,\n })\n )}`,\n })\n }\n\n return (\n <div>\n <ButtonWithIcon\n icon={<IconAdd />}\n variation=\"primary\"\n onClick={newItem}\n block\n disabled={statusButton}\n >\n {obj.namebutton}\n </ButtonWithIcon>\n </div>\n )\n}\n\nexport default NewButtonComponent\n\n```" } ]
code_mega-menu_b7cc7b6b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/Category/Components/SearchComponent.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React, { useState } from 'react'\nimport { InputSearch } from 'vtex.styleguide'\n\nimport type { DataMenu, ResponseFilterFunction } from '../../shared'\n\ninterface SearchComponentProps {\n placeholder: string\n dataItems: DataMenu[]\n responseFilter: ResponseFilterFunction\n}\n\nconst SearchComponent: FC<SearchComponentProps> = (props) => {\n const [valueSearch, setValueSearch] = useState('')\n\n const filterItems = (e: { target: HTMLInputElement }) => {\n const { value } = e.target\n\n setValueSearch(value)\n const menuFilter: DataMenu[] = value\n ? props.dataItems.filter((dataMenu: DataMenu) =>\n dataMenu.name.toUpperCase().includes(value.toUpperCase())\n )\n : []\n\n props.responseFilter(menuFilter)\n }\n\n return (\n <div>\n <InputSearch\n placeholder={props.placeholder}\n value={valueSearch}\n size=\"regular\"\n onChange={filterItems}\n />\n </div>\n )\n}\n\nexport default SearchComponent\n\n```" } ]
code_mega-menu_78176568
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/Category/Components/TableComponent.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable prettier/prettier */\nimport type { FC } from 'react'\nimport React, { useEffect, useState } from 'react'\nimport {\n Table,\n ButtonWithIcon,\n Spinner,\n ModalDialog,\n EmptyState,\n} from 'vtex.styleguide'\nimport { useMutation } from 'react-apollo'\nimport { useRuntime } from 'vtex.render-runtime'\nimport {\n FaMobileAlt,\n FaDesktop,\n FaEye,\n FaEyeSlash,\n FaCode,\n} from 'react-icons/fa'\n\nimport IconEdit from '../../icons/IconEdit'\nimport IconDelete from '../../icons/IconDelete'\nimport IconUp from '../../icons/IconUp'\nimport IconDown from '../../icons/IconDown'\nimport DELETE from '../../graphql/mutations/delete.graphql'\nimport EDIT from '../../graphql/mutations/edit.graphql'\nimport type {\n DataMenu,\n MenuItem,\n ShowAlertFunction,\n UpdateData,\n} from '../../shared'\n\ninterface TableComponentProps {\n dataMenu: DataMenu[]\n level: string\n showAlert: ShowAlertFunction\n updateData: UpdateData\n idLevels?: {\n idFirstlvl?: string\n idSecondlvl?: string\n }\n mainData: DataMenu[]\n loading: boolean\n titleColumn: {\n name: string\n slug: string\n icon: string\n action: string\n visibility: string\n emptyTitle: string\n empty: string\n modalTitle: string\n modalBody: string\n cancel: string\n confirm: string\n loading: string\n deleteConfirm: string\n }\n}\n\ninterface TableItem {\n cellData: unknown\n rowData: DataMenu\n updateCellMeasurements: () => void\n}\n\ninterface BodyProps {\n id: string\n level: string\n type: string\n firstLevel?: string | null\n secondLevel?: string | null\n}\n\nconst defaultcontent = {\n id: '',\n name: '',\n icon: '',\n slug: '',\n styles: '',\n menu: [],\n display: false,\n enableSty: false,\n order: 0,\n}\n\nconst TableComponent: FC<TableComponentProps> = (props) => {\n const [dataChangeItem, setDataChangeItem] = useState<MenuItem>(defaultcontent)\n\n const [isModalOpen, setIsModalOpen] = useState(false)\n const [menuDelete, setMenuDelete] = useState<MenuItem>(defaultcontent)\n\n const [deleteMenu, { data: dataDelete }] = useMutation(DELETE, {\n fetchPolicy: 'no-cache',\n })\n\n const { navigate } = useRuntime()\n const [menuInput, { data: dataEdit }] = useMutation(EDIT, {\n fetchPolicy: 'no-cache',\n })\n\n useEffect(() => {\n if (dataEdit) {\n if (dataChangeItem.id) {\n menuInput({\n variables: {\n editMenu: {\n id: dataChangeItem.id,\n name: dataChangeItem.name,\n icon: dataChangeItem.icon,\n slug: dataChangeItem.slug,\n styles: dataChangeItem.styles,\n menu: dataChangeItem.menu,\n display: dataChangeItem.display,\n enableSty: dataChangeItem.enableSty,\n order: dataChangeItem.order,\n mobile: dataChangeItem.mobile ?? true,\n desktop: dataChangeItem.desktop ?? true,\n },\n },\n })\n setDataChangeItem(defaultcontent)\n } else {\n props.updateData(dataEdit.editMenu, 'move')\n }\n }\n }, [dataEdit]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n if (!dataDelete) return\n\n setIsModalOpen(false)\n props.showAlert(true, props.titleColumn.deleteConfirm, dataDelete)\n window.scrollTo(0, 0)\n setTimeout(() => {\n props.showAlert(false, '', dataDelete)\n }, 4000)\n props.updateData(dataDelete.deleteMenu, 'delete')\n }, [dataDelete]) // eslint-disable-line react-hooks/exhaustive-deps\n\n const editItem = (item: TableItem) => {\n const localId = localStorage.getItem('idlvl2')\n\n const localIdFirst = localStorage.getItem('idlvl1')\n\n let bodyContext: BodyProps\n\n if (props.level === 'firstLevel') {\n bodyContext = {\n id: item.rowData.id,\n level: props.level,\n type: 'edit',\n }\n } else if (props.level === 'secondLevel') {\n bodyContext = {\n id: item.rowData.id,\n level: props.level,\n type: 'edit',\n firstLevel: item.rowData.firstLevel,\n }\n } else {\n bodyContext = {\n id: item.rowData.id,\n level: props.level,\n type: 'edit',\n firstLevel: item.rowData.firstLevel\n ? item.rowData.firstLevel\n : localIdFirst,\n secondLevel: props.idLevels?.idSecondlvl\n ? props.idLevels?.idSecondlvl\n : localId,\n }\n }\n\n navigate({\n to: `/admin/app/mega-menu/form-menu/${encodeURIComponent(\n JSON.stringify(bodyContext)\n )}`,\n })\n }\n\n const deleteItem = (idMenu: MenuItem) => {\n let id = ''\n let idSecond = ''\n let idThird = ''\n\n if (props.level === 'firstLevel') {\n id = idMenu.id\n } else if (props.level === 'secondLevel') {\n idSecond = idMenu.id\n } else {\n idThird = idMenu.id\n }\n\n deleteMenu({\n variables: {\n id: id || props.idLevels?.idFirstlvl,\n idSecond: idSecond || props.idLevels?.idSecondlvl,\n idThird,\n },\n })\n }\n\n const filtermove = (id: string, order: number, type: string) => {\n const arrayMove = [...props.dataMenu]\n let dataTempEdit: MenuItem = {} as MenuItem\n let dataChange: MenuItem = {} as MenuItem\n\n for (const i in arrayMove) {\n if (arrayMove[i].id === id) {\n const index: number =\n type === 'up' ? parseInt(i, 10) - 1 : parseInt(i, 10) + 1\n\n arrayMove[i] = {\n ...arrayMove[i],\n order: type === 'up' ? order - 1 : order + 1,\n }\n arrayMove[index] = { ...arrayMove[index], order }\n dataTempEdit = arrayMove[i]\n dataChange = arrayMove[index]\n }\n }\n\n return { dataTempEdit, dataChange }\n }\n\n const move = (id: string, order: number, typeMove: string) => {\n const { dataTempEdit, dataChange } = filtermove(id, order, typeMove)\n let dataNew = {} as DataMenu\n\n if (props.level === 'thirdLevel') {\n let subArray = [...props.dataMenu]\n\n subArray = subArray.map((item) => {\n if (item.id === dataTempEdit.id) item = dataTempEdit\n if (item.id === dataChange.id) item = dataChange\n\n return item\n })\n\n const idFirstlvl = props.idLevels ? props.idLevels.idFirstlvl : ''\n const idSecondlvl = props.idLevels ? props.idLevels.idSecondlvl : ''\n const mainMegaMenu: DataMenu[] = [...props.mainData]\n\n let dataFirstLevel = mainMegaMenu.find((item) => item.id === idFirstlvl)\n\n if (dataFirstLevel?.menu) {\n const dataSecondLevel = dataFirstLevel.menu.map((item) => {\n if (item.id === idSecondlvl) item.menu = subArray\n\n return item\n })\n\n dataFirstLevel = { ...dataFirstLevel, menu: dataSecondLevel }\n dataNew = dataFirstLevel\n }\n } else if (props.level === 'secondLevel') {\n let mainMegaMenu = { ...props.mainData[0] }\n let subArray = [...props.dataMenu]\n\n subArray = subArray.map((item) => {\n if (item.id === dataTempEdit.id) item = dataTempEdit\n if (item.id === dataChange.id) item = dataChange\n\n return item\n })\n\n mainMegaMenu = { ...mainMegaMenu, menu: subArray }\n\n dataNew = mainMegaMenu\n } else {\n setDataChangeItem(dataChange)\n dataNew = dataTempEdit\n }\n\n menuInput({\n variables: {\n editMenu: {\n id: dataNew.id,\n name: dataNew.name,\n icon: dataNew.icon,\n slug: dataNew.slug,\n styles: dataNew.styles,\n menu: dataNew.menu,\n display: dataNew.display,\n enableSty: dataNew.enableSty,\n order: dataNew.order,\n mobile: dataNew.mobile ?? true,\n desktop: dataNew.desktop ?? true,\n },\n },\n })\n }\n\n const cellComponent = (e: TableItem) => {\n const up = <IconUp color={e.rowData.order === 1 ? '#9A9899' : '#134cd8'} />\n const down = (\n <IconDown\n color={\n e.rowData.order === props.dataMenu.length ? '#9A9899' : '#134cd8'\n }\n />\n )\n\n const orderMenu = e.rowData.order ?? 0\n\n return (\n <div className=\"flex\">\n <div className=\"pt5 pr3 pb5\">\n <ButtonWithIcon\n icon={up}\n variation=\"secondary\"\n disabled={e.rowData.order === 1}\n onClick={() => move(e.rowData.id, orderMenu, 'up')}\n />\n </div>\n <div className=\"pt5 pr3 pb5\">\n <ButtonWithIcon\n icon={down}\n variation=\"secondary\"\n disabled={e.rowData.order === props.dataMenu.length}\n onClick={() => move(e.rowData.id, orderMenu, 'down')}\n />\n </div>\n <div className=\"pt5 pr3 pb5\">\n <ButtonWithIcon\n icon={<IconEdit />}\n variation=\"secondary\"\n onClick={() => editItem(e)}\n />\n </div>\n <div className=\"pt5 pb5\">\n <ButtonWithIcon\n icon={<IconDelete />}\n variation=\"danger\"\n onClick={() => {\n setMenuDelete(e.rowData)\n setIsModalOpen(true)\n }}\n />\n </div>\n </div>\n )\n }\n\n const customSchema = {\n properties: {\n name: {\n title: props.titleColumn.name,\n width: 400,\n },\n slug: {\n title: props.titleColumn.slug,\n width: 300,\n },\n icon: {\n title: props.titleColumn.icon,\n width: 300,\n },\n visibility: {\n title: props.titleColumn.visibility,\n width: 200,\n cellRenderer: (e: TableItem) => {\n return (\n <div className=\"flex\" style={{ gap: '10px' }}>\n {(e.rowData.mobile || e.rowData.mobile === null) && (\n <FaMobileAlt color=\"0C389F\" size={20} />\n )}\n {(e.rowData.desktop || e.rowData.desktop === null) && (\n <FaDesktop color=\"0C389F\" size={20} />\n )}\n {e.rowData.display ? (\n <FaEye color=\"0C389F\" size={20} />\n ) : (\n <FaEyeSlash color=\"0C389F\" size={20} />\n )}\n {e.rowData.enableSty && <FaCode color=\"0C389F\" size={20} />}\n </div>\n )\n },\n },\n actions: {\n title: props.titleColumn.action,\n width: 250,\n cellRenderer: (e: TableItem) => cellComponent(e),\n },\n },\n }\n\n return (\n <div>\n <ModalDialog\n centered\n loading={false}\n confirmation={{\n label: props.titleColumn.confirm,\n isDangerous: true,\n onClick: () => {\n deleteItem(menuDelete)\n },\n }}\n cancelation={{\n label: props.titleColumn.cancel,\n onClick: () => {\n setIsModalOpen(false)\n },\n }}\n isOpen={isModalOpen}\n onClose={() => setIsModalOpen(false)}\n >\n <div className=\"\">\n <p className=\"f3 f3-ns fw3 gray\">{props.titleColumn.modalTitle}</p>\n <p>{props.titleColumn.modalBody}</p>\n </div>\n </ModalDialog>\n {props.loading ? (\n <div style={{ textAlign: 'center' }} className=\"mt8\">\n <Spinner />\n <p>{props.titleColumn.loading}</p>\n </div>\n ) : props.dataMenu.length > 0 ? (\n <Table schema={customSchema} items={props.dataMenu} />\n ) : (\n <div className=\"mt9\">\n <EmptyState title={props.titleColumn.emptyTitle}>\n <p>\n {props.titleColumn.empty}\n </p>\n </EmptyState>\n </div>\n )}\n </div>\n )\n}\n\nexport default TableComponent\n\n```" } ]
code_mega-menu_91af86ba
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/shared/contexts/dataMenuContext.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { createContext, useContext } from 'react'\n\nimport type { DataMenu, ShowAlertFunction, UpdateData } from '..'\n\nexport interface DataMenuCtx {\n dataMenu: DataMenu[]\n showAlert: ShowAlertFunction\n updateData: UpdateData\n loading: boolean\n}\n\nconst dataMenuDefault: DataMenuCtx = {\n dataMenu: [],\n showAlert: () => null,\n updateData: () => null,\n loading: true,\n}\n\nexport const DataMenuContext = createContext<DataMenuCtx>(dataMenuDefault)\nexport const DataMenuProvider = DataMenuContext.Provider\nexport const useDataMenu = () => useContext(DataMenuContext)\n\n```" } ]
code_mega-menu_c0e062fa
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/shared/components/IconSelector/index.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React, { useMemo } from 'react'\nimport { Icon } from 'vtex.store-icons'\nimport { EXPERIMENTAL_Select as VtexSelect } from 'vtex.styleguide'\nimport { FormattedMessage } from 'react-intl'\n\nimport useStoreIconPack from './useStoreIconPack'\n\ntype Option = {\n label: JSX.Element\n value: string\n}\n\nexport interface IconSelectorProps {\n onChange?: (iconId: string) => void\n}\n\nexport const IconSelector: FC<IconSelectorProps> = ({ onChange }) => {\n const { IconPack, iconPackList } = useStoreIconPack()\n const options: Option[] = useMemo(() => {\n return iconPackList.map((icon) => ({\n label: (\n <div className=\"flex items-center\">\n <span className=\"mr4 flex items-center\">\n <Icon id={icon} />\n </span>\n <span> {icon}</span>\n </div>\n ),\n value: icon,\n }))\n }, [iconPackList])\n\n return (\n <div>\n {IconPack}\n <VtexSelect\n creatable\n multi={false}\n options={options}\n onChange={onChange}\n placeholder={\n <FormattedMessage id=\"admin/mega-menu.items.input3Form.placeholder\" />\n }\n />\n </div>\n )\n}\n\n```" } ]
code_mega-menu_169c5532
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/shared/components/IconSelector/useStoreIconPack.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useEffect, useRef, useState } from 'react'\n\nconst ICONPACK_URL =\n 'https://raw.githubusercontent.com/vtex-apps/store-icons/master/styles/iconpacks/iconpack.svg'\n\nconst useStoreIconPack = () => {\n const [svg, setSvg] = useState('')\n const [isLoaded, setIsLoaded] = useState(false)\n const [isErrored, setIsErrored] = useState(false)\n const [iconPackList, setIconPackList] = useState<string[]>([])\n const ref = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n fetch(ICONPACK_URL)\n .then((res) => res.text())\n .then(setSvg)\n .catch(setIsErrored)\n .then(() => setIsLoaded(true))\n }, [])\n\n useEffect(() => {\n if (!svg || iconPackList.length) return\n\n const list = ref.current?.querySelector('defs')?.children\n const iconIds = Array.from(list ?? []).map((x) => x.id)\n\n setIconPackList(iconIds)\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [svg])\n\n return {\n iconPackList,\n IconPack: (\n <div\n ref={ref}\n className={`svgInline svgInline--${isLoaded ? 'loaded' : 'loading'} ${\n isErrored ? 'svgInline--errored' : ''\n }`}\n dangerouslySetInnerHTML={{ __html: svg }}\n id=\"store-icon-pack\"\n />\n ),\n }\n}\n\nexport default useStoreIconPack\n\n```" } ]
code_mega-menu_41249838
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/graphql/mutations/createEditSettings.graphql from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation createEditSettings($settingsInput: SettingsInput!) {\n createEditSettings(settingsInput: $settingsInput) {\n idMenu\n orientation\n }\n}\n\n```" } ]
code_mega-menu_3ef86a2d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/graphql/mutations/create.graphql from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation create($menuInput: MenuInput!) {\n createMenu(menuInput: $menuInput) {\n id\n name\n icon\n slug\n styles\n display\n enableSty\n order\n slugRoot\n slugRelative\n mobile\n desktop\n }\n}\n\n```" } ]
code_mega-menu_68c7a5f7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/graphql/mutations/edit.graphql from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation edit($editMenu: MenuInput!) {\n editMenu(menuInput: $editMenu) {\n id\n name\n icon\n slug\n styles\n display\n enableSty\n order\n slugRoot\n slugRelative\n menu {\n id\n name\n icon\n slug\n styles\n display\n enableSty\n order\n slugRoot\n slugRelative\n mobile\n desktop\n menu {\n id\n name\n icon\n slug\n styles\n display\n enableSty\n order\n slugRoot\n slugRelative\n mobile\n desktop\n }\n }\n mobile\n desktop\n }\n}\n\n```" } ]
code_mega-menu_d3f073c4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/graphql/mutations/uploadData.graphql from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation uploadData($uploadData: [MenuInput]!) {\n uploadMenu(menuData: $uploadData) {\n id\n name\n icon\n slug\n styles\n display\n enableSty\n order\n slugRoot\n slugRelative\n mobile\n }\n}\n\n```" } ]
code_mega-menu_ed7a0111
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/graphql/mutations/delete.graphql from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation delete($id: String, $idSecond: String, $idThird: String) {\n deleteMenu(id: $id, idSecond: $idSecond, idThird: $idThird) {\n id\n name\n icon\n slug\n styles\n display\n enableSty\n order\n slugRoot\n slugRelative\n mobile\n menu {\n id\n name\n icon\n slug\n styles\n display\n enableSty\n order\n slugRoot\n slugRelative\n mobile\n menu {\n id\n name\n icon\n slug\n styles\n display\n enableSty\n order\n slugRoot\n slugRelative\n mobile\n }\n }\n }\n}\n\n```" } ]
code_mega-menu_37540503
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/graphql/queries/getMenus.graphql from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery getMenus($isMobile: Boolean) {\n menus(isMobile: $isMobile) {\n id\n name\n icon\n slug\n styles\n display\n enableSty\n order\n slugRoot\n slugRelative\n menu {\n id\n name\n icon\n slug\n styles\n display\n enableSty\n order\n slugRoot\n slugRelative\n mobile\n desktop\n menu {\n id\n name\n icon\n slug\n styles\n display\n enableSty\n order\n slugRoot\n slugRelative\n mobile\n desktop\n }\n }\n mobile\n desktop\n }\n}\n\n```" } ]
code_mega-menu_bd886b1d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/graphql/queries/getMenu.graphql from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery getMenu($id: ID!) {\n menu(id: $id) {\n id\n name\n icon\n slug\n styles\n display\n enableSty\n order\n mobile\n desktop\n menu {\n id\n name\n icon\n slug\n styles\n display\n enableSty\n order\n slugRoot\n slugRelative\n mobile\n desktop\n menu {\n id\n name\n icon\n slug\n styles\n display\n enableSty\n order\n slugRoot\n slugRelative\n mobile\n desktop\n }\n }\n }\n}\n\n```" } ]
code_mega-menu_b36f0ab9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/graphql/queries/getSettings.graphql from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery getsettings {\n settings {\n idMenu\n orientation\n }\n}\n\n```" } ]
code_mega-menu_ff463f0b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/MegaMenu/components/VerticalMenu.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport classNames from 'classnames'\nimport { observer } from 'mobx-react-lite'\nimport type { FC } from 'react'\nimport React, { useMemo } from 'react'\nimport type { InjectedIntlProps } from 'react-intl'\nimport { injectIntl } from 'react-intl'\nimport Skeleton from 'react-loading-skeleton'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { formatIOMessage } from 'vtex.native-types'\nimport { useDevice } from 'vtex.device-detector'\n\nimport { megaMenuState } from '../State'\nimport type { ItemProps } from './Item'\nimport Item from './Item'\nimport Submenu from './Submenu'\n\nconst CSS_HANDLES = [\n 'menuContainerVertical',\n 'departmentsContainer',\n 'menuContainerNavVertical',\n 'menuItemVertical',\n 'submenuContainerVertical',\n 'departmentsTitle',\n] as const\n\nconst VerticalMenu: FC<VerticalMenuProps> = observer((props) => {\n const { handles } = useCssHandles(CSS_HANDLES)\n const {\n departments,\n departmentActive,\n config,\n setDepartmentActive,\n isOpenMenu,\n } = megaMenuState\n\n const { isMobile } = useDevice()\n\n const { openOnly, orientation, intl } = props\n\n const departmentActiveHasCategories = !!departmentActive?.menu?.length\n\n const { title } = config\n\n const departmentItems = useMemo(\n () =>\n departments.map((d, i) => {\n const hasCategories = !!d.menu?.length\n\n const openDepartment = () => {\n setDepartmentActive(d)\n }\n\n const itemProps: ItemProps = {\n id: d.id,\n iconId: d.icon,\n accordion: hasCategories,\n tabIndex: i,\n onClick: openDepartment,\n style: d.styles,\n enableStyle: d.enableSty,\n ...(!hasCategories && { to: d.slug }),\n }\n\n return (\n <li\n className={classNames(\n handles.menuItemVertical,\n 'bb b--light-gray',\n {\n bt: i === 0,\n }\n )}\n key={d.id}\n >\n <Item className={classNames('pv5 mh5')} {...itemProps}>\n {d.name}\n </Item>\n </li>\n )\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [departments]\n )\n\n return (isOpenMenu && openOnly === orientation) || isMobile ? (\n <nav className={classNames(handles.menuContainerNavVertical, 'w-100')}>\n <div\n className={classNames(handles.departmentsContainer, {\n dn: !!departmentActive,\n })}\n >\n <h3\n className={classNames(\n handles.departmentsTitle,\n 'f4 fw7 c-on-base mv5 lh-copy ph5'\n )}\n >\n {formatIOMessage({ id: title, intl })}\n </h3>\n <ul className={classNames(handles.menuContainerVertical, 'list pa0')}>\n {departments.length ? (\n departmentItems\n ) : (\n <div className=\"flex flex-column justify-center ph5 lh-copy\">\n <Skeleton count={4} height={40} />\n </div>\n )}\n </ul>\n </div>\n {departmentActive && departmentActiveHasCategories && (\n <div\n className={classNames(\n handles.submenuContainerVertical,\n 'bg-base w-100'\n )}\n >\n <Submenu openOnly={openOnly} />\n </div>\n )}\n </nav>\n ) : null\n})\n\ntype VerticalMenuProps = InjectedIntlProps & {\n openOnly: string\n orientation: string\n}\n\nexport default injectIntl(VerticalMenu)\n\n```" } ]
code_mega-menu_6dc32142
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/MegaMenu/components/Submenu.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable prettier/prettier */\nimport classNames from 'classnames'\nimport { observer } from 'mobx-react-lite'\nimport type { FC } from 'react'\nimport React, { useMemo, useState } from 'react'\nimport type { InjectedIntlProps } from 'react-intl'\nimport { defineMessages, injectIntl } from 'react-intl'\nimport { applyModifiers, useCssHandles } from 'vtex.css-handles'\nimport { formatIOMessage } from 'vtex.native-types'\nimport { ExtensionPoint, Link } from 'vtex.render-runtime'\nimport { Collapsible } from 'vtex.styleguide'\n\nimport type { MenuItem } from '../../shared'\nimport { megaMenuState } from '../State'\nimport styles from '../styles.css'\nimport Item from './Item'\n\nconst CSS_HANDLES = [\n 'submenuContainer',\n 'submenuList',\n 'submenuListVertical',\n 'submenuItem',\n 'submenuItemVertical',\n 'collapsibleContent',\n 'collapsibleHeaderText',\n 'seeAllLinkContainer',\n 'seeAllLink',\n 'submenuContainerTitle',\n 'hideArrow',\n] as const\n\nconst messages = defineMessages({\n seeAllTitle: {\n defaultMessage: '',\n id: 'store/mega-menu.submenu.seeAllButton.title',\n },\n})\n\nexport type ItemProps = InjectedIntlProps & {\n closeMenu?: (open: boolean) => void\n openOnly?: string\n}\n\nconst Submenu: FC<ItemProps> = observer((props) => {\n const { intl, closeMenu, openOnly } = props\n const { handles } = useCssHandles(CSS_HANDLES)\n const { departmentActive, config, getCategories } = megaMenuState\n const { orientation } = config\n\n const [collapsibleStates, setCollapsibleStates] = useState<\n Record<string, boolean>\n >({})\n\n const [showBtnCat, setShowBtnCat] = useState(false)\n\n const seeAllLink = (to: string, level = 1, className?: string) => {\n return (\n <div\n className={classNames(\n handles.seeAllLinkContainer,\n !className && level === 1 && 'bb b--light-gray pv5 ph5 w-100',\n !className && level > 1 && 'mt4 mb6 t-body',\n className\n )}\n >\n <Link\n to={to}\n className={classNames(\n handles.seeAllLink,\n 'link underline fw7 c-on-base'\n )}\n onClick={() => {\n if (closeMenu) closeMenu(false)\n }}\n >\n {formatIOMessage({ id: messages.seeAllTitle.id, intl })}\n </Link>\n </div>\n )\n }\n\n const subCategories = (items: MenuItem[]) => {\n return items\n .filter((v) => v.display)\n .map((x) => (\n <div key={x.id} className={classNames(handles.submenuItem, 'mt3')}>\n <Item\n to={x.slug}\n iconId={x.icon}\n level={3}\n style={x.styles}\n enableStyle={x.enableSty}\n closeMenu={closeMenu}\n >\n {x.name}\n </Item>\n </div>\n ))\n }\n\n const items = useMemo(\n () => {\n if (!departmentActive) return\n\n if (departmentActive.menu) {\n if (departmentActive.menu.length > 1) {\n setShowBtnCat(true)\n } else {\n setShowBtnCat(false)\n }\n } else {\n setShowBtnCat(false)\n }\n\n const categories = getCategories()\n\n return categories\n .filter((j) => j.display)\n .map((category, i) => {\n const subcategories = category.menu?.length\n ? subCategories(category.menu)\n : []\n\n return (\n <div\n key={category.id}\n className={classNames(\n applyModifiers(\n orientation === 'horizontal' && openOnly === 'horizontal'\n ? styles.submenuItem\n : handles.submenuItemVertical,\n collapsibleStates[category.id] ? 'isOpen' : 'isClosed'\n ),\n (orientation === 'vertical' || openOnly === 'vertical') &&\n 'c-on-base bb b--light-gray mv0 ph5',\n (orientation === 'vertical' || openOnly === 'vertical') &&\n i === 0 &&\n 'bt',\n collapsibleStates[category.id] && 'bg-near-white'\n )}\n >\n {orientation === 'horizontal' && openOnly === 'horizontal' ? (\n <>\n <Item\n to={category.slug}\n iconId={category.icon}\n level={2}\n style={category.styles}\n isTitle\n enableStyle={category.enableSty}\n closeMenu={closeMenu}\n >\n {category.name}\n </Item>\n\n {!!subcategories.length && subcategories}\n {subcategories.length > 1 ? (\n seeAllLink(category.slug, 2)\n ) : (\n <div />\n )}\n </>\n ) : (\n <div\n className={\n category.menu?.length ? '' : classNames(handles.hideArrow)\n }\n >\n <Collapsible\n header={\n <p\n className={classNames(\n handles.collapsibleHeaderText,\n collapsibleStates[category.id] && 'fw7'\n )}\n >\n {category.name}\n </p>\n }\n align=\"right\"\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onClick={(e: any) => {\n if (subcategories.length >= 1) {\n setCollapsibleStates({\n ...collapsibleStates,\n [category.id]: e.target.isOpen,\n })\n } else {\n window.location.assign(`${category.slug}`)\n if (closeMenu) closeMenu(false)\n }\n }}\n isOpen={collapsibleStates[category.id]}\n caretColor={`${\n collapsibleStates[category.id] ? 'base' : 'muted'\n }`}\n >\n {!!subcategories.length && (\n <div className={handles.collapsibleContent}>\n {subcategories}\n </div>\n )}\n\n {subcategories.length >= 0 ? (\n seeAllLink(category.slug, 2)\n ) : (\n // eslint-disable-next-line jsx-a11y/anchor-has-content\n <a href={category.slug} />\n )}\n </Collapsible>\n </div>\n )}\n </div>\n )\n })\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [departmentActive, collapsibleStates]\n )\n\n return (\n <>\n {departmentActive && (\n <>\n <h3\n className={classNames(\n handles.submenuContainerTitle,\n 'f4 fw7 c-on-base lh-copy ma0 flex items-center',\n orientation === 'horizontal' &&\n openOnly === 'horizontal' &&\n 'mb6',\n (orientation === 'vertical' || openOnly === 'vertical') &&\n 'pv5 ph5'\n )}\n >\n {departmentActive.name}\n {orientation === 'horizontal' &&\n openOnly === 'horizontal' &&\n showBtnCat ? (\n seeAllLink(departmentActive.slug, 1, 't-small ml7')\n ) : (\n <div />\n )}\n </h3>\n\n <div\n className={classNames(\n orientation === 'horizontal' &&\n openOnly === 'horizontal' &&\n styles.submenuList,\n (orientation === 'vertical' || openOnly === 'vertical') &&\n handles.submenuListVertical\n )}\n >\n {orientation === 'horizontal' && openOnly === 'horizontal' ? (\n <>\n <ExtensionPoint id=\"before-menu\" /> {items}{' '}\n <ExtensionPoint id=\"after-menu\" />\n </>\n ) : (\n <>\n {items}\n {/* showBtnCat ? seeAllLink(departmentActive.slug) : <div /> */}\n </>\n )}\n </div>\n </>\n )}\n </>\n )\n})\n\nexport default injectIntl(Submenu)\n\n```" } ]
code_mega-menu_ce2626f2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/MegaMenu/components/GoBackButton.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport classNames from 'classnames'\nimport { observer } from 'mobx-react-lite'\nimport type { FC } from 'react'\nimport { useQuery } from 'react-apollo'\nimport React, { useState, useEffect } from 'react'\nimport type { InjectedIntlProps } from 'react-intl'\nimport { defineMessages, injectIntl } from 'react-intl'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { formatIOMessage } from 'vtex.native-types'\nimport { IconCaret } from 'vtex.store-icons'\n\nimport GET_SETTINGS from '../../graphql/queries/getSettings.graphql'\nimport { megaMenuState } from '../State'\n\nconst messages = defineMessages({\n goBackButtonTitle: {\n defaultMessage: '',\n id: 'store/mega-menu.goBackButton.title',\n },\n})\n\nconst CSS_HANDLES = [\n 'goBackContainer',\n 'goBackButton',\n 'goBackButtonIcon',\n 'goBackButtonText',\n] as const\n\nconst GoBackButton: FC<InjectedIntlProps> = observer(({ intl }) => {\n const { handles } = useCssHandles(CSS_HANDLES)\n const {\n departmentActive,\n config: { orientation },\n setDepartmentActive,\n } = megaMenuState\n\n const goBack = () => {\n setDepartmentActive(null)\n }\n\n const [orientationMenu, setOrientationMenu] = useState('')\n\n const { data } = useQuery(GET_SETTINGS, {\n fetchPolicy: 'no-cache',\n })\n\n useEffect(() => {\n if (data) {\n if (data.settings && data.settings.length > 0) {\n setOrientationMenu(data.settings[0].orientation)\n } else {\n setOrientationMenu('horizontal')\n }\n }\n }, [data])\n\n return (orientation === 'vertical' || orientationMenu === 'vertical') &&\n departmentActive ? (\n <div className={handles.goBackContainer}>\n <button\n className={classNames(handles.goBackButton, 'flex items-center')}\n onClick={goBack}\n >\n <IconCaret\n className={handles.goBackButtonIcon}\n orientation=\"left\"\n size=\"18\"\n />\n <span className={classNames(handles.goBackButtonText, 'ml3')}>\n {formatIOMessage({ id: messages.goBackButtonTitle.id, intl })}\n </span>\n </button>\n </div>\n ) : null\n})\n\nexport default injectIntl(GoBackButton)\n\n```" } ]
code_mega-menu_62992e7e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/MegaMenu/components/HorizontalMenu.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport classNames from 'classnames'\nimport { observer } from 'mobx-react-lite'\nimport type { FC } from 'react'\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react'\nimport type { InjectedIntlProps } from 'react-intl'\nimport { injectIntl } from 'react-intl'\nimport Skeleton from 'react-loading-skeleton'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { formatIOMessage } from 'vtex.native-types'\n\nimport { megaMenuState } from '../State'\nimport styles from '../styles.css'\nimport Item from './Item'\nimport Submenu from './Submenu'\nimport { BUTTON_ID } from './TriggerButton'\n\nconst CSS_HANDLES = [\n 'menuContainer',\n 'menuContainerNav',\n 'menuItem',\n 'submenuContainer',\n] as const\n\nconst HorizontalMenu: FC<\n InjectedIntlProps & {\n openOnly: string\n orientation: string\n }\n> = observer((props) => {\n const { handles } = useCssHandles(CSS_HANDLES)\n const {\n isOpenMenu,\n departments,\n departmentActive,\n config: { title, defaultDepartmentActive },\n setDepartmentActive,\n openMenu,\n } = megaMenuState\n\n const { openOnly, orientation, intl } = props\n\n const departmentActiveHasCategories = !!departmentActive?.menu?.length\n const navRef = useRef<HTMLDivElement>(null)\n\n const handleClickOutside = useCallback(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (event: any) => {\n const isTriggerButton = event?.path?.find(\n (data: HTMLElement) => data.dataset?.id === BUTTON_ID\n )\n\n if (\n navRef.current &&\n !navRef.current.contains(event.target as Node) &&\n !isTriggerButton\n ) {\n openMenu(false)\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n },\n [openMenu]\n )\n\n useEffect(() => {\n document.addEventListener('click', handleClickOutside, true)\n\n return () => {\n document.removeEventListener('click', handleClickOutside, true)\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n useEffect(() => {\n const defaultDepartment = departments.find(\n (x) =>\n x.name.toLowerCase().trim() ===\n defaultDepartmentActive?.toLowerCase().trim()\n )\n\n if (defaultDepartment) {\n setDepartmentActive(defaultDepartment)\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [defaultDepartmentActive])\n\n const departmentItems = useMemo(\n () =>\n departments\n .filter((j) => j.display)\n .map((d) => {\n const hasCategories = !!d.menu?.length\n\n return (\n <li\n className={classNames(\n handles.menuItem,\n d.id === departmentActive?.id && 'bg-black-05'\n )}\n key={d.id}\n onMouseEnter={() => {\n setDepartmentActive(d)\n }}\n >\n <Item\n id={d.id}\n to={d.slug}\n iconId={d.icon}\n accordion={hasCategories}\n className={classNames('pv3 mh5')}\n style={d.styles}\n enableStyle={d.enableSty}\n closeMenu={openMenu}\n >\n {d.name}\n </Item>\n </li>\n )\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [departments, departmentActive]\n )\n\n const loaderBlocks = useMemo(() => {\n const blocks: JSX.Element[] = []\n\n for (let index = 1; index <= 4; index++) {\n blocks.push(\n <div className=\"lh-copy\">\n <Skeleton height={20} />\n <Skeleton height={80} />\n </div>\n )\n }\n\n return blocks\n }, [])\n\n return isOpenMenu && openOnly === orientation ? (\n <nav\n className={classNames(\n handles.menuContainerNav,\n 'absolute left-0 bg-white bw1 bb b--muted-3 flex'\n )}\n ref={navRef}\n >\n <ul\n className={classNames(\n styles.menuContainer,\n 'list ma0 pa0 pb3 br b--muted-4'\n )}\n >\n <h3 className=\"f4 fw7 c-on-base lh-copy ma0 pv5 ph5\">\n {formatIOMessage({ id: title, intl })}\n </h3>\n {departments.length ? (\n departmentItems\n ) : (\n <div className=\"flex flex-column justify-center ph5 lh-copy\">\n <Skeleton count={3} height={30} />\n </div>\n )}\n </ul>\n {departments.length ? (\n departmentActive &&\n departmentActiveHasCategories && (\n <div className={classNames(styles.submenuContainer, 'pa5 w-100')}>\n <Submenu closeMenu={openMenu ?? 'horizontal'} openOnly={openOnly} />\n </div>\n )\n ) : (\n <div className=\"w-100\" style={{ overflow: 'auto' }}>\n <div className=\"w-30 mb4 ml4 mt5\">\n <Skeleton height={30} />\n </div>\n <div className={classNames(styles.submenuList, 'mh4 mb5')}>\n {loaderBlocks}\n </div>\n </div>\n )}\n </nav>\n ) : null\n})\n\nexport default injectIntl(HorizontalMenu)\n\n```" } ]
code_mega-menu_7602794a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/MegaMenu/components/TriggerButton.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport classNames from 'classnames'\nimport { observer } from 'mobx-react-lite'\nimport { useQuery } from 'react-apollo'\nimport type { FC } from 'react'\nimport React, { useState, useEffect } from 'react'\nimport { applyModifiers, useCssHandles } from 'vtex.css-handles'\nimport { Icon } from 'vtex.store-icons'\nimport { useDevice } from 'vtex.device-detector'\n\nimport GET_SETTINGS from '../../graphql/queries/getSettings.graphql'\nimport type { IconProps } from '../../shared'\nimport { megaMenuState } from '../State'\nimport styles from '../styles.css'\n\nconst CSS_HANDLES = ['triggerContainer', 'triggerButtonIcon'] as const\n\nexport const BUTTON_ID = 'mega-menu-trigger-button'\n\nconst TriggerButton: FC<TriggerButtonProps> = observer((props) => {\n const { handles } = useCssHandles(CSS_HANDLES)\n const { openMenu, isOpenMenu } = megaMenuState\n const [orientationMenu, setOrientationMenu] = useState('')\n const { isMobile } = useDevice()\n\n const { data } = useQuery(GET_SETTINGS, {\n fetchPolicy: 'no-cache',\n })\n\n const { isActive, activeClassName, mutedClassName, Drawer, ...rest } = props\n const iconBaseClassName = applyModifiers(\n handles.triggerButtonIcon,\n isActive ? 'active' : 'muted'\n )\n\n useEffect(() => {\n if (data) {\n if (data.settings && data.settings.length > 0) {\n setOrientationMenu(data.settings[0].orientation)\n } else {\n setOrientationMenu('horizontal')\n }\n }\n }, [data])\n\n return orientationMenu === 'vertical' || isMobile ? (\n // eslint-disable-next-line jsx-a11y/interactive-supports-focus\n <div\n onClick={() => {\n if (!isOpenMenu && orientationMenu === 'vertical') {\n openMenu((v) => !v)\n }\n\n if (!isOpenMenu && isMobile) {\n openMenu((v) => !v)\n }\n }}\n role=\"button\"\n >\n <Drawer />\n </div>\n ) : (\n <button\n data-id={BUTTON_ID}\n className={classNames(styles.triggerContainer, 'pointer')}\n onClick={() => openMenu((v) => !v)}\n >\n <Icon\n activeClassName={classNames(iconBaseClassName, activeClassName)}\n mutedClassName={classNames(iconBaseClassName, mutedClassName)}\n isActive={isActive}\n {...rest}\n />\n </button>\n )\n})\n\nexport type TriggerButtonProps = IconProps\n\nTriggerButton.defaultProps = {\n id: 'hpa-hamburguer-menu',\n isActive: true,\n}\n\nexport default TriggerButton\n\n```" } ]
code_mega-menu_b37db560
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of mega-menu/react/MegaMenu/components/Item.tsx from the mega-menu VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport classNames from 'classnames'\nimport { observer } from 'mobx-react-lite'\nimport React, { useMemo } from 'react'\nimport type { FC } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { Icon, IconCaret } from 'vtex.store-icons'\n\nimport type { IconProps } from '../../shared'\nimport { megaMenuState } from '../State'\n\nconst CSS_HANDLES = [\n 'styledLink',\n 'styledLinkIcon',\n 'styledLinkContainer',\n 'styledLinkContent',\n 'styledLinkText',\n 'accordionIconContainer',\n 'accordionIcon',\n] as const\n\nconst defaultTypography: Record<number, string> = {\n 1: 't-body',\n 2: 't-body',\n 3: 't-body',\n}\n\nconst Item: FC<ItemProps> = observer((props) => {\n const { handles, withModifiers } = useCssHandles(CSS_HANDLES)\n const { departmentActive } = megaMenuState\n const {\n id,\n to,\n level = 1,\n isTitle,\n disabled,\n accordion,\n iconId,\n iconProps,\n iconPosition,\n typography = defaultTypography[level],\n tabIndex,\n className,\n onClick,\n children,\n style,\n enableStyle,\n closeMenu,\n ...rest\n } = props\n\n // Only for level 1\n const isOpen = departmentActive?.id === id\n const hasLink = to && to !== '#'\n\n const { rootPath } = useRuntime()\n\n const linkClassNames = classNames(\n handles.styledLink,\n 'no-underline c-on-base w-100 pa0',\n {\n [typography]: true,\n 'fw6 c-on-base': isTitle,\n pointer: !disabled && !isTitle,\n }\n )\n\n const stylesItem = useMemo(() => {\n if (style) {\n let tempStyle: Record<string, string> = {}\n\n try {\n tempStyle = JSON.parse(style)\n } catch (e) {\n return {}\n }\n\n return Object.entries(tempStyle).reduce((obj, [key, value]) => {\n const formatKey = key.replace(/-([a-z])/g, (g) => {\n return g[1].toUpperCase()\n })\n\n return {\n ...obj,\n [formatKey]: value,\n }\n }, {})\n }\n\n return {}\n }, [style])\n\n const iconTestId = `icon-${iconPosition}`\n const iconComponent =\n iconProps || iconId ? (\n <span\n className={classNames(\n handles.styledLinkIcon,\n 'flex items-center',\n iconPosition === 'left' ? 'mr3' : 'ml3'\n )}\n data-testid={iconTestId}\n >\n <Icon {...{ ...iconProps, id: iconProps?.id ?? iconId }} />\n </span>\n ) : null\n\n const content = (\n <div\n className={classNames(handles.styledLinkContent, 'flex justify-between')}\n >\n <div\n className={classNames(\n handles.styledLinkText,\n 'flex justify-between items-center',\n iconPosition === 'left' && iconComponent && 'nowrap'\n )}\n {...(enableStyle && { style: stylesItem })}\n >\n {iconPosition === 'left' && iconComponent}\n {children}\n {iconPosition === 'right' && iconComponent}\n </div>\n {accordion && (\n <div\n className={`${withModifiers(\n 'accordionIconContainer',\n isOpen ? 'isOpen' : 'isClosed'\n )} ml1 c-muted-3`}\n >\n <IconCaret classNames={handles.accordionIcon} orientation=\"right\" />\n </div>\n )}\n </div>\n )\n\n console.info(rootPath)\n console.info({ ...rest })\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions\n <div\n className={classNames(handles.styledLinkContainer, className)}\n onClick={onClick}\n >\n {disabled || !hasLink ? (\n onClick ? (\n <button className={linkClassNames}>{content}</button>\n ) : (\n <span className={linkClassNames}>{content}</span>\n )\n ) : (\n <a className={linkClassNames} href={`${window.location.origin}/${to}`}>\n {content}\n </a>\n )}\n </div>\n )\n})\n\nItem.defaultProps = {\n iconPosition: 'left',\n}\n\nexport interface ItemProps {\n id?: string\n level?: number\n to?: string\n isTitle?: boolean\n disabled?: boolean\n accordion?: boolean\n typography?: string\n iconId?: string\n iconProps?: IconProps\n iconPosition?: 'left' | 'right'\n tabIndex?: number\n className?: string\n style?: string\n enableStyle?: boolean\n onClick?: () => void\n closeMenu?: (open: boolean) => void\n}\n\nexport default Item\n\n```" } ]
code_google-customer-reviews_1dcf6eb9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of google-customer-reviews/docs/README.md from the google-customer-reviews VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/vtex-apps/google-customer-reviews) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# Google Customer Reviews\n\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n\nThis is a first party integration app for Google Customer Reviews, a free service that enables Google to collect valuable feedback from customers who’ve made a purchase on your site.\n\n![Google Customer Reviews](https://user-images.githubusercontent.com/284515/77967280-31500500-72bb-11ea-9e71-b3abf8d677df.png)\n\n## Configuration\n\n1. [Install](https://vtex.io/docs/recipes/store/installing-an-app) the `vtex.google-customer-reviews` app in your VTEX account.\n\n> ℹ️ *By installing the Google Customer Reviews, you will have access to the `google-customer-review-badge` block, which displays the Google Customer Reviews badge on your store's UI. To know how to set it up, check out the **Advanced Configuration** section below.*\n\n2. In your account's admin, open the **Apps** section and select the **Google Customer Reviews** box.\n3. Click on the settings icon and add your **Merchant Center ID**. You can get this value from the [Google Merchant Center](https://www.google.com/retail/solutions/merchant-center/.\n4. Save your changes.\n\n### Advanced Configuration\n\nTo display the Google Customer Reviews badge in your store, follow the instructions below:\n\n1. Add the Google Customer Reviews app to your theme's `peerDependency` list: \n\n```diff\n \"peerDependencies\": {\n \"vtex.reviews-and-ratings\": \"2.x\",\n+ \"vtex.google-customer-reviews\": \"1.x\"\n },\n```\n\n> ⚠️ *To be successful in the first step, you will need to update your theme to a new major version. Learn how to perform this update following the instructions given in [this tutorial](https://vtex.io/docs/recipes/development/migrating-CMS-settings-after-major-update/).* \n\n2. Add the `google-customer-review-badge` block to your theme's in the desired template. For example: \n\n```diff\n \"flex-layout.row#footer-1-desktop\": {\n \"children\": [\n \"vtex.menu@2.x:menu#Products\",\n \"vtex.menu@2.x:menu#footer-clothing\",\n \"vtex.menu@2.x:menu#footer-decoration\",\n \"vtex.menu@2.x:menu#footer-bags\",\n \"footer-spacer\",\n \"social-networks\",\n+ \"google-customer-review-badge\"\n ],\n \"props\": {\n \"blockClass\": \"menu-row\",\n \"paddingTop\": 6,\n \"paddingBottom\": 3\n }\n },\n```\n\n3. [Deploy your theme changes](https://vtex.io/docs/recipes/store-management/making-your-theme-content-public/). \n\n## Troubleshooting\n\nThis app only works with the website URL verified and claimed in Merchant Center. When the website URL is not verified, a 404 javascript error is generated.\n\n<!-- DOCS-IGNORE:start -->\n\n## Contributors ✨\n\nThanks goes to these wonderful people:\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!\n\n<!-- DOCS-IGNORE:end -->\n\n\n\n```" } ]
code_google-customer-reviews_df6689cb
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of google-customer-reviews/react/index.tsx from the google-customer-reviews VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/camelcase */\nimport { canUseDOM } from 'vtex.render-runtime'\nimport { PixelMessage } from './typings/events'\nimport { getCountryISO2 } from './modules/iso-3-to-2'\nimport { addScript } from './modules/addScript'\n\nexport function handleEvents(e: PixelMessage) {\n switch (e.data.eventName) {\n case 'vtex:orderPlacedTracked':\n case 'vtex:orderPlaced': {\n const data = e.data\n const merchantId = window.__google_customer_reviews.merchantId\n const passGtin = window.__google_customer_reviews.passGtin\n const optInStyle = window.__google_customer_reviews.optInStyle\n const showBadge = window.__google_customer_reviews.showBadge\n const badgePosition = window.__google_customer_reviews.badgePosition\n\n const shippingEstimateDate = new Date(\n data.transactionLatestShippingEstimate\n )\n const estimate = shippingEstimateDate.toISOString().slice(0, 10)\n\n window.renderOptIn = function() {\n if (showBadge === 'true') {\n const ratingBadgeContainer = document.createElement('div')\n document.body.appendChild(ratingBadgeContainer)\n\n window.gapi.load('ratingbadge', function() {\n window.gapi.ratingbadge.render(ratingBadgeContainer, {\n merchant_id: merchantId,\n position: badgePosition,\n })\n })\n }\n\n window.gapi.load('surveyoptin', function() {\n window.gapi.surveyoptin.render({\n // REQUIRED\n merchant_id: merchantId,\n order_id: data.orderGroup,\n email: data.visitorContactInfo[0],\n delivery_country: getCountryISO2(\n data.visitorAddressCountry as keyof typeof getCountryISO2\n ),\n estimated_delivery_date: estimate,\n // OPTIONAL\n products:\n passGtin === 'true'\n ? data.transactionProducts.map(product => ({\n gtin: product.ean,\n }))\n : undefined,\n opt_in_style: optInStyle,\n })\n })\n }\n\n addScript('renderOptIn')\n return\n }\n default: {\n return\n }\n }\n}\n\nif (canUseDOM) {\n window.addEventListener('message', handleEvents)\n}\n\n```" } ]
code_google-customer-reviews_70527a97
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of google-customer-reviews/react/package.json from the google-customer-reviews VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"ramda\": \"^0.26.1\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^3.1.3\",\n \"@types/graphql\": \"^14.5.0\",\n \"@types/jest\": \"^24.9.0\",\n \"@types/node\": \"^13.1.8\",\n \"@types/ramda\": \"^0.26.5\",\n \"@types/react\": \"^16.9.19\",\n \"@types/react-intl\": \"^3.0.0\",\n \"@vtex/test-tools\": \"^3.0.1\",\n \"apollo-cache-inmemory\": \"^1.6.5\",\n \"apollo-client\": \"^2.6.8\",\n \"eslint\": \"^5.16.0\",\n \"eslint-config-vtex-react\": \"^4.1.0\",\n \"graphql\": \"^14.5.4\",\n \"prettier\": \"^1.18.2\",\n \"react-intl\": \"^3.11.0\",\n \"tslint-eslint-rules\": \"^5.4.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.pixel-interfaces\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.pixel-interfaces@1.1.1/public/_types/react\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.126.4/public/@types/vtex.render-runtime\"\n },\n \"version\": \"1.1.1\"\n}\n\n```" } ]
code_google-customer-reviews_85ffe7c8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of google-customer-reviews/react/Badge.tsx from the google-customer-reviews VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useEffect } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport { addScript } from './modules/addScript'\n\n// @ts-expect-error it will be called onload of the script\nwindow.renderGoogleInlineBadge = function() {\n var ratingBadgeContainer = document.getElementById(\n 'google-customer-reviews-badge'\n ) as HTMLDivElement\n\n window.gapi.load('ratingbadge', function() {\n const merchantId = window.__google_customer_reviews\n ? window.__google_customer_reviews.merchantId\n : ''\n\n if (!ratingBadgeContainer) return\n\n window.gapi.ratingbadge.render(ratingBadgeContainer, {\n // eslint-disable-next-line @typescript-eslint/camelcase\n merchant_id: merchantId,\n position: 'INLINE',\n })\n })\n}\n\nconst CSS_HANDLES = ['badge'] as const\n\nfunction Badge() {\n const { handles } = useCssHandles(CSS_HANDLES)\n\n useEffect(() => {\n addScript('renderGoogleInlineBadge')\n }, [])\n\n return (\n <div id=\"google-customer-reviews-badge\" className={handles.badge}></div>\n )\n}\n\nexport default Badge\n\n```" } ]
code_google-customer-reviews_32dbda75
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of google-customer-reviews/store/interfaces.json from the google-customer-reviews VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"pixel.google-customer-reviews\": {\n \"component\": \"index\"\n },\n \"google-customer-review-badge\": {\n \"component\": \"Badge\"\n }\n}\n\n```" } ]
code_google-customer-reviews_9010eee5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of google-customer-reviews/store/plugins.json from the google-customer-reviews VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"pixels > pixel\": \"pixel.google-customer-reviews\"\n}\n\n```" } ]
code_google-customer-reviews_e9c33e4c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of google-customer-reviews/public/metadata/messages/es-AR.json from the google-customer-reviews VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"Google Customer Review\",\n \"headline\": \"Esta aplicación permite a Google recopilar y publicar comentarios de clientes que han realizado una compra en su sitio web.\",\n \"overview\": \"Esta aplicación permite la integración con el servicio gratuito ofrecido por Google para recopilar opiniones y comentarios de clientes que han comprado en su tienda.\\nLa información recopilada puede ser útil para monitorear, a través del Centro de comerciantes de Google, cómo van las experiencias de los clientes, también para los anuncios de Google AdWords y para mostrar productos en Google Shopping.\",\n \"features\": [\n \"Envío de e-mail para evaluación de clientes con la opción \\\"Google Customer Reviews\\\" habilitada\",\n \"Sello de Google con la calificación del vendedor (opcional)\",\n \"Formulario de encuesta de opinión del cliente (opcional)\",\n \"Calificación del vendedor en Google Shopping.\"\n ],\n \"additionalInformation\": \"Para usar la aplicación en su tienda y controlar los datos recopilados, debe tener una cuenta en Google Merchant Center.\",\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_google-customer-reviews_842fc687
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of google-customer-reviews/public/metadata/messages/pt-BR.json from the google-customer-reviews VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"Google Customer Review\",\n \"headline\": \"Este aplicativo permite que o Google colete e publique comentários de clientes que fizeram uma compra no seu site.\",\n \"overview\": \"Este aplicativo permite a integração com o serviço gratuito oferecido pelo Google de coleta de avaliações e comentários dos clientes que compraram na sua loja.\\nAs informações coletadas podem ser úteis para monitorar, por meio do Google Merchant Center, como estão sendo as experiências dos clientes, também para anúncios do Google AdWords e para apresentação de produtos no Google Shopping.\",\n \"features\": [\n \"Envio de e-mail para avaliação de clientes com a opção \\\"Google Customer Reviews\\\" ativada\",\n \"Selo do Google com a classificação do vendedor (opcional)\",\n \"Formulário de pesquisa de opinião de clientes (opcional)\",\n \"Classificação do vendedor no Google Shopping.\"\n ],\n \"additionalInformation\": \"Para a utilização do aplicativo em sua loja e acompanhamento dos dados coletados, é preciso ter uma conta no Google Merchant Center.\",\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_google-customer-reviews_d61b703e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of google-customer-reviews/public/metadata/messages/en-US.json from the google-customer-reviews VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"Google Customer Review\",\n \"headline\": \"This application allows Google to collect and post comments from customers who have made a purchase on your website.\",\n \"overview\": \"This application allows integration with the free service offered by Google to collect reviews and comments from customers who have purchased at your store.\\nThe information collected can be useful for monitoring, through the Google Merchant Center, how customers' experiences are going, also for Google AdWords and for product presentation on Google Shopping.\",\n \"features\": [\n \"Sending e-mail for customer evaluation with the 'Google Customer Reviews' opt-in\",\n \"Google stamp with the seller rating (optional)\",\n \"Customer opinion survey form (optional)\",\n \"Seller rating on Google Shopping.\"\n ],\n \"additionalInformation\": \"To use the application in your store and monitor the data collected, you must have an account at Google Merchant Center.\",\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_google-customer-reviews_3ad52033
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of google-customer-reviews/react/typings/events.d.ts from the google-customer-reviews VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport interface PixelMessage extends MessageEvent {\n data:\n | ProductViewData\n | ProductClickData\n | OrderPlacedData\n | OrderPlacedTrackedData\n | PageViewData\n | ProductImpressionData\n | AddToCartData\n | RemoveToCartData\n | CartChangedData\n | HomePageInfo\n | ProductPageInfoData\n | SearchPageInfoData\n | UserData\n | CartIdData\n}\n\nexport interface EventData {\n event: string\n eventName: string\n currency: string\n}\n\nexport interface PageInfoData extends EventData {\n event: 'pageInfo'\n eventName: 'vtex:pageInfo'\n accountName: string\n pageTitle: string\n pageUrl: string\n}\n\nexport interface UserData extends PageInfoData {\n eventType: 'userData'\n eventName: 'vtex:userData'\n firstName?: string\n lastName?: string\n document?: string\n id?: string\n email?: string\n phone?: string\n isAuthenticated: boolean\n}\n\nexport interface CartIdData extends PageInfoData {\n eventType: 'cartId'\n eventName: 'vtex:cartId'\n cartId: string\n}\n\nexport interface HomePageInfo extends PageInfoData {\n eventType: 'homeView'\n}\n\nexport interface ProductPageInfoData extends PageInfoData {\n eventType: 'productPageInfo'\n}\n\nexport interface SearchPageInfoData extends PageInfoData {\n eventType:\n | 'internalSiteSearchView'\n | 'categoryView'\n | 'departmentView'\n | 'emptySearchView'\n category?: CategoryMetaData\n department?: DepartmentMetaData\n search?: SearchMetaData\n}\n\ninterface CategoryMetaData {\n id: string\n name: string\n}\n\ninterface DepartmentMetaData {\n id: string\n name: string\n}\n\ninterface SearchMetaData {\n term: string\n category: CategoryMetaData\n results: number\n}\n\nexport interface PageViewData extends EventData {\n event: 'pageView'\n eventName: 'vtex:pageView'\n pageTitle: string\n pageUrl: string\n referrer: string\n}\n\nexport interface AddToCartData extends EventData {\n event: 'addToCart'\n eventName: 'vtex:addToCart'\n items: CartItem[]\n}\n\nexport interface RemoveToCartData extends EventData {\n event: 'removeFromCart'\n eventName: 'vtex:removeFromCart'\n items: CartItem[]\n}\n\nexport interface CartChangedData extends EventData {\n event: 'cartChanged'\n eventName: 'vtex:cartChanged'\n items: CartItem[]\n}\n\nexport interface OrderPlacedData extends Order, EventData {\n event: 'orderPlaced'\n eventName: 'vtex:orderPlaced'\n}\n\nexport interface OrderPlacedTrackedData extends Order, EventData {\n event: 'orderPlacedTracked'\n eventName: 'vtex:orderPlacedTracked'\n}\n\nexport interface ProductViewData extends EventData {\n event: 'productView'\n eventName: 'vtex:productView'\n product: ProductDetail\n}\n\nexport interface ProductClickData extends EventData {\n event: 'productClick'\n eventName: 'vtex:productClick'\n product: ProductSummary\n}\n\nexport interface ProductImpressionData extends EventData {\n event: 'productImpression'\n eventName: 'vtex:productImpression'\n impressions: Impression[]\n product?: ProductSummary // deprecated, use impressions list!\n position?: number // deprecated, use impressions list!\n list: string\n}\n\ninterface CartItem {\n skuId: string\n variant: string\n price: number\n name: string\n quantity: number\n productRefId: string\n brand: string\n category: string\n detailUrl: string\n imageUrl: string\n}\n\nexport interface Order {\n currency: string\n accountName: string\n orderGroup: string\n salesChannel: string\n coupon: string\n visitorType: string\n visitorContactInfo: string[]\n visitorAddressState: string\n visitorAddressCountry: string\n visitorAddressPostalCode: string\n transactionId: string\n transactionDate: string\n transactionAffiliation: string\n transactionTotal: number\n transactionShipping: number\n transactionSubtotal: number\n transactionDiscounts: number\n transactionTax: number\n transactionCurrency: string\n transactionPaymentType: PaymentType[]\n transactionShippingMethod: ShippingMethod[]\n transactionLatestShippingEstimate: Date\n transactionProducts: ProductOrder[]\n transactionPayment: {\n id: string\n }\n}\n\nexport interface Impression {\n product: ProductSummary\n position: number\n}\n\nexport interface PaymentType {\n group: string\n paymentSystemName: string\n installments: number\n value: number\n}\n\nexport interface ShippingMethod {\n itemId: string\n selectedSla: string\n}\n\nexport interface ProductOrder {\n id: string\n name: string\n sku: string\n skuRefId: string\n skuName: string\n productRefId: string\n ean: string\n slug: string\n brand: string\n brandId: string\n seller: string\n sellerId: string\n category: string\n categoryId: string\n categoryTree: string[]\n categoryIdTree: string[]\n priceTags: PriceTag[]\n originalPrice: number\n price: number\n sellingPrice: number\n tax: number\n quantity: number\n components: any[]\n measurementUnit: string\n unitMultiplier: number\n}\n\nexport interface PriceTag {\n identifier: string\n isPercentual: boolean\n value: number\n}\n\ninterface Product {\n brand: string\n brandId: string\n categories: string[]\n productId: string\n productName: string\n productReference: string\n linkText: string\n items: Item[]\n}\n\nexport interface ProductSummary extends Product {\n sku: Item\n}\n\nexport interface ProductDetail extends Product {\n categoryId: string\n categoryTree: { id: string; name: string }[]\n selectedSku: Item\n}\n\nexport interface Item {\n itemId: string\n name: string\n ean?: string // TODO: provide this info at productImpression\n referenceId: { Key: string; Value: string }\n seller?: Seller\n sellers: Seller[]\n}\n\nexport interface Seller {\n commertialOffer: CommertialOffer\n sellerId: string\n}\n\nexport interface CommertialOffer {\n Price: number\n ListPrice: number\n AvailableQuantity: number\n}\n\n```" } ]
code_google-customer-reviews_193f0389
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of google-customer-reviews/react/typings/global.d.ts from the google-customer-reviews VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ninterface Window extends Window {\n __google_customer_reviews: {\n merchantId: MerchantId\n passGtin: 'true' | 'false'\n optInStyle:\n | 'CENTER_DIALOG'\n | 'BOTTOM_RIGHT_DIALOG'\n | 'BOTTOM_LEFT_DIALOG'\n | 'TOP_RIGHT_DIALOG'\n | 'TOP_LEFT_DIALOG'\n | 'BOTTOM_TRAY'\n showBadge: 'true' | 'false'\n badgePosition: 'BOTTOM_RIGHT' | 'BOTTOM_LEFT' | 'INLINE'\n }\n gapi: GoogleAPI\n renderOptIn: () => void\n}\n\ntype MerchantId = string\n\ninterface GoogleAPI {\n load: (event: string, callback: () => void) => void\n ratingbadge: {\n render: (element: HTMLDivElement, params: RatingBadgeParams) => void\n },\n surveyoptin: {\n render: (params: SurveyParams) => void\n }\n}\n\ninterface SurveyParams {\n merchant_id: MerchantId\n order_id: string\n email: string\n delivery_country: string\n estimated_delivery_date: string\n products?: SurveyProducts[]\n opt_in_style?:\n | 'CENTER_DIALOG'\n | 'BOTTOM_RIGHT_DIALOG'\n | 'BOTTOM_LEFT_DIALOG'\n | 'TOP_RIGHT_DIALOG'\n | 'TOP_LEFT_DIALOG'\n | 'BOTTOM_TRAY'\n}\n\ninterface SurveyProducts {\n gtin: string\n}\n\ninterface RatingBadgeParams {\n merchant_id: MerchantId\n position: 'BOTTOM_RIGHT' | 'BOTTOM_LEFT' | 'INLINE'\n}\n\n```" } ]
code_google-customer-reviews_b4bf02a4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of google-customer-reviews/react/modules/addScript.ts from the google-customer-reviews VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport function addScript(callbackName: string) {\n const scriptOnPage = document.getElementById('google-customer-reviews')\n if (scriptOnPage) return\n\n const script = document.createElement('script')\n script.async = true\n script.defer = true\n script.id = 'google-customer-reviews'\n script.src = 'https://apis.google.com/js/platform.js?onload=' + callbackName\n document.body.appendChild(script)\n}\n\n```" } ]
code_google-customer-reviews_a918dbb1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of google-customer-reviews/react/modules/iso-3-to-2.ts from the google-customer-reviews VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nconst countryISOMapping = {\n AFG: \"AF\",\n ALA: \"AX\",\n ALB: \"AL\",\n DZA: \"DZ\",\n ASM: \"AS\",\n AND: \"AD\",\n AGO: \"AO\",\n AIA: \"AI\",\n ATA: \"AQ\",\n ATG: \"AG\",\n ARG: \"AR\",\n ARM: \"AM\",\n ABW: \"AW\",\n AUS: \"AU\",\n AUT: \"AT\",\n AZE: \"AZ\",\n BHS: \"BS\",\n BHR: \"BH\",\n BGD: \"BD\",\n BRB: \"BB\",\n BLR: \"BY\",\n BEL: \"BE\",\n BLZ: \"BZ\",\n BEN: \"BJ\",\n BMU: \"BM\",\n BTN: \"BT\",\n BOL: \"BO\",\n BIH: \"BA\",\n BWA: \"BW\",\n BVT: \"BV\",\n BRA: \"BR\",\n VGB: \"VG\",\n IOT: \"IO\",\n BRN: \"BN\",\n BGR: \"BG\",\n BFA: \"BF\",\n BDI: \"BI\",\n KHM: \"KH\",\n CMR: \"CM\",\n CAN: \"CA\",\n CPV: \"CV\",\n CYM: \"KY\",\n CAF: \"CF\",\n TCD: \"TD\",\n CHL: \"CL\",\n CHN: \"CN\",\n HKG: \"HK\",\n MAC: \"MO\",\n CXR: \"CX\",\n CCK: \"CC\",\n COL: \"CO\",\n COM: \"KM\",\n COG: \"CG\",\n COD: \"CD\",\n COK: \"CK\",\n CRI: \"CR\",\n CIV: \"CI\",\n HRV: \"HR\",\n CUB: \"CU\",\n CYP: \"CY\",\n CZE: \"CZ\",\n DNK: \"DK\",\n DJI: \"DJ\",\n DMA: \"DM\",\n DOM: \"DO\",\n ECU: \"EC\",\n EGY: \"EG\",\n SLV: \"SV\",\n GNQ: \"GQ\",\n ERI: \"ER\",\n EST: \"EE\",\n ETH: \"ET\",\n FLK: \"FK\",\n FRO: \"FO\",\n FJI: \"FJ\",\n FIN: \"FI\",\n FRA: \"FR\",\n GUF: \"GF\",\n PYF: \"PF\",\n ATF: \"TF\",\n GAB: \"GA\",\n GMB: \"GM\",\n GEO: \"GE\",\n DEU: \"DE\",\n GHA: \"GH\",\n GIB: \"GI\",\n GRC: \"GR\",\n GRL: \"GL\",\n GRD: \"GD\",\n GLP: \"GP\",\n GUM: \"GU\",\n GTM: \"GT\",\n GGY: \"GG\",\n GIN: \"GN\",\n GNB: \"GW\",\n GUY: \"GY\",\n HTI: \"HT\",\n HMD: \"HM\",\n VAT: \"VA\",\n HND: \"HN\",\n HUN: \"HU\",\n ISL: \"IS\",\n IND: \"IN\",\n IDN: \"ID\",\n IRN: \"IR\",\n IRQ: \"IQ\",\n IRL: \"IE\",\n IMN: \"IM\",\n ISR: \"IL\",\n ITA: \"IT\",\n JAM: \"JM\",\n JPN: \"JP\",\n JEY: \"JE\",\n JOR: \"JO\",\n KAZ: \"KZ\",\n KEN: \"KE\",\n KIR: \"KI\",\n PRK: \"KP\",\n KOR: \"KR\",\n KWT: \"KW\",\n KGZ: \"KG\",\n LAO: \"LA\",\n LVA: \"LV\",\n LBN: \"LB\",\n LSO: \"LS\",\n LBR: \"LR\",\n LBY: \"LY\",\n LIE: \"LI\",\n LTU: \"LT\",\n LUX: \"LU\",\n MKD: \"MK\",\n MDG: \"MG\",\n MWI: \"MW\",\n MYS: \"MY\",\n MDV: \"MV\",\n MLI: \"ML\",\n MLT: \"MT\",\n MHL: \"MH\",\n MTQ: \"MQ\",\n MRT: \"MR\",\n MUS: \"MU\",\n MYT: \"YT\",\n MEX: \"MX\",\n FSM: \"FM\",\n MDA: \"MD\",\n MCO: \"MC\",\n MNG: \"MN\",\n MNE: \"ME\",\n MSR: \"MS\",\n MAR: \"MA\",\n MOZ: \"MZ\",\n MMR: \"MM\",\n NAM: \"NA\",\n NRU: \"NR\",\n NPL: \"NP\",\n NLD: \"NL\",\n ANT: \"AN\",\n NCL: \"NC\",\n NZL: \"NZ\",\n NIC: \"NI\",\n NER: \"NE\",\n NGA: \"NG\",\n NIU: \"NU\",\n NFK: \"NF\",\n MNP: \"MP\",\n NOR: \"NO\",\n OMN: \"OM\",\n PAK: \"PK\",\n PLW: \"PW\",\n PSE: \"PS\",\n PAN: \"PA\",\n PNG: \"PG\",\n PRY: \"PY\",\n PER: \"PE\",\n PHL: \"PH\",\n PCN: \"PN\",\n POL: \"PL\",\n PRT: \"PT\",\n PRI: \"PR\",\n QAT: \"QA\",\n REU: \"RE\",\n ROU: \"RO\",\n RUS: \"RU\",\n RWA: \"RW\",\n BLM: \"BL\",\n SHN: \"SH\",\n KNA: \"KN\",\n LCA: \"LC\",\n MAF: \"MF\",\n SPM: \"PM\",\n VCT: \"VC\",\n WSM: \"WS\",\n SMR: \"SM\",\n STP: \"ST\",\n SAU: \"SA\",\n SEN: \"SN\",\n SRB: \"RS\",\n SYC: \"SC\",\n SLE: \"SL\",\n SGP: \"SG\",\n SVK: \"SK\",\n SVN: \"SI\",\n SLB: \"SB\",\n SOM: \"SO\",\n ZAF: \"ZA\",\n SGS: \"GS\",\n SSD: \"SS\",\n ESP: \"ES\",\n LKA: \"LK\",\n SDN: \"SD\",\n SUR: \"SR\",\n SJM: \"SJ\",\n SWZ: \"SZ\",\n SWE: \"SE\",\n CHE: \"CH\",\n SYR: \"SY\",\n TWN: \"TW\",\n TJK: \"TJ\",\n TZA: \"TZ\",\n THA: \"TH\",\n TLS: \"TL\",\n TGO: \"TG\",\n TKL: \"TK\",\n TON: \"TO\",\n TTO: \"TT\",\n TUN: \"TN\",\n TUR: \"TR\",\n TKM: \"TM\",\n TCA: \"TC\",\n TUV: \"TV\",\n UGA: \"UG\",\n UKR: \"UA\",\n ARE: \"AE\",\n GBR: \"GB\",\n USA: \"US\",\n UMI: \"UM\",\n URY: \"UY\",\n UZB: \"UZ\",\n VUT: \"VU\",\n VEN: \"VE\",\n VNM: \"VN\",\n VIR: \"VI\",\n WLF: \"WF\",\n ESH: \"EH\",\n YEM: \"YE\",\n ZMB: \"ZM\",\n ZWE: \"ZW\",\n XKX: \"XK\"\n}\n\nexport function getCountryISO2(countryCode: keyof typeof countryISOMapping) {\n return countryISOMapping[countryCode]\n}\n\n```" } ]
code_order-payment_b6a4c1de
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of order-payment/docs/README.md from the order-payment VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# OrderPayment\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n```" } ]
code_order-payment_2c0e1693
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of order-payment/react/OrderPayment.tsx from the order-payment VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { useCallback } from 'react'\nimport { useOrderForm } from 'vtex.order-manager/OrderForm'\nimport { useQueueStatus, useOrderQueue } from 'vtex.order-manager/OrderQueue'\nimport { useMutation } from 'react-apollo'\nimport MutationUpdateOrderFormPayment from 'vtex.checkout-resources/MutationUpdateOrderFormPayment'\nimport {\n OrderForm as CheckoutOrderForm,\n PaymentDataInput,\n} from '@vtex/checkout-types'\n\nimport {\n createOrderPaymentProvider,\n useOrderPayment,\n} from './components/createOrderPaymentProvider'\nimport { useLogger } from './utils/logger'\n\ninterface UpdateOrderFormPaymentMutation {\n updateOrderFormPayment: CheckoutOrderForm\n}\n\ninterface UpdateOrderFormPaymentMutationVariables {\n paymentData: PaymentDataInput\n}\n\nfunction useUpdateOrderFormPayment() {\n const [updateOrderFormPayment] = useMutation<\n UpdateOrderFormPaymentMutation,\n UpdateOrderFormPaymentMutationVariables\n >(MutationUpdateOrderFormPayment)\n\n return {\n updateOrderFormPayment: useCallback(\n async (paymentData: PaymentDataInput) => {\n const { data } = await updateOrderFormPayment({\n variables: { paymentData },\n })\n\n const newOrderForm = data!.updateOrderFormPayment\n\n return newOrderForm\n },\n [updateOrderFormPayment]\n ),\n }\n}\n\nconst { OrderPaymentProvider } = createOrderPaymentProvider<CheckoutOrderForm>({\n useLogger,\n useOrderQueue,\n useOrderForm,\n useUpdateOrderFormPayment,\n useQueueStatus,\n})\n\nexport { useOrderPayment, OrderPaymentProvider }\nexport default { useOrderPayment, OrderPaymentProvider }\n\n```" } ]
code_order-payment_775f6f55
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of order-payment/react/package.json from the order-payment VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"test\": \"vtex-test-tools test\",\n \"lint\": \"tsc --noEmit && eslint --ext ts,tsx .\"\n },\n \"dependencies\": {\n \"@vtex/css-handles\": \"^1.0.0\",\n \"classnames\": \"^2.2.6\",\n \"react\": \"^16.8.3\",\n \"react-apollo\": \"^3.1.3\",\n \"react-dom\": \"^16.8.3\",\n \"react-intl\": \"^5.23.0\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^4.0.0\",\n \"@vtex/order-manager\": \"^0.5.4-beta.0\",\n \"@types/classnames\": \"^2.2.7\",\n \"@types/jest\": \"^24.0.18\",\n \"@types/node\": \"^12.7.5\",\n \"@types/prop-types\": \"^15.7.0\",\n \"@types/react\": \"^16.9.2\",\n \"@vtex/test-tools\": \"3.0.3\",\n \"apollo-client\": \"^2.5.1\",\n \"react-hooks-testing-library\": \"^0.6.0\",\n \"react-scripts\": \"^4.0.3\",\n \"typescript\": \"3.9.7\",\n \"vtex.checkout-graphql\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.checkout-graphql@0.55.1/public/@types/vtex.checkout-graphql\",\n \"vtex.checkout-resources\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.checkout-resources@0.41.0/public/@types/vtex.checkout-resources\",\n \"vtex.order-manager\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.order-manager@0.9.0/public/@types/vtex.order-manager\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.126.5/public/@types/vtex.render-runtime\"\n },\n \"version\": \"0.9.0\"\n}\n\n```" } ]
code_order-payment_7fec567a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of order-payment/store/interfaces.json from the order-payment VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"base-store-component\": {\n \"component\": \"Example\"\n }\n}\n```" } ]
code_order-payment_24308024
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of order-payment/react/__fixtures__/OrderFormProvider.tsx from the order-payment VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { createOrderFormProvider } from '@vtex/order-manager'\n\nimport { mockOrderForm } from './orderForm'\n\nfunction useToast() {\n return {\n showToast: () => {},\n toastState: {\n isToastVisible: false,\n },\n }\n}\n\nfunction useClearOrderFormMessages() {\n return () =>\n new Promise(resolve => {\n resolve(true)\n })\n}\n\nfunction useGetOrderForm(args: any): any {\n return new Promise(resolve => {\n resolve({\n ...args,\n })\n })\n}\n\nconst { OrderFormProvider } = createOrderFormProvider({\n useToast,\n useClearOrderFormMessages,\n useGetOrderForm,\n defaultOrderForm: mockOrderForm,\n})\n\nexport { OrderFormProvider }\n\n```" } ]
code_order-payment_d2721caa
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of order-payment/react/__fixtures__/orderForm.ts from the order-payment VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport const mockOrderForm = {\n id: '123',\n loggedIn: false,\n paymentData: {\n installmentOptions: [\n {\n value: 100,\n paymentSystem: '1',\n installments: [],\n },\n ],\n isValid: true,\n payments: [],\n paymentSystems: [],\n availableAccounts: [],\n },\n items: [\n {\n additionalInfo: {\n brandName: 'Test Brand 0',\n },\n id: '1',\n uniqueId: '1',\n detailUrl: '/work-shirt/p',\n imageUrls: {\n at1x:\n 'http://storecomponents.vteximg.com.br/arquivos/ids/155476-55-55/Frame-4.jpg?v=636793808441900000',\n at2x:\n 'http://storecomponents.vteximg.com.br/arquivos/ids/155476-55-55/Frame-4.jpg?v=636793808441900000',\n at3x:\n 'http://storecomponents.vteximg.com.br/arquivos/ids/155476-55-55/Frame-4.jpg?v=636793808441900000',\n },\n listPrice: 2800000,\n measurementUnit: 'un',\n name: 'قميص العمل الأعلى',\n price: 2400000,\n productId: '1',\n quantity: 3,\n sellingPrice: 2400000,\n skuName: 'Test SKU 0',\n skuSpecifications: [],\n attachmentOfferings: [],\n bundleItems: [],\n\n attachments: [],\n offerings: [],\n priceTags: [],\n },\n {\n additionalInfo: {\n brandName: 'Test Brand 1',\n },\n id: '30',\n uniqueId: '30',\n detailUrl: '/long-sleeve-shirt/p',\n imageUrls: {\n at1x:\n 'http://storecomponents.vteximg.com.br/arquivos/ids/155487-55-55/Frame-7.jpg?v=636793837686400000',\n at2x:\n 'http://storecomponents.vteximg.com.br/arquivos/ids/155487-55-55/Frame-7.jpg?v=636793837686400000',\n at3x:\n 'http://storecomponents.vteximg.com.br/arquivos/ids/155487-55-55/Frame-7.jpg?v=636793837686400000',\n },\n listPrice: 945000,\n measurementUnit: 'un',\n name: '上品なサングラス',\n price: 945000,\n productId: '2000005',\n quantity: 1,\n sellingPrice: 945000,\n skuName: 'Test SKU 1',\n skuSpecifications: [],\n attachmentOfferings: [],\n bundleItems: [],\n isGift: false,\n attachments: [],\n offerings: [],\n priceTags: [],\n },\n {\n additionalInfo: {\n brandName: 'Test Brand 2',\n },\n id: '2000535',\n uniqueId: '2000535',\n detailUrl: '/classy--sunglasses/p',\n imageUrls: {\n at1x:\n 'http://storecomponents.vteximg.com.br/arquivos/ids/155469-55-55/Frame-8.jpg?v=636793757498800000',\n at2x:\n 'http://storecomponents.vteximg.com.br/arquivos/ids/155469-55-55/Frame-8.jpg?v=636793757498800000',\n at3x:\n 'http://storecomponents.vteximg.com.br/arquivos/ids/155469-55-55/Frame-8.jpg?v=636793757498800000',\n },\n listPrice: 400000,\n measurementUnit: 'un',\n name: 'กางเกงขาสั้น St Tropez',\n price: 360000,\n productId: '13',\n quantity: 4,\n sellingPrice: 360000,\n skuName: 'Test SKU 2',\n skuSpecifications: [],\n attachmentOfferings: [],\n bundleItems: [],\n isGift: false,\n attachments: [],\n offerings: [],\n priceTags: [],\n },\n ],\n marketingData: {},\n totalizers: [\n {\n id: 'Items',\n name: 'Items Total',\n value: 9585000,\n },\n ],\n shipping: { isValid: true, pickupOptions: [], deliveryOptions: [] },\n messages: {\n couponMessages: [],\n generalMessages: [],\n },\n clientProfileData: {\n email: '***@vt**.**',\n firstName: 'U*e*',\n lastName: 'N*m*',\n isValid: true,\n },\n canEditData: false,\n value: 9585000,\n}\n\n```" } ]
code_order-payment_6f73ddd5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of order-payment/react/typings/storefront.d.ts from the order-payment VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { FunctionComponent } from 'react'\n\ndeclare global {\n type Obj = Record<string, string | never>\n interface StorefrontFunctionComponent<P = Obj> extends FunctionComponent<P> {\n getSchema?(props: P): Obj\n schema?: Obj\n }\n\n interface StorefrontComponent<P = Obj, S = Obj> extends Component<P, S> {\n getSchema?(props: P): Obj\n schema: Obj\n }\n}\n\n```" } ]
code_order-payment_a11ae53d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of order-payment/react/typings/vtex.checkout-resources.d.ts from the order-payment VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.checkout-resources/MutationUpdateOrderFormPayment' {\n export { default } from 'vtex.checkout-resources/react/MutationUpdateOrderFormPayment'\n}\n\n```" } ]
code_order-payment_3158a5c3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of order-payment/react/typings/vtex.order-manager.d.ts from the order-payment VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.order-manager/OrderForm' {\n export * from 'vtex.order-manager/react/OrderForm'\n export { default } from 'vtex.order-manager/react/OrderForm'\n}\n\ndeclare module 'vtex.order-manager/OrderQueue' {\n export * from 'vtex.order-manager/react/OrderQueue'\n export { default } from 'vtex.order-manager/react/OrderQueue'\n}\n\n```" } ]
code_order-payment_6a3b63f5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of order-payment/react/typings/vtex.render-runtime.d.ts from the order-payment VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* Typings for `render-runtime` */\ndeclare module 'vtex.render-runtime' {\n import { Component, ComponentType, ReactElement, ReactType } from 'react'\n\n export interface NavigationOptions {\n page: string\n params?: any\n }\n\n export interface RenderContextProps {\n runtime: {\n navigate: (options: NavigationOptions) => void\n }\n }\n\n interface ExtensionPointProps {\n id: string\n [key: string]: any\n }\n\n export const ExtensionPoint: ComponentType<ExtensionPointProps>\n\n interface ChildBlockProps {\n id: string\n }\n\n type Obj = Record<string, string>\n\n export const ChildBlock: ComponentType<ChildBlockProps>\n export const useChildBlock = function({ id: string }): Obj {}\n\n export const Helmet: ReactElement\n export const Link: ReactType\n export const NoSSR: ReactElement\n export const RenderContextConsumer: ReactElement\n export const canUseDOM: boolean\n export const withRuntimeContext: <TOriginalProps extends Obj>(\n Component: ComponentType<TOriginalProps & RenderContextProps>\n ) => ComponentType<TOriginalProps>\n}\n\n```" } ]
code_order-payment_b48d36a4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of order-payment/react/typings/css.d.ts from the order-payment VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const css: any\n export default css\n}\n\n```" } ]
code_order-payment_4d77c57a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of order-payment/react/typings/graphql.d.ts from the order-payment VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.graphql' {\n import { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\n```" } ]
code_order-payment_5342aff5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of order-payment/react/typings/vtex.styleguide.d.ts from the order-payment VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide' {\n import { ComponentType } from 'react'\n\n export const Input: ComponentType<InputProps>\n\n interface InputProps {\n [key: string]: any\n }\n}\n\n```" } ]
code_order-payment_ea7de194
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of order-payment/react/utils/logger.ts from the order-payment VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport interface LogParams {\n type: 'Error'\n level: 'Critical'\n event: unknown\n workflowType?: 'OrderPayment'\n workflowInstance: string\n}\n\nexport type LogFn = (params: LogParams) => void\n\nexport type UseLogger = () => { log: LogFn }\n\nexport function useLogger() {\n const log = ({\n type,\n level,\n event,\n workflowType,\n workflowInstance,\n }: LogParams) => {\n // eslint-disable-next-line no-console\n console.log({\n type,\n level,\n event,\n workflowInstance,\n workflowType: workflowType || 'OrderPayment',\n })\n }\n\n return { log }\n}\n\n```" } ]
code_order-payment_af654a73
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of order-payment/react/components/createOrderPaymentProvider.tsx from the order-payment VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, {\n FC,\n useContext,\n useCallback,\n createContext,\n useState,\n useMemo,\n} from 'react'\nimport { OrderQueueContext, OrderForm } from '@vtex/order-manager'\nimport {\n OrderForm as CheckoutOrderForm,\n PaymentDataInput,\n PaymentSystem,\n InstallmentOption,\n AvailableAccount,\n Payment,\n PaymentInput,\n Totalizer,\n} from '@vtex/checkout-types'\n\nimport { UseLogger } from '../utils/logger'\n\nexport const QueueStatus = {\n PENDING: 'Pending',\n FULFILLED: 'Fulfilled',\n} as const\n\ntype ListenFunction = (event: any, callback: () => void) => () => void\ninterface QueueContext {\n enqueue: (task: () => Promise<CheckoutOrderForm>, id?: string) => any\n listen: ListenFunction\n isWaiting: (id: string) => boolean\n}\n\ninterface OrderContext<O extends CheckoutOrderForm> {\n loading: boolean\n setOrderForm: (nextValue: Partial<CheckoutOrderForm>) => void\n error: any | undefined\n orderForm: O\n}\n\ntype UseUpdateOrderFormPayment = () => {\n updateOrderFormPayment: (\n paymentData: PaymentDataInput,\n orderFormId?: string\n ) => Promise<CheckoutOrderForm>\n}\n\ninterface CreateOrderPaymentProvider<O extends CheckoutOrderForm> {\n useLogger: UseLogger\n useOrderQueue: () => QueueContext\n useOrderForm: () => OrderContext<O>\n useUpdateOrderFormPayment: UseUpdateOrderFormPayment\n useQueueStatus: (listen: OrderQueueContext<OrderForm>['listen']) => any\n}\n\ninterface PaymentContext {\n setPaymentField: (\n paymentField: Partial<PaymentInput>\n ) => Promise<{ success: boolean }>\n paymentSystems: PaymentSystem[]\n availableAccounts: AvailableAccount[]\n installmentOptions: InstallmentOption[]\n payment: Payment\n referenceValue: number\n value: number\n interestValue: number\n cardLastDigits: string\n setCardLastDigits: (cardDigits: string) => void\n paymentsValid: boolean\n setCardFormFilled: (filled: boolean) => void\n isFreePurchase: boolean\n}\n\nconst SET_PAYMENT_TASK = 'SetPaymentTask'\nconst OrderPaymentContext = createContext<PaymentContext | undefined>(undefined)\n\nexport function createOrderPaymentProvider<T extends CheckoutOrderForm>({\n useLogger,\n useOrderQueue,\n useOrderForm,\n useUpdateOrderFormPayment,\n useQueueStatus,\n}: CreateOrderPaymentProvider<T>) {\n const OrderPaymentProvider: FC = ({ children }) => {\n const { enqueue, listen } = useOrderQueue()\n const { orderForm, setOrderForm } = useOrderForm()\n const [cardLastDigits, setCardLastDigits] = useState('')\n const [cardFormFilled, setCardFormFilled] = useState(false)\n const queueStatusRef = useQueueStatus(listen)\n const { updateOrderFormPayment } = useUpdateOrderFormPayment()\n const { log } = useLogger()\n\n const {\n id,\n totalizers,\n paymentData: {\n paymentSystems,\n availableAccounts,\n installmentOptions,\n payments,\n },\n } = orderForm\n\n const referenceValue =\n totalizers?.reduce((total: number, totalizer: Totalizer) => {\n if (totalizer?.id === 'Tax' || totalizer?.id === 'interest') {\n return total\n }\n\n return total + (totalizer?.value ?? 0)\n }, 0) ?? 0\n\n const value =\n payments?.reduce(\n (total: number, payment: Payment) => total + (payment?.value ?? 0),\n 0\n ) ?? 0\n\n const interestValue =\n payments?.reduce(\n (total: number, payment: Payment) =>\n total + ((payment?.value ?? 0) - (payment?.referenceValue ?? 0)),\n 0\n ) ?? 0\n\n const payment = payments?.[0] ?? {}\n\n const isFreePurchase = !referenceValue && orderForm.items.length > 0\n\n const paymentsValid = useMemo(() => {\n if (isFreePurchase) {\n return true\n }\n\n if (!payments?.length) {\n return false\n }\n\n if (\n payments\n .map((p: Payment) => p.paymentSystem)\n .map((paymentSystem?: string | null) =>\n paymentSystems.find((ps: PaymentSystem) => ps.id === paymentSystem)\n )\n .some(\n (paymentSystem?: PaymentSystem) =>\n paymentSystem?.groupName === 'creditCardPaymentGroup'\n )\n ) {\n return (\n cardFormFilled &&\n payments.every((p: Payment) => p.installments != null)\n )\n }\n\n return true\n }, [cardFormFilled, isFreePurchase, paymentSystems, payments])\n\n const setOrderPayment = useCallback(\n async (paymentData: PaymentDataInput) => {\n try {\n const task = async () => {\n const newOrderForm = await updateOrderFormPayment(paymentData, id)\n\n return newOrderForm\n }\n\n const newOrderForm = await enqueue(task, SET_PAYMENT_TASK)\n\n if (queueStatusRef.current === QueueStatus.FULFILLED) {\n setOrderForm(newOrderForm)\n }\n\n return { success: true }\n } catch (err) {\n if (!err || err.code !== 'TASK_CANCELLED') {\n throw err\n }\n\n return { success: false }\n }\n },\n [enqueue, queueStatusRef, setOrderForm, updateOrderFormPayment, id]\n )\n\n const setPaymentField = useCallback(\n async (paymentField: Partial<PaymentInput>) => {\n const newPayment = {\n ...payment,\n ...paymentField,\n }\n\n const paymentStatusUpdated = await setOrderPayment({\n payments: [newPayment],\n })\n\n if (!paymentStatusUpdated.success) {\n log({\n type: 'Error',\n level: 'Critical',\n event: {\n paymentField,\n success: paymentStatusUpdated.success,\n orderFormId: id,\n },\n workflowInstance: 'payment-field-not-updated',\n })\n }\n\n return paymentStatusUpdated\n },\n [payment, setOrderPayment, log, id]\n )\n\n const contextValue = useMemo(\n () => ({\n setPaymentField,\n paymentSystems,\n installmentOptions,\n availableAccounts,\n payment,\n value,\n interestValue,\n referenceValue,\n cardLastDigits,\n setCardLastDigits,\n paymentsValid,\n setCardFormFilled,\n isFreePurchase,\n }),\n [\n setPaymentField,\n paymentSystems,\n installmentOptions,\n availableAccounts,\n payment,\n value,\n interestValue,\n referenceValue,\n cardLastDigits,\n paymentsValid,\n isFreePurchase,\n ]\n )\n\n return (\n <OrderPaymentContext.Provider value={contextValue}>\n {children}\n </OrderPaymentContext.Provider>\n )\n }\n\n return { OrderPaymentProvider }\n}\n\nexport const useOrderPayment = () => {\n const context = useContext(OrderPaymentContext)\n\n if (context === undefined) {\n throw new Error(\n 'useOrderPayment must be used within a OrderPaymentProvider'\n )\n }\n\n return context\n}\n\n```" } ]
code_order-payment_41b19ed3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of order-payment/react/__tests__/createOrderPaymentProvider.test.tsx from the order-payment VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport { renderHook, act } from '@testing-library/react-hooks'\nimport {\n useOrderForm,\n useOrderQueue,\n useQueueStatus,\n OrderQueueProvider,\n} from '@vtex/order-manager'\n\nimport { mockOrderForm } from '../__fixtures__/orderForm'\nimport { OrderFormProvider } from '../__fixtures__/OrderFormProvider'\nimport {\n createOrderPaymentProvider,\n useOrderPayment,\n} from '../components/createOrderPaymentProvider'\nimport { LogParams } from '../utils/logger'\n\nconst mockCashPayment = {\n payments: [\n {\n paymentSystem: '201',\n bin: null,\n accountId: null,\n tokenId: null,\n installments: 1,\n referenceValue: 230500,\n value: 230500,\n\n installmentsInterestRate: 0,\n },\n ],\n}\n\nconst mockLog = jest.fn()\n\nfunction useLogger() {\n const log = ({\n type,\n level,\n event,\n workflowType,\n workflowInstance,\n }: LogParams) => {\n mockLog({\n type,\n level,\n event,\n workflowType,\n workflowInstance,\n })\n }\n\n return { log }\n}\n\nconst mockUseUpdateOrderFormPayment = jest.fn().mockResolvedValue(true)\nconst createWrapperOrderProviders = () => {\n function useUpdateOrderFormPayment() {\n return {\n updateOrderFormPayment: mockUseUpdateOrderFormPayment,\n }\n }\n\n const { OrderPaymentProvider } = createOrderPaymentProvider({\n useLogger,\n useOrderQueue,\n useOrderForm,\n useUpdateOrderFormPayment,\n useQueueStatus,\n })\n\n const Wrapper: FC = ({ children }) => {\n return (\n <OrderQueueProvider>\n <OrderFormProvider>\n <OrderPaymentProvider>{children}</OrderPaymentProvider>\n </OrderFormProvider>\n </OrderQueueProvider>\n )\n }\n\n return { Wrapper }\n}\n\ndescribe('OrderPayment', () => {\n it('should throw an error if theres no OrderPaymentProvider on the tree', () => {\n const {\n result: { error },\n } = renderHook(() => useOrderPayment())\n\n expect(error).not.toBeNull()\n expect(error.message).toEqual(\n 'useOrderPayment must be used within a OrderPaymentProvider'\n )\n expect(mockUseUpdateOrderFormPayment).not.toHaveBeenCalled()\n })\n\n it('should get payment data from the current orderForm', () => {\n const { Wrapper } = createWrapperOrderProviders()\n\n const { result } = renderHook(() => useOrderPayment(), { wrapper: Wrapper })\n const { current } = result\n\n expect(current).not.toBeNull()\n expect(current.referenceValue).toEqual(mockOrderForm.value)\n expect(mockUseUpdateOrderFormPayment).not.toHaveBeenCalled()\n })\n\n it('should call function to update orderForm on the server if the payment data is updated', async () => {\n const { Wrapper } = createWrapperOrderProviders()\n\n const { result } = renderHook(() => useOrderPayment(), { wrapper: Wrapper })\n const { current } = result\n\n await act(async () => {\n const { success } = await current.setPaymentField(\n mockCashPayment.payments[0]\n )\n\n expect(success).toBeTruthy()\n })\n expect(mockUseUpdateOrderFormPayment).toHaveBeenCalled()\n })\n\n it('should log information when a payment cannot be updated', async () => {\n const { Wrapper } = createWrapperOrderProviders()\n\n const { result } = renderHook(() => useOrderPayment(), { wrapper: Wrapper })\n const { current } = result\n\n mockUseUpdateOrderFormPayment.mockRejectedValue({ code: 'TASK_CANCELLED' })\n\n await act(async () => {\n const { success } = await current.setPaymentField(\n mockCashPayment.payments[0]\n )\n\n expect(success).toBeFalsy()\n })\n expect(mockLog).toHaveBeenCalled()\n expect(mockUseUpdateOrderFormPayment).toHaveBeenCalled()\n })\n})\n\n```" } ]
code_store-header_6005fb59
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/messages/th-TH.json from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.header.title\": \"ส่วนหัวของหน้า\",\n \"admin/editor.header.description\": \"คอมโพเนนต์ของส่วนหัวของหน้า\",\n \"admin/editor.header.logo.title\": \"โลโก้\",\n \"admin/editor.header.logo.image\": \"รูปภาพโลโก้\",\n \"admin/editor.header.link.url\": \"ลิงก์โลโก้\",\n \"admin/editor.header.show.searchbar.title\": \"แสดงแถบค้นหา\",\n \"admin/editor.header.show.login.title\": \"แสดงการเข้าสู่ระบบ\",\n \"store/header.search-placeholder\": \"ค้นหาผลิตถัณฑ์ แบรนด์...\",\n \"store/header.search-emptyPlaceholder\": \"ไม่พบข้อมูลที่ตรงกัน\",\n \"store/header.topMenu.minicart.icon.label\": \"รถเข็นของฉัน\",\n \"store/header.topMenu.login.icon.label\": \"ลงชื่อเข้าใช้\",\n \"store/header.search-cancel\": \"ยกเลิก\"\n}\n\n```" } ]
code_store-header_915932d2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/messages/ja.json from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.header.title\": \"ヘッダー\",\n \"admin/editor.header.description\": \"ヘッダーコンポーネント\",\n \"admin/editor.header.logo.title\": \"ロゴ\",\n \"admin/editor.header.logo.image\": \"ロゴ画像\",\n \"admin/editor.header.link.url\": \"ロゴリンク\",\n \"admin/editor.header.show.searchbar.title\": \"検索バーを表示\",\n \"admin/editor.header.show.login.title\": \"ログインを表示\",\n \"store/header.search-placeholder\": \"製品やブランドを検索…\",\n \"store/header.search-emptyPlaceholder\": \"一致しませんでした\",\n \"store/header.topMenu.minicart.icon.label\": \"マイカート\",\n \"store/header.topMenu.login.icon.label\": \"サインイン\",\n \"store/header.search-cancel\": \"キャンセル\"\n}\n```" } ]
code_store-header_574c0826
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/messages/fi.json from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.header.title\": \"Ylätunniste\",\n \"admin/editor.header.description\": \"Otsikkokomponentti\",\n \"admin/editor.header.logo.title\": \"Logo\",\n \"admin/editor.header.logo.image\": \"Logo-kuva\",\n \"admin/editor.header.link.url\": \"Logo-linkki\",\n \"admin/editor.header.show.searchbar.title\": \"Näytä hakurivi\",\n \"admin/editor.header.show.login.title\": \"Näytä kirjautuminen\",\n \"store/header.search-placeholder\": \"Hae tuotteita, brändejä...\",\n \"store/header.search-emptyPlaceholder\": \"Tuloksia ei löytynyt\",\n \"store/header.topMenu.minicart.icon.label\": \"Oma ostoskori\",\n \"store/header.topMenu.login.icon.label\": \"Kirjaudu sisään\",\n \"store/header.search-cancel\": \"Peruuta\"\n}\n```" } ]
code_store-header_9a31a956
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/messages/id-ID.json from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.header.title\": \"Header\",\n \"admin/editor.header.description\": \"Komponen header\",\n \"admin/editor.header.logo.title\": \"Logo\",\n \"admin/editor.header.logo.image\": \"Gambar logo\",\n \"admin/editor.header.link.url\": \"Tautan logo\",\n \"admin/editor.header.show.searchbar.title\": \"Tampilkan Bilah Pencarian\",\n \"admin/editor.header.show.login.title\": \"Tampilkan Log Masuk\",\n \"store/header.search-placeholder\": \"Cari produk, merek...\",\n \"store/header.search-emptyPlaceholder\": \"Tidak ada yang cocok\",\n \"store/header.topMenu.minicart.icon.label\": \"Troli Saya\",\n \"store/header.topMenu.login.icon.label\": \"Masuk\",\n \"store/header.search-cancel\": \"Batalkan\"\n}\n\n```" } ]
code_store-header_240b95fb
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/messages/pt.json from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.header.title\": \"Cabeçalho\",\n \"admin/editor.header.description\": \"Componente de cabeçalho\",\n \"admin/editor.header.logo.title\": \"Logo\",\n \"admin/editor.header.logo.image\": \"Imagem da Logo\",\n \"admin/editor.header.link.url\": \"Link da Logo\",\n \"admin/editor.header.show.searchbar.title\": \"Mostrar Busca\",\n \"admin/editor.header.show.login.title\": \"Mostrar Login\",\n \"store/header.search-placeholder\": \"Busque por produtos, marcas...\",\n \"store/header.search-emptyPlaceholder\": \"Nenhum resultado encontrado\",\n \"store/header.topMenu.minicart.icon.label\": \"Meu Carrinho\",\n \"store/header.topMenu.login.icon.label\": \"Entrar\",\n \"store/header.search-cancel\": \"Cancelar\"\n}\n```" } ]
code_store-header_a9edac25
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/messages/en.json from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.header.title\": \"Header\",\n \"admin/editor.header.description\": \"Header component\",\n \"admin/editor.header.logo.title\": \"Logo\",\n \"admin/editor.header.logo.image\": \"Logo image\",\n \"admin/editor.header.link.url\": \"Logo link\",\n \"admin/editor.header.show.searchbar.title\": \"Show SearchBar\",\n \"admin/editor.header.show.login.title\": \"Show Login\",\n \"store/header.search-placeholder\": \"Search for products, brands...\",\n \"store/header.search-emptyPlaceholder\": \"No matches found\",\n \"store/header.topMenu.minicart.icon.label\": \"My Cart\",\n \"store/header.topMenu.login.icon.label\": \"Sign in\",\n \"store/header.search-cancel\": \"Cancel\"\n}\n```" } ]
code_store-header_5cec3dae
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/messages/ro.json from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.header.title\": \"Antet\",\n \"admin/editor.header.description\": \"Componentă antet\",\n \"admin/editor.header.logo.title\": \"Logo\",\n \"admin/editor.header.logo.image\": \"Imagine logo\",\n \"admin/editor.header.link.url\": \"Link logo\",\n \"admin/editor.header.show.searchbar.title\": \"Arată Bara de căutare\",\n \"admin/editor.header.show.login.title\": \"Arată Autentificarea\",\n \"store/header.search-placeholder\": \"Caută produse, mărci...\",\n \"store/header.search-emptyPlaceholder\": \"Nu s-a găsit niciun rezultat\",\n \"store/header.topMenu.minicart.icon.label\": \"Coșul meu\",\n \"store/header.topMenu.login.icon.label\": \"Autentificare\",\n \"store/header.search-cancel\": \"Anulează\"\n}\n```" } ]
code_store-header_894e3c86
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/messages/context.json from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.header.title\": \"admin/editor.header.title\",\n \"admin/editor.header.description\": \"admin/editor.header.description\",\n \"admin/editor.header.logo.title\": \"admin/editor.header.logo.title\",\n \"admin/editor.header.logo.image\": \"admin/editor.header.logo.image\",\n \"admin/editor.header.link.url\": \"admin/editor.header.link.url\",\n \"admin/editor.header.show.searchbar.title\": \"admin/editor.header.show.searchbar.title\",\n \"admin/editor.header.show.login.title\": \"admin/editor.header.show.login.title\",\n \"store/header.search-placeholder\": \"store/header.search-placeholder\",\n \"store/header.search-emptyPlaceholder\": \"store/header.search-emptyPlaceholder\",\n \"store/header.topMenu.minicart.icon.label\": \"store/header.topMenu.minicart.icon.label\",\n \"store/header.topMenu.login.icon.label\": \"store/header.topMenu.login.icon.label\",\n \"store/header.search-cancel\": \"store/header.search-cancel\"\n}\n```" } ]
code_store-header_b741c208
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/messages/ko.json from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.header.title\": \"헤더\",\n \"admin/editor.header.description\": \"헤더 구성 요소\",\n \"admin/editor.header.logo.title\": \"로고\",\n \"admin/editor.header.logo.image\": \"로고 이미지\",\n \"admin/editor.header.link.url\": \"로고 링크\",\n \"admin/editor.header.show.searchbar.title\": \"검색창 표시\",\n \"admin/editor.header.show.login.title\": \"로그인 표시\",\n \"store/header.search-placeholder\": \"제품, 브랜드 검색...\",\n \"store/header.search-emptyPlaceholder\": \"일치하는 항목을 찾을 수 없음\",\n \"store/header.topMenu.minicart.icon.label\": \"내 장바구니\",\n \"store/header.topMenu.login.icon.label\": \"로그인\",\n \"store/header.search-cancel\": \"취소\"\n}\n```" } ]
code_store-header_907b5d5e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/messages/no.json from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.header.title\": \"Overskrift\",\n \"admin/editor.header.description\": \"Del av overskrift\",\n \"admin/editor.header.logo.title\": \"Logo\",\n \"admin/editor.header.logo.image\": \"Bilde av logo\",\n \"admin/editor.header.link.url\": \"Lenke til logo\",\n \"admin/editor.header.show.searchbar.title\": \"Vis søkefelt\",\n \"admin/editor.header.show.login.title\": \"Vis innlogging\",\n \"store/header.search-placeholder\": \"Søk etter produkter, merkevarer...\",\n \"store/header.search-emptyPlaceholder\": \"Ingen treff\",\n \"store/header.topMenu.minicart.icon.label\": \"Min handlekurv\",\n \"store/header.topMenu.login.icon.label\": \"Logg inn\",\n \"store/header.search-cancel\": \"Avbryt\"\n}\n```" } ]
code_store-header_91c1a641
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/messages/da.json from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.header.title\": \"Overskrift\",\n \"admin/editor.header.description\": \"Overskrift komponent\",\n \"admin/editor.header.logo.title\": \"Logo\",\n \"admin/editor.header.logo.image\": \"Logobillede\",\n \"admin/editor.header.link.url\": \"Logolink\",\n \"admin/editor.header.show.searchbar.title\": \"Vis søgebar\",\n \"admin/editor.header.show.login.title\": \"Vis login\",\n \"store/header.search-placeholder\": \"Søg efter produkter, brands...\",\n \"store/header.search-emptyPlaceholder\": \"Ingen matches fundet\",\n \"store/header.topMenu.minicart.icon.label\": \"Min kurv\",\n \"store/header.topMenu.login.icon.label\": \"Log ind\",\n \"store/header.search-cancel\": \"Annuller\"\n}\n```" } ]
code_store-header_b593cd91
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/messages/nn.json from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.header.title\": \"Overskrift\",\n \"admin/editor.header.description\": \"Del av overskrift\",\n \"admin/editor.header.logo.title\": \"Logo\",\n \"admin/editor.header.logo.image\": \"Bilde av logo\",\n \"admin/editor.header.link.url\": \"Lenke til logo\",\n \"admin/editor.header.show.searchbar.title\": \"Vis søkefelt\",\n \"admin/editor.header.show.login.title\": \"Vis innlogging\",\n \"store/header.search-placeholder\": \"Søk etter produkter, merkevarer...\",\n \"store/header.search-emptyPlaceholder\": \"Ingen treff\",\n \"store/header.topMenu.minicart.icon.label\": \"Min handlekurv\",\n \"store/header.topMenu.login.icon.label\": \"Logg inn\",\n \"store/header.search-cancel\": \"Avbryt\"\n}\n```" } ]
code_store-header_c1a86f94
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/messages/es.json from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.header.title\": \"Cabecera\",\n \"admin/editor.header.description\": \"Componente de cabecera\",\n \"admin/editor.header.logo.title\": \"Logotipo\",\n \"admin/editor.header.logo.image\": \"Imagen del logotipo\",\n \"admin/editor.header.link.url\": \"Link del logotipo\",\n \"admin/editor.header.show.searchbar.title\": \"Mostrar Busca\",\n \"admin/editor.header.show.login.title\": \"Mostrar Login\",\n \"store/header.search-placeholder\": \"Búsqueda por productos, marcas...\",\n \"store/header.search-emptyPlaceholder\": \"Ningún resultado encontrado\",\n \"store/header.topMenu.minicart.icon.label\": \"Mi Cesta\",\n \"store/header.topMenu.login.icon.label\": \"Entrar\",\n \"store/header.search-cancel\": \"Cancelar\"\n}\n```" } ]
code_store-header_8951185b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/messages/ar.json from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.header.title\": \"الترويسة\",\n \"admin/editor.header.description\": \"مكون الترويسة\",\n \"admin/editor.header.logo.title\": \"الشعار\",\n \"admin/editor.header.logo.image\": \"صورة الشعار\",\n \"admin/editor.header.link.url\": \"رابط الشعار\",\n \"admin/editor.header.show.searchbar.title\": \"عرض شريط البحث\",\n \"admin/editor.header.show.login.title\": \"عرض تسجيل الدخول\",\n \"store/header.search-placeholder\": \"بحث عن المنتجات، العلامات...\",\n \"store/header.search-emptyPlaceholder\": \"لم يتم العثور على أي تطابق\",\n \"store/header.topMenu.minicart.icon.label\": \"عربتي\",\n \"store/header.topMenu.login.icon.label\": \"تسجيل الدخول\",\n \"store/header.search-cancel\": \"إلغاء\"\n}\n```" } ]
code_store-header_f33c7156
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/docs/README.md from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/vtex-apps/store-header) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n<!-- ALL-CONTRIBUTORS-BADGE:START - Don't remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\n# Header\n\n[<i class=\"fa-brands fa-github\"></i> Source code](https://github.com/vtex-apps/store-header)\n\nThe Header app displays a navigation bar at the top of your store pages. It serves as the central hub for essential navigation elements, such as your store [logo](https://developers.vtex.com/docs/apps/vtex.store-components/logo), the [minicart](https://developers.vtex.com/docs/apps/vtex.minicart), user [login](https://developers.vtex.com/docs/apps/vtex.login), and the [search bar](https://developers.vtex.com/docs/apps/vtex.store-components/searchbar).\n\n![header](https://user-images.githubusercontent.com/52087100/74090325-b6235d00-4a88-11ea-8227-317f93204d8f.png) \n\n## Installation\n\n1. Add the `store-header` app to your theme's dependencies in the `manifest.json` file: \n\n```json\n dependencies: {\n \"vtex.store-header\": \"2.x\"\n }\n```\n\nYou can now use all the blocks exported by the `store-header` app. The following table lists the available blocks:\n\n| Block name | Description | \n| -------- | ------------ | \n| `header-layout.desktop` | ![https://img.shields.io/badge/-Mandatory-red](https://img.shields.io/badge/-Mandatory-red) Defines the Header layout for desktop devices through `header-row` blocks. | \n| `header-layout.mobile`| Defines the Header layout for mobile devices through `header-row` blocks. |\n| `header-row` | ![https://img.shields.io/badge/-Mandatory-red](https://img.shields.io/badge/-Mandatory-red) Create Header lines according to your store needs. | \n| `header-border` | Adds a `1px` margin to a Header row. | \n| `header-force-center` | Centralizes its children blocks in a Header row. | \n| `header-spacer` | Adds spacing between blocks throughout a Header row. | \n\n## Configuration\n\n1. Declare the `header-layout.desktop` and `header-layout.mobile` blocks in your `header.jsonc` file. This allows you to define different header structures for desktop and mobile devices.\n\n```json\n{\n \"header\": {\n \"blocks\": [\n \"header-layout.desktop\",\n \"header-layout.mobile\"\n ]\n },\n```\n\n>ℹ️ The Header is a default store interface element defined in the `interfaces.json` file, so you don't need to declare it in every template. Store Framework automatically applies your configuration across all store pages. To customize the header for specific pages, see the [Advanced configuration](#advanced-configuration) section.\n\n2. In your `header.jsonc` file, define `header-row` blocks inside `header-layout.desktop` and `header-layout.mobile`. The number of rows depends on your store design.\n\n```json\n{\n \"header\": {\n \"blocks\": [\n \"header-layout.desktop\",\n \"header-layout.mobile\"\n ]\n },\n \"header-layout.desktop\": {\n \"children\": [\n \"header-row#1-desktop\",\n \"header-row#2-desktop\",\n \"header-row#3-desktop\",\n \"header-row#4-desktop\"\n ]\n },\n```\n\n>⚠️ The example above uses four rows for the desktop header. This setup allows replicating the header to include telemarketing functionalities (when activated), notifications, page links, and other blocks, such as a logo and menu.\n\n3. Configure each `header-row` by adding props and declaring the desired blocks as children. The most commonly used blocks are [Logo](https://developers.vtex.com/docs/apps/vtex.store-components/logo), [Minicart](https://developers.vtex.com/docs/apps/vtex.minicart), and [Menu](https://developers.vtex.com/docs/apps/vtex.menu).\n\nIn the example below, we'll add a [Telemarketing](https://developers.vtex.com/docs/apps/vtex.telemarketing) bar to the first row:\n\n```json\n\"header-row#1-desktop\": {\n \"children\": [\n \"telemarketing\"\n ],\n \"props\": {\n \"fullWidth\": true\n }\n},\n```\n\n- `header-row` props: \n\n| Prop name | Type | Description | Default value |\n| ---------- | --------- | ------------------------------------------------------------------------------------ | ------------- |\n| `zIndex` | `Number` | Controls the vertical stacking order of elements for overlapping. | `0` |\n| `sticky` | `Boolean` | Determines if the header row remains fixed at the top of the screen during scroll (true) or not (false). | `false` |\n| `fullWidth` | `Boolean` | Determines if the header row should span the full width of the screen. | `true` |\n| `inverted` | `Boolean` | If true, the row uses the inverted base color defined in styles.json. | `false` |\n\n⚠️ Repeat this process for all `header-row` blocks in both `header-layout.desktop` and `header-layout.mobile`, configuring each block with the necessary props.\n\n### Layout customization blocks\n\nYou can use the `header-border`, `header-force-center`, and `header-spacer` blocks as children of `header-row` to customize your header layout.\n\n- **`header-border`**\n\nAdds a `1px` margin to a header row.\n\n```json\n\"header-row#2-desktop\": {\n \"children\": [\n \"header-border\",\n \"notification.bar#home\"\n ],\n \"props\": {\n \"fullWidth\": \"true\"\n }\n},\n\"notification.bar#home\": {\n \"props\": {\n \"content\": \"SELECTED ITEMS ON SALE! CHECK IT OUT!\"\n }\n},\n```\n\n- **`header-force-center`**\n\nCentralizes its child blocks within a header row.\n\n```json\n\"header-row#4-desktop\": {\n \"props\": {\n \"blockClass\": \"main-header\",\n \"horizontalAlign\": \"center\",\n \"verticalAlign\": \"center\",\n \"preventHorizontalStretch\": true,\n \"preventVerticalStretch\": true,\n \"fullWidth\": true\n },\n \"children\": [\"header-force-center\"]\n}, \n\"header-force-center\": {\n \"children\":[\n \"logo#desktop\"\n ]\n},\n\"logo#desktop\": {\n \"props\": {\n \"title\": \"Logo\",\n \"href\": \"/\",\n \"url\": \"https://storecomponents.vteximg.com.br/arquivos/store-theme-logo.png\",\n \"width\": \"180\"\n }\n},\n```\n\n- **`header-spacer`**: \n\nAdds a flexible space between blocks in a header row. Blocks declared before `header-spacer` are pushed to the left, and blocks declared after are pushed to the right.\n\n```json\n\"header-row#3-desktop\": {\n \"children\": [\n \"vtex.menu@2.x:menu#websites\",\n \"header-spacer\",\n \"vtex.menu@2.x:menu#institutional\"\n ],\n \"props\": {\n \"blockClass\": \"menu-link\",\n \"inverted\": \"true\"\n }\n},\n```\n\n### Advanced configuration\n\nBy default, the header configuration is applied to all store templates. To override this behavior and apply custom configurations to different templates, you can modify the `interfaces.json` file.\n\nFor detailed instructions, see the guide [Customizing the Header and Footer blocks by page](https://developers.vtex.com/docs/guides/vtex-io-documentation-customizing-the-header-and-footer-blocks-by-page).\n\n## Customization\n\nTo apply CSS customizations to these and other blocks, follow the instructions in [Using CSS Handles for store customization](https://developers.vtex.com/docs/guides/vtex-io-documentation-using-css-handles-for-store-customization).\n\n| CSS Handles | \n|----------------------|\n| `container` | \n| `leanMode` | \n| `topMenuContainer` | \n| `topMenuLogo` | \n| `topMenuSearchBar` | \n| `topMenuIcons` | \n| `topMenuCollapsible` | \n| `forceCenter` | \n| `forceCenterInnerContainer` | \n| `headerBorder` | \n| `headerSpacer` | \n| `headerStickyRow` | \n| `headerRowContentContainer` |\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n```" } ]
code_store-header_dd79f989
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/react/index.tsx from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { PropsWithChildren } from 'react'\nimport React, { Suspense } from 'react'\nimport { useChildBlock, NoSSR } from 'vtex.render-runtime'\n\nimport CustomHeader from './components/CustomHeader'\n\nconst LegacyHeader = React.lazy(() => import('./legacy'))\n\nfunction Header(props: PropsWithChildren<unknown>) {\n const hasHeaderDesktop = !!useChildBlock({\n id: 'header-layout.desktop',\n })\n\n const hasUnstableHeaderDesktop = !!useChildBlock({\n id: 'unstable--header-layout.desktop',\n })\n\n const hasHeaderMobile = !!useChildBlock({\n id: 'header-layout.mobile',\n })\n\n const hasUnstableHeaderMobile = !!useChildBlock({\n id: 'unstable--header-layout.mobile',\n })\n\n const hasCustomHeader =\n hasHeaderDesktop ||\n hasHeaderMobile ||\n hasUnstableHeaderDesktop ||\n hasUnstableHeaderMobile\n\n return hasCustomHeader ? (\n <CustomHeader {...props} />\n ) : (\n <NoSSR>\n <Suspense fallback={<div />}>\n <LegacyHeader {...props} />\n </Suspense>\n </NoSSR>\n )\n}\n\n// @ts-expect-error - legacy code\nHeader.schema = LegacyHeader.schema\n\nexport default Header\n\n```" } ]
code_store-header_1d4d3516
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building 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-header/react/Border.tsx from the store-header VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { PropsWithChildren } from 'react'\nimport React from 'react'\nimport type { CssHandlesTypes } from 'vtex.css-handles'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport StickyRow from './components/StickyRow'\n\nconst CSS_HANDLES = ['headerBorder'] as const\n\ninterface Props {\n /**\n * Define if the element behaves in a sticky manner\n * @default false\n * */\n sticky: boolean\n classes?: CssHandlesTypes.CustomClasses<typeof CSS_HANDLES>\n}\n\n/**\n * @deprecated Use 'vtex.sticky-layout' instead\n */\nfunction Border({ sticky, classes }: PropsWithChildren<Props>) {\n const { handles } = useCssHandles(CSS_HANDLES, {\n classes,\n })\n\n return (\n <StickyRow sticky={sticky}>\n <div className={`${handles.headerBorder} bb b--muted-3`} />\n </StickyRow>\n )\n}\n\nexport default Border\n\n```" } ]