fix: schedule pages — real API data, role display, time formatting

- Rewrite StaffSchedule.razor from hardcoded stub to real API integration
  (profile → shop schedules → filter by staffId)
- Fix admin ShopSchedule role column: use staff role from merchant data
  instead of showing "—"
- Add FormatTime() helper to strip seconds from time display (08:00:00 → 08:00)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ho Ngoc Hai
2026-03-13 17:06:40 +07:00
parent deffb9de4a
commit fffedea785
2 changed files with 137 additions and 47 deletions

View File

@@ -82,10 +82,10 @@
var schedStaffName = schedStaff != null && (!string.IsNullOrWhiteSpace(schedStaff.LastName) || !string.IsNullOrWhiteSpace(schedStaff.FirstName)) ? $"{schedStaff.LastName} {schedStaff.FirstName}".Trim() : (s.EmployeeCode ?? s.StaffId.ToString()[..8]);
<tr style="border-top:1px solid var(--admin-border-subtle);">
<td style="padding:12px 16px;font-weight:600;">@schedStaffName</td>
<td style="padding:12px 16px;font-size:13px;color:var(--admin-text-tertiary);">@(s.Role ?? "—")</td>
<td style="padding:12px 16px;font-size:13px;color:var(--admin-text-tertiary);">@(schedStaff?.Role ?? s.Role ?? "—")</td>
<td style="padding:12px 16px;text-align:center;font-weight:600;color:var(--admin-orange-primary);">@ShopHelpers.DayLabel(s.DayOfWeek)</td>
<td style="padding:12px 16px;text-align:center;">@s.StartTime</td>
<td style="padding:12px 16px;text-align:center;">@s.EndTime</td>
<td style="padding:12px 16px;text-align:center;">@FormatTime(s.StartTime)</td>
<td style="padding:12px 16px;text-align:center;">@FormatTime(s.EndTime)</td>
<td style="padding:12px 16px;text-align:center;"><button @onclick='() => DeleteScheduleItem(s.Id)' style="background:rgba(239,68,68,0.1);border:none;border-radius:6px;width:28px;height:28px;display:flex;align-items:center;justify-content:center;cursor:pointer;"><i data-lucide="trash-2" style="color:#EF4444;width:14px;height:14px;"></i></button></td>
</tr>
}
@@ -278,4 +278,15 @@ else if (SubSection == "shifts")
}
catch (Exception ex) { Console.Error.WriteLine($"Không thể xóa lịch làm việc: {ex.Message}"); }
}
/// <summary>
/// EN: Format time string — remove seconds if present (08:00:00 → 08:00).
/// VI: Định dạng giờ — bỏ giây nếu có (08:00:00 → 08:00).
/// </summary>
private static string FormatTime(string? time)
{
if (string.IsNullOrEmpty(time)) return "—";
var parts = time.Split(':');
return parts.Length >= 2 ? $"{parts[0]}:{parts[1]}" : time;
}
}