api integration updates

This commit is contained in:
Cyril Joseph 2025-06-08 21:17:21 -03:00
parent 43f0b09432
commit a67f9cba31
12 changed files with 49 additions and 42 deletions

View File

@ -15,7 +15,7 @@ export class BasicDetailService {
constructor(private http: HttpClient, private userService: UserService) { } constructor(private http: HttpClient, private userService: UserService) { }
getBasicDetailsById(id: number): BasicDetail | any { getBasicDetailsById(id: number): BasicDetail | any {
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetPreparerByClientid?p_spid=${this.userService.getUserSpid()}&p_clientid=${id}`).pipe( return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetPreparerByClientid/${this.userService.getUserSpid()}/${id}`).pipe(
filter(response => response.length > 0), filter(response => response.length > 0),
map(response => this.mapToBasicDetail(response?.[0]))); map(response => this.mapToBasicDetail(response?.[0])));
} }

View File

@ -16,7 +16,7 @@ export class ClientService {
constructor(private http: HttpClient, private userService: UserService) { } constructor(private http: HttpClient, private userService: UserService) { }
getPreparers(filter: PreparerFilter): Observable<BasicDetail[]> { getPreparers(filter: PreparerFilter): Observable<BasicDetail[]> {
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetPreparers?P_SPID=${this.userService.getUserSpid()}&P_STATUS=ACTIVE&P_NAME=${filter.name}&P_LOOKUPCODE=${filter.lookupCode}&P_CITY=${filter.city}&P_STATE=${filter.state}`).pipe( return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetPreparers/${this.userService.getUserSpid()}/ACTIVE?P_NAME=${filter.name}&P_LOOKUPCODE=${filter.lookupCode}&P_CITY=${filter.city}&P_STATE=${filter.state}`).pipe(
map(response => this.mapToClients(response))); map(response => this.mapToClients(response)));
} }

View File

@ -15,7 +15,7 @@ export class ContactService {
constructor(private http: HttpClient, private userService: UserService) { } constructor(private http: HttpClient, private userService: UserService) { }
getContactsById(id: number): Observable<Contact[]> { getContactsById(id: number): Observable<Contact[]> {
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetPreparerContactsByClientid?p_spid=${this.userService.getUserSpid()}&p_clientid=${id}`).pipe( return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetPreparerContactsByClientid/${this.userService.getUserSpid()}/${id}`).pipe(
map(response => this.mapToContacts(response))); map(response => this.mapToContacts(response)));
} }
@ -81,7 +81,7 @@ export class ContactService {
return this.http.put(`${this.apiUrl}/${this.apiDb}/UpdateClientContacts`, contact); return this.http.put(`${this.apiUrl}/${this.apiDb}/UpdateClientContacts`, contact);
} }
deleteContact(clientContactId: string): Observable<any> { // deleteContact(clientContactId: string): Observable<any> {
return this.http.post(`${this.apiUrl}/${this.apiDb}/InactivateSPContact?p_clientcontactid=${clientContactId}`, null); // return this.http.post(`${this.apiUrl}/${this.apiDb}/InactivateSPContact?p_clientcontactid=${clientContactId}`, null);
} // }
} }

View File

@ -15,7 +15,7 @@ export class LocationService {
constructor(private http: HttpClient, private userService: UserService) { } constructor(private http: HttpClient, private userService: UserService) { }
getLocationsById(id: number): Observable<Location[]> { getLocationsById(id: number): Observable<Location[]> {
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetPreparerLocByClientid?p_spid=${this.userService.getUserSpid()}&p_clientid=${id}`).pipe( return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetPreparerLocByClientid/${this.userService.getUserSpid()}/${id}`).pipe(
map(response => this.mapToLocations(response))); map(response => this.mapToLocations(response)));
} }

View File

@ -15,7 +15,7 @@ export class BasicDetailService {
constructor(private http: HttpClient, private userService: UserService) { } constructor(private http: HttpClient, private userService: UserService) { }
getBasicDetailsById(id: number): BasicDetail | any { getBasicDetailsById(id: number): BasicDetail | any {
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetSelectedServiceprovider?p_spid=${id}`).pipe( return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetSelectedServiceprovider/${id}`).pipe(
filter(response => response.length > 0), filter(response => response.length > 0),
map(response => this.mapToBasicDetail(response?.[0]))); map(response => this.mapToBasicDetail(response?.[0])));
} }

View File

@ -15,7 +15,7 @@ export class CarnetSequenceService {
constructor(private http: HttpClient, private userService: UserService) { } constructor(private http: HttpClient, private userService: UserService) { }
getCarnetSequenceById(id: number): Observable<CarnetSequence[]> { getCarnetSequenceById(id: number): Observable<CarnetSequence[]> {
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetCarnetSequence?p_spid=${id}`).pipe( return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetCarnetSequence/${id}`).pipe(
map(response => this.mapToCarnetSequence(response))); map(response => this.mapToCarnetSequence(response)));
} }

View File

@ -15,7 +15,7 @@ export class ContactService {
constructor(private http: HttpClient, private userService: UserService) { } constructor(private http: HttpClient, private userService: UserService) { }
getContactsById(id: number): Observable<Contact[]> { getContactsById(id: number): Observable<Contact[]> {
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetSPAllContacts?p_SPid=${id}`).pipe( return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetSPAllContacts/${id}`).pipe(
map(response => this.mapToContacts(response))); map(response => this.mapToContacts(response)));
} }
@ -79,7 +79,7 @@ export class ContactService {
} }
deleteContact(spContactId: string): Observable<any> { deleteContact(spContactId: string): Observable<any> {
return this.http.post(`${this.apiUrl}/${this.apiDb}/InactivateSPContact?p_spcontactid=${spContactId}`, null); return this.http.post(`${this.apiUrl}/${this.apiDb}/InactivateSPContact/${spContactId}`, null);
} }
} }

