Merge branch 'main' into develop
This commit is contained in:
commit
6e5d4709d4
5 changed files with 53 additions and 11 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -34,6 +34,7 @@ htmlcov/
|
|||
|
||||
# Environment files
|
||||
.env*
|
||||
!.env.production
|
||||
!.env.example
|
||||
|
||||
.turbo
|
||||
|
|
|
|||
12
apps/api/.env.production
Normal file
12
apps/api/.env.production
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
SUPABASE_URL=https://mhcafqvzbrrwvahpvvzd.supabase.co
|
||||
|
||||
STREAM_CHAT_API_KEY=h7bwnn8ynjpx
|
||||
|
||||
XTABLO_URL=https://app.xtablo.com
|
||||
|
||||
R2_ACCOUNT_ID="9715fa14c5e5d1612301572cf1c6bbee"
|
||||
|
||||
TASKS_SECRET="gT3BAytmNwhe1wKmvgREBlWcqK0="
|
||||
|
||||
EMAIL_USER="baptiste@xtablo.com"
|
||||
EMAIL_CLIENT_ID="904332563417-e2n7pchtgnkrkp360baaebfeig55maig.apps.googleusercontent.com"
|
||||
|
|
@ -68,6 +68,27 @@ const createCheckoutSession = (
|
|||
return c.json({ error: "priceId is required" }, 400);
|
||||
}
|
||||
|
||||
const { data: price } = await supabase
|
||||
.schema("stripe")
|
||||
.from("prices")
|
||||
.select("*")
|
||||
.eq("id", priceId)
|
||||
.maybeSingle();
|
||||
|
||||
if (!price) {
|
||||
return c.json({ error: "Price not found" }, 404);
|
||||
}
|
||||
|
||||
const allowedInfiniteUsers = [
|
||||
"arbelleville@gmail.com",
|
||||
"baptiste.belleville74@gmail.com",
|
||||
"hugo@xtablo.com",
|
||||
];
|
||||
|
||||
if (price.unit_amount === 0 && !allowedInfiniteUsers.includes(user.email!)) {
|
||||
return c.json({ error: "This price is not available" }, 400);
|
||||
}
|
||||
|
||||
try {
|
||||
// Get or create Stripe customer
|
||||
let customerId: string;
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ VITE_SUPABASE_URL=https://mhcafqvzbrrwvahpvvzd.supabase.co
|
|||
VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1oY2FmcXZ6YnJyd3ZhaHB2dnpkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDEyNDEzMjEsImV4cCI6MjA1NjgxNzMyMX0.Otxn5BWCPD2ABlMM59hCgeur9Tf_Q7PndAbTkqXDPtM
|
||||
|
||||
VITE_SUPABASE_ID=mhcafqvzbrrwvahpvvzd
|
||||
VITE_STREAM_CHAT_API_KEY="v4yf8rs94aa8"
|
||||
VITE_STREAM_CHAT_API_KEY="h7bwnn8ynjpx"
|
||||
|
||||
VITE_STRIPE_PUBLISHABLE_KEY=pk_live_51Qc159AmcXPHW4mTHUTW6it2mdZ3KQTxZGXZ188DKpXuXgpirUWOj24dnb7DzbcEAu45nU1S5k66Nm4liY3IlGOW00pndRsgUM
|
||||
VITE_STRIPE_STANDARD_MONTHLY_PRICE_ID=price_1SPr3qAto3YQ7YhIALNeFBva
|
||||
VITE_STRIPE_STANDARD_MONTHLY_PRICE_ID=price_1SO0HAAmcXPHW4mTkFIh3CvF
|
||||
VITE_STRIPE_INFINITE_PRICE_ID=price_1SXHp8AmcXPHW4mTbus6j4Za
|
||||
|
||||
VITE_API_URL=https://xablo-api-636270553187.europe-west1.run.app
|
||||
|
|
@ -7,7 +7,6 @@ import {
|
|||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@xtablo/ui/components/card";
|
||||
import { Text } from "@xtablo/ui/components/typography";
|
||||
import { AlertCircle, CheckCircle2, CreditCard, Loader2Icon, Sparkles } from "lucide-react";
|
||||
import {
|
||||
useCancelSubscription,
|
||||
|
|
@ -21,6 +20,12 @@ import { useUser } from "../providers/UserStoreProvider";
|
|||
import { pluralize } from "@xtablo/shared";
|
||||
import { useMemo } from "react";
|
||||
|
||||
const allowedInfiniteUsers = [
|
||||
"arbelleville@gmail.com",
|
||||
"baptiste.belleville74@gmail.com",
|
||||
"hugo@xtablo.com",
|
||||
];
|
||||
|
||||
/**
|
||||
* Subscription management card for Settings page
|
||||
* Shows current subscription status and allows users to upgrade/manage
|
||||
|
|
@ -48,7 +53,14 @@ export function SubscriptionCard() {
|
|||
const showTrialBanner = user.plan === "none";
|
||||
|
||||
// Replace with your actual price ID from Stripe Dashboard
|
||||
const STANDARD_MONTHLY_PRICE_ID = import.meta.env.VITE_STRIPE_STANDARD_MONTHLY_PRICE_ID || "";
|
||||
|
||||
const infinitePriceId = import.meta.env.VITE_STRIPE_INFINITE_PRICE_ID || "";
|
||||
const standardPriceId = import.meta.env.VITE_STRIPE_STANDARD_MONTHLY_PRICE_ID || "";
|
||||
|
||||
const priceId =
|
||||
allowedInfiniteUsers.includes(user.email!) && infinitePriceId
|
||||
? infinitePriceId
|
||||
: standardPriceId;
|
||||
|
||||
const getStatusBadge = () => {
|
||||
// Check for beta plan first
|
||||
|
|
@ -167,12 +179,12 @@ export function SubscriptionCard() {
|
|||
<Button
|
||||
onClick={() =>
|
||||
createCheckout({
|
||||
priceId: STANDARD_MONTHLY_PRICE_ID,
|
||||
priceId: priceId,
|
||||
successUrl: `${window.location.origin}/settings?success=true`,
|
||||
cancelUrl: `${window.location.origin}/settings?canceled=true`,
|
||||
})
|
||||
}
|
||||
disabled={checkoutPending || !STANDARD_MONTHLY_PRICE_ID}
|
||||
disabled={checkoutPending || !priceId}
|
||||
className="w-full gap-2 bg-gradient-to-r from-purple-500 to-blue-500 hover:from-purple-600 hover:to-blue-600"
|
||||
>
|
||||
{checkoutPending ? (
|
||||
|
|
@ -187,11 +199,6 @@ export function SubscriptionCard() {
|
|||
</>
|
||||
)}
|
||||
</Button>
|
||||
{!STANDARD_MONTHLY_PRICE_ID && (
|
||||
<Text className="text-xs text-red-600 dark:text-red-400">
|
||||
Configuration Stripe requise
|
||||
</Text>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue