diff --git a/src/custom-surf/uniforms/ContactPersonNameField.tsx b/src/custom-surf/uniforms/ContactPersonNameField.tsx index 20e2186e..5c6c24a2 100644 --- a/src/custom-surf/uniforms/ContactPersonNameField.tsx +++ b/src/custom-surf/uniforms/ContactPersonNameField.tsx @@ -25,15 +25,20 @@ import ApplicationContext from "utils/ApplicationContext"; import { ContactPerson } from "utils/types"; import { stop } from "utils/Utils"; -export type ContactPersonNameFieldProps = FieldProps; +export type ContactPersonNameFieldProps = FieldProps< + string, + { customerId?: string; customerKey?: string; organisationId?: string; organisationKey?: string } +>; declare module "uniforms" { interface FilterDOMProps { - organisationId: never; - organisationKey: never; + customerId: never; + customerKey: never; + organistionId: never; + organistionKey: never; } } -filterDOMProps.register("organisationId", "organisationKey"); +filterDOMProps.register("customerId", "customerKey", "organistionId", "organistionKey"); function ContactPersonName({ disabled, @@ -49,10 +54,19 @@ function ContactPersonName({ error, showInlineError, errorMessage, + customerId, + customerKey, organisationId, organisationKey, ...props }: ContactPersonNameFieldProps) { + if (organisationId) { + customerId = organisationId; + } + if (organisationKey) { + customerKey = organisationKey; + } + const intl = useIntl(); const { customApiClient } = useContext(ApplicationContext); const { model, onChange: formOnChange, schema } = useForm(); @@ -67,19 +81,17 @@ function ContactPersonName({ const useFieldName = contactsPersonFieldNameArray.length ? contactsFieldName : name; const contactsField = useField(useFieldName, {}, { absoluteName: true })[0]; - const organisationFieldName = organisationKey || contactsField.field.organisationKey || "organisation"; + const customerFieldName = customerKey || contactsField.field.customerKey || "customer_id"; // Get initial value for org field if it exists (we cant really test) - let organisationInitialValue; + let customerInitialValue; try { - organisationInitialValue = schema.getInitialValue(organisationFieldName, {}); + customerInitialValue = schema.getInitialValue(customerFieldName, {}); } catch { - organisationInitialValue = ""; + customerInitialValue = ""; } - const organisationIdValue = - organisationId || - contactsField.field.organisationId || - get(model, organisationFieldName, organisationInitialValue); + const customerIdValue = + customerId || contactsField.field.customerId || get(model, customerFieldName, customerInitialValue); let [displayAutocomplete, setDisplayAutocomplete] = useState(false); let [contactPersons, setContactPersons] = useState([]); @@ -92,12 +104,12 @@ function ContactPersonName({ : []; useEffect(() => { - if (organisationIdValue) { - customApiClient.contacts(organisationIdValue).then((contactPersons) => { + if (customerIdValue) { + customApiClient.contacts(customerIdValue).then((contactPersons) => { setContactPersons(contactPersons); }); } - }, [organisationIdValue, customApiClient]); + }, [customerIdValue, customApiClient]); useEffect(() => { // Set focus to the last name component to be created diff --git a/src/lib/uniforms-surfnet/src/SubscriptionField.tsx b/src/lib/uniforms-surfnet/src/SubscriptionField.tsx index 0d73b68e..d425fa9b 100644 --- a/src/lib/uniforms-surfnet/src/SubscriptionField.tsx +++ b/src/lib/uniforms-surfnet/src/SubscriptionField.tsx @@ -47,6 +47,9 @@ export function makeLabel(subscription: iSubscription, products: Product[], orga } else if (["SP", "SPNL", "AGGSP", "AGGSPNL", "MSC", "MSCNL", "IRBSP"].includes(product.tag)) { let portSubscription = subscription as ServicePortSubscription; const portMode = getPortMode(portSubscription, products); + if (portSubscription.title) { + return `${subscription_substring} - ${description.trim()} - ${portSubscription.title.trim()}`; + } return `${subscription_substring} ${portMode.toUpperCase()} ${description.trim()} ${customerName}`; } else { return description.trim(); diff --git a/src/utils/types.ts b/src/utils/types.ts index 72c9ff23..0f790a01 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -168,6 +168,7 @@ export interface IpPrefixSubscription extends Subscription { export interface ServicePortSubscription extends Subscription { port_mode?: string; + title?: string; } export interface ServicePort {