feat: update license manually
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// import { useEffect } from "react";
|
||||
import { useEffect } from "react";
|
||||
import {
|
||||
useCheckLicenseMutation,
|
||||
useGetLicenseQuery,
|
||||
@@ -10,12 +10,12 @@ const useLicense = () => {
|
||||
const { userCount, isGuest } = useAppSelector((store) => {
|
||||
return { userCount: store.users.ids.length, isGuest: store.authData.guest };
|
||||
});
|
||||
const { data: license } = useGetLicenseQuery(undefined, {
|
||||
const { data: license, refetch: refetchLicense } = useGetLicenseQuery(undefined, {
|
||||
refetchOnMountOrArgChange: true,
|
||||
skip: isGuest
|
||||
});
|
||||
const [check, { isLoading: isChecking, isSuccess: checked }] = useCheckLicenseMutation();
|
||||
const [upsert, { isSuccess: upserted, isLoading: upserting }] = useUpsertLicenseMutation();
|
||||
const [upsert, { isSuccess: upserted, isLoading: upserting, reset: resetUpsert }] = useUpsertLicenseMutation();
|
||||
const checkLicense = (l: string) => {
|
||||
check(l);
|
||||
};
|
||||
@@ -28,7 +28,12 @@ const useLicense = () => {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
console.log("uuu", userCount, license);
|
||||
useEffect(() => {
|
||||
if (upserted) {
|
||||
refetchLicense();
|
||||
resetUpsert();
|
||||
}
|
||||
}, [upserted]);
|
||||
const lUserLimit = license?.user_limit ?? Number.MAX_SAFE_INTEGER;
|
||||
return {
|
||||
reachLimit: userCount >= lUserLimit,
|
||||
|
||||
Reference in New Issue
Block a user