Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ahmad/trade type url param fix for reports #17268

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const getEmploymentAndTaxValidationSchema = ({
is_mf = false,
is_real = false,
is_tin_auto_set = false,
is_duplicate_account = false,
}: TEmployeeDetailsTinValidationConfig) => {
return Yup.object({
employment_status: Yup.string().required(localize('Employment status is required.')),
Expand All @@ -66,7 +67,7 @@ export const getEmploymentAndTaxValidationSchema = ({
tin_skipped: Yup.number().oneOf([0, 1]).default(0),
tax_identification_confirm: Yup.bool().when(['tax_identification_number', 'tax_residence', 'tin_skipped'], {
is: (tax_identification_number: string, tax_residence: string, tin_skipped: boolean) =>
tax_identification_number && tax_residence && !tin_skipped,
tax_identification_number && tax_residence && !tin_skipped && !is_duplicate_account,
then: Yup.bool().required().oneOf([true]),
otherwise: Yup.bool().notRequired(),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,15 @@ const EmploymentTaxDetailsContainer = observer(

const isFieldDisabled = (field_name: string) => isFieldImmutable(field_name, editable_fields);

// [TODO] - This should come from BE
const should_disable_employment_status =
isFieldDisabled('employment_status') || Boolean(is_virtual && client.account_settings.employment_status);

return (
<div id={'employment-tax-section'}>
<EmploymentStatusField
required
is_disabled={isFieldDisabled('employment_status')}
is_disabled={should_disable_employment_status}
fieldFocused={should_focus_fields && !account_settings.employment_status}
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ const EmploymentTaxInfo = observer(
tin_config: tin_validation_config,
is_mf: is_eu,
is_real: !client.is_virtual,
is_duplicate_account:
client.account_settings.immutable_fields?.includes('tax_identification_number') ||
client.account_settings.immutable_fields?.includes('tax_residence'),
});

const handleCancel = (values: FormikValues) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ const PersonalDetailsForm = observer(() => {
is_virtual,
is_svg,
tin_validation_config,
is_tin_auto_set
is_tin_auto_set,
account_settings?.immutable_fields
);
const displayErrorMessage = (status: { code: string; msg: string }) => {
if (status?.code === 'PhoneNumberTaken') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ export const getPersonalDetailsValidationSchema = (
is_virtual?: boolean,
is_svg?: boolean,
tin_validation_config?: TinValidations,
is_tin_auto_set?: boolean
is_tin_auto_set?: boolean,
immutable_fields?: string[]
) => {
if (is_virtual) return Yup.object();

Expand All @@ -151,6 +152,8 @@ export const getPersonalDetailsValidationSchema = (
is_mf: !is_svg,
is_real: !is_virtual,
is_tin_auto_set,
is_duplicate_account:
immutable_fields?.includes('tax_identification_number') || immutable_fields?.includes('tax_residence'),
});

return personal_details_schema.concat(address_detail_schema).concat(employment_tin_schema);
Expand Down
1 change: 1 addition & 0 deletions packages/account/src/Types/common.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ export type TEmployeeDetailsTinValidationConfig = {
is_mf?: boolean;
is_real?: boolean;
is_tin_auto_set?: boolean;
is_duplicate_account?: boolean;
};

type ReqRule = ['req', React.ReactNode];
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/sass/account-wizard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -826,4 +826,8 @@
width: 100%;
}
}

.employment-status-field {
margin-top: 0.5rem;
}
}
18 changes: 13 additions & 5 deletions packages/trader/src/Stores/Modules/Trading/trade-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1848,13 +1848,21 @@ export default class TradeStore extends BaseStore {
updateChartType(chartTypeParam);
}

this.contract_type = contractType ?? '';

setTradeURLParams({
const urlParams: {
chartType: string;
granularity: number;
contractType?: string;
} = {
chartType: chartTypeParam ?? chart_type,
granularity: granularityParam ?? Number(granularity),
contractType: contractType ?? '',
});
};

if (contractType) {
this.contract_type = contractType ?? '';
urlParams.contractType = contractType;
}

setTradeURLParams(urlParams);
}

setChartStatus(status: boolean, isFromChart?: boolean) {
Expand Down