mirror of
https://github.com/wasp-lang/open-saas.git
synced 2025-10-10 22:24:44 +02:00
fix shared import and user admin access
This commit is contained in:
@@ -7,8 +7,15 @@ import ReferrerTable from '../../components/ReferrerTable';
|
|||||||
import DefaultLayout from '../../layout/DefaultLayout';
|
import DefaultLayout from '../../layout/DefaultLayout';
|
||||||
import { useQuery } from '@wasp/queries';
|
import { useQuery } from '@wasp/queries';
|
||||||
import getDailyStats from '@wasp/queries/getDailyStats';
|
import getDailyStats from '@wasp/queries/getDailyStats';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
|
import type { User } from '@wasp/entities';
|
||||||
|
|
||||||
|
const ECommerce = ({ user} : { user: User }) => {
|
||||||
|
const history = useHistory();
|
||||||
|
if (!user.isAdmin) {
|
||||||
|
history.push('/');
|
||||||
|
}
|
||||||
|
|
||||||
const ECommerce = () => {
|
|
||||||
const { data: stats, isLoading, error } = useQuery(getDailyStats);
|
const { data: stats, isLoading, error } = useQuery(getDailyStats);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@@ -5,7 +5,7 @@ import logout from '@wasp/auth/logout';
|
|||||||
import { useState, Dispatch, SetStateAction } from 'react';
|
import { useState, Dispatch, SetStateAction } from 'react';
|
||||||
import { Link } from '@wasp/router'
|
import { Link } from '@wasp/router'
|
||||||
import { CUSTOMER_PORTAL_LINK } from '../../shared/const';
|
import { CUSTOMER_PORTAL_LINK } from '../../shared/const';
|
||||||
|
import { TierIds } from '@wasp/shared/const';
|
||||||
|
|
||||||
export default function AccountPage({ user }: { user: User }) {
|
export default function AccountPage({ user }: { user: User }) {
|
||||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||||
@@ -28,7 +28,7 @@ export default function AccountPage({ user }: { user: User }) {
|
|||||||
<dt className='text-sm font-medium text-gray-500'>Your Plan</dt>
|
<dt className='text-sm font-medium text-gray-500'>Your Plan</dt>
|
||||||
{user.hasPaid ? (
|
{user.hasPaid ? (
|
||||||
<>
|
<>
|
||||||
<dd className='mt-1 text-sm text-gray-900 sm:col-span-1 sm:mt-0'>Premium Monthly Subscription</dd>
|
{user.subscriptionStatus !== 'past_due' ? <dd className='mt-1 text-sm text-gray-900 sm:col-span-1 sm:mt-0'>{user.subscriptionTier === TierIds.HOBBY ? 'Hobby' : 'Pro' } Plan</dd> : <dd className='mt-1 text-sm text-gray-900 sm:col-span-1 sm:mt-0'>Your Account is Past Due! Please Update your Payment Information</dd>}
|
||||||
<CustomerPortalButton isLoading={isLoading} setIsLoading={setIsLoading} />
|
<CustomerPortalButton isLoading={isLoading} setIsLoading={setIsLoading} />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { TierIds} from "../../shared/const";
|
import { TierIds } from '@wasp/shared/const';
|
||||||
|
|
||||||
export const navigation = [
|
export const navigation = [
|
||||||
{ name: 'Features', href: '#features' },
|
{ name: 'Features', href: '#features' },
|
||||||
|
@@ -6,7 +6,7 @@ import type { GenerateGptResponse, StripePayment } from '@wasp/actions/types';
|
|||||||
import type { StripePaymentResult, OpenAIResponse } from './types';
|
import type { StripePaymentResult, OpenAIResponse } from './types';
|
||||||
import { UpdateCurrentUser, SaveReferrer, UpdateUserReferrer, UpdateUserById } from '@wasp/actions/types';
|
import { UpdateCurrentUser, SaveReferrer, UpdateUserReferrer, UpdateUserById } from '@wasp/actions/types';
|
||||||
import { fetchStripeCustomer, createStripeCheckoutSession } from './stripeUtils.js';
|
import { fetchStripeCustomer, createStripeCheckoutSession } from './stripeUtils.js';
|
||||||
import { TierIds } from '../shared/const.js';
|
import { TierIds } from '@wasp/shared/const.js';
|
||||||
|
|
||||||
export const stripePayment: StripePayment<string, StripePaymentResult> = async (tier, context) => {
|
export const stripePayment: StripePayment<string, StripePaymentResult> = async (tier, context) => {
|
||||||
if (!context.user || !context.user.email) {
|
if (!context.user || !context.user.email) {
|
||||||
|
Reference in New Issue
Block a user