|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070 |
- import {
- Button,
- FormControlLabel,
- Grid, InputAdornment, Switch, TextField, Typography,
- Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Paper, Select, MenuItem, IconButton
- } from '@mui/material';
- import MainCard from "../../../components/MainCard";
- import * as React from "react";
- import {useForm} from "react-hook-form";
- import {useContext, useEffect, useState} from "react";
- import LoadingComponent from "../../extra-pages/LoadingComponent";
- import {useLocation, useNavigate, useParams} from "react-router-dom";
- import {
- GeneralConfirmWindow,
- getComboValueByIdList,
- getComboValueByLabel,
- getDateString,
- getDeletedRecordWithRefList,
- getIdList,
- getNewRecordWithRefList, isOptionEqualToValue, isStringEmptyAfterTrim, notifyDeleteError, notifyDeleteSuccess,
- notifySaveSuccess, trimDataBeforePost,
- } from "../../../utils/CommonFunction";
- import Autocomplete from "@mui/material/Autocomplete";
- import axios from "axios";
- import {apiPath} from "../../../auth/utils";
- import {
- CHECK_EVENT_DUPLICATE,
- GET_CLIENT_PATH,
- GET_CONSULTANT_COMBO_LIST,
- GET_SUB_DIVISION_COMBO_LIST,
- POST_CLIENT_PATH
- } from "../../../utils/ApiPathConst";
- import {LIONER_BUTTON_THEME, LIONER_LONG_BUTTON_THEME, GENERAL_RED_COLOR} from "../../../themes/colorConst";
- import {eventFrequencyCombo, EVENT_REGION_COMBO, EVENT_TYPE_COMBO} from "../../../utils/ComboConst";
- import {DatePicker} from "@mui/x-date-pickers/DatePicker";
- import dayjs from "dayjs";
- import {DemoItem} from "@mui/x-date-pickers/internals/demo";
- import {AdapterDayjs} from "@mui/x-date-pickers/AdapterDayjs";
- import {LocalizationProvider} from "@mui/x-date-pickers/LocalizationProvider";
- import {ThemeProvider} from "@emotion/react";
- import UploadContext from "../../../components/UploadProvider";
- import {isObjEmpty} from "../../../utils/Utils";
- import AbilityContext from "../../../components/AbilityProvider";
- import {CARD_MAX_WIDTH} from "../../../themes/themeConst";
-
- const ClientForm = ({ refClientDetail, isNewRecord, getClientDetail }) => {
- const location = useLocation();
- const queryParams = new URLSearchParams(location.search);
- const refId = queryParams.get("refId");
-
- const params = useParams();
- const navigate = useNavigate();
- const ability = useContext(AbilityContext);
- const [onReady, setOnReady] = useState(false);
- const [errors, setErrors] = useState({});
- const [clientDetail, setClientDetail] = useState({});
- const [isCollectData, setIsCollectData] = useState(false);
- const [userConfirm, setUserConfirm] = useState(false);
- const [isEditing, setIsEditing] = useState(false);
- const { setIsUploading } = useContext(UploadContext);
- const [refClient, setRefClient] = useState({});
- const [consultantComboList, setConsultantComboList] = useState([]);
- const [selectedConsultant, setSelectedConsultant] = useState(null);
- const [isFirstInit, setIsFirstInit] = useState(true);
-
- // Form data
- const { register, getValues, setValue } = useForm();
- const [dob, setDob] = useState(null);
-
- const [dobError, setDobError] = React.useState(null);
-
- // Handler to navigate back
- const returnSearchPage = () => {
- navigate('/client');
- }
-
- const FIXED_HEADER_HEIGHT = 120; // <-- **IMPORTANT: Set this to the height of your actual fixed header in pixels**
-
- const handleFocus = (event) => {
- setTimeout(() => {
- const element = event.target;
- // Get the element's position relative to the viewport
- const rect = element.getBoundingClientRect();
-
- // Calculate the target scroll position (Current scroll position + element top position - Header height)
- const targetScrollY = window.scrollY + rect.top - FIXED_HEADER_HEIGHT;
-
- // Scroll the window to the new position
- window.scrollTo({
- top: targetScrollY,
- behavior: 'smooth'
- });
-
- // Ensure the element has focus
- element.focus();
-
- }, 100);
- };
-
- // Handler to enable edit mode
- const handleEditClick = () => {
- setIsEditing(true);
- };
-
- useEffect(() => {
- if (!isObjEmpty(refClient) && consultantComboList.length > 0 && isFirstInit) {
- const matched = consultantComboList.find(c => c.id === refClient.consultantId);
- setSelectedConsultant(matched || null);
- setValue("consultantId", matched || null);
- setIsFirstInit(false);
- }
- }, [refClient, consultantComboList, isFirstInit]);
-
- // 1. Earned Income
- const [earnedIncome, setEarnedIncome] = useState({
- salaryCurrent: '',
- salaryLast: '',
- bonusCurrent: '',
- bonusLast: '',
- otherEarnedCurrent: '',
- otherEarnedLast: ''
- });
- const handleEarnedIncomeChange = (field, value) => {
- setEarnedIncome(prev => ({ ...prev, [field]: value }));
- };
- const totalEarnedCurrent = (parseFloat(earnedIncome.salaryCurrent) || 0) +
- (parseFloat(earnedIncome.bonusCurrent) || 0) +
- (parseFloat(earnedIncome.otherEarnedCurrent) || 0);
- const totalEarnedLast = (parseFloat(earnedIncome.salaryLast) || 0) +
- (parseFloat(earnedIncome.bonusLast) || 0) +
- (parseFloat(earnedIncome.otherEarnedLast) || 0);
-
-
- // 2. Unearned Income (Updated for Current Year / Last Year columns as per Image 2)
- const [unearnedIncome, setUnearnedIncome] = useState({
- companyInterestCurrent: '',
- companyInterestLast: '',
- dividendsCurrent: '',
- dividendsLast: '',
- rentalsCurrent: '',
- rentalsLast: '',
- investmentIncomeCurrent: '',
- investmentIncomeLast: '',
- otherUnearnedCurrent: '',
- otherUnearnedLast: ''
- });
- const handleUnearnedIncomeChange = (field, value) => {
- setUnearnedIncome(prev => ({ ...prev, [field]: value }));
- };
- const totalUnearnedCurrent = (parseFloat(unearnedIncome.companyInterestCurrent) || 0) +
- (parseFloat(unearnedIncome.dividendsCurrent) || 0) +
- (parseFloat(unearnedIncome.rentalsCurrent) || 0) +
- (parseFloat(unearnedIncome.investmentIncomeCurrent) || 0) +
- (parseFloat(unearnedIncome.otherUnearnedCurrent) || 0);
- const totalUnearnedLast = (parseFloat(unearnedIncome.companyInterestLast) || 0) +
- (parseFloat(unearnedIncome.dividendsLast) || 0) +
- (parseFloat(unearnedIncome.rentalsLast) || 0) +
- (parseFloat(unearnedIncome.investmentIncomeLast) || 0) +
- (parseFloat(unearnedIncome.otherUnearnedLast) || 0);
-
-
- // Total Income Calculation
- const totalIncomeCurrent = totalEarnedCurrent + totalUnearnedCurrent;
- const totalIncomeLast = totalEarnedLast + totalUnearnedLast;
-
-
- // 3. Expenditure Statement
- const [expenditure, setExpenditure] = useState({
- mortgageCurrent: '',
- mortgageLast: '',
- rentCurrent: '',
- rentLast: '',
- schoolingCurrent: '',
- schoolingLast: '',
- membershipsCurrent: '',
- membershipsLast: '',
- otherExpenditureCurrent: '',
- otherExpenditureLast: '',
- interestCurrent: '',
- interestLast: '',
- principalCurrent: '',
- principalLast: '',
- otherPrefFinanceCurrent: '',
- otherPrefFinanceLast: ''
- });
- const handleExpenditureChange = (field, value) => {
- setExpenditure(prev => ({ ...prev, [field]: value }));
- };
- const totalExpenditureCurrent = (parseFloat(expenditure.mortgageCurrent) || 0) +
- (parseFloat(expenditure.rentCurrent) || 0) +
- (parseFloat(expenditure.schoolingCurrent) || 0) +
- (parseFloat(expenditure.membershipsCurrent) || 0) +
- (parseFloat(expenditure.otherExpenditureCurrent) || 0) +
- (parseFloat(expenditure.interestCurrent) || 0) +
- (parseFloat(expenditure.principalCurrent) || 0)+
- (parseFloat(expenditure.otherPrefFinanceCurrent) || 0);
- const totalExpenditureLast = (parseFloat(expenditure.mortgageLast) || 0) +
- (parseFloat(expenditure.rentLast) || 0) +
- (parseFloat(expenditure.schoolingLast) || 0) +
- (parseFloat(expenditure.membershipsLast) || 0) +
- (parseFloat(expenditure.otherExpenditureLast) || 0) +
- (parseFloat(expenditure.interestLast) || 0) +
- (parseFloat(expenditure.principalLast) || 0)+
- (parseFloat(expenditure.otherPrefFinanceLast) || 0);
-
-
- // 4. Liquid & Non-Liquid Assets (Combined for Image 4)
- const [assets, setAssets] = useState({
- // Liquid Assets
- cashDepositsCurrent: '',
- cashDepositsLast: '',
- investmentsCurrent: '',
- investmentsLast: '',
- otherLiquidCurrent: '',
- otherLiquidLast: '',
- // Non-Liquid Assets
- netBusinessInterestCurrent: '',
- netBusinessInterestLast: '',
- personalPropertiesCurrent: '',
- personalPropertiesLast: '',
- realEstateCurrent: '',
- realEstateLast: '',
- otherNonLiquidCurrent: '',
- otherNonLiquidLast: ''
- });
- const handleAssetsChange = (field, value) => {
- setAssets(prev => ({ ...prev, [field]: value }));
- };
- const totalLiquidAssetCurrent = (parseFloat(assets.cashDepositsCurrent) || 0) +
- (parseFloat(assets.investmentsCurrent) || 0) +
- (parseFloat(assets.otherLiquidCurrent) || 0);
- const totalLiquidAssetLast = (parseFloat(assets.cashDepositsLast) || 0) +
- (parseFloat(assets.investmentsLast) || 0) +
- (parseFloat(assets.otherLiquidLast) || 0);
-
- const totalNonLiquidAssetCurrent = (parseFloat(assets.netBusinessInterestCurrent) || 0) +
- (parseFloat(assets.personalPropertiesCurrent) || 0) +
- (parseFloat(assets.realEstateCurrent) || 0) + // ← NEW
- (parseFloat(assets.otherNonLiquidCurrent) || 0);
-
- const totalNonLiquidAssetLast = (parseFloat(assets.netBusinessInterestLast) || 0) +
- (parseFloat(assets.personalPropertiesLast) || 0) +
- (parseFloat(assets.realEstateLast) || 0) + // ← NEW
- (parseFloat(assets.otherNonLiquidLast) || 0);
-
- const totalAssetsCurrent = totalLiquidAssetCurrent + totalNonLiquidAssetCurrent;
- const totalAssetsLast = totalLiquidAssetLast + totalNonLiquidAssetLast;
-
-
- // 5. Liabilities (Combined with Existing Premium Financing/Policy Loan section from Image 5)
- const [liabilities, setLiabilities] = useState({
- personalLoansCurrent: '',
- personalLoansLast: '',
- mortgagesCurrent: '',
- mortgagesLast: '',
- marginAccountCurrent: '',
- marginAccountLast: '',
- loanGuaranteesCurrent: '',
- loanGuaranteesLast: '',
- bankingFacilityCurrent: '',
- bankingFacilityLast: '',
- // Existing Premium Financing/Policy Loan (Principal and Other from Image 5)
- prefFinancePrincipalCurrent: '',
- prefFinancePrincipalLast: '',
- prefFinanceOtherCurrent: '',
- prefFinanceOtherLast: '',
- });
- const handleLiabilitiesChange = (field, value) => {
- setLiabilities(prev => ({ ...prev, [field]: value }));
- };
-
- const totalLiabilitiesCurrent = (parseFloat(liabilities.personalLoansCurrent) || 0) +
- (parseFloat(liabilities.mortgagesCurrent) || 0) +
- (parseFloat(liabilities.marginAccountCurrent) || 0) +
- (parseFloat(liabilities.loanGuaranteesCurrent) || 0) +
- (parseFloat(liabilities.bankingFacilityCurrent) || 0) +
- (parseFloat(liabilities.prefFinancePrincipalCurrent) || 0) +
- (parseFloat(liabilities.prefFinanceOtherCurrent) || 0);
- const totalLiabilitiesLast = (parseFloat(liabilities.personalLoansLast) || 0) +
- (parseFloat(liabilities.mortgagesLast) || 0) +
- (parseFloat(liabilities.marginAccountLast) || 0) +
- (parseFloat(liabilities.loanGuaranteesLast) || 0) +
- (parseFloat(liabilities.bankingFacilityLast) || 0) +
- (parseFloat(liabilities.prefFinancePrincipalLast) || 0) +
- (parseFloat(liabilities.prefFinanceOtherLast) || 0);
-
- const dobErrorMessage = React.useMemo(() => {
- switch (dobError) {
- case 'invalidDate': {
- return "Invalid date";
- }
- }
- }, [dobError]);
-
- // DELETE WINDOW RELATED
- const [isWindowOpen, setIsWindowOpen] = React.useState(false);
-
- const handleClose = () => {
- setIsWindowOpen(false);
- };
-
- const handleDeleteClick = () => {
- setIsWindowOpen(true);
- };
-
- const copyClientAsNew = () => {
- navigate(`/event/maintain/-1?refId=${params.id}`);
- };
-
- const formatNumberForDisplay = (num) => {
- console.log(num);
- // 1. Handle null, undefined, or empty string input gracefully (return as is)
- if (num === null || num === undefined || num === '') return '';
-
- // Convert to a string and use regex to allow up to one decimal point and digits
- const numString = String(num);
-
- // Check if the input ends with a decimal point (e.g., '100.')
- // We preserve this during display so the user can continue typing decimals.
- const endsWithDecimal = numString.endsWith('.');
-
- // Attempt to parse the number
- const numericValue = parseFloat(numString);
-
- // 2. If it's NaN (like if the input was only '.'), return the original string
- if (isNaN(numericValue) && numString !== '.') return numString;
-
- // 3. Use Intl.NumberFormat to add commas
- const formatted = new Intl.NumberFormat('en-US', {
- minimumFractionDigits: 0,
- maximumFractionDigits: 2,
- }).format(numericValue);
-
- // 4. If the original string ended with a decimal (e.g., '123.'),
- // re-append the decimal point because Intl.NumberFormat removes it for whole numbers.
- if (endsWithDecimal) {
- // If the formatted number doesn't already contain a decimal point
- if (!formatted.includes('.')) {
- return formatted + '.';
- }
- }
-
- console.log(formatted);
-
- return formatted;
- };
-
- // Function to clean the string input back to a raw number string for state storage
- const cleanNumberForState = (inputString) => {
- if (inputString === null || inputString === undefined) return '';
-
- // 1. Remove commas (,) and any thousand separators
- let cleanedString = inputString.toString().replace(/,/g, '');
-
- // 2. Check for multiple decimal points (only keep the first one)
- const parts = cleanedString.split('.');
- if (parts.length > 2) {
- // If there are multiple decimals, we revert to the state before the last one was typed
- // This prevents '123.45.' from breaking the number
- return parts[0] + '.' + parts.slice(1).join('');
- }
-
- // 3. Optional: Remove characters that are NOT digits or a decimal point
- // cleanedString = cleanedString.replace(/[^0-9.]/g, '');
-
- // Return the cleaned string. We keep it as a STRING to preserve leading zeros
- // and prevent immediate number conversion issues.
- return cleanedString;
- };
-
- function updateData() {
- axios.delete(`${apiPath}${GET_CLIENT_PATH}/${params.id}`)
- .then((response) => {
- if (response.status === 204) {
- notifyDeleteSuccess();
- setIsWindowOpen(false);
- returnSearchPage();
- }
- })
- .catch(error => {
- console.log(error);
- return false;
- });
- }
-
- function getConsultantCombo() {
- axios.get(`${apiPath}${GET_CONSULTANT_COMBO_LIST}`, {
- params: {}
- })
- .then((response) => {
- if (response.status === 200) {
- setConsultantComboList(response.data.records);
- }
- })
- .catch(error => {
- console.log(error);
- return false;
- });
- }
-
- useEffect(() => {
- if (!isNewRecord) {
- setRefClient(refClientDetail);
- }
- getConsultantCombo();
- }, []);
-
- useEffect(() => {
- if (!isObjEmpty(refClient)) {
- setValue("lastname", refClient.lastname);
- setValue("firstname", refClient.firstname);
- setValue("email", refClient.email);
- setValue("phone1", refClient.phone1);
- setValue("phone1Code", refClient.phone1Code);
- setValue("phone2", refClient.phone2);
- setValue("remarks", refClient.remarks);
- setValue("caseManagerId", 1);
-
- setValue("crAddressRoom", refClient.crAddressRoom);
- setValue("crAddressFloor", refClient.crAddressFloor);
- setValue("crAddressBuilding", refClient.crAddressBuilding);
- setValue("crAddressStreet", refClient.crAddressStreet);
- setValue("crAddressStreet", refClient.crAddressStreet);
- setValue("crAddressArea", refClient.crAddressArea);
- setValue("crAddressCity", refClient.crAddressCity);
- setValue("crAddressCountry", refClient.crAddressCountry);
- setValue("crAddressPostalCode", refClient.crAddressPostalCode);
-
- setValue("corAddressRoom", refClient.corAddressRoom);
- setValue("corAddressFloor", refClient.corAddressFloor);
- setValue("corAddressBlock", refClient.corAddressBlock);
- setValue("corAddressBuilding", refClient.corAddressBuilding);
- setValue("corAddressStreet", refClient.corAddressStreet);
- setValue("corAddressArea", refClient.corAddressArea);
- setValue("corAddressCity", refClient.corAddressCity);
- setValue("corAddressCountry", refClient.corAddressCountry);
- setValue("corAddressPostalCode", refClient.corAddressPostalCode);
-
- earnedIncome.salaryCurrent = refClient.salaryCurrent;
- earnedIncome.salaryLast = refClient.salaryLast;
- earnedIncome.bonusCurrent = refClient.bonusCurrent;
- earnedIncome.bonusLast = refClient.bonusLast;
- earnedIncome.otherEarnedCurrent = refClient.otherEarnedCurrent;
- earnedIncome.otherEarnedLast = refClient.otherEarnedLast;
-
- unearnedIncome.companyInterestCurrent = refClient.companyInterestCurrent;
- unearnedIncome.companyInterestLast = refClient.companyInterestLast;
- unearnedIncome.dividendsCurrent = refClient.dividendsCurrent;
- unearnedIncome.dividendsLast = refClient.dividendsLast;
- unearnedIncome.rentalsCurrent = refClient.rentalsCurrent;
- unearnedIncome.rentalsLast = refClient.rentalsLast;
- unearnedIncome.investmentIncomeCurrent = refClient.investmentIncomeCurrent;
- unearnedIncome.investmentIncomeLast = refClient.investmentIncomeLast;
- unearnedIncome.otherUnearnedCurrent = refClient.otherUnearnedCurrent;
- unearnedIncome.otherUnearnedLast = refClient.otherUnearnedLast;
-
- expenditure.mortgageCurrent = refClient.mortgageCurrent;
- expenditure.mortgageLast = refClient.mortgageLast;
- expenditure.rentCurrent = refClient.rentCurrent;
- expenditure.rentLast = refClient.rentLast;
- expenditure.schoolingCurrent = refClient.schoolingCurrent;
- expenditure.schoolingLast = refClient.schoolingLast;
- expenditure.membershipsCurrent = refClient.membershipsCurrent;
- expenditure.membershipsLast = refClient.membershipsLast;
- expenditure.otherExpenditureCurrent = refClient.otherExpenditureCurrent;
- expenditure.otherExpenditureLast = refClient.otherExpenditureLast;
-
- expenditure.interestCurrent = refClient.interestCurrent;
- expenditure.interestLast = refClient.interestLast;
- expenditure.principalCurrent = refClient.principalCurrent;
- expenditure.principalLast = refClient.principalLast;
- expenditure.otherPrefFinanceCurrent = refClient.otherPrefFinanceCurrent;
- expenditure.otherPrefFinanceLast = refClient.otherPrefFinanceLast;
-
- assets.cashDepositsCurrent = refClient.cashDepositsCurrent;
- assets.cashDepositsLast = refClient.cashDepositsLast;
- assets.investmentsCurrent = refClient.investmentsCurrent;
- assets.investmentsLast = refClient.investmentsLast;
- assets.otherLiquidCurrent = refClient.otherLiquidCurrent;
- assets.otherLiquidLast = refClient.otherLiquidLast;
- assets.netBusinessInterestCurrent = refClient.netBusinessInterestCurrent;
- assets.netBusinessInterestLast = refClient.netBusinessInterestLast;
- assets.personalPropertiesCurrent = refClient.personalPropertiesCurrent;
- assets.personalPropertiesLast = refClient.personalPropertiesLast;
- assets.realEstateCurrent = refClient.realEstateCurrent;
- assets.realEstateLast = refClient.realEstateLast;
- assets.otherNonLiquidCurrent = refClient.otherNonLiquidCurrent;
- assets.otherNonLiquidLast = refClient.otherNonLiquidLast;
-
- liabilities.personalLoansCurrent = refClient.personalLoansCurrent;
- liabilities.personalLoansLast = refClient.personalLoansLast;
- liabilities.mortgagesCurrent = refClient.mortgagesCurrent;
- liabilities.mortgagesLast = refClient.mortgagesLast;
- liabilities.marginAccountCurrent = refClient.marginAccountCurrent;
- liabilities.marginAccountLast = refClient.marginAccountLast;
- liabilities.loanGuaranteesCurrent = refClient.loanGuaranteesCurrent;
- liabilities.loanGuaranteesLast = refClient.loanGuaranteesLast;
- liabilities.bankingFacilityCurrent = refClient.bankingFacilityCurrent;
- liabilities.bankingFacilityLast = refClient.bankingFacilityLast;
- liabilities.prefFinancePrincipalCurrent = refClient.prefFinancePrincipalCurrent;
- liabilities.prefFinancePrincipalLast = refClient.prefFinancePrincipalLast;
-
- liabilities.prefFinanceOtherCurrent = refClient.prefFinanceOtherCurrent;
- liabilities.prefFinanceOtherLast = refClient.prefFinanceOtherLast;
-
-
- //totalEarnedCurrent = refClient.totalEarnedCurrent;
- //totalEarnedLast = refClient.totalEarnedLast;
-
- // Set consultantId for Autocomplete
- const selectedConsultant = consultantComboList.find(
- (option) => option.id === refClient.consultantId
- );
- setValue("consultantId", selectedConsultant || null);
-
- setDob(dayjs(getDateString(refClient.dob)));
- }
- }, [refClient, consultantComboList]);
-
- useEffect(() => {
- if (!isObjEmpty(refClient)) {
- setOnReady(true);
- } else if (isNewRecord) {
- setOnReady(true);
- setIsEditing(true);
- }
- }, [refClient]);
-
- useEffect(() => {
- if (isCollectData) {
- const values = getValues();
- const formErrors = {};
-
- if (isStringEmptyAfterTrim(values.lastname)) {
- formErrors.lastname = 'Last Name is required';
- }
-
- setErrors(formErrors);
- if (Object.keys(formErrors).length === 0) {
- let data = {};
- data["id"] = isNewRecord ? params.id : refClientDetail.id;
- data["lastname"] = values.lastname;
- data["firstname"] = values.firstname;
- data["email"] = values.email;
- data["phone1"] = values.phone1;
- data["phone1Code"] = values.phone1Code;
- data["phone2"] = values.phone2;
- data["remarks"] = values.remarks;
- data["caseManagerId"] = 1;
- data["consultantId"] = values.consultantId ? values.consultantId.id : null;
- data["dob"] = dob === null ? null : dayjs(dob).format('YYYY-MM-DD');
- data["crAddressRoom"] = values.crAddressRoom;
- data["crAddressFloor"] = values.crAddressFloor;
- data["crAddressBlock"] = values.crAddressBlock;
- data["crAddressBuilding"] = values.crAddressBuilding;
- data["crAddressStreet"] = values.crAddressStreet;
- data["crAddressArea"] = values.crAddressArea;
- data["crAddressCity"] = values.crAddressCity;
- data["crAddressCountry"] = values.crAddressCountry;
- data["crAddressPostalCode"] = values.crAddressPostalCode;
- data["corAddressRoom"] = values.corAddressRoom;
- data["corAddressFloor"] = values.corAddressFloor;
- data["corAddressBlock"] = values.corAddressBlock;
- data["corAddressBuilding"] = values.corAddressBuilding;
- data["corAddressStreet"] = values.corAddressStreet;
- data["corAddressArea"] = values.corAddressArea;
- data["corAddressCity"] = values.corAddressCity;
- data["corAddressCountry"] = values.corAddressCountry;
- data["corAddressPostalCode"] = values.corAddressPostalCode;
-
- data = {
- ...data, // Keep all existing header fields
- ...earnedIncome,
- ...unearnedIncome,
- ...expenditure,
- ...assets,
- ...liabilities,
- totalEarnedCurrent,
- totalEarnedLast,
- totalUnearnedCurrent,
- totalUnearnedLast,
- totalAssetsCurrent,
- totalAssetsLast,
- totalIncomeCurrent,
- totalIncomeLast,
- totalExpenditureCurrent,
- totalExpenditureLast,
- totalLiquidAssetCurrent,
- totalLiquidAssetLast,
- totalNonLiquidAssetCurrent,
- totalNonLiquidAssetLast,
- totalLiabilitiesCurrent,
- totalLiabilitiesLast,
- };
-
- setClientDetail(data);
- } else if (isCollectData) {
- setUserConfirm(false);
- setIsCollectData(false);
- }
- }
- }, [isCollectData]);
-
- useEffect(() => {
- if (userConfirm) {
- postClient();
- }
- setUserConfirm(false);
- }, [clientDetail]);
-
- const submitData = () => {
- setIsCollectData(!isCollectData);
- setUserConfirm(true);
- };
-
- const updateIsEdit = () => {
- setIsEditing(!isEditing);
- };
-
- function postClient() {
- setIsUploading(true);
- const temp = trimDataBeforePost(clientDetail);
- axios.post(`${apiPath}${POST_CLIENT_PATH}`, temp)
- .then((response) => {
- if (response.status === 200) {
- notifySaveSuccess();
- if (isNewRecord) {
- setIsUploading(false);
- navigate('/client');
- } else {
- setIsUploading(false);
- getClientDetail(params.id);
- setIsEditing(!isEditing);
- }
- setIsCollectData(!isCollectData);
- }
- })
- .catch(error => {
- if (error.response.status === 422) {
- const formErrors = {};
- formErrors.subDivision = error.response.data.error;
- setErrors(formErrors);
- }
- console.log(error);
- setIsUploading(false);
- return false;
- });
- }
-
- return (
- !onReady ?
- <LoadingComponent />
- :
- <MainCard content={false} sx={{ width: CARD_MAX_WIDTH }}>
- <Typography variant="h5" sx={{ mt: 3, ml: 3, mb: 1 }}>
- Information
- </Typography>
- <form>
- <Grid container>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ mt: 1, ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"flex-start"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, mt: 1, display: 'flex', alignItems: 'flex-start' }}>
- <Typography variant="lionerSize" component="span">
- Client Code: <Typography sx={{ color: GENERAL_RED_COLOR }} component="span">*</Typography>
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- {...register("clientCode", { value: refClient.clientCode })}
- id='clientCode'
- required
- inputProps={{ maxLength: 255, style: { fontSize: '1.1rem' } }}
- InputProps={{ style: { minHeight: '42.5px', maxHeight: '50vh' } }}
- multiline
- maxRows={3}
- error={!!errors.lastname}
- helperText={errors.lastname}
- disabled
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ mt: 1, ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"flex-start"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, mt: 1, display: 'flex', alignItems: 'flex-start' }}>
- <Typography variant="lionerSize" component="span">
- Last Name(Surname/Family Name): <Typography sx={{ color: GENERAL_RED_COLOR }} component="span">*</Typography>
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- {...register("lastname", { value: refClient.lastname })}
- id='lastname'
- required
- inputProps={{ maxLength: 255, style: { fontSize: '1.1rem' } }}
- InputProps={{ style: { minHeight: '42.5px', maxHeight: '50vh' } }}
- multiline
- maxRows={3}
- error={!!errors.lastname}
- helperText={errors.lastname}
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ mt: 1, ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"flex-start"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, mt: 1, display: 'flex', alignItems: 'flex-start' }}>
- <Typography variant="lionerSize" component="span">
- First Name(Given Name/Forename):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- {...register("firstname", { value: refClient.firstname })}
- id='firstname'
- required
- inputProps={{ maxLength: 255, style: { fontSize: '1.1rem' } }}
- InputProps={{ style: { minHeight: '42.5px', maxHeight: '50vh' } }}
- multiline
- maxRows={3}
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Date of Birth:
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={7}>
- <LocalizationProvider dateAdapter={AdapterDayjs}>
- <DemoItem components={['DatePicker']}>
- <DatePicker
- id="dob"
- size="small"
- required
- value={dob === null ? null : dayjs(dob)}
- onChange={(newValue) => setDob(newValue)}
- format="DD/MM/YYYY"
- onError={(newError) => setDobError(newError)}
- slotProps={{
- field: { clearable: true },
- textField: {
- error: !!errors.dob || dobError,
- helperText: dobError ? dobErrorMessage : errors.dob,
- },
- }}
- disabled={!isEditing}
- />
- </DemoItem>
- </LocalizationProvider>
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Email Address:
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("email", { value: refClient.email })}
- id='email'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Phone Number:
- </Typography>
- </Grid>
- <Grid item xs={1} sm={1} md={1} lg={1.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 5 }}
- size="small"
- {...register("phone1Code", { value: refClient.phote1Code })}
- id='phone1Code'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- <Grid item xs={0.1} sm={0.1} md={0.1} lg={0.15}>
- </Grid>
- <Grid item xs={6} sm={6} md={6} lg={5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 20 }}
- size="small"
- {...register("phone1", { value: refClient.phone1 })}
- id='phone1'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"flex-start"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Case Manager: <Typography sx={{ color: GENERAL_RED_COLOR }} component="span"></Typography>
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("cm", { value: "N/A" })}
- id='cm'
- disabled
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"flex-start"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Consultant: <Typography sx={{ color: GENERAL_RED_COLOR }} component="span"></Typography>
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <Autocomplete
- disablePortal
- id="consultant-combo-box"
- options={consultantComboList}
- getOptionLabel={(option) => option.name || ""}
- isOptionEqualToValue={(option, value) => option.id === value.id}
- value={selectedConsultant}
- onChange={(e, v) => {
- setSelectedConsultant(v);
- setValue('consultantId', v); }
- }
- renderInput={(params) => (
- <TextField
- {...params}
- label="Consultant"
- name="consultant"
- />
- )}
- disabled={!isEditing}
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Rs. Address(Room):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("crAddressRoom", { value: refClient.crAddressRoom })}
- id='crAddressRoom'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Rs. Address(Floor):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("crAddressFloor", { value: refClient.crAddressFloor })}
- id='crAddressFloor'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Rs. Address(Block):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("crAddressBlock", { value: refClient.crAddressBlock })}
- id='crAddressBlock'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Rs. Address(Buliding):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("crAddressBuilding", { value: refClient.crAddressBuilding })}
- id='crAddressBuilding'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Rs. Address(Street):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("crAddressStreet", { value: refClient.crAddressStreet })}
- id='crAddressStreet'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Rs. Address(Area):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("crAddressArea", { value: refClient.crAddressArea })}
- id='crAddressArea'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Rs. Address(City):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("crAddressCity", { value: refClient.crAddressCity })}
- id='crAddressCity'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Rs. Address(Country):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("crAddressCountry", { value: refClient.crAddressCountry })}
- id='crAddressCountry'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Rs. Address(Postal Code):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("crAddressPostalCode", { value: refClient.crAddressPostalCode })}
- id='crAddressPostalCode'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Corr. Address(Room):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("corAddressRoom", { value: refClient.corAddressRoom })}
- id='corAddressRoom'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Corr. Address(Floor):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("corAddressFloor", { value: refClient.corAddressFloor })}
- id='corAddressFloor'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Corr. Address(Block):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("corAddressBlock", { value: refClient.corAddressBlock })}
- id='corAddressBlock'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Corr. Address(Buliding):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("corAddressBuilding", { value: refClient.corAddressBuilding })}
- id='corAddressBuilding'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Corr. Address(Street):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("corAddressStreet", { value: refClient.corAddressStreet })}
- id='corAddressStreet'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Corr. Address(Area):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("corAddressArea", { value: refClient.corAddressArea })}
- id='corAddressArea'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Corr. Address(City):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("corAddressCity", { value: refClient.corAddressCity })}
- id='corAddressCity'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Corr. Address(Country):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("corAddressCountry", { value: refClient.corAddressCountry })}
- id='corAddressCountry'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, display: 'flex', alignItems: 'center' }}>
- <Typography variant="lionerSize" component="span">
- Corr. Address(Postal Code):
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={6.5}>
- <TextField
- fullWidth
- inputProps={{ maxLength: 50 }}
- size="small"
- {...register("corAddressPostalCode", { value: refClient.corAddressPostalCode })}
- id='corAddressPostalCode'
- disabled={!isEditing}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3, mt: 1 }}>
- <Grid container alignItems={"flex-start"}>
- <Grid item xs={4} sm={4} md={4} lg={4} sx={{ ml: 3, mr: 3, mt: 1, display: 'flex', alignItems: 'flex-start' }}>
- <Typography variant="lionerSize" component="span">
- Remarks:
- </Typography>
- </Grid>
- <Grid item xs={7} sm={7} md={7} lg={7}>
- <TextField
- fullWidth
- {...register("remarks", { value: refClient.remarks })}
- id='remarks'
- required
- disabled={!isEditing}
- inputProps={{ maxLength: 500, style: { fontSize: '1.1rem' } }}
- InputProps={{ style: { minHeight: '42.5px', maxHeight: '50vh' } }}
- multiline
- maxRows={10}
- autoComplete="off"
- />
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} sm={12} md={12} lg={5.5} sx={{ ml: 3, mr: 3, mb: 3 }}>
- </Grid>
- <Grid>
- {/* ======================================================================= */}
- {/* --- START: EARNED INCOME 薪酬收入 (Image 1) --- */}
- {/* ======================================================================= */}
- <Grid item xs={12}>
- <Typography variant="h5" sx={{ mt: 3, mb: 1, px: 2, backgroundColor: '#d0d0d0', py: 1, borderRadius: 1 }}>
- EARNED INCOME 薪酬收入
- </Typography>
- <TableContainer component={Paper} elevation={1}>
- <Table size="small" aria-label="earned income table">
- <TableHead sx={{ backgroundColor: '#f0f0f0' }}>
- <TableRow>
- <TableCell sx={{ fontWeight: 'bold', width: '40%' }}></TableCell>
- <TableCell align="center" sx={{ fontWeight: 'bold', width: '30%' }}>Current Year 本年度</TableCell>
- <TableCell align="center" sx={{ fontWeight: 'bold', width: '30%' }}>Last Year 上年度</TableCell>
- </TableRow>
- </TableHead>
- <TableBody>
- {/* Salary */}
- <TableRow>
- <TableCell>Salary 薪酬</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(earnedIncome.salaryCurrent)} onChange={(e) => handleEarnedIncomeChange('salaryCurrent', cleanNumberForState(cleanNumberForState(e.target.value)))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(earnedIncome.salaryLast)} onChange={(e) => handleEarnedIncomeChange('salaryLast', cleanNumberForState(cleanNumberForState(e.target.value)))}
- />
- </TableCell>
- </TableRow>
- {/* Bonus */}
- <TableRow>
- <TableCell>Bonus 花紅</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(earnedIncome.bonusCurrent)} onChange={(e) => handleEarnedIncomeChange('bonusCurrent', cleanNumberForState(cleanNumberForState(e.target.value)))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(earnedIncome.bonusLast)} onChange={(e) => handleEarnedIncomeChange('bonusLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Other */}
- <TableRow>
- <TableCell>Other 其他</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(earnedIncome.otherEarnedCurrent)} onChange={(e) => handleEarnedIncomeChange('otherEarnedCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(earnedIncome.otherEarnedLast)} onChange={(e) => handleEarnedIncomeChange('otherEarnedLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Total Earned Income */}
- <TableRow sx={{ '& td': { fontWeight: 'bold', backgroundColor: '#e0e0e0' } }}>
- <TableCell>Total Earned Income 薪酬收入總額</TableCell>
- <TableCell align="right">
- <TextField fullWidth variant="filled" size="small" readOnly
- value={formatNumberForDisplay(totalEarnedCurrent.toFixed(0))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField fullWidth variant="filled" size="small" readOnly
- value={formatNumberForDisplay(totalEarnedLast.toFixed(0))}
- />
- </TableCell>
- </TableRow>
- </TableBody>
- </Table>
- </TableContainer>
- </Grid>
- {/* --- END: EARNED INCOME --- */}
-
-
- {/* ======================================================================= */}
- {/* --- START: UNEARNED INCOME 非薪酬收入 (Image 2 - UPDATED) --- */}
- {/* ======================================================================= */}
- <Grid item xs={12}>
- <Typography variant="h5" sx={{ mt: 5, mb: 1, px: 2, backgroundColor: '#d0d0d0', py: 1, borderRadius: 1 }}>
- UNEARNED INCOME 非薪酬收入
- </Typography>
- <TableContainer component={Paper} elevation={1}>
- <Table size="small" aria-label="unearned income table">
- <TableHead sx={{ backgroundColor: '#f0f0f0' }}>
- <TableRow>
- <TableCell sx={{ fontWeight: 'bold', width: '40%' }}></TableCell>
- <TableCell align="center" sx={{ fontWeight: 'bold', width: '30%' }}>Current Year 本年度</TableCell>
- <TableCell align="center" sx={{ fontWeight: 'bold', width: '30%' }}>Last Year 上年度</TableCell>
- </TableRow>
- </TableHead>
- <TableBody>
- {/* Company Interest */}
- <TableRow>
- <TableCell>Company Interest 公司收益</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(unearnedIncome.companyInterestCurrent)} onChange={(e) => handleUnearnedIncomeChange('companyInterestCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(unearnedIncome.companyInterestLast)} onChange={(e) => handleUnearnedIncomeChange('companyInterestLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Dividends */}
- <TableRow>
- <TableCell>Dividends 股息</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(unearnedIncome.dividendsCurrent)} onChange={(e) => handleUnearnedIncomeChange('dividendsCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(unearnedIncome.dividendsLast)} onChange={(e) => handleUnearnedIncomeChange('dividendsLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Rentals */}
- <TableRow>
- <TableCell>Rentals 租金</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(unearnedIncome.rentalsCurrent)} onChange={(e) => handleUnearnedIncomeChange('rentalsCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(unearnedIncome.rentalsLast)} onChange={(e) => handleUnearnedIncomeChange('rentalsLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Investment Income */}
- <TableRow>
- <TableCell>Investment Income 投資收益</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(unearnedIncome.investmentIncomeCurrent)} onChange={(e) => handleUnearnedIncomeChange('investmentIncomeCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(unearnedIncome.investmentIncomeLast)} onChange={(e) => handleUnearnedIncomeChange('investmentIncomeLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Other Unearned */}
- <TableRow>
- <TableCell>Other 其他</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(unearnedIncome.otherUnearnedCurrent)} onChange={(e) => handleUnearnedIncomeChange('otherUnearnedCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(unearnedIncome.otherUnearnedLast)} onChange={(e) => handleUnearnedIncomeChange('otherUnearnedLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Total Unearned Income */}
- <TableRow sx={{ '& td': { fontWeight: 'bold', backgroundColor: '#e0e0e0' } }}>
- <TableCell>Total Unearned Income 非薪酬收入總額</TableCell>
- <TableCell align="right">
- <TextField fullWidth variant="filled" size="small" readOnly
- value={formatNumberForDisplay(totalUnearnedCurrent.toFixed(0))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField fullWidth variant="filled" size="small" readOnly
- value={formatNumberForDisplay(totalUnearnedLast.toFixed(0))}
- />
- </TableCell>
- </TableRow>
- {/* Total Income */}
- <TableRow sx={{ '& td': { fontWeight: 'bold', backgroundColor: '#d0d0d0' } }}>
- <TableCell>Total Income 收入總額</TableCell>
- <TableCell align="right">
- <TextField fullWidth variant="filled" size="small" readOnly
- value={formatNumberForDisplay(totalIncomeCurrent.toFixed(0))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField fullWidth variant="filled" size="small" readOnly
- value={formatNumberForDisplay(totalIncomeLast.toFixed(0))}
- />
- </TableCell>
- </TableRow>
- </TableBody>
- </Table>
- </TableContainer>
- </Grid>
- {/* --- END: UNEARNED INCOME --- */}
-
-
- {/* ======================================================================= */}
- {/* --- START: EXPENDITURE STATEMENT 開支報表 (Image 3) --- */}
- {/* ======================================================================= */}
- <Grid item xs={12}>
- <Typography variant="h5" sx={{ mt: 5, mb: 1, px: 2, backgroundColor: '#d0d0d0', py: 1, borderRadius: 1 }}>
- Expenditure Statement 開支報表
- </Typography>
- <TableContainer component={Paper} elevation={1}>
- <Table size="small" aria-label="expenditure statement table">
- <TableHead sx={{ backgroundColor: '#f0f0f0' }}>
- <TableRow>
- <TableCell sx={{ fontWeight: 'bold', width: '40%' }}></TableCell>
- <TableCell align="center" sx={{ fontWeight: 'bold', width: '30%' }}>Current Year 本年度</TableCell>
- <TableCell align="center" sx={{ fontWeight: 'bold', width: '30%' }}>Last Year 上年度</TableCell>
- </TableRow>
- </TableHead>
- <TableBody>
- {/* Mortgage */}
- <TableRow>
- <TableCell>Mortgage 按揭</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(expenditure.mortgageCurrent)} onChange={(e) => handleExpenditureChange('mortgageCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(expenditure.mortgageLast)} onChange={(e) => handleExpenditureChange('mortgageLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Rent */}
- <TableRow>
- <TableCell>Rent 租金</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(expenditure.rentCurrent)} onChange={(e) => handleExpenditureChange('rentCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(expenditure.rentLast)} onChange={(e) => handleExpenditureChange('rentLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Schooling for Children */}
- <TableRow>
- <TableCell>Schooling for Children 子女教育</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(expenditure.schoolingCurrent)} onChange={(e) => handleExpenditureChange('schoolingCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(expenditure.schoolingLast)} onChange={(e) => handleExpenditureChange('schoolingLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Memberships */}
- <TableRow>
- <TableCell>Memberships 會籍</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(expenditure.membershipsCurrent)} onChange={(e) => handleExpenditureChange('membershipsCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(expenditure.membershipsLast)} onChange={(e) => handleExpenditureChange('membershipsLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Other Expenditure */}
- <TableRow>
- <TableCell>Other 其他</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(expenditure.otherExpenditureCurrent)} onChange={(e) => handleExpenditureChange('otherExpenditureCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(expenditure.otherExpenditureLast)} onChange={(e) => handleExpenditureChange('otherExpenditureLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Interest */}
- <TableRow>
- <TableCell>Interest 利息還款額</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(expenditure.interestCurrent)} onChange={(e) => handleExpenditureChange('interestCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(expenditure.interestLast)} onChange={(e) => handleExpenditureChange('interestLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Principal */}
- <TableRow>
- <TableCell>Principal 本金還款額</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(expenditure.principalCurrent)} onChange={(e) => handleExpenditureChange('principalCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(expenditure.principalLast)} onChange={(e) => handleExpenditureChange('principalLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Other */}
- <TableRow>
- <TableCell>Other Loan 其他</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(expenditure.otherPrefFinanceCurrent)} onChange={(e) => handleExpenditureChange('otherPrefFinanceCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(expenditure.otherPrefFinanceLast)} onChange={(e) => handleExpenditureChange('otherPrefFinanceLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Empty Rows (from your image) - you can remove these if not strictly needed for layout */}
- <TableRow><TableCell></TableCell><TableCell></TableCell><TableCell></TableCell></TableRow>
- <TableRow><TableCell></TableCell><TableCell></TableCell><TableCell></TableCell></TableRow>
-
- {/* Total Expenditure */}
- <TableRow sx={{ '& td': { fontWeight: 'bold', backgroundColor: '#e0e0e0' } }}>
- <TableCell>Total Expenditure 開支總額</TableCell>
- <TableCell align="right">
- <TextField fullWidth variant="filled" size="small" readOnly
- value={formatNumberForDisplay(totalExpenditureCurrent.toFixed(0))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField fullWidth variant="filled" size="small" readOnly
- value={formatNumberForDisplay(totalExpenditureLast.toFixed(0))}
- />
- </TableCell>
- </TableRow>
- </TableBody>
- </Table>
- </TableContainer>
- </Grid>
- {/* --- END: EXPENDITURE STATEMENT --- */}
-
-
- {/* ======================================================================= */}
- {/* --- START: LIQUID & NON-LIQUID ASSET 流動資產 & 非流動資產 (Image 4) --- */}
- {/* ======================================================================= */}
- <Grid item xs={12}>
- <Typography variant="h5" sx={{ mt: 5, mb: 1, px: 2, backgroundColor: '#d0d0d0', py: 1, borderRadius: 1 }}>
- Liquid Asset 流動資產
- </Typography>
- <TableContainer component={Paper} elevation={1}>
- <Table size="small" aria-label="liquid asset table">
- <TableHead sx={{ backgroundColor: '#f0f0f0' }}>
- <TableRow>
- <TableCell sx={{ fontWeight: 'bold', width: '40%' }}></TableCell>
- <TableCell align="center" sx={{ fontWeight: 'bold', width: '30%' }}>Current Year 本年度</TableCell>
- <TableCell align="center" sx={{ fontWeight: 'bold', width: '30%' }}>Last Year 上年度</TableCell>
- </TableRow>
- </TableHead>
- <TableBody>
- {/* Cash and Fixed Deposits */}
- <TableRow>
- <TableCell>Cash and Fixed Deposits 現金與定期存款</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(assets.cashDepositsCurrent)} onChange={(e) => handleAssetsChange('cashDepositsCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(assets.cashDepositsLast)} onChange={(e) => handleAssetsChange('cashDepositsLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Investments */}
- <TableRow>
- <TableCell>Investments 投資</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(assets.investmentsCurrent)} onChange={(e) => handleAssetsChange('investmentsCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(assets.investmentsLast)} onChange={(e) => handleAssetsChange('investmentsLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Other Liquid */}
- <TableRow>
- <TableCell>Other 其他</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(assets.otherLiquidCurrent)} onChange={(e) => handleAssetsChange('otherLiquidCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(assets.otherLiquidLast)} onChange={(e) => handleAssetsChange('otherLiquidLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Total Liquid Asset */}
- <TableRow sx={{ '& td': { fontWeight: 'bold', backgroundColor: '#e0e0e0' } }}>
- <TableCell>Total Liquid Asset 流動資產總額</TableCell>
- <TableCell align="right">
- <TextField fullWidth variant="filled" size="small" readOnly
- value={formatNumberForDisplay(totalLiquidAssetCurrent.toFixed(0))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField fullWidth variant="filled" size="small" readOnly
- value={formatNumberForDisplay(totalLiquidAssetLast.toFixed(0))}
- />
- </TableCell>
- </TableRow>
- </TableBody>
- </Table>
- </TableContainer>
-
- <Typography variant="h5" sx={{ mt: 3, mb: 1, px: 2, backgroundColor: '#d0d0d0', py: 1, borderRadius: 1 }}>
- Non-Liquid Asset 非流動資產
- </Typography>
- <TableContainer component={Paper} elevation={1}>
- <Table size="small" aria-label="non-liquid asset table">
- <TableHead sx={{ backgroundColor: '#f0f0f0' }}>
- <TableRow>
- <TableCell sx={{ fontWeight: 'bold', width: '40%' }}></TableCell>
- <TableCell align="center" sx={{ fontWeight: 'bold', width: '30%' }}>Current Year 本年度</TableCell>
- <TableCell align="center" sx={{ fontWeight: 'bold', width: '30%' }}>Last Year 上年度</TableCell>
- </TableRow>
- </TableHead>
- <TableBody>
- {/* Net Business Interest */}
- <TableRow>
- <TableCell>Net Business Interest 淨商業利益</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(assets.netBusinessInterestCurrent)} onChange={(e) => handleAssetsChange('netBusinessInterestCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(assets.netBusinessInterestLast)} onChange={(e) => handleAssetsChange('netBusinessInterestLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Personal Properties */}
- <TableRow>
- <TableCell>Personal Properties 個人財產</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(assets.personalPropertiesCurrent)} onChange={(e) => handleAssetsChange('personalPropertiesCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(assets.personalPropertiesLast)} onChange={(e) => handleAssetsChange('personalPropertiesLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Real Estate - NEW ROW */}
- <TableRow>
- <TableCell>Real Estate 房地產</TableCell>
- <TableCell align="right">
- <TextField
- onFocus={handleFocus}
- disabled={!isEditing}
- fullWidth
- variant="outlined"
- size="small"
- inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(assets.realEstateCurrent)}
- onChange={(e) => handleAssetsChange('realEstateCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField
- onFocus={handleFocus}
- disabled={!isEditing}
- fullWidth
- variant="outlined"
- size="small"
- inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(assets.realEstateLast)}
- onChange={(e) => handleAssetsChange('realEstateLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Other Non-Liquid */}
- <TableRow>
- <TableCell>Other 其他</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(assets.otherNonLiquidCurrent)} onChange={(e) => handleAssetsChange('otherNonLiquidCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(assets.otherNonLiquidLast)} onChange={(e) => handleAssetsChange('otherNonLiquidLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Total Non-Liquid Asset */}
- <TableRow sx={{ '& td': { fontWeight: 'bold', backgroundColor: '#e0e0e0' } }}>
- <TableCell>Total Non-Liquid Asset 非流動資產總額</TableCell>
- <TableCell align="right">
- <TextField fullWidth variant="filled" size="small" readOnly
- value={formatNumberForDisplay(totalNonLiquidAssetCurrent.toFixed(0))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField fullWidth variant="filled" size="small" readOnly
- value={formatNumberForDisplay(totalNonLiquidAssetLast.toFixed(0))}
- />
- </TableCell>
- </TableRow>
- {/* Total Assets */}
- <TableRow sx={{ '& td': { fontWeight: 'bold', backgroundColor: '#d0d0d0' } }}>
- <TableCell>Total Assets 資產總額</TableCell>
- <TableCell align="right">
- <TextField fullWidth variant="filled" size="small" readOnly
- value={formatNumberForDisplay(totalAssetsCurrent.toFixed(0))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField fullWidth variant="filled" size="small" readOnly
- value={formatNumberForDisplay(totalAssetsLast.toFixed(0))}
- />
- </TableCell>
- </TableRow>
- </TableBody>
- </Table>
- </TableContainer>
- </Grid>
- {/* --- END: LIQUID & NON-LIQUID ASSET --- */}
-
-
- {/* ======================================================================= */}
- {/* --- START: LIABILITIES 負債 (Image 5) --- */}
- {/* ======================================================================= */}
- <Grid item xs={12}>
- <Typography variant="h5" sx={{ mt: 5, mb: 1, px: 2, backgroundColor: '#d0d0d0', py: 1, borderRadius: 1 }}>
- Liabilities 負債
- </Typography>
- <TableContainer component={Paper} elevation={1}>
- <Table size="small" aria-label="liabilities table">
- <TableHead sx={{ backgroundColor: '#f0f0f0' }}>
- <TableRow>
- <TableCell sx={{ fontWeight: 'bold', width: '40%' }}></TableCell>
- <TableCell align="center" sx={{ fontWeight: 'bold', width: '30%' }}>Current Year 本年度</TableCell>
- <TableCell align="center" sx={{ fontWeight: 'bold', width: '30%' }}>Last Year 上年度</TableCell>
- </TableRow>
- </TableHead>
- <TableBody>
- {/* Personal Loans */}
- <TableRow>
- <TableCell>Personal Loans 個人債務</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(liabilities.personalLoansCurrent)} onChange={(e) => handleLiabilitiesChange('personalLoansCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(liabilities.personalLoansLast)} onChange={(e) => handleLiabilitiesChange('personalLoansLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Mortgages */}
- <TableRow>
- <TableCell>Mortgages 按揭</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(liabilities.mortgagesCurrent)} onChange={(e) => handleLiabilitiesChange('mortgagesCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(liabilities.mortgagesLast)} onChange={(e) => handleLiabilitiesChange('mortgagesLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Margin Account */}
- <TableRow>
- <TableCell>Margin Account 保證金賬戶</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(liabilities.marginAccountCurrent)} onChange={(e) => handleLiabilitiesChange('marginAccountCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(liabilities.marginAccountLast)} onChange={(e) => handleLiabilitiesChange('marginAccountLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Loan Guarantees */}
- <TableRow>
- <TableCell>Loan Guarantees 債務擔保</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(liabilities.loanGuaranteesCurrent)} onChange={(e) => handleLiabilitiesChange('loanGuaranteesCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(liabilities.loanGuaranteesLast)} onChange={(e) => handleLiabilitiesChange('loanGuaranteesLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Banking Facility */}
- <TableRow>
- <TableCell>Banking Facility 銀行貸款</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(liabilities.bankingFacilityCurrent)} onChange={(e) => handleLiabilitiesChange('bankingFacilityCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(liabilities.bankingFacilityLast)} onChange={(e) => handleLiabilitiesChange('bankingFacilityLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Sub-header for Existing Premium Financing/Policy loan */}
- <TableRow>
- <TableCell colSpan={3} sx={{ fontWeight: 'bold', backgroundColor: '#f0f0f0', textAlign: 'center' }}>
- Existing Premium Financing/ Policy loan 現有保費融資/保單貸款
- </TableCell>
- </TableRow>
- {/* Principal */}
- <TableRow>
- <TableCell>Principal 本金還款額</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(liabilities.prefFinancePrincipalCurrent)} onChange={(e) => handleLiabilitiesChange('prefFinancePrincipalCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(liabilities.prefFinancePrincipalLast)} onChange={(e) => handleLiabilitiesChange('prefFinancePrincipalLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Other Liabilities */}
- <TableRow>
- <TableCell>Other 其他</TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(liabilities.prefFinanceOtherCurrent)} onChange={(e) => handleLiabilitiesChange('prefFinanceOtherCurrent', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField onFocus={handleFocus} disabled={!isEditing} fullWidth variant="outlined" size="small" inputProps={{ min: "0", step: "0.01" }}
- value={formatNumberForDisplay(liabilities.prefFinanceOtherLast)} onChange={(e) => handleLiabilitiesChange('prefFinanceOtherLast', cleanNumberForState(e.target.value))}
- />
- </TableCell>
- </TableRow>
- {/* Total Liabilities */}
- <TableRow sx={{ '& td': { fontWeight: 'bold', backgroundColor: '#d0d0d0' } }}>
- <TableCell>Total Liabilities 負債總額</TableCell>
- <TableCell align="right">
- <TextField fullWidth variant="filled" size="small" readOnly
- value={formatNumberForDisplay(totalLiabilitiesCurrent.toFixed(0))}
- />
- </TableCell>
- <TableCell align="right">
- <TextField fullWidth variant="filled" size="small" readOnly
- value={formatNumberForDisplay(totalLiabilitiesLast.toFixed(0))}
- />
- </TableCell>
- </TableRow>
- </TableBody>
- </Table>
- </TableContainer>
- </Grid>
- {/* --- END: LIABILITIES --- */}
-
- <Grid item xs={12} sx={{
- minHeight: isEditing ? '100px' : '70px',
- width: '100%'
- }} />
- <Grid></Grid>
- <Grid item xs={12} sx={{
- minHeight: isEditing ? '100px' : '70px',
- width: '100%'
- }} />
- <Grid></Grid>
-
-
- {(isEditing) ?
- <Paper
- sx={{
- position: 'fixed',
- bottom: 0,
- left: 0,
- right: 0,
- zIndex: 1300,
- padding: 1.5,
- boxShadow: '0 -4px 12px rgba(0, 0, 0, 0.15)',
- backgroundColor: 'white',
- display: 'flex',
- justifyContent: 'flex-end',
- }}
- >
- <Grid container maxWidth justifyContent="center" alignItems="center" >
- <ThemeProvider theme={LIONER_BUTTON_THEME}>
- <Grid item>
- <Grid container>
- <Grid item sx={{ ml: { xs: 1.5, md: 1.5, lg: 1.5 }, mr: 1.5, mb: 1, mt: 2 }}>
- <Button
- variant="contained"
- color="save"
- onClick={submitData}
- >
- Save
- </Button>
- </Grid>
- <Grid item sx={{ ml: 1.5, mr: 1.5, mb: 1, mt: 2 }}>
- <Button
- variant="contained"
- color="cancel"
- onClick={isNewRecord ? returnSearchPage : updateIsEdit}
- >
- Cancel
- </Button>
- </Grid>
- </Grid>
- </Grid>
- <Grid item>
- <Grid container>
- <ThemeProvider theme={LIONER_LONG_BUTTON_THEME}>
- </ThemeProvider>
- </Grid>
- </Grid>
- </ThemeProvider>
- </Grid>
- </Paper>
- :
- <Paper
- sx={{
- position: 'fixed',
- bottom: 0,
- left: 0,
- right: 0,
- zIndex: 1100, // Ensure it floats above all other content
- padding: 1.5,
- boxShadow: '0 -4px 12px rgba(0, 0, 0, 0.15)', // A shadow to clearly separate the bar
- backgroundColor: 'white', // Set an explicit background color
- display: 'flex',
- justifyContent: 'flex-end', // Push buttons to the right
- }}
- >
- <Grid container justifyContent="flex-end" alignItems="center" sx={{ maxWidth: '1400px', width: '100%', margin: '0 auto', pr: 3, pl: 3 }}>
- <Grid item sx={{ ml: 1, mr: 1 }}>
- {/* The Save button should only show/be enabled when editing */}
- <Button
- type="submit"
- variant="contained"
- color="primary"
- disabled={!isEditing || !ability.can('MAINTAIN', 'CLIENT')} // Disable if not editing
- sx={{ display: isEditing ? 'block' : 'none' }} // Only show when editing
- >
- Save
- </Button>
- </Grid>
- <Grid item sx={{ ml: 1, mr: 1 }}>
- {/* ADDED: onClick={handleEditClick} and conditional display/disabled */}
- <Button
- variant="contained"
- color="info"
- onClick={handleEditClick} // <--- REINSTATED EDIT LOGIC
- disabled={isEditing || !ability.can('MAINTAIN', 'CLIENT')} // Disable if already editing or no permission
- sx={{ display: isEditing ? 'none' : 'block' }} // Only show when not editing
- >
- Edit
- </Button>
- </Grid>
- <Grid item>
- <Button
- variant="contained"
- // ... (rest of Back button styles)
- onClick={returnSearchPage}
- >
- Back
- </Button>
- </Grid>
- </Grid>
- </Paper>
- }
- </Grid>
- </Grid>
- </form>
- </MainCard>
- );
- };
-
- export default ClientForm;
|