-
Notifications
You must be signed in to change notification settings - Fork 13
[TASK-14307] Feat/manteca claim request #1201
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
Zishan-7
merged 14 commits into
feat/manteca-integration
from
feat/manteca-claim-request
Sep 16, 2025
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
19e62b4
add claim to mercado pago UI
Zishan-7 2a9f311
refactor: replace Card component with MantecaDetailsCard in MantecaDe…
Zishan-7 a333a54
Add UI for Manteca req fulfilment flow
Zishan-7 ad7602a
Integrate request fulfilment API
Zishan-7 899e5f0
implement claim flow
Zishan-7 7e84b75
refactor: enhance MantecaDepositCard to dynamically manage row visibi…
Zishan-7 c7e8c4c
refactor: update AvatarWithBadge to use StaticImageData for logo prop…
Zishan-7 10a4fba
fix: typo and add suggested changes
Zishan-7 7eb03c6
Merge remote-tracking branch 'origin/feat/manteca-integration' into f…
Zishan-7 2932f75
refactor: Update flow
Zishan-7 11ed3ec
move manteca APIs to service
Zishan-7 b71d7db
chore: add 'use client' directive to MantecaFlowManager component
Zishan-7 d6dd05f
fix: improve error handling and transaction hash validation in Mantec…
Zishan-7 4a74991
fix: typo
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
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,46 @@ | ||
'use server' | ||
|
||
import { MantecaWithdrawData, MantecaWithdrawResponse } from '@/types/manteca.types' | ||
import { fetchWithSentry } from '@/utils' | ||
import { cookies } from 'next/headers' | ||
|
||
const API_KEY = process.env.PEANUT_API_KEY! | ||
|
||
export async function mantecaWithdraw(params: MantecaWithdrawData): Promise<MantecaWithdrawResponse> { | ||
const apiUrl = process.env.PEANUT_API_URL | ||
const cookieStore = cookies() | ||
const jwtToken = (await cookieStore).get('jwt-token')?.value | ||
|
||
if (!apiUrl || !API_KEY) { | ||
console.error('API URL or API Key is not configured.') | ||
return { error: 'Server configuration error.' } | ||
} | ||
Zishan-7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
try { | ||
const response = await fetchWithSentry(`${apiUrl}/manteca/withdraw`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${jwtToken}`, | ||
'api-key': API_KEY, | ||
}, | ||
body: JSON.stringify(params), | ||
}) | ||
|
||
const data = await response.json() | ||
|
||
if (!response.ok) { | ||
console.log('error', response) | ||
return { error: data.error || 'Failed to create manteca withdraw.' } | ||
} | ||
|
||
return { data } | ||
} catch (error) { | ||
console.log('error', error) | ||
console.error('Error calling create manteca withdraw API:', error) | ||
if (error instanceof Error) { | ||
return { error: error.message } | ||
} | ||
return { error: 'An unexpected error occurred.' } | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
'use client' | ||
|
||
import { MERCADO_PAGO } from '@/assets' | ||
import NavHeader from '@/components/Global/NavHeader' | ||
import PeanutActionDetailsCard from '@/components/Global/PeanutActionDetailsCard' | ||
import { useClaimBankFlow } from '@/context/ClaimBankFlowContext' | ||
import { ClaimLinkData } from '@/services/sendLinks' | ||
import { FC, useState } from 'react' | ||
import MantecaDetailsStep from './views/MantecaDetailsStep.view' | ||
import { MercadoPagoStep } from '@/types/manteca.types' | ||
import MantecaReviewStep from './views/MantecaReviewStep' | ||
import { Button } from '@/components/0_Bruddle' | ||
import { useRouter } from 'next/navigation' | ||
|
||
interface MantecaFlowManagerProps { | ||
claimLinkData: ClaimLinkData | ||
amount: string | ||
attachment: { message: string | undefined; attachmentUrl: string | undefined } | ||
} | ||
|
||
const MantecaFlowManager: FC<MantecaFlowManagerProps> = ({ claimLinkData, amount, attachment }) => { | ||
const { setClaimToMercadoPago } = useClaimBankFlow() | ||
const [currentStep, setCurrentStep] = useState<MercadoPagoStep>(MercadoPagoStep.DETAILS) | ||
const router = useRouter() | ||
const [destinationAddress, setDestinationAddress] = useState('') | ||
|
||
const isSuccess = currentStep === MercadoPagoStep.SUCCESS | ||
|
||
const renderStepDetails = () => { | ||
if (currentStep === MercadoPagoStep.DETAILS) { | ||
return ( | ||
<MantecaDetailsStep | ||
destinationAddress={destinationAddress} | ||
setDestinationAddress={setDestinationAddress} | ||
setCurrentStep={setCurrentStep} | ||
/> | ||
) | ||
} | ||
if (currentStep === MercadoPagoStep.REVIEW) { | ||
return ( | ||
<MantecaReviewStep | ||
setCurrentStep={setCurrentStep} | ||
claimLink={claimLinkData.link} | ||
destinationAddress={destinationAddress} | ||
amount={amount} | ||
/> | ||
) | ||
} | ||
|
||
if (currentStep === MercadoPagoStep.SUCCESS) { | ||
return ( | ||
<Button onClick={() => router.push('/home')} shadowSize="4"> | ||
Back to home | ||
</Button> | ||
) | ||
} | ||
return null | ||
} | ||
|
||
const onPrev = () => { | ||
if (currentStep === MercadoPagoStep.DETAILS) { | ||
setClaimToMercadoPago(false) | ||
return | ||
} | ||
|
||
if (currentStep === MercadoPagoStep.REVIEW) { | ||
setCurrentStep(MercadoPagoStep.DETAILS) | ||
return | ||
} | ||
if (currentStep === MercadoPagoStep.SUCCESS) { | ||
router.push('/home') | ||
return | ||
} | ||
} | ||
|
||
return ( | ||
<div className="flex min-h-[inherit] flex-col justify-between gap-8 md:min-h-fit"> | ||
<NavHeader icon={isSuccess ? 'cancel' : 'chevron-up'} title="Receive" onPrev={onPrev} /> | ||
|
||
<div className="my-auto space-y-4"> | ||
<PeanutActionDetailsCard | ||
viewType={isSuccess ? 'SUCCESS' : 'NORMAL'} | ||
avatarSize="medium" | ||
transactionType="REGIONAL_METHOD_CLAIM" | ||
recipientType="USERNAME" | ||
recipientName={isSuccess ? 'You’ll receive' : 'Receive in Mercado Pago'} | ||
amount={amount} | ||
tokenSymbol={claimLinkData.tokenSymbol} | ||
message={attachment.message} | ||
fileUrl={attachment.attachmentUrl} | ||
logo={isSuccess ? undefined : MERCADO_PAGO} | ||
/> | ||
|
||
{renderStepDetails()} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default MantecaFlowManager |
45 changes: 45 additions & 0 deletions
45
src/components/Claim/Link/views/MantecaDetailsStep.view.tsx
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,45 @@ | ||
'use client' | ||
|
||
import { Button } from '@/components/0_Bruddle' | ||
import BaseInput from '@/components/0_Bruddle/BaseInput' | ||
import { Icon } from '@/components/Global/Icons/Icon' | ||
import { MercadoPagoStep } from '@/types/manteca.types' | ||
import { Dispatch, FC, SetStateAction } from 'react' | ||
|
||
interface MantecaDetailsStepProps { | ||
setCurrentStep: Dispatch<SetStateAction<MercadoPagoStep>> | ||
destinationAddress: string | ||
setDestinationAddress: Dispatch<SetStateAction<string>> | ||
} | ||
|
||
const MantecaDetailsStep: FC<MantecaDetailsStepProps> = ({ | ||
setCurrentStep, | ||
destinationAddress, | ||
setDestinationAddress, | ||
}) => { | ||
const handleOnClick = async () => { | ||
setCurrentStep(MercadoPagoStep.REVIEW) | ||
} | ||
|
||
return ( | ||
<> | ||
<p className="font-bold">Enter Mercado Pago account details</p> | ||
|
||
<BaseInput | ||
value={destinationAddress} | ||
onChange={(e) => setDestinationAddress(e.target.value)} | ||
placeholder="CVU or Alias" | ||
/> | ||
<div className="flex items-center gap-2 text-xs text-grey-1"> | ||
<Icon name="info" width={16} height={16} /> | ||
<span>You can only withdraw to accounts under your name.</span> | ||
</div> | ||
|
||
<Button disabled={!destinationAddress} onClick={() => handleOnClick()} shadowSize="4"> | ||
Review | ||
</Button> | ||
</> | ||
) | ||
} | ||
|
||
export default MantecaDetailsStep |
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.