From 06b473f4a1782f8c2b58af5f6a9693cab5e39572 Mon Sep 17 00:00:00 2001 From: arturfracala Date: Thu, 13 Feb 2025 15:59:10 +0100 Subject: [PATCH] feat: remove login functionality and adjust action menu (DPS-4428) (#1551) * feat: remove login functionality and adjust action menu * feat: update package.json and package-lock.json * feat: delete action menu --------- Co-authored-by: Artur Fracala --- package-lock.json | 22 -- package.json | 1 - src/api/accounts.js | 35 --- src/api/index.js | 28 -- src/api/livechat.js | 35 --- src/components/Page/index.js | 146 ++++----- src/components/core/Navbar/Header.js | 6 - .../core/Navbar/MobileMenu/MobileMenu.js | 38 +-- src/components/core/Profile/Profile.js | 290 ------------------ src/components/core/Rating/index.js | 6 +- .../extensions/CopyToClipboardIcon.js | 13 +- src/contexts/auth.js | 111 ------- src/pages/index.js | 103 +++---- 13 files changed, 123 insertions(+), 711 deletions(-) delete mode 100644 src/api/accounts.js delete mode 100644 src/api/index.js delete mode 100644 src/api/livechat.js delete mode 100644 src/components/core/Profile/Profile.js delete mode 100644 src/contexts/auth.js diff --git a/package-lock.json b/package-lock.json index 00438b1a4..5a25c3bea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1271,15 +1271,6 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, - "@livechat/accounts-sdk": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/@livechat/accounts-sdk/-/accounts-sdk-2.0.6.tgz", - "integrity": "sha512-++I8QrWuxNN5h270SbSsgURdREGtSLsvAwDPrCRoDxeVJPXkNT+ICoqTtza8H0Ca6j17w2jqYjSvTld896rfyw==", - "requires": { - "js-cookie": "^2.2.1", - "qs": "^6.9.4" - } - }, "@livechat/data-utils": { "version": "0.2.16", "resolved": "https://registry.npmjs.org/@livechat/data-utils/-/data-utils-0.2.16.tgz", @@ -5037,11 +5028,6 @@ } } }, - "js-cookie": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-2.2.1.tgz", - "integrity": "sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ==" - }, "js-levenshtein": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.6.tgz", @@ -24718,14 +24704,6 @@ "integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==", "dev": true }, - "qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "requires": { - "side-channel": "^1.0.4" - } - }, "querystring": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.1.tgz", diff --git a/package.json b/package.json index 1150eec42..fb8649515 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "@docsearch/react": "^3.3.3", "@emotion/core": "^10.0.22", "@emotion/styled": "^10.0.23", - "@livechat/accounts-sdk": "^2.0.6", "@livechat/design-system": "^0.13.4", "@mapbox/rehype-prism": "^0.7.0", "@mdx-js/mdx": "^1.5.1", diff --git a/src/api/accounts.js b/src/api/accounts.js deleted file mode 100644 index 020fef0ba..000000000 --- a/src/api/accounts.js +++ /dev/null @@ -1,35 +0,0 @@ -import axios from "axios"; - -class AccountsClient { - constructor(token) { - this.instance = axios.create({ - baseURL: process.env.NEXT_PUBLIC_SERVER_URL, - headers: { - Authorization: `Bearer ${token}`, - "Content-Type": "application/json", - }, - }); - } - - async getInfo() { - try { - const response = await this.instance.get(`/info`); - - return response.data; - } catch (error) { - if (error.response.data.error === "unauthorized") - throw new Error(`Unauthorized`); - console.error(error); - } - } - - async deleteSessions() { - try { - await this.instance.delete(`/v2/sessions`); - } catch (error) { - console.error(error); - } - } -} - -export default AccountsClient; diff --git a/src/api/index.js b/src/api/index.js deleted file mode 100644 index 3ce26c8ca..000000000 --- a/src/api/index.js +++ /dev/null @@ -1,28 +0,0 @@ -import AccountsClient from "./accounts"; -import LiveChatClient from "./livechat"; - -let clients = { - accounts: null, - livechat: null, - isInitialized: false, -}; - -const api = { - initialize(token) { - clients = { - accounts: new AccountsClient(token), - livechat: new LiveChatClient(token), - isInitialized: true, - }; - }, - - getAccounts() { - return clients.accounts; - }, - - getLiveChat() { - return clients.livechat; - }, -}; - -export default api; diff --git a/src/api/livechat.js b/src/api/livechat.js deleted file mode 100644 index 1abb1f0ba..000000000 --- a/src/api/livechat.js +++ /dev/null @@ -1,35 +0,0 @@ -import axios from "axios"; -import { getRegion } from "../utils/region"; - -class LiveChatClient { - constructor(token) { - const region = getRegion(token); - - this.instance = axios.create({ - baseURL: process.env.NEXT_PUBLIC_LC_API_URL, - headers: { - Authorization: `Bearer ${token}`, - "X-Region": region, - }, - }); - } - - async getMe(id) { - try { - const response = await this.instance.post( - `/v3.5/configuration/action/get_agent`, - { - id, - } - ); - - return response.data; - } catch (error) { - if (error.response.data.error === "unauthorized") - throw new Error(`Unauthorized`); - console.error(error); - } - } -} - -export default LiveChatClient; diff --git a/src/components/Page/index.js b/src/components/Page/index.js index f9ac0bff4..a3a059309 100644 --- a/src/components/Page/index.js +++ b/src/components/Page/index.js @@ -38,7 +38,6 @@ import { RatingProvider, PromotionProvider, } from "../../contexts"; -import { AuthProvider } from "../../contexts/auth"; import { canUseWindow } from "../../utils"; import { useRating } from "../../hooks"; import articlesVersions from "../../configs/articlesVersions.json"; @@ -161,92 +160,83 @@ const Page = ({ frontMatter, children }) => { slug = slug[slug.length - 1] === "/" ? slug : `${slug}/`; const ratingContext = useRating({ slug }); - const useRedocPage = [ - "global-accounts-api", - "customer-accounts-api", - "text-api", - "chat-api" - ].includes(subcategory) || ["Chat API"].includes(title); + const useRedocPage = + [ + "global-accounts-api", + "customer-accounts-api", + "text-api", + "chat-api", + ].includes(subcategory) || ["Chat API"].includes(title); return ( - - - - - -
- - {!useRedocPage && ( - + + + +
+ + {!useRedocPage && ( + + )} + + + {currentApiVersion && ( + )} - - - {currentApiVersion && ( - + {title && !useRedocPage && } + {useRedocPage && ( + + + + + + + + + + {category} + + + )} - - {title && !useRedocPage && } - {useRedocPage && ( - - - - - - - - - - {category} - - - - )} - {children} + {children} - {!useRedocPage && ( - - )} - - - - {!useRedocPage && } - -