Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update merge-account-form.tsx

Kiran K71aed39c5efa
diff --git a/apps/web/ui/partners/merge-accounts/merge-account-form.tsx b/apps/web/ui/partners/merge-accounts/merge-account-form.tsx
index 1209de4768..48cf29d6a1 100644
--- a/apps/web/ui/partners/merge-accounts/merge-account-form.tsx
+++ b/apps/web/ui/partners/merge-accounts/merge-account-form.tsx
@@ -1,3 +1,48 @@
-export function MergeAccountForm() {
- return <div>MergeAccountForm</div>;
-}
\ No newline at end of file
+import { mergePartnerAccountsAction } from "@/lib/actions/partners/merge-partner-accounts";
+import { Button } from "@dub/ui";
+import { useAction } from "next-safe-action/hooks";
+import { toast } from "sonner";
+import { useMergePartnerAccountsForm } from "./form-context";
+
+export function MergeAccountForm({ onSuccess }: { onSuccess: () => void }) {
+ const { sourceAccount, targetAccount } = useMergePartnerAccountsForm();
+
+ console.info("sourceAccount", sourceAccount);
+ console.info("targetAccount", targetAccount);
+
+ const { executeAsync, isPending } = useAction(mergePartnerAccountsAction, {
+ onSuccess: async () => {
+ onSuccess();
+ },
+ onError({ error }) {
+ toast.error(error.serverError);
+ },
+ });
+
+ const onSubmit = async () => {
+ await executeAsync({
+ step: "merge-accounts",
+ });
+ };
+
+ return (
+ <form onSubmit={onSubmit} className="space-y-6">
+ MergeAccountForm
+ <div className="flex items-center justify-end gap-2">
+ <Button
+ variant="secondary"
+ text="Cancel"
+ className="h-8 w-fit px-3"
+ disabled={isPending}
+ />
+ <Button
+ text="Merge accounts"
+ className="h-8 w-fit px-3"
+ type="submit"
+ disabled={isPending}
+ loading={isPending}
+ />
+ </div>
+ </form>
+ );
+}