mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-17 21:25:54 +02:00
feat: show email used count
This commit is contained in:
@@ -18,7 +18,7 @@ const Header = ({ showSidebar }) => {
|
||||
const { t, i18n } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const { width } = useWindowSize();
|
||||
let username = localStorage.getItem("username");
|
||||
const username = localStorage.getItem("username") || "";
|
||||
const image = localStorage.getItem("profileImg") || dp;
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [isSubscribe, setIsSubscribe] = useState(true);
|
||||
@@ -26,6 +26,7 @@ const Header = ({ showSidebar }) => {
|
||||
const [applogo, setAppLogo] = useState(
|
||||
localStorage.getItem("appLogo") || " "
|
||||
);
|
||||
const [emailUsed, setEmailUsed] = useState(0);
|
||||
|
||||
const toggleDropdown = () => {
|
||||
setIsOpen(!isOpen);
|
||||
@@ -47,6 +48,11 @@ const Header = ({ showSidebar }) => {
|
||||
}
|
||||
setIsTeam(subscribe);
|
||||
setIsSubscribe(subscribe.isValid);
|
||||
const extUser =
|
||||
localStorage.getItem("Extand_Class") &&
|
||||
JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
|
||||
const MonthlyFreeEmails = extUser?.MonthlyFreeEmails || 0;
|
||||
setEmailUsed(MonthlyFreeEmails);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,6 +201,14 @@ const Header = ({ showSidebar }) => {
|
||||
tabIndex={0}
|
||||
className="mt-3 z-[1] p-2 shadow op-menu op-menu-sm op-dropdown-content text-base-content bg-base-100 rounded-box w-52"
|
||||
>
|
||||
{isEnableSubscription && isTeam?.plan === "freeplan" && (
|
||||
<li className="cursor-pointer">
|
||||
<span>
|
||||
<i className="fa-light fa-envelope"></i> Email used:{" "}
|
||||
{emailUsed}/20
|
||||
</span>
|
||||
</li>
|
||||
)}
|
||||
<li onClick={() => openInNewTab("https://docs.opensignlabs.com")}>
|
||||
<span>
|
||||
<i className="fa-light fa-book"></i> {t("docs")}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { combineReducers } from "redux";
|
||||
import infoReducer from "./infoReducer";
|
||||
import ShowTenant from "./ShowTenant";
|
||||
import TourStepsReducer from "./TourStepsReducer";
|
||||
import showHeader from "./showHeader";
|
||||
|
||||
export default combineReducers({
|
||||
appInfo: infoReducer,
|
||||
TourSteps: TourStepsReducer,
|
||||
ShowTenant,
|
||||
showHeader
|
||||
});
|
||||
@@ -103,15 +103,15 @@ export const updateMailCount = async (extUserId, plan, monthchange) => {
|
||||
if (plan === 'freeplan') {
|
||||
if (monthchange) {
|
||||
contractUser.set('LastEmailCountReset', new Date());
|
||||
contractUser.set('MontlyfreeEmails', 1);
|
||||
contractUser.set('MonthlyFreeEmails', 1);
|
||||
} else {
|
||||
if (contractUser?.get('MontlyfreeEmails')) {
|
||||
contractUser.increment('MontlyfreeEmails', 1);
|
||||
if (contractUser?.get('MonthlyFreeEmails')) {
|
||||
contractUser.increment('MonthlyFreeEmails', 1);
|
||||
if (contractUser?.get('LastEmailCountReset')) {
|
||||
contractUser.set('LastEmailCountReset', new Date());
|
||||
}
|
||||
} else {
|
||||
contractUser.set('MontlyfreeEmails', 1);
|
||||
contractUser.set('MonthlyFreeEmails', 1);
|
||||
contractUser.set('LastEmailCountReset', new Date());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ async function sendmailv3(req) {
|
||||
}
|
||||
} else {
|
||||
if (Plan && Plan === 'freeplan') {
|
||||
let MontlyfreeEmails = _extRes?.MontlyfreeEmails || 0;
|
||||
let MonthlyFreeEmails = _extRes?.MonthlyFreeEmails || 0;
|
||||
if (_extRes?.LastEmailCountReset?.iso) {
|
||||
const lastDate = new Date(_extRes?.LastEmailCountReset?.iso);
|
||||
const newDate = new Date();
|
||||
@@ -225,7 +225,7 @@ async function sendmailv3(req) {
|
||||
const nonCustomMail = await sendMailProvider(req, Plan, true);
|
||||
return nonCustomMail;
|
||||
} else {
|
||||
if (MontlyfreeEmails >= 20) {
|
||||
if (MonthlyFreeEmails >= 20) {
|
||||
return { status: 'quota-reached' };
|
||||
} else {
|
||||
const nonCustomMail = await sendMailProvider(req, Plan);
|
||||
|
||||
Reference in New Issue
Block a user