`Hi, I'm new to this angular stuff and do not quite understand how to do this part of the form.
We have had people click the submit button multiple times very quickly and add the same information just as many times before it can even send the information to the API.
I've tried searching on here and even googled it but I feel like our forms are very specific and could not find anything that seemed even close.
Here is what I have and any suggestions would be really helpful:
onSubmit(model: ExampleDto) {
if (!this.form.disabled) {
if (this.form.valid) {
if (this.form.dirty) {
if (this.mode === this.modes.Add) {
delete model["CompanyName"];
delete model["EffectiveDate"];
delete model["ExpirationDate"];
delete model["CancelDate"];
model.UserCreated = localStorage.getItem("name");
this.userService.AddExample(model).subscribe(
(data) => {
if (data) {
if (data.Status == "Success") {
if (data.Example.CExampleid.trim() == "") {
this.onRowSelect({ data: data.Claim });
} else {
this.searchCriteria.setValue({
policyNumber: data.Example.PolicyNumber,
claimNumber: data.Example.ClaimNumber,
dateOfLoss: data.Example.DateOfLoss,
});
this.onSearch();
}
} else {
this.confirmationService.confirm({
key: "error-message",
message:
"The example was NOT created. You may try again after clicking OK. If the problem persists, contact the Helpdesk.",
accept: () => {},
});
}
}
},
(err) => {
this.confirmationService.confirm({
key: "error-message",
message:
"The example was NOT created. You may try again after clicking OK. If the problem persists, contact the Helpdesk.",
accept: () => {},
});
},
() => {}
);
}
} else {
this.confirmationService.confirm({
key: "notice",
message: "You haven't made any changes to the example.",
accept: () => {},
});
}
} else {
this.confirmationService.confirm({
key: "error-message",
message:
"There are errors on the form. Click OK to make corrections before resubmitting.",
accept: () => {},
});
}
}
}