-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stripe Connect Onboarding Integration (#528)
* Base for stripe connect onboardnig flow * Almost done with stripe onboarding * Stripe Connect onboarding flow complete * Cleanup * More cleanup * Improve code style/structure, improve onboarding flow, remove redundant code * Clean up delete connect account route * Address code review comments
- Loading branch information
1 parent
7684374
commit 4352a25
Showing
16 changed files
with
777 additions
and
58 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,81 @@ | ||
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; | ||
} | ||
|
||
if (!auth.currentUser?.permissions?.includes("is_admin")) { | ||
navigate("/"); | ||
return; | ||
} | ||
}, [auth.isLoading, auth.isAuthenticated]); | ||
|
||
const handleDeleteTestAccounts = async () => { | ||
try { | ||
const { data, error } = await auth.client.POST( | ||
"/stripe/connect/delete/accounts", | ||
{}, | ||
); | ||
|
||
if (error) { | ||
addErrorAlert(error); | ||
return; | ||
} | ||
|
||
addAlert(`Successfully deleted ${data.count} test accounts`, "success"); | ||
setTimeout(() => { | ||
navigate("/sell/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> | ||
</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,69 @@ | ||
import { useEffect } from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
import { useAuthentication } from "@/hooks/useAuth"; | ||
import { Check } from "lucide-react"; | ||
|
||
export default function SellerDashboard() { | ||
const navigate = useNavigate(); | ||
const auth = useAuthentication(); | ||
|
||
useEffect(() => { | ||
auth.fetchCurrentUser(); | ||
}, []); | ||
|
||
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("/sell/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> | ||
<div className="flex gap-2 text-green-600"> | ||
<Check /> | ||
<p> | ||
Your K-Scale seller account is active and ready to receive | ||
payments. | ||
</p> | ||
</div> | ||
|
||
<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.