rename hasActiveSubscription from useCurrentUser() to hasOngoingSubscription

This commit is contained in:
m5r 2021-10-21 00:01:03 +02:00
parent 6dbdeac4d3
commit 1dd1c2bafe
6 changed files with 19 additions and 9 deletions

View File

@ -1,6 +1,6 @@
import { useQuery } from "blitz";
import getCurrentPhoneNumber from "../../phone-numbers/queries/get-current-phone-number";
import getCurrentPhoneNumber from "app/phone-numbers/queries/get-current-phone-number";
import useCurrentUser from "./use-current-user";
export default function useUserPhoneNumber() {

View File

@ -15,7 +15,7 @@ export default function useCurrentUser() {
organization,
hasFilledTwilioCredentials,
hasPhoneNumber: Boolean(phoneNumber),
hasActiveSubscription: organization && organization.subscriptions.length > 0,
hasOngoingSubscription: organization && organization.subscriptions.length > 0,
refetch: userQuery.refetch,
};
}

View File

@ -10,7 +10,7 @@ import { formatRelativeDate } from "app/core/helpers/date-formatter";
import useCurrentUser from "app/core/hooks/use-current-user";
export default function PhoneCallsList() {
const { hasActiveSubscription } = useCurrentUser();
const { hasOngoingSubscription } = useCurrentUser();
const [phoneCalls, query] = usePhoneCalls();
useEffect(() => {
@ -25,7 +25,7 @@ export default function PhoneCallsList() {
}
if (phoneCalls.length === 0) {
return hasActiveSubscription ? <EmptyCalls /> : null;
return hasOngoingSubscription ? <EmptyCalls /> : null;
}
return (

View File

@ -11,7 +11,7 @@ import InactiveSubscription from "app/core/components/inactive-subscription";
import PhoneCallsList from "../components/phone-calls-list";
const PhoneCalls: BlitzPage = () => {
const { hasFilledTwilioCredentials, hasPhoneNumber, hasActiveSubscription } = useCurrentUser();
const { hasFilledTwilioCredentials, hasPhoneNumber, hasOngoingSubscription } = useCurrentUser();
if (!hasFilledTwilioCredentials || !hasPhoneNumber) {
return (
@ -22,7 +22,7 @@ const PhoneCalls: BlitzPage = () => {
);
}
if (!hasActiveSubscription) {
if (!hasOngoingSubscription) {
return (
<>
<InactiveSubscription />

View File

@ -15,7 +15,7 @@ import useCurrentUser from "app/core/hooks/use-current-user";
import KeypadErrorModal from "../components/keypad-error-modal";
const KeypadPage: BlitzPage = () => {
const { hasFilledTwilioCredentials, hasPhoneNumber, hasActiveSubscription } = useCurrentUser();
const { hasFilledTwilioCredentials, hasPhoneNumber, hasOngoingSubscription } = useCurrentUser();
const router = useRouter();
const [isKeypadErrorModalOpen, setIsKeypadErrorModalOpen] = useState(false);
const [phoneCalls] = usePhoneCalls();
@ -90,8 +90,10 @@ const KeypadPage: BlitzPage = () => {
return;
}
if (!hasActiveSubscription) {
if (!hasOngoingSubscription) {
// TODO
setIsKeypadErrorModalOpen(true);
return;
}
if (phoneNumber === "") {

View File

@ -17,7 +17,15 @@ export default async function getCurrentUser(_ = null, { session }: Ctx) {
organization: {
include: {
subscriptions: {
where: { status: SubscriptionStatus.active },
where: {
OR: [
{ status: { not: SubscriptionStatus.deleted } },
{
status: SubscriptionStatus.deleted,
cancellationEffectiveDate: { gt: new Date() },
},
],
},
},
},
},