Skip to content

Commit 7f401c3

Browse files
committed
fix download cv in profile
1 parent 1cc675f commit 7f401c3

5 files changed

Lines changed: 27 additions & 32 deletions

File tree

projects/social_platform/src/app/auth/services/auth.service.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,8 @@ export class AuthService {
7676
.pipe(map(json => plainToInstance(RegisterResponse, json)));
7777
}
7878

79-
/**
80-
* Отправить резюме по email
81-
* @returns Observable завершения операции
82-
*/
83-
sendCV(): Observable<any> {
84-
return this.apiService.get(`${this.AUTH_USERS_URL}/send_mail_cv/`);
79+
downloadCV() {
80+
return this.apiService.getFile(`${this.AUTH_USERS_URL}/download_cv/`);
8581
}
8682

8783
/** Поток данных профиля пользователя */

projects/social_platform/src/app/office/features/detail/detail.component.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -545,10 +545,9 @@ <h3 class="text-body-14 cancel__title" style="flex-wrap: wrap; width: 90%">
545545

546546
@if (+profile.id === +info().id) {
547547
<app-button
548-
(click)="sendCVEmail()"
548+
(click)="downloadCV()"
549549
size="medium"
550-
style="opacity: 0, 5"
551-
[disabled]="true"
550+
[loader]="isSended"
552551
appearance="outline"
553552
customTypographyClass="text-body-12"
554553
>cкачать CV</app-button
@@ -645,18 +644,19 @@ <h3 class="text-body-12 lists__title">подтвердить владение н
645644
<i
646645
(click)="isDelayModalOpen = false"
647646
appIcon
647+
appSquare="8"
648648
icon="cross"
649649
class="cancel__cross"
650650
></i>
651651
<p class="cancel__title text-bold-body-16">Повторите загрузку позже</p>
652652
</div>
653653
<p class="text-body-14 cancel__text">
654-
Скачивание будет доступно через {{ errorMessageModal() }} секунд.
654+
Скачивание будет доступно через несколько секунд.
655655
</p>
656656
</div>
657657
</app-modal>
658658

659-
<app-modal [open]="isSended" (openChange)="isSended = !isSended">
659+
<!-- <app-modal [open]="isSended" (openChange)="isSended = !isSended">
660660
<div class="cancel">
661661
<div class="cancel__top">
662662
<i
@@ -673,7 +673,7 @@ <h3 class="text-body-12 lists__title">подтвердить владение н
673673
Технические сложности? Мы всегда на связи в Telegram — {{ "@procollab_support" }}
674674
</p>
675675
</div>
676-
</app-modal>
676+
</app-modal> -->
677677
</ng-template>
678678

679679
<router-outlet></router-outlet>

projects/social_platform/src/app/office/features/detail/detail.component.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import { CommonModule, Location } from "@angular/common";
44
import { ChangeDetectorRef, Component, inject, OnDestroy, OnInit, signal } from "@angular/core";
5-
import { ButtonComponent, InputComponent } from "@ui/components";
6-
import { BackComponent, IconComponent } from "@uilib";
5+
import { ButtonComponent } from "@ui/components";
6+
import { IconComponent } from "@uilib";
77
import { ModalComponent } from "@ui/components/modal/modal.component";
88
import { ActivatedRoute, Router, RouterModule } from "@angular/router";
99
import { AuthService } from "@auth/services";
@@ -23,15 +23,13 @@ import { ProfileDataService } from "@office/profile/detail/services/profile-date
2323
import { ProfileService } from "projects/skills/src/app/profile/services/profile.service";
2424
import { SnackbarService } from "@ui/services/snackbar.service";
2525
import { ApproveSkillComponent } from "../approve-skill/approve-skill.component";
26-
import { ProjectsService } from "@office/projects/services/projects.service";
27-
import { TruncatePipe } from "projects/core/src/lib/pipes/truncate.pipe";
2826
import { ProgramService } from "@office/program/services/program.service";
2927
import { ProjectFormService } from "@office/projects/edit/services/project-form.service";
3028
import {
3129
PartnerProgramFields,
3230
projectNewAdditionalProgramVields,
3331
} from "@office/models/partner-program-fields.model";
34-
import { HttpRequest, HttpResponse } from "@angular/common/http";
32+
import { saveFile } from "@utils/helpers/export-file";
3533

3634
@Component({
3735
selector: "app-detail",
@@ -42,13 +40,10 @@ import { HttpRequest, HttpResponse } from "@angular/common/http";
4240
RouterModule,
4341
IconComponent,
4442
ButtonComponent,
45-
BackComponent,
4643
ModalComponent,
4744
AvatarComponent,
4845
TooltipComponent,
49-
InputComponent,
5046
ApproveSkillComponent,
51-
TruncatePipe,
5247
],
5348
standalone: true,
5449
})
@@ -64,7 +59,6 @@ export class DeatilComponent implements OnInit, OnDestroy {
6459
private readonly location = inject(Location);
6560
private readonly profileDataService = inject(ProfileDataService);
6661
public readonly skillsProfileService = inject(ProfileService);
67-
private readonly projectsService = inject(ProjectsService);
6862
public readonly chatService = inject(ChatService);
6963
private readonly cdRef = inject(ChangeDetectorRef);
7064
private readonly programService = inject(ProgramService);
@@ -388,15 +382,17 @@ export class DeatilComponent implements OnInit, OnDestroy {
388382
* Отправка CV пользователя на email
389383
* Проверяет ограничения по времени и отправляет CV на почту пользователя
390384
*/
391-
sendCVEmail() {
392-
this.authService.sendCV().subscribe({
393-
next: () => {
394-
this.isSended = true;
385+
downloadCV() {
386+
this.isSended = true;
387+
this.authService.downloadCV().subscribe({
388+
next: blob => {
389+
saveFile(blob, "cv", this.profile?.firstName + " " + this.profile?.lastName);
390+
this.isSended = false;
395391
},
396392
error: err => {
393+
this.isSended = false;
397394
if (err.status === 400) {
398395
this.isDelayModalOpen = true;
399-
this.errorMessageModal.set(err.error.seconds_after_retry);
400396
}
401397
},
402398
});

projects/social_platform/src/app/office/program/detail/list/list.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ export class ProgramListComponent implements OnInit, OnDestroy, AfterViewInit {
506506

507507
this.exportFileService.exportAllProjects(programId).subscribe({
508508
next: blob => {
509-
saveFile(this.programDataService.getProgramName(), blob, "all");
509+
saveFile(blob, "all", this.programDataService.getProgramName());
510510
this.loadingExportProjects.set(false);
511511
},
512512
error: err => {
@@ -522,7 +522,7 @@ export class ProgramListComponent implements OnInit, OnDestroy, AfterViewInit {
522522

523523
this.exportFileService.exportSubmittedProjects(programId).subscribe({
524524
next: blob => {
525-
saveFile(this.programDataService.getProgramName(), blob, "submitted");
525+
saveFile(blob, "submitted", this.programDataService.getProgramName());
526526
this.loadingExportSubmittedProjects.set(false);
527527
},
528528
error: () => {
@@ -537,7 +537,7 @@ export class ProgramListComponent implements OnInit, OnDestroy, AfterViewInit {
537537

538538
this.exportFileService.exportProgramRates(programId).subscribe({
539539
next: blob => {
540-
saveFile(this.programDataService.getProgramName(), blob, "rates");
540+
saveFile(blob, "rates", this.programDataService.getProgramName());
541541
this.loadingExportRates.set(false);
542542
},
543543
error: () => {

projects/social_platform/src/app/utils/helpers/export-file.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88
import { saveAs } from "file-saver";
99

1010
export const saveFile = (
11-
programName: string,
1211
blob: Blob,
13-
type: "all" | "submitted" | "rates"
12+
type: "all" | "submitted" | "rates" | "cv",
13+
name?: string
1414
): void => {
1515
const prefixFileName =
1616
type === "all" ? "projects" : type === "rates" ? "scores" : "projects_review";
1717
const todayDate = new Date().toLocaleDateString("ru-RU");
18-
const fullName = prefixFileName + "-" + programName + "-" + todayDate + ".xlsx";
18+
const fullName =
19+
(type !== "cv" ? prefixFileName + "-" : "") +
20+
name +
21+
(type !== "cv" ? "-" + todayDate + ".xlsx" : ".pdf");
1922
saveAs(blob, fullName);
2023
};

0 commit comments

Comments
 (0)