add endpoint configuration for city, currency, language, and timezone
This commit is contained in:
@@ -121,7 +121,6 @@ export class TokenStorageService {
|
||||
}
|
||||
|
||||
private isExpired(expiresOn: string | null): boolean {
|
||||
debugger;
|
||||
if (!expiresOn) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { CITY_ENDPOINTS } from '../../end-points/city/city.endpoints';
|
||||
import {
|
||||
CityDto,
|
||||
CreateCityRequest,
|
||||
UpdateCityRequest
|
||||
} from '../../models/city/city.model';
|
||||
import {
|
||||
DataTableQuery,
|
||||
DataTableResult
|
||||
} from '../../../shared/components/data-table/data-table.types';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CityService {
|
||||
private readonly http = inject(HttpClient);
|
||||
|
||||
getCityDataTable(
|
||||
query: DataTableQuery,
|
||||
stateId: string
|
||||
): Observable<DataTableResult<CityDto>> {
|
||||
return this.http.post<DataTableResult<CityDto>>(
|
||||
CITY_ENDPOINTS.dataTable,
|
||||
query,
|
||||
{ params: new HttpParams().set('stateId', stateId) }
|
||||
);
|
||||
}
|
||||
|
||||
createCity(request: CreateCityRequest): Observable<CityDto> {
|
||||
return this.http.post<CityDto>(CITY_ENDPOINTS.create, request);
|
||||
}
|
||||
|
||||
updateCity(id: string, request: UpdateCityRequest): Observable<CityDto> {
|
||||
return this.http.put<CityDto>(CITY_ENDPOINTS.update(id), request);
|
||||
}
|
||||
|
||||
getCityById(id: string): Observable<CityDto> {
|
||||
return this.http.get<CityDto>(CITY_ENDPOINTS.getById(id));
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,9 @@ export const SAAS_MENU_DATA: MenuContext = {
|
||||
selected: false,
|
||||
dirchange: false,
|
||||
children: [
|
||||
{ path: '/global-masters/currencies', title: 'Currency', type: 'link', dirchange: false },
|
||||
{ path: '/global-masters/languages', title: 'Language', type: 'link', dirchange: false },
|
||||
{ path: '/global-masters/timezones', title: 'Timezone', type: 'link', dirchange: false },
|
||||
{ path: '/global-masters/countries', title: 'Country', type: 'link', dirchange: false },
|
||||
{ path: '/global-masters/states', title: 'State', type: 'link', dirchange: false },
|
||||
{ path: '/global-masters/cities', title: 'City', type: 'link', dirchange: false },
|
||||
@@ -75,4 +78,4 @@ export const SAAS_MENU_DATA: MenuContext = {
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { HttpClient, HttpParams } from "@angular/common/http";
|
||||
import { Injectable, inject } from "@angular/core";
|
||||
import { COUNTRY_ENDPOINTS } from "../../../core/end-points/country/country.endpoints";
|
||||
import { Observable } from "rxjs";
|
||||
import { DataTableQuery, DataTableResult } from "../../../shared/components/data-table/data-table.types";
|
||||
import {
|
||||
CountryDto,
|
||||
CountryLookupDto,
|
||||
CreateCountryRequest,
|
||||
UpdateCountryRequest
|
||||
} from "../../models/country/country.model";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -11,7 +17,27 @@ export class CountryService {
|
||||
|
||||
private readonly http = inject(HttpClient);
|
||||
|
||||
getCountryDataTable(query: DataTableQuery): Observable<DataTableResult<any>> {
|
||||
return this.http.post<DataTableResult<any>>(`${COUNTRY_ENDPOINTS.dataTable}`, query);
|
||||
getCountryDataTable(query: DataTableQuery): Observable<DataTableResult<CountryDto>> {
|
||||
return this.http.post<DataTableResult<CountryDto>>(`${COUNTRY_ENDPOINTS.dataTable}`, query);
|
||||
}
|
||||
}
|
||||
|
||||
createCountry(request: CreateCountryRequest): Observable<CountryDto> {
|
||||
return this.http.post<CountryDto>(COUNTRY_ENDPOINTS.create, request);
|
||||
}
|
||||
|
||||
updateCountry(id: string, request: UpdateCountryRequest): Observable<CountryDto> {
|
||||
return this.http.put<CountryDto>(COUNTRY_ENDPOINTS.update(id), request);
|
||||
}
|
||||
|
||||
getCountryById(id: string): Observable<CountryDto> {
|
||||
return this.http.get<CountryDto>(COUNTRY_ENDPOINTS.getById(id));
|
||||
}
|
||||
|
||||
autocomplete(term = '', limit = 50): Observable<CountryLookupDto[]> {
|
||||
return this.http.get<CountryLookupDto[]>(COUNTRY_ENDPOINTS.autocomplete, {
|
||||
params: new HttpParams()
|
||||
.set('term', term)
|
||||
.set('limit', limit)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { CURRENCY_ENDPOINTS } from '../../../core/end-points/currency/currency.endpoints';
|
||||
import { DataTableQuery, DataTableResult } from '../../../shared/components/data-table/data-table.types';
|
||||
import {
|
||||
CreateCurrencyRequest,
|
||||
CurrencyDto,
|
||||
CurrencyLookupDto,
|
||||
UpdateCurrencyRequest
|
||||
} from '../../models/currency/currency.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CurrencyService {
|
||||
private readonly http = inject(HttpClient);
|
||||
|
||||
getCurrencyDataTable(query: DataTableQuery): Observable<DataTableResult<CurrencyDto>> {
|
||||
return this.http.post<DataTableResult<CurrencyDto>>(CURRENCY_ENDPOINTS.dataTable, query);
|
||||
}
|
||||
|
||||
createCurrency(request: CreateCurrencyRequest): Observable<CurrencyDto> {
|
||||
return this.http.post<CurrencyDto>(CURRENCY_ENDPOINTS.create, request);
|
||||
}
|
||||
|
||||
updateCurrency(id: string, request: UpdateCurrencyRequest): Observable<CurrencyDto> {
|
||||
return this.http.put<CurrencyDto>(CURRENCY_ENDPOINTS.update(id), request);
|
||||
}
|
||||
|
||||
getCurrencyById(id: string): Observable<CurrencyDto> {
|
||||
return this.http.get<CurrencyDto>(CURRENCY_ENDPOINTS.getById(id));
|
||||
}
|
||||
|
||||
autocomplete(term: string | null, limit = 10): Observable<readonly CurrencyLookupDto[]> {
|
||||
let params = new HttpParams().set('limit', limit);
|
||||
const normalizedTerm = term?.trim();
|
||||
|
||||
if (normalizedTerm) {
|
||||
params = params.set('term', normalizedTerm);
|
||||
}
|
||||
|
||||
return this.http.get<readonly CurrencyLookupDto[]>(CURRENCY_ENDPOINTS.autocomplete, { params });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { LANGUAGE_ENDPOINTS } from '../../end-points/language/language.endpoints';
|
||||
import {
|
||||
CreateLanguageRequest,
|
||||
LanguageDto,
|
||||
LanguageLookupDto,
|
||||
UpdateLanguageRequest
|
||||
} from '../../models/language/language.model';
|
||||
import {
|
||||
DataTableQuery,
|
||||
DataTableResult
|
||||
} from '../../../shared/components/data-table/data-table.types';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class LanguageService {
|
||||
private readonly http = inject(HttpClient);
|
||||
|
||||
getDataTable(query: DataTableQuery): Observable<DataTableResult<LanguageDto>> {
|
||||
return this.http.post<DataTableResult<LanguageDto>>(LANGUAGE_ENDPOINTS.dataTable, query);
|
||||
}
|
||||
|
||||
getById(id: string): Observable<LanguageDto> {
|
||||
return this.http.get<LanguageDto>(LANGUAGE_ENDPOINTS.getById(id));
|
||||
}
|
||||
|
||||
create(request: CreateLanguageRequest): Observable<LanguageDto> {
|
||||
return this.http.post<LanguageDto>(LANGUAGE_ENDPOINTS.create, request);
|
||||
}
|
||||
|
||||
update(id: string, request: UpdateLanguageRequest): Observable<LanguageDto> {
|
||||
return this.http.put<LanguageDto>(LANGUAGE_ENDPOINTS.update(id), request);
|
||||
}
|
||||
|
||||
autocomplete(
|
||||
term: string | null,
|
||||
limit = 10
|
||||
): Observable<readonly LanguageLookupDto[]> {
|
||||
let params = new HttpParams().set('limit', limit);
|
||||
if (term !== null) {
|
||||
params = params.set('term', term);
|
||||
}
|
||||
|
||||
return this.http.get<readonly LanguageLookupDto[]>(LANGUAGE_ENDPOINTS.autocomplete, { params });
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,14 @@
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { HttpClient, HttpParams } from "@angular/common/http";
|
||||
import { Injectable, inject } from "@angular/core";
|
||||
import { STATE_ENDPOINTS } from "../../end-points/state/state.endpoints"
|
||||
import { Observable } from "rxjs";
|
||||
import { DataTableQuery, DataTableResult } from "../../../shared/components/data-table/data-table.types";
|
||||
import {
|
||||
CreateStateRequest,
|
||||
StateDto,
|
||||
StateLookupDto,
|
||||
UpdateStateRequest
|
||||
} from "../../models/state/state.model";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -11,7 +17,30 @@ export class StateService {
|
||||
|
||||
private readonly http = inject(HttpClient);
|
||||
|
||||
getStateDataTable(query: DataTableQuery, countryId: string): Observable<DataTableResult<any>> {
|
||||
return this.http.post<DataTableResult<any>>(`${STATE_ENDPOINTS.dataTable}`, { ...query, countryId });
|
||||
getStateDataTable(query: DataTableQuery, countryId: string): Observable<DataTableResult<StateDto>> {
|
||||
return this.http.post<DataTableResult<StateDto>>(`${STATE_ENDPOINTS.dataTable}`, query, {
|
||||
params: new HttpParams().set('countryId', countryId)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
createState(request: CreateStateRequest): Observable<StateDto> {
|
||||
return this.http.post<StateDto>(STATE_ENDPOINTS.create, request);
|
||||
}
|
||||
|
||||
updateState(id: string, request: UpdateStateRequest): Observable<StateDto> {
|
||||
return this.http.put<StateDto>(STATE_ENDPOINTS.update(id), request);
|
||||
}
|
||||
|
||||
getStateById(id: string): Observable<StateDto> {
|
||||
return this.http.get<StateDto>(STATE_ENDPOINTS.getById(id));
|
||||
}
|
||||
|
||||
autocomplete(countryId: string, term = '', limit = 50): Observable<StateLookupDto[]> {
|
||||
return this.http.get<StateLookupDto[]>(STATE_ENDPOINTS.autocomplete, {
|
||||
params: new HttpParams()
|
||||
.set('countryId', countryId)
|
||||
.set('term', term)
|
||||
.set('limit', limit)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { TIMEZONE_ENDPOINTS } from '../../end-points/timezone/timezone.endpoints';
|
||||
import {
|
||||
CreateTimezoneRequest,
|
||||
TimezoneDto,
|
||||
TimezoneLookupDto,
|
||||
UpdateTimezoneRequest
|
||||
} from '../../models/timezone/timezone.model';
|
||||
import {
|
||||
DataTableQuery,
|
||||
DataTableResult
|
||||
} from '../../../shared/components/data-table/data-table.types';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class TimezoneService {
|
||||
private readonly http = inject(HttpClient);
|
||||
|
||||
getDataTable(query: DataTableQuery): Observable<DataTableResult<TimezoneDto>> {
|
||||
return this.http.post<DataTableResult<TimezoneDto>>(TIMEZONE_ENDPOINTS.dataTable, query);
|
||||
}
|
||||
|
||||
getById(id: string): Observable<TimezoneDto> {
|
||||
return this.http.get<TimezoneDto>(TIMEZONE_ENDPOINTS.getById(id));
|
||||
}
|
||||
|
||||
create(request: CreateTimezoneRequest): Observable<TimezoneDto> {
|
||||
return this.http.post<TimezoneDto>(TIMEZONE_ENDPOINTS.create, request);
|
||||
}
|
||||
|
||||
update(id: string, request: UpdateTimezoneRequest): Observable<TimezoneDto> {
|
||||
return this.http.put<TimezoneDto>(TIMEZONE_ENDPOINTS.update(id), request);
|
||||
}
|
||||
|
||||
autocomplete(term: string | null, limit = 10): Observable<readonly TimezoneLookupDto[]> {
|
||||
const normalizedTerm = term?.trim() || null;
|
||||
let params = new HttpParams().set('limit', limit);
|
||||
if (normalizedTerm !== null) {
|
||||
params = params.set('term', normalizedTerm);
|
||||
}
|
||||
return this.http.get<readonly TimezoneLookupDto[]>(TIMEZONE_ENDPOINTS.autocomplete, { params });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user