Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 3 additions & 28 deletions nevo_frontend/app/pools/new/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createPool, submitSignedXdr, ApiError } from '@/lib/api-client';
import { signTransaction } from '@stellar/freighter-api';
import { contractService } from '@/lib/contract-service';
import { useWalletStore } from '@/src/store/walletStore';
import { parseApiError } from '@/lib/errors';

import {
validateFormData,
Expand Down Expand Up @@ -130,7 +131,6 @@ function CreatePoolPageContent() {
const [submitStep, setSubmitStep] = useState<
'idle' | 'creating' | 'signing' | 'submitting'
>('idle');
const [submitted, setSubmitted] = useState(false);
const [imageFile, setImageFile] = useState<File | null>(null);
const [imagePreviewUrl, setImagePreviewUrl] = useState('');
const [cropPreviewUrl, setCropPreviewUrl] = useState('');
Expand Down Expand Up @@ -355,7 +355,8 @@ function CreatePoolPageContent() {
setSubmitStep('submitting');
await submitSignedXdr(signedResult.signedTxXdr);

setSubmitted(true);
// Redirect to the newly created pool's page after successful submission
router.push(`/pools/${createPoolResult.id}`);
} catch (error) {
setErrors({ submit: parseApiError(error) });
} finally {
Expand All @@ -364,10 +365,6 @@ function CreatePoolPageContent() {
}
}

if (submitted) {
return <SuccessScreen onGoToDashboard={() => router.push('/dashboard')} />;
}

const tagList = form.tags
.split(',')
.map((t) => t.trim())
Expand Down Expand Up @@ -951,28 +948,6 @@ function Step3({
);
}

/* ── Success screen ───────────────────────────────────────────────────────── */

function SuccessScreen({ onGoToDashboard }: { onGoToDashboard: () => void }) {
return (
<main className="mx-auto max-w-2xl px-6 py-24 text-center">
<div className="flex flex-col items-center gap-4">
<div className="flex size-16 items-center justify-center rounded-full bg-success-light text-success">
<CheckCircleIcon />
</div>
<h1 className="text-2xl font-bold">Pool Created!</h1>
<p className="text-[var(--color-text-muted)] max-w-sm">
Your donation pool has been created successfully. Share it with your
community to start receiving contributions.
</p>
<button onClick={onGoToDashboard} className={`mt-4 ${primaryBtn}`}>
Go to Dashboard
</button>
</div>
</main>
);
}

/* ── Field wrapper ────────────────────────────────────────────────────────── */

interface FieldProps {
Expand Down
20 changes: 20 additions & 0 deletions nevo_server/src/donations/donations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,24 @@ export class DonationsService {
const count = await this.donationRepo.countBy({ txHash });
return count > 0;
}

async recordDonation(data: {
poolId: string;
donorWallet: string;
amount: string;
asset: string;
txHash: string;
memo?: string;
}): Promise<Donation> {
return this.donationRepo.save(
this.donationRepo.create({
poolId: data.poolId,
donorWallet: data.donorWallet,
amount: data.amount,
asset: data.asset,
txHash: data.txHash,
memo: data.memo || null,
}),
);
}
}
11 changes: 11 additions & 0 deletions nevo_server/src/pools/pools.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ export class PoolsService {
return this.poolRepo.save(pool);
}

async incrementRaised(contractPoolId: string, amount: string): Promise<Pool | null> {
const pool = await this.poolRepo.findOne({ where: { contractPoolId } });
if (!pool) return null;

const currentRaised = BigInt(pool.raised || '0');
const additionalAmount = BigInt(amount);
pool.raised = (currentRaised + additionalAmount).toString();

return this.poolRepo.save(pool);
}

buildWithdrawTx(pool: Pool): { unsignedXdr: string; poolId: string } {
// TODO: replace with real Stellar transaction build calling contract.withdraw (#657)
return { unsignedXdr: 'placeholder_xdr', poolId: pool.contractPoolId };
Expand Down
Loading