-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#385] Init set income target page layout
- Loading branch information
1 parent
bf4919d
commit 4e15fb2
Showing
4 changed files
with
267 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -1,7 +1,189 @@ | ||
import React from "react"; | ||
import React, { useMemo } from "react"; | ||
import { | ||
Tabs, | ||
Form, | ||
Radio, | ||
Row, | ||
Col, | ||
InputNumber, | ||
Select, | ||
Card, | ||
Space, | ||
} from "antd"; | ||
import { CurrentCaseState } from "../store"; | ||
import { yesNoOptions } from "../../../store/static"; | ||
import { InputNumberThousandFormatter } from "../../../lib"; | ||
|
||
const formStyle = { width: "100%" }; | ||
|
||
const IncomeTargetForm = ({ segmentId }) => { | ||
const [form] = Form.useForm(); | ||
|
||
const setTargetYourself = Form.useWatch("set_target_yourself", form); | ||
|
||
const currentCase = CurrentCaseState.useState((s) => s); | ||
|
||
const preventNegativeValue = (fieldName) => [ | ||
() => ({ | ||
validator(_, value) { | ||
if (value >= 0) { | ||
return Promise.resolve(); | ||
} | ||
form.setFieldValue(fieldName, null); | ||
return Promise.reject(new Error("Negative value not allowed")); | ||
}, | ||
}), | ||
]; | ||
|
||
const renderTargetInput = (key) => { | ||
switch (key) { | ||
case 1: | ||
return ( | ||
<Col span={24}> | ||
<Form.Item | ||
name="target" | ||
label="Target" | ||
rules={[ | ||
{ | ||
required: true, | ||
message: "Income target required.", | ||
}, | ||
]} | ||
> | ||
<InputNumber | ||
style={{ width: "40%" }} | ||
controls={false} | ||
addonAfter={currentCase.currency} | ||
{...InputNumberThousandFormatter} | ||
// disabled={!disableTarget || !enableEditCase} | ||
/> | ||
</Form.Item> | ||
</Col> | ||
); | ||
case 0: | ||
return ( | ||
<Col span={24}> | ||
<Row gutter={[12, 12]}> | ||
<Col span={8}> | ||
<Form.Item label="Region" name="region"> | ||
<Select | ||
style={formStyle} | ||
// options={regionOptions} | ||
// disabled={!disableTarget || !enableEditCase} | ||
// loading={loadingRegionOptions} | ||
// placeholder={ | ||
// regionOptionStatus === 404 | ||
// ? "Region not available" | ||
// : "Select or Type Region" | ||
// } | ||
// {...selectProps} | ||
/> | ||
</Form.Item> | ||
</Col> | ||
<Col span={8}> | ||
<Form.Item | ||
label="Average number of adults in the household" | ||
name="household_adult" | ||
rules={preventNegativeValue("household_adult")} | ||
> | ||
<InputNumber | ||
style={formStyle} | ||
// onChange={handleOnChangeHouseholdAdult} | ||
// disabled={!enableEditCase} | ||
controls={false} | ||
/> | ||
</Form.Item> | ||
</Col> | ||
<Col span={8}> | ||
<Form.Item | ||
label="Average number of children in the household" | ||
name="household_children" | ||
rules={preventNegativeValue("household_children")} | ||
> | ||
<InputNumber | ||
style={formStyle} | ||
// onChange={handleOnChangeHouseholdChild} | ||
// disabled={!enableEditCase} | ||
controls={false} | ||
/> | ||
</Form.Item> | ||
</Col> | ||
<Col span={24}> | ||
<Card className="card-income-target-wrapper"> | ||
<Space size={50}> | ||
<div className="income-target-value"> | ||
4486.00 {currentCase.currency} | ||
</div> | ||
<div className="income-target-text"> | ||
Living income benchmark value for a household per year | ||
</div> | ||
</Space> | ||
</Card> | ||
</Col> | ||
<Col span={24}> | ||
<Card className="card-lib-wrapper"> | ||
<Row align="middle"> | ||
<Col span={12} className="lib-text"> | ||
Information about Living Income Benchmark | ||
</Col> | ||
<Col span={12} align="end" className="lib-source"> | ||
Source: Living Income Benchmark | ||
</Col> | ||
</Row> | ||
</Card> | ||
</Col> | ||
</Row> | ||
</Col> | ||
); | ||
default: | ||
return ""; | ||
} | ||
}; | ||
|
||
return ( | ||
<Form form={form} layout="vertical" autoComplete="off"> | ||
<Row gutter={[12, 12]}> | ||
<Col span={24}> | ||
<Form.Item | ||
name="set_target_yourself" | ||
label="Do you want to set an income target yourself?" | ||
rules={[ | ||
{ | ||
required: true, | ||
message: "Please select yes or no", | ||
}, | ||
]} | ||
> | ||
<Radio.Group options={yesNoOptions} /> | ||
</Form.Item> | ||
</Col> | ||
{renderTargetInput(setTargetYourself)} | ||
</Row> | ||
</Form> | ||
); | ||
}; | ||
|
||
const SetIncomeTarget = () => { | ||
return <div>SetIncomeTarget</div>; | ||
const currentCase = CurrentCaseState.useState((s) => s); | ||
|
||
const segmentTabItems = useMemo(() => { | ||
return currentCase.segments.map((segment) => ({ | ||
label: segment.name, | ||
key: segment.id, | ||
children: <IncomeTargetForm segmentId={segment.id} />, | ||
})); | ||
}, [currentCase]); | ||
|
||
return ( | ||
<div id="step1"> | ||
<Tabs | ||
className="step-segment-tabs-container" | ||
type="card" | ||
items={segmentTabItems} | ||
tabBarGutter={5} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SetIncomeTarget; |
This file contains 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,80 @@ | ||
@import "../../../variables.scss"; | ||
|
||
.step-segment-tabs-container { | ||
&.ant-tabs { | ||
.ant-tabs-nav { | ||
margin: 0; | ||
|
||
.ant-tabs-nav-wrap { | ||
.ant-tabs-nav-list { | ||
.ant-tabs-tab { | ||
border-radius: 15px 15px 0 0 !important; | ||
background: #e1e0e0; | ||
|
||
&.ant-tabs-tab-active { | ||
background: #fff; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
.ant-tabs-content { | ||
background: #fff; | ||
padding: 20px 24px; | ||
border-radius: 0 20px 20px 20px; | ||
} | ||
} | ||
} | ||
|
||
.card-income-target-wrapper { | ||
font-family: "TabletGothic"; | ||
background: $primary-color; | ||
color: #fff; | ||
border-radius: 20px; | ||
|
||
.ant-card-body { | ||
padding: 20px; | ||
|
||
.income-target-value { | ||
font-family: "RocGrotesk"; | ||
font-weight: bold; | ||
font-size: 22px; | ||
} | ||
|
||
.income-target-text { | ||
max-width: 225px; | ||
} | ||
} | ||
} | ||
|
||
.card-lib-wrapper { | ||
background: #f2f2f2; | ||
border: 1px solid #e5e5e5; | ||
border-radius: 8px; | ||
|
||
.ant-card-body { | ||
padding: 20px; | ||
|
||
.lib-text, | ||
.lib-source { | ||
font-family: "TabletGothic" !important; | ||
} | ||
|
||
.lib-text { | ||
font-size: 16px; | ||
font-weight: 700; | ||
} | ||
|
||
.lib-source { | ||
font-size: 14px; | ||
font-weight: 400; | ||
text-decoration-line: underline; | ||
text-decoration-style: solid; | ||
text-decoration-skip-ink: none; | ||
text-decoration-thickness: auto; | ||
text-underline-offset: auto; | ||
text-underline-position: from-font; | ||
} | ||
} | ||
} |