Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, OnInit, Inject, ViewChild, QueryList, ElementRef } from "@angular/core";
- import { Title } from "@angular/platform-browser";
- import { NgbDateStruct } from "@ng-bootstrap/ng-bootstrap";
- import { VacancyFormService } from "./vacancy-form.service";
- import { NgxSpinnerService } from 'ngx-spinner';
- import { Router, ActivatedRoute, ParamMap } from '@angular/router';
- import { SESSION_STORAGE, StorageService } from 'angular-webstorage-service';
- import { FormGroup, FormBuilder, Validators, FormControl } from "@angular/forms";
- import { DataService } from "../services/data.service";
- import { MatStepper } from '@angular/material/stepper';
- import { formatDate, DatePipe } from "@angular/common";
- import { MatDialog, MatSnackBar } from "@angular/material";
- import { MatDatepickerInputEvent } from '@angular/material/datepicker';
- import { ApplyConfirmationDialogComponent } from "./apply-confirmation-dialog/apply-confirmation-dialog.component";
- import * as moment from 'moment';
- import { debounceTime, map, startWith } from "rxjs/operators";
- import { debounce } from 'lodash';
- import { Observable } from "rxjs";
- import { CoverLetterData, DocumentGeneratorService } from "./document-generator.service";
- export class AvailableVacancies {
- vacancyId: number
- title: string
- category: string
- description: string
- requirement: string
- createdDate: Date
- modifiedDate: Date
- expiredDate: Date
- availableVacanciesConfig: AvailableVacanciesConfig[]
- }
- export class AvailableVacanciesConfig {
- id: number
- vacancyId: string
- field: string
- rule: string
- value: string
- }
- export class Document {
- candidatesDocumentId: number;
- npwpNo: string
- bpjsNo: string
- faskes: string
- jamsostekNo: string
- jamsostekDate: string
- simType: string
- simNo: string
- simExpiredDate: string
- stnkExpiredDate: string
- stnkPlatNoDate: string
- bankName: string
- bankAccountName: string
- bankAccountNo: string
- licensePlate: string
- }
- export class EmergencyContact {
- candidatesEmergencyContactId: number
- emergencyContactName: string;
- phoneNumber: string;
- relationship: string;
- }
- export class LanguageSkill {
- candidatesLanguageId: number;
- language: string;
- readingSkill: string
- writingSkill: string
- listeningSkill: string
- conversationalSkill: string
- remarks: string
- }
- export class WorkExperience {
- candidatesWorkExperienceId: number;
- companyName: string
- position: string
- yearIn: string
- yearOut: string
- achievement: string
- }
- export class InformalEducation {
- candidatesInformalId: number;
- trainingName: string
- trainingDate: string
- remarks: string
- }
- export class Education {
- candidatesEducationId: number;
- institution: string
- major: string
- yearIn: string
- yearOut: string
- grade: string
- }
- export class Family {
- candidatesFamilyId: number;
- relationship: string;
- name: string;
- gender: string;
- dateOfBirth: string;
- lastEducation: string;
- occupation: string;
- companyName: string;
- }
- export class PersonalInfo {
- candidatesId: number
- name: string;
- sex: string;
- dateOfBirth: string;
- placeOfBirth: string;
- dateOfDivorce: string;
- ktpNo: string = "";
- ktpAddress: string;
- ktpKota: string;
- ktpKodePos: string;
- ktpKecamatan: string;
- ktpKelurahan: string;
- ktpRt: string;
- ktpRw: string;
- domisiliAddress: string;
- domisiliKota: string;
- domisiliKodePos: string = "";
- kkNo: string = "";
- address: string;
- lastEducation: string;
- religion: string;
- maritalStatus: string;
- email: string;
- phoneNumber: string = "";
- driverLicenseType: string = "";
- driverLicenseNumber: string = "";
- hobby: string;
- appliedPosition: string;
- level: string
- placementCityCode: string;
- placementProvinceCode: string;
- jobVacancySource: string;
- ptkp: string;
- vaccineStatus: number;
- vaccineConsent: number;
- }
- export interface ResumeData {
- personalInfo: PersonalInfoPrint;
- familyList: Family[];
- educationList: Education[];
- informalEducationList: InformalEducation[];
- workExperienceList: WorkExperience[];
- }
- export interface PersonalInfoPrint extends PersonalInfo {
- placeDateBirth?: string;
- }
- @Component({
- selector: "app-vacancy-form-component",
- templateUrl: "./vacancy-form.component.html",
- styleUrls: ["./vacancy-form.component.scss"]
- })
- export class VacancyFormComponent implements OnInit {
- @ViewChild('stepper') private myStepper: MatStepper;
- @ViewChild('cards') cards: QueryList<ElementRef>;
- moment: any = moment;
- allowedFile: string = "JPG,JPEG,PDF"
- optionVaccine = [
- {
- label: "Belum Vaksin",
- value: 0
- },
- {
- label: "Tahap 1",
- value: 1
- },
- {
- label: "Tahap 2",
- value: 2
- },
- ]
- optionVaccineConsent = [
- {
- label: "Ya",
- value: 1
- },
- {
- label: "Tidak",
- value: 0
- },
- ]
- applyConfirmationDialogComponent = ApplyConfirmationDialogComponent;
- optionBpjs: Array<string> = ["YA", "TIDAK"]
- selectedOptionBpjs: string
- selectedOptionJamsostek: string
- numberOnly: RegExp = /[0-9]+/
- validKtp: RegExp = /^(?!(\d)\1+$|\d*(\d)\2{6}$)(?:\d{16})?$/
- validEmail: RegExp = /[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/
- validPhone: RegExp = /^08[0-9]*$/
- alphaspaceOnly: RegExp = /[^a-z ]/gi
- placementProvince: string
- placementCity: string
- placementProvinceCode: string
- placementCityCode: string
- placementProvinceAuto: Array<any>
- placementCityAuto: Array<any>
- numberOfSibling: number = 0
- numberOfChild: number = 0
- loadPersonalData: boolean = false
- loadFamily: boolean = false
- loadDocument: boolean = false
- loadEducation: boolean = false
- loadInformalEducation: boolean = false
- loadWorkExperience: boolean = false
- loadLanguageSkill: boolean = false
- loadEmergencyContact: boolean = false
- ijazah: File
- cv: File
- ktp: File
- kk: File
- skck: File
- sim: File
- stnk: File
- stnkBack: File
- tabungan: File
- vaccine: File
- coverLetter: File
- ijazahStatus: boolean = false
- cvStatus: boolean = false
- ktpStatus: boolean = false
- kkStatus: boolean = false
- skckStatus: boolean = false
- simStatus: boolean = false
- stnkStatus: boolean = false
- stnkBackStatus: boolean = false
- tabunganStatus: boolean = false
- vaccineStatus: boolean = false
- ijazahFilename: string
- cvFilename: string
- ktpFilename: string
- kkFilename: string
- skckFilename: string
- simFilename: string
- stnkFilename: string
- stnkBackFilename: string
- tabunganFilename: string
- vaccineFilename: string
- vacancyId: string
- title: string = ""
- category: string = ""
- candidatesId: string
- step: number = 0
- availableVacancies: AvailableVacancies
- availableVacanciesConfig: AvailableVacanciesConfig[] = []
- personalInfoDetail: PersonalInfo = new PersonalInfo
- documentDetail: Document = new Document
- familyList: Family[] = []
- educationList: Education[] = [new Education]
- informalEducationList: InformalEducation[] = [new InformalEducation]
- workExperienceList: WorkExperience[] = []
- languageSkillList: LanguageSkill[] = []
- emergencyContactList: EmergencyContact[] = [new EmergencyContact]
- validationStatus: Array<boolean> = [
- false,
- false,
- false,
- false,
- false,
- false,
- false,
- ]
- url: string = "";
- public candidateId: any;
- public authorization: string = "";
- public position: string = "";
- hasFileName = {
- KTP: '',
- KK: '',
- Ijazah: '',
- CV: '',
- SIM: '',
- STNK: '',
- STNKBACK: '',
- Tabungan: '',
- Vaccine: '',
- }
- textPTKP = {
- TK0: 'BELUM KAWIN',
- TK1: 'BELUM KAWIN TANGGUNGAN SATU',
- TK2: 'BELUM KAWIN TANGGUNGAN DUA',
- TK3: 'BELUM KAWIN TANGGUNGAN TIGA',
- K0: 'KAWIN TANGGUNGAN 0',
- K1: 'KAWIN TANGGUNGAN 1',
- K2: 'KAWIN TANGGUNGAN 2',
- K3: 'KAWIN TANGGUNGAN 3'
- }
- simOption = [
- // "SIM A",
- // "SIM B",
- "SIM C"
- ];
- bankDetail = [
- {
- bankName: "BCA",
- minLength: 10,
- maxLength: 10
- },
- {
- bankName: "BNI",
- minLength: 4,
- maxLength: 20
- },
- {
- bankName: "BRI",
- minLength: 4,
- maxLength: 20
- },
- {
- bankName: "MANDIRI",
- minLength: 13,
- maxLength: 13
- },
- {
- bankName: "BSI",
- minLength: 4,
- maxLength: 20
- },
- ]
- districtList;
- provinceList = [];
- filteredProvinceList: Observable<any>;
- cityList = [];
- filteredCityList: Observable<any>;
- provinceControl = new FormControl();
- cityControl = new FormControl();
- constructor(
- private datePipe: DatePipe,
- private dataService: DataService,
- private _formBuilder: FormBuilder,
- private services: VacancyFormService,
- public spinner: NgxSpinnerService,
- public router: Router,
- private route: ActivatedRoute,
- @Inject(SESSION_STORAGE) public storage: StorageService,
- private dialog: MatDialog,
- private _snackBar: MatSnackBar,
- private titleService: Title,
- private docGenerator: DocumentGeneratorService,
- ) {
- this.url = this.router.url;
- if (this.url == "/psikotest-start" || this.url == "/epkwt-form") {
- this.authorization = this.storage.get("token") ? this.storage.get("token") : this.dataService.token;
- this.candidateId = this.storage.get("candidate_id");
- this.titleService.setTitle("Psikotest");
- } else {
- this.titleService.setTitle("Anteraja Career");
- }
- // this.onInputPlacementProvince = debounce(this.onInputPlacementProvince, 4)
- // this.onInputPlacementCity = debounce(this.onInputPlacementCity, 4)
- // this.onChangePlacementCity = debounce(this.onChangePlacementCity, 7)
- // this.onChangePlacementProvince = debounce(this.onChangePlacementProvince, 7)
- }
- @ViewChild('topPage')
- topPage: ElementRef;
- ngOnInit() {
- //For AutoComplete
- this.services.getDisctrictFromAPI().subscribe((res) => {
- this.districtList = res;
- this.provinceList = Object.keys(this.districtList);
- this.provinceControl.valueChanges.subscribe((val) => {
- // console.log(val);
- if (this.districtList) {
- let provinceData = this.districtList[val];
- // console.log('dis',provinceData);
- if (provinceData) {
- this.cityList = provinceData;
- this.placementProvinceCode = this.cityList[0].provinceCode;
- this.cityControl.setValue('');
- // console.log('code',this.placementProvinceCode);
- }
- else {
- this.cityList = [];
- this.placementProvinceCode = null;
- this.cityControl.setValue('');
- // console.log(this.placementCityCode);
- }
- }
- })
- this.cityControl.valueChanges.subscribe((val) => {
- // console.log(val);
- if (this.cityList) {
- let cityData = this.cityList.filter(x => x.cityName == val);
- // console.log('city',cityData);
- if (cityData.length == 1) {
- this.placementCityCode = cityData[0].cityCode;
- // console.log('code',this.placementCityCode);
- }
- else {
- this.placementCityCode = null;
- }
- }
- })
- this.filteredCityList = this.cityControl.valueChanges
- .pipe(
- startWith(''),
- map(value => this.filterCity(value))
- );
- this.filteredProvinceList = this.provinceControl.valueChanges
- .pipe(
- startWith(''),
- map(value => this.filterProvince(value))
- );
- });
- let ayah = new Family
- let ibu = new Family
- ayah.relationship = "Father"
- ibu.relationship = "Mother"
- ayah.gender = "M"
- ibu.gender = "F"
- this.familyList.push(ayah)
- this.familyList.push(ibu)
- //console.log(this.validateSatriaAge(new Date("2012-10-10")))
- if (this.isPsikotestStart() || this.isEpkwtForm()) {
- this.getAllDataPsikotest()
- this.services.findAVacancyByTitle(this.personalInfoDetail.appliedPosition).subscribe(
- result => {
- this.availableVacancies = result
- this.availableVacanciesConfig = result.availableVacanciesConfig
- console.log("Detail Vacancy")
- console.log(this.availableVacancies)
- }
- )
- } else {
- console.log(this.route.snapshot.paramMap.get('id'))
- this.services.findAVacancy(this.route.snapshot.paramMap.get('id')).subscribe(
- result => {
- console.log(result)
- if (result) {
- // console.log("notEmpty")
- this.availableVacancies = result
- this.availableVacanciesConfig = result.availableVacanciesConfig
- console.log("Detail Vacancy")
- console.log(this.availableVacancies)
- this.vacancyId = result.vacancyId
- this.title = result.title
- this.position = this.title;
- this.category = result.category
- if (this.title.toUpperCase() == "SATMOB" || this.position.toUpperCase() == "SATMOB") {
- this.simOption = [
- "SIM A",
- "SIM B1"
- ];
- }
- //this.personalInfoDetail.appliedPosition = result.title
- //this.personalInfoDetail.level = result.category
- } else {
- console.log("empty")
- this.router.navigate(['/'])
- }
- }, err => {
- console.log("empty")
- this.router.navigate(['/'])
- }
- );
- }
- }
- createResume() {
- let personalInfoPrint = Object.assign({}, this.personalInfoDetail);
- let data: ResumeData = {
- personalInfo: personalInfoPrint,
- familyList: this.familyList,
- educationList: this.educationList,
- informalEducationList: this.informalEducationList,
- workExperienceList: this.workExperienceList,
- }
- this.docGenerator.createResume(data).then((data) => {
- this.cv = data;
- });
- }
- createCoverLetter() {
- let data: CoverLetterData = {
- position: this.position.toUpperCase(),
- vacancySource: this.personalInfoDetail.jobVacancySource,
- personalInfo: {
- name: this.personalInfoDetail.name,
- sex: this.personalInfoDetail.sex,
- religion: this.personalInfoDetail.religion,
- placeDateOfBirth: this.personalInfoDetail.placeOfBirth + ', ' + this.personalInfoDetail.dateOfBirth,
- nik: this.personalInfoDetail.ktpNo,
- address: this.personalInfoDetail.address,
- phoneNum: this.personalInfoDetail.phoneNumber,
- email: this.personalInfoDetail.email,
- },
- education: {
- lastEducation: this.personalInfoDetail.lastEducation,
- major: this.educationList[0].institution,
- gradYear: this.educationList[0].yearOut,
- },
- }
- this.docGenerator.createCoverLetter(data).then((data) => {
- this.coverLetter = data;
- });
- }
- checkCandidateUploadedFiles() {
- if (!this.candidatesId) return;
- this.services.getCandidateDocumentFile(this.candidatesId).subscribe((res: any[]) => {
- const KTPName = res.find(x => x.fileName.includes('KTP')).fileName;
- this.hasFileName.KTP = KTPName ? KTPName : '';
- const KKName = res.find(x => x.fileName.includes('KK')).fileName;
- this.hasFileName.KK = KKName ? KKName : '';
- const IjazahName = res.find(x => x.fileName.includes('IJAZAH')).fileName
- this.hasFileName.Ijazah = IjazahName ? IjazahName : '';
- const TabunganName = res.find(x => x.fileName.includes('TABUNGAN')).fileName;
- this.hasFileName.Tabungan = TabunganName ? TabunganName : '';
- const SIMName = res.find(x => x.fileName.includes('SIM')).fileName;
- this.hasFileName.SIM = SIMName ? SIMName : '';
- const CVName = res.find(x => x.fileName.includes('CV')).fileName;
- this.hasFileName.CV = CVName ? CVName : '';
- const vaccineName = res.find(x => x.fileName.includes('SERTIFIKAT VAKSIN')).fileName;
- this.hasFileName.Vaccine = vaccineName ? vaccineName : '';
- const STNKName = res.find(x => x.fileName.includes('STNK PAJAK TAHUNAN')).fileName;
- this.hasFileName.STNK = STNKName ? STNKName : '';
- const STNKBackName = res.find(x => x.fileName.includes('STNK PAJAK 5 TAHUNAN')).fileName;
- this.hasFileName.STNKBACK = STNKBackName ? STNKBackName : '';
- })
- }
- checkLoadingState() {
- if (this.loadPersonalData ||
- this.loadDocument ||
- this.loadFamily ||
- this.loadEducation ||
- this.loadInformalEducation ||
- this.loadEmergencyContact ||
- this.loadWorkExperience) {
- console.log("Loading Data")
- } else {
- console.log("Loading Data End")
- this.hideSpinner()
- }
- }
- progressBarValue() {
- return (this.step / 6) * 100
- }
- isSatria() {
- if (this.title.toUpperCase() == "SATRIA"
- || this.position.toUpperCase() == "SATRIA"
- || this.position.toUpperCase() == "COURIER"
- || this.title.toUpperCase() == "SATMOB"
- || this.position.toUpperCase() == "SATMOB") {
- return true
- } else {
- return false
- }
- }
- isPsikotestStart() {
- if (this.url == "/psikotest-start") {
- return true;
- } else {
- return false;
- }
- }
- isEpkwtForm() {
- if (this.url == "/epkwt-form") {
- return true;
- } else {
- return false;
- }
- }
- isSibling(family) {
- if (family.relationship.toLowerCase() == "sibling" || family.relationship.toLowerCase() == "older sibling") {
- return true;
- } else {
- return false;
- }
- }
- isChild(family) {
- if (family.relationship.toLowerCase() == "child") {
- return true;
- } else {
- return false;
- }
- }
- validatePersonalInfoPage() {
- let valid = true
- valid = this.validateEmergencyContact()
- if (this.personalInfoDetail.name == "" || this.personalInfoDetail.name == null) {
- valid = false
- }
- if (this.personalInfoDetail.sex == "" || this.personalInfoDetail.sex == null) {
- valid = false
- }
- if (this.personalInfoDetail.dateOfBirth == null) {
- valid = false
- }
- if (this.personalInfoDetail.placeOfBirth == "" || this.personalInfoDetail.placeOfBirth == null) {
- valid = false
- }
- if (this.personalInfoDetail.religion == "" || this.personalInfoDetail.religion == null) {
- valid = false
- }
- if (this.personalInfoDetail.ktpNo == "" || this.personalInfoDetail.ktpNo == null) {
- valid = false
- }
- if (this.personalInfoDetail.ktpKodePos == "" || this.personalInfoDetail.ktpKodePos == null) {
- valid = false
- }
- if (this.personalInfoDetail.ktpAddress == "" || this.personalInfoDetail.ktpAddress == null) {
- valid = false
- }
- if (this.personalInfoDetail.ktpKecamatan == "" || this.personalInfoDetail.ktpKecamatan == null) {
- valid = false
- }
- if (this.personalInfoDetail.ktpKelurahan == "" || this.personalInfoDetail.ktpKelurahan == null) {
- valid = false
- }
- if (this.personalInfoDetail.ktpRt == "" || this.personalInfoDetail.ktpRt == null) {
- valid = false
- }
- if (this.personalInfoDetail.ktpRw == "" || this.personalInfoDetail.ktpRw == null) {
- valid = false
- }
- if (this.personalInfoDetail.domisiliAddress == "" || this.personalInfoDetail.domisiliAddress == null) {
- valid = false
- }
- if (this.personalInfoDetail.domisiliKodePos == "" || this.personalInfoDetail.domisiliKodePos == null) {
- valid = false
- }
- if (this.personalInfoDetail.domisiliKota == "" || this.personalInfoDetail.domisiliKota == null) {
- valid = false
- }
- if (this.personalInfoDetail.email == "" || this.personalInfoDetail.email == null) {
- valid = false
- }
- if (this.personalInfoDetail.phoneNumber == "" || this.personalInfoDetail.phoneNumber == null) {
- valid = false
- }
- if (!this.validEmail.test(this.personalInfoDetail.email)) {
- valid = false
- }
- if (!this.numberOnly.test(this.personalInfoDetail.ktpNo)) {
- valid = false
- }
- if (!this.validKtp.test(this.personalInfoDetail.ktpNo)) {
- valid = false
- }
- if (this.personalInfoDetail.ktpNo.length != 16) {
- valid = false
- }
- if (this.personalInfoDetail.phoneNumber != null && this.personalInfoDetail.phoneNumber != "") {
- if (!this.validPhone.test(this.personalInfoDetail.phoneNumber)) {
- valid = false
- }
- if (this.personalInfoDetail.phoneNumber.length < 10) {
- valid = false
- }
- }
- if (this.personalInfoDetail.dateOfBirth != null) {
- let umur = moment(this.personalInfoDetail.dateOfBirth).diff(new Date(), "years") * -1;
- console.log("umur :" + umur)
- if (umur >= this.maxAge() || umur < this.minAge()) {
- //console.log(this.maxAge()+"<= umur <"+this.minAge())
- valid = false
- }
- }
- if (this.placementCityValidationMsg() != "") {
- valid = false
- }
- if (this.placementProvinceValidationMsg() != "") {
- valid = false
- }
- if (this.placementCityCode == "" || this.placementCityCode == null) {
- valid = false
- }
- if (this.placementProvinceCode == "" || this.placementProvinceCode == null) {
- valid = false
- }
- if (this.vaccineShow() && this.vaccineRequired()) {
- if (this.personalInfoDetail.vaccineStatus == null) {
- valid = false
- } else {
- if (this.personalInfoDetail.vaccineStatus == 0) {
- if (this.personalInfoDetail.vaccineConsent == null) {
- valid = false
- }
- }
- }
- }
- return valid
- }
- validateFamily() {
- let valid = true
- if (this.familyList.length == 0) {
- valid = true
- } else {
- this.familyList.forEach((val, idx) => {
- if (val.relationship == "" || val.relationship == null) {
- valid = false
- }
- if (val.name == "" || val.name == null) {
- valid = false
- }
- if (val.relationship != "" && val.relationship != null) {
- if (val.relationship == "Wife" || val.relationship == "Child" || val.relationship == "Husband") {
- if (val.dateOfBirth == null) {
- valid = false
- }
- }
- }
- if (val.gender == "" || val.gender == null) {
- valid = false
- }
- if (val.lastEducation == "" || val.lastEducation == null) {
- valid = false
- }
- })
- }
- if (this.personalInfoDetail.kkNo != null) {
- if (this.personalInfoDetail.kkNo.length < 16) {
- valid = false
- }
- }
- if (this.personalInfoDetail.maritalStatus == null || this.personalInfoDetail.maritalStatus == "") {
- valid = false
- }
- return valid
- }
- validateDocument() {
- let valid = true
- if (this.simShow() && this.simRequired()) {
- if (this.documentDetail.simNo == "" || this.documentDetail.simNo == null) {
- valid = false
- }
- if (this.documentDetail.simType == "" || this.documentDetail.simType == null) {
- valid = false
- }
- if (this.documentDetail.simExpiredDate == "" || this.documentDetail.simExpiredDate == null) {
- valid = false
- }
- if (this.documentDetail.simNo != "" && this.documentDetail.simNo != null) {
- if (this.documentDetail.simNo.length < 12 || this.documentDetail.simNo.length > 17) {
- valid = false
- }
- }
- if (this.simExpirationThreshold() != null) {
- if (this.documentDetail.simExpiredDate != "" && this.documentDetail.simExpiredDate != null) {
- if (moment(this.documentDetail.simExpiredDate).diff(new Date(), "months") < this.simExpirationThreshold()) {
- valid = false
- }
- } else {
- valid = false
- }
- }
- }
- if (this.stnkShow() && this.stnkRequired()) {
- if (this.documentDetail.stnkExpiredDate == "" || this.documentDetail.stnkExpiredDate == null) {
- valid = false
- }
- if (this.documentDetail.stnkPlatNoDate == "" || this.documentDetail.stnkPlatNoDate == null) {
- valid = false
- }
- if (this.documentDetail.licensePlate == "" || this.documentDetail.licensePlate == null) {
- valid = false
- }
- if (this.stnkExpirationThreshold() != null) {
- if (this.documentDetail.stnkExpiredDate != "" && this.documentDetail.stnkExpiredDate != null) {
- if (moment(this.documentDetail.stnkExpiredDate).diff(new Date(), "months") < this.stnkExpirationThreshold()) {
- valid = false
- }
- } else {
- valid = false
- }
- if (this.documentDetail.stnkPlatNoDate != "" && this.documentDetail.stnkPlatNoDate != null) {
- if (moment(this.documentDetail.stnkPlatNoDate).diff(new Date(), "months") < this.stnkExpirationThreshold()) {
- valid = false
- }
- } else {
- valid = false
- }
- }
- }
- //if (this.isSatria()) {
- //}
- if (this.selectedOptionBpjs == null || this.selectedOptionJamsostek == null) {
- valid = false
- }
- if (this.selectedOptionBpjs == "YA") {
- if (this.documentDetail.bpjsNo == "" || this.documentDetail.bpjsNo == null) {
- valid = false
- }
- }
- if (this.selectedOptionJamsostek == "YA") {
- if (this.documentDetail.jamsostekNo == "" || this.documentDetail.jamsostekNo == null) {
- valid = false
- }
- }
- if (this.documentDetail.bankAccountName == "" || this.documentDetail.bankAccountName == null) {
- valid = false
- }
- if (this.documentDetail.bankAccountNo == "" || this.documentDetail.bankAccountNo == null) {
- valid = false
- }
- if (this.documentDetail.bankName == "" || this.documentDetail.bankName == null) {
- valid = false
- }
- if (this.documentDetail.bankAccountNo) {
- if (this.documentDetail.bankAccountNo.length < this.bankMinValue()) {
- valid = false
- }
- }
- return valid
- }
- validateSatriaAge(date: Date) {
- return moment().diff(date, "years")
- }
- validateEducation() {
- let valid = true
- if (this.personalInfoDetail.lastEducation == null || this.personalInfoDetail.lastEducation == "") {
- valid = false
- }
- if (this.educationList.length == 0) {
- valid = false
- } else {
- this.educationList.forEach((val, idx) => {
- if (val.institution == "" || val.institution == null) {
- valid = false
- }
- if (val.major == "" || val.major == null) {
- valid = false
- }
- if (val.yearIn == "" || val.yearIn == null) {
- valid = false
- }
- if (val.yearOut == "" || val.yearOut == null) {
- valid = false
- }
- })
- }
- //valid=this.validateLanguageSkill()
- return valid
- }
- validateInformalEducation() {
- let valid = true
- if (this.informalEducationList.length == 0) {
- valid = true
- } else {
- this.informalEducationList.forEach((val, idx) => {
- if (val.trainingName == "" || val.trainingName == null) {
- valid = false
- }
- if (val.trainingDate == "" || val.trainingDate == null) {
- valid = false
- }
- })
- }
- return valid
- }
- validateLanguageSkill() {
- let valid = true
- if (this.languageSkillList.length == 0) {
- valid = true
- } else {
- this.languageSkillList.forEach((val, idx) => {
- if (val.language == "" || val.language == null) {
- valid = false
- }
- if (val.writingSkill == "" || val.writingSkill == null) {
- valid = false
- }
- if (val.readingSkill == "" || val.readingSkill == null) {
- valid = false
- }
- if (val.listeningSkill == "" || val.listeningSkill == null) {
- valid = false
- }
- if (val.conversationalSkill == "" || val.conversationalSkill == null) {
- valid = false
- }
- })
- }
- return valid
- }
- validateWorkExperience() {
- let valid = true
- if (this.workExperienceList.length == 0) {
- valid = true
- } else {
- this.workExperienceList.forEach((val, idx) => {
- if (val.companyName == "" || val.companyName == null) {
- valid = false
- }
- // if (val.yearIn==""||val.yearIn==null){
- // valid=false
- // }
- if (val.position == "" || val.position == null) {
- valid = false
- }
- })
- }
- return valid
- }
- validateEmergencyContact() {
- let valid = true
- if (this.emergencyContactList.length == 0) {
- valid = false
- } else {
- this.emergencyContactList.forEach((val, idx) => {
- if (val.emergencyContactName == "" || val.emergencyContactName == null) {
- valid = false
- }
- if (val.relationship == "" || val.relationship == null) {
- valid = false
- }
- if (val.phoneNumber == "" || val.phoneNumber == null) {
- valid = false
- }
- if (val.phoneNumber != "" && val.phoneNumber != null) {
- if (!this.validPhone.test(val.phoneNumber)) {
- valid = false
- }
- if (val.phoneNumber.length < 10) {
- valid = false
- }
- }
- })
- }
- return valid
- }
- validateBerkas() {
- let valid = true;
- if (!this.ktpStatus && !this.hasFileName.KTP) {
- valid = false
- }
- if (!this.kkStatus && !this.hasFileName.KK) {
- valid = false
- }
- // if (!this.cvStatus && !this.hasFileName.CV) {
- // valid = false
- // }
- if (!this.ijazahStatus && !this.hasFileName.Ijazah) {
- valid = false
- }
- if (!this.tabunganStatus && !this.hasFileName.Tabungan) {
- valid = false
- }
- if (this.personalInfoDetail.vaccineStatus == 2) {
- if (!this.vaccineStatus && !this.hasFileName.Vaccine) {
- valid = false
- }
- }
- if (this.simShow() && this.simRequired()) {
- if (!this.simStatus && !this.hasFileName.SIM) {
- valid = false
- }
- }
- if (this.stnkShow() && this.stnkRequired()) {
- if (!this.stnkStatus && !this.hasFileName.STNK) {
- valid = false
- }
- if (!this.stnkBackStatus && !this.hasFileName.STNKBACK) {
- valid = false
- }
- }
- return valid
- }
- //Vacancies Config
- maxAge(): number {
- let config: AvailableVacanciesConfig = this.availableVacanciesConfig.find(element => element.field == "dateOfBirth" && element.rule == "MAX_AGE")
- if (config == null) {
- return 9999
- }
- return parseInt(config.value)
- }
- minAge(): number {
- let config: AvailableVacanciesConfig = this.availableVacanciesConfig.find(element => element.field == "dateOfBirth" && element.rule == "MIN_AGE")
- if (config == null) {
- return 0
- }
- return parseInt(config.value)
- }
- stnkShow(): boolean {
- let config: AvailableVacanciesConfig = this.availableVacanciesConfig.find(element => element.field == "stnk" && element.rule == "SHOW")
- if (config == null) {
- return false
- }
- return config.value == "1" ? true : false
- }
- simShow(): boolean {
- let config: AvailableVacanciesConfig = this.availableVacanciesConfig.find(element => element.field == "sim" && element.rule == "SHOW")
- if (config == null) {
- return false
- }
- return config.value == "1" ? true : false
- }
- vaccineShow(): boolean {
- let config: AvailableVacanciesConfig = this.availableVacanciesConfig.find(element => element.field == "vaccine" && element.rule == "SHOW")
- if (config == null) {
- return false
- }
- return config.value == "1" ? true : false
- }
- stnkRequired(): boolean {
- let config: AvailableVacanciesConfig = this.availableVacanciesConfig.find(element => element.field == "stnk" && element.rule == "REQUIRED")
- if (config == null) {
- return false
- }
- if (!this.stnkShow()) {
- return false
- }
- return config.value == "1" ? true : false
- }
- simRequired(): boolean {
- let config: AvailableVacanciesConfig = this.availableVacanciesConfig.find(element => element.field == "sim" && element.rule == "REQUIRED")
- if (config == null) {
- return false
- }
- if (!this.simShow()) {
- return false
- }
- return config.value == "1" ? true : false
- }
- vaccineRequired(): boolean {
- let config: AvailableVacanciesConfig = this.availableVacanciesConfig.find(element => element.field == "vaccine" && element.rule == "REQUIRED")
- if (config == null) {
- return false
- }
- if (!this.vaccineShow()) {
- return false
- }
- return config.value == "1" ? true : false
- }
- simType(): string {
- let config: AvailableVacanciesConfig = this.availableVacanciesConfig.find(element => element.field == "simType" && element.rule == "VALUE")
- if (config == null) {
- return ""
- }
- if (!this.simShow()) {
- return ""
- }
- return config.value
- }
- simExpirationThreshold(): number {
- let config: AvailableVacanciesConfig = this.availableVacanciesConfig.find(element => element.field == "sim" && element.rule == "MIN_ACTIVE")
- if (config == null) {
- return null
- }
- if (!this.simShow()) {
- return null
- }
- parseInt(config.value)
- }
- stnkExpirationThreshold(): number {
- let config: AvailableVacanciesConfig = this.availableVacanciesConfig.find(element => element.field == "stnk" && element.rule == "MIN_ACTIVE")
- if (config == null) {
- return null
- }
- if (!this.stnkShow()) {
- return null
- }
- return parseInt(config.value)
- }
- replace(fileName, key) {
- fileName[key] = '';
- }
- bankMinValue() {
- let selectedBank = this.bankDetail.findIndex(elem => elem.bankName == this.documentDetail.bankName)
- if (selectedBank >= 0) {
- return this.bankDetail[selectedBank].minLength
- } else {
- return 4
- }
- }
- bankMaxValue() {
- let selectedBank = this.bankDetail.findIndex(elem => elem.bankName == this.documentDetail.bankName)
- if (selectedBank >= 0) {
- return this.bankDetail[selectedBank].maxLength
- } else {
- return 20
- }
- }
- maritalStatusChange(maritalStatus: string) {
- console.log(maritalStatus)
- this.familyList = this.familyList.filter(el => el.relationship.toUpperCase() != "WIFE" && el.relationship.toUpperCase() != "HUSBAND")
- if (maritalStatus.toUpperCase() == "MENIKAH" && this.personalInfoDetail.sex == "M") {
- let istri = new Family
- istri.relationship = "Wife"
- istri.gender = "F"
- this.familyList.push(istri)
- }
- if (maritalStatus.toUpperCase() == "MENIKAH" && this.personalInfoDetail.sex == "F") {
- let suami = new Family
- suami.gender = "M"
- suami.relationship = "Husband"
- this.familyList.push(suami)
- }
- this.checkPTKP(this.personalInfoDetail.maritalStatus, this.numberOfChild);
- }
- numberOfSiblingChange(nSiblings: number) {
- console.log(nSiblings)
- this.familyList = this.familyList.filter(el => el.relationship.toUpperCase() != "OLDER SIBLING" && el.relationship.toUpperCase() != "SIBLING")
- for (let i = 0; i < nSiblings; i++) {
- let sibling = new Family
- sibling.relationship = "Sibling"
- this.familyList.push(sibling)
- }
- }
- numberOfChildChange(nChilds: number) {
- console.log(nChilds)
- this.familyList = this.familyList.filter(el => el.relationship.toUpperCase() != "CHILD" && el.relationship.toUpperCase() != "FOSTER CHILD")
- for (let i = 0; i < nChilds; i++) {
- let child = new Family
- child.relationship = "Child"
- this.familyList.push(child)
- }
- this.checkPTKP(this.personalInfoDetail.maritalStatus, this.numberOfChild);
- }
- checkPTKP(marriageStatus: string, numChild: number) {
- if (!marriageStatus && !numChild) return;
- let status = '';
- if (marriageStatus.toUpperCase() == 'MENIKAH') status += 'K';
- else status += 'TK';
- if (numChild > 2) status += '3';
- else status += numChild;
- this.personalInfoDetail.ptkp = status;
- }
- checkApplicantIdByNIK() {
- if (this.personalInfoDetail.ktpNo.length >= 16) {
- console.log("hit")
- this.services.findPersonalDataByNik(this.personalInfoDetail.ktpNo).subscribe(
- result => {
- if (!result.data) {
- let obj = {
- candidatesId: result.candidatesId,
- appliedPosition: result.appliedPosition,
- applyingPosition: this.title,
- vacancyId: this.vacancyId
- }
- this.reRegisterDialog(obj);
- console.log(result)
- }
- }, err => {
- if (err != "Data not found") {
- this.openSnackBarV2(err, "close")
- }
- console.log(err)
- }
- )
- }
- }
- reRegisterDialog(obj) {
- let dialogRef = this.dialog.open(this.applyConfirmationDialogComponent, {
- width: '70vw',
- data: obj
- });
- dialogRef.componentInstance.data.subscribe(result => {
- if (result == "yes") {
- this.showSpinner();
- this.services.reRegisterApplicant(obj.candidatesId, obj.vacancyId).subscribe(result => {
- this.hideSpinner()
- this.openSnackBarV2("Registrasi kembali berhasil", "close")
- this.dialog.closeAll()
- }, err => {
- this.hideSpinner()
- this.openSnackBar(err, "close")
- this.dialog.closeAll()
- })
- } else {
- this.dialog.closeAll()
- }
- })
- }
- public handleFileKK(files: FileList) {
- setTimeout(() => {
- if (files[0]) {
- let ext = files[0].name.split('.').pop()
- if (this.allowedFile.includes(ext.toUpperCase())) {
- if ((files[0].size / 1024) > 2000) {
- this.openSnackBar('File berkas tidak boleh lebih dari 2 MB', 'close')
- } else {
- this.kk = files[0];
- this.kkFilename = files[0].name;
- this.kkStatus = true
- }
- } else {
- this.openSnackBar('File harus JPG/PDF', 'close')
- }
- }
- })
- }
- public handleFileKTP(files: FileList) {
- setTimeout(() => {
- if (files[0]) {
- let ext = files[0].name.split('.').pop()
- if (this.allowedFile.includes(ext.toUpperCase())) {
- if ((files[0].size / 1024) > 2000) {
- this.openSnackBar('File berkas tidak boleh lebih dari 2 MB', 'close')
- } else {
- this.ktp = files[0];
- this.ktpFilename = files[0].name;
- this.ktpStatus = true
- }
- } else {
- this.openSnackBar('File harus JPG/PDF', 'close')
- }
- }
- })
- }
- public handleFileIjazah(files: FileList) {
- setTimeout(() => {
- if (files[0]) {
- let ext = files[0].name.split('.').pop()
- if (this.allowedFile.includes(ext.toUpperCase())) {
- if ((files[0].size / 1024) > 2000) {
- this.openSnackBar('File berkas tidak boleh lebih dari 2 MB', 'close')
- } else {
- this.ijazah = files[0];
- this.ijazahFilename = files[0].name
- this.ijazahStatus = true
- }
- } else {
- this.openSnackBar('File harus JPG/PDF', 'close')
- }
- }
- })
- }
- public handleFileCV(files: FileList) {
- setTimeout(() => {
- if (files[0]) {
- let ext = files[0].name.split('.').pop()
- if (this.allowedFile.includes(ext.toUpperCase())) {
- if ((files[0].size / 1024) > 2000) {
- this.openSnackBar('File berkas tidak boleh lebih dari 2 MB', 'close')
- } else {
- this.cv = files[0];
- this.cvFilename = files[0].name;
- this.cvStatus = true
- }
- } else {
- this.openSnackBar('File harus JPG/PDF', 'close')
- }
- }
- })
- }
- public handleFileSIM(files: FileList) {
- setTimeout(() => {
- if (files[0]) {
- let ext = files[0].name.split('.').pop()
- if (this.allowedFile.includes(ext.toUpperCase())) {
- if ((files[0].size / 1024) > 2000) {
- this.openSnackBar('File berkas tidak boleh lebih dari 2 MB', 'close')
- } else {
- this.sim = files[0];
- this.simFilename = files[0].name;
- this.simStatus = true
- }
- } else {
- this.openSnackBar('File harus JPG/PDF', 'close')
- }
- }
- })
- }
- public handleFileSTNK(files: FileList) {
- setTimeout(() => {
- if (files[0]) {
- let ext = files[0].name.split('.').pop()
- if (this.allowedFile.includes(ext.toUpperCase())) {
- if ((files[0].size / 1024) > 2000) {
- this.openSnackBar('File berkas tidak boleh lebih dari 2 MB', 'close')
- } else {
- this.stnk = files[0];
- this.stnkFilename = files[0].name;
- this.stnkStatus = true
- }
- } else {
- this.openSnackBar('File harus JPG/PDF', 'close')
- }
- }
- })
- }
- public handleFileSTNKBack(files: FileList) {
- setTimeout(() => {
- if (files[0]) {
- let ext = files[0].name.split('.').pop()
- if (this.allowedFile.includes(ext.toUpperCase())) {
- if ((files[0].size / 1024) > 2000) {
- this.openSnackBar('File berkas tidak boleh lebih dari 2 MB', 'close')
- } else {
- this.stnkBack = files[0];
- this.stnkBackFilename = files[0].name;
- this.stnkBackStatus = true
- }
- } else {
- this.openSnackBar('File harus JPG/PDF', 'close')
- }
- }
- })
- }
- public handleFileTabungan(files: FileList) {
- setTimeout(() => {
- if (files[0]) {
- let ext = files[0].name.split('.').pop()
- if (this.allowedFile.includes(ext.toUpperCase())) {
- if ((files[0].size / 1024) > 2000) {
- this.openSnackBar('File berkas tidak boleh lebih dari 2 MB', 'close')
- } else {
- this.tabungan = files[0];
- this.tabunganFilename = files[0].name;
- this.tabunganStatus = true
- }
- } else {
- this.openSnackBar('File harus JPG/PDF', 'close')
- }
- }
- })
- }
- public handleFileVaccine(files: FileList) {
- setTimeout(() => {
- if (files[0]) {
- let ext = files[0].name.split('.').pop()
- if (this.allowedFile.includes(ext.toUpperCase())) {
- if ((files[0].size / 1024) > 2000) {
- this.openSnackBar('File berkas tidak boleh lebih dari 2 MB', 'close')
- } else {
- this.vaccine = files[0];
- this.vaccineFilename = files[0].name;
- this.vaccineStatus = true
- }
- } else {
- this.openSnackBar('File harus JPG/PDF', 'close')
- }
- }
- })
- }
- nextStep(stepTo: number) {
- if (this.isPsikotestStart() || this.isEpkwtForm()) {
- if (stepTo == 1) {
- this.submitPersonalInfo(stepTo)
- }
- if (stepTo == 2) {
- this.submitDocumentInfo(stepTo)
- }
- if (stepTo == 3) {
- this.submitFamily(stepTo)
- }
- if (stepTo == 4) {
- this.submitEducation(stepTo)
- }
- if (stepTo == 5) {
- this.submitWorkExperience(stepTo)
- }
- if (stepTo == 6) {
- this.submitAttachment(stepTo)
- }
- } else {
- this.step = stepTo
- this.topPage.nativeElement.scrollIntoView({ behavior: 'smooth' });
- }
- }
- prevStep() {
- this.step--
- this.topPage.nativeElement.scrollIntoView({ behavior: 'smooth' });
- }
- translateFamilyRelation(relation) {
- switch (relation) {
- case 'Father':
- return 'Ayah Kandung'
- break;
- case 'Mother':
- return 'Ibu Kandung'
- break;
- case 'Wife':
- return 'Istri'
- break;
- case 'Husband':
- return 'Suami'
- break;
- case 'Child':
- return 'Anak'
- break;
- }
- }
- familyRelationOption(relation) {
- if (relation == "Father") {
- return true
- } else if (relation == "Mother") {
- return true
- }
- else if (relation == "Sibling") {
- return true
- } else if (relation == "Husband") {
- if (this.personalInfoDetail.maritalStatus == "Menikah" && this.personalInfoDetail.sex == "F") {
- return true
- } else {
- return false
- }
- } else if (relation == "Wife") {
- if (this.personalInfoDetail.maritalStatus == "Menikah" && this.personalInfoDetail.sex == "M") {
- return true
- } else {
- return false
- }
- } else if (relation == "Child") {
- if (this.personalInfoDetail.maritalStatus == "Menikah" || this.personalInfoDetail.maritalStatus == "Janda" || this.personalInfoDetail.maritalStatus == "Duda") {
- return true
- } else {
- return false
- }
- } else if (relation == "Foster Child") {
- if (this.personalInfoDetail.maritalStatus == "Menikah" || this.personalInfoDetail.maritalStatus == "Janda" || this.personalInfoDetail.maritalStatus == "Duda") {
- return true
- } else {
- return false
- }
- } else {
- return false
- }
- }
- familyDeleteFormValidation() {
- if (this.familyList.length == 1) {
- if (this.personalInfoDetail.maritalStatus == "Menikah") {
- return false
- } else {
- return true
- }
- } else {
- return true
- }
- }
- lastFormElement(data: Array<any>, index: number) {
- if (data.length == index + 1) {
- return true
- } else if (data.length < 1) {
- return true
- } else {
- return false
- }
- }
- addNewEmergencyContact() {
- this.emergencyContactList.push(new EmergencyContact)
- }
- deleteEmergencyContact(idx) {
- this.emergencyContactList.splice(idx, 1)
- }
- addNewEducation() {
- this.educationList.push(new Education)
- }
- deleteEducation(idx) {
- this.educationList.splice(idx, 1)
- }
- addNewInformalEducation() {
- this.informalEducationList.push(new InformalEducation)
- }
- deleteInformalEducation(idx) {
- this.informalEducationList.splice(idx, 1)
- }
- addNewLanguageSkill() {
- this.languageSkillList.push(new LanguageSkill)
- }
- deleteLanguageSkill(idx) {
- this.languageSkillList.splice(idx, 1)
- }
- addNewFamily() {
- this.familyList.push(new Family)
- }
- deleteFamily(idx) {
- this.familyList.splice(idx, 1)
- }
- addNewWorkExperience() {
- if (this.workExperienceList.length < 3) {
- this.workExperienceList.push(new WorkExperience)
- } else {
- this.openSnackBar('Maksimal 3 Pengalaman Kerja', 'close');
- }
- }
- deleteWorkExperience(idx) {
- this.workExperienceList.splice(idx, 1)
- }
- getAllData() {
- if (!(this.isPsikotestStart() || this.isEpkwtForm())) {
- this.showSpinner();
- this.loadPersonalData = true
- this.checkLoadingState()
- this.getPersonalDataByNIK().then((res) => {
- this.loadPersonalData = false
- this.loadDocument = true
- this.loadEducation = true
- this.loadFamily = true
- this.loadInformalEducation = true
- this.loadEmergencyContact = true
- this.loadWorkExperience = true
- //this.loadLanguageSkill=true
- this.checkCandidateUploadedFiles();
- this.getDocumentByCandidateId().then((res) => {
- this.loadDocument = false
- this.checkLoadingState()
- }).catch(err => {
- this.loadDocument = false
- this.checkLoadingState()
- })
- this.getFamilyByCandidateId().then((res) => {
- this.loadFamily = false
- this.checkLoadingState()
- }).catch(err => {
- this.loadFamily = false
- this.checkLoadingState()
- })
- this.getEducationByCandidateId().then((res) => {
- this.loadEducation = false
- this.checkLoadingState()
- }).catch(err => {
- this.loadEducation = false
- this.checkLoadingState()
- })
- this.getInformalEducationByCandidateId().then((res) => {
- this.loadInformalEducation = false
- this.checkLoadingState()
- }).catch(err => {
- this.loadInformalEducation = false
- this.checkLoadingState()
- })
- this.getWorkExperienceByCandidateId().then((res) => {
- this.loadWorkExperience = false
- this.checkLoadingState()
- }).catch(err => {
- this.loadWorkExperience = false
- this.checkLoadingState()
- })
- // this.getLanguageByCandidateId().then((res)=>{
- // this.loadLanguageSkill=false
- // this.checkLoadingState()
- // }).catch(err=>{
- // this.loadLanguageSkill=false
- // this.checkLoadingState()
- // })
- this.getEmergencyContactByCandidateId().then((res) => {
- this.loadEmergencyContact = false
- this.checkLoadingState()
- }).catch(err => {
- this.loadEmergencyContact = false
- this.checkLoadingState()
- })
- }).catch(err => {
- console.log(err)
- this.loadPersonalData = false
- this.checkLoadingState()
- })
- }
- }
- getAllDataPsikotest() {
- this.showSpinner();
- this.loadPersonalData = true
- this.checkLoadingState();
- this.getPersonalDataById().then((res) => {
- this.loadPersonalData = false
- this.loadDocument = true
- this.loadEducation = true
- this.loadFamily = true
- this.loadInformalEducation = true
- this.loadEmergencyContact = true
- this.loadWorkExperience = true
- //this.loadLanguageSkill=true
- this.checkCandidateUploadedFiles();
- this.getDocumentByCandidateId().then((res) => {
- this.loadDocument = false
- this.checkLoadingState();
- }).catch(err => {
- this.loadDocument = false
- this.checkLoadingState()
- })
- this.getFamilyByCandidateId().then((res) => {
- this.loadFamily = false
- this.checkLoadingState()
- }).catch(err => {
- this.loadFamily = false
- this.checkLoadingState()
- })
- this.getEducationByCandidateId().then((res) => {
- this.loadEducation = false
- this.checkLoadingState()
- }).catch(err => {
- this.loadEducation = false
- this.checkLoadingState()
- })
- this.getInformalEducationByCandidateId().then((res) => {
- this.loadInformalEducation = false
- this.checkLoadingState()
- }).catch(err => {
- this.loadInformalEducation = false
- this.checkLoadingState()
- })
- this.getWorkExperienceByCandidateId().then((res) => {
- this.loadWorkExperience = false
- this.checkLoadingState()
- }).catch(err => {
- this.loadWorkExperience = false
- this.checkLoadingState()
- })
- this.getEmergencyContactByCandidateId().then((res) => {
- this.loadEmergencyContact = false
- this.checkLoadingState()
- }).catch(err => {
- this.loadEmergencyContact = false
- this.checkLoadingState()
- })
- }).catch(err => {
- console.log(err)
- this.loadPersonalData = false
- this.checkLoadingState()
- })
- }
- getPersonalDataByNIK() {
- return new Promise((resolve, reject) => {
- this.services.findPersonalDataByNik(this.personalInfoDetail.ktpNo).subscribe(
- result => {
- if (!result.data) {
- console.log(result)
- this.candidatesId = result.candidatesId
- delete result.candidatesDocument
- delete result.oneCandidatesDocument
- this.personalInfoDetail = result
- this.position = this.title;
- this.personalInfoDetail.appliedPosition = this.title;
- this.personalInfoDetail.level = this.title;
- this.placementProvince = result.placementProvince != '0' ? result.placementProvince : null;
- this.provinceControl.setValue(this.placementProvince);
- this.placementProvinceCode = result.placementProvinceCode != '0' ? result.placementProvinceCode : null;
- this.placementCity = result.placementCity != '0' ? result.placementCity : null;
- this.cityControl.setValue(this.placementCity);
- this.placementCityCode = result.placementCityCode != '0' ? result.placementCityCode : null;
- if (this.title.toUpperCase() == "SATMOB" || this.position.toUpperCase() == "SATMOB") {
- this.simOption = [
- "SIM A",
- "SIM B1"
- ];
- }
- //delete this.personalInfoDetail.oneCandidate
- console.log("Data candidate")
- console.log(this.personalInfoDetail)
- // this.personalInfoDetail.candidatesId=result.candidatesId
- // this.personalInfoDetail.address=result.address
- // this.personalInfoDetail.dateOfBirth= new Date(result.dateOfBirth)
- // this.personalInfoDetail.email=result.email
- // this.personalInfoDetail.kkNo=result.kkNo
- // this.personalInfoDetail.name=result.name
- // this.personalInfoDetail.placeOfBirth=result.placeOfBirth
- // this.personalInfoDetail.sex=result.sex
- // this.personalInfoDetail.religion=result.religion
- // this.personalInfoDetail.lastEducation=result.lastEducation
- // this.personalInfoDetail.maritalStatus=result.maritalStatus
- // this.personalInfoDetail.phoneNumber=result.phoneNumber
- // this.personalInfoDetail.driverLicenseNumber=result.driverLicenseNumber
- // this.personalInfoDetail.driverLicenseType=result.driverLicenseType
- // this.personalInfoDetail.hobby=result.hobby
- // this.personalInfoDetail.ktpAddress=result.ktpAddress
- // this.personalInfoDetail.ktpKecamatan=result.ktpKecamatan
- // this.personalInfoDetail.ktpKelurahan=result.ktpKelurahan
- // this.personalInfoDetail.ktpKota=result.ktpKota
- // this.personalInfoDetail.ktpKodePos=result.ktpKodePos
- // this.personalInfoDetail.ktpRt=result.ktpRt
- // this.personalInfoDetail.ktpRw=result.ktpRw
- // this.personalInfoDetail.domisiliAddress=result.domisiliAddress
- // this.personalInfoDetail.domisiliKota=result.domisiliKota
- // this.personalInfoDetail.domisiliKodePos=result.domisiliKodePos
- }
- resolve("Done")
- }, err => {
- console.log(err)
- reject("error getting nik")
- }
- )
- })
- }
- getPersonalDataById() {
- return new Promise((resolve, reject) => {
- this.services.findPersonalDataById(this.candidateId).subscribe(
- result => {
- if (!result.data) {
- console.log(result)
- this.candidatesId = result.candidatesId
- this.personalInfoDetail = result;
- this.position = result.appliedPosition;
- this.placementProvince = result.placementProvince != '0' ? result.placementProvince : null;
- this.provinceControl.setValue(this.placementProvince);
- this.placementProvinceCode = result.placementProvinceCode != '0' ? result.placementProvinceCode : null;
- this.placementCity = result.placementCity != '0' ? result.placementCity : null;
- this.cityControl.setValue(this.placementCity);
- this.placementCityCode = result.placementCityCode != '0' ? result.placementCityCode : null;
- if (this.title.toUpperCase() == "SATMOB" || this.position.toUpperCase() == "SATMOB") {
- this.simOption = [
- "SIM A",
- "SIM B1"
- ];
- }
- // console.log(this.personalInfoDetail)
- }
- resolve("Done")
- }, err => {
- console.log(err)
- reject("error getting candidates data")
- }
- )
- })
- }
- getDocumentByCandidateId() {
- return new Promise((resolve, reject) => {
- if (!this.candidatesId) {
- resolve("done")
- }
- this.services.findDocumentByCandidateId(this.candidatesId).subscribe(
- result => {
- if (!result.data) {
- this.documentDetail.candidatesDocumentId = result.candidatesDocumentId
- this.documentDetail.bankAccountName = result.bankAccountName
- this.documentDetail.bankAccountNo = result.bankAccountNo
- this.documentDetail.bankName = result.bankName
- this.documentDetail.bpjsNo = result.bpjsNo
- this.documentDetail.faskes = result.faskes
- this.documentDetail.jamsostekDate = result.jamsostekDate
- this.documentDetail.jamsostekNo = result.jamsostekNo
- this.documentDetail.npwpNo = result.npwpNo
- this.documentDetail.simNo = result.simNo
- this.documentDetail.simType = result.simType
- this.documentDetail.simExpiredDate = result.simExpiredDate
- this.documentDetail.stnkExpiredDate = result.stnkExpiredDate
- this.documentDetail.stnkPlatNoDate = result.stnkPlatNoDate
- this.documentDetail.licensePlate = result.licensePlate
- if (result.bpjsNo != null) {
- this.selectedOptionBpjs = "YA"
- } else {
- this.selectedOptionBpjs = "TIDAK"
- }
- if (result.jamsostekNo != null) {
- this.selectedOptionJamsostek = "YA"
- } else {
- this.selectedOptionJamsostek = "TIDAK"
- }
- }
- resolve("done")
- }, err => {
- console.log(err)
- reject(err)
- }
- )
- })
- }
- getFamilyByCandidateId() {
- return new Promise((resolve, reject) => {
- if (!this.candidatesId) {
- console.log("new data")
- resolve("Done")
- }
- this.services.findFamilyByCandidateId(this.candidatesId).subscribe(
- result => {
- if (!result.data) {
- if (result.length == 0) {
- resolve("Done")
- }
- result.forEach(family => {
- if (this.isChild(family)) {
- this.numberOfChild++;
- } else if (this.isSibling(family)) {
- this.numberOfSibling++;
- }
- });
- this.checkPTKP(this.personalInfoDetail.maritalStatus, this.numberOfChild);
- this.familyList = result
- resolve("Done")
- }
- }, err => {
- console.log(err)
- resolve(err)
- }
- )
- })
- }
- getEducationByCandidateId() {
- return new Promise((resolve, reject) => {
- if (!this.candidatesId) {
- resolve("Done")
- }
- this.services.findEducationByCandidateId(this.candidatesId).subscribe(
- result => {
- if (result.length == 0) {
- resolve("Done")
- }
- if (!result.data) {
- // let dataEducation:Education[]=[]
- // result.forEach(element => {
- // let education = new Education
- // education.candidatesEducationId=element.candidatesEducationId
- // education.institution= element.institution
- // education.major= element.major
- // education.yearIn= element.yearIn
- // education.yearOut= element.yearOut
- // education.grade=element.grade
- // dataEducation.push(education)
- // });
- this.educationList = result
- resolve("Done")
- }
- }, err => {
- console.log(err)
- reject(err)
- }
- )
- })
- }
- getInformalEducationByCandidateId() {
- return new Promise((resolve, reject) => {
- if (!this.candidatesId) {
- resolve("Done")
- }
- this.services.findInformalEducationByCandidateId(this.candidatesId).subscribe(
- result => {
- if (result.length == 0) {
- //this.informalEducationList.push(new InformalEducation)
- resolve("Done")
- } else {
- if (!result.data) {
- // let dataInformalEducation:InformalEducation[]=[]
- // result.forEach(element => {
- // let informalEducation = new InformalEducation
- // informalEducation.candidatesInformalId=element.candidatesInformalId
- // informalEducation.trainingName= element.trainingName
- // informalEducation.trainingDate= element.trainingDate
- // informalEducation.remarks= element.remarks
- // dataInformalEducation.push(informalEducation)
- // });
- this.informalEducationList = result
- resolve("Done")
- }
- }
- }, err => {
- console.log(err)
- //this.informalEducationList.push(new InformalEducation)
- reject(reject)
- }
- )
- })
- }
- getLanguageByCandidateId() {
- return new Promise((resolve, reject) => {
- if (!this.candidatesId) {
- resolve("Done")
- }
- this.services.findLanguageByCandidateId(this.candidatesId).subscribe(
- result => {
- if (result.length == 0) {
- resolve("Done")
- }
- if (!result.data) {
- // let dataLanguage:LanguageSkill[]=[]
- // result.forEach(element => {
- // let language = new LanguageSkill
- // language.candidatesLanguageId=element.candidatesLanguageId
- // language.language= element.language
- // language.conversationalSkill= element.conversationalSkill
- // language.writingSkill= element.writingSkill
- // language.readingSkill= element.readingSkill
- // language.listeningSkill=element.listeningSkill
- // language.remarks=element.remarks
- // dataLanguage.push(language)
- // });
- this.languageSkillList = result
- resolve("Done")
- }
- }, err => {
- console.log(err)
- reject(reject)
- }
- )
- })
- }
- getWorkExperienceByCandidateId() {
- return new Promise((resolve, reject) => {
- if (!this.candidatesId) {
- resolve("Done")
- }
- this.services.findWorkExperienceByCandidateId(this.candidatesId).subscribe(
- result => {
- if (result.length == 0) {
- resolve("Done")
- }
- if (!result.data) {
- // let dataExperience:WorkExperience[]=[]
- // result.forEach(element => {
- // let experience = new WorkExperience
- // experience.candidatesWorkExperienceId=element.candidatesWorkExperienceId
- // experience.companyName= element.companyName
- // experience.position= element.position
- // experience.yearIn= element.yearIn
- // experience.yearOut= element.yearOut
- // experience.achievement=element.achievement
- // dataExperience.push(experience)
- // });
- this.workExperienceList = result
- resolve("Done")
- }
- }, err => {
- console.log(err)
- reject(err)
- }
- )
- })
- }
- getEmergencyContactByCandidateId() {
- return new Promise((resolve, reject) => {
- if (!this.candidatesId) {
- resolve("done")
- }
- this.services.findEmergencyContactByCandidateId(this.candidatesId).subscribe(
- result => {
- console.log(result)
- if (result.length == 0) {
- resolve("done")
- }
- if (!result.data) {
- // let dataEmergencyContact:EmergencyContact[]=[]
- // result.forEach(element => {
- // let emergencyContact = new EmergencyContact
- // emergencyContact.candidatesEmergencyContactId=element.candidatesEmergencyContactId
- // emergencyContact.emergencyContactName= element.emergencyContactName
- // emergencyContact.relationship = element.relationship
- // emergencyContact.phoneNumber= element.phoneNumber
- // dataEmergencyContact.push(emergencyContact)
- // });
- this.emergencyContactList = result
- resolve("done")
- }
- }, err => {
- console.log(err)
- reject("done")
- }
- )
- })
- }
- npwpFormat(nStr: string) {
- if (nStr) {
- if (nStr.length == 15) {
- return nStr.replace(/(\d{2})(\d{3})(\d{3})(\d{1})(\d{3})(\d{3})/, '$1.$2.$3.$4-$5.$6');
- } else {
- return ''
- }
- } else {
- return ''
- }
- }
- changePersonalDoB(event: MatDatepickerInputEvent<Date>) {
- let umur = moment(this.personalInfoDetail.dateOfBirth).diff(new Date(), "years") * -1
- //console.log(moment(new Date()).diff(event.value, "days"))
- if (umur >= this.maxAge()) {
- this.openSnackBar("Maksimum Umur untuk posisi " + this.position + " adalah " + this.maxAge() + " tahun", "close")
- }
- if (umur < this.minAge()) {
- this.openSnackBar("Minimum Umur untuk posisi " + this.position + " adalah " + this.minAge() + " tahun", "close")
- }
- console.log(this.personalInfoDetail.dateOfBirth)
- }
- changeExpiredSim(event: MatDatepickerInputEvent<Date>) {
- console.log(moment(event.value).diff(new Date(), "months"))
- if (this.simExpirationThreshold() != null) {
- if (moment(event.value).diff(new Date(), "months") < this.simExpirationThreshold()) {
- this.openSnackBar("SIM Wajib aktif minimal " + this.simExpirationThreshold() + " bulan sebelum masa berakhir", "close")
- }
- }
- console.log(event.value)
- }
- changeExpiredStnk(event: MatDatepickerInputEvent<Date>) {
- console.log(moment(event.value).diff(new Date(), "months"))
- if (this.stnkExpirationThreshold() != null) {
- if (moment(event.value).diff(new Date(), "months") < this.stnkExpirationThreshold()) {
- this.openSnackBar("STNK Wajib aktif minimal " + this.stnkExpirationThreshold() + " bulan sebelum masa berakhir", "close")
- }
- }
- console.log(event.value)
- }
- // onInputPlacementProvince() {
- // this.filteredProvinceList = this.filteredProvinceList
- // .pipe(map(province => this.filterProvince(province)),
- // )
- // }
- filterProvince(value: string) {
- const filterValue = value.toLowerCase();
- return this.provinceList.filter(option => option.toLowerCase().includes(filterValue));
- }
- filterCity(value: string) {
- const filterValue = value.toLowerCase();
- return this.cityList.filter(option => option.cityName.toLowerCase().includes(filterValue));
- }
- // onInputPlacementCity(value: string) {
- //console.log("input")
- // if (value.length >= 2) {
- // this.services.suggestCity(this.placementProvinceCode, value).subscribe(res => {
- // console.log(res)
- // this.placementCityAuto = res
- // }, err => {
- // this.placementCityAuto = []
- // })
- // }
- // if (value.length < 1) {
- // this.placementCityAuto = []
- // }
- // }
- placementProvinceValidationMsg() {
- if (this.placementProvinceCode == null && this.placementProvince != null) {
- return "Nama Provinsi tidak Valid"
- }
- return ""
- }
- placementCityValidationMsg() {
- if (this.placementCityCode == null) {
- return "Nama Kota tidak Valid"
- }
- return ""
- }
- escapeNonAlphaSpaceName(value: string, page: string, index: number) {
- value = value.trim()
- if (page == 'personal') this.personalInfoDetail.name = value.replace(this.alphaspaceOnly, '')
- if (page == 'family') this.familyList[index].name = value.replace(this.alphaspaceOnly, '')
- if (page == 'ttl') this.personalInfoDetail.placeOfBirth = value.replace(this.alphaspaceOnly, '')
- }
- escapeNonAlphaSpaceNameRek(value: string) {
- value = value.trim()
- this.documentDetail.bankAccountName = value.replace(this.alphaspaceOnly, '')
- }
- unixTimestampToDate(unix) {
- // Create a new JavaScript Date object based on the timestamp
- // multiplied by 1000 so that the argument is in milliseconds, not seconds.
- let dateFormat = new Date(unix);
- // Hours part from the timestamp
- let date = dateFormat.getDate();
- let dateStr = date + ""
- if (date < 10) {
- dateStr = "0" + date
- }
- // Minutes part from the timestamp
- let month = dateFormat.getMonth() + 1;
- let monthStr = month + ""
- if (month < 10) {
- monthStr = "0" + month
- }
- // Seconds part from the timestamp
- let year = dateFormat.getFullYear();
- // Will display time in 10:30:23 format
- let formattedTime = dateStr + '/' + monthStr + '/' + year;
- console.log(formattedTime);
- return formattedTime
- }
- appendAttachment(body: FormData) {
- if (!this.coverLetter) this.createCoverLetter();
- if (!this.cv) this.createResume();
- if (this.ktp) body.append("ktp", this.ktp);
- if (this.kk) body.append("kk", this.kk);
- if (this.ijazah) body.append("ijazah", this.ijazah);
- if (this.cv) body.append("cv", this.cv);
- if (this.tabungan) body.append("tabungan", this.tabungan);
- if (this.sim) {
- body.append("sim", this.sim)
- }
- if (this.stnk) {
- body.append("stnkFront", this.stnk)
- }
- if (this.stnkBack) {
- body.append("stnkBack", this.stnkBack)
- }
- if (this.vaccine) body.append("vaccine", this.vaccine);
- if (this.coverLetter) body.append("coverLetter", this.coverLetter)
- }
- submitApplication() {
- this.showSpinner()
- let body = new FormData()
- let arrayDoc: Document[] = []
- let status = "";
- if (this.personalInfoDetail.vaccineStatus == 1 || this.personalInfoDetail.vaccineStatus == 2) {
- this.personalInfoDetail.vaccineConsent = null
- }
- arrayDoc.push(this.documentDetail)
- this.personalInfoDetail.address = this.personalInfoDetail.domisiliAddress + ' ' + this.personalInfoDetail.domisiliKota
- this.personalInfoDetail.dateOfBirth = moment(this.personalInfoDetail.dateOfBirth).format("YYYY-MM-DD")
- if (this.documentDetail.simExpiredDate != null) this.documentDetail.simExpiredDate = moment(this.documentDetail.simExpiredDate).format("YYYY-MM-DD")
- if (this.documentDetail.stnkExpiredDate != null) this.documentDetail.stnkExpiredDate = moment(this.documentDetail.stnkExpiredDate).format("YYYY-MM-DD")
- if (this.documentDetail.stnkPlatNoDate != null) this.documentDetail.stnkPlatNoDate = moment(this.documentDetail.stnkPlatNoDate).format("YYYY-MM-DD")
- if (this.documentDetail.jamsostekDate != null) this.documentDetail.jamsostekDate = moment(this.documentDetail.jamsostekDate).format("YYYY-MM-DD")
- this.personalInfoDetail.placementCityCode = this.placementCityCode
- this.personalInfoDetail.placementProvinceCode = this.placementProvinceCode
- this.familyList.forEach(family => {
- if (family.dateOfBirth != null) family.dateOfBirth = moment(family.dateOfBirth).format("YYYY-MM-DD")
- });
- if (this.isPsikotestStart()) {
- console.log("psikotest")
- } else {
- this.personalInfoDetail.appliedPosition = this.title
- this.personalInfoDetail.level = this.category
- }
- body.append("candidates", JSON.stringify(this.personalInfoDetail))
- body.append("candidatesFamilies", JSON.stringify(this.familyList))
- //body.append("candidatesLanguages",JSON.stringify(this.languageSkillList))
- body.append("candidatesWorkExperiences", JSON.stringify(this.workExperienceList))
- body.append("candidatesEducations", JSON.stringify(this.educationList[0]))
- body.append("candidatesInformalEducations", JSON.stringify(this.informalEducationList[0]))
- body.append("candidatesEmergencyContacts", JSON.stringify(this.emergencyContactList[0]))
- body.append("candidatesDocument", JSON.stringify(arrayDoc[0]))
- this.appendAttachment(body);
- if (this.isPsikotestStart()) {
- status = "psikotest";
- } else {
- status = "entry";
- }
- body.append("status", status);
- console.log(this.personalInfoDetail)
- console.log(this.emergencyContactList)
- console.log(this.documentDetail)
- console.log(this.familyList)
- console.log(this.workExperienceList)
- console.log(this.educationList)
- console.log(this.informalEducationList)
- this.services.registerApplicant(body).subscribe(result => {
- if (this.isPsikotestStart()) {
- this.services.postPathDone(this.candidateId, null, this.authorization)
- .subscribe(result => {
- this.router.navigate([result.nextPath]);
- setTimeout(() => {
- this.myStepper.next();
- this.hideSpinner()
- }, 500);
- }, error => {
- setTimeout(() => {
- this.hideSpinner();
- console.log(error);
- })
- });
- } else {
- console.log(result)
- this.myStepper.next();
- this.step++
- this.hideSpinner()
- this.openSnackBar("Data Berhasil Dikirim", "close")
- }
- },
- err => {
- console.log('error register', err)
- this.hideSpinner()
- this.openSnackBarV2(err, "close")
- })
- }
- //per step submit
- submitPersonalInfo(stepTo: number) {
- this.showSpinner()
- if (this.personalInfoDetail.vaccineStatus == 1 || this.personalInfoDetail.vaccineStatus == 2) {
- this.personalInfoDetail.vaccineConsent = null
- }
- this.personalInfoDetail.dateOfBirth = moment(this.personalInfoDetail.dateOfBirth).format("YYYY-MM-DD")
- this.personalInfoDetail.address = this.personalInfoDetail.domisiliAddress + ' ' + this.personalInfoDetail.domisiliKota
- this.personalInfoDetail.placementCityCode = this.placementCityCode
- this.personalInfoDetail.placementProvinceCode = this.placementProvinceCode
- let body = {
- candidates: this.personalInfoDetail,
- candidatesEmergencyContact: this.emergencyContactList[0]
- }
- this.services.submitPersonalData(body).subscribe(result => {
- console.log(result.message)
- this.step = stepTo
- this.hideSpinner()
- },
- err => {
- console.log(err)
- this.hideSpinner()
- this.openSnackBarV2(err, "close")
- })
- }
- submitDocumentInfo(stepTo: number) {
- this.showSpinner()
- let body = new FormData()
- if (this.documentDetail.simExpiredDate != null) this.documentDetail.simExpiredDate = moment(this.documentDetail.simExpiredDate).format("YYYY-MM-DD")
- if (this.documentDetail.stnkExpiredDate != null) this.documentDetail.stnkExpiredDate = moment(this.documentDetail.stnkExpiredDate).format("YYYY-MM-DD")
- if (this.documentDetail.stnkPlatNoDate != null) this.documentDetail.stnkPlatNoDate = moment(this.documentDetail.stnkPlatNoDate).format("YYYY-MM-DD")
- if (this.documentDetail.jamsostekDate != null) this.documentDetail.jamsostekDate = moment(this.documentDetail.jamsostekDate).format("YYYY-MM-DD")
- body.append("candidatesId", this.candidateId)
- body.append("candidatesDocument", JSON.stringify(this.documentDetail))
- this.services.submitDocument(body).subscribe(result => {
- console.log(result.message)
- console.log(result)
- this.documentDetail = result.document
- this.step = stepTo
- this.hideSpinner()
- },
- err => {
- console.log(err)
- this.hideSpinner()
- this.openSnackBarV2(err, "close")
- })
- }
- submitFamily(stepTo: number) {
- this.showSpinner()
- let body = new FormData()
- this.familyList.forEach(family => {
- if (family.dateOfBirth != null) family.dateOfBirth = moment(family.dateOfBirth).format("YYYY-MM-DD")
- });
- body.append("candidatesId", this.candidateId)
- body.append("candidatesFamilies", JSON.stringify(this.familyList))
- body.append("kkNo", this.personalInfoDetail.kkNo)
- body.append("maritalStatus", this.personalInfoDetail.maritalStatus)
- this.services.submitFamily(body).subscribe(result => {
- console.log(result.message)
- this.familyList = result.family
- this.step = stepTo
- this.hideSpinner()
- },
- err => {
- console.log(err)
- this.hideSpinner()
- this.openSnackBarV2(err, "close")
- })
- }
- submitEducation(stepTo: number) {
- this.showSpinner()
- let body = new FormData()
- body.append("candidatesId", this.candidateId)
- body.append("candidatesEducations", JSON.stringify(this.educationList[0]))
- body.append("candidatesInformalEducations", JSON.stringify(this.informalEducationList[0]))
- this.services.submitEducation(body).subscribe(result => {
- console.log(result.message)
- console.log(result)
- this.educationList[0] = result.education
- if (result.informalEducation != null) {
- this.informalEducationList[0] = result.informalEducation
- }
- this.step = stepTo
- this.hideSpinner()
- },
- err => {
- console.log(err)
- this.hideSpinner()
- this.openSnackBarV2(err, "close")
- })
- }
- submitWorkExperience(stepTo: number) {
- this.showSpinner()
- let body = new FormData()
- body.append("candidatesId", this.candidateId)
- body.append("candidatesWorkExperiences", JSON.stringify(this.workExperienceList))
- this.services.submitWorkExperience(body).subscribe(result => {
- console.log(result.message)
- console.log(result)
- this.workExperienceList = result.workExperience
- this.step = stepTo
- this.hideSpinner()
- },
- err => {
- console.log(err)
- this.hideSpinner()
- this.openSnackBarV2(err, "close")
- })
- }
- submitAttachment(stepTo: number) {
- this.showSpinner()
- let body = new FormData()
- if (this.candidateId) body.append("candidatesId", this.candidateId);
- if (this.isPsikotestStart()) body.append("source", "psikotest");
- if (this.isEpkwtForm()) body.append("source", "epkwt");
- this.appendAttachment(body);
- this.services.submitAttachment(body).subscribe(result => {
- let obj = JSON.parse(result);
- console.log("next path return " + obj["nextPath"]);
- console.log("next path return " + obj);
- if (this.isPsikotestStart() || this.isEpkwtForm()) {
- this.router.navigate([obj.nextPath]);
- // this.services.postPathDone(this.candidateId, null, this.authorization)
- // .subscribe(result => {
- // this.router.navigate([result.nextPath]);
- // setTimeout(() => {
- // this.hideSpinner()
- // }, 500);
- // }, error => {
- // setTimeout(() => {
- // this.hideSpinner()
- // console.log(error);
- // })
- // });
- } else {
- console.log(result)
- this.step++
- this.hideSpinner()
- this.openSnackBar("Data Berhasil Dikirim", "close")
- }
- },
- err => {
- console.log(err)
- this.hideSpinner()
- this.openSnackBarV2(err, "close")
- })
- }
- sliceFilename(str) {
- if (str) {
- return str.slice(0, 10) + " ... " + str.split('.').pop();
- } else {
- return ""
- }
- }
- checkFile(file: File) {
- if (file) {
- return true
- } else {
- return false
- }
- }
- private openSnackBar(message: string, action: string) {
- this._snackBar.open(message, action, {
- duration: 4000
- });
- }
- private openSnackBarV2(message: string, action: string) {
- this._snackBar.open(message, action);
- }
- showSpinner() {
- this.spinner.show()
- }
- hideSpinner() {
- this.spinner.hide();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement