-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1be7a42
commit 1881425
Showing
9 changed files
with
596 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { useEffect } from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
import { useAlertQueue } from "@/hooks/useAlertQueue"; | ||
import { useAuthentication } from "@/hooks/useAuth"; | ||
|
||
export default function DeleteConnect() { | ||
const navigate = useNavigate(); | ||
const auth = useAuthentication(); | ||
const { addErrorAlert, addAlert } = useAlertQueue(); | ||
|
||
useEffect(() => { | ||
if (auth.isLoading) return; | ||
|
||
if (!auth.isAuthenticated) { | ||
navigate("/login"); | ||
return; | ||
} | ||
|
||
// Only allow access in development | ||
if (process.env.NODE_ENV !== "development") { | ||
navigate("/"); | ||
return; | ||
} | ||
}, [auth.isLoading, auth.isAuthenticated]); | ||
|
||
const handleDeleteTestAccounts = async () => { | ||
try { | ||
const { data, error } = await auth.client.POST( | ||
"/stripe/connect-account/delete-test-accounts", | ||
{}, | ||
); | ||
|
||
if (error) { | ||
addErrorAlert(error); | ||
return; | ||
} | ||
|
||
addAlert(`Successfully deleted ${data.count} test accounts`, "success"); | ||
setTimeout(() => { | ||
navigate("/seller-onboarding"); | ||
}, 2000); | ||
} catch (error) { | ||
addErrorAlert(`Failed to delete test accounts: ${error}`); | ||
} | ||
}; | ||
|
||
if (auth.isLoading) { | ||
return ( | ||
<div className="container mx-auto px-4 py-8"> | ||
<div className="max-w-2xl mx-auto"> | ||
<p>Loading...</p> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="container mx-auto px-4 py-8"> | ||
<div className="max-w-2xl mx-auto"> | ||
<h1 className="text-3xl font-bold mb-6"> | ||
Delete Test Connect Accounts | ||
</h1> | ||
|
||
<div className="bg-red-50 p-6 rounded-lg mb-6"> | ||
<h2 className="text-red-800 font-semibold mb-2">⚠️ Warning</h2> | ||
<p className="text-red-700 mb-4"> | ||
This action will delete all test Stripe Connect accounts associated | ||
with this environment. This operation cannot be undone. | ||
</p> | ||
<p className="text-red-700 mb-4"> | ||
This functionality is only available in development mode. | ||
</p> | ||
</div> | ||
|
||
<button | ||
onClick={handleDeleteTestAccounts} | ||
className="w-full bg-red-600 text-white px-6 py-3 rounded-lg hover:bg-red-700" | ||
> | ||
Delete All Test Connect Accounts | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { useEffect } from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
import { useAuthentication } from "@/hooks/useAuth"; | ||
|
||
export default function SellerDashboard() { | ||
const navigate = useNavigate(); | ||
const auth = useAuthentication(); | ||
|
||
useEffect(() => { | ||
if (auth.isLoading) return; | ||
|
||
if (!auth.isAuthenticated) { | ||
navigate("/login"); | ||
return; | ||
} | ||
|
||
// Redirect to onboarding if not completed | ||
if (!auth.currentUser?.stripe_connect_onboarding_completed) { | ||
navigate("/seller-onboarding"); | ||
return; | ||
} | ||
}, [auth.isLoading, auth.isAuthenticated, auth.currentUser]); | ||
|
||
if (auth.isLoading) { | ||
return ( | ||
<div className="container mx-auto px-4 py-8"> | ||
<div className="max-w-2xl mx-auto"> | ||
<p>Loading...</p> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="container mx-auto px-4 py-8"> | ||
<div className="max-w-2xl mx-auto"> | ||
<h1 className="text-3xl font-bold mb-6">Seller Dashboard</h1> | ||
|
||
<div className="bg-white rounded-lg shadow p-6"> | ||
<h2 className="text-xl font-semibold mb-4">Account Status</h2> | ||
<p className="text-green-600 mb-4"> | ||
✓ Your seller account is active and ready to receive payments | ||
</p> | ||
|
||
<div className="mt-6"> | ||
<a | ||
href={`https://dashboard.stripe.com/${auth.currentUser?.stripe_connect_account_id}`} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="bg-primary-9 text-white px-6 py-3 rounded-lg hover:bg-primary-9/80 inline-block" | ||
> | ||
Open Stripe Dashboard | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.