diff --git a/src/routes/chat/Layout/LicenseOutdatedTip.tsx b/src/routes/chat/Layout/LicenseOutdatedTip.tsx new file mode 100644 index 00000000..851c847f --- /dev/null +++ b/src/routes/chat/Layout/LicenseOutdatedTip.tsx @@ -0,0 +1,44 @@ +// import { useEffect } from "react"; +import { useNavigate } from "react-router-dom"; +import styled from "styled-components"; +import Button from "../../../common/component/styled/Button"; +const Styled = styled.div` + display: flex; + align-items: center; + justify-content: space-between; + background: #ef4444; + border-radius: var(--br); + width: 100%; + width: -webkit-fill-available; + padding: 12px 16px; + .txt { + font-weight: 500; + font-size: 16px; + line-height: 16px; + color: #fff; + .hand { + font-size: 20px; + margin-right: 10px; + } + } +`; +// type Props = {}; + +const LicenseUpgradeTip = () => { + const navigateTo = useNavigate(); + const handleRedirect = () => { + navigateTo("/setting?nav=license"); + }; + + return ( + + + 🚨 + Your license has reached the limit, upgrade the License or contact the Admin! + + + + ); +}; + +export default LicenseUpgradeTip; diff --git a/src/routes/chat/Layout/index.tsx b/src/routes/chat/Layout/index.tsx index 993351e5..a6bd9a4e 100644 --- a/src/routes/chat/Layout/index.tsx +++ b/src/routes/chat/Layout/index.tsx @@ -9,6 +9,8 @@ import useUploadFile from "../../../common/hook/useUploadFile"; import { ChatPrefixes } from "../../../app/config"; import { useAppSelector } from "../../../app/store"; import LoginTip from "./LoginTip"; +import useLicense from "../../../common/hook/useLicense"; +import LicenseUpgradeTip from "./LicenseOutdatedTip"; interface Props { readonly?: boolean; @@ -31,6 +33,7 @@ const Layout: FC = ({ context = "channel", to }) => { + const { reachLimit } = useLicense(); const { addStageFile } = useUploadFile({ context, id: to }); const messagesContainer = useRef(null); const [previewImage, setPreviewImage] = useState(null); @@ -107,7 +110,13 @@ const Layout: FC = ({
{children}
- {readonly ? : } + {readonly ? ( + + ) : reachLimit ? ( + + ) : ( + + )} {selects && }
diff --git a/src/routes/setting/License.tsx b/src/routes/setting/License.tsx index bc0c3c6b..b560077c 100644 --- a/src/routes/setting/License.tsx +++ b/src/routes/setting/License.tsx @@ -1,42 +1,14 @@ -import { useState } from "react"; +import { useState, MouseEvent } from "react"; import dayjs from "dayjs"; import styled from "styled-components"; // import Tippy from "@tippyjs/react"; // import toast from "react-hot-toast"; // import { hideAll } from "tippy.js"; -import Textarea from "../../common/component/styled/Textarea"; +// import Textarea from "../../common/component/styled/Textarea"; import Button from "../../common/component/styled/Button"; import useLicense from "../../common/hook/useLicense"; import LicensePriceListModal from "./LicensePriceListModal"; -const StyledInfo = styled.div` - padding: 12px; - border-radius: 5px; - border: 2px solid #557d2340; - background-color: #d1fadf60; - display: flex; - flex-direction: column; - gap: 15px; - .item { - white-space: nowrap; - display: flex; - flex-direction: column; - align-items: flex-start; - justify-content: flex-start; - line-height: 1.2; - .label { - font-size: 13px; - color: #aaa; - &:after { - content: ":"; - } - } - .info { - font-weight: bold; - font-size: 18px; - } - } -`; const Styled = styled.div` max-width: 760px; display: flex; @@ -45,16 +17,67 @@ const Styled = styled.div` align-items: flex-start; gap: 15px; > .license { + position: relative; width: 100%; + padding: 12px; + border-radius: 5px; + border: 2px solid #557d2340; + background-color: #d1fadf60; display: flex; - /* flex-direction: column; */ - align-items: flex-start; + flex-direction: column; gap: 15px; + &.outdated { + border-color: #ef4444; + background-color: #ef444457; + &:after { + content: "License Outdated"; + position: absolute; + right: 10px; + top: 10px; + background-color: #ef4444; + padding: 5px 4px; + font-size: 14px; + font-weight: bold; + color: #fff; + border-radius: 4px; + } + } + .item { + white-space: nowrap; + display: flex; + flex-direction: column; + align-items: flex-start; + justify-content: flex-start; + line-height: 1.2; + .label { + font-size: 13px; + color: #aaa; + &:after { + content: ":"; + } + } + .info { + font-weight: bold; + font-size: 18px; + line-height: 1.4; + &.value { + cursor: pointer; + width: 100%; + white-space: pre-wrap; + word-break: break-all; + &.fold { + white-space: inherit; + overflow: hidden; + text-overflow: ellipsis; + } + } + } + } } `; export default function License() { - const { license: licenseInfo } = useLicense(); + const { license: licenseInfo, reachLimit } = useLicense(); const [modalVisible, setModalVisible] = useState(false); const handleRenewLicense = () => { toggleModalVisible(); @@ -62,45 +85,60 @@ export default function License() { const toggleModalVisible = () => { setModalVisible((prev) => !prev); }; - + const handleLicenseValueToggle = (evt: MouseEvent) => { + const ele = evt.currentTarget; + ele.classList.toggle("fold"); + if (ele.classList.contains("fold")) { + ele.title = "Click to see full text"; + } else { + ele.title = "Click to fold text"; + } + }; // const disableBtn = !reachLimit; return ( <> -
-