refactor(project): Renamed all instances of dafa to msfa or mina-sidor-fa. (TV-379)
Squashed commit of the following: commit d3f52ff6876f6e246c7d3c188e56cc2370289341 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Aug 17 14:10:38 2021 +0200 Renamed all dafa instances to msfa
This commit is contained in:
20
apps/mina-sidor-fa/src/app/shared/models/address.model.ts
Normal file
20
apps/mina-sidor-fa/src/app/shared/models/address.model.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { AddressType, getAddressType } from '@msfa-enums/address-type.enum';
|
||||
import { AddressResponse } from './api/address.response.model';
|
||||
|
||||
export interface Address {
|
||||
type: AddressType;
|
||||
street: string;
|
||||
postalCode: string;
|
||||
city: string;
|
||||
country: string;
|
||||
}
|
||||
|
||||
export function mapResponseToAddress(data: AddressResponse): Address {
|
||||
return {
|
||||
type: getAddressType(data.adresstyp),
|
||||
street: data.gatuadress,
|
||||
postalCode: data.postnummer,
|
||||
city: data.postort,
|
||||
country: data.land,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export interface AddressResponse {
|
||||
adresstyp: 'FBF' | 'EgenAngiven';
|
||||
gatuadress: string;
|
||||
postnummer: string;
|
||||
postort: string;
|
||||
land: string;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
export interface AuthenticationResponse {
|
||||
id: string;
|
||||
access_token: string;
|
||||
scope: string;
|
||||
id_token: string;
|
||||
token_type: string;
|
||||
expires_in: number;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
export interface AvropResponse {
|
||||
id: string;
|
||||
deltagare: string;
|
||||
genomforandeReferens: number;
|
||||
orgId: string;
|
||||
leverantorId: number;
|
||||
organisationsnummer: string;
|
||||
utforandeVerksamhetId: number;
|
||||
utforandeverksamhet: string;
|
||||
kommunKod: string;
|
||||
kommun: string;
|
||||
utforandeAdressId: number;
|
||||
adress: string;
|
||||
ordernummer: string;
|
||||
bokningsId: number;
|
||||
personnummer: string;
|
||||
sokandeId: number;
|
||||
tjanstekod: string;
|
||||
tjansteNamn: string;
|
||||
deltagandeGrad: number;
|
||||
startdatumAvrop: string;
|
||||
slutdatumAvrop: string;
|
||||
aktnummerDiariet: string;
|
||||
tolkbehov: string;
|
||||
sprakstod: string;
|
||||
sparkod: string;
|
||||
sparNamn: string;
|
||||
supervisorId: number;
|
||||
recievedTimestamp: string;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { AddressResponse } from './address.response.model';
|
||||
import { PhoneNumberResponse } from './phonenumber.response.model';
|
||||
|
||||
export interface ContactInformationResponse {
|
||||
fornamn: string;
|
||||
efternamn: string;
|
||||
personnummer: string;
|
||||
epost: string;
|
||||
telekomadresser: PhoneNumberResponse[];
|
||||
adresser: AddressResponse[];
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { AvropResponse } from './avrop.response.model';
|
||||
import { ContactInformationResponse } from './contact-information.response.model';
|
||||
import { DisabilitiesResponse } from './disabilities.response.model';
|
||||
import { DriversLicenseResponse } from './drivers-license.response.model';
|
||||
import { EducationsResponse } from './educations.response.model';
|
||||
import { HighestEducationResponse } from './highest-education.response.model';
|
||||
import { TranslatorResponse } from './translator.response.model';
|
||||
import { WorkExperiencesResponse } from './work-experiences.response.model';
|
||||
import { WorkLanguagesResponse } from './work-languages.response.model';
|
||||
|
||||
export interface DeltagareCompactResponse {
|
||||
sokandeId: string;
|
||||
deltagare: string;
|
||||
kommun: string;
|
||||
}
|
||||
|
||||
export interface DeltagareResponse {
|
||||
id: string;
|
||||
contact: ContactInformationResponse;
|
||||
driverlicense: DriversLicenseResponse;
|
||||
highestEducation: HighestEducationResponse;
|
||||
educations: EducationsResponse;
|
||||
translator: TranslatorResponse;
|
||||
workLanguages: WorkLanguagesResponse;
|
||||
disabilities: DisabilitiesResponse;
|
||||
workExperiences: WorkExperiencesResponse;
|
||||
avropInformation: AvropResponse;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { DisabilityResponse } from './disability.response.model';
|
||||
|
||||
export interface DisabilitiesResponse {
|
||||
funktionsnedsattningar: DisabilityResponse[];
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export interface DisabilityResponse {
|
||||
|
||||
kod: string;
|
||||
funktionsnedsattning: string;
|
||||
beskrivning: string;
|
||||
utgatt: boolean;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface DriversLicenseResponse {
|
||||
korkort: { behorighet: string };
|
||||
tillgang_till_bil: boolean;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface EducationLevelResponse {
|
||||
utbildningsniva: string;
|
||||
beskrivning: string;
|
||||
taxonomy_id: number;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export interface EducationResponse {
|
||||
utbildning: string;
|
||||
beskrivning: string;
|
||||
anordnare: string;
|
||||
period_from: string;
|
||||
period_tom: string;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { EducationResponse } from './education.response.model';
|
||||
|
||||
export interface EducationsResponse {
|
||||
utbildningar: EducationResponse[];
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface EmployeeInviteMockApiResponse {
|
||||
id: number,
|
||||
createdAt: number
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface HandledareResponse {
|
||||
id: number;
|
||||
name: string
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export interface HighestEducationResponse {
|
||||
utbildningsniva: string;
|
||||
beskrivning_utbildningsniva: string;
|
||||
sun_kod: string;
|
||||
beskrivning_sun_kod: string;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface KommunResponse {
|
||||
kommunCode: number;
|
||||
kommun: string;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export interface LanguageResponse {
|
||||
beskrivning: string;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface OrganizationResponse {
|
||||
name: string;
|
||||
organizationnumber: string;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface PhoneNumberResponse {
|
||||
landskod: number;
|
||||
nummer_utan_inledande_nolla: number;
|
||||
telekomtyp: 'Mobil' | 'Bostad';
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface SunKodResponse {
|
||||
sun_kod: string;
|
||||
beskrivning: string;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface TjanstResponse {
|
||||
code: string;
|
||||
name: string;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { LanguageResponse } from './language.response.model';
|
||||
|
||||
export interface TranslatorResponse {
|
||||
sprak: LanguageResponse;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export interface UserInfoResponse {
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
roles: string[];
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface UtforandeVerksamhetResponse {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export interface WorkExperienceResponse {
|
||||
yrke: string;
|
||||
beskrivning: string;
|
||||
arbetsgivare: string;
|
||||
period_from: string;
|
||||
period_tom: string;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { WorkExperienceResponse } from './work-experience.response.model';
|
||||
|
||||
export interface WorkExperiencesResponse {
|
||||
arbetslivserfarenheter: WorkExperienceResponse[];
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { LanguageResponse } from './language.response.model';
|
||||
|
||||
export interface WorkLanguagesResponse {
|
||||
sprak: LanguageResponse[];
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { AuthenticationResponse } from './api/authentication.response.model';
|
||||
|
||||
export interface Authentication {
|
||||
idToken: string;
|
||||
expiresIn: number;
|
||||
}
|
||||
|
||||
export function mapAuthApiResponseToAuthenticationResult(data: AuthenticationResponse): Authentication {
|
||||
const { id_token, expires_in } = data;
|
||||
return {
|
||||
idToken: id_token,
|
||||
expiresIn: expires_in,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { Authorization as AuthorizationEnum } from '@msfa-enums/authorization.enum';
|
||||
|
||||
export interface Authorization {
|
||||
id: string;
|
||||
name: AuthorizationEnum;
|
||||
}
|
||||
|
||||
export interface AuthorizationApiResponse {
|
||||
data: AuthorizationApiResponseData[];
|
||||
}
|
||||
|
||||
export interface AuthorizationApiResponseData {
|
||||
id: string;
|
||||
name: AuthorizationEnum;
|
||||
}
|
||||
|
||||
export function mapAuthorizationApiResponseToAuthorization(data: AuthorizationApiResponseData): Authorization {
|
||||
const { id, name } = data;
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
};
|
||||
}
|
||||
57
apps/mina-sidor-fa/src/app/shared/models/avrop.model.ts
Normal file
57
apps/mina-sidor-fa/src/app/shared/models/avrop.model.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { AvropResponse } from './api/avrop.response.model';
|
||||
|
||||
export interface AvropCompact {
|
||||
id: string; // id
|
||||
sokandeId: number; // sokandeId
|
||||
fullName: string; // deltagare
|
||||
tjanst: string; // tjansteNamn
|
||||
startDate: Date; // startdatumAvrop
|
||||
endDate: Date; // slutdatumAvrop
|
||||
tolkbehov: string; // tolkbehov
|
||||
sprakstod: string; // sprakstod
|
||||
utforandeAdress: string; // adress
|
||||
trackCode: string; // sparkod
|
||||
trackName: string; // sparNamn
|
||||
}
|
||||
|
||||
export interface Avrop extends AvropCompact {
|
||||
genomforandeReferens: number; // genomforandeReferens
|
||||
participationFrequency: number; // deltagandeGrad
|
||||
utforandeVerksamhet: string; // utforandeverksamhet
|
||||
}
|
||||
|
||||
export function mapAvropResponseToAvrop(data: AvropResponse): Avrop {
|
||||
const {
|
||||
id,
|
||||
sokandeId,
|
||||
deltagare,
|
||||
tjansteNamn,
|
||||
startdatumAvrop,
|
||||
slutdatumAvrop,
|
||||
tolkbehov,
|
||||
sprakstod,
|
||||
adress,
|
||||
sparkod,
|
||||
sparNamn,
|
||||
genomforandeReferens,
|
||||
deltagandeGrad,
|
||||
utforandeverksamhet,
|
||||
} = data;
|
||||
|
||||
return {
|
||||
id,
|
||||
sokandeId,
|
||||
fullName: deltagare,
|
||||
tjanst: tjansteNamn,
|
||||
startDate: new Date(startdatumAvrop),
|
||||
endDate: new Date(slutdatumAvrop),
|
||||
tolkbehov: tolkbehov,
|
||||
sprakstod: sprakstod,
|
||||
utforandeAdress: adress,
|
||||
trackCode: sparkod,
|
||||
trackName: sparNamn,
|
||||
genomforandeReferens,
|
||||
participationFrequency: deltagandeGrad,
|
||||
utforandeVerksamhet: utforandeverksamhet,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Address, mapResponseToAddress } from './address.model';
|
||||
import { ContactInformationResponse } from './api/contact-information.response.model';
|
||||
import { mapResponseToPhoneNumber, PhoneNumber } from './phonenumber.model';
|
||||
|
||||
export interface ContactInformation {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
fullName: string;
|
||||
ssn: string;
|
||||
email: string;
|
||||
phoneNumbers: PhoneNumber[];
|
||||
addresses: Address[];
|
||||
}
|
||||
|
||||
export function mapResponseToContactInformation(contactInformation: ContactInformationResponse): ContactInformation {
|
||||
return {
|
||||
firstName: contactInformation.fornamn,
|
||||
lastName: contactInformation.efternamn,
|
||||
fullName: `${contactInformation.fornamn} ${contactInformation.efternamn}`,
|
||||
ssn: `${contactInformation.personnummer.substring(
|
||||
0,
|
||||
contactInformation.personnummer.length - 4
|
||||
)}-${contactInformation.personnummer.substring(contactInformation.personnummer.length - 4)}`,
|
||||
email: contactInformation.epost,
|
||||
phoneNumbers: contactInformation.telekomadresser
|
||||
? contactInformation.telekomadresser.map(phoneNumber => {
|
||||
return mapResponseToPhoneNumber(phoneNumber);
|
||||
})
|
||||
: [],
|
||||
addresses: contactInformation.adresser
|
||||
? contactInformation.adresser.map(address => mapResponseToAddress(address))
|
||||
: null,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export interface DateFormatOptions {
|
||||
year?: 'short' | 'long' | 'numeric';
|
||||
month?: 'short' | 'long' | 'numeric';
|
||||
day?: 'short' | 'long' | 'numeric';
|
||||
weekday?: 'short' | 'long' | 'numeric';
|
||||
}
|
||||
78
apps/mina-sidor-fa/src/app/shared/models/deltagare.model.ts
Normal file
78
apps/mina-sidor-fa/src/app/shared/models/deltagare.model.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
import { Address } from './address.model';
|
||||
import { AvropResponse } from './api/avrop.response.model';
|
||||
import { DeltagareResponse } from './api/deltagare.response.model';
|
||||
import { Avrop, mapAvropResponseToAvrop } from './avrop.model';
|
||||
import { mapResponseToContactInformation } from './contact-information.model';
|
||||
import { Disability, mapResponseToDisability } from './disability.model';
|
||||
import { DriversLicense, mapResponseToDriversLicense } from './drivers-license.model';
|
||||
import { Education, mapResponseToEducation } from './education.model';
|
||||
import { HighestEducation, mapResponseToHighestEducation } from './highest-education.model';
|
||||
import { PhoneNumber } from './phonenumber.model';
|
||||
import { mapResponseToWorkExperience, WorkExperience } from './work-experience.model';
|
||||
|
||||
export interface DeltagareCompact {
|
||||
id: string;
|
||||
fullName: string;
|
||||
utforandeVerksamhet: string;
|
||||
utforandeAdress: string;
|
||||
}
|
||||
|
||||
export interface Deltagare {
|
||||
id: string;
|
||||
fullName: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
ssn: string;
|
||||
email: string;
|
||||
phoneNumbers: PhoneNumber[];
|
||||
addresses: Address[];
|
||||
driversLicense: DriversLicense;
|
||||
educations: Education[];
|
||||
highestEducation: HighestEducation;
|
||||
translator: string;
|
||||
disabilities: Disability[];
|
||||
workLanguages: string[];
|
||||
workExperiences: WorkExperience[];
|
||||
avropInformation: Avrop;
|
||||
}
|
||||
|
||||
export function mapResponseToDeltagareCompact(data: AvropResponse): DeltagareCompact {
|
||||
const { sokandeId, deltagare, adress, utforandeverksamhet } = data;
|
||||
return {
|
||||
id: sokandeId.toString(),
|
||||
fullName: deltagare,
|
||||
utforandeVerksamhet: utforandeverksamhet,
|
||||
utforandeAdress: adress,
|
||||
};
|
||||
}
|
||||
|
||||
export function mapResponseToDeltagare(data: DeltagareResponse): Deltagare {
|
||||
const {
|
||||
id,
|
||||
contact,
|
||||
driverlicense,
|
||||
highestEducation,
|
||||
educations,
|
||||
translator,
|
||||
workLanguages,
|
||||
disabilities,
|
||||
workExperiences,
|
||||
avropInformation,
|
||||
} = data;
|
||||
|
||||
return {
|
||||
id,
|
||||
...mapResponseToContactInformation(contact),
|
||||
driversLicense: mapResponseToDriversLicense(driverlicense),
|
||||
highestEducation: highestEducation && mapResponseToHighestEducation(highestEducation),
|
||||
educations: educations && educations.utbildningar.map(education => mapResponseToEducation(education)),
|
||||
translator: translator && translator.sprak.beskrivning,
|
||||
workLanguages: workLanguages && workLanguages.sprak.map(language => language.beskrivning),
|
||||
disabilities:
|
||||
disabilities && disabilities.funktionsnedsattningar.map(disability => mapResponseToDisability(disability)),
|
||||
workExperiences:
|
||||
workExperiences &&
|
||||
workExperiences.arbetslivserfarenheter.map(workExperience => mapResponseToWorkExperience(workExperience)),
|
||||
avropInformation: avropInformation && mapAvropResponseToAvrop(avropInformation),
|
||||
};
|
||||
}
|
||||
16
apps/mina-sidor-fa/src/app/shared/models/disability.model.ts
Normal file
16
apps/mina-sidor-fa/src/app/shared/models/disability.model.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { DisabilityResponse } from './api/disability.response.model';
|
||||
|
||||
export interface Disability {
|
||||
code: string;
|
||||
title: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export function mapResponseToDisability(data: DisabilityResponse): Disability {
|
||||
const { kod, funktionsnedsattning, beskrivning } = data;
|
||||
return {
|
||||
code: kod,
|
||||
title: funktionsnedsattning,
|
||||
description: beskrivning,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { DRIVERS_LICENSES } from '@msfa-constants/drivers-licenses';
|
||||
import { DriversLicenseResponse } from './api/drivers-license.response.model';
|
||||
|
||||
export interface DriversLicense {
|
||||
licenses: string[];
|
||||
accessToCar: boolean;
|
||||
}
|
||||
|
||||
function mapLicensesAsStringToArray(licenses = ''): string[] {
|
||||
const allLicenses = DRIVERS_LICENSES.sort((a, b) => b.length - a.length);
|
||||
let search = licenses;
|
||||
const found: string[] = [];
|
||||
|
||||
allLicenses.forEach(license => {
|
||||
if (search.indexOf(license) >= 0) {
|
||||
found.push(license);
|
||||
search = search.replace(license, '');
|
||||
}
|
||||
});
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
export function mapResponseToDriversLicense(data: DriversLicenseResponse): DriversLicense {
|
||||
return {
|
||||
licenses: mapLicensesAsStringToArray(data.korkort.behorighet),
|
||||
accessToCar: data.tillgang_till_bil,
|
||||
};
|
||||
}
|
||||
22
apps/mina-sidor-fa/src/app/shared/models/education.model.ts
Normal file
22
apps/mina-sidor-fa/src/app/shared/models/education.model.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { formatToDate } from '@msfa-utils/format-to-date.util';
|
||||
import { EducationResponse } from './api/education.response.model';
|
||||
|
||||
export interface Education {
|
||||
education: string;
|
||||
description: string;
|
||||
organizer: string;
|
||||
dateFrom: Date;
|
||||
dateTo: Date;
|
||||
}
|
||||
|
||||
export function mapResponseToEducation(data: EducationResponse): Education {
|
||||
const { utbildning, beskrivning, anordnare, period_from, period_tom } = data;
|
||||
|
||||
return {
|
||||
education: utbildning,
|
||||
description: beskrivning,
|
||||
organizer: anordnare,
|
||||
dateFrom: formatToDate(period_from),
|
||||
dateTo: formatToDate(period_tom),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export interface EmployeeInviteMockaData {
|
||||
id: number
|
||||
}
|
||||
75
apps/mina-sidor-fa/src/app/shared/models/employee.model.ts
Normal file
75
apps/mina-sidor-fa/src/app/shared/models/employee.model.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { Authorization } from '@msfa-enums/authorization.enum';
|
||||
import { Organization } from './organization.model';
|
||||
import { PaginationMeta } from './pagination-meta.model';
|
||||
import { Service } from './service.model';
|
||||
|
||||
export interface Employee {
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
fullName?: string;
|
||||
ssn: string;
|
||||
organizations: Organization[];
|
||||
services: Service[];
|
||||
authorizations: Authorization[];
|
||||
createdAt?: number;
|
||||
}
|
||||
|
||||
export interface EmployeesApiResponse {
|
||||
data: Employee[];
|
||||
meta: PaginationMeta;
|
||||
}
|
||||
|
||||
export interface EmployeesData {
|
||||
data: Employee[];
|
||||
meta: PaginationMeta;
|
||||
}
|
||||
|
||||
export interface EmployeeApiResponse {
|
||||
data: Employee;
|
||||
}
|
||||
|
||||
export interface EmployeeApiResponseData {
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
ssn: string;
|
||||
organizations: Organization[];
|
||||
authorizations: Authorization[];
|
||||
services: Service[];
|
||||
}
|
||||
|
||||
export interface EmployeeApiRequestData {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
ssn: string;
|
||||
organizations: Organization[];
|
||||
services: Service[];
|
||||
authorizations: Authorization[];
|
||||
}
|
||||
|
||||
export function mapEmployeeToEmployeeApiRequestData(data: Employee): EmployeeApiRequestData {
|
||||
const { firstName, lastName, ssn, services, organizations, authorizations } = data;
|
||||
return {
|
||||
firstName,
|
||||
lastName,
|
||||
ssn,
|
||||
services,
|
||||
organizations,
|
||||
authorizations,
|
||||
};
|
||||
}
|
||||
|
||||
export function mapEmployeeReponseToEmployee(data: EmployeeApiResponseData): Employee {
|
||||
const { id, firstName, lastName, ssn, services, organizations, authorizations } = data;
|
||||
return {
|
||||
id,
|
||||
firstName,
|
||||
lastName,
|
||||
fullName: `${firstName} ${lastName}`,
|
||||
organizations,
|
||||
authorizations,
|
||||
services,
|
||||
ssn,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
export interface Environment {
|
||||
environment: 'api' | 'local' | 'prod';
|
||||
clientId: string;
|
||||
loginUrl: string;
|
||||
production: boolean;
|
||||
api: {
|
||||
url: string;
|
||||
headers: { [key: string]: string };
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import { ErrorSeverity } from '@msfa-enums/error-severity.enum';
|
||||
import { ErrorType } from '@msfa-enums/error-type.enum';
|
||||
|
||||
export class CustomError implements Error {
|
||||
id: string;
|
||||
name: string;
|
||||
message: string;
|
||||
stack: string;
|
||||
type: ErrorType;
|
||||
severity: ErrorSeverity;
|
||||
timestamp: Date;
|
||||
error: Error;
|
||||
removeAfter: number;
|
||||
|
||||
constructor(args: { error: Error; type?: ErrorType; message?: string; severity?: ErrorSeverity; stack?: string }) {
|
||||
this.timestamp = new Date();
|
||||
this.id = this.timestamp.getTime().toString();
|
||||
this.type = this.name = args.type || ErrorType.UNKNOWN;
|
||||
this.message = args.message || args.error.message;
|
||||
this.severity = args.severity || ErrorSeverity.HIGH;
|
||||
this.stack = args.stack || CustomError.getStack(args.error);
|
||||
this.error = args.error;
|
||||
this.removeAfter =
|
||||
this.severity === ErrorSeverity.LOW ? 5000 : this.severity === ErrorSeverity.MEDIUM ? 10000 : 20000;
|
||||
}
|
||||
|
||||
static getStack(error: Error | { error: Error }): string {
|
||||
if (!error) {
|
||||
return '';
|
||||
}
|
||||
if (typeof error === 'string') {
|
||||
return error;
|
||||
}
|
||||
|
||||
if ('stack' in error) {
|
||||
return error.stack;
|
||||
} else if ('error' in error) {
|
||||
return this.getStack(error.error);
|
||||
} else {
|
||||
return error as never;
|
||||
}
|
||||
}
|
||||
|
||||
static getErrorType(error: Error | (Error & { type: ErrorType })): ErrorType {
|
||||
if (typeof error === 'object' && 'type' in error) {
|
||||
return error.type;
|
||||
} else if (error.name === 'HttpErrorResponse') {
|
||||
return ErrorType.API;
|
||||
}
|
||||
|
||||
return ErrorType.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
export function errorToCustomError(error: Error & { ngDebugContext: unknown }): CustomError {
|
||||
const type = CustomError.getErrorType(error);
|
||||
const message = error.message || error;
|
||||
const severity = ErrorSeverity.HIGH;
|
||||
|
||||
// this is done to avoid circular references while running in debug mode
|
||||
if ('ngDebugContext' in error) {
|
||||
error.ngDebugContext = {};
|
||||
}
|
||||
|
||||
return new CustomError({
|
||||
error,
|
||||
type,
|
||||
severity,
|
||||
message: message as string,
|
||||
});
|
||||
}
|
||||
17
apps/mina-sidor-fa/src/app/shared/models/handledare.model.ts
Normal file
17
apps/mina-sidor-fa/src/app/shared/models/handledare.model.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { HandledareResponse } from './api/handledare.response.model';
|
||||
|
||||
export interface Handledare {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export function mapHandledareResponseToHandledare(
|
||||
data: HandledareResponse
|
||||
): Handledare {
|
||||
const { id, name } = data;
|
||||
|
||||
return {
|
||||
id,
|
||||
name
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { HighestEducationResponse } from './api/highest-education.response.model';
|
||||
|
||||
export interface HighestEducation {
|
||||
level: {
|
||||
code: string;
|
||||
description: string;
|
||||
};
|
||||
sunKod: {
|
||||
code: string;
|
||||
description: string;
|
||||
};
|
||||
}
|
||||
|
||||
export function mapResponseToHighestEducation(data: HighestEducationResponse): HighestEducation {
|
||||
const { utbildningsniva, beskrivning_utbildningsniva, sun_kod, beskrivning_sun_kod } = data;
|
||||
|
||||
return {
|
||||
level: {
|
||||
code: utbildningsniva,
|
||||
description: beskrivning_utbildningsniva,
|
||||
},
|
||||
sunKod: {
|
||||
code: sun_kod,
|
||||
description: beskrivning_sun_kod,
|
||||
},
|
||||
};
|
||||
}
|
||||
15
apps/mina-sidor-fa/src/app/shared/models/kommun.model.ts
Normal file
15
apps/mina-sidor-fa/src/app/shared/models/kommun.model.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { KommunResponse } from './api/kommun.response.model';
|
||||
|
||||
export interface Kommun {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export function mapKommunResponseToKommun(data: KommunResponse): Kommun {
|
||||
const { kommunCode, kommun } = data;
|
||||
|
||||
return {
|
||||
id: kommunCode,
|
||||
name: kommun
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface MultiselectFilterOption {
|
||||
label?: string;
|
||||
id?: string;
|
||||
count?: number;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { OrganizationResponse } from './api/organization.response.model';
|
||||
|
||||
export interface Organization {
|
||||
name: string;
|
||||
organizationNumber: string;
|
||||
}
|
||||
|
||||
export function mapResponseToOrganization(data: OrganizationResponse): Organization {
|
||||
const { name, organizationnumber } = data;
|
||||
|
||||
return {
|
||||
name,
|
||||
organizationNumber: organizationnumber,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface OutOfOfficeDate {
|
||||
id: number;
|
||||
start: Date;
|
||||
end: Date;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export interface PaginationMeta {
|
||||
count: number;
|
||||
limit: number;
|
||||
page: number;
|
||||
totalPages: number;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import { ParticipantStatus } from '@msfa-enums/participant-status.enum';
|
||||
import { Service } from '@msfa-enums/service.enum';
|
||||
import { PaginationMeta } from './pagination-meta.model';
|
||||
|
||||
export interface Participant {
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
fullName: string;
|
||||
ssn: string;
|
||||
status: ParticipantStatus;
|
||||
nextStep: string;
|
||||
service: Service;
|
||||
errandNumber: number;
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
handleBefore: Date;
|
||||
}
|
||||
|
||||
export interface ParticipantsApiResponse {
|
||||
data: ParticipantApiResponseData[];
|
||||
meta?: PaginationMeta;
|
||||
}
|
||||
|
||||
export interface ParticipantApiResponse {
|
||||
data: ParticipantApiResponseData;
|
||||
}
|
||||
|
||||
export interface ParticipantApiResponseData {
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
ssn: string;
|
||||
status: ParticipantStatus;
|
||||
nextStep: string;
|
||||
service: Service;
|
||||
errandNumber: number;
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
handleBefore: Date;
|
||||
}
|
||||
|
||||
export function mapParticipantApiResponseToParticipant(data: ParticipantApiResponseData): Participant {
|
||||
const {
|
||||
id,
|
||||
firstName,
|
||||
lastName,
|
||||
ssn,
|
||||
status,
|
||||
nextStep,
|
||||
service,
|
||||
errandNumber,
|
||||
startDate,
|
||||
endDate,
|
||||
handleBefore,
|
||||
} = data;
|
||||
return {
|
||||
id,
|
||||
firstName,
|
||||
lastName,
|
||||
fullName: `${firstName} ${lastName}`,
|
||||
ssn,
|
||||
status,
|
||||
nextStep,
|
||||
service,
|
||||
errandNumber,
|
||||
startDate,
|
||||
endDate,
|
||||
handleBefore,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { getPhoneNumberType, PhoneNumberType } from '@msfa-enums/phonenumber-type.enum';
|
||||
import { PhoneNumberResponse } from './api/phonenumber.response.model';
|
||||
|
||||
export interface PhoneNumber {
|
||||
type: PhoneNumberType;
|
||||
number: string;
|
||||
}
|
||||
|
||||
export function mapResponseToPhoneNumber(data: PhoneNumberResponse): PhoneNumber {
|
||||
return {
|
||||
type: getPhoneNumberType(data.telekomtyp),
|
||||
number: `+${data.landskod}${data.nummer_utan_inledande_nolla}`,
|
||||
};
|
||||
}
|
||||
23
apps/mina-sidor-fa/src/app/shared/models/service.model.ts
Normal file
23
apps/mina-sidor-fa/src/app/shared/models/service.model.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Service as ServiceEnum } from '@msfa-enums/service.enum';
|
||||
|
||||
export interface Service {
|
||||
id: string;
|
||||
name: ServiceEnum;
|
||||
}
|
||||
|
||||
export interface ServiceApiResponse {
|
||||
data: ServiceApiResponseData[];
|
||||
}
|
||||
|
||||
export interface ServiceApiResponseData {
|
||||
id: string;
|
||||
name: ServiceEnum;
|
||||
}
|
||||
|
||||
export function mapServiceApiResponseToService(data: ServiceApiResponseData): Service {
|
||||
const { id, name } = data;
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
};
|
||||
}
|
||||
6
apps/mina-sidor-fa/src/app/shared/models/sort.model.ts
Normal file
6
apps/mina-sidor-fa/src/app/shared/models/sort.model.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { SortOrder } from '@msfa-enums/sort-order.enum';
|
||||
|
||||
export interface Sort<Key> {
|
||||
key: Key;
|
||||
order: SortOrder;
|
||||
}
|
||||
15
apps/mina-sidor-fa/src/app/shared/models/tjanst.model.ts
Normal file
15
apps/mina-sidor-fa/src/app/shared/models/tjanst.model.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { TjanstResponse } from './api/tjanst.response.model';
|
||||
|
||||
export interface Tjanst {
|
||||
code: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export function mapTjanstResponseToTjanst(data: TjanstResponse): Tjanst {
|
||||
const { code, name } = data;
|
||||
|
||||
return {
|
||||
code,
|
||||
name,
|
||||
};
|
||||
}
|
||||
21
apps/mina-sidor-fa/src/app/shared/models/user-info.model.ts
Normal file
21
apps/mina-sidor-fa/src/app/shared/models/user-info.model.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { UserInfoResponse } from './api/user-info.response.model';
|
||||
|
||||
export interface UserInfo {
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
fullName: string;
|
||||
roles: string[];
|
||||
}
|
||||
|
||||
export function mapResponseToUserInfo(data: UserInfoResponse): UserInfo {
|
||||
const { id, firstName, lastName, roles } = data;
|
||||
|
||||
return {
|
||||
id,
|
||||
firstName,
|
||||
lastName,
|
||||
fullName: `${firstName} ${lastName}`,
|
||||
roles,
|
||||
};
|
||||
}
|
||||
21
apps/mina-sidor-fa/src/app/shared/models/user.model.ts
Normal file
21
apps/mina-sidor-fa/src/app/shared/models/user.model.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { OrganizationResponse } from './api/organization.response.model';
|
||||
import { UserInfoResponse } from './api/user-info.response.model';
|
||||
import { mapResponseToOrganization, Organization } from './organization.model';
|
||||
import { UserInfo } from './user-info.model';
|
||||
|
||||
export interface User extends UserInfo {
|
||||
organizations: Organization[];
|
||||
}
|
||||
|
||||
export function mapUserApiResponseToUser(userInfo: UserInfoResponse, organizations: OrganizationResponse[]): User {
|
||||
const { id, firstName, lastName, roles } = userInfo;
|
||||
|
||||
return {
|
||||
id,
|
||||
firstName,
|
||||
lastName,
|
||||
fullName: `${firstName} ${lastName}`,
|
||||
roles,
|
||||
organizations: organizations ? organizations.map(organization => mapResponseToOrganization(organization)) : [],
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { UtforandeVerksamhetResponse } from './api/utforande-verksamhet.response.model';
|
||||
|
||||
export interface UtforandeVerksamhet {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export function mapUtforandeVerksamhetResponseToUtforandeVerksamhet(
|
||||
data: UtforandeVerksamhetResponse
|
||||
): UtforandeVerksamhet {
|
||||
const { id, name } = data;
|
||||
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface ValidationError {
|
||||
type: string;
|
||||
message: string;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { formatToDate } from '@msfa-utils/format-to-date.util';
|
||||
import { WorkExperienceResponse } from './api/work-experience.response.model';
|
||||
|
||||
export interface WorkExperience {
|
||||
profession: string;
|
||||
description: string;
|
||||
employer: string;
|
||||
dateFrom: Date;
|
||||
dateTo: Date;
|
||||
}
|
||||
|
||||
export function mapResponseToWorkExperience(data: WorkExperienceResponse): WorkExperience {
|
||||
const { yrke, beskrivning, arbetsgivare, period_from, period_tom } = data;
|
||||
|
||||
return {
|
||||
profession: yrke,
|
||||
description: beskrivning,
|
||||
employer: arbetsgivare,
|
||||
dateFrom: formatToDate(period_from),
|
||||
dateTo: formatToDate(period_tom),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user