Subscription Guard and Installation Guide

This commit is contained in:
ajaysi
2025-10-13 15:27:48 +05:30
parent c38812b6c5
commit b6debd80b7
13 changed files with 1176 additions and 42 deletions

View File

@@ -82,6 +82,7 @@ const PricingPage: React.FC = () => {
const [selectedPlan, setSelectedPlan] = useState<number | null>(null);
const [subscribing, setSubscribing] = useState(false);
const [paymentModalOpen, setPaymentModalOpen] = useState(false);
const [showSignInPrompt, setShowSignInPrompt] = useState(false);
const [knowMoreModal, setKnowMoreModal] = useState<{ open: boolean; title: string; content: React.ReactNode }>({
open: false,
title: '',
@@ -113,6 +114,17 @@ const PricingPage: React.FC = () => {
const plan = plans.find(p => p.id === planId);
if (!plan) return;
// Get user_id from localStorage (set by Clerk auth)
const userId = localStorage.getItem('user_id');
// Check if user is signed in
if (!userId || userId === 'anonymous' || userId === '') {
// User not signed in, show sign-in prompt
console.warn('PricingPage: User not signed in, showing prompt');
setShowSignInPrompt(true);
return;
}
// For alpha testing, only allow Free and Basic plans (Pro features not ready)
if (plan.tier !== 'free' && plan.tier !== 'basic') {
setError('This plan is not available for alpha testing');
@@ -937,6 +949,38 @@ const PricingPage: React.FC = () => {
</Button>
</DialogActions>
</Dialog>
{/* Sign In Prompt Modal */}
<Dialog
open={showSignInPrompt}
onClose={() => setShowSignInPrompt(false)}
maxWidth="sm"
fullWidth
>
<DialogTitle>Sign In Required</DialogTitle>
<DialogContent>
<Typography variant="body1" sx={{ mb: 2 }}>
Please sign in to subscribe to a plan and start using ALwrity.
</Typography>
<Typography variant="body2" color="text.secondary">
If you don't have an account, signing in will automatically create one for you.
</Typography>
</DialogContent>
<DialogActions>
<Button onClick={() => setShowSignInPrompt(false)}>
Cancel
</Button>
<Button
variant="contained"
onClick={() => {
// Redirect to landing page which has sign-in
window.location.href = '/';
}}
>
Sign In
</Button>
</DialogActions>
</Dialog>
</Container>
);
};