-
Notifications
You must be signed in to change notification settings - Fork 0
/
formSchema.tsx
257 lines (249 loc) · 7.04 KB
/
formSchema.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
import type { CalculationResult, EligibilityResult } from "./calculators/loan";
import { qualifiesForDutyConcession } from "./schemes/FHBAS";
import type { FormResponse } from "./defaults";
import { State } from "./defaults";
import { qualifiesForFHBG } from "./schemes/FHBG";
import { qualifiesForFHOG } from "./schemes/FHOG";
type Question = { name: string; label: string; helpText?: string | (() => JSX.Element) } & (
| { type: "money" }
| { type: "radio"; options: { description: string; value: string }[] }
| { type: "select"; options: { description: string; value: string | number; disabled?: boolean }[] }
);
interface Scheme {
name: string;
short: string;
link: string;
helpDoc: string;
affects: keyof CalculationResult;
getEligibility: (purchasePrice: number, formData: FormResponse) => EligibilityResult;
}
export function getQuestions(state: State) {
return defaultQuestions.concat(schema[state].questions);
}
export function getSchemes(state: State) {
return defaultSchemes.concat(schema[state].schemes);
}
const defaultQuestions: Question[] = [
{
label: "What state are you in?",
type: "select",
name: "state",
options: [
...Object.values(State)
.sort()
.filter((state) => state === "NSW" || state === "VIC" || state === "QLD")
.map((state) => ({ description: state, value: state })),
{ description: "More coming soon" as any, value: "", disabled: true },
],
},
{
label: "Why are you buying a place?",
type: "radio",
name: "purpose",
options: [
{ description: "To live in", value: "occupier" },
{ description: "As an investment", value: "investor" },
],
},
{
label: "Buying an existing, new property or vacant land?",
type: "radio",
name: "propertyType",
options: [
{ description: "Existing", value: "existing" },
{ description: "New e.g. off the plan", value: "new-property" },
{ description: "Vacant land", value: "vacant-land" },
],
},
{
label: "Buying as a single or a couple?",
type: "radio",
name: "participants",
options: [
{ description: "Single", value: "single" },
{ description: "Couple", value: "couple" },
],
},
{
type: "select",
name: "dependents",
label: "How many dependents do you have?",
options: [
{ description: "0", value: 0 },
{ description: "1", value: 1 },
{ description: "2", value: 2 },
{ description: "3", value: 3 },
{ description: "4", value: 4 },
{ description: "5", value: 5 },
{ description: "6+", value: 6 },
],
},
{
name: "income",
type: "money",
helpText: "Combined if a couple",
label: "What is your yearly pre-tax income?",
},
{
type: "money",
label: "How much have you saved for a deposit?",
helpText: () => (
<p className="py-1 text-xs text-zinc-600">
Add your{" "}
<a
target="_blank"
rel="noopener noreferrer"
href="https://www.ato.gov.au/individuals-and-families/super-for-individuals-and-families/super/withdrawing-and-using-your-super/early-access-to-super/first-home-super-saver-scheme#Requestingadeterminationstep1"
className="underline hover:text-zinc-400"
>
FHSS determination
</a>{" "}
amount here if you have one
</p>
),
name: "deposit",
},
{
type: "money",
name: "expenses",
label: "What are your monthly living expenses?",
helpText: "e.g. food, clothes and other loan repayments, don't include rent",
},
{
type: "money",
name: "hecs",
label: "Do you have a HECS debt?",
helpText: "Add your total remaining amount",
},
];
const defaultSchemes: Scheme[] = [
{
name: "First Home Guarantee",
short: "FHBG",
link: "https://www.nhfic.gov.au/support-buy-home/first-home-guarantee",
helpDoc: "fhbg.md",
affects: "lmi",
getEligibility: qualifiesForFHBG,
},
];
const schema: Record<State, { questions: Question[]; schemes: Scheme[] }> = {
NSW: {
questions: [
{
label: "Where are you buying?",
type: "radio",
name: "location",
options: [
{ description: "Sydney, Newcastle, Lake Macquarie or Illawarra", value: "city" },
{ description: "Rest of State", value: "regional" },
],
},
],
schemes: [
{
name: "First Home Buyer Assistance Scheme",
short: "FHBAS",
link: "https://www.revenue.nsw.gov.au/grants-schemes/first-home-buyer/assistance-scheme",
helpDoc: "fhbas.md",
affects: "transferDuty",
getEligibility: qualifiesForDutyConcession,
},
{
name: "First Home Owner's Grant",
short: "FHOG",
link: "https://www.revenue.nsw.gov.au/grants-schemes/first-home-buyer/new-homes",
helpDoc: "fhog.md",
affects: "cashOnHand",
getEligibility: qualifiesForFHOG,
},
],
},
VIC: {
questions: [
{
label: "Where are you buying?",
type: "radio",
name: "location",
options: [
{ description: "Melbourne or Geelong", value: "city" },
{ description: "Rest of State", value: "regional" },
],
},
],
schemes: [
{
name: "FHB Duty Concession",
short: "FHB Duty",
link: "https://www.sro.vic.gov.au/fhbduty",
helpDoc: "fhbas.md",
affects: "transferDuty",
getEligibility: qualifiesForDutyConcession,
},
{
name: "First Home Owner's Grant",
short: "FHOG",
link: "https://www.revenue.nsw.gov.au/grants-schemes/first-home-buyer/new-homes",
helpDoc: "fhog.md",
affects: "cashOnHand",
getEligibility: qualifiesForFHOG,
},
],
},
QLD: {
questions: [
{
label: "Where are you buying?",
type: "radio",
name: "location",
options: [
{ description: "Brisbane, Gold Coast or Sunshine Coast", value: "city" },
{ description: "Rest of State", value: "regional" },
],
},
],
schemes: [
{
name: "First Home Concession",
short: "FH Concession",
link: "https://qro.qld.gov.au/duties/transfer-duty/concessions/homes/first-home/",
helpDoc: "fhbas.md",
affects: "transferDuty",
getEligibility: qualifiesForDutyConcession,
},
{
name: "First Home Owner's Grant",
short: "FHOG",
link: "https://qro.qld.gov.au/property-concessions-grants/first-home-grant/",
helpDoc: "fhog.md",
affects: "cashOnHand",
getEligibility: qualifiesForFHOG,
},
],
},
WA: {
questions: [
{
label: "Where are you buying?",
type: "radio",
name: "location",
options: [
{ description: "Perth", value: "city" },
{ description: "Rest of State", value: "regional" },
],
},
],
schemes: [],
},
SA: {
questions: [],
schemes: [],
},
ACT: {
questions: [],
schemes: [],
},
NT: {
questions: [],
schemes: [],
},
};