Skip to content

Commit

Permalink
docs: update service
Browse files Browse the repository at this point in the history
  • Loading branch information
yanmariomenev committed Apr 30, 2024
1 parent 0370432 commit 6af59bf
Showing 1 changed file with 21 additions and 17 deletions.
Expand Up @@ -15,28 +15,36 @@ export class ExcelDataService {
}

public saveTicketData(data: TicketPrices): void {
this.incrementCellValues(1, 11, 3, data.workshopFirstDay);
this.incrementCellValues(1, 12, 3, data.workshopSecondDay);
this.incrementCellValues(1, 13, 3, data.onlineTickets);
this.incrementCellValues(1, 14, 3, data.fullPackage);
this.incrementCellValues(1, 18, 3, data.talksOnly);
const ticketCellLocations = [
{ sheetNumber: 1, rowNumber: 11, cellNumber: 3, value: data.workshopFirstDay },
{ sheetNumber: 1, rowNumber: 12, cellNumber: 3, value: data.workshopSecondDay },
{ sheetNumber: 1, rowNumber: 13, cellNumber: 3, value: data.onlineTickets },
{ sheetNumber: 1, rowNumber: 14, cellNumber: 3, value: data.fullPackage },
{ sheetNumber: 1, rowNumber: 18, cellNumber: 3, value: data.talksOnly }
];

this.updateCellValues(ticketCellLocations);
}

public saveSpeakerData(profileForm: SpeakerProfile): void {
let cellLocation;

switch (profileForm.speakerType) {
case 'Talk - Online':
this.incrementCellValues(0, 14, 3, 1);
cellLocation = { sheetNumber: 0, rowNumber: 14, cellNumber: 3, value: 1 };
break;
case 'Workshop - Online':
this.incrementCellValues(0, 12, 3, 1);
cellLocation = { sheetNumber: 0, rowNumber: 12, cellNumber: 3, value: 1 };
break;
case 'Talk - Live Talk':
this.incrementCellValues(0, 13, 3, 1);
cellLocation = { sheetNumber: 0, rowNumber: 13, cellNumber: 3, value: 1 };
break;
default:
console.log('Invalid Request');
break;
return;
}

this.updateCellValues([cellLocation]);
}

public saveData(data: SheetDescriptor[]): void {
Expand All @@ -47,13 +55,9 @@ export class ExcelDataService {
this.data = [...spreadSheetJsonData];
}

private incrementCellValues(
sheetNumber: number,
rowNumber: number,
cellNumber: number,
incrementValue: number
): void {
this.data[sheetNumber].rows[rowNumber].cells[cellNumber].value +=
incrementValue;
private updateCellValues(cellLocations: { sheetNumber: number, rowNumber: number, cellNumber: number, value: number }[]): void {
cellLocations.forEach(location => {
this.data[location.sheetNumber].rows[location.rowNumber].cells[location.cellNumber].value += location.value;
});
}
}

0 comments on commit 6af59bf

Please sign in to comment.