-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add PartnerStack import logic to program onboarding #2804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,27 +2,39 @@ | |
|
|
||
| import { setPartnerStackTokenAction } from "@/lib/actions/partners/set-partnerstack-token"; | ||
| import useWorkspace from "@/lib/swr/use-workspace"; | ||
| import { ProgramData } from "@/lib/types"; | ||
| import { Button, Input } from "@dub/ui"; | ||
| import { useAction } from "next-safe-action/hooks"; | ||
| import Link from "next/link"; | ||
| import { useState } from "react"; | ||
| import { UseFormSetValue, UseFormWatch } from "react-hook-form"; | ||
| import { toast } from "sonner"; | ||
|
|
||
| export const ImportPartnerStackForm = ({ | ||
| watch, | ||
| setValue, | ||
| onSuccess, | ||
| isPending, | ||
| }: { | ||
| watch: UseFormWatch<ProgramData>; | ||
| setValue: UseFormSetValue<ProgramData>; | ||
| onSuccess: () => void; | ||
| isPending: boolean; | ||
| }) => { | ||
| const { id: workspaceId } = useWorkspace(); | ||
| const [publicKey, setPublicKey] = useState(""); | ||
| const [secretKey, setSecretKey] = useState(""); | ||
|
|
||
| const partnerStack = watch("partnerstack"); | ||
|
|
||
| const { executeAsync, isPending: isSettingPartnerStackToken } = useAction( | ||
| setPartnerStackTokenAction, | ||
| { | ||
| onSuccess: () => { | ||
| onSuccess: ({ data }) => { | ||
| setValue("partnerstack", { | ||
| publicKey: data?.publicKey, | ||
| maskedSecretKey: data?.maskedSecretKey, | ||
| }); | ||
| onSuccess(); | ||
| toast.success("PartnerStack credentials saved successfully!"); | ||
| }, | ||
|
|
@@ -55,7 +67,7 @@ export const ImportPartnerStackForm = ({ | |
| type="password" | ||
| placeholder="Public key" | ||
| className="mt-2 max-w-full" | ||
| value={publicKey} | ||
| value={publicKey || partnerStack?.publicKey || ""} | ||
| onChange={(e) => setPublicKey(e.target.value)} | ||
| /> | ||
| <div className="mt-2 text-xs font-normal leading-[1.1] text-neutral-600"> | ||
|
|
@@ -79,7 +91,7 @@ export const ImportPartnerStackForm = ({ | |
| type="password" | ||
| placeholder="Secret key" | ||
| className="mt-2 max-w-full" | ||
| value={secretKey} | ||
| value={secretKey || partnerStack?.maskedSecretKey || ""} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The secret key input field will display a masked value (like "sk_***") when credentials are already saved, making it confusing for users who expect to see their actual input or a blank field. View Details📝 Patch Detailsdiff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/import-partnerstack-form.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/import-partnerstack-form.tsx
index b38199581..7f534644c 100644
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/import-partnerstack-form.tsx
+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/import-partnerstack-form.tsx
@@ -67,7 +67,7 @@ export const ImportPartnerStackForm = ({
type="password"
placeholder="Public key"
className="mt-2 max-w-full"
- value={publicKey || partnerStack?.publicKey || ""}
+ value={publicKey || ""}
onChange={(e) => setPublicKey(e.target.value)}
/>
<div className="mt-2 text-xs font-normal leading-[1.1] text-neutral-600">
@@ -91,7 +91,7 @@ export const ImportPartnerStackForm = ({
type="password"
placeholder="Secret key"
className="mt-2 max-w-full"
- value={secretKey || partnerStack?.maskedSecretKey || ""}
+ value={secretKey || ""}
onChange={(e) => setSecretKey(e.target.value)}
/>
</div>
AnalysisThe secret key input field on line 94 uses This creates a poor user experience because:
The input should either be empty when showing previously saved credentials, or should not show the masked value at all. A better pattern would be:
|
||
| onChange={(e) => setSecretKey(e.target.value)} | ||
| /> | ||
| </div> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.