Align tax page with authenticated backend flow
This commit is contained in:
parent
edbcbea5b4
commit
b3b3fa3392
@ -72,7 +72,6 @@ export default function TaxPage() {
|
|||||||
const [returns, setReturns] = useState<TaxReturn[]>([]);
|
const [returns, setReturns] = useState<TaxReturn[]>([]);
|
||||||
const [status, setStatus] = useState("");
|
const [status, setStatus] = useState("");
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [useSample, setUseSample] = useState(true);
|
|
||||||
const [selectedReturnId, setSelectedReturnId] = useState("");
|
const [selectedReturnId, setSelectedReturnId] = useState("");
|
||||||
const [intake, setIntake] = useState<TaxIntake>(emptyIntake);
|
const [intake, setIntake] = useState<TaxIntake>(emptyIntake);
|
||||||
const [readiness, setReadiness] = useState<TaxReadiness | null>(null);
|
const [readiness, setReadiness] = useState<TaxReadiness | null>(null);
|
||||||
@ -81,38 +80,14 @@ export default function TaxPage() {
|
|||||||
const [filingType, setFilingType] = useState<"individual" | "business">("individual");
|
const [filingType, setFilingType] = useState<"individual" | "business">("individual");
|
||||||
const [jurisdictions, setJurisdictions] = useState<string[]>(["CA", "NY"]);
|
const [jurisdictions, setJurisdictions] = useState<string[]>(["CA", "NY"]);
|
||||||
|
|
||||||
const sampleProfile = {
|
const requiredDocuments = [
|
||||||
taxpayer: {
|
|
||||||
name: "John Doe",
|
|
||||||
ssn: "111-22-3333",
|
|
||||||
dob: "1989-04-12",
|
|
||||||
filingStatus: "Single",
|
|
||||||
address: "123 Market St, San Francisco, CA"
|
|
||||||
},
|
|
||||||
income: {
|
|
||||||
w2: [{ employer: "Northwind Labs", wages: 92000, federalWithheld: 12000 }],
|
|
||||||
interest: [{ payer: "City Bank", amount: 320 }],
|
|
||||||
dividends: [{ payer: "Index Fund", amount: 480 }],
|
|
||||||
selfEmployment: [{ business: "Doe Consulting", income: 28000, expenses: 6400 }]
|
|
||||||
},
|
|
||||||
deductions: {
|
|
||||||
standard: true,
|
|
||||||
charitable: 600,
|
|
||||||
studentLoanInterest: 900
|
|
||||||
},
|
|
||||||
credits: {
|
|
||||||
education: 0,
|
|
||||||
childTax: 0
|
|
||||||
},
|
|
||||||
documents: [
|
|
||||||
{ docType: "w2_or_1099", label: "W-2 / 1099 income forms" },
|
{ docType: "w2_or_1099", label: "W-2 / 1099 income forms" },
|
||||||
{ docType: "interest_and_dividend_forms", label: "1099-INT / 1099-DIV forms" },
|
{ docType: "interest_and_dividend_forms", label: "1099-INT / 1099-DIV forms" },
|
||||||
{ docType: "deduction_support", label: "Deduction support" },
|
{ docType: "deduction_support", label: "Deduction support" },
|
||||||
{ docType: "identity_information", label: "Identity information" },
|
{ docType: "identity_information", label: "Identity information" },
|
||||||
{ docType: "state_withholding_statement", label: "State withholding statement" },
|
{ docType: "state_withholding_statement", label: "State withholding statement" },
|
||||||
{ docType: "health_insurance_statement", label: "Health insurance 1095-A" }
|
{ docType: "health_insurance_statement", label: "Health insurance 1095-A" }
|
||||||
]
|
];
|
||||||
};
|
|
||||||
|
|
||||||
const states = [
|
const states = [
|
||||||
{ code: "AL", name: "Alabama" },
|
{ code: "AL", name: "Alabama" },
|
||||||
@ -205,45 +180,11 @@ export default function TaxPage() {
|
|||||||
setStatus(response.error?.message ?? "Unable to create return.");
|
setStatus(response.error?.message ?? "Unable to create return.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (useSample) {
|
|
||||||
await Promise.all(
|
|
||||||
sampleProfile.documents.map((document) =>
|
|
||||||
apiFetch(`/api/tax/returns/${response.data.id}/documents`, {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify({
|
|
||||||
docType: document.docType,
|
|
||||||
metadata: { source: "sample", label: document.label, taxpayer: sampleProfile.taxpayer.name },
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
setStatus("Return created.");
|
setStatus("Return created.");
|
||||||
await loadReturns();
|
await loadReturns();
|
||||||
setSelectedReturnId(response.data.id);
|
setSelectedReturnId(response.data.id);
|
||||||
if (useSample) {
|
setIntake(emptyIntake);
|
||||||
const sampleIntake = intakeFromSample();
|
setReadiness(null);
|
||||||
setIntake(sampleIntake);
|
|
||||||
await saveIntake(response.data.id, sampleIntake, true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const intakeFromSample = (): TaxIntake => {
|
|
||||||
const wages = sampleProfile.income.w2.reduce((sum, item) => sum + item.wages, 0);
|
|
||||||
const business = sampleProfile.income.selfEmployment.reduce((sum, item) => sum + item.income - item.expenses, 0);
|
|
||||||
const interest = sampleProfile.income.interest.reduce((sum, item) => sum + item.amount, 0);
|
|
||||||
const dividends = sampleProfile.income.dividends.reduce((sum, item) => sum + item.amount, 0);
|
|
||||||
return {
|
|
||||||
taxpayer: {
|
|
||||||
name: sampleProfile.taxpayer.name,
|
|
||||||
filingStatus: sampleProfile.taxpayer.filingStatus,
|
|
||||||
address: sampleProfile.taxpayer.address,
|
|
||||||
},
|
|
||||||
income: { wages, business, interest, dividends, total: wages + business + interest + dividends },
|
|
||||||
deductions: sampleProfile.deductions,
|
|
||||||
credits: sampleProfile.credits,
|
|
||||||
notes: "Sample intake generated from John Doe dataset.",
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectReturn = async (ret: TaxReturn) => {
|
const selectReturn = async (ret: TaxReturn) => {
|
||||||
@ -345,28 +286,6 @@ export default function TaxPage() {
|
|||||||
<div className="glass-panel p-6 rounded-2xl shadow-sm">
|
<div className="glass-panel p-6 rounded-2xl shadow-sm">
|
||||||
<h2 className="text-lg font-bold text-foreground">Create a return</h2>
|
<h2 className="text-lg font-bold text-foreground">Create a return</h2>
|
||||||
<div className="mt-4 grid gap-4">
|
<div className="mt-4 grid gap-4">
|
||||||
<div className="rounded-xl border border-border bg-background/50 p-4">
|
|
||||||
<div className="flex items-center justify-between">
|
|
||||||
<div>
|
|
||||||
<p className="text-sm font-semibold text-foreground">Sample dataset</p>
|
|
||||||
<p className="text-xs text-muted-foreground">Use John Doe sample intake data.</p>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => setUseSample((value) => !value)}
|
|
||||||
className={`rounded-full px-3 py-1 text-xs font-semibold transition-colors ${useSample ? "bg-primary text-primary-foreground" : "bg-secondary text-muted-foreground"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{useSample ? "On" : "Off"}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{useSample ? (
|
|
||||||
<div className="mt-4 text-xs text-muted-foreground">
|
|
||||||
<p>W-2 wages: $92,000 - 1099-NEC: $28,000</p>
|
|
||||||
<p>Standard deduction - CA + NY filings</p>
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
<label className="text-xs uppercase tracking-[0.2em] text-muted-foreground font-semibold">Tax year</label>
|
<label className="text-xs uppercase tracking-[0.2em] text-muted-foreground font-semibold">Tax year</label>
|
||||||
<input
|
<input
|
||||||
@ -418,7 +337,7 @@ export default function TaxPage() {
|
|||||||
<div className="rounded-xl border border-border bg-background/50 p-4">
|
<div className="rounded-xl border border-border bg-background/50 p-4">
|
||||||
<p className="text-xs uppercase tracking-[0.2em] text-muted-foreground font-semibold">Required documents</p>
|
<p className="text-xs uppercase tracking-[0.2em] text-muted-foreground font-semibold">Required documents</p>
|
||||||
<div className="mt-3 grid gap-2 text-xs text-muted-foreground">
|
<div className="mt-3 grid gap-2 text-xs text-muted-foreground">
|
||||||
{sampleProfile.documents.map((doc) => (
|
{requiredDocuments.map((doc) => (
|
||||||
<div key={doc.docType} className="flex items-center justify-between">
|
<div key={doc.docType} className="flex items-center justify-between">
|
||||||
<span>{doc.label}</span>
|
<span>{doc.label}</span>
|
||||||
<span className="rounded-full bg-secondary px-2 py-1 text-foreground font-medium">Pending</span>
|
<span className="rounded-full bg-secondary px-2 py-1 text-foreground font-medium">Pending</span>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user