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
13 changes: 9 additions & 4 deletions apps/frontend/components/campaigns/new/steps/step-budget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ export function StepBudget({ data, onChange, errors }: StepBudgetProps) {
onChange({ ...data, ...patch });
}

const validTotalBudget =
Number.isFinite(data.totalBudget) && data.totalBudget > 0
? data.totalBudget
: 0;

const payoutPerCreator =
data.totalBudget > 0 && data.creatorSlots > 0
? (data.totalBudget / data.creatorSlots).toFixed(2)
validTotalBudget > 0 && data.creatorSlots > 0
? (validTotalBudget / data.creatorSlots).toFixed(2)
: "0.00";

const platformFee = data.totalBudget * 0.005;
const platformFee = validTotalBudget * 0.005;

return (
<div className="flex flex-col gap-4">
Expand Down Expand Up @@ -138,7 +143,7 @@ export function StepBudget({ data, onChange, errors }: StepBudgetProps) {
<p className="text-[13px] leading-relaxed text-[var(--dash-muted)]">
Upon campaign launch, your selected budget of{" "}
<strong className="text-[var(--dash-bg)]">
{data.totalBudget.toLocaleString()} {data.asset}
{validTotalBudget.toLocaleString()} {data.asset}
</strong>{" "}
will be locked in a secure{" "}
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function validateStep(step: number, state: WizardState): Record<string, string>

if (step === 3) {
if (!state.budget.asset) errors.asset = "Select a payment asset.";
if (state.budget.totalBudget <= 0) errors.totalBudget = "Budget must be greater than 0.";
if (!Number.isFinite(state.budget.totalBudget) || state.budget.totalBudget <= 0) errors.totalBudget = "Budget must be greater than 0.";
if (state.budget.creatorSlots < 1) errors.creatorSlots = "At least 1 creator slot is required.";
}

Expand Down
26 changes: 11 additions & 15 deletions apps/frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { dirname } from "path";
import { fileURLToPath } from "url";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const compat = new FlatCompat({
baseDirectory: __dirname,
});

const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"),
import nextConfig from "eslint-config-next";

export default [
...nextConfig,
{
rules: {
"react-hooks/set-state-in-effect": "off",
"react-hooks/immutability": "off",
"react/no-unescaped-entities": "off",
},
},
];

export default eslintConfig;
2 changes: 1 addition & 1 deletion apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "eslint ."
},
"dependencies": {
"@stellar/freighter-api": "^6.0.1",
Expand Down
13 changes: 13 additions & 0 deletions vitest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import path from "node:path";
import { fileURLToPath } from "node:url";

const __dirname = path.dirname(fileURLToPath(import.meta.url));

export default {
test: {
alias: {
"@": path.resolve(__dirname, "./apps/frontend"),
"node:test": "vitest",
},
},
};