mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-09-27 12:04:52 +02:00
Merge pull request #1165 from OpenSignLabs/validation
feat: show email used count
This commit is contained in:
@@ -18,7 +18,7 @@ const Header = ({ showSidebar }) => {
|
|||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { width } = useWindowSize();
|
const { width } = useWindowSize();
|
||||||
let username = localStorage.getItem("username");
|
const username = localStorage.getItem("username") || "";
|
||||||
const image = localStorage.getItem("profileImg") || dp;
|
const image = localStorage.getItem("profileImg") || dp;
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const [isSubscribe, setIsSubscribe] = useState(true);
|
const [isSubscribe, setIsSubscribe] = useState(true);
|
||||||
@@ -26,6 +26,7 @@ const Header = ({ showSidebar }) => {
|
|||||||
const [applogo, setAppLogo] = useState(
|
const [applogo, setAppLogo] = useState(
|
||||||
localStorage.getItem("appLogo") || " "
|
localStorage.getItem("appLogo") || " "
|
||||||
);
|
);
|
||||||
|
const [emailUsed, setEmailUsed] = useState(0);
|
||||||
|
|
||||||
const toggleDropdown = () => {
|
const toggleDropdown = () => {
|
||||||
setIsOpen(!isOpen);
|
setIsOpen(!isOpen);
|
||||||
@@ -47,6 +48,11 @@ const Header = ({ showSidebar }) => {
|
|||||||
}
|
}
|
||||||
setIsTeam(subscribe);
|
setIsTeam(subscribe);
|
||||||
setIsSubscribe(subscribe.isValid);
|
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}
|
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"
|
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")}>
|
<li onClick={() => openInNewTab("https://docs.opensignlabs.com")}>
|
||||||
<span>
|
<span>
|
||||||
<i className="fa-light fa-book"></i> {t("docs")}
|
<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 (plan === 'freeplan') {
|
||||||
if (monthchange) {
|
if (monthchange) {
|
||||||
contractUser.set('LastEmailCountReset', new Date());
|
contractUser.set('LastEmailCountReset', new Date());
|
||||||
contractUser.set('MontlyfreeEmails', 1);
|
contractUser.set('MonthlyFreeEmails', 1);
|
||||||
} else {
|
} else {
|
||||||
if (contractUser?.get('MontlyfreeEmails')) {
|
if (contractUser?.get('MonthlyFreeEmails')) {
|
||||||
contractUser.increment('MontlyfreeEmails', 1);
|
contractUser.increment('MonthlyFreeEmails', 1);
|
||||||
if (contractUser?.get('LastEmailCountReset')) {
|
if (contractUser?.get('LastEmailCountReset')) {
|
||||||
contractUser.set('LastEmailCountReset', new Date());
|
contractUser.set('LastEmailCountReset', new Date());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
contractUser.set('MontlyfreeEmails', 1);
|
contractUser.set('MonthlyFreeEmails', 1);
|
||||||
contractUser.set('LastEmailCountReset', new Date());
|
contractUser.set('LastEmailCountReset', new Date());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ async function sendmailv3(req) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Plan && Plan === 'freeplan') {
|
if (Plan && Plan === 'freeplan') {
|
||||||
let MontlyfreeEmails = _extRes?.MontlyfreeEmails || 0;
|
let MonthlyFreeEmails = _extRes?.MonthlyFreeEmails || 0;
|
||||||
if (_extRes?.LastEmailCountReset?.iso) {
|
if (_extRes?.LastEmailCountReset?.iso) {
|
||||||
const lastDate = new Date(_extRes?.LastEmailCountReset?.iso);
|
const lastDate = new Date(_extRes?.LastEmailCountReset?.iso);
|
||||||
const newDate = new Date();
|
const newDate = new Date();
|
||||||
@@ -225,7 +225,7 @@ async function sendmailv3(req) {
|
|||||||
const nonCustomMail = await sendMailProvider(req, Plan, true);
|
const nonCustomMail = await sendMailProvider(req, Plan, true);
|
||||||
return nonCustomMail;
|
return nonCustomMail;
|
||||||
} else {
|
} else {
|
||||||
if (MontlyfreeEmails >= 20) {
|
if (MonthlyFreeEmails >= 20) {
|
||||||
return { status: 'quota-reached' };
|
return { status: 'quota-reached' };
|
||||||
} else {
|
} else {
|
||||||
const nonCustomMail = await sendMailProvider(req, Plan);
|
const nonCustomMail = await sendMailProvider(req, Plan);
|
||||||
|
|||||||
Reference in New Issue
Block a user