feat(passes): render data conditionally based on auth state
This commit is contained in:
@@ -11,6 +11,7 @@ import { ReviewsSection } from './ReviewsSection';
|
||||
import { Layout } from '../Layout';
|
||||
import { LoginModal } from './LoginModal';
|
||||
import { ImageWithFallback } from './figma/ImageWithFallback';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
|
||||
interface PassesPageProps {
|
||||
onCheckoutClick?: () => void;
|
||||
@@ -149,16 +150,18 @@ export function PassesPage({
|
||||
onCheckoutClick,
|
||||
onSignInClick,
|
||||
onSignOutClick,
|
||||
user,
|
||||
// user,
|
||||
onLoginSuccess
|
||||
}: PassesPageProps) {
|
||||
const [selectedPass, setSelectedPass] = useState<string>('unlimited');
|
||||
const [isLoginOpen, setIsLoginOpen] = useState(false);
|
||||
const [userData, setUserData] = useState<{ email: string; name: string } | null>(user || null);
|
||||
// const [userData, setUserData] = useState<{ email: string; name: string } | null>(user || null);
|
||||
const { user } = useAuth(); // from AuthContext
|
||||
|
||||
|
||||
// ✅ Handle purchase button click
|
||||
const handlePurchaseClick = () => {
|
||||
if (!userData) {
|
||||
if (!user) {
|
||||
// User not logged in - show login modal
|
||||
setIsLoginOpen(true);
|
||||
} else {
|
||||
@@ -169,7 +172,7 @@ export function PassesPage({
|
||||
|
||||
// ✅ Handle successful login
|
||||
const handleLoginSuccess = (data: { email: string; name: string }) => {
|
||||
setUserData(data);
|
||||
// setUserData(data);
|
||||
setIsLoginOpen(false);
|
||||
console.log('Logged in user:', data);
|
||||
|
||||
@@ -195,7 +198,7 @@ export function PassesPage({
|
||||
activeCity={sessionStorage.getItem("lastKnownCity")||"shared"}
|
||||
onSignInClick={onSignInClick}
|
||||
onSignOutClick={onSignOutClick}
|
||||
user={userData} // ✅ Pass the updated user data
|
||||
user={user} // ✅ Pass the updated user data
|
||||
>
|
||||
<div className="container mx-auto px-4 pt-52 pb-12 relative z-10">
|
||||
{/* Page Header */}
|
||||
@@ -759,12 +762,6 @@ export function PassesPage({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<LoginModal
|
||||
isOpen={isLoginOpen}
|
||||
onClose={() => setIsLoginOpen(false)}
|
||||
onLoginSuccess={handleLoginSuccess}
|
||||
/>
|
||||
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user