Skip to content

Commit b10112d

Browse files
fix(#2374): Add a validation in both BE and FE when there is no association between the legal type and client type (#2364)
* fix(#1120): Add a validation in both BE and FE, to prevent the user to create a client when there is no association between the legal type and client type * Mapped BC registry legal type mapping with Oracle mapping
1 parent a6f595f commit b10112d

3 files changed

Lines changed: 31 additions & 20 deletions

File tree

frontend/src/pages/bceidform/BusinessInformationWizardStep.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ watch([autoCompleteResult], () => {
157157
formData.value.businessInformation.clientType = retrieveClientType(
158158
autoCompleteResult.value.legalType
159159
);
160+
161+
if (!formData.value.businessInformation.clientType) {
162+
toggleErrorMessages(null, null, null, null, true);
163+
return;
164+
};
165+
160166
showAutoCompleteInfo.value = false;
161167
162168
if (formData.value.businessInformation.clientType === 'RSP') {

frontend/src/pages/staffform/BcRegisteredClientInformationWizardStep.vue

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@ const errorBus = useEventBus<ValidationMessageType[]>(
6363
const formData = ref<FormDataDto>(props.data);
6464
const showUnsupportedLegalTypeError = ref<boolean>(false);
6565
66+
const toggleErrorMessages = (
67+
unsupportedLegalType: boolean | null = null,
68+
) => {
69+
showUnsupportedLegalTypeError.value = unsupportedLegalType ?? false;
70+
71+
if (unsupportedLegalType) {
72+
progressIndicatorBus.emit({ kind: "disabled", value: true });
73+
exitBus.emit({
74+
unsupportedLegalType
75+
});
76+
} else {
77+
progressIndicatorBus.emit({ kind: "disabled", value: false });
78+
exitBus.emit({
79+
unsupportedLegalType: false
80+
});
81+
}
82+
};
83+
6684
watch(
6785
() => formData.value,
6886
() => emit("update:data", formData.value)
@@ -146,30 +164,17 @@ watch([autoCompleteResult], () => {
146164
);
147165
formData.value.businessInformation.businessType = getEnumKeyByEnumValue(BusinessTypeEnum, BusinessTypeEnum.R);
148166
167+
if (!formData.value.businessInformation.clientType) {
168+
toggleErrorMessages(true);
169+
return;
170+
}
171+
149172
emit("update:data", formData.value);
150173
151174
if (formData.value.businessInformation.clientType === "RSP") {
152175
validation.birthdate = false;
153176
}
154177
155-
const toggleErrorMessages = (
156-
unsupportedLegalType: boolean | null = null,
157-
) => {
158-
showUnsupportedLegalTypeError.value = unsupportedLegalType ?? false;
159-
160-
if (unsupportedLegalType) {
161-
progressIndicatorBus.emit({ kind: "disabled", value: true });
162-
exitBus.emit({
163-
unsupportedLegalType
164-
});
165-
} else {
166-
progressIndicatorBus.emit({ kind: "disabled", value: false });
167-
exitBus.emit({
168-
unsupportedLegalType: false
169-
});
170-
}
171-
};
172-
173178
//Also, we will load the backend data to fill all the other information as well
174179
const {
175180
error,
@@ -446,7 +451,7 @@ onMounted(() => {
446451
data-text="Client information"
447452
v-shadow="2"
448453
id="bcRegistrySearchNotification"
449-
v-if="!formData.businessInformation.clientType"
454+
v-if="!formData.businessInformation.clientType && !showUnsupportedLegalTypeError"
450455
low-contrast="true"
451456
open="true"
452457
kind="info"

legacy/src/test/java/ca/bc/gov/app/controller/ClientLocationControllerIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void shouldSaveLocation(String clientNumber) {
6565
}
6666

6767
private static Stream<String> saveLocation() {
68-
return Stream.of("00000001", "00000002", "00000008");
68+
return Stream.of("00000001", "00000002", "00000005");
6969
}
7070

7171
@ParameterizedTest

0 commit comments

Comments
 (0)