Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
const contact = this.partnerInformationForm.contacts[index];
if (!contact) return false;
const hasExternal = contact.type === 'External';
const hasInternal = contact.type === 'Internal';
const hasInternalAndExternal = hasExternal && hasInternal;
const isValid = this.partnerInformationForm.internalApple === false && !hasInternalAndExternal;
return isValid;
};
areAllInternalAndExternalValidation = () => {
return this.partnerInformationForm.contacts.every((contact, index) => {
const isValid = this.internalAndExternalValidation(index);
return isValid;
});
};
isValidContactExternalValidation = index => {
const contact = this.partnerInformationForm.contacts[index];
if (!contact) return false;
const isValid = this.partnerInformationForm.internalApple === true && contact.type === 'External';
return isValid;
};
areAllContactExternalValidation = () => {
return this.partnerInformationForm.contacts.every((contact, index) => {
const isValid = this.isValidContactExternalValidation(index);
return isValid;
});
};
import React, {useEffect} from 'react';
import {observer} from 'mobx-react';
import {StoreContext} from '../utils/StoreContext';
import TypeAhead from '@aosprodsys/brucke-ui-core/dist/es/components/TypeAhead';
import Input from '@aosprodsys/brucke-ui-core/dist/es/components/Input';
import styles from '../sass/components/contact-information.scss';
export const ContactInformation = () => {
const {createPartner} = React.useContext(StoreContext);
const {
partnerInformationForm,
partnerTypeOptions,
updateValueForContacts,
addContact,
removeContact,
emailValidation,
internalAndExternalValidation,
isValidContactExternalValidation
} = createPartner;
const {contacts} = partnerInformationForm;
useEffect(() => {
if (contacts.length === 0) {
addContact();
}
}, []);
const isContactComplete = contact => {
return contact.type && contact.name && contact.email;
};
const canAddMoreContacts = contacts.length === 0 || isContactComplete(contacts[contacts.length - 1]);
return (
<div className={styles.contactInformation}>
{contacts.length > 0 &&
contacts.map((row, index) => {
const selectedPartnerType = partnerTypeOptions.find(option => option.value === row.type) || null;
return (
<div className="contact-details" key={index}>
<TypeAhead
id="contact Type"
placeholder="Partner Type"
showChevronIcon={true}
errorMessage={
(internalAndExternalValidation(index) &&
'Both External and Internal Contact Type must be avilable for External Partners') ||
(isValidContactExternalValidation(index) &&
'User should be able to add external contact info only for External Partners selects as Yes')
}
className="form-wrapper"
clearable={false}
selectOptions={{
isMulti: false,
closeMenuOnSelect: true,
backspaceRemovesValue: true,
options: partnerTypeOptions,
showSelectedValue: true,
hideSelectedOptions: true
}}
value={selectedPartnerType}
onChange={selected => {
updateValueForContacts(index, 'type', selected.value);
}}
/>
<Input
placeholder="Partner Name"
id="Contact Name"
className="form-wrapper"
disabled={!row.type}
inputProps={{
value: row.name,
disabled: !row.type,
debounceTimeout: 700,
onChange: e => {
updateValueForContacts(index, 'name', e.target.value);
}
}}
/>
<Input
className="form-wrapper"
placeholder="Partner Email"
id="Contact Email"
errorMessage={row.email && !emailValidation(index) && 'Please enter valid email'}
disabled={!row.type}
inputProps={{
value: row.email,
disabled: !row.type,
debounceTimeout: 700,
onChange: e => {
updateValueForContacts(index, 'email', e.target.value);
}
}}
/>
{contacts.length > 1 && (
<button className="link" onClick={() => removeContact(index)}>
Remove Contact
</button>
)}
</div>
);
})}
<button
className={`link ${!canAddMoreContacts ? 'add-contact' : ''}`}
disabled={!canAddMoreContacts}
onClick={() => {
addContact();
}}
>
Add Another Contact
</button>
</div>
);
};
export default observer(ContactInformation);
<button
className="button button-block button-elevated"
onClick={() => {
createPartner.savePartnerInformation();
}}
disabled={
disableSave ||
validatePartnerKey ||
!isEmailValid ||
!isAreAllInternalAndExternalValidation ||
isAreAllContactExternalValidation
}
>
Save
</button>
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team