Skip to content

Commit

Permalink
Merge pull request #330 from framgia/bugtask/hris-432
Browse files Browse the repository at this point in the history
[HRIS-432] - [Bugtask]  After the user inputted the leave form the “Type of Leave” is not displayed in the modal box of notification
  • Loading branch information
Fontilllas authored Nov 13, 2024
2 parents ce38c75 + 763e826 commit cbd023c
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 6 deletions.
3 changes: 3 additions & 0 deletions api/NotificationDataClasses/LeaveData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public class LeaveData
public string Status { get; set; } = default!;
public string? Remarks { get; set; } = default!;
public bool? IsWithPay { get; set; } = default!;

// Added new type below to satisfy the need of Leave Type for LeaveNotification
public string? LeaveType { get; set; }
}

public class LeaveManagerData : LeaveData
Expand Down
25 changes: 23 additions & 2 deletions api/Services/NotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,20 @@ public async Task<List<LeaveNotification>> createLeaveNotification(Leave leave)
Type = NotificationDataTypeEnum.REQUEST,
Status = _leaveService.GetLeaveRequestStatus(leave),
Remarks = leave.Reason,
// Added new type below to satisfy the need of Leave Type for LeaveNotification
LeaveType = leave.LeaveTypeId switch
{
1 => "Sick Leave",
2 => "Bereavement Leave",
3 => "Emergency Leave",
4 => "Vacation Leave",
5 => "Maternity/Paternity Leave",
6 => "Undertime",
_ => "Unknown Leave Type"
} ?? leave.LeaveTypeId.ToString(), // Fallback if null
IsWithPay = leave.IsWithPay
}
);
});


// Notification to Manager
var notificationToManager = new LeaveNotification
Expand Down Expand Up @@ -97,6 +108,16 @@ public async Task<List<LeaveNotification>> createLeaveNotification(Leave leave)
DateFiled = (DateTime)leave.CreatedAt,
Type = NotificationDataTypeEnum.REQUEST,
Status = _leaveService.GetLeaveRequestStatus(leave),
LeaveType = leave.LeaveTypeId switch
{
1 => "Sick Leave",
2 => "Bereavement Leave",
3 => "Emergency Leave",
4 => "Vacation Leave",
5 => "Maternity/Paternity Leave",
6 => "Undertime",
_ => "Unknown Leave Type"
} ?? leave.LeaveTypeId.ToString(), // Fallback if null
Remarks = leave.Reason,
IsWithPay = leave.IsWithPay
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ type Props = {
}

const LeaveDetails: FC<Props> = ({ notification }): JSX.Element => {
const { project, date, duration, dateFiled, status, remarks } = notification
const { project, date, duration, dateFiled, status, remarks, leaveType } = notification

return (
<>
<li className="inline-flex items-center space-x-3">
<span className="text-slate-600">Project: </span>
<span className="flex items-center font-medium">{project}</span>
</li>
<li className="inline-flex items-center space-x-3">
<span className="text-slate-600">Type of Leave: </span>
<span className="flex items-center font-medium">{leaveType}</span>
</li>
<li className="inline-flex items-center space-x-3 pt-2">
<span className="text-slate-600">Date: </span>
<span className="flex items-center font-medium">{date}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ type Props = {
}

const LeaveResolvedDetails: FC<Props> = ({ notification }): JSX.Element => {
const { project, date, duration, dateFiled, status, remarks } = notification
const { project, date, duration, dateFiled, status, remarks, leaveType } = notification

return (
<>
<li className="inline-flex items-center space-x-3">
<span className="text-slate-600">Project: </span>
<span className="flex items-center font-medium">{project}</span>
</li>
<li className="inline-flex items-center space-x-3">
<span className="text-slate-600">Type of Leave: </span>
<span className="flex items-center font-medium">{leaveType}</span>
</li>
<li className="inline-flex items-center space-x-3 pt-2">
<span className="text-slate-600">Date: </span>
<span className="flex items-center font-medium">{date}</span>
Expand Down
6 changes: 4 additions & 2 deletions client/src/pages/notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ const Notifications: NextPage = (): JSX.Element => {
if (notificationsData != null && !notificationLoading) {
const mappedNotifications = notificationsData.notificationByRecipientId.map((notif) => {
const parsedData: NotificationData = JSON.parse(notif.data)
const notificationType: string = notif.type.charAt(0).toUpperCase() + notif.type.slice(1)
const mapped: INotification = {
id: notif.id,
name: parsedData.User.Name,
project: parsedData?.Projects?.join(', '),
type: notif.type.charAt(0).toUpperCase() + notif.type.slice(1),
type: notificationType,
specificType: parsedData.Type,
date: moment(parsedData.DateRequested).format('MMMM D, YYYY'),
remarks: parsedData.Remarks,
Expand All @@ -75,7 +76,8 @@ const Notifications: NextPage = (): JSX.Element => {
offsets: parsedData.Offsets,
managerRemarks: parsedData.ManagerRemarks,
startDate: parsedData.StartDate,
endDate: parsedData.EndDate
endDate: parsedData.EndDate,
leaveType: notificationType === 'Leave' ? parsedData.LeaveType : null
}
return mapped
})
Expand Down
1 change: 1 addition & 0 deletions client/src/utils/interfaces/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface INotification {
managerRemarks: string | null
startDate: string
endDate: string
leaveType?: string | null
}

export interface IEmployeeManagement {
Expand Down
1 change: 1 addition & 0 deletions client/src/utils/types/notificationTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type NotificationData = {
ManagerRemarks: string | null
StartDate: string
EndDate: string
LeaveType: string | null
}

export type NotificationRequestInput = {
Expand Down

0 comments on commit cbd023c

Please sign in to comment.