rename hasActiveSubscription
from useCurrentUser()
to hasOngoingSubscription
This commit is contained in:
parent
6dbdeac4d3
commit
1dd1c2bafe
@ -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() {
|
||||
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
@ -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 (
|
||||
|
@ -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 />
|
||||
|
@ -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 === "") {
|
||||
|
@ -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() },
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user