View File

@ -190,6 +190,7 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
// states // states
basicDetailData.state = this.basicDetailsForm.get('state')?.value; basicDetailData.state = this.basicDetailsForm.get('state')?.value;
basicDetailData.revenueLocation = this.basicDetailsForm.get('revenueLocation')?.value;
// non editable fields values // non editable fields values
if (this.isEditMode) { if (this.isEditMode) {
@ -207,6 +208,10 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
if (!this.isEditMode) { if (!this.isEditMode) {
this.clientidCreated.emit(basicData.clientId); this.clientidCreated.emit(basicData.clientId);
} }
if( this.isEditMode) {
this.clientName.emit(basicDetailData.name);
}
}, },
error: (error: any) => { error: (error: any) => {
let errorMessage = this.errorHandler.handleApiError(error, `Failed to ${this.isEditMode ? 'update' : 'add'} basic details`); let errorMessage = this.errorHandler.handleApiError(error, `Failed to ${this.isEditMode ? 'update' : 'add'} basic details`);

View File

@ -166,31 +166,31 @@ export class ContactsComponent {
} }
deleteContact(contactId: string): void { deleteContact(contactId: string): void {
const dialogRef = this.dialog.open(ConfirmDialogComponent, { // const dialogRef = this.dialog.open(ConfirmDialogComponent, {
width: '350px', // width: '350px',
data: { // data: {
title: 'Confirm Delete', // title: 'Confirm Delete',
message: 'Are you sure you want to delete this contact?', // message: 'Are you sure you want to delete this contact?',
confirmText: 'Delete', // confirmText: 'Delete',
cancelText: 'Cancel' // cancelText: 'Cancel'
} // }
}); // });
dialogRef.afterClosed().subscribe(result => { // dialogRef.afterClosed().subscribe(result => {
if (result) { // if (result) {
this.contactService.deleteContact(contactId).subscribe({ // this.contactService.deleteContact(contactId).subscribe({
next: () => { // next: () => {
this.notificationService.showSuccess('Contact deleted successfully'); // this.notificationService.showSuccess('Contact deleted successfully');
this.loadContacts(); // this.loadContacts();
}, // },
error: (error) => { // error: (error) => {
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to delete contact'); // let errorMessage = this.errorHandler.handleApiError(error, 'Failed to delete contact');
this.notificationService.showError(errorMessage); // this.notificationService.showError(errorMessage);
console.error('Error deleting contact:', error); // console.error('Error deleting contact:', error);
} // }
}); // });
} // }
}); // });
} }
createLogin(): void { createLogin(): void {

View File

@ -55,7 +55,7 @@
</form> </form>
</div> </div>
<div class="results-section" *ngIf="showResults"> <div class="results-section">
<div class="loading-shade" *ngIf="isLoading"> <div class="loading-shade" *ngIf="isLoading">
<mat-spinner diameter="50"></mat-spinner> <mat-spinner diameter="50"></mat-spinner>

View File

@ -39,7 +39,6 @@ export class ManagePreparerComponent implements OnInit, OnDestroy, AfterViewInit
} }
searchForm: FormGroup; searchForm: FormGroup;
showResults = false;
isLoading = false; isLoading = false;
userPreferences: UserPreferences; userPreferences: UserPreferences;
countries: Country[] = []; countries: Country[] = [];
@ -66,6 +65,7 @@ export class ManagePreparerComponent implements OnInit, OnDestroy, AfterViewInit
ngOnInit(): void { ngOnInit(): void {
this.loadCountries(); this.loadCountries();
this.loadRegions(); this.loadRegions();
this.searchPreparers();
} }
ngOnDestroy(): void { ngOnDestroy(): void {
@ -97,9 +97,12 @@ export class ManagePreparerComponent implements OnInit, OnDestroy, AfterViewInit
if (this.searchForm.invalid || !this.isSearchCriteriaProvided()) { if (this.searchForm.invalid || !this.isSearchCriteriaProvided()) {
return; return;
} }
this.searchPreparers();
}
searchPreparers(): void {
this.isLoading = true; this.isLoading = true;
this.showResults = true;
const filterData: PreparerFilter = this.searchForm.value; const filterData: PreparerFilter = this.searchForm.value;
this.clientService.getPreparers(filterData).subscribe({ this.clientService.getPreparers(filterData).subscribe({
@ -117,9 +120,9 @@ export class ManagePreparerComponent implements OnInit, OnDestroy, AfterViewInit
} }
onClear(): void { onClear(): void {
this.searchForm.reset(); this.searchForm = this.createSearchForm();
this.showResults = false;
this.dataSource.data = []; this.dataSource.data = [];
this.searchPreparers();
} }
navigateTo(route: string): void { navigateTo(route: string): void {
@ -130,7 +133,6 @@ export class ManagePreparerComponent implements OnInit, OnDestroy, AfterViewInit
this.navigationService.navigate(['preparer', clientid]); this.navigationService.navigate(['preparer', clientid]);
} }
loadRegions(): void { loadRegions(): void {
this.commonService.getRegions() this.commonService.getRegions()
.pipe(takeUntil(this.destroy$)) .pipe(takeUntil(this.destroy$))

View File

@ -1,5 +1,5 @@
export const environment = { export const environment = {
production: false, production: false,
apiUrl: 'http://localhost:3001/', apiUrl: 'https://dev.alphaomegainfosys.com/test-api',
apiDb: 'oracle' apiDb: 'oracle'
}; };