, name: string) => {\r\n const selectedIndex = selected.indexOf(name);\r\n let newSelected: string[] = [];\r\n\r\n if (selectedIndex === -1) {\r\n newSelected = newSelected.concat(selected, name);\r\n } else if (selectedIndex === 0) {\r\n newSelected = newSelected.concat(selected.slice(1));\r\n } else if (selectedIndex === selected.length - 1) {\r\n newSelected = newSelected.concat(selected.slice(0, -1));\r\n } else if (selectedIndex > 0) {\r\n newSelected = newSelected.concat(\r\n selected.slice(0, selectedIndex),\r\n selected.slice(selectedIndex + 1)\r\n );\r\n }\r\n\r\n setSelected(newSelected);\r\n };\r\n\r\n const handleChangePage = (event: unknown, newPage: number) => {\r\n setPage(newPage);\r\n };\r\n\r\n const isSelected = (name: string) => selected.indexOf(name) !== -1;\r\n\r\n const emptyRows =\r\n rowsPerPage - Math.min(rowsPerPage, rows.length - page * rowsPerPage);\r\n\r\n const theme = Mui.useTheme();\r\n\r\n return (\r\n \r\n \r\n \r\n {rows.length > 0 && (\r\n \r\n \r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n \r\n Actions\r\n \r\n \r\n \r\n \r\n )}\r\n \r\n
\r\n \r\n \r\n {stableSort(rows as any, getComparator(order, orderBy))\r\n .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)\r\n .map((row, index) => {\r\n const isItemSelected = isSelected(row.setID as string);\r\n const labelId = `enhanced-table-checkbox-${index}`;\r\n\r\n return (\r\n handleClick(event, row.setID as string)}\r\n aria-checked={isItemSelected}\r\n tabIndex={-1}\r\n key={row.setID}\r\n // selected={isItemSelected}\r\n >\r\n \r\n {row.setName}\r\n \r\n \r\n {row.setCode}\r\n \r\n \r\n {row.hundCode}\r\n \r\n \r\n \r\n \r\n \r\n \r\n {false && (\r\n \r\n handleEditClick({\r\n article: (row as unknown) as Models.Set.Article,\r\n })\r\n }\r\n size=\"small\"\r\n style={{\r\n padding: theme.spacing(0.125),\r\n }}\r\n >\r\n \r\n \r\n {/* */}\r\n \r\n \r\n )}\r\n\r\n {false && (\r\n handleDeleteClick({ id: row.setID })}\r\n size=\"small\"\r\n style={{\r\n padding: theme.spacing(0.125),\r\n }}\r\n >\r\n \r\n \r\n {/* */}\r\n \r\n \r\n )}\r\n\r\n {false && (\r\n \r\n handleActivateClick({ id: row.setID })\r\n }\r\n size=\"small\"\r\n style={{\r\n padding: theme.spacing(0.125),\r\n }}\r\n >\r\n \r\n \r\n {/* */}\r\n \r\n \r\n )}\r\n\r\n {false && (\r\n \r\n handleTranslateClick({\r\n article: (row as unknown) as Models.Set.Article,\r\n })\r\n }\r\n size=\"small\"\r\n style={{\r\n padding: theme.spacing(0.125),\r\n }}\r\n >\r\n \r\n {/* */}\r\n \r\n \r\n \r\n )}\r\n\r\n \r\n handleView({\r\n article: (row as unknown) as Models.Set.Article,\r\n })\r\n }\r\n style={{\r\n padding: theme.spacing(0.125),\r\n }}\r\n size=\"small\"\r\n >\r\n \r\n {/* */}\r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n })}\r\n {rows.length === 0 && (\r\n \r\n \r\n \r\n No articles found\r\n \r\n \r\n \r\n )}\r\n {emptyRows > 0 && (\r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n {rows.length > 7 && (\r\n \r\n handleChangePage(event, page - 1)}\r\n shape=\"rounded\"\r\n />\r\n \r\n )}\r\n \r\n
\r\n );\r\n}\r\n\r\nexport const Main = Mobx.observer(function () {\r\n const [validationFailedDialog, setValidationFailedDialog] = React.useState<{\r\n open: boolean;\r\n action: \"ACTIVATE\" | \"DELETE\";\r\n dependentArticles: Models.Set.Article[];\r\n selectedArticles: Models.Set.Article[];\r\n }>({\r\n open: false,\r\n action: \"ACTIVATE\",\r\n dependentArticles: [],\r\n selectedArticles: [],\r\n });\r\n const [currentArticle, setCurrentArticle] = React.useState<\r\n Models.Set.Article\r\n >();\r\n const [detailsDrawerOpen, setDetailsDrawerOpen] = React.useState(\r\n false\r\n );\r\n const [editDialogOpen, setEditDialogOpen] = React.useState<\r\n Models.Set.Article\r\n >();\r\n const [translateDialogOpen, setTranslateDialogOpen] = React.useState<\r\n Models.Set.Article\r\n >();\r\n const [deleteDialogOpen, setDeleteDialogOpen] = React.useState<\r\n number | string\r\n >();\r\n const [activateDialogOpen, setActivateDialogOpen] = React.useState<\r\n number | string\r\n >();\r\n const [isLoading, setIsLoading] = React.useState(false);\r\n const userStore = React.useContext(App.Contexts.userStore);\r\n const articleStore = React.useContext(App.Contexts.articleStore);\r\n const functionStore = React.useContext(App.Contexts.functionStore);\r\n const theme = Mui.useTheme();\r\n const { t } = ReactI18next.useTranslation();\r\n const { enqueueSnackbar } = Notistack.useSnackbar();\r\n\r\n const articleService = new Services.Article({\r\n httpManager: new Services.Managers.Axios({ agent: App.axios }),\r\n urlFactory: new Services.Factories.URL({\r\n protocol: Constants.environment.apiBaseUrlProtocol as \"http\",\r\n hostname: Constants.environment.apiBaseUrlHostname,\r\n version: Constants.environment.apiBaseUrlVersion,\r\n }),\r\n });\r\n\r\n React.useEffect(() => {\r\n articleStore.read();\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, []);\r\n\r\n React.useEffect(() => {\r\n functionStore.read();\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, []);\r\n\r\n function getArticlesDependentOnThis({\r\n setID,\r\n }: {\r\n setID: number;\r\n }): Models.Set.Article[] {\r\n return articleStore.articles\r\n .filter((article) => article.status === 1)\r\n .filter((article) => article.dependentSets.includes(setID));\r\n }\r\n\r\n function getDependentArticlesOfThis({\r\n setID,\r\n }: {\r\n setID: number;\r\n }): Models.Set.Article[] {\r\n const selectedArticle = articleStore.articles.find(\r\n (article) => article.setID === setID\r\n );\r\n\r\n if (!selectedArticle) {\r\n return [];\r\n }\r\n\r\n return articleStore.articles\r\n .filter((article) => article.status === 2)\r\n .filter((article) =>\r\n selectedArticle.dependentSets.includes(article.setID)\r\n );\r\n }\r\n\r\n async function handleDeleteArticle() {\r\n setIsLoading(true);\r\n const uid = userStore.user?.uid;\r\n if (deleteDialogOpen === undefined || uid === undefined) {\r\n return;\r\n }\r\n\r\n try {\r\n await articleService.delete({\r\n articleId: deleteDialogOpen,\r\n uid,\r\n });\r\n enqueueSnackbar(t(\"Article successfully deleted!\"), {\r\n variant: \"success\",\r\n preventDuplicate: false,\r\n });\r\n } catch (error) {\r\n console.error(error);\r\n enqueueSnackbar(t(\"Something went wrong! Please try again later.\"), {\r\n variant: \"warning\",\r\n preventDuplicate: false,\r\n });\r\n } finally {\r\n setIsLoading(false);\r\n setDeleteDialogOpen(undefined);\r\n articleStore.read();\r\n }\r\n }\r\n async function handleActivateArticle() {\r\n setIsLoading(true);\r\n const uid = userStore.user?.uid;\r\n if (activateDialogOpen === undefined || uid === undefined) {\r\n // console.log({ activateDialogOpen, uid });\r\n return;\r\n }\r\n try {\r\n await articleService.activate({\r\n setId: activateDialogOpen,\r\n uid,\r\n });\r\n enqueueSnackbar(t(\"Article successfully activated!\"), {\r\n variant: \"success\",\r\n preventDuplicate: false,\r\n });\r\n } catch (error) {\r\n console.error(error);\r\n enqueueSnackbar(t(\"Something went wrong! Please try again later.\"), {\r\n variant: \"warning\",\r\n preventDuplicate: false,\r\n });\r\n } finally {\r\n setIsLoading(false);\r\n setActivateDialogOpen(undefined);\r\n articleStore.read();\r\n }\r\n }\r\n\r\n const handleSearch = (event: React.ChangeEvent) => {\r\n articleStore.setSearch({ search: event.target.value as string });\r\n };\r\n\r\n const handleChange = (event: React.ChangeEvent<{ value: unknown }>) => {\r\n const status = event.target.value as string | number;\r\n if (typeof status === \"string\" && status !== \"\") {\r\n return;\r\n }\r\n\r\n if (status === \"\") {\r\n articleStore.setStatus({ status: undefined });\r\n return;\r\n }\r\n\r\n articleStore.setStatus({ status });\r\n };\r\n\r\n const toggleDetailsDrawer = () => {\r\n setDetailsDrawerOpen(!detailsDrawerOpen);\r\n };\r\n\r\n return (\r\n <>\r\n {\r\n toggleDetailsDrawer();\r\n setEditDialogOpen(article);\r\n }}\r\n handleTranslateClick={({ article }) => {\r\n toggleDetailsDrawer();\r\n setTranslateDialogOpen(article);\r\n }}\r\n handleDeleteClick={({ id }) => {\r\n toggleDetailsDrawer();\r\n\r\n const articlesDepentOnThis = getArticlesDependentOnThis({\r\n setID: id as number,\r\n });\r\n\r\n const selectedArticle = articleStore.articles.find(\r\n (article) => article.setID === id\r\n );\r\n\r\n if (articlesDepentOnThis.length > 0) {\r\n setValidationFailedDialog({\r\n open: true,\r\n action: \"DELETE\",\r\n dependentArticles: articlesDepentOnThis,\r\n selectedArticles: selectedArticle ? [selectedArticle] : [],\r\n });\r\n return;\r\n }\r\n\r\n setDeleteDialogOpen(id);\r\n }}\r\n handleActivateClick={function ({ id }) {\r\n toggleDetailsDrawer();\r\n\r\n const dependentArticlesOfThis = getDependentArticlesOfThis({\r\n setID: id as number,\r\n });\r\n\r\n const selectedArticle = articleStore.articles.find(\r\n (article) => article.setID === id\r\n );\r\n\r\n if (dependentArticlesOfThis.length > 0) {\r\n setValidationFailedDialog({\r\n open: true,\r\n action: \"ACTIVATE\",\r\n dependentArticles: dependentArticlesOfThis,\r\n selectedArticles: selectedArticle ? [selectedArticle] : [],\r\n });\r\n return;\r\n }\r\n\r\n setActivateDialogOpen(id);\r\n }}\r\n />\r\n {\r\n articleStore.setCreateDialogOpen({ createDialogOpen: false });\r\n // articleStore.read();\r\n }}\r\n />\r\n {\r\n setTranslateDialogOpen(undefined);\r\n // articleStore.read();\r\n }}\r\n />\r\n {\r\n setEditDialogOpen(undefined);\r\n // articleStore.read();\r\n }}\r\n />\r\n \r\n {validationFailedDialog.action === \"DELETE\" && \"Deletion\"}\r\n {validationFailedDialog.action === \"ACTIVATE\" && \"Activation\"}\r\n interrupted!\r\n >\r\n }\r\n handleClose={() => {\r\n setValidationFailedDialog({\r\n action: \"ACTIVATE\",\r\n dependentArticles: [],\r\n open: false,\r\n selectedArticles: [],\r\n });\r\n setDetailsDrawerOpen(true);\r\n }}\r\n contentText={\r\n <>\r\n {(function () {\r\n if (validationFailedDialog.dependentArticles.length === 0) {\r\n return null;\r\n }\r\n\r\n return (\r\n \r\n Can't proceed!\r\n {validationFailedDialog.action === \"DELETE\" && (\r\n <>\r\n Based on the selected license for deletion, we found that\r\n there are other article(s) which depend on it. For a\r\n successful re-attempt, please try deleting all those\r\n article(s) first.\r\n >\r\n )}\r\n {validationFailedDialog.action === \"ACTIVATE\" && (\r\n <>\r\n Based on the selected license for activation, we found\r\n that it is dependent on other article(s). For a successful\r\n re-attempt, please try activating all those article(s)\r\n first.\r\n >\r\n )}\r\n \r\n );\r\n })()}\r\n\r\n \r\n Selected license for{\" \"}\r\n {validationFailedDialog.action === \"DELETE\" && \"deletion\"}\r\n {validationFailedDialog.action === \"ACTIVATE\" && \"activation\"}\r\n \r\n \r\n {validationFailedDialog.selectedArticles.map((set) => (\r\n \r\n \r\n set.functions.includes(func.setFunctionID)\r\n )}\r\n article={set}\r\n variant={\"DETAILED\"}\r\n />\r\n \r\n ))}\r\n \r\n {(function () {\r\n if (validationFailedDialog.dependentArticles.length === 0) {\r\n return null;\r\n }\r\n\r\n return (\r\n <>\r\n \r\n {validationFailedDialog.action === \"ACTIVATE\" && (\r\n <>\r\n Deleted dependent license(s) of your selected license\r\n for activation\r\n >\r\n )}\r\n {validationFailedDialog.action === \"DELETE\" && (\r\n <>\r\n Active license(s) dependent on your selected license for\r\n deletion\r\n >\r\n )}\r\n \r\n \r\n {validationFailedDialog.dependentArticles.map((set) => (\r\n \r\n \r\n set.functions.includes(func.setFunctionID)\r\n )}\r\n article={set}\r\n variant={\"DETAILED\"}\r\n />\r\n \r\n ))}\r\n \r\n >\r\n );\r\n })()}\r\n >\r\n }\r\n actions={\r\n <>\r\n {\r\n setValidationFailedDialog({\r\n action: \"ACTIVATE\",\r\n dependentArticles: [],\r\n open: false,\r\n selectedArticles: [],\r\n });\r\n setDetailsDrawerOpen(true);\r\n }}\r\n >\r\n OK\r\n \r\n >\r\n }\r\n />\r\n setDeleteDialogOpen(undefined)}\r\n title={t(\"Delete article\")}\r\n contentText={t(\"Are you sure you want to delete this article?\")}\r\n actions={\r\n <>\r\n setDeleteDialogOpen(undefined)}\r\n >\r\n Cancel\r\n \r\n handleDeleteArticle()}\r\n disabled={isLoading}\r\n {...(!isLoading && {\r\n style: {\r\n backgroundColor: theme.palette.primary.main,\r\n color: theme.palette.common.white,\r\n },\r\n })}\r\n >\r\n Delete\r\n {isLoading && (\r\n \r\n )}\r\n \r\n >\r\n }\r\n />\r\n setActivateDialogOpen(undefined)}\r\n title={t(\"Activate article\")}\r\n contentText={t(\"Are you sure you want to activate this article?\")}\r\n actions={\r\n <>\r\n setActivateDialogOpen(undefined)}\r\n >\r\n Cancel\r\n \r\n handleActivateArticle()}\r\n disabled={isLoading}\r\n {...(!isLoading && {\r\n style: {\r\n backgroundColor: theme.palette.success.main,\r\n color: theme.palette.common.white,\r\n },\r\n })}\r\n >\r\n \r\n Activate\r\n \r\n {isLoading && (\r\n \r\n )}\r\n \r\n >\r\n }\r\n />\r\n { articleStore.articles.length > 0 &&(\r\n \r\n \r\n \r\n Filter by status\r\n \r\n \r\n \r\n Filter by status\r\n \r\n }\r\n >\r\n \r\n \r\n None\r\n \r\n \r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n { articleStore.articles.length > 0 &&()}\r\n \r\n )}\r\n {articleStore.isInitialLoading ? (\r\n \r\n \r\n \r\n ) : (\r\n <>\r\n {articleStore.view === \"CARD\" && (\r\n {\r\n setCurrentArticle(article);\r\n toggleDetailsDrawer();\r\n }}\r\n articles={articleStore.filtered}\r\n />\r\n )}\r\n {articleStore.view === \"TABULAR\" && (\r\n {\r\n setEditDialogOpen(article);\r\n }}\r\n handleTranslateClick={({ article }) => {\r\n setTranslateDialogOpen(article);\r\n }}\r\n handleDeleteClick={({ id }) => {\r\n setDeleteDialogOpen(id);\r\n }}\r\n handleActivateClick={({ id }) => {\r\n setActivateDialogOpen(id);\r\n }}\r\n handleView={({ article }) => {\r\n setCurrentArticle(article);\r\n toggleDetailsDrawer();\r\n }}\r\n rows={articleStore.filtered}\r\n />\r\n )}\r\n >\r\n )}\r\n >\r\n );\r\n});\r\n","/** @format */\r\n\r\nimport * as Article from \"src/app/pages/article\";\r\nimport * as Yup from \"yup\";\r\nimport * as React from \"react\";\r\nimport * as App from \"src/app\";\r\n\r\nexport declare namespace Shared {\r\n export interface Props {\r\n t(key: string): string;\r\n }\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare\r\nexport function Shared({ t }: Shared.Props) {\r\n const articleStore = React.useContext(App.Contexts.articleStore);\r\n const articleIdFromEdit: any = localStorage.getItem(\"articleIdFromEdit\");\r\n return {\r\n Form: {\r\n validationSchema: Yup.object({\r\n name: Yup.string()\r\n .required(t(\"Article name is required\"))\r\n .test(\"Already exists\", t(\"Article name already exists\"), (value) => {\r\n if (articleIdFromEdit?.length > 0) {\r\n if (\r\n articleStore.articles\r\n .filter((k) => k.setID !== parseInt(articleIdFromEdit))\r\n .map((k: any) => k.setName)\r\n .includes(value)\r\n ) {\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n } else if (\r\n articleStore.articles.map((k: any) => k.setName).includes(value)\r\n ) {\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n }),\r\n code: Yup.string()\r\n .required(t(\"Article code is required\"))\r\n .test(\"Already exists\", t(\"Article code already exists\"), (value) => {\r\n if (articleIdFromEdit?.length > 0) {\r\n if (\r\n articleStore.articles\r\n .filter((k) => k.setID !== parseInt(articleIdFromEdit))\r\n .map((k: any) => k.setCode)\r\n .includes(value)\r\n ) {\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n } else if (\r\n articleStore.articles.map((k: any) => k.setCode).includes(value)\r\n ) {\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n }),\r\n industrySegmentsId: Yup.string()\r\n .nullable()\r\n .required(t(\"Industry / Segment is required\")),\r\n hundCode: Yup.string()\r\n .required(t(\"Model number is required\"))\r\n .test(\"Already exists\", t(\"Model number already exists\"), (value) => {\r\n if (articleIdFromEdit?.length > 0) {\r\n if (\r\n articleStore.articles\r\n .filter((k) => k.setID !== parseInt(articleIdFromEdit))\r\n .map((k: any) => k.hundCode)\r\n .includes(value)\r\n ) {\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n } else if (\r\n articleStore.articles.map((k: any) => k.hundCode).includes(value)\r\n ) {\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n }),\r\n description: Yup.string().required(\r\n t(\"Article description is required\")\r\n ),\r\n \r\n isFree: Yup.bool().notRequired(),\r\n validityPeriodInDays: Yup.number().required(t(\"Validity is required\")),\r\n netPricePerItem: Yup.number().required(t(\"Price is required\")),\r\n licensesPerArticle: Yup.number().required(t(\"Licenses are required\")),\r\n iconClass: Yup.string().nullable().required(t(\"Icon name is required\")),\r\n linkForMoreInfo: Yup.string()\r\n .nullable()\r\n .required(t(\"More info link is required\")),\r\n setID: Yup.array()\r\n .nullable()\r\n .required(t(\"Functions are required\")),\r\n dependentSets: Yup.array(),\r\n }),\r\n },\r\n Translate: {\r\n Form: {\r\n validationSchema: Yup.object({\r\n name_de: Yup.string().required(t(\"Article name in DE is required\")),\r\n name_es: Yup.string().required(t(\"Article name in ES is required\")),\r\n name_fr: Yup.string().required(t(\"Article name in FR is required\")),\r\n name_it: Yup.string().required(t(\"Article name in IT is required\")),\r\n description_de: Yup.string().required(\r\n t(\"Description in DE is required\")\r\n ),\r\n description_es: Yup.string().required(\r\n t(\"Description in ES is required\")\r\n ),\r\n description_fr: Yup.string().required(\r\n t(\"Description in FR is required\")\r\n ),\r\n description_it: Yup.string().required(\r\n t(\"Description in IT is required\")\r\n ),\r\n }),\r\n },\r\n },\r\n };\r\n}\r\n","import * as Mobx from \"mobx\";\r\nimport * as i18n from \"src/app/i18n\";\r\nimport * as Models from \"src/models\";\r\nimport * as Services from \"src/services\";\r\n\r\nexport declare namespace Store {\r\n export type View = \"TABULAR\" | \"CARD\";\r\n\r\n export interface IStore {\r\n isLoading: boolean;\r\n search: string;\r\n status?: number;\r\n view: Store.View;\r\n createDialogOpen: boolean;\r\n articles: Models.Set.Article[];\r\n }\r\n\r\n export type Options = Pick & {\r\n articleService: Services.Article;\r\n };\r\n\r\n export namespace SetView {\r\n export interface Props extends Pick {}\r\n }\r\n\r\n export namespace SetCreateDialogOpen {\r\n export interface Props extends Pick {}\r\n }\r\n\r\n export namespace SetSearch {\r\n export interface Props extends Pick {}\r\n }\r\n\r\n export namespace SetStatus {\r\n export interface Props extends Pick {}\r\n }\r\n\r\n export namespace SetLocale {\r\n export interface Props {\r\n locale: string;\r\n }\r\n }\r\n\r\n export namespace Read {\r\n export interface Props extends Services.Article.GetAllData.Props {}\r\n }\r\n\r\n export namespace GetAllSetData {\r\n export interface Props {\r\n userID?: string | any;\r\n customerDealerId?: string | any;\r\n }\r\n }\r\n\r\n export namespace GetAllPurchanseSetData {\r\n export interface Props {\r\n orderID?: string | any;\r\n }\r\n export type Return = Models.API.Response;\r\n }\r\n\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare\r\nexport class Store implements Store.IStore {\r\n @Mobx.observable private _locale: string = \"en\";\r\n\r\n @Mobx.observable public isLoading: boolean = false;\r\n @Mobx.observable public search: string = \"\";\r\n @Mobx.observable public status?: number = 1;\r\n @Mobx.observable public view: Store.View = \"TABULAR\";\r\n @Mobx.observable public createDialogOpen: boolean = false;\r\n @Mobx.observable public articles: Models.Set.Article[] = [];\r\n\r\n private _translations: Map = new Map();\r\n private _articleService: Services.Article;\r\n\r\n constructor({ view, articleService }: Store.Options) {\r\n this.view = view;\r\n this._articleService = articleService;\r\n i18n.instance.on(\"languageChanged\", (language) =>\r\n this.setLocale({ locale: language })\r\n );\r\n }\r\n\r\n @Mobx.action public reset() {\r\n this.search = \"\";\r\n this.status = 1;\r\n }\r\n\r\n @Mobx.action setLocale({ locale }: Store.SetLocale.Props) {\r\n this._locale = locale.toLowerCase();\r\n\r\n this.articles = this.articles.map((article) => {\r\n const translatedArticle = this._translations.get(\r\n `${article.setID}${this._locale.toLowerCase()}`\r\n );\r\n\r\n return {\r\n ...article,\r\n setName: translatedArticle?.setName ?? article.setName,\r\n setDescriptions:\r\n translatedArticle?.setDescriptions ?? article.setDescriptions,\r\n };\r\n });\r\n }\r\n\r\n @Mobx.action setView({ view }: Store.SetView.Props) {\r\n this.view = view;\r\n }\r\n\r\n @Mobx.action public setSearch({ search }: Store.SetSearch.Props) {\r\n this.search = search;\r\n }\r\n\r\n @Mobx.action public setStatus({ status }: Store.SetStatus.Props) {\r\n this.status = status;\r\n }\r\n\r\n @Mobx.action setCreateDialogOpen({\r\n createDialogOpen,\r\n }: Store.SetCreateDialogOpen.Props) {\r\n this.createDialogOpen = createDialogOpen;\r\n }\r\n\r\n private _prepareTranslations() {\r\n this._translations = this.articles.reduce(\r\n (acc: Map, article: Models.Set.Article) => {\r\n const { setID } = article;\r\n acc.set(`${setID}en`, { ...article });\r\n article.setsLang.map((lang) =>\r\n acc.set(`${setID}${lang.langCode.toLowerCase()}`, {\r\n ...article,\r\n setName: lang.setName,\r\n setDescriptions: lang.setDescriptions,\r\n })\r\n );\r\n return acc;\r\n },\r\n new Map()\r\n );\r\n }\r\n\r\n @Mobx.action public async read(props?: Store.Read.Props) {\r\n try {\r\n this.isLoading = true;\r\n const { result } = await this._articleService.getAllData(props);\r\n\r\n this.articles = result;\r\n this._prepareTranslations();\r\n this.setLocale({ locale: i18n.instance.language });\r\n } catch (error) {\r\n console.error(error);\r\n } finally {\r\n this.isLoading = false;\r\n }\r\n }\r\n\r\n @Mobx.action public async readForCustomerInvite(\r\n props?: Store.GetAllSetData.Props\r\n ) {\r\n try {\r\n this.isLoading = true;\r\n const { result } = await this._articleService.getAllSetForInviteData(\r\n props\r\n );\r\n\r\n this.articles = result;\r\n this._prepareTranslations();\r\n this.setLocale({ locale: i18n.instance.language });\r\n } catch (error) {\r\n console.error(error);\r\n } finally {\r\n this.isLoading = false;\r\n }\r\n }\r\n\r\n @Mobx.action public async readCustomerInvitePurchange(\r\n props?: Store.GetAllPurchanseSetData.Props\r\n ) {\r\n try {\r\n this.isLoading = true;\r\n const { result } =\r\n await this._articleService.getAllPurchangeSetForInviteData(props);\r\n return result;\r\n \r\n }\r\n\r\n catch (error) {\r\n console.error(error);\r\n } finally {\r\n this.isLoading = false;\r\n }\r\n }\r\n\r\n @Mobx.computed public get isInitialLoading(): boolean {\r\n if (this.articles.length !== 0) {\r\n return false;\r\n }\r\n\r\n if (!this.isLoading) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n @Mobx.computed public get filtered() {\r\n return this.articles\r\n .filter((article) => {\r\n if (!this.status) {\r\n return true;\r\n }\r\n return article.status === this.status;\r\n })\r\n .filter((article) => {\r\n if (!this.search) {\r\n return true;\r\n }\r\n return (\r\n (article.setName &&\r\n article.setName\r\n .toLowerCase()\r\n .includes(this.search.toLowerCase())) ||\r\n (article.setCode &&\r\n article.setCode\r\n .toLowerCase()\r\n .includes(this.search.toLowerCase())) ||\r\n (article.hundCode &&\r\n article.hundCode.toLowerCase().includes(this.search.toLowerCase()))\r\n );\r\n });\r\n }\r\n}\r\n","import * as Mui from \"@material-ui/core\";\r\nimport * as Formik from \"formik\";\r\nimport * as Mobx from \"mobx-react-lite\";\r\nimport * as Notistack from \"notistack\";\r\nimport * as React from \"react\";\r\nimport * as ReactI18next from \"react-i18next\";\r\nimport * as App from \"src/app\";\r\nimport * as Components from \"src/app/components\";\r\nimport * as Article from \"src/app/pages/article\";\r\nimport * as Constants from \"src/constants\";\r\nimport * as Models from \"src/models\";\r\nimport * as Services from \"src/services\";\r\n\r\nconst useStyles = Mui.makeStyles((theme) =>\r\n Mui.createStyles({\r\n title: {\r\n flexGrow: 1,\r\n },\r\n })\r\n);\r\n\r\nexport declare namespace Translate {\r\n export type Props = Pick<\r\n Components.ResponsiveFullscreenDialogWithScroll.Props,\r\n \"open\" | \"handleClose\"\r\n > & {\r\n article?: Models.Set.Article;\r\n };\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare\r\nexport const Translate = Mobx.observer(function ({\r\n article,\r\n open,\r\n handleClose,\r\n}: Translate.Props) {\r\n const classes = useStyles();\r\n const { enqueueSnackbar } = Notistack.useSnackbar();\r\n const [initialValues, setInitialValues] = React.useState<\r\n Article.TranslateForm.Values\r\n >();\r\n const [industrySegments, setIndustrySegments] = React.useState<\r\n Models.IndustrySegment.Main[]\r\n >([]);\r\n const { t } = ReactI18next.useTranslation();\r\n const articleStore = React.useContext(App.Contexts.articleStore);\r\n const articleService = new Services.Article({\r\n httpManager: new Services.Managers.Axios({ agent: App.axios }),\r\n urlFactory: new Services.Factories.URL({\r\n protocol: Constants.environment.apiBaseUrlProtocol as \"http\",\r\n hostname: Constants.environment.apiBaseUrlHostname,\r\n version: Constants.environment.apiBaseUrlVersion,\r\n }),\r\n });\r\n const theme = Mui.useTheme();\r\n const userStore = React.useContext(App.Contexts.userStore);\r\n const industrySegmentService = new Services.IndustrySegment({\r\n httpManager: new Services.Managers.Axios({ agent: App.axios }),\r\n urlFactory: new Services.Factories.URL({\r\n protocol: Constants.environment.apiBaseUrlProtocol as \"http\",\r\n hostname: Constants.environment.apiBaseUrlHostname,\r\n version: Constants.environment.apiBaseUrlVersion,\r\n }),\r\n });\r\n\r\n async function handleTranslate(\r\n values: Article.TranslateForm.Values,\r\n { setSubmitting }: Formik.FormikHelpers\r\n ) {\r\n try {\r\n const uid = userStore.user?.uid;\r\n if (uid === undefined) {\r\n throw new Error(t(\"uid is undefined\"));\r\n }\r\n\r\n if (!article) {\r\n throw new Error(t(\"Article is undefined\"));\r\n }\r\n\r\n const setsLang: Partial[] = [\r\n {\r\n setID: article.setID,\r\n setName: values.name_de,\r\n langCode: \"de\",\r\n setDescriptions: values.description_de,\r\n industrySegment: industrySegments.find(\r\n (industrySegment) =>\r\n industrySegment.industrySegmentsId === article.industrySegmentsId\r\n )?.nameDE,\r\n },\r\n {\r\n setID: article.setID,\r\n setName: values.name_fr,\r\n langCode: \"fr\",\r\n setDescriptions: values.description_fr,\r\n industrySegment: industrySegments.find(\r\n (industrySegment) =>\r\n industrySegment.industrySegmentsId === article.industrySegmentsId\r\n )?.nameFR,\r\n },\r\n {\r\n setID: article.setID,\r\n setName: values.name_it,\r\n langCode: \"it\",\r\n setDescriptions: values.description_it,\r\n industrySegment: industrySegments.find(\r\n (industrySegment) =>\r\n industrySegment.industrySegmentsId === article.industrySegmentsId\r\n )?.nameIT,\r\n },\r\n {\r\n setID: article.setID,\r\n setName: values.name_es,\r\n langCode: \"es\",\r\n setDescriptions: values.description_es,\r\n industrySegment: industrySegments.find(\r\n (industrySegment) =>\r\n industrySegment.industrySegmentsId === article.industrySegmentsId\r\n )?.nameES,\r\n },\r\n ];\r\n await articleService.createLangs({ body: setsLang, uid });\r\n enqueueSnackbar(t(\"Article successfully translated!\"), {\r\n variant: \"success\",\r\n preventDuplicate: false,\r\n });\r\n articleStore.read();\r\n } catch (error) {\r\n console.error(error);\r\n enqueueSnackbar(t(\"Something went wrong! Please try again later.\"), {\r\n variant: \"warning\",\r\n preventDuplicate: false,\r\n });\r\n } finally {\r\n setSubmitting(false);\r\n handleClose();\r\n }\r\n }\r\n\r\n React.useEffect(() => {\r\n if (!open) {\r\n return;\r\n }\r\n (async function () {\r\n try {\r\n const {\r\n result: industrySegments,\r\n } = await industrySegmentService.getAllData();\r\n setIndustrySegments(industrySegments);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n })();\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, [open]);\r\n\r\n React.useEffect(() => {\r\n if (!article) {\r\n setInitialValues(undefined);\r\n return;\r\n }\r\n\r\n const initialValues: Article.TranslateForm.Values = {\r\n name_de: article?.setsLang?.reduce((name: string, lang) => {\r\n if (lang.langCode.toLowerCase() === \"de\") {\r\n return name + lang.setName;\r\n }\r\n return name;\r\n }, \"\"),\r\n name_es: article?.setsLang?.reduce((name: string, lang) => {\r\n if (lang.langCode.toLowerCase() === \"es\") {\r\n return name + lang.setName;\r\n }\r\n return name;\r\n }, \"\"),\r\n name_fr: article?.setsLang?.reduce((name: string, lang) => {\r\n if (lang.langCode.toLowerCase() === \"fr\") {\r\n return name + lang.setName;\r\n }\r\n return name;\r\n }, \"\"),\r\n name_it: article?.setsLang?.reduce((name: string, lang) => {\r\n if (lang.langCode.toLowerCase() === \"it\") {\r\n return name + lang.setName;\r\n }\r\n return name;\r\n }, \"\"),\r\n description_de: article?.setsLang?.reduce((name: string, lang) => {\r\n if (lang.langCode.toLowerCase() === \"de\") {\r\n return name + lang.setDescriptions;\r\n }\r\n return name;\r\n }, \"\"),\r\n description_es: article?.setsLang?.reduce((name: string, lang) => {\r\n if (lang.langCode.toLowerCase() === \"es\") {\r\n return name + lang.setDescriptions;\r\n }\r\n return name;\r\n }, \"\"),\r\n description_fr: article?.setsLang?.reduce((name: string, lang) => {\r\n if (lang.langCode.toLowerCase() === \"fr\") {\r\n return name + lang.setDescriptions;\r\n }\r\n return name;\r\n }, \"\"),\r\n description_it: article?.setsLang?.reduce((name: string, lang) => {\r\n if (lang.langCode.toLowerCase() === \"it\") {\r\n return name + lang.setDescriptions;\r\n }\r\n return name;\r\n }, \"\"),\r\n };\r\n setInitialValues(initialValues);\r\n }, [article]);\r\n\r\n return (\r\n <>\r\n \r\n {({ isSubmitting, submitForm }) => {\r\n \r\n return (\r\n \r\n \r\n {article && (\r\n <>\r\n \r\n \r\n >\r\n )}\r\n >\r\n }\r\n title={\r\n \r\n {t(\"Translate article name & description\")}\r\n \r\n }\r\n actions={\r\n <>\r\n \r\n CLOSE\r\n \r\n submitForm()}\r\n >\r\n \r\n Save / Update\r\n \r\n {isSubmitting && (\r\n \r\n )}\r\n \r\n >\r\n }\r\n />\r\n )}}\r\n \r\n >\r\n );\r\n});\r\n","import * as Mui from \"@material-ui/core\";\r\nimport * as Formik from \"formik\";\r\nimport * as FormikMui from \"formik-material-ui\";\r\nimport * as React from \"react\";\r\nimport * as ReactI18next from \"react-i18next\";\r\n\r\nexport declare namespace TranslateForm {\r\n export interface Values {\r\n name_de: string;\r\n name_fr: string;\r\n name_it: string;\r\n name_es: string;\r\n description_de: string;\r\n description_fr: string;\r\n description_it: string;\r\n description_es: string;\r\n }\r\n\r\n export interface Props {\r\n name: string;\r\n description: string;\r\n }\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare\r\nexport function TranslateForm({ name, description }: TranslateForm.Props) {\r\n const { t } = ReactI18next.useTranslation();\r\n const theme = Mui.useTheme();\r\n return (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n Article name\r\n \r\n \r\n {name}\r\n \r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n Article description\r\n \r\n \r\n {description}\r\n \r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n >\r\n );\r\n}\r\n","import * as React from \"react\";\r\nimport * as ReactI18next from \"react-i18next\";\r\n\r\nexport function Main() {\r\n return (\r\n <>\r\n \r\n This is a customers main page\r\n \r\n >\r\n );\r\n}\r\n","import * as Mobx from \"mobx\";\r\nimport * as Models from \"src/models\";\r\nimport * as Services from \"src/services\";\r\n\r\nexport declare namespace Store {\r\n export type View = \"TABULAR\" | \"CARD\";\r\n\r\n export interface IStore {\r\n isLoading: boolean;\r\n customers: Models.Customer.Main[];\r\n customerService: Services.Customer;\r\n }\r\n\r\n export type Options = Pick;\r\n\r\n export namespace Read {\r\n export interface Props extends Services.Customer.GetAllData.Props {}\r\n }\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare\r\nexport class Store implements Store.IStore {\r\n @Mobx.observable public customers: Models.Customer.Main[] = [];\r\n @Mobx.observable public isLoading: boolean = false;\r\n\r\n public customerService: Services.Customer;\r\n\r\n constructor({ customerService }: Store.Options) {\r\n this.customerService = customerService;\r\n }\r\n\r\n @Mobx.action public async read(props: Store.Read.Props) {\r\n try {\r\n this.isLoading = true;\r\n const { result } = await this.customerService.getAllData(props);\r\n this.customers = result;\r\n } catch (error) {\r\n console.error(error);\r\n } finally {\r\n this.isLoading = false;\r\n }\r\n }\r\n\r\n @Mobx.computed public get isInitialLoading(): boolean {\r\n if (this.customers.length !== 0) {\r\n return false;\r\n }\r\n\r\n if (!this.isLoading) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n","/** @format */\r\n\r\nimport * as Mui from \"@material-ui/core\";\r\nimport * as MuiLab from \"@material-ui/lab\";\r\nimport * as Notistack from \"notistack\";\r\nimport * as React from \"react\";\r\nimport * as ReactI18next from \"react-i18next\";\r\nimport * as Router from \"react-router-dom\";\r\nimport * as App from \"src/app\";\r\nimport * as DealerCustomer from \"src/app/pages/dealercustomer\";\r\nimport * as Order from \"src/app/pages/order\";\r\nimport * as Models from \"src/models\";\r\nimport { v4 as uuidv4 } from \"uuid\";\r\nimport * as Components from \"src/app/components\";\r\n\r\ninterface Data extends Models.DealerCustomer.Main {}\r\n\r\nfunction stableSort(array: T[], comparator: (a: T, b: T) => number) {\r\n const stabilizedThis = array.map((el, index) => [el, index] as [T, number]);\r\n stabilizedThis.sort((a, b) => {\r\n const order = comparator(a[0], b[0]);\r\n if (order !== 0) return order;\r\n return a[1] - b[1];\r\n });\r\n return stabilizedThis.map((el) => el[0]);\r\n}\r\n\r\ntype Order = \"asc\" | \"desc\";\r\n\r\nfunction getComparator(\r\n order: Order,\r\n orderBy: Key\r\n): (\r\n a: { [key in Key]: number | string },\r\n b: { [key in Key]: number | string }\r\n) => number {\r\n return order === \"asc\"\r\n ? (a, b) => descendingComparator(a, b, orderBy)\r\n : (a, b) => -descendingComparator(a, b, orderBy);\r\n}\r\n\r\nfunction descendingComparator(a: T, b: T, orderBy: keyof T) {\r\n if (b[orderBy] < a[orderBy]) {\r\n return -1;\r\n }\r\n if (b[orderBy] > a[orderBy]) {\r\n return 1;\r\n }\r\n return 0;\r\n}\r\n\r\nexport declare namespace Cards {\r\n export interface Props {\r\n customers: Models.DealerCustomer.Main[];\r\n }\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare\r\nexport function Cards({ customers }: Cards.Props) {\r\n const theme = Mui.useTheme();\r\n const { t } = ReactI18next.useTranslation();\r\n\r\n const [orderId, setOrderId] = React.useState();\r\n const [orderDetailsDialogOpen, setOrderDetailsDialogOpen] = React.useState<\r\n boolean\r\n >(false);\r\n \r\n const [customerData, setCustomerData] = React.useState();\r\n const [page, setPage] = React.useState(0);\r\n const [select, setSelect] = React.useState(false);\r\n const [\r\n adminAndCustomerRoleCheck,\r\n setAdminAndCustomerRoleCheck,\r\n ] = React.useState(false);\r\n const [rowsPerPage] = React.useState(8);\r\n\r\n React.useEffect(() => {\r\n setPage(0);\r\n }, [customers]);\r\n\r\n const handleChangePage = (event: unknown, newPage: number) => {\r\n setPage(newPage);\r\n };\r\n const [detailsDrawerOpen, setDetailsDrawerOpen] = React.useState(\r\n false\r\n );\r\n const functionStore = React.useContext(App.Contexts.functionStore);\r\n const [currentLicense, setCurrentLicense] = React.useState(false);\r\n const [customerMailID, setCustomerMailID] = React.useState(\"\");\r\n const toggleDetailsDrawer = () => {\r\n setDetailsDrawerOpen(!detailsDrawerOpen);\r\n };\r\n const navigate = Router.useNavigate();\r\n const { enqueueSnackbar } = Notistack.useSnackbar();\r\n const dCustomerStore = React.useContext(App.Contexts.delareCustomerStore);\r\n const [selectedValue, setSelectedValue] = React.useState(\"\");\r\n const userStore = React.useContext(App.Contexts.userStore);\r\n React.useEffect(() => {\r\n const userRole = userStore.user?.RoleName;\r\n if (userRole === \"admin\" || userRole === \"superadmin\" || userRole === \"customer\") {\r\n setAdminAndCustomerRoleCheck(false);\r\n } else {\r\n setAdminAndCustomerRoleCheck(true);\r\n }\r\n }, [userStore.user, adminAndCustomerRoleCheck]);\r\n\r\n const handleSelectDealerUser = ({\r\n dealerProfile,\r\n }: {\r\n dealerProfile: any;\r\n }) => {\r\n\r\n const selectedIndex = dCustomerStore.selected.indexOf(dealerProfile);\r\n let newSelected: Models.CustomerLicense.Main[] = [];\r\n dCustomerStore.setSelected({ selected: newSelected });\r\n if (selectedIndex === -1) {\r\n newSelected = newSelected.concat(dCustomerStore.selected, dealerProfile);\r\n } else if (selectedIndex === 0) {\r\n newSelected = newSelected.concat(dCustomerStore.selected.slice(1));\r\n } else if (selectedIndex === dCustomerStore.selected.length - 1) {\r\n newSelected = newSelected.concat(dCustomerStore.selected.slice(0, -1));\r\n } else if (selectedIndex > 0) {\r\n newSelected = newSelected.concat(\r\n dCustomerStore.selected.slice(0, selectedIndex),\r\n dCustomerStore.selected.slice(selectedIndex + 1)\r\n );\r\n }\r\n dCustomerStore.setSelected({ selected: newSelected });\r\n let arrayCustomer: any = [];\r\n arrayCustomer = newSelected;\r\n const customerName = arrayCustomer.map((k: any) => k.customerName);\r\n const mailID: any = arrayCustomer.map((k: any) => k.emailID);\r\n const companyName: any = arrayCustomer.map((k: any) => k.companyName);\r\n const customerID: any = arrayCustomer.map((k: any) => k.customerID);\r\n localStorage.setItem(\"mID\", mailID);\r\n localStorage.setItem(\"cuName\", customerName);\r\n localStorage.setItem(\"coName\", companyName);\r\n localStorage.setItem(\"customerID\", customerID);\r\n };\r\n const [customerId, setCustomerId] = React.useState();\r\n const [customerDetailsDialogOpen, setCustomerDetailsDialogOpen] = React.useState<\r\n boolean\r\n >(false);\r\n const uid = userStore.user?.ETUID;\r\n const userRole = userStore?.user?.RoleName\r\n return (\r\n <>\r\n setCustomerDetailsDialogOpen(false)}\r\n title={t(\"Customer details\")}\r\n contentText={}\r\n actions={\r\n <>\r\n window.print()}\r\n >\r\n Print\r\n \r\n setCustomerDetailsDialogOpen(false)}\r\n >\r\n Close\r\n \r\n >\r\n }\r\n />\r\n\r\n \r\n {stableSort(customers as any, getComparator(\"asc\", \"customerName\"))\r\n .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)\r\n .map((Customer, index) => (\r\n \r\n {\r\n setCustomerMailID(EmailID)\r\n setOrderId(CustomerID);\r\n setCustomerId(CustomerID);\r\n setCustomerData(customerData)\r\n setSelectedValue(CustomerID);\r\n handleSelectDealerUser({\r\n dealerProfile: (Customer as unknown) as Models.CustomerLicense.Main[],\r\n });\r\n navigate(\r\n `/dealercustomer/customerdetail?q=${etuid}&m=${CustomerID}`\r\n );\r\n }}\r\n customer={(Customer as unknown) as Models.DealerCustomer.Main}\r\n />\r\n \r\n ))}\r\n {customers.length === 0 && (\r\n \r\n \r\n No customers found\r\n \r\n \r\n )}\r\n \r\n \r\n {customers.length > 7 && (\r\n \r\n handleChangePage(event, page - 1)}\r\n shape=\"rounded\"\r\n />\r\n \r\n )}\r\n >\r\n );\r\n}\r\n","import * as Mobx from \"mobx-react-lite\";\r\nimport * as React from \"react\";\r\nimport * as App from \"src/app\";\r\nimport * as Components from \"src/app/components\";\r\nimport * as Constants from \"src/constants\";\r\nimport * as Services from \"src/services\";\r\nimport * as Models from \"src/models\";\r\n\r\nexport declare namespace CardDetails {\r\n export interface Props {\r\n uid?: string | number;\r\n userRole?: string | any;\r\n mailID?:string | any;\r\n row?: Models.DealerCustomer.Main;\r\n customers?: Models.DealerCustomer.Main[];\r\n }\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare\r\nexport const CardDetails = Mobx.observer(function ({\r\n uid,\r\n userRole,\r\n mailID,\r\n row,\r\n customers\r\n}: CardDetails.Props) {\r\n // \r\n const [order, setOrder] = React.useState();\r\n const [isLoading, setIsLoading] = React.useState(true);\r\n const userStore = React.useContext(App.Contexts.userStore);\r\n const orderServices = new Services.Order({\r\n httpManager: new Services.Managers.Axios({ agent: App.axios }),\r\n urlFactory: new Services.Factories.URL({\r\n protocol: Constants.environment.apiBaseUrlProtocol as \"http\",\r\n hostname: Constants.environment.apiBaseUrlHostname,\r\n version: Constants.environment.apiBaseUrlVersion,\r\n }),\r\n });\r\n \r\n const dCustomerStore = React.useContext(App.Contexts.delareCustomerStore);\r\n React.useEffect(() => {\r\n (async function () {\r\n if (!uid) {\r\n return;\r\n }\r\n\r\n try {\r\n setIsLoading(true)\r\n const roleID:any = userStore.user?.ETUID;\r\n \r\n const result = await dCustomerStore.readOfCustomerProfile({\r\n uid,\r\n mailID,\r\n roleID,\r\n userRole,\r\n });\r\n setOrder(dCustomerStore.delaerCustomerProfile);\r\n } catch (error) {\r\n console.error(error);\r\n } finally {\r\n setIsLoading(false)\r\n }\r\n })(); \r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, []);\r\n\r\n return (\r\n <>\r\n \r\n >\r\n );\r\n});\r\n","/** @format */\r\n\r\nimport * as Mui from \"@material-ui/core\";\r\nimport * as MuiIcons from \"@material-ui/icons\";\r\nimport * as React from \"react\";\r\nimport * as App from \"src/app\";\r\nimport * as Components from \"src/app/components\";\r\nimport * as Models from \"src/models\";\r\nimport * as ReactI18next from \"react-i18next\";\r\n\r\nexport declare namespace Card {\r\n export interface Props {\r\n customer: Models.DealerCustomer.Main;\r\n selected: number | string;\r\n handleClick?(props: { CustomerID: number | string ,EmailID: any,customerData:any,etuid:any}): void;\r\n }\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare\r\nexport function Card({\r\n customer,\r\n selected,\r\n handleClick,\r\n}: \r\nCard.Props) {\r\n const theme = Mui.useTheme();\r\n const { t } = ReactI18next.useTranslation();\r\n const [\r\n adminAndCustomerRoleCheck,\r\n setAdminAndCustomerRoleCheck,\r\n ] = React.useState(false);\r\n const userStore = React.useContext(App.Contexts.userStore);\r\n const userRole = userStore.user?.RoleName;\r\n React.useEffect(() => {\r\n if (userRole === \"admin\" || userRole === \"superadmin\" || userRole === \"customer\") {\r\n setAdminAndCustomerRoleCheck(false);\r\n } else {\r\n setAdminAndCustomerRoleCheck(true);\r\n }\r\n }, [userRole, adminAndCustomerRoleCheck]);\r\n const CardInternals = (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {customer.companyName}\r\n \r\n }\r\n secondary={\r\n <>\r\n \r\n \r\n
\r\n >\r\n }\r\n />\r\n \r\n \r\n }\r\n action={\r\n <>\r\n \r\n >\r\n }\r\n />\r\n \r\n \r\n <>\r\n \r\n \r\n \r\n Customer name\r\n :\r\n \r\n \r\n {customer.customerName}\r\n \r\n
\r\n >\r\n\r\n {/* */}\r\n <>\r\n \r\n \r\n {\" \"}\r\n {t(\"Email ID\")}:\r\n \r\n {window.open(`mailto:${customer.emailID}`)}}\r\n style={{\r\n color: \"black\",\r\n fontSize: \"14px\",\r\n marginLeft: \"6px\",\r\n }}\r\n >\r\n \r\n click to open an mail\r\n }>{customer.emailID}\r\n \r\n \r\n
\r\n >\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n Purchased license\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n {t(\"Status\")}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n );\r\n\r\n return (\r\n \r\n {handleClick ? (\r\n handleClick({ CustomerID: customer.customerID,EmailID: customer.emailID ,customerData:customer,etuid:customer.etuid})}\r\n >\r\n {CardInternals}\r\n \r\n ) : (\r\n { CardInternals }\r\n )}\r\n \r\n );\r\n}\r\n","import * as Mobx from \"mobx-react-lite\";\r\nimport * as React from \"react\";\r\nimport * as App from \"src/app\";\r\nimport * as Components from \"src/app/components\";\r\nimport * as Constants from \"src/constants\";\r\nimport * as Services from \"src/services\";\r\nimport * as Models from \"src/models\";\r\n\r\nexport declare namespace Details {\r\n export interface Props {\r\n uid?: string | number;\r\n userRole?: string | any;\r\n mailID?:string | any;\r\n row?: Models.DealerCustomer.Main;\r\n customers?: Models.DealerCustomer.Main[];\r\n }\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare\r\nexport const Details = Mobx.observer(function ({\r\n uid,\r\n userRole,\r\n mailID,\r\n row,\r\n customers\r\n}: Details.Props) {\r\n const [order, setOrder] = React.useState();\r\n const [isLoading, setIsLoading] = React.useState(true);\r\n const userStore = React.useContext(App.Contexts.userStore);\r\n const orderServices = new Services.Order({\r\n httpManager: new Services.Managers.Axios({ agent: App.axios }),\r\n urlFactory: new Services.Factories.URL({\r\n protocol: Constants.environment.apiBaseUrlProtocol as \"http\",\r\n hostname: Constants.environment.apiBaseUrlHostname,\r\n version: Constants.environment.apiBaseUrlVersion,\r\n }),\r\n });\r\n \r\n const dCustomerStore = React.useContext(App.Contexts.delareCustomerStore);\r\n React.useEffect(() => {\r\n (async function () {\r\n if (!uid) {\r\n return;\r\n }\r\n\r\n try {\r\n setIsLoading(true);\r\n const roleID:any = userStore.user?.ETUID;\r\n const result = await dCustomerStore.readOfCustomerProfile({\r\n uid,\r\n mailID,\r\n roleID,\r\n userRole,\r\n });\r\n setOrder(dCustomerStore.delaerCustomerProfile);\r\n } catch (error) {\r\n console.error(error);\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n })(); \r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, []);\r\n\r\n return (\r\n <>\r\n \r\n >\r\n );\r\n});\r\n","import * as Mui from \"@material-ui/core\";\r\nimport * as MuiIcons from \"@material-ui/icons\";\r\nimport * as React from \"react\";\r\nimport * as App from \"src/app\";\r\nimport * as Components from \"src/app/components\";\r\nimport * as Models from \"src/models\";\r\nimport * as ReactI18next from \"react-i18next\";\r\nexport declare namespace List {\r\n export interface Props {\r\n customer: Models.DealerCustomer.Main;\r\n selected: number | string;\r\n handleClick?(props: { CustomerID: number | string }): void;\r\n }\r\n}\r\n\r\nexport declare namespace ListDetails {\r\n export interface Props {\r\n customerLicense: Models.Set.Function[];\r\n handleClick?(props: { CustomerID: number | string }): void;\r\n }\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare\r\n//Load the Card details\r\nexport function List({ customer, handleClick, selected }: List.Props) {\r\n const theme = Mui.useTheme();\r\n const CardInternals = (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n {customer.companyName}\r\n \r\n }\r\n secondary={\r\n <>\r\n \r\n \r\n Role:\r\n \r\n\r\n \r\n {customer.loginUserRole}\r\n \r\n
\r\n >\r\n }\r\n />\r\n \r\n \r\n }\r\n action={\r\n <>\r\n {selected !== undefined && (\r\n {\r\n event.stopPropagation();\r\n event.preventDefault();\r\n }}\r\n />\r\n )}\r\n >\r\n }\r\n style={{ padding: 4, margin: 6 }}\r\n />\r\n \r\n \r\n <>\r\n \r\n >\r\n\r\n <>\r\n \r\n \r\n {\" \"}\r\n {\"EmailID:\"}\r\n \r\n {window.open(`mailto:${customer.emailID}`)}}\r\n style={{ color: \"black\", fontSize: \"14px\" }}>\r\n \r\n click to open an mail\r\n }>{customer.emailID}\r\n\r\n \r\n
\r\n >\r\n\r\n \r\n \r\n \r\n \r\n Available license\r\n \r\n\r\n \r\n \r\n \r\n {customer?.functionCount > 4 && (\r\n \r\n + {customer.functionCount}\r\n {}more\r\n \r\n )}\r\n \r\n \r\n \r\n \r\n {\"Status\"}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n );\r\n\r\n return (\r\n \r\n {handleClick ? (\r\n handleClick({ CustomerID: customer.customerID })}>\r\n {CardInternals}\r\n \r\n ) : (\r\n CardInternals\r\n )}\r\n \r\n );\r\n}\r\n\r\nexport function ListDeatils({ customer, handleClick }: List.Props) {\r\n const customerLic = JSON.stringify(customer);\r\n\r\n const CardInternals = (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n }\r\n secondary={\r\n <>\r\n \r\n Role:\r\n\r\n \r\n \r\n
\r\n >\r\n }\r\n />\r\n \r\n \r\n }\r\n style={{ padding: 4, margin: 6 }}\r\n />\r\n \r\n \r\n <>\r\n \r\n Company name:\r\n \r\n {customerLic.valueOf()}\r\n \r\n
\r\n >\r\n\r\n <>\r\n \r\n {\"EmailID:\"}\r\n \r\n \r\n
\r\n >\r\n\r\n \r\n \r\n \r\n \r\n {customer.functionCount > 4 && (\r\n \r\n + {customer.functionCount}\r\n {}more\r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n {\"Status\"}\r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n );\r\n\r\n return (\r\n \r\n {handleClick ? (\r\n handleClick({ CustomerID: 1 })}>\r\n {CardInternals}\r\n \r\n ) : (\r\n CardInternals\r\n )}\r\n \r\n );\r\n}\r\n","/** @format */\r\n\r\nimport * as Mui from \"@material-ui/core\";\r\nimport * as MuiLab from \"@material-ui/lab\";\r\nimport * as DateFns from \"date-fns\";\r\nimport * as Mobx from \"mobx-react-lite\";\r\nimport * as Notistack from \"notistack\";\r\nimport * as React from \"react\";\r\nimport * as ReactI18next from \"react-i18next\";\r\nimport * as Router from \"react-router-dom\";\r\nimport * as App from \"src/app\";\r\nimport * as Components from \"src/app/components\";\r\nimport * as Containers from \"src/app/containers\";\r\nimport * as DealerCustomer from \"src/app/pages/dealercustomer\";\r\nimport * as Models from \"src/models\";\r\nimport * as MuiIcon from \"@material-ui/icons\";\r\n\r\ninterface Data extends Models.DealerCustomer.Main {}\r\n\r\nfunction descendingComparator(a: T, b: T, orderBy: keyof T) {\r\n if (b[orderBy] < a[orderBy]) {\r\n return -1;\r\n }\r\n if (b[orderBy] > a[orderBy]) {\r\n return 1;\r\n }\r\n return 0;\r\n}\r\n\r\ntype Order = \"asc\" | \"desc\";\r\n\r\nfunction getComparator(\r\n order: Order,\r\n orderBy: Key\r\n): (a: { [key in Key]: any }, b: { [key in Key]: any }) => number {\r\n return order === \"asc\"\r\n ? (a, b) => descendingComparator(a, b, orderBy)\r\n : (a, b) => -descendingComparator(a, b, orderBy);\r\n}\r\n\r\nfunction stableSort(array: T[], comparator: (a: T, b: T) => number) {\r\n const stabilizedThis = array.map((el, index) => [el, index] as [T, number]);\r\n stabilizedThis.sort((a, b) => {\r\n const order = comparator(a[0], b[0]);\r\n if (order !== 0) return order;\r\n return a[1] - b[1];\r\n });\r\n return stabilizedThis.map((el) => el[0]);\r\n}\r\n\r\ninterface EnhancedTableProps {\r\n classes: ReturnType;\r\n numselected: number;\r\n onRequestSort: (\r\n event: React.MouseEvent,\r\n property: keyof Data\r\n ) => void;\r\n onSelectAllClick: (event: React.ChangeEvent) => void;\r\n order: Order;\r\n orderBy: string;\r\n rowcount: number;\r\n}\r\n\r\nfunction EnhancedTableHead(\r\n props: EnhancedTableProps & {\r\n id: string;\r\n label: string;\r\n numeric?: boolean;\r\n disablePadding?: boolean;\r\n leftmost?: boolean;\r\n rightmost?: boolean;\r\n }\r\n) {\r\n const { classes, order, orderBy, onRequestSort, ...restOfProps } = props;\r\n const createSortHandler =\r\n (property: keyof Data) => (event: React.MouseEvent) => {\r\n onRequestSort(event, property);\r\n };\r\n\r\n const theme = Mui.useTheme();\r\n\r\n return (\r\n \r\n \r\n {props.label}\r\n {orderBy === props.id ? (\r\n \r\n {order === \"desc\" ? \"sorted descending\" : \"sorted ascending\"}\r\n \r\n ) : null}\r\n \r\n \r\n );\r\n}\r\n\r\nconst useStyles = Mui.makeStyles((theme) =>\r\n Mui.createStyles({\r\n root: {\r\n width: \"100%\",\r\n },\r\n paper: {\r\n width: \"100%\",\r\n marginBottom: theme.spacing(2),\r\n },\r\n table: {\r\n minWidth: 750,\r\n },\r\n visuallyHidden: {\r\n border: 0,\r\n clip: \"rect(0 0 0 0)\",\r\n height: 1,\r\n margin: -1,\r\n overflow: \"hidden\",\r\n padding: 0,\r\n position: \"absolute\",\r\n top: 20,\r\n width: 1,\r\n },\r\n })\r\n);\r\n\r\nfunction EnhancedTable({\r\n rows,\r\n handleView,\r\n}: {\r\n rows: Models.DealerCustomer.Main[];\r\n handleView(props: { avilableFunction: Models.Set.Function[] }): void;\r\n}) {\r\n const classes = useStyles();\r\n const [order, setOrder] = React.useState(\"asc\");\r\n const [orderBy, setOrderBy] = React.useState(\"customerName\");\r\n const [selected, setSelected] = React.useState([]);\r\n const [page, setPage] = React.useState(0);\r\n const [rowsPerPage] = React.useState(7);\r\n const dCustomerStore = React.useContext(App.Contexts.delareCustomerStore);\r\n const functionStore = React.useContext(App.Contexts.functionStore);\r\n const [currentLicense, setCurrentLicense] = React.useState(false);\r\n const [selectedValue, setSelectedValue] = React.useState(\"\");\r\n React.useEffect(() => {\r\n setPage(0);\r\n }, [rows]);\r\n\r\n const handleRequestSort = (\r\n event: React.MouseEvent,\r\n property: keyof Data\r\n ) => {\r\n setPage(0);\r\n const isAsc = orderBy === property && order === \"asc\";\r\n setOrder(isAsc ? \"desc\" : \"asc\");\r\n setOrderBy(property);\r\n };\r\n\r\n const handleSelectAllClick = (event: React.ChangeEvent) => {\r\n if (event.target.checked) {\r\n const newSelecteds = rows.map((n) => n.customerID);\r\n setSelected(newSelecteds);\r\n return;\r\n }\r\n setSelected([]);\r\n };\r\n\r\n const handleClick = (event: React.MouseEvent, name: string) => {\r\n const selectedIndex = selected.indexOf(name);\r\n let newSelected: string[] = [];\r\n\r\n if (selectedIndex === -1) {\r\n newSelected = newSelected.concat(selected, name);\r\n } else if (selectedIndex === 0) {\r\n newSelected = newSelected.concat(selected.slice(1));\r\n } else if (selectedIndex === selected.length - 1) {\r\n newSelected = newSelected.concat(selected.slice(0, -1));\r\n } else if (selectedIndex > 0) {\r\n newSelected = newSelected.concat(\r\n selected.slice(0, selectedIndex),\r\n selected.slice(selectedIndex + 1)\r\n );\r\n }\r\n\r\n setSelected(newSelected);\r\n };\r\n\r\n const handleChangePage = (event: unknown, newPage: number) => {\r\n setPage(newPage);\r\n };\r\n const navigate = Router.useNavigate();\r\n const isSelected = (name: string) => selected.indexOf(name) !== -1;\r\n const [adminAndCustomerRoleCheck, setAdminAndCustomerRoleCheck] =\r\n React.useState(false);\r\n const userStore = React.useContext(App.Contexts.userStore);\r\n const userRole = userStore.user?.RoleName;\r\n React.useEffect(() => {\r\n if (\r\n userRole === \"admin\" ||\r\n userRole === \"superadmin\" ||\r\n userRole === \"customer\"\r\n ) {\r\n setAdminAndCustomerRoleCheck(false);\r\n } else {\r\n setAdminAndCustomerRoleCheck(true);\r\n }\r\n }, [userRole, adminAndCustomerRoleCheck]);\r\n const handleSelectDealerUser = ({\r\n dealerProfile,\r\n }: {\r\n dealerProfile: any;\r\n }) => {\r\n //alert(JSON.stringify(dealerProfile));\r\n const selectedIndex = dCustomerStore.selected.indexOf(dealerProfile);\r\n let newSelected: Models.CustomerLicense.Main[] = [];\r\n dCustomerStore.setSelected({ selected: newSelected });\r\n if (selectedIndex === -1) {\r\n newSelected = newSelected.concat(dCustomerStore.selected, dealerProfile);\r\n } else if (selectedIndex === 0) {\r\n // alert(\"4\");\r\n newSelected = newSelected.concat(dCustomerStore.selected.slice(1));\r\n } else if (selectedIndex === dCustomerStore.selected.length - 1) {\r\n newSelected = newSelected.concat(dCustomerStore.selected.slice(0, -1));\r\n // alert(\"5\");\r\n } else if (selectedIndex > 0) {\r\n //alert(\"6\");\r\n newSelected = newSelected.concat(\r\n dCustomerStore.selected.slice(0, selectedIndex),\r\n dCustomerStore.selected.slice(selectedIndex + 1)\r\n );\r\n }\r\n dCustomerStore.setSelected({ selected: newSelected });\r\n let arrayCustomer: any = [];\r\n arrayCustomer = newSelected;\r\n\r\n const customerName = arrayCustomer.map((k: any) => k.customerName);\r\n const mailID: any = arrayCustomer.map((k: any) => k.emailID);\r\n const companyName: any = arrayCustomer.map((k: any) => k.companyName);\r\n const customerID: any = arrayCustomer.map((k: any) => k.customerID);\r\n localStorage.setItem(\"mID\", mailID);\r\n localStorage.setItem(\"cuName\", customerName);\r\n localStorage.setItem(\"coName\", companyName);\r\n localStorage.setItem(\"customerID\", customerID);\r\n //dCustomerStore.setSelected();\r\n };\r\n const emptyRows =\r\n rowsPerPage - Math.min(rowsPerPage, rows.length - page * rowsPerPage);\r\n\r\n const { t } = ReactI18next.useTranslation();\r\n const theme = Mui.useTheme();\r\n const { enqueueSnackbar } = Notistack.useSnackbar();\r\n const [customerId, setCustomerId] = React.useState();\r\n const [MailID, setMailID] = React.useState();\r\n const [Row, setRow] = React.useState();\r\n const [customerDetailsDialogOpen, setCustomerDetailsDialogOpen] =\r\n React.useState(false);\r\n const uid = userStore.user?.ETUID;\r\n const roleName = \"dealer\";\r\n\r\n return (\r\n \r\n setCustomerDetailsDialogOpen(false)}\r\n title={t(\"Customer details\")}\r\n contentText={\r\n \r\n }\r\n actions={\r\n <>\r\n window.print()}\r\n >\r\n Print\r\n \r\n setCustomerDetailsDialogOpen(false)}\r\n >\r\n Close\r\n \r\n >\r\n }\r\n />\r\n \r\n \r\n {rows.length > 0 && (\r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n )}\r\n \r\n
\r\n \r\n \r\n {stableSort(rows as any, getComparator(order, orderBy))\r\n .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)\r\n .map((row, index) => {\r\n const isItemSelected = isSelected(row.customerID as string);\r\n const labelId = `enhanced-table-checkbox-${index}`;\r\n\r\n return (\r\n {\r\n if (row.etUserStatus !== 5) {\r\n handleClick(event, row.customerID as string);\r\n handleView({\r\n avilableFunction:\r\n row.customerID as unknown as Models.Set.Function[],\r\n });\r\n \r\n setCustomerId(row.customerID);\r\n setMailID(row.emailID);\r\n setRow(row);\r\n if (row.etuid) {\r\n navigate(\r\n `/dealercustomer/customerdetail?q=${row.etuid}&m=${row.customerID}`\r\n );\r\n }\r\n } else {\r\n enqueueSnackbar(\r\n t(\"Detail view not available for license unassigned\"),\r\n {\r\n variant: \"warning\",\r\n preventDuplicate: false,\r\n }\r\n );\r\n }\r\n }}\r\n aria-checked={isItemSelected}\r\n tabIndex={-1}\r\n key={row.customerID}\r\n \r\n >\r\n \r\n \r\n \r\n {row.customerDealerID}\r\n \r\n \r\n {row.companyName}\r\n \r\n \r\n {row.customerName}\r\n \r\n \r\n\r\n {\r\n window.open(`mailto:${row.emailID}`);\r\n }}\r\n >\r\n \r\n click to open an mail\r\n \r\n }\r\n >\r\n \r\n {row.emailID}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {row.etUserStatus > 0 ? (\r\n \r\n \r\n \r\n \r\n \r\n \r\n ) : (\r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n );\r\n })}\r\n {rows.length === 0 && (\r\n \r\n \r\n \r\n \r\n \r\n No customers found\r\n \r\n \r\n \r\n \r\n \r\n )}\r\n {emptyRows > 0 && (\r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n \r\n {rows.length > 7 && (\r\n \r\n handleChangePage(event, page - 1)}\r\n shape=\"rounded\"\r\n />\r\n \r\n )}\r\n \r\n
\r\n );\r\n}\r\n\r\nexport const Main = Mobx.observer(function () {\r\n const [search, setSearch] = React.useState(\"\");\r\n const [state, setState] = React.useState();\r\n const userStore = React.useContext(App.Contexts.userStore);\r\n const dCustomerStore = React.useContext(App.Contexts.delareCustomerStore);\r\n const theme = Mui.useTheme();\r\n const [detailsDrawerOpen, setDetailsDrawerOpen] =\r\n React.useState(false);\r\n const [searchParams] = Router.useSearchParams();\r\n\r\n const id = searchParams.get(\"roleId\");\r\n\r\n React.useEffect(() => {\r\n const uid = userStore.user?.ETUID;\r\n dCustomerStore.delaerCustomer = [];\r\n // userStore.setPreviousUrl({ urls: \"/dealercustomer?roles=all\" });\r\n const userRole = \"customer\";\r\n if (uid !== undefined && uid !== null) {\r\n dCustomerStore.read({\r\n uid,\r\n userRole,\r\n });\r\n }\r\n console.log(\"dCustomerStore\"+JSON.stringify(dCustomerStore.delaerCustomer));\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, [searchParams]);\r\n\r\n const handleSearch = (event: React.ChangeEvent) => {\r\n setSearch(event.target.value as string);\r\n };\r\n const { t } = ReactI18next.useTranslation();\r\n const toggleDetailsDrawer = () => {\r\n setDetailsDrawerOpen(!detailsDrawerOpen);\r\n };\r\n const [currentAvilableFunction, setCurrentAvilableFunction] =\r\n React.useState();\r\n \r\n const licenseStore = React.useContext(App.Contexts.license.store);\r\n const functionStore = React.useContext(App.Contexts.functionStore);\r\n\r\n const handleChange = (event: any) => {\r\n if (event.target.value === \"All\") {\r\n setSearch(\"\");\r\n } else {\r\n setSearch(event.target.value as string);\r\n }\r\n };\r\n return (\r\n <>\r\n \r\n \r\n \r\n {dCustomerStore.delaerCustomer.length > 0 && (\r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {dCustomerStore.isInitialLoading ? (\r\n \r\n \r\n \r\n ) : (\r\n <>\r\n {dCustomerStore.view === \"LIST\" && (\r\n {\r\n if (!search) {\r\n return true;\r\n }\r\n return (\r\n order?.companyName\r\n ?.toLowerCase()\r\n .includes(search.toLowerCase()) ||\r\n order?.customerName\r\n ?.toLowerCase()\r\n .includes(search.toLowerCase()) ||\r\n order?.licenseCount\r\n ?.toLowerCase()\r\n .includes(search.toLowerCase()) ||\r\n order?.emailID\r\n ?.toLowerCase()\r\n .includes(search.toLowerCase()) ||\r\n (order.companyName &&\r\n DateFns.format(new Date(order.companyName), \"dd.MM.yyyy\")\r\n .toLowerCase()\r\n .includes(search.toLowerCase()))\r\n );\r\n })}\r\n />\r\n )}\r\n {dCustomerStore.view === \"CARD\" && (\r\n {\r\n if (!search) {\r\n return true;\r\n }\r\n return (\r\n customer?.loginUserRole\r\n ?.toLowerCase()\r\n .includes(search.toLowerCase()) ||\r\n customer?.customerName\r\n ?.toLowerCase()\r\n .includes(search.toLowerCase()) ||\r\n customer?.emailID\r\n ?.toLowerCase()\r\n .includes(search.toLowerCase()) ||\r\n customer?.customerName\r\n ?.toLowerCase()\r\n .includes(search.toLowerCase()) ||\r\n customer?.customerDealerID\r\n .includes(search) ||\r\n customer?.companyName\r\n ?.toLowerCase()\r\n .includes(search.toLowerCase()) ||\r\n (customer.inviteDate &&\r\n DateFns.format(new Date(customer.inviteDate), \"dd.MM.yyyy\")\r\n .toLowerCase()\r\n .includes(search.toLowerCase()))\r\n );\r\n })}\r\n />\r\n )}\r\n {dCustomerStore.view === \"TABULAR\" && (\r\n {\r\n setCurrentAvilableFunction(avilableFunction);\r\n toggleDetailsDrawer();\r\n }}\r\n rows={dCustomerStore.delaerCustomer.filter((order) => {\r\n if (!search) {\r\n return true;\r\n }\r\n\r\n return (\r\n order?.loginUserRole\r\n ?.toLowerCase()\r\n .includes(search.toLowerCase()) ||\r\n order?.customerName\r\n ?.toLowerCase()\r\n .includes(search.toLowerCase()) ||\r\n order?.emailID\r\n ?.toLowerCase()\r\n .includes(search.toLowerCase()) ||\r\n order?.customerName\r\n ?.toLowerCase()\r\n .includes(search.toLowerCase()) ||\r\n order?.companyName\r\n ?.toLowerCase()\r\n .includes(search.toLowerCase()) ||\r\n order?.customerDealerID\r\n ?.toLowerCase()\r\n .includes(search.toLowerCase()) ||\r\n order?.licenseCount\r\n ?.toLowerCase()\r\n .includes(search.toLowerCase())\r\n );\r\n })}\r\n />\r\n )}\r\n >\r\n )}\r\n >\r\n );\r\n});\r\n","/** @format */\r\n\r\nimport * as Mobx from \"mobx\";\r\nimport * as Models from \"src/models\";\r\nimport * as Services from \"src/services\";\r\n\r\nexport declare namespace Store {\r\n export type View = \"TABULAR\" | \"CARD\" | \"LIST\";\r\n\r\n export interface IStore {\r\n isLoading: boolean;\r\n dcustomerService: Services.DealerCustomerService;\r\n view: Store.View;\r\n }\r\n\r\n export type Options = Pick;\r\n\r\n export namespace SetView {\r\n export interface Props extends Pick {}\r\n }\r\n\r\n export namespace Read {\r\n export interface Props\r\n extends Services.DealerCustomerService.GetAllData.Props {}\r\n }\r\n export namespace ReadOfCustomerProfile {\r\n export interface Props\r\n extends Services.DealerCustomerService.GetCustomerProfileData.Props {}\r\n }\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare\r\nexport class Store implements Store.IStore {\r\n @Mobx.observable public view: Store.View = \"TABULAR\";\r\n @Mobx.observable public delaerCustomer: Models.DealerCustomer.Main[] = [];\r\n @Mobx.observable public selectedCustomer: Models.DealerCustomer.Main[] = [];\r\n @Mobx.observable\r\n public delaerCustomerProfile: Models.CustomerProfileOnDealer.Main[] = [];\r\n @Mobx.observable public isLoading: boolean = false;\r\n @Mobx.observable public isCustomerAdded: boolean = false;\r\n @Mobx.observable public isSet: boolean = false;\r\n @Mobx.observable public isCustomerSelected: boolean = false;\r\n @Mobx.observable public selected: Models.CustomerLicense.Main[] = [];\r\n public dcustomerService: Services.DealerCustomerService;\r\n constructor({ view, dcustomerService }: Store.Options) {\r\n this.view = view;\r\n this.dcustomerService = dcustomerService;\r\n }\r\n\r\n @Mobx.action setView({ view }: Store.SetView.Props) {\r\n this.view = view;\r\n }\r\n\r\n @Mobx.action public async readOfCustomerProfile(\r\n props: Store.ReadOfCustomerProfile.Props\r\n ) {\r\n try {\r\n this.isLoading = true;\r\n const { result } =\r\n await this.dcustomerService.getCustomerProfileWithLicense(props);\r\n\r\n this.delaerCustomerProfile = result;\r\n //\r\n } catch (error) {\r\n console.error(error);\r\n } finally {\r\n this.isLoading = false;\r\n }\r\n }\r\n\r\n @Mobx.action public async read(props: Store.Read.Props) {\r\n try {\r\n this.isLoading = true;\r\n const { result } = await this.dcustomerService.getCustomer(props);\r\n this.delaerCustomer = result;\r\n this.selectedCustomer = result;\r\n\r\n //\r\n } catch (error) {\r\n console.error(error);\r\n } finally {\r\n this.isLoading = false;\r\n }\r\n }\r\n\r\n @Mobx.action setIsCustomerAdded(isCustomerAdded: boolean) {\r\n this.isCustomerAdded = isCustomerAdded;\r\n }\r\n\r\n @Mobx.action setSelectedCustomer(customerID: any) {\r\n this.selectedCustomer = this.selectedCustomer.filter(\r\n (k) => k.etuid === customerID\r\n );\r\n }\r\n\r\n @Mobx.action getSelectedCustomer() {\r\n if (this.selectedCustomer.length === 0) {\r\n return [];\r\n } else {\r\n return this.selectedCustomer;\r\n } //\r\n }\r\n @Mobx.computed public get isInitialLoadings(): boolean {\r\n if (this.delaerCustomerProfile.length !== 0) {\r\n return false;\r\n }\r\n\r\n if (!this.isLoading) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n @Mobx.computed public get isInitialLoading(): boolean {\r\n if (this.delaerCustomer.length !== 0) {\r\n return false;\r\n }\r\n\r\n if (!this.isLoading) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n @Mobx.action public setSelected({\r\n selected,\r\n }: {\r\n selected: Models.CustomerLicense.Main[];\r\n }) {\r\n this.selected = selected;\r\n \r\n }\r\n\r\n @Mobx.action public setCustomerSelected(isCustomerSelected: boolean) {\r\n this.isCustomerSelected = isCustomerSelected;\r\n console.log(\"selected\" + this.isCustomerSelected);\r\n }\r\n\r\n @Mobx.computed public get getCustomerSelected(): boolean {\r\n if (this.isCustomerSelected === true) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n}\r\n","/** @format */\r\n\r\nimport * as Mui from \"@material-ui/core\";\r\nimport LanguageIcon from \"@material-ui/icons/Language\";\r\nimport * as Formik from \"formik\";\r\nimport * as FormikMui from \"formik-material-ui\";\r\nimport * as Mobx from \"mobx-react-lite\";\r\nimport * as React from \"react\";\r\nimport * as Router from \"react-router-dom\";\r\nimport * as App from \"src/app\";\r\nimport * as MuiIcons from \"@material-ui/icons\";\r\nimport * as ReactI18next from \"react-i18next\";\r\nconst CustomTextField = Mobx.observer(function (\r\n props: FormikMui.TextFieldProps\r\n) {\r\n const activateStore = React.useContext(App.Contexts.license.activateStore);\r\n const easyTouchDeviceStore = React.useContext(\r\n App.Contexts.easyTouchDeviceStore\r\n );\r\n const userStore = React.useContext(App.Contexts.userStore);\r\n const prevValue = React.useRef(\"\");\r\n\r\n const {\r\n form: { setFieldTouched },\r\n field: { name },\r\n } = props;\r\n\r\n const onBlur = React.useCallback(\r\n async (event) => {\r\n const { value } = event.target;\r\n const etuid = userStore.user?.ETUID;\r\n setFieldTouched(name);\r\n if (!value && activateStore.installed.length) {\r\n activateStore.setInstalled({ installed: [] });\r\n }\r\n\r\n if (!value || !etuid || value === prevValue.current) {\r\n prevValue.current = value;\r\n return;\r\n }\r\n\r\n try {\r\n activateStore.setIsLoadingPreviouslyInstalledArticles({\r\n isLoadingPreviouslyInstalledArticles: true,\r\n });\r\n\r\n await easyTouchDeviceStore.read({\r\n userRole: \"customer\",\r\n status: -1,\r\n uid: etuid,\r\n });\r\n\r\n const installed: Set = new Set();\r\n easyTouchDeviceStore.devices\r\n ?.filter((device) => device.macID === value)\r\n .map((device) => {\r\n device.sets.forEach((set) => installed.add(set.setID));\r\n });\r\n\r\n if (installed.size > 0 && activateStore.selected.length > 0) {\r\n activateStore.setSelected({\r\n selected: activateStore.selected.filter(\r\n (setID) => !installed.has(setID)\r\n ),\r\n });\r\n }\r\n\r\n activateStore.setInstalled({\r\n installed: Array.from(installed.values()),\r\n });\r\n } catch (error) {\r\n console.error(error);\r\n } finally {\r\n activateStore.setIsLoadingPreviouslyInstalledArticles({\r\n isLoadingPreviouslyInstalledArticles: false,\r\n });\r\n prevValue.current = value;\r\n }\r\n },\r\n [activateStore, easyTouchDeviceStore, name, setFieldTouched, userStore.user]\r\n );\r\n\r\n return (\r\n <>\r\n \r\n >\r\n );\r\n});\r\n\r\nexport const Form = Mobx.observer(function () {\r\n const theme = Mui.useTheme();\r\n const { t } = ReactI18next.useTranslation();\r\n const { submitCount, submitForm } = Formik.useFormikContext();\r\n\r\n return (\r\n <>\r\n \r\n \r\n \r\n Customer Details\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n Assign Licenses\r\n \r\n \r\n \r\n \r\n \r\n >\r\n );\r\n});\r\n","/** @format */\r\n\r\nimport * as Mui from \"@material-ui/core\";\r\nimport * as Mobx from \"mobx-react-lite\";\r\nimport * as React from \"react\";\r\nimport * as App from \"src/app\";\r\nimport * as AddCustomer from \"src/app/pages/dealercustomer/addcustomer\";\r\nexport const Layout = Mobx.observer(function () {\r\n const licenseStore = React.useContext(App.Contexts.license.store);\r\n const functionStore = React.useContext(App.Contexts.functionStore);\r\n const userStore = React.useContext(App.Contexts.userStore);\r\n\r\n React.useEffect(() => {\r\n const uid = userStore.user?.ETUID;\r\n const userRole = userStore.user?.RoleName ?? \"customer\";\r\n\r\n if (\r\n !licenseStore.licenses?.length &&\r\n userRole === \"customer\" &&\r\n uid !== undefined &&\r\n uid !== null\r\n )\r\n licenseStore.read({\r\n body: { status: null, userID: uid },\r\n userRole,\r\n uid,\r\n });\r\n\r\n if (!functionStore.functions.length) functionStore.read();\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, []);\r\n\r\n return (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n );\r\n});\r\n","/** @format */\r\nimport * as Mui from \"@material-ui/core\";\r\nimport { withStyles } from \"@material-ui/core\";\r\nimport Dialog from \"@material-ui/core/Dialog\";\r\nimport DialogActions from \"@material-ui/core/DialogActions\";\r\nimport DialogContent from \"@material-ui/core/DialogContent\";\r\nimport DialogContentText from \"@material-ui/core/DialogContentText\";\r\nimport DialogTitle from \"@material-ui/core/DialogTitle\";\r\nimport * as MuiIcons from \"@material-ui/icons\";\r\nimport CheckCircleIcon from \"@material-ui/icons/CheckCircle\";\r\nimport InfoIcon from \"@material-ui/icons/Info\";\r\nimport LanguageIcon from \"@material-ui/icons/Language\";\r\nimport * as ReactUndraw from \"iblis-react-undraw\";\r\nimport * as Mobx from \"mobx-react-lite\";\r\nimport * as Notistack from \"notistack\";\r\nimport * as React from \"react\";\r\nimport * as ReactI18next from \"react-i18next\";\r\nimport * as Router from \"react-router-dom\";\r\nimport * as Pages from \"src/app/pages\";\r\n\r\nimport { useLocation } from \"react-router-dom\";\r\nimport * as App from \"src/app\";\r\nimport * as Components from \"src/app/components\";\r\nimport { CustomerInviteSummary } from \"src/app/routes/dealer\";\r\nimport * as Models from \"src/models\";\r\nimport { v4 as uuidv4 } from \"uuid\";\r\nimport * as Yup from \"yup\";\r\nimport * as Services from \"src/services\";\r\nimport * as Constants from \"src/constants\";\r\nexport interface FormProps {\r\n emailID: string;\r\n firstname?: any;\r\n companyName?: any;\r\n lastname?: any;\r\n}\r\n\r\nexport const Main = Mobx.observer(function () {\r\n const [updateDialogOpen, setUpadateRoleDialogOpen] = React.useState<\r\n | {\r\n roles: number;\r\n }\r\n | undefined\r\n >();\r\n const [failureDialogOpen, setfailureRoleDialogOpen] = React.useState<\r\n | {\r\n roles: number;\r\n }\r\n | undefined\r\n >();\r\n\r\n const [purchaseDialogOpen, setfPurchaseDialogOpen] = React.useState<\r\n | {\r\n roles: number;\r\n }\r\n | undefined\r\n >();\r\n //const [modalFlag, setModalFlag] = React.useState(false);\r\n const [open, setOpen] = React.useState(false);\r\n const homeStore = React.useContext(App.Contexts.homeStore);\r\n const [loader, setLoader] = React.useState(false);\r\n const navigate = Router.useNavigate();\r\n const { t } = ReactI18next.useTranslation();\r\n const theme = Mui.useTheme();\r\n // const cartStore = React.useContext(App.Contexts.cartStore);\r\n const userStore = React.useContext(App.Contexts.userStore);\r\n const validationSchema = Yup.object().shape({\r\n emailID: Yup.string().required(\"Email ID is required\"),\r\n });\r\n const [searchParams] = Router.useSearchParams();\r\n\r\n const [isFromManageOrder, setIsFromManageOrder] = React.useState(false);\r\n\r\n const orderStore = React.useContext(App.Contexts.orderStore);\r\n\r\n const customerInviteStore = React.useContext(\r\n App.Contexts.customerInviteStore\r\n );\r\n const importDealerStore = React.useContext(App.Contexts.importDealerStore);\r\n\r\n const addCustomerStore = React.useContext(App.Contexts.addCustomerStore);\r\n const { enqueueSnackbar } = Notistack.useSnackbar();\r\n var orderIdFromPurchaseRedirection = searchParams.get(\"isP\");\r\n var navigationFromManageCustomer = searchParams.get(\"q\");\r\n var navigationFromManageOrder = searchParams.get(\"m\");\r\n //console.log(\"navigationFromManageCustomer\", navigationFromManageCustomer);\r\n React.useEffect(() => {\r\n const result = customerInviteStore.setArticleSelected;\r\n const dealerUser = Array.from(\r\n customerInviteStore.selectedArticle.values()\r\n ).map(\r\n (item) =>\r\n ({\r\n setDescriptions: item.setDescriptions,\r\n setName: item.setName,\r\n setID: item.setID,\r\n } as any)\r\n );\r\n\r\n //alert(JSON.stringify(dealerUser));\r\n\r\n // const ETUID = userStore.user?.ETUID.toString();\r\n\r\n //**********Getting the OrderId from query string******\r\n\r\n //alert(orderIdFromPurchaseRedirection);\r\n if (orderIdFromPurchaseRedirection) {\r\n setOpen(true);\r\n }\r\n\r\n importDealerStore.readUsers({ searchtext:userStore.user?.emailID ?? \"All\", });\r\n\r\n //\r\n //alert(purchaseNavigation);\r\n\r\n // customerInviteStore.getPurchangeArticleDetails({\r\n // orderID: OrderID,\r\n // });\r\n }, [customerInviteStore.setArticleSelected, customerInviteStore.selectedArticle, orderIdFromPurchaseRedirection, importDealerStore, userStore.user]);\r\n \r\n const Email = localStorage.getItem(\"customermailID\")\r\n const cid = localStorage.getItem(\"customerID\")\r\n React.useEffect(()=>{\r\n const userRole = \"customer\"\r\n const EmailId = Email? Email : undefined;\r\n const uid = cid ? cid : \"0\";\r\n if ((uid !== undefined && uid !== null) && Email) {\r\n homeStore.read({\r\n uid,\r\n userRole,\r\n EmailId,\r\n });\r\n }\r\n },[Email, cid, homeStore])\r\n //BindComapnay(OrderID);\r\n\r\n function ArticleUpdateInCart(article: Models.Set.Article) {\r\n const cartStore = React.useContext(App.Contexts.cartStore);\r\n article.olPrice.singleNetPrice = article.setCost;\r\n article.olPrice.grossPositionSinglePriceInclVAT = article.setCost;\r\n article.olPrice.grossPositionTotalPriceInclVAT = article.setCost;\r\n article.olPrice.totalNetPrice = article.setCost;\r\n\r\n if (article.quantity > article.availableQuantity) {\r\n // article.quantity = article.availableQuantity - article.quantity;\r\n cartStore.vatTaxPercent = article.vatPercentage;\r\n cartStore.addProduct({ product: article });\r\n enqueueSnackbar(t(\"Added to cart!\"), {\r\n variant: \"success\",\r\n preventDuplicate: false,\r\n });\r\n }\r\n }\r\n const search = useLocation().search;\r\n const id = new URLSearchParams(search).get(\"isP\");\r\n function ArticleQuantityUpdateAfterPurchase(article: Models.Set.Article) {\r\n // const cartStore = React.useContext(App.Contexts.cartStore);\r\n // article.setCost = 300;\r\n // if (article.quantity > article.availableQuantity) {\r\n // // article.quantity = article.availableQuantity - article.quantity;\r\n // cartStore.addProduct({ product: article });\r\n // }\r\n // const OrderID = \"196\";\r\n purchaseUpdate(id);\r\n async function purchaseUpdate(orderID: any) {\r\n //alert(DealerMasterID);\r\n //alert(DealerProfileID);\r\n // alert('BindComapnay method');\r\n const company = await addCustomerStore.getPurchangeArticleDetails({\r\n orderID: orderID,\r\n });\r\n\r\n //alert(JSON.stringify(company))\r\n const purchaseAvailableQuantity: any = company?.map((k) => ({\r\n setID: k.setID,\r\n availableQuantity: k.availableQuantity,\r\n quantity:\r\n k.setID == article.setID\r\n ? (article.availableQuantity =\r\n +article.availableQuantity + +k.availableQuantity)\r\n : article.availableQuantity,\r\n }));\r\n\r\n //alert(JSON.stringify(purchaseAvailableQuantity));\r\n }\r\n }\r\n\r\n function ArticleIncreaseUpdate(article: Models.Set.Article): void {\r\n\r\n\r\n let validationData = [];\r\n let dashboardReplica:any = [];\r\n dashboardReplica = homeStore.dashboard?.licenseSummary\r\n for (var i = 0; i < dashboardReplica.length; i++) {\r\n dashboardReplica[i].totalQuantity = +dashboardReplica[i].totalQuantity;\r\n }\r\n const dash = dashboardReplica.map((k:any)=>{\r\n return {\r\n hundCode: k.hundCode,\r\n totalQuantity: k.totalQuantity / 4,\r\n setName: k.setName\r\n }\r\n })\r\n \r\n let customerInviteStores:any = Array.from(customerInviteStore.article.values())\r\n // const replacing = cartStores.map(({ quantity }:any) => ({ totalQuantity: quantity}));\r\n // \r\n \r\n for (var j = 0; j < customerInviteStores.length; j++) {\r\n customerInviteStores[j].quantity = +customerInviteStores[j].quantity;\r\n customerInviteStores[j].availableQuantity = +customerInviteStores[j].availableQuantity;\r\n }\r\n const customerInviteStoress = customerInviteStores.map((k:any)=>{\r\n return {\r\n hundCode: k.hundCode,\r\n totalQuantity: k.quantity,\r\n setName: k.setName,\r\n availableQuantity: k.availableQuantity\r\n }\r\n })\r\n \r\n if(dashboardReplica.length > 0 && customerInviteStoress.length > 0){\r\n const result = Object.values([...customerInviteStoress, ...dash].reduce((acc, { hundCode, totalQuantity,setName }) => {\r\n acc[hundCode] = { hundCode, totalQuantity: (acc[hundCode] ? acc[hundCode].totalQuantity : 0) + totalQuantity,setName };\r\n return acc;\r\n }, {}));\r\n validationData = result;\r\n \r\n \r\n }\r\n else if(dashboardReplica.length > 0 && (customerInviteStoress.length === 0 || customerInviteStoress === undefined )){\r\n const dash = dashboardReplica.map((k:any)=>{\r\n return {\r\n hundCode: k.hundCode,\r\n totalQuantity: k.totalQuantity / 4,\r\n setName: k.setName\r\n }\r\n })\r\n validationData = dash\r\n }\r\n else if((dashboardReplica.length === 0 || dashboardReplica === undefined ) && customerInviteStoress.length > 0){\r\n const inviteStore = customerInviteStoress.map((k:any)=>{\r\n return {\r\n hundCode: k.hundCode,\r\n totalQuantity: k.totalQuantity,\r\n setName: k.setName,\r\n availableQuantity: k.availableQuantity\r\n }\r\n })\r\n validationData = inviteStore;\r\n\r\n }\r\n else\r\n {\r\n validationData = [];\r\n }\r\n \r\n \r\n // const validat = validationData.filter((k:any)=>k.hundCode === article.hundCode\r\n \r\n // ).map((k:any)=>k.totalQuantity + 1)\r\n for(var m = 0; m < validationData.length; m++){\r\n if(validationData[m].hundCode === article.hundCode){\r\n validationData[m].totalQuantity = validationData[m].totalQuantity + 1;\r\n }\r\n \r\n }\r\n \r\n const validationCheckfilter = validationData.filter((k:any)=>k.hundCode === article.hundCode)\r\n if(validationCheckfilter.length > 0){\r\n \r\n \r\n }else{\r\n \r\n \r\n validationData.push({\r\n hundCode: article.hundCode,\r\n totalQuantity: 1,\r\n setName: article.setName\r\n })\r\n }\r\n\r\n \r\n const filteringSelectedArticleQuantity = validationData.filter((k:any)=>k.hundCode === article.hundCode).map((k:any)=>k.totalQuantity)\r\n const filteringBasicSetQuantity= validationData.filter((k:any)=>k.hundCode === \"SET-01\").map((k:any)=>k.totalQuantity)\r\n \r\n if(article.hundCode === \"SET-01\"){\r\n customerInviteStore.addProduct({ article: article });\r\n \r\n // const InviteStore = customerInviteStoress.map((k:any)=>{\r\n // return {\r\n // hundCode: k.hundCode,\r\n // totalQuantity: k.quantity,\r\n // setName: k.setName,\r\n // availableQuantity: k.availableQuantity\r\n // }\r\n // })\r\n const quantityOfInvite = customerInviteStoress.filter((k:any)=>k.hundCode === article.hundCode).map((k:any)=>k.totalQuantity)[0]\r\n const availableQuantityOfInvite = customerInviteStoress.filter((k:any)=>k.hundCode === article.hundCode).map((k:any)=>k.availableQuantity)[0]\r\n customerInviteStore.increaseProductQuantity({\r\n article,\r\n });\r\n customerInviteStore.addProduct({ article: article })\r\n if((quantityOfInvite + +1) - availableQuantityOfInvite > 0){\r\n cartStore.addProduct({ product: article })\r\n enqueueSnackbar(t(\"Added to cart!\"), {\r\n variant: \"success\",\r\n preventDuplicate: false,\r\n });\r\n }\r\n }\r\n else if(article.hundCode !== \"SET-01\"){\r\n\r\n const FilteringSelectedArticleQuantityisZeroChecks = filteringSelectedArticleQuantity.length === 0 || filteringSelectedArticleQuantity.length === undefined || filteringSelectedArticleQuantity.length === null ? 0 : filteringSelectedArticleQuantity[0]\r\n const FilteringBasicSetQuantityisZeroChecks = filteringBasicSetQuantity.length === 0 || filteringBasicSetQuantity.length === undefined || filteringBasicSetQuantity.length === null ? 0 : filteringBasicSetQuantity[0]\r\n \r\n const checkForAddToCart = FilteringSelectedArticleQuantityisZeroChecks <= FilteringBasicSetQuantityisZeroChecks \r\n \r\n const inviteStore = customerInviteStoress.map((k:any)=>{\r\n return {\r\n hundCode: k.hundCode,\r\n totalQuantity: k.totalQuantity,\r\n setName: k.setName,\r\n availableQuantity: k.availableQuantity\r\n }\r\n })\r\n const filteringBasicSetQuantityAutomateBasicAdd= inviteStore.filter((k:any)=>k.hundCode === \"SET-01\").map((k:any)=>k.totalQuantity)\r\n const FilteringBasicSetQuantityAutomateBasicAddInvite = filteringBasicSetQuantityAutomateBasicAdd.length === 0 || filteringBasicSetQuantity.length === undefined || filteringBasicSetQuantity.length === null ? 0 : filteringBasicSetQuantity[0]\r\n let isEnableBasicset = false;\r\n if((FilteringBasicSetQuantityisZeroChecks === 0 )&& (FilteringBasicSetQuantityAutomateBasicAddInvite === 0)){\r\n isEnableBasicset = true\r\n const articled:any = customerInviteStore.selectedArticle.filter((k:any) => k.hundCode === \"SET-01\")\r\n \r\n const articles = Object.assign({}, ...articled);\r\n customerInviteStore.increaseProductQuantity({\r\n article,\r\n });\r\n customerInviteStore.addProduct({ article: article });\r\n \r\n // const InviteStore = customerInviteStoress.map((k:any)=>{\r\n // return {\r\n // hundCode: k.hundCode,\r\n // totalQuantity: k.quantity,\r\n // setName: k.setName,\r\n // availableQuantity: k.availableQuantity\r\n // }\r\n // })\r\n const quantityOfInvite = customerInviteStoress.filter((k:any)=>k.hundCode === article.hundCode).map((k:any)=>k.totalQuantity)[0]\r\n const availableQuantityOfInvite = customerInviteStoress.filter((k:any)=>k.hundCode === article.hundCode).map((k:any)=>k.availableQuantity)[0]\r\n customerInviteStore.increaseProductQuantity({\r\n article,\r\n });\r\n customerInviteStore.addProduct({ article: article })\r\n if((quantityOfInvite + +1) - availableQuantityOfInvite > 0){\r\n cartStore.addProduct({ product: article })\r\n enqueueSnackbar(t(\"Added to cart!\"), {\r\n variant: \"success\",\r\n preventDuplicate: false,\r\n });\r\n \r\n }\r\n }else{\r\n isEnableBasicset = false\r\n }\r\n \r\n if((checkForAddToCart === true)|| (isEnableBasicset === true)){\r\n customerInviteStore.increaseProductQuantity({\r\n article,\r\n });\r\n customerInviteStore.addProduct({ article: article });\r\n \r\n // const InviteStore = customerInviteStoress.map((k:any)=>{\r\n // return {\r\n // hundCode: k.hundCode,\r\n // totalQuantity: k.quantity,\r\n // setName: k.setName,\r\n // availableQuantity: k.availableQuantity\r\n // }\r\n // })\r\n const quantityOfInvite = customerInviteStoress.filter((k:any)=>k.hundCode === article.hundCode).map((k:any)=>k.totalQuantity)[0]\r\n const availableQuantityOfInvite = customerInviteStoress.filter((k:any)=>k.hundCode === article.hundCode).map((k:any)=>k.availableQuantity)[0]\r\n // customerInviteStore.increaseProductQuantity({\r\n // article,\r\n // });\r\n // customerInviteStore.addProduct({ article: article })\r\n if((quantityOfInvite + +1) - availableQuantityOfInvite > 0){\r\n cartStore.addProduct({ product: article })\r\n enqueueSnackbar(t(\"Added to cart!\"), {\r\n variant: \"success\",\r\n preventDuplicate: false,\r\n });\r\n \r\n }else{\r\n \r\n }\r\n \r\n }\r\n else\r\n {\r\n enqueueSnackbar(\r\n t(`Basic Set cannot be lesser than the other article, please add Basic Set`),\r\n {\r\n variant: \"warning\",\r\n preventDuplicate: false,\r\n }\r\n );\r\n }\r\n \r\n }\r\n\r\n\r\n\r\n\r\n \r\n }\r\n function ArticleDecreaseUpdate(article: Models.Set.Article): void {\r\n\r\n let product:any = []\r\n product = article\r\n let validationData = [];\r\n let dashboardReplica:any = [];\r\n dashboardReplica = homeStore.dashboard?.licenseSummary\r\n for (var i = 0; i < dashboardReplica.length; i++) {\r\n dashboardReplica[i].totalQuantity = +dashboardReplica[i].totalQuantity;\r\n }\r\n const dash = dashboardReplica.map((k:any)=>{\r\n return {\r\n hundCode: k.hundCode,\r\n totalQuantity: k.totalQuantity / 4,\r\n setName: k.setName\r\n }\r\n })\r\n \r\n let customerInviteStores:any = Array.from(customerInviteStore.article.values())\r\n // const replacing = cartStores.map(({ quantity }:any) => ({ totalQuantity: quantity}));\r\n // \r\n \r\n for (var j = 0; j < customerInviteStores.length; j++) {\r\n customerInviteStores[j].quantity = +customerInviteStores[j].quantity;\r\n }\r\n const invite = customerInviteStores.map((k:any)=>{\r\n return {\r\n hundCode: k.hundCode,\r\n totalQuantity: k.quantity,\r\n setName: k.setName,\r\n availableQuantity: k.availableQuantity\r\n }\r\n })\r\n \r\n if(dashboardReplica.length > 0 && customerInviteStores.length > 0){\r\n const result = Object.values([...invite, ...dash].reduce((acc, { hundCode, totalQuantity,setName,availableQuantity }) => {\r\n acc[hundCode] = { hundCode, totalQuantity: (acc[hundCode] ? acc[hundCode].totalQuantity : 0) + totalQuantity,setName,availableQuantity };\r\n return acc;\r\n }, {}));\r\n validationData = result;\r\n \r\n \r\n }\r\n else if(dashboardReplica.length > 0 && (customerInviteStores.length === 0 || customerInviteStores === undefined )){\r\n const dash = dashboardReplica.map((k:any)=>{\r\n return {\r\n hundCode: k.hundCode,\r\n totalQuantity: k.totalQuantity / 4,\r\n setName: k.setName\r\n }\r\n })\r\n validationData = dash\r\n }\r\n else if((dashboardReplica.length === 0 || dashboardReplica === undefined ) && customerInviteStores.length > 0){\r\n const customerInvite = customerInviteStores.map((k:any)=>{\r\n return {\r\n hundCode: k.hundCode,\r\n totalQuantity: k.quantity,\r\n setName: k.setName,\r\n availableQuantity: k.availableQuantity\r\n }\r\n })\r\n validationData = customerInvite;\r\n \r\n }\r\n else\r\n {\r\n validationData = [];\r\n }\r\n \r\n \r\n if(article.hundCode === \"SET-01\"){\r\n const basicSetQuantity = validationData.filter((k:any)=>k.hundCode === \"SET-01\").map((s:any)=>s.totalQuantity)\r\n \r\n const OtherSetQuantityExceptBasic = validationData.filter((k:any)=>k.hundCode !== \"SET-01\").map((s:any)=>s.totalQuantity)\r\n const maximumQuantityFromOtherSets:any = Math.max(...OtherSetQuantityExceptBasic)\r\n const MaxValue = maximumQuantityFromOtherSets\r\n \r\n const subFunction = (a:number,b:number)=>{\r\n return a - b\r\n }\r\n const oneDecrement = 1\r\n const twoDecrement = parseInt(basicSetQuantity[0])\r\n const subtraction = subFunction(twoDecrement,oneDecrement)\r\n \r\n var comaprator ;\r\n if(subtraction > MaxValue || subtraction === MaxValue){\r\n comaprator = true\r\n }\r\n else {\r\n comaprator = false\r\n \r\n }\r\n \r\n \r\n if(comaprator){\r\n customerInviteStore.decreaseProductQuantity({article});\r\n cartStore.decreaseProductQuantity({product});\r\n \r\n \r\n }\r\n else{\r\n enqueueSnackbar(\r\n t(`Basic Set cannot be lesser than the other article, please add Basic Set`),\r\n {\r\n variant: \"warning\",\r\n preventDuplicate: false,\r\n }\r\n );\r\n }\r\n }\r\n else if(article.hundCode !== \"SET-01\"){\r\n const basicSetQuantity = validationData.filter((k:any)=>k.hundCode === \"SET-01\").map((s:any)=>s.totalQuantity)\r\n \r\n const selectedQuantity = validationData.filter((k:any)=>k.hundCode === article.hundCode).map((s:any)=>s.totalQuantity)\r\n const oneDecrement = 1\r\n if((selectedQuantity[0] - oneDecrement) <= basicSetQuantity[0]){\r\n customerInviteStore.decreaseProductQuantity({article});\r\n cartStore.decreaseProductQuantity({product});\r\n \r\n \r\n }\r\n else{\r\n enqueueSnackbar(\r\n t(`Basic Set cannot be lesser than the other article, please add Basic Set`),\r\n {\r\n variant: \"warning\",\r\n preventDuplicate: false,\r\n }\r\n );\r\n }\r\n \r\n }\r\n \r\n }\r\n\r\n const handleRemoveSelect = ({ article }: { article: any }) => {\r\n // alert(\"Hi\");\r\n //alert(JSON.stringify(article));\r\n\r\n const selectedIndex = customerInviteStore.selected.indexOf(article.setID);\r\n //alert(JSON.stringify(selectedIndex));\r\n let newSelected: number[] = [];\r\n let newRowSelected: Models.Set.Article[] = [];\r\n //alert('handleSelect');\r\n if (selectedIndex === -1) {\r\n newSelected = newSelected.concat(\r\n customerInviteStore.selected,\r\n article.setID\r\n );\r\n newRowSelected = newRowSelected.concat(\r\n customerInviteStore.selectedArticle,\r\n article\r\n );\r\n } else if (selectedIndex === 0) {\r\n } else if (selectedIndex === customerInviteStore.selected.length - 1) {\r\n newSelected = newSelected.concat(\r\n customerInviteStore.selected.slice(0, -1)\r\n );\r\n newRowSelected = newRowSelected.concat(\r\n customerInviteStore.selectedArticle.slice(0, -1)\r\n );\r\n } else if (selectedIndex > 0) {\r\n newSelected = newSelected.concat(\r\n customerInviteStore.selected.slice(0, selectedIndex),\r\n customerInviteStore.selected.slice(selectedIndex + 1)\r\n );\r\n newRowSelected = newRowSelected.concat(\r\n customerInviteStore.selectedArticle.slice(0, selectedIndex),\r\n customerInviteStore.selectedArticle.slice(selectedIndex + 1)\r\n );\r\n // setDisable(false);\r\n }\r\n\r\n customerInviteStore.setArticleSelected({ selectedArticle: newRowSelected });\r\n customerInviteStore.setSelected({ selected: newSelected });\r\n };\r\n //const [isPurchase, setIsPurchase] = React.useState(true);\r\n const purchaseEnableFromInviteCustomer = Array.from(\r\n customerInviteStore.article.values()\r\n )\r\n .map((k) => k)\r\n .some((k) => (k.quantity > k.availableQuantity ? true : false));\r\n //alert(purchaseEnableFromInviteCustomer);\r\n localStorage.setItem(\r\n \"isCustomerInvitePurchase\",\r\n JSON.stringify(purchaseEnableFromInviteCustomer)\r\n );\r\n\r\n const fName = localStorage.getItem(\"cfname\");\r\n const lName = localStorage.getItem(\"clname\");\r\n const cName = localStorage.getItem(\"ccname\");\r\n const mailI = localStorage.getItem(\"mailId\");\r\n\r\n localStorage.setItem(\"nfname\", JSON.stringify(fName));\r\n localStorage.setItem(\"nlname\", JSON.stringify(lName));\r\n localStorage.setItem(\"ncname\", JSON.stringify(cName));\r\n localStorage.setItem(\"nmailId\", JSON.stringify(mailI));\r\n const DarkerDisabledTextField = withStyles({\r\n root: {\r\n marginRight: 8,\r\n \"& .MuiInputBase-root.Mui-disabled\": {\r\n color: \"black\", // (default alpha is 0.38)\r\n },\r\n },\r\n })(Mui.TextField);\r\n\r\n var quantityUpdate = Array.from(\r\n customerInviteStore.article.values()\r\n ).map((k) =>\r\n k.quantity > k.availableQuantity\r\n ? { setID: k.setID, quantity: k.quantity }\r\n : \"\"\r\n );\r\n\r\n const cartStore = React.useContext(App.Contexts.cartStore);\r\n\r\n const handleClose = () => {\r\n setOpen(false);\r\n };\r\n \r\n const isPurchase = localStorage.getItem(\"isCustomerInvitePurchase\");\r\n const purchaseCheck = isPurchase == \"true\" ? false : true;\r\n const sendInviteCheck = isPurchase == \"true\" ? true : false;\r\n const { i18n } = ReactI18next.useTranslation(); \r\n const localdisplayCustomerDetailCard = localStorage.getItem(\r\n \"displayCustomerDetailCard\"\r\n );\r\n var checkDisplay = localdisplayCustomerDetailCard === \"true\";\r\n const licenseList = orderStore.getAssignLicense();\r\n\r\n React.useEffect(() => {\r\n const custID = localStorage.getItem(\"customerID\");\r\n\r\n \r\n });\r\n \r\n const handleSendInvite = async () => {\r\n try {\r\n \r\n let newSelected: number[] = [];\r\n customerInviteStore.setSelected({\r\n selected: newSelected,\r\n });\r\n const articleIds = Array.from(\r\n customerInviteStore.article.values()\r\n ).map(\r\n (item) =>\r\n ({\r\n setId: item.setID,\r\n setName: item.setName,\r\n hundCode: item.hundCode,\r\n assignedQuantity: item.quantity,\r\n } as Models.InviteCustomer.InviteArticle)\r\n );\r\n const dealerEmail = userStore.user?.UserEmail;\r\n const fName = localStorage.getItem(\"cfname\");\r\n const lName = localStorage.getItem(\"clname\");\r\n const cName = localStorage.getItem(\"ccname\");\r\n const mailI = localStorage.getItem(\"mailId\");\r\n const custID = localStorage.getItem(\"customerID\");\r\n const dealerFirstName = userStore.user?.FirstName;\r\n const dealerLastName = userStore.user?.LastName;\r\n const dealerName = dealerFirstName+\" \"+dealerLastName;\r\n var dealerCompany = importDealerStore.importDealer.map((k) => k.companyName)[0];\r\n if(navigationFromManageOrder !== \"ManageOrder\"){\r\n const inviteCustomer: Models.InviteCustomer.Main = {\r\n EmailID: mailI ? mailI : \"\",\r\n CompanyName: cName ? cName : \"\",\r\n FirstName: fName ? fName : \"\",\r\n LastName: lName ? lName : \"\",\r\n ETUID: userStore.user?.RoleName === \"dealer\"? userStore.user?.ETUID: localStorage.getItem(\"etID\") ?? \"\",\r\n DealerEmail: dealerEmail ? dealerEmail : \"\",\r\n DealerName: dealerFirstName ? dealerName : \"\",\r\n langCode: i18n.language, \r\n DealerCompanyName: dealerCompany,\r\n IsExsitingCustomer: navigationFromManageCustomer\r\n ? custID\r\n : \"0\",\r\n SerialNumber: articleIds,\r\n };\r\n var result = await addCustomerStore.inviteCustomer({\r\n body: inviteCustomer,\r\n });\r\n }else{\r\n var licenses\r\n if(licenseList !== undefined ){\r\n licenses = licenseList.map((k:Models.License)=>{\r\n return{\r\n setID : k.setID,\r\n setName : k.setName,\r\n hundCode : k.setCode,\r\n assignedQuantity : 1,\r\n licenseCode: k.licenseCode,\r\n OrderDetailID: k.orderDetailID,\r\n }\r\n })}\r\n const inviteCustomer: Models.InviteFromManageOrder.Main = {\r\n EmailID: mailI ? mailI : \"\",\r\n CompanyName: cName ? cName : \"\",\r\n FirstName: fName ? fName : \"\",\r\n LastName: lName ? lName : \"\",\r\n ETUID: userStore.user?.ETUID,\r\n DealerEmail: userStore.user?.UserEmail ?? \"\",\r\n DealerName: userStore.user?.FirstName + \" \"+userStore.user?.LastName,\r\n langCode: i18n.language, \r\n DealerCompanyName: userStore.user?.CompanyName,\r\n IsExsitingCustomer: \"0\",\r\n AssignAll: localStorage.getItem(\"isAssignAl\") === \"0\" ? 0 : 1,\r\n OrderCode:localStorage.getItem(\"orderCode\") ?? \"\",\r\n SerialNumber: licenses,\r\n };\r\n \r\n var result = await addCustomerStore.inviteFromManageOrder({\r\n body: inviteCustomer,\r\n });\r\n }\r\n if (result != \"\") {\r\n setUpadateRoleDialogOpen({ roles: 1 });\r\n } else {\r\n setfailureRoleDialogOpen({ roles: 1 });\r\n }\r\n }\r\n catch (error) {\r\n throw error;\r\n }\r\n}\r\n const handlePurchase = async () => {\r\n window.location.href = 'https://www.kern-sohn.com/shop/en/products/software/easytouch'\r\n // Array.from(customerInviteStore.selectedArticle).map(\r\n // (item) =>\r\n // (({\r\n // setID: item.setID,\r\n // setName: item.setName,\r\n // setDescriptions: item.setDescriptions,\r\n // createdBy: item.createdBy,\r\n // createdOn: item.createdOn,\r\n // functions: item.functions,\r\n // hundCode: item.hundCode,\r\n // iconClass: item.iconClass,\r\n // industrySegment: item.industrySegment,\r\n // industrySegmentsId: item.industrySegmentsId,\r\n // isItFree: item.isItFree, \r\n // langId: item.langId,\r\n // licensePerSet: item.licensePerSet,\r\n // modifiedBy: item.modifiedBy,\r\n // modifiedOn: item.modifiedOn,\r\n // moreInfo: item.setCode,\r\n // setCode: item.setID,\r\n // setCost: item.setCost,\r\n // setsLang: item.setsLang,\r\n // status: item.status,\r\n // validityPeriod: item.validityPeriod,\r\n // vatPercentage: item.vatPercentage,\r\n // quantity: item.quantity,\r\n // availableQuantity: item.availableQuantity,\r\n // olPrice: item.olPrice,\r\n // dependentSets: item.dependentSets,\r\n // } as unknown) as Models.Set.Article)\r\n // );\r\n \r\n // navigate(\"/shop/cart\");\r\n }\r\n\r\n return (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n Customer company selected for customer invite\r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n {checkDisplay == true ? (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {cName}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Company details\r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Email ID\r\n \r\n \r\n \r\n \r\n \r\n {window.open(`mailto:${mailI}`)}}\r\n >\r\n \r\n click to open an mail\r\n }>{mailI}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n First name\r\n \r\n \r\n \r\n \r\n \r\n \r\n {fName}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n Last name\r\n \r\n \r\n \r\n \r\n \r\n {lName}\r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n ) : (\r\n <>\r\n \r\n \r\n \r\n \r\n Customer details\r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n )}\r\n \r\n \r\n \r\n \r\n \r\n \r\n Selected license\r\n \r\n\r\n \r\n }\r\n />\r\n {Array.from(customerInviteStore.article.values()).length > 0 ? (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n Model\r\n \r\n \r\n \r\n \r\n Product\r\n \r\n \r\n \r\n \r\n {/* Price excl. VAT */}\r\n \r\n \r\n \r\n \r\n Quantity\r\n \r\n \r\n \r\n \r\n Available\r\n \r\n \r\n \r\n \r\n To be purchased\r\n \r\n \r\n \r\n \r\n Remove\r\n \r\n \r\n \r\n \r\n \r\n {Array.from(customerInviteStore.article.values()).map(\r\n (article) => (\r\n \r\n \r\n {article.hundCode}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {article.setName}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ArticleDecreaseUpdate(article)\r\n }\r\n handleIncrement={() =>\r\n \r\n ArticleIncreaseUpdate(article)\r\n }\r\n style={{ justifyContent: \"flex-end\" }}\r\n />\r\n \r\n \r\n {article.availableQuantity ? article.availableQuantity : 0}\r\n \r\n \r\n {(article.quantity - article.availableQuantity) < 0 ? 0: article.quantity - article.availableQuantity}\r\n \r\n \r\n {\r\n enqueueSnackbar(\r\n t(`SET-01 is a dependent for your selected license, hence it cannot be removed`),\r\n {\r\n variant: \"warning\",\r\n preventDuplicate: false,\r\n }\r\n );\r\n })()\r\n : (() => {\r\n const totalBasicSetInCartStore = Array.from(\r\n customerInviteStore.article.values()\r\n ).filter((item) => item.setID !== 1).map((k) => k);\r\n\r\n const lengthCheckOfExceptBasicSetFromCart = totalBasicSetInCartStore.length;\r\n if(lengthCheckOfExceptBasicSetFromCart > 0 && article.setID === 1){\r\n enqueueSnackbar(\r\n t(`SET-01 is a dependent for your selected license, hence it cannot be removed`),\r\n {\r\n variant: \"warning\",\r\n preventDuplicate: false,\r\n }\r\n );\r\n }else{\r\n customerInviteStore.removeProduct({\r\n article,\r\n });\r\n let product = [];\r\n product = article;\r\n cartStore.removeProduct({ product });\r\n handleRemoveSelect({ article });\r\n }\r\n\r\n })();\r\n\r\n \r\n }}\r\n >\r\n \r\n \r\n \r\n \r\n )\r\n )}\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n Add more license\r\n \r\n \r\n {sendInviteCheck && (\r\n \r\n {loader?:\r\n Purchase\r\n } \r\n \r\n )}\r\n {purchaseCheck && (\r\n \r\n \r\n Assign license\r\n \r\n \r\n )}\r\n \r\n \r\n >\r\n ) : (\r\n navigationFromManageOrder === \"ManageOrder\" ? <> \r\n \r\n \r\n Assign license\r\n \r\n \r\n >: \r\n \r\n \r\n \r\n No articles are assigned\r\n \r\n \r\n \r\n \r\n Please click on the Assign license to add the article.\r\n \r\n \r\n \r\n \r\n \r\n Assign licenses\r\n \r\n \r\n \r\n \r\n )}\r\n \r\n \r\n\r\n \r\n {/* Failure Response pop up start*/}\r\n \r\n {/* Failure pop up end */}\r\n \r\n >\r\n );\r\n});\r\n","/** @format */\r\n\r\nimport * as Mobx from \"mobx\";\r\nimport * as Article from \"src/app/pages/article\";\r\nimport * as Models from \"src/models\";\r\nimport * as Services from \"src/services\";\r\n\r\nexport declare namespace Store {\r\n export interface IStore {\r\n isLoading: boolean;\r\n addCustomer: Models.AddDealer.Main | undefined;\r\n addCustomerService: Services.AddCustomer;\r\n }\r\n\r\n export type Options = {\r\n addCustomerService: Services.AddCustomer;\r\n articleStore: Article.Store;\r\n };\r\n\r\n export namespace InviteCustomer {\r\n export interface Props\r\n extends Services.InviteCustomerService.InviteCustomer.Props {}\r\n }\r\n export namespace InviteFromManageOrder {\r\n export interface Props\r\n extends Services.AddCustomer.InviteFromManageOrder.Props {}\r\n }\r\n\r\n export namespace Read {\r\n export interface Props extends Services.AddCustomer.GetAllData.Return {}\r\n }\r\n export namespace GetAllPurchanseSetData {\r\n export interface Props {\r\n orderID?: string | any;\r\n }\r\n export type Return = Models.API.Response;\r\n }\r\n export namespace cancelInvite {\r\n export type Props = Services.AddCustomer.CancelInvite.Props;\r\n export type Return = Models.API.Response;\r\n }\r\n\r\n export namespace unassignAll {\r\n export type Props = Services.AddCustomer.UnAssignAll.Props;\r\n export type Return = Models.API.Response;\r\n }\r\n\r\n export namespace cancelInviteForSingleLicense {\r\n export type Props = Services.AddCustomer.CancelInviteForSingleLicense.Props;\r\n export type Return = Models.API.Response;\r\n }\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare\r\nexport class Store implements Store.IStore {\r\n @Mobx.observable public addCustomer: Models.AddDealer.Main | undefined;\r\n\r\n @Mobx.observable public isLoading: boolean = false;\r\n public addCustomerService: Services.AddCustomer;\r\n articleStore: Article.Store;\r\n constructor({ addCustomerService, articleStore }: Store.Options) {\r\n this.addCustomerService = addCustomerService;\r\n this.articleStore = articleStore;\r\n }\r\n\r\n @Mobx.action public async readUsers() {\r\n try {\r\n this.isLoading = true;\r\n const { result } = await this.addCustomerService.getAllData();\r\n this.addCustomer = result;\r\n } catch (error) {\r\n console.error(error);\r\n } finally {\r\n this.isLoading = false;\r\n }\r\n }\r\n\r\n @Mobx.action public async inviteCustomer(props: Store.InviteCustomer.Props) {\r\n try {\r\n this.isLoading = true;\r\n const { result } = await this.addCustomerService.inviteCustomer(props);\r\n return result;\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n @Mobx.action public async inviteFromManageOrder(\r\n props: Store.InviteFromManageOrder.Props\r\n ) {\r\n try {\r\n this.isLoading = true;\r\n const { result } = await this.addCustomerService.inviteFromManageOrder(\r\n props\r\n );\r\n return result;\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n\r\n @Mobx.action public async getPurchangeArticleDetails(\r\n props: Store.GetAllPurchanseSetData.Props\r\n ) {\r\n try {\r\n this.isLoading = true;\r\n const result = await this.articleStore.readCustomerInvitePurchange({\r\n orderID: props?.orderID,\r\n });\r\n return result;\r\n } catch (error) {\r\n console.error(error);\r\n } finally {\r\n this.isLoading = false;\r\n }\r\n }\r\n @Mobx.action public async cancelInvite(props: Store.cancelInvite.Props) {\r\n try {\r\n this.isLoading = true;\r\n const result = await this.addCustomerService.cancelInvite(props);\r\n return result;\r\n } catch (error) {\r\n console.error(error);\r\n } finally {\r\n this.isLoading = false;\r\n }\r\n }\r\n\r\n @Mobx.action public async unAssignAll(props: Store.unassignAll.Props) {\r\n try {\r\n this.isLoading = true;\r\n const result = await this.addCustomerService.unAssignAll(props);\r\n return result;\r\n } catch (error) {\r\n console.error(error);\r\n } finally {\r\n this.isLoading = false;\r\n }\r\n }\r\n\r\n @Mobx.action public async cancelInviteForSingleLicense(\r\n props: Store.cancelInviteForSingleLicense.Props\r\n ) {\r\n try {\r\n this.isLoading = true;\r\n const result = await this.addCustomerService.cancelInviteForSingleLicense(\r\n props\r\n );\r\n return result;\r\n } catch (error) {\r\n console.error(error);\r\n } finally {\r\n this.isLoading = false;\r\n }\r\n }\r\n}\r\n","import * as Mui from \"@material-ui/core\";\r\nimport Numeral from \"numeral\";\r\nimport * as React from \"react\";\r\nimport * as ReactI18next from \"react-i18next\";\r\nimport * as Containers from \"src/app/containers\";\r\nimport * as Models from \"src/models\";\r\nimport * as DateFns from \"date-fns\";\r\nimport * as Components from \"src/app/components\";\r\n\r\nexport declare namespace Card {\r\n export interface Props {\r\n order: Models.Order.Main;\r\n handleClick?(props: { orderId: number | string , OrderedOn: any }): void;\r\n \r\n }\r\n}\r\n// eslint-disable-next-line no-redeclare\r\n\r\n// eslint-disable-next-line no-redeclare\r\nexport function Card({ order, handleClick }: Card.Props) {\r\n const [language,setLanguage] = React.useState('en-IN');\r\n const { i18n } = ReactI18next.useTranslation();\r\n const languageValue = i18n.language\r\n React.useEffect(()=>{\r\n if(languageValue === \"en\"){\r\n setLanguage('en-IN')\r\n }else if(languageValue === \"fr\")\r\n {\r\n setLanguage('fr-FR')\r\n }\r\n else{\r\n setLanguage('de-DE')\r\n }\r\n },[languageValue])\r\n const CardInternals = (\r\n <>\r\n \r\n \r\n Order #\r\n \r\n {order.dataFrom === \"webshop\" && order.sageOLReferenceBillID != null && order.sageOLReferenceBillID > 0 && order.assignedTo === \"0\"? order.orderCode+\"-\"+order.sageOLReferenceBillID : order.orderCode}\r\n >\r\n }\r\n />\r\n \r\n \r\n \r\n <>\r\n \r\n \r\n Status\r\n \r\n \r\n \r\n {/* {DateFns.format(new Date(order.orderedOn), \"dd.MM.yyyy\")} */}\r\n \r\n \r\n >\r\n \r\n \r\n >\r\n );\r\n \r\n \r\n return (\r\n \r\n {handleClick ? (\r\n handleClick({ orderId: order.orderID,OrderedOn: order.orderedOn})}\r\n >\r\n {CardInternals}\r\n \r\n ) : (\r\n CardInternals\r\n )}\r\n \r\n );\r\n}\r\n","/** @format */\r\n\r\nimport * as Mui from \"@material-ui/core\";\r\nimport * as MuiLab from \"@material-ui/lab\";\r\nimport * as React from \"react\";\r\nimport * as ReactI18next from \"react-i18next\";\r\nimport * as Components from \"src/app/components\";\r\nimport * as Order from \"src/app/pages/order\";\r\nimport * as Models from \"src/models\";\r\nimport { v4 as uuidv4 } from \"uuid\";\r\nimport * as Services from \"src/services\";\r\nimport * as App from \"src/app\";\r\nimport * as Constants from \"src/constants\";\r\nimport { CustomerDetail } from \"src/app/routes/dealer\";\r\nimport { Pages } from \"@material-ui/icons\";\r\nimport { Card } from \"../card\";\r\n\r\ninterface Data extends Models.Order.Main {}\r\n\r\nfunction stableSort(array: T[], comparator: (a: T, b: T) => number) {\r\n const stabilizedThis = array.map((el, index) => [el, index] as [T, number]);\r\n stabilizedThis.sort((a, b) => {\r\n const order = comparator(a[0], b[0]);\r\n if (order !== 0) return order;\r\n return a[1] - b[1];\r\n });\r\n return stabilizedThis.map((el) => el[0]);\r\n}\r\n\r\ntype Order = \"asc\" | \"desc\";\r\n\r\nfunction getComparator(\r\n order: Order,\r\n orderBy: Key\r\n): (\r\n a: { [key in Key]: number | string },\r\n b: { [key in Key]: number | string }\r\n) => number {\r\n return order === \"asc\"\r\n ? (a, b) => descendingComparator(a, b, orderBy)\r\n : (a, b) => -descendingComparator(a, b, orderBy);\r\n}\r\n\r\nfunction descendingComparator(a: T, b: T, orderBy: keyof T) {\r\n if (b[orderBy] < a[orderBy]) {\r\n return -1;\r\n }\r\n if (b[orderBy] > a[orderBy]) {\r\n return 1;\r\n }\r\n return 0;\r\n}\r\n\r\nexport declare namespace Cards {\r\n export interface Props {\r\n orders: Models.Order.Main[];\r\n }\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare\r\nexport function Cards({ orders }: Cards.Props) {\r\n const theme = Mui.useTheme();\r\n const { t } = ReactI18next.useTranslation();\r\n const userStore = React.useContext(App.Contexts.userStore);\r\n\r\n const [orderId, setOrderId] = React.useState();\r\n const [orderCode, setOrderCode] = React.useState();\r\n const [orderDetailsDialogOpen, setOrderDetailsDialogOpen] = React.useState<\r\n boolean\r\n >(false);\r\n const [orderedOn,setOrderedOn] = React.useState();\r\n const [page, setPage] = React.useState(0);\r\n const [rowsPerPage] = React.useState(16);\r\n const orderServices = new Services.Order({\r\n httpManager: new Services.Managers.Axios({ agent: App.axios }),\r\n urlFactory: new Services.Factories.URL({\r\n protocol: Constants.environment.apiBaseUrlProtocol as \"http\",\r\n hostname: Constants.environment.apiBaseUrlHostname,\r\n version: Constants.environment.apiBaseUrlVersion,\r\n }),\r\n });\r\n React.useEffect(() => {\r\n setPage(0);\r\n }, [orders]);\r\n \r\n React.useEffect(() => {\r\n (async function () {\r\n const uid = userStore.user?.ETUID;\r\n if (!orderId) {\r\n return;\r\n }\r\n\r\n try {\r\n const {\r\n result: [order],\r\n } = await orderServices.getData({\r\n body: { id: orderId, cid: uid },\r\n });\r\n \r\n var {result} = await orderServices.getData({\r\n body: { id: orderId, cid: uid },\r\n });\r\n\r\n //overAllStatus = 3 -- > Order completely returned\r\n if(result.find((k:any)=>k.status === 3)){\r\n order.overAllStatus = 3\r\n var partialReturnOrderObjectForStatus3 = result.find((k:any)=>k.status === 2);\r\n partialReturnOrderObjectForStatus3?.orderDetails.map((k:any)=>{\r\n // eslint-disable-next-line array-callback-return\r\n order.orderDetails.map((q:any)=>{\r\n if(q.setID === k.setID ){\r\n q.returnQuantity = k.quantity\r\n }\r\n })\r\n })\r\n } \r\n //overAllStatus = 2 -- > Order paretially returned\r\n else if(result.find((k:any)=>k.status === 4)){\r\n order.overAllStatus = 4\r\n var partialReturnOrderObjectForStatus4 = result.find((k:any)=>k.status === 2);\r\n partialReturnOrderObjectForStatus4?.orderDetails.map((k:any)=>{\r\n // eslint-disable-next-line array-callback-return\r\n order.orderDetails.map((q:any)=>{\r\n if(q.setID === k.setID ){\r\n q.returnQuantity = k.quantity\r\n }\r\n })\r\n })\r\n // \r\n \r\n } \r\n else if(result.find((k:any)=>k.status === 5)){\r\n order.overAllStatus = 5\r\n var partialReturnOrderObjectForStatus5 = result.find((k:any)=>k.status === 2);\r\n partialReturnOrderObjectForStatus5?.orderDetails.map((k:any)=>{\r\n // eslint-disable-next-line array-callback-return\r\n order.orderDetails.map((q:any)=>{\r\n if(q.setID === k.setID ){\r\n q.returnQuantity = k.quantity\r\n }\r\n })\r\n })\r\n // \r\n \r\n } \r\n //overAllStatus = 1 -- > Order paretially returned Order with no return\r\n else{\r\n order.overAllStatus = 1\r\n }\r\n \r\n setOrders(order);\r\n \r\n } catch (error) {\r\n console.error(error);\r\n }\r\n })();\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, [orderDetailsDialogOpen]);\r\n const handleChangePage = (event: unknown, newPage: number) => {\r\n setPage(newPage);\r\n };\r\n const useStyles = Mui.makeStyles((theme) =>\r\n Mui.createStyles({\r\n \r\n title: {\r\n flexGrow: 1,\r\n },\r\n })\r\n);\r\n\r\nconst key = 'orderCode';\r\nconst [order, setOrders] = React.useState();\r\n\r\nconst orderArrayUniqueByKey = [...new Map(orders.map(item =>\r\n [item[key], item])).values()];\r\n\r\n // \r\nconst classes = useStyles();\r\n return (\r\n <>\r\n setOrderDetailsDialogOpen(false)}\r\n content={}\r\n title={\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n Order details\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n }\r\n actions={\r\n <>\r\n setOrderDetailsDialogOpen(false)}>\r\n CLOSE\r\n \r\n {\r\n window.print();\r\n }}\r\n >\r\n Print\r\n \r\n >\r\n }\r\n />\r\n\r\n \r\n {stableSort(orderArrayUniqueByKey as any, getComparator(\"asc\", \"orderCode\"))\r\n .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)\r\n .map((order, index) => (\r\n \r\n {\r\n setOrderDetailsDialogOpen(true);\r\n setOrderId(orderId);\r\n setOrderCode(order.orderCode)\r\n setOrderedOn(OrderedOn)\r\n }}\r\n order={(order as unknown) as Models.Order.Main}\r\n />\r\n \r\n ))}\r\n {orders.length === 0 && (\r\n \r\n \r\n No orders found\r\n \r\n \r\n )}\r\n \r\n {orders.length > 7 && (\r\n \r\n handleChangePage(event, page - 1)}\r\n shape=\"rounded\"\r\n />\r\n \r\n )}\r\n >\r\n );\r\n}\r\n","import * as Mobx from \"mobx-react-lite\";\r\nimport * as React from \"react\";\r\nimport * as App from \"src/app\";\r\nimport * as Components from \"src/app/components\";\r\nimport * as Constants from \"src/constants\";\r\nimport * as Services from \"src/services\";\r\n\r\nexport declare namespace Details {\r\n export interface Props {\r\n orderId?: string | number;\r\n cid?: string | number;\r\n orderCode?: string | number | undefined;\r\n orderedOn?: string | number ;\r\n isDealer?: boolean ;\r\n }\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare\r\nexport const Details = Mobx.observer(function ({\r\n orderedOn,\r\n orderId,\r\n cid,\r\n orderCode,\r\n isDealer = false,\r\n}: Details.Props) {\r\n const [order, setOrder] = React.useState();\r\n const userStore = React.useContext(App.Contexts.userStore);\r\n const uid = userStore.user?.ETUID;\r\n const orderServices = new Services.Order({\r\n httpManager: new Services.Managers.Axios({ agent: App.axios }),\r\n urlFactory: new Services.Factories.URL({\r\n protocol: Constants.environment.apiBaseUrlProtocol as \"http\",\r\n hostname: Constants.environment.apiBaseUrlHostname,\r\n version: Constants.environment.apiBaseUrlVersion,\r\n }),\r\n });\r\n\r\n React.useEffect(() => {\r\n (async function () {\r\n // \r\n if (!orderId) {\r\n return;\r\n }\r\n\r\n try {\r\n //alert('Order');\r\n const {\r\n result: [order],\r\n } = await orderServices.getData({\r\n body: { id: orderId, cid: cid },\r\n });\r\n \r\n var {result} = await orderServices.getData({\r\n body: { id: orderId, cid: cid },\r\n });\r\n\r\n //overAllStatus = 3 -- > Order completely returned\r\n if(result.find(k=>k.status === 3)){\r\n order.overAllStatus = 3\r\n var partialReturnOrderObjectForStatus3 = result.find(k=>k.status === 2);\r\n partialReturnOrderObjectForStatus3?.orderDetails.map((k)=>{\r\n // eslint-disable-next-line array-callback-return\r\n order.orderDetails.map((q)=>{\r\n if(q.setID === k.setID ){\r\n q.returnQuantity = k.quantity\r\n }\r\n })\r\n })\r\n } \r\n\r\n //overAllStatus = 2 -- > Order paretially returned\r\n else if(result.find(k=>k.status === 4)){\r\n order.overAllStatus = 4\r\n var partialReturnOrderObjectForStatus4 = result.find(k=>k.status === 2);\r\n partialReturnOrderObjectForStatus4?.orderDetails.map((k)=>{\r\n // eslint-disable-next-line array-callback-return\r\n order.orderDetails.map((q)=>{\r\n if(q.setID === k.setID ){\r\n q.returnQuantity = k.quantity\r\n }\r\n })\r\n })\r\n // \r\n \r\n } \r\n else if(result.find(k=>k.status === 5)){\r\n order.overAllStatus = 5\r\n var partialReturnOrderObjectForStatus5 = result.find(k=>k.status === 2);\r\n partialReturnOrderObjectForStatus5?.orderDetails.map((k)=>{\r\n // eslint-disable-next-line array-callback-return\r\n order.orderDetails.map((q)=>{\r\n if(q.setID === k.setID ){\r\n q.returnQuantity = k.quantity\r\n }\r\n })\r\n })\r\n // \r\n \r\n } \r\n //overAllStatus = 1 -- > Order paretially returned Order with no return\r\n else{\r\n order.overAllStatus = 1\r\n }\r\n \r\n setOrder(order);\r\n \r\n localStorage.setItem(\"orderStatus\",JSON.stringify(order.overAllStatus))\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n })();\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, []);\r\n\r\n return (\r\n <>\r\n \r\n >\r\n );\r\n});\r\n","/** @format */\r\n\r\nimport * as Mui from \"@material-ui/core\";\r\nimport * as MuiIcons from \"@material-ui/icons\";\r\nimport * as MuiLab from \"@material-ui/lab\";\r\nimport * as Mobx from \"mobx-react-lite\";\r\nimport * as Notistack from \"notistack\";\r\nimport * as React from \"react\";\r\nimport SwipeableViews from \"react-swipeable-views\";\r\nimport * as ReactI18next from \"react-i18next\";\r\nimport * as Router from \"react-router-dom\";\r\nimport * as App from \"src/app\";\r\nimport * as Article from \"src/app/pages/article\";\r\nimport * as DateFns from \"date-fns\";\r\nimport * as Containers from \"src/app/containers\";\r\nimport * as Components from \"src/app/components\";\r\nimport * as Models from \"src/models\";\r\nimport { v4 as uuidv4 } from \"uuid\";\r\nimport { makeStyles, Theme } from \"@material-ui/core\";\r\nimport * as CustomerDetail from \"src/app/pages/dealercustomer/customerdetail\";\r\nimport { withStyles } from \"@material-ui/core\";\r\nimport * as Services from \"src/services\";\r\nimport * as Constants from \"src/constants\";\r\nimport * as MuiIcon from \"@material-ui/icons\";\r\n\r\ninterface Data extends Models.Order.Main {}\r\n\r\nfunction descendingComparator(a: T, b: T, orderBy: keyof T) {\r\n if (b[orderBy] < a[orderBy]) {\r\n return -1;\r\n }\r\n if (b[orderBy] > a[orderBy]) {\r\n return 1;\r\n }\r\n return 0;\r\n}\r\n\r\ntype Order = \"asc\" | \"desc\";\r\n\r\nfunction getComparator(\r\n order: Order,\r\n orderBy: Key\r\n): (\r\n a: { [key in Key]: number | string },\r\n b: { [key in Key]: number | string }\r\n) => number {\r\n return order === \"asc\"\r\n ? (a, b) => descendingComparator(a, b, orderBy)\r\n : (a, b) => -descendingComparator(a, b, orderBy);\r\n}\r\n\r\nfunction stableSort(array: T[], comparator: (a: T, b: T) => number) {\r\n const stabilizedThis = array.map((el, index) => [el, index] as [T, number]);\r\n stabilizedThis.sort((a, b) => {\r\n const order = comparator(a[0], b[0]);\r\n if (order !== 0) return order;\r\n return a[1] - b[1];\r\n });\r\n return stabilizedThis.map((el) => el[0]);\r\n}\r\n\r\ninterface EnhancedTableProps {\r\n classes: ReturnType;\r\n numSelected: number;\r\n onRequestSort: (\r\n event: React.MouseEvent,\r\n property: keyof Data\r\n ) => void;\r\n onSelectAllClick: (event: React.ChangeEvent) => void;\r\n order: Order;\r\n orderBy: string;\r\n rowCount: number;\r\n}\r\n\r\nfunction EnhancedTableHead(\r\n props: EnhancedTableProps & {\r\n id: string;\r\n label: string;\r\n numeric?: boolean;\r\n disablePadding?: boolean;\r\n leftmost?: boolean;\r\n rightmost?: boolean;\r\n }\r\n) {\r\n const { classes, order, orderBy, onRequestSort, ...restOfProps } = props;\r\n const createSortHandler =\r\n (property: keyof Data) => (event: React.MouseEvent) => {\r\n onRequestSort(event, property);\r\n };\r\n\r\n const theme = Mui.useTheme();\r\n\r\n return (\r\n \r\n \r\n {props.label}\r\n {orderBy === props.id ? (\r\n \r\n {order === \"desc\" ? \"sorted descending\" : \"sorted ascending\"}\r\n \r\n ) : null}\r\n \r\n \r\n );\r\n}\r\n\r\nconst useStyles = Mui.makeStyles((theme) =>\r\n Mui.createStyles({\r\n root: {\r\n width: \"100%\",\r\n },\r\n paper: {\r\n width: \"100%\",\r\n marginBottom: theme.spacing(2),\r\n },\r\n table: {\r\n minWidth: 750,\r\n },\r\n visuallyHidden: {\r\n border: 0,\r\n clip: \"rect(0 0 0 0)\",\r\n height: 1,\r\n margin: -1,\r\n overflow: \"hidden\",\r\n padding: 0,\r\n position: \"absolute\",\r\n top: 20,\r\n width: 1,\r\n },\r\n title: {\r\n flexGrow: 1,\r\n },\r\n })\r\n);\r\n\r\nfunction EnhancedTable({ rows, cid }: { rows: Models.Order.Main[]; cid: any }) {\r\n const classes = useStyles();\r\n const [order, setOrder] = React.useState(\"asc\");\r\n const [orderedOn, setOrderedOn] = React.useState();\r\n const [orderBy, setOrderBy] = React.useState(\"orderCode\");\r\n const [selected, setSelected] = React.useState([]);\r\n const [page, setPage] = React.useState(0);\r\n const [rowsPerPage] = React.useState(7);\r\n const [orderId, setOrderId] = React.useState();\r\n const [orderCode, setOrderCode] = React.useState();\r\n const [orderDetailsDialogOpen, setOrderDetailsDialogOpen] =\r\n React.useState(false);\r\n const userStore = React.useContext(App.Contexts.userStore);\r\n const uid = userStore.user?.ETUID;\r\n React.useEffect(() => {\r\n setPage(0);\r\n }, [rows]);\r\n const key = \"orderCode\";\r\n\r\n const orderArrayUniqueByKey = [\r\n ...new Map(rows.map((item) => [item[key], item])).values(),\r\n ];\r\n const handleRequestSort = (\r\n event: React.MouseEvent,\r\n property: keyof Data\r\n ) => {\r\n setPage(0);\r\n const isAsc = orderBy === property && order === \"asc\";\r\n setOrder(isAsc ? \"desc\" : \"asc\");\r\n setOrderBy(property);\r\n };\r\n \r\n\r\n const orderDetaile = rows;\r\n var keys = [\"setName\"];\r\n const handleSelectAllClick = (event: React.ChangeEvent) => {\r\n if (event.target.checked) {\r\n const newSelecteds = rows.map((n) => n.orderCode);\r\n setSelected(newSelecteds);\r\n return;\r\n }\r\n setSelected([]);\r\n };\r\n\r\n const handleClick = (event: React.MouseEvent, name: string) => {\r\n const selectedIndex = selected.indexOf(name);\r\n let newSelected: string[] = [];\r\n\r\n if (selectedIndex === -1) {\r\n newSelected = newSelected.concat(selected, name);\r\n } else if (selectedIndex === 0) {\r\n newSelected = newSelected.concat(selected.slice(1));\r\n } else if (selectedIndex === selected.length - 1) {\r\n newSelected = newSelected.concat(selected.slice(0, -1));\r\n } else if (selectedIndex > 0) {\r\n newSelected = newSelected.concat(\r\n selected.slice(0, selectedIndex),\r\n selected.slice(selectedIndex + 1)\r\n );\r\n }\r\n\r\n setSelected(newSelected);\r\n };\r\n\r\n const handleChangePage = (event: unknown, newPage: number) => {\r\n setPage(newPage);\r\n };\r\n\r\n const isSelected = (name: string) => selected.indexOf(name) !== -1;\r\n\r\n const emptyRows =\r\n rowsPerPage - Math.min(rowsPerPage, rows.length - page * rowsPerPage);\r\n\r\n const { t } = ReactI18next.useTranslation();\r\n const theme = Mui.useTheme();\r\n\r\n const HtmlTooltip = withStyles((theme) => ({\r\n tooltip: {\r\n backgroundColor: \"#f5f5f9\",\r\n color: \"rgba(0, 0, 0, 0.87)\",\r\n maxWidth: 300,\r\n fontSize: theme.typography.pxToRem(16),\r\n border: \"2px solid #dadde9\",\r\n },\r\n }))(Mui.Tooltip);\r\n const [language, setLanguage] = React.useState(\"en-IN\");\r\n const { i18n } = ReactI18next.useTranslation();\r\n const languageValue = i18n.language;\r\n const [orders, setOrders] = React.useState();\r\n const orderServices = new Services.Order({\r\n httpManager: new Services.Managers.Axios({ agent: App.axios }),\r\n urlFactory: new Services.Factories.URL({\r\n protocol: Constants.environment.apiBaseUrlProtocol as \"http\",\r\n hostname: Constants.environment.apiBaseUrlHostname,\r\n version: Constants.environment.apiBaseUrlVersion,\r\n }),\r\n });\r\n React.useEffect(() => {\r\n (async function () {\r\n // \r\n if (!orderId) {\r\n return;\r\n }\r\n\r\n try {\r\n //alert('Order');\r\n const {\r\n result: [order],\r\n } = await orderServices.getData({\r\n body: { id: orderId, cid: cid },\r\n });\r\n\r\n var { result } = await orderServices.getData({\r\n body: { id: orderId, cid: cid },\r\n });\r\n\r\n //overAllStatus = 3 -- > Order completely returned\r\n if (result.find((k: any) => k.status === 3)) {\r\n order.overAllStatus = 3;\r\n var partialReturnOrderObjectForStatus3 = result.find(\r\n (k: any) => k.status === 2\r\n );\r\n partialReturnOrderObjectForStatus3?.orderDetails.map((k: any) => {\r\n // eslint-disable-next-line array-callback-return\r\n order.orderDetails.map((q: any) => {\r\n if (q.setID === k.setID) {\r\n q.returnQuantity = k.quantity;\r\n }\r\n });\r\n });\r\n }\r\n //overAllStatus = 2 -- > Order paretially returned\r\n else if (result.find((k: any) => k.status === 4)) {\r\n order.overAllStatus = 4;\r\n var partialReturnOrderObjectForStatus4 = result.find(\r\n (k: any) => k.status === 2\r\n );\r\n partialReturnOrderObjectForStatus4?.orderDetails.map((k: any) => {\r\n // eslint-disable-next-line array-callback-return\r\n order.orderDetails.map((q: any) => {\r\n if (q.setID === k.setID) {\r\n q.returnQuantity = k.quantity;\r\n }\r\n });\r\n });\r\n // \r\n } else if (result.find((k: any) => k.status === 5)) {\r\n order.overAllStatus = 5;\r\n var partialReturnOrderObjectForStatus5 = result.find(\r\n (k: any) => k.status === 2\r\n );\r\n partialReturnOrderObjectForStatus5?.orderDetails.map((k: any) => {\r\n // eslint-disable-next-line array-callback-return\r\n order.orderDetails.map((q: any) => {\r\n if (q.setID === k.setID) {\r\n q.returnQuantity = k.quantity;\r\n }\r\n });\r\n });\r\n // \r\n }\r\n //overAllStatus = 1 -- > Order paretially returned Order with no return\r\n else {\r\n order.overAllStatus = 1;\r\n }\r\n \r\n setOrders(order);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n })();\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, [orderDetailsDialogOpen]);\r\n // \r\n React.useEffect(() => {\r\n if (languageValue === \"en\") {\r\n setLanguage(\"en-IN\");\r\n } else if (languageValue === \"fr\") {\r\n setLanguage(\"fr-FR\");\r\n } else {\r\n setLanguage(\"de-DE\");\r\n }\r\n }, [languageValue]);\r\n\r\n return (\r\n \r\n {/* setOrderDetailsDialogOpen(false)}\r\n title={t(\"Order details\")}\r\n contentText={}\r\n actions={\r\n <>\r\n window.print()}\r\n >\r\n Print\r\n \r\n setOrderDetailsDialogOpen(false)}\r\n >\r\n Close\r\n \r\n >\r\n }\r\n /> */}\r\n setOrderDetailsDialogOpen(false)}\r\n content={\r\n \r\n }\r\n title={\r\n <>\r\n \r\n \r\n \r\n \r\n Order details\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n >\r\n }\r\n actions={\r\n <>\r\n setOrderDetailsDialogOpen(false)}\r\n >\r\n CLOSE\r\n \r\n {\r\n window.print();\r\n }}\r\n >\r\n Print\r\n \r\n >\r\n }\r\n />\r\n {/* */}\r\n \r\n \r\n {rows.length > 0 && (\r\n \r\n \r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n \r\n \r\n )}\r\n \r\n
\r\n \r\n \r\n {stableSort(\r\n orderArrayUniqueByKey as any,\r\n getComparator(order, orderBy)\r\n )\r\n .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)\r\n .map((row, index) => {\r\n const isItemSelected = isSelected(row.orderCode as string);\r\n const labelId = `enhanced-table-checkbox-${index}`;\r\n const grossTotalPriceInclVAT: any = row.grossTotalPriceInclVAT;\r\n const totalPrice =\r\n row?.vatTaxPercent === 0\r\n ? (19 / 100) * grossTotalPriceInclVAT +\r\n +grossTotalPriceInclVAT\r\n : row.grossTotalPriceInclVAT;\r\n const assignedDetails =\r\n row.assignedTo === \"0\" ? \"KERN\" : \"Dealer\";\r\n return (\r\n {\r\n handleClick(event, row.orderCode as string);\r\n setOrderCode(row.orderCode);\r\n setOrderedOn(row.orderedOn);\r\n setOrderId(row.orderID);\r\n setOrderDetailsDialogOpen(true);\r\n }}\r\n aria-checked={isItemSelected}\r\n tabIndex={-1}\r\n key={row.orderCode}\r\n\r\n >\r\n \r\n {row.dataFrom === \"webshop\" &&\r\n row.sageOLReferenceBillID != null &&\r\n row.sageOLReferenceBillID > 0 &&\r\n row.assignedTo === \"0\"\r\n ? row.orderCode + \"-\" + row.sageOLReferenceBillID\r\n : row.orderCode}\r\n \r\n \r\n {DateFns.format(new Date(row.orderedOn), \"dd.MM.yyyy\")}\r\n \r\n \r\n {row.dataFrom === \"webshop\" && row.assignedTo === \"0\"\r\n ? \"\"\r\n : row.userFirstName + \" \" + row.userLastName}\r\n \r\n\r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n })}\r\n {rows.length === 0 && (\r\n \r\n \r\n \r\n \r\n \r\n No orders found\r\n \r\n \r\n \r\n \r\n \r\n )}\r\n {emptyRows > 0 && (\r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n {rows.length > 7 && (\r\n \r\n handleChangePage(event, page - 1)}\r\n shape=\"rounded\"\r\n />\r\n \r\n )}\r\n \r\n
\r\n );\r\n}\r\n\r\nexport const Main = Mobx.observer(function () {\r\n const [searchOrder, setSearchOrder] = React.useState(\"\");\r\n const [searchUser, setSearchUser] = React.useState(\"\");\r\n const [searchOrderLicense, setSearchOrderLicense] =\r\n React.useState(\"\");\r\n const [searchOrderDevice, setSearchOrderDevice] = React.useState(\"\");\r\n const theme = Mui.useTheme();\r\n const importDealerStore = React.useContext(App.Contexts.importDealerStore);\r\n const userStore = React.useContext(App.Contexts.userStore);\r\n const orderStore = React.useContext(App.Contexts.orderStore);\r\n const dCustomerStore = React.useContext(App.Contexts.delareCustomerStore);\r\n const addCustomerStore = React.useContext(App.Contexts.addCustomerStore);\r\n const [searchParams] = Router.useSearchParams();\r\n var searchParam = searchParams.get(\"q\");\r\n var searchParamCustomerID = searchParams.get(\"m\");\r\n React.useEffect(() => {\r\n const uid = userStore.user?.ETUID;\r\n const userRole = \"customer\";\r\n if (uid !== undefined && uid !== null) {\r\n dCustomerStore.read({\r\n uid,\r\n userRole,\r\n });\r\n }\r\n\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, [searchParams]);\r\n React.useEffect(() => {\r\n const uid = searchParam;\r\n const userRole = \"customer\";\r\n if (\r\n userRole === \"customer\" ||\r\n userRole === \"dealer\" ||\r\n userRole === \"admin\" ||\r\n userRole === \"superadmin\"\r\n ) {\r\n if (uid !== undefined && uid !== null) {\r\n orderStore.read({\r\n uid,\r\n userRole,\r\n });\r\n }\r\n }\r\n importDealerStore.readUsers({ searchtext: \"All\"});\r\n localStorage.removeItem(\"namedatad\");\r\n let dealer: any;\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, []);\r\n let searchHighlight: Boolean = false;\r\n const getSearchHighlight = (highlightFlag: boolean) => {\r\n searchHighlight = highlightFlag;\r\n return highlightFlag;\r\n };\r\n const handleSearchUser = (event: any) => {\r\n // \r\n setSearchUser(event.target.value);\r\n };\r\n const handleSearchOrder = (event: any) => {\r\n // \r\n setSearchOrder(event.target.value);\r\n };\r\n const customerName: any = dCustomerStore?.delaerCustomer\r\n ?.filter((k) => k.customerID === searchParamCustomerID)\r\n ?.map((k) => k.customerName);\r\n \r\n const emailID = dCustomerStore?.delaerCustomer\r\n ?.filter((k) => k.customerID === searchParamCustomerID)\r\n ?.map((k) => k.emailID);\r\n const dealerCustomerID = dCustomerStore?.delaerCustomer\r\n ?.filter((k) => k.customerID === searchParamCustomerID)\r\n ?.map((k) => k.customerDealerID);\r\n const etUserStatus: any = dCustomerStore?.delaerCustomer\r\n ?.filter((k) => k.customerID === searchParamCustomerID)\r\n ?.map((k) => k.etUserStatus);\r\n const companyName: any = dCustomerStore?.delaerCustomer\r\n ?.filter((k) => k.customerID === searchParamCustomerID)\r\n ?.map((k) => k.companyName);\r\n const fullName = customerName[0] === undefined ? \"\" : customerName[0].toString();\r\n const statusConversion = parseInt(etUserStatus.toString());\r\n const userRoleName = userStore.user?.RoleName;\r\n // \r\n const [state, setState] = React.useState();\r\n const { t } = ReactI18next.useTranslation();\r\n function a11yProps(index: any) {\r\n return {\r\n id: `full-width-tab-${index}`,\r\n \"aria-controls\": `full-width-tabpanel-${index}`,\r\n };\r\n }\r\n function a12yProps(index: any) {\r\n return {\r\n id: `full-width-tab-${index}`,\r\n \"aria-controls\": `full-width-tabpanel-${index}`,\r\n };\r\n }\r\n const useStyles = makeStyles((theme: Theme) => ({\r\n root: {\r\n backgroundColor: theme.palette.background.paper,\r\n borderRadius: \"10px\",\r\n },\r\n link: {\r\n display: \"flex\",\r\n },\r\n icon: {\r\n color: theme.palette.text.secondary,\r\n marginRight: theme.spacing(0.5),\r\n width: 20,\r\n height: 20,\r\n },\r\n }));\r\n const classes = useStyles();\r\n const [value, setValue] = React.useState(0);\r\n interface TabPanelProps {\r\n children?: React.ReactNode;\r\n dir?: string;\r\n index: any;\r\n value: any;\r\n }\r\n\r\n function TabPanel(props: TabPanelProps) {\r\n const { children, value, index, ...other } = props;\r\n\r\n return (\r\n \r\n {value === index && (\r\n \r\n {children}\r\n \r\n )}\r\n
\r\n );\r\n }\r\n const handleChangeTab = (event: React.ChangeEvent<{}>, newValue: number) => {\r\n setValue(newValue);\r\n };\r\n\r\n const handleChangeTab2 = (event: React.ChangeEvent<{}>, newValue: number) => {\r\n setValue(newValue);\r\n };\r\n\r\n const handleChangeIndex = (index: number) => {\r\n setValue(index);\r\n };\r\n const handleChangeIndex2 = (index: number) => {\r\n setValue(index);\r\n };\r\n const [detailsDrawerOpen, setDetailsDrawerOpen] =\r\n React.useState(false);\r\n const [currentLicense, setCurrentLicense] = React.useState(false);\r\n const customerStore = React.useContext(App.Contexts.customerStore);\r\n const functionStore = React.useContext(App.Contexts.functionStore);\r\n const licenseStore = React.useContext(App.Contexts.license.store);\r\n const handleSearchLicense = (event: React.ChangeEvent) => {\r\n setSearchOrderLicense(event.target.value);\r\n licenseStore.setSearch({ search: event.target.value as string });\r\n };\r\n const toggleDetailsDrawer = () => {\r\n setDetailsDrawerOpen(!detailsDrawerOpen);\r\n };\r\n const handleStatusFilterChange = (\r\n event: React.ChangeEvent<{ value: unknown }>\r\n ) => {\r\n const status = event.target.value as string | number;\r\n if (typeof status === \"string\" && status !== \"\") {\r\n return;\r\n }\r\n\r\n if (status === \"\") {\r\n licenseStore.setStatus({ status: undefined });\r\n return;\r\n }\r\n\r\n licenseStore.setStatus({ status });\r\n };\r\n React.useEffect(() => {\r\n const uid: any = searchParam;\r\n const userRole = \"customer\";\r\n if (\r\n (userRole === \"customer\" || userRole === \"dealer\") &&\r\n uid !== undefined &&\r\n uid !== null\r\n ) {\r\n licenseStore.read({\r\n body: { status: null, userID: uid },\r\n userRole,\r\n uid,\r\n });\r\n }\r\n\r\n\r\n functionStore.read();\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, []);\r\n const removingLicenseDuplication = licenseStore.filtered.filter((k) =>\r\n orderStore.orders.length === 0\r\n ? k.licenseCode === \"CustInvite\"\r\n : k.setID !== 2\r\n );\r\n\r\n // \r\n\r\n /********************End of duplication article remove filter ********************/\r\n\r\n const [isLoading, setIsLoading] = React.useState(false);\r\n const [deactivationDialogOpen, setDeactivationDialogOpen] =\r\n React.useState(false);\r\n const [detailsDrawerOpenDevice, setDetailsDrawerOpenDevice] =\r\n React.useState(false);\r\n const [currentDevice, setCurrentDevice] = React.useState<\r\n Models.Devices & { sets: Set }\r\n >();\r\n const { enqueueSnackbar } = Notistack.useSnackbar();\r\n const easyTouchDeviceStore = React.useContext(\r\n App.Contexts.easyTouchDeviceStore\r\n );\r\n\r\n React.useEffect(() => {\r\n const macId = searchParams.get(\"macId\");\r\n if (!macId) {\r\n return;\r\n }\r\n if (!easyTouchDeviceStore.devices) {\r\n return;\r\n }\r\n const device = easyTouchDeviceStore.devices.find(\r\n (device) => device.macID === macId\r\n );\r\n if (!device) {\r\n return;\r\n }\r\n if (device) {\r\n Array.from(licenseStore.selectedArticlesForDeactivation.values()).forEach(\r\n (setID) => {\r\n licenseStore.toggleArticleSelectionForDeactivation({ setID });\r\n }\r\n );\r\n device?.sets?.forEach((set) => {\r\n licenseStore.toggleArticleSelectionForDeactivation({\r\n setID: set?.setID,\r\n });\r\n });\r\n setDetailsDrawerOpen(true);\r\n setCurrentDevice(device);\r\n }\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, [easyTouchDeviceStore.devices, deactivationDialogOpen]);\r\n\r\n React.useEffect(() => {\r\n const userRole = userStore.user?.RoleName;\r\n\r\n if (userRole === \"customer\") {\r\n return;\r\n }\r\n\r\n const customer = searchParams.get(\"customer\");\r\n\r\n if (!customer) {\r\n return;\r\n }\r\n\r\n customerChange(customer);\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, []);\r\n\r\n const customerChange = (customer: number | string) => {\r\n const uid: any = searchParam;\r\n\r\n easyTouchDeviceStore.setCustomer({ customer });\r\n\r\n if (uid === undefined || uid === null) {\r\n return;\r\n }\r\n\r\n if (customer === \"\" || customer === undefined || customer === null) {\r\n return;\r\n }\r\n\r\n easyTouchDeviceStore.read({\r\n body: { status: null, userID: customer },\r\n userRole: \"customer\",\r\n uid,\r\n });\r\n };\r\n\r\n const handleChangeDevice = (event: React.ChangeEvent<{ value: unknown }>) => {\r\n const customer = event.target.value as string | number;\r\n customerChange(customer);\r\n };\r\n\r\n const handleSearchDevice = (event: any) => {\r\n setSearchOrderDevice(event.target.value);\r\n easyTouchDeviceStore.setSearch({ search: event.target.value as string });\r\n };\r\n\r\n const toggleDetailsDrawerDevice = () => {\r\n setDetailsDrawerOpenDevice(!detailsDrawerOpenDevice);\r\n };\r\n\r\n React.useEffect(() => {\r\n functionStore.read();\r\n\r\n const userRole = \"customer\";\r\n const uid: any = searchParam;\r\n\r\n if (\r\n (userRole === \"customer\" || userRole === \"EU\") &&\r\n uid !== undefined &&\r\n uid !== null\r\n ) {\r\n easyTouchDeviceStore.read({ userRole: \"customer\", status: -1, uid });\r\n }\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, []);\r\n\r\n function handleDeactivateAll() {\r\n Array.from(licenseStore.selectedArticlesForDeactivation.values()).forEach(\r\n (setID) => {\r\n licenseStore.toggleArticleSelectionForDeactivation({ setID });\r\n }\r\n );\r\n currentDevice?.sets.forEach(({ setID }) => {\r\n licenseStore.toggleArticleSelectionForDeactivation({ setID });\r\n });\r\n setDetailsDrawerOpenDevice(false);\r\n setDeactivationDialogOpen(true);\r\n }\r\n\r\n function handleDeactivateSelected() {\r\n setDetailsDrawerOpenDevice(false);\r\n setDeactivationDialogOpen(true);\r\n }\r\n React.useEffect(() => {\r\n functionStore.read();\r\n\r\n const userRole = userStore.user?.RoleName ?? (\"customer\" || \"EU\");\r\n const uid = userStore.user?.ETUID;\r\n\r\n if (userRole === \"admin\" || userRole === \"superadmin\") {\r\n customerStore.read({});\r\n }\r\n if (\r\n (userRole === \"customer\" || userRole === \"EU\") &&\r\n uid !== undefined &&\r\n uid !== null\r\n ) {\r\n easyTouchDeviceStore.read({ userRole: \"customer\", status: -1, uid });\r\n }\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, []);\r\n async function handleDeactivate() {\r\n try {\r\n const userRole = userStore.user?.RoleName;\r\n const etuid = parseInt(searchParam ?? \"\");\r\n\r\n if (!etuid) {\r\n return;\r\n }\r\n\r\n if (!currentDevice) {\r\n return;\r\n }\r\n\r\n setIsLoading(true);\r\n\r\n const successAcknowledgement = () => {\r\n enqueueSnackbar(t(\"License(s) deactivated successfully.\"), {\r\n variant: \"success\",\r\n preventDuplicate: false,\r\n });\r\n\r\n\r\n easyTouchDeviceStore.read({\r\n userRole: \"customer\",\r\n status: -1,\r\n uid: etuid,\r\n });\r\n };\r\n\r\n if (\r\n userRole === \"customer\" &&\r\n licenseStore.selectedArticlesForDeactivation.size > 0 &&\r\n licenseStore.selectedArticlesForDeactivation.size ===\r\n currentDevice?.sets.size\r\n ) {\r\n await licenseStore.deactivateAll({\r\n body: {\r\n MacID: currentDevice.macID,\r\n UserId: etuid,\r\n },\r\n });\r\n successAcknowledgement();\r\n return;\r\n }\r\n\r\n if (\r\n (userRole === \"admin\" || userRole === \"superadmin\") &&\r\n easyTouchDeviceStore.customer &&\r\n licenseStore.selectedArticlesForDeactivation.size > 0 &&\r\n licenseStore.selectedArticlesForDeactivation.size ===\r\n currentDevice?.sets.size\r\n ) {\r\n await licenseStore.deactivateAll({\r\n body: {\r\n MacID: currentDevice.macID,\r\n UserId: easyTouchDeviceStore.customer as number,\r\n },\r\n });\r\n successAcknowledgement();\r\n return;\r\n }\r\n\r\n const dependentSetIds = Array.from(currentDevice?.sets?.values() ?? [])\r\n .filter((set) =>\r\n licenseStore.selectedArticlesForDeactivation.has(set?.setID)\r\n )\r\n .reduce((acc, set) => {\r\n Array.from(currentDevice?.sets?.values() ?? [])\r\n .filter(\r\n (set) =>\r\n !licenseStore.selectedArticlesForDeactivation.has(set?.setID)\r\n )\r\n .forEach((otherSet) => {\r\n if (\r\n otherSet.dependentSets.includes(set.setID) &&\r\n licenseStore.selectedArticlesForDeactivation.has(otherSet.setID)\r\n ) {\r\n return;\r\n }\r\n if (otherSet.dependentSets.includes(set.setID)) {\r\n acc.add(otherSet.setID);\r\n }\r\n });\r\n return acc;\r\n }, new Set());\r\n\r\n const dependentSets = Array.from(\r\n currentDevice?.sets?.values() ?? []\r\n ).filter((set) => dependentSetIds.has(set?.setID));\r\n\r\n const selectedSets = Array.from(currentDevice.sets.values()).filter(\r\n (set) => licenseStore.selectedArticlesForDeactivation.has(set.setID)\r\n );\r\n\r\n await licenseStore.deactivateSelected({\r\n body: {\r\n LicenseDetailsList: [...dependentSets, ...selectedSets].map((set) => {\r\n return {\r\n LicenseDetailID: (set as any)?.licenseDetailID,\r\n MacID: currentDevice.macID,\r\n };\r\n }),\r\n },\r\n });\r\n successAcknowledgement();\r\n } catch (error) {\r\n enqueueSnackbar(t(\"Something went wrong! Please try again later.\"), {\r\n variant: \"warning\",\r\n preventDuplicate: false,\r\n });\r\n } finally {\r\n setIsLoading(false);\r\n setDeactivationDialogOpen(false);\r\n }\r\n }\r\n const navigate = Router.useNavigate();\r\n return (\r\n <>\r\n {userRoleName !== \"customer\" && (\r\n {\r\n navigate(`/dealercustomer/`);\r\n }}\r\n >\r\n Back\r\n \r\n )}\r\n {(userRoleName === \"dealer\" &&\r\n {\r\n navigate(`/dealercustomer/customerinvite?e=${emailID}&ci=${dealerCustomerID}`);\r\n }}\r\n >\r\n Add more license\r\n )}\r\n { statusConversion === 1 && userRoleName === \"dealer\" && {\r\n const uid = userStore.user?.ETUID;\r\n\r\n var requestHeader = {\r\n EmailID: emailID[0],\r\n DealerID: uid,\r\n OrderCode: \"0\"\r\n }\r\n var result = await addCustomerStore.cancelInvite({\r\n body:requestHeader\r\n })\r\n enqueueSnackbar(t(\"The invitation has been canceled and the sold order has been returned to you\"), {\r\n variant: \"success\",\r\n preventDuplicate: false,\r\n });\r\n navigate(\"/dealercustomer\")\r\n }}\r\n >\r\n \r\n Cancel invite\r\n \r\n }\r\n\r\n \r\n \r\n \r\n \r\n \r\n