Skip to content

Commit 0fec09a

Browse files
authored
Merge pull request #67 from DevCom-IITB/develop
Fixed Dashboard Rebate not Appearing Issue and added total number of rebatedays taken
2 parents 237eef6 + 0906c75 commit 0fec09a

File tree

9 files changed

+111
-4
lines changed

9 files changed

+111
-4
lines changed

src/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<img class="mess-i-logo" src="assets/mess-i-logo.png"> <!-- isme issues hai -->
99
<a id="nav_home" class="nav-link nav-items-style" *ngIf="auth.isStaff()" routerLink="/home" >HOME</a>
1010
<a id="nav_student_list" class="nav-link nav-items-style" *ngIf="auth.isStaff()" routerLink="/list">STUDENTS' LIST</a>
11-
<a id="nav_rebate" class="nav-link nav-items-style" role="button" *ngIf="isStudent" routerLink="/rebate">REBATES</a>
11+
<a id="nav_rebate" class="nav-link nav-items-style" role="button" *ngIf="auth.isStudent()" routerLink="/rebate">REBATES</a>
1212
<a id="nav_rebate_admin" class="nav-link nav-items-style" *ngIf="auth.isRebate()" routerLink="/rebate-admin" >REBATES ADMIN</a>
1313
<a id="nav_guest_admin" class="nav-link nav-items-style" *ngIf="auth.isStaff()" routerLink="/guest-admin">GUEST ADMIN</a>
1414
<a id="nav_overview" class="nav-link nav-items-style" *ngIf="auth.isStaff()" routerLink="/overview" >MESS STATS</a>

src/app/app.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export class AppComponent {
3333
this.navIdtoUrl.set("nav_guest_admin","/guest-admin")
3434
// this.navIdtoUrl.set("nav_mess_bill","/mess-bill")
3535
this.isStudent = this.auth.isStudent();
36+
//console.log("is student: ",this.isStudent);
3637
}
3738

3839
showNavbar() {

src/app/rebate-admin/rebate-admin.component.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
background-color: rgba(255, 196, 75, 0.1);
4040
}
4141
.no-rebates-message {
42-
color: #ffffff;
42+
color: #28272c;
4343
}
4444

