ContactDetailsScreen prevent double click on contact create
This commit is contained in:
parent
a1e6083f7e
commit
30cda93bde
1 changed files with 15 additions and 0 deletions
|
|
@ -125,6 +125,8 @@ class ContactDetailsScreen extends React.Component {
|
|||
state = {
|
||||
/** @type {'add'|'edit} */
|
||||
action: 'add',
|
||||
/** Is Working Saving Contact */
|
||||
savingContact: false,
|
||||
|
||||
/** @type {0|1} 0 is VISITS 1, is NOTES */
|
||||
selectedVisitsOrNoteTab: 0,
|
||||
|
|
@ -162,6 +164,9 @@ class ContactDetailsScreen extends React.Component {
|
|||
|
||||
// * - CONTACT METHODS
|
||||
saveContact() {
|
||||
this.setState({
|
||||
savingContact: true,
|
||||
});
|
||||
/** @type {typeof import('./../Models/Contact').ContactData} */
|
||||
const contact = Object.assign({}, this.state.contact);
|
||||
|
||||
|
|
@ -186,6 +191,9 @@ class ContactDetailsScreen extends React.Component {
|
|||
lockedFields.forEach(fieldName => {
|
||||
const form = lockedForms.find(inputForm => inputForm.name === fieldName);
|
||||
if (!form) {
|
||||
this.setState({
|
||||
savingContact: false,
|
||||
});
|
||||
throw new Error(`failed to get form ${fieldName}`);
|
||||
}
|
||||
if (contact[fieldName]?.length) {
|
||||
|
|
@ -248,6 +256,9 @@ class ContactDetailsScreen extends React.Component {
|
|||
});
|
||||
|
||||
if (error.length > 0) {
|
||||
this.setState({
|
||||
savingContact: false,
|
||||
});
|
||||
Alert.alert(i18n.t('global.warning') + ' !', error, [{ text: 'OK' }], {
|
||||
cancelable: false,
|
||||
});
|
||||
|
|
@ -268,6 +279,9 @@ class ContactDetailsScreen extends React.Component {
|
|||
setContactHook(this.props.currentUser, contact);
|
||||
|
||||
if (this.state.action === 'edit') {
|
||||
this.setState({
|
||||
savingContact: false,
|
||||
});
|
||||
showMessage({
|
||||
message: i18n.t('contact_details_s.contact_saved') + '.',
|
||||
type: 'success',
|
||||
|
|
@ -636,6 +650,7 @@ class ContactDetailsScreen extends React.Component {
|
|||
title={i18n.t('global.save')}
|
||||
onPress={() => this.saveContact()}
|
||||
color={this.props.mainColor}
|
||||
disabled={this.state.savingContact}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue