Skip to content

Commit

Permalink
feat: set the date based on the file
Browse files Browse the repository at this point in the history
  • Loading branch information
cskiwi committed Jan 29, 2024
1 parent ed7b241 commit 27a90b8
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { CommonModule } from '@angular/common';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Inject, inject } from '@angular/core';
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
Inject,
inject,
} from '@angular/core';
import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { RankingSystem } from '@badman/frontend-models';

Expand All @@ -19,6 +25,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatInputModule } from '@angular/material/input';
import { MatSnackBar } from '@angular/material/snack-bar';
import { RANKING_CONFIG } from '../../injection';
import moment from 'moment';

@Component({
selector: 'badman-upload-ranking',
Expand Down Expand Up @@ -98,6 +105,15 @@ export class UploadRankingDialogComponent {
return;
}

// if the filename has 'exportMembersRolePerGroup-' then the part after is the date in DDMMYYYY format set the ranking date to that
if (this.uploadedFile.name.includes('exportMembersRolePerGroup-')) {
const datePart = this.uploadedFile.name.split('exportMembersRolePerGroup-')[1];
const date = moment(datePart, 'DDMMYYYY');
if (date.isValid()) {
this.rankingDate = date.toDate();
}
}

const formData = new FormData();
formData.append('file', this.uploadedFile, this.uploadedFile.name);

Expand Down

0 comments on commit 27a90b8

Please sign in to comment.