-
Notifications
You must be signed in to change notification settings - Fork 13
[TASK-14061] Update claim flow redirect actions for guest users #1185
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
44f9e17
initial implementation
Zishan-7 5b28086
show verification modal
Zishan-7 2baca60
implement claim to wallet after signup/login
Zishan-7 0400f32
Merge remote-tracking branch 'origin/peanut-wallet-dev' into feat/fix…
Zishan-7 7fbaf66
update post signup actions
Zishan-7 a043f9b
revert ActionModal changes and update prop name
Zishan-7 61825be
sanitize redirect url
Zishan-7 ed3f2a3
remove param before claiming
Zishan-7 746e07b
Add redirect to profile if KYC status is approved in IdentityVerifica…
Zishan-7 31dd819
add connected peanutWallet check
Zishan-7 d7255ba
fix: automatic claim not working
Zishan-7 85fba96
Merge remote-tracking branch 'origin/peanut-wallet-dev' into feat/fix…
Zishan-7 7683b29
fix: response handling
Zishan-7 101dccb
fix: build errors
Zishan-7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,55 @@ | ||
import { NextRequest, NextResponse } from 'next/server' | ||
import { fetchWithSentry } from '@/utils' | ||
import { PEANUT_API_URL } from '@/constants' | ||
|
||
/** | ||
* API route for automated link claiming without requiring user interaction. | ||
* | ||
* This route serves as a workaround for Next.js server action limitations: | ||
* Server actions cannot be directly called within useEffect hooks, which is | ||
* necessary for our automatic claim flow. By exposing this as an API route | ||
* instead, we can make the claim request safely from client-side effects. | ||
*/ | ||
export async function POST(request: NextRequest) { | ||
try { | ||
const body = await request.json() | ||
const { pubKey, recipient, password } = body | ||
|
||
if (!pubKey || !recipient || !password) { | ||
return NextResponse.json( | ||
{ error: 'Missing required parameters: pubKey, recipient, or password' }, | ||
{ status: 400 } | ||
) | ||
} | ||
|
||
const response = await fetchWithSentry(`${PEANUT_API_URL}/send-links/${pubKey}/claim`, { | ||
method: 'POST', | ||
headers: { | ||
'api-key': process.env.PEANUT_API_KEY!, | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
Zishan-7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
recipient, | ||
password, | ||
}), | ||
}) | ||
|
||
if (!response.ok) { | ||
return NextResponse.json( | ||
{ error: `Failed to claim link: ${response.statusText}` }, | ||
{ status: response.status } | ||
) | ||
} | ||
|
||
const responseText = await response.text() | ||
console.log('response', responseText) | ||
return new NextResponse(responseText, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
} catch (error) { | ||
console.error('Error claiming send link:', error) | ||
return NextResponse.json({ error: 'Failed to claim send link' }, { status: 500 }) | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.