4545
@media screen and (max-width: 431px){
@@ -217,6 +217,7 @@
217217
background-color: #ffc24b !important;
218218
}
219219
.no-rebates-message {
220+
color: #ffffff !important;
220221
margin: 10px 0;
221222
padding-top: 2vw;
222223
padding-bottom: 2vw;

src/app/rebate/pd-rebate-card/pd-rebate-card.component.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,27 @@
183183
*{
184184
font-family: 'Open Sans', sans-serif;
185185
}
186+
187+
.rebate-taken-days {
188+
margin: 12px 0px;
189+
position: relative;
190+
bottom: 10px;
191+
}
192+
193+
.total-rebate-info {
194+
display: flex;
195+
justify-content: space-between;
196+
align-items: center;
197+
}
198+
199+
.total-rebate-info .label {
200+
font-weight: 600;
201+
color: #28272c;
202+
font-size: 16px;
203+
}
204+
205+
.total-rebate-info .total-days {
206+
font-weight: 600;
207+
color: #28272c;
208+
font-size: 16px;
209+
}

src/app/rebate/pd-rebate-card/pd-rebate-card.component.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
<div id="days">
2222
<span id="noofdays">{{ p_rebate_days }} days </span><span id="nobold">(both inclusive)</span>
2323
</div>
24+
<div class="rebate-taken-days">
25+
<div class="total-rebate-info">
26+
<span class="label">Total Rebate Days Taken:</span>
27+
<span class="total-days">{{p_total_rebate_days}} days</span>
28+
</div>
29+
</div>
2430
<div id="rebate-reason-container" class="row">
2531
<p id="reason">{{ p_rebate_reason }}</p>
2632
<button id="official" *ngIf="rebate_request.official" (click)="downloadRebateDoc()">

src/app/rebate/pd-rebate-card/pd-rebate-card.component.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class PdRebateCardComponent implements OnInit {
2626
public card_comment: string;
2727
public rebate_status: string;
2828
private numToMonth: string[] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
29-
29+
public p_total_rebate_days: string = "0";
3030
constructor(
3131
private data_service: StudentdataService,
3232
private dialog: MatDialog,
@@ -43,6 +43,7 @@ export class PdRebateCardComponent implements OnInit {
4343
this.p_rebate_reason = this.rebate_request.reason;
4444
this.card_comment="";
4545
this.p_rebate_days= this.noOfDays(this.rebate_request.start, this.rebate_request.end);
46+
this.calculateTotalRebateDays();
4647
}
4748

4849
acceptRebate(){
@@ -91,7 +92,7 @@ export class PdRebateCardComponent implements OnInit {
9192
}
9293

9394
isAdmin(): boolean {
94-
return !this.auth.isStudent();
95+
return this.auth.isRebate();
9596
}
9697

9798
updateRebateData() {
@@ -165,4 +166,21 @@ export class PdRebateCardComponent implements OnInit {
165166
return "0";
166167
}
167168
}
169+
170+
private async calculateTotalRebateDays(): Promise<void> {
171+
try {
172+
const res: any = await this.data_service.getAdminRebatesRoll(this.rebate_request.roll);
173+
const acceptedRebates = res.accepted_rebate || [];
174+
175+
let totalDays = 0;
176+
acceptedRebates.forEach((rebate: any) => {
177+
totalDays += parseInt(this.noOfDays(rebate.start, rebate.end));
178+
});
179+
180+
this.p_total_rebate_days = totalDays.toString();
181+
} catch (error) {
182+
console.error('Error calculating total rebate days:', error);
183+
this.p_total_rebate_days = "0";
184+
}
185+
}
168186
}

src/app/rebate/stu-reb-card/stu-reb-card.component.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,33 @@ p{
231231
.rebate-card-container{
232232
min-width: 80vw;
233233
}
234+
.total-rebate-info .label {
235+
font-size: 4vw;
236+
}
237+
238+
.total-rebate-info .total-days {
239+
font-size: 4vw;
240+
}
241+
}
242+
243+
.rebate-taken-days {
244+
margin-bottom: 12px;
245+
}
246+
247+
.total-rebate-info {
248+
display: flex;
249+
justify-content: space-between;
250+
align-items: center;
251+
}
252+
253+
.total-rebate-info .label {
254+
font-weight: 600;
255+
color: #28272c;
256+
font-size: 16px;
257+
}
258+
259+
.total-rebate-info .total-days {
260+
font-weight: 600;
261+
color: #28272c;
262+
font-size: 16px;
234263
}

src/app/rebate/stu-reb-card/stu-reb-card.component.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
<div id="days">
3636
<span id="noOfDays">{{ p_rebate_days }} days </span><span id="both-inclusive">(Both inclusive)</span>
3737
</div>
38+
<div class="rebate-taken-days" *ngIf="on_admin_page">
39+
<div class="total-rebate-info">
40+
<span class="label">Total Rebate Days Taken:</span>
41+
<span class="total-days">{{p_total_rebate_days}} days</span>
42+
</div>
43+
</div>
44+
3845
<div class="row">
3946
<p id="reason-txt" *ngIf="!isStudentPage()">{{ p_rebate_reason }}</p>
4047
<p id="reason-txt" *ngIf="isStudentPage()" style="font-size: 18px;">{{ p_rebate_reason }}</p>

src/app/rebate/stu-reb-card/stu-reb-card.component.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class StuRebCardComponent implements OnInit {
2323
public p_rebate_reason: string;
2424
public p_rebate_comment: string;
2525
private numToMonth: string[] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
26+
public p_total_rebate_days: string = "0";
2627
@Input() public rebate_request: RebateRequest;
2728
// @Input() public isApproved: boolean = false;
2829
public on_admin_page:boolean ;
@@ -55,6 +56,9 @@ export class StuRebCardComponent implements OnInit {
5556
is_student_page: this.isStudentPage(),
5657
current_url: this.router.url
5758
});
59+
if (this.on_admin_page) {
60+
this.calculateTotalRebateDays();
61+
}
5862
}
5963

6064
readableDate(inp: Date): string{
@@ -186,5 +190,22 @@ export class StuRebCardComponent implements OnInit {
186190
return true; // Default to showing buttons if there's an error
187191
}
188192
}
193+
private async calculateTotalRebateDays(): Promise<void> {
194+
try {
195+
const res: any = await this.data_service.getAdminRebatesRoll(this.rebate_request.roll);
196+
const acceptedRebates = res.accepted_rebate || [];
197+
198+
let totalDays = 0;
199+
acceptedRebates.forEach((rebate: any) => {
200+
totalDays += parseInt(this.noOfDays(rebate.start, rebate.end));
201+
});
202+
203+
this.p_total_rebate_days = totalDays.toString();
204+
} catch (error) {
205+
console.error('Error calculating total rebate days:', error);
206+
this.p_total_rebate_days = "0";
207+
}
208+
}
209+
189210
}
190211

0 commit comments

Comments
 (0)