From 5f8e7281e677cba867efd6c3a38757be0a58779b Mon Sep 17 00:00:00 2001 From: bcgov-brwang Date: Mon, 26 Aug 2024 08:50:41 -0700 Subject: [PATCH 01/11] 2.0.6: fix of TH-120363 --- Server/SchoolBusAPI/Services/CurrentUserService.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Server/SchoolBusAPI/Services/CurrentUserService.cs b/Server/SchoolBusAPI/Services/CurrentUserService.cs index 08a8031d..9994728c 100644 --- a/Server/SchoolBusAPI/Services/CurrentUserService.cs +++ b/Server/SchoolBusAPI/Services/CurrentUserService.cs @@ -255,6 +255,8 @@ public virtual IActionResult UsersCurrentGetAsync() DateTime today = DateUtils.ConvertPacificToUtcTime( new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0)); + // TH-120363 + today = DateTime.SpecifyKind(today, DateTimeKind.Unspecified); DateTime utcDateTo = today.AddDays(31).AddSeconds(-1); DateTime dateTo = DateTime.SpecifyKind(utcDateTo, DateTimeKind.Unspecified); From bd53fc944d0c55a622a3217cb9aa2faf1ed7fe56 Mon Sep 17 00:00:00 2001 From: bcgov-brwang Date: Tue, 27 Aug 2024 11:13:02 -0700 Subject: [PATCH 02/11] TH-120363: fix of search pop up error --- Server/SchoolBusAPI/Services/SchoolBusService.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Server/SchoolBusAPI/Services/SchoolBusService.cs b/Server/SchoolBusAPI/Services/SchoolBusService.cs index cb6b04d0..38fc61f5 100644 --- a/Server/SchoolBusAPI/Services/SchoolBusService.cs +++ b/Server/SchoolBusAPI/Services/SchoolBusService.cs @@ -964,6 +964,8 @@ public IActionResult SchoolbusesSearchGetAsync(int?[] districts, int?[] inspecto { var dateFrom = DateUtils.ConvertPacificToUtcTime( new DateTime(sDate.Year, sDate.Month, sDate.Day, 0, 0, 0)); + // TH-120363 + dateFrom = DateTime.SpecifyKind(dateFrom, DateTimeKind.Unspecified); data = data.Where(x => x.NextInspectionDate >= dateFrom); } @@ -974,6 +976,8 @@ public IActionResult SchoolbusesSearchGetAsync(int?[] districts, int?[] inspecto new DateTime(eDate.Year, eDate.Month, eDate.Day, 0, 0, 0)) .AddDays(1) .AddSeconds(-1); + // TH-120363 + dateTo = DateTime.SpecifyKind(dateTo, DateTimeKind.Unspecified); data = data.Where(x => x.NextInspectionDate <= dateTo); } From d1a4acb6f4a327f3fb50c28e2f420ade47e8e972 Mon Sep 17 00:00:00 2001 From: Wang Date: Wed, 18 Sep 2024 12:57:50 -0700 Subject: [PATCH 03/11] TH-121015: fix for user roles adding failure and ccwdata fetching error --- Server/SchoolBusAPI/Services/CCWDataService.cs | 13 +++++++++++++ Server/SchoolBusAPI/Services/UserService.cs | 15 ++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Server/SchoolBusAPI/Services/CCWDataService.cs b/Server/SchoolBusAPI/Services/CCWDataService.cs index aec55204..57c45b75 100644 --- a/Server/SchoolBusAPI/Services/CCWDataService.cs +++ b/Server/SchoolBusAPI/Services/CCWDataService.cs @@ -325,6 +325,19 @@ public CCWData GetCCW(string regi, string plate, string vin, string userId, stri } } + // TH-121015 + DateTime dateFetched = DateTime.SpecifyKind(ccwdata.DateFetched.GetValueOrDefault(), DateTimeKind.Unspecified); + DateTime icbcVipExpiry = DateTime.SpecifyKind(ccwdata.ICBCCVIPExpiry.GetValueOrDefault(), DateTimeKind.Unspecified); + DateTime nscPolicyEffectiveDate = DateTime.SpecifyKind(ccwdata.NSCPolicyEffectiveDate.GetValueOrDefault(), DateTimeKind.Unspecified); + DateTime nscPolicyExpiryDate = DateTime.SpecifyKind(ccwdata.NSCPolicyExpiryDate.GetValueOrDefault(), DateTimeKind.Unspecified); + DateTime nscPolicyStatusDate = DateTime.SpecifyKind(ccwdata.NSCPolicyStatusDate.GetValueOrDefault(), DateTimeKind.Unspecified); + ccwdata.DateFetched = dateFetched; + ccwdata.ICBCCVIPExpiry = icbcVipExpiry; + ccwdata.NSCPolicyEffectiveDate = nscPolicyEffectiveDate; + ccwdata.NSCPolicyExpiryDate = nscPolicyExpiryDate; + ccwdata.NSCPolicyStatusDate = nscPolicyStatusDate; + + if (ccwdata.Id > 0) { var bus = _context.SchoolBuss.FirstOrDefault(x => x.CCWDataId == ccwdata.Id); diff --git a/Server/SchoolBusAPI/Services/UserService.cs b/Server/SchoolBusAPI/Services/UserService.cs index 018233f8..daf3173d 100644 --- a/Server/SchoolBusAPI/Services/UserService.cs +++ b/Server/SchoolBusAPI/Services/UserService.cs @@ -325,12 +325,16 @@ public virtual IActionResult CreateUserRole(int userId, UserRoleViewModel item) user.UserRoles = new List(); } + // TH - 121015 + DateTime effectiveDate = DateTime.SpecifyKind(item.EffectiveDate, DateTimeKind.Unspecified); + DateTime expiryDate = DateTime.SpecifyKind(item.ExpiryDate.GetValueOrDefault(), DateTimeKind.Unspecified); + // create a new UserRole based on the view model. user.UserRoles.Add(new UserRole { Role = _context.Roles.First(x => x.Id == item.RoleId), - EffectiveDate = item.EffectiveDate, - ExpiryDate = item.ExpiryDate + EffectiveDate = effectiveDate, + ExpiryDate = expiryDate } ); @@ -352,9 +356,10 @@ public virtual IActionResult UpdateUserRole(int userId, int userRoleId, UserRole var userRole = _context.UserRoles .Include(x => x.Role) - .First(x => x.Id == item.Id); - - userRole.ExpiryDate = item.ExpiryDate; + .First(x => x.Id == item.Id); + // TH-121015 + DateTime expiryDate = DateTime.SpecifyKind(item.ExpiryDate.GetValueOrDefault(), DateTimeKind.Unspecified); + userRole.ExpiryDate = expiryDate; _context.SaveChanges(); return new StatusCodeResult(201); From d6555c1a8b693af13dc4fe41980f921b0b51f744 Mon Sep 17 00:00:00 2001 From: Wang Date: Thu, 26 Sep 2024 11:21:13 -0700 Subject: [PATCH 04/11] TH-121015: committed the missing part from the last fix for TH-120363 --- Server/SchoolBusAPI/Services/InspectionService.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Server/SchoolBusAPI/Services/InspectionService.cs b/Server/SchoolBusAPI/Services/InspectionService.cs index bd72b77a..f0bfa16b 100644 --- a/Server/SchoolBusAPI/Services/InspectionService.cs +++ b/Server/SchoolBusAPI/Services/InspectionService.cs @@ -269,6 +269,8 @@ public virtual IActionResult InspectionsPostAsync(Inspection item) { // Inspection has a special field, createdDate which is set to now. item.CreatedDate = DateTime.UtcNow; + // TH-120363 + item.CreatedDate = DateTime.SpecifyKind(item.CreatedDate, DateTimeKind.Unspecified); _context.Inspections.Add(item); } _context.SaveChanges(); From 415d5369c29478b59c23c970e814274b3643b1b0 Mon Sep 17 00:00:00 2001 From: Wang Date: Thu, 26 Sep 2024 12:18:21 -0700 Subject: [PATCH 05/11] TH-121015: fixed the error that inspection date is still utc format --- Server/SchoolBusAPI/Services/InspectionService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Server/SchoolBusAPI/Services/InspectionService.cs b/Server/SchoolBusAPI/Services/InspectionService.cs index f0bfa16b..69b0c3e8 100644 --- a/Server/SchoolBusAPI/Services/InspectionService.cs +++ b/Server/SchoolBusAPI/Services/InspectionService.cs @@ -258,6 +258,7 @@ public virtual IActionResult InspectionsPostAsync(Inspection item) } var exists = _context.Inspections.Any(a => a.Id == item.Id); + item.InspectionDate = DateTime.SpecifyKind(item.InspectionDate, DateTimeKind.Unspecified); if (exists) { _context.Inspections.Update(item); From 5f4700938143a7958303f4a82836a5ec949c4e56 Mon Sep 17 00:00:00 2001 From: Wang Date: Thu, 26 Sep 2024 12:38:30 -0700 Subject: [PATCH 06/11] TH-121015: fixed the error that next inspection date for schoolbut is still utc format --- Server/SchoolBusAPI/Services/SchoolBusService.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Server/SchoolBusAPI/Services/SchoolBusService.cs b/Server/SchoolBusAPI/Services/SchoolBusService.cs index 38fc61f5..67582b1d 100644 --- a/Server/SchoolBusAPI/Services/SchoolBusService.cs +++ b/Server/SchoolBusAPI/Services/SchoolBusService.cs @@ -292,6 +292,8 @@ private void AdjustSchoolBus(SchoolBus item) item.CCWData = null; } } + + item.NextInspectionDate = DateTime.SpecifyKind(item.NextInspectionDate.GetValueOrDefault(), DateTimeKind.Unspecified); } } From f11b29afc497b6c976ef37d056f613dd3c50aa68 Mon Sep 17 00:00:00 2001 From: Wang Date: Thu, 26 Sep 2024 12:53:06 -0700 Subject: [PATCH 07/11] TH-121015: fixed the error that permist issued date for schoolbut is still utc format --- Server/SchoolBusAPI/Services/SchoolBusService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Server/SchoolBusAPI/Services/SchoolBusService.cs b/Server/SchoolBusAPI/Services/SchoolBusService.cs index 67582b1d..0d36a004 100644 --- a/Server/SchoolBusAPI/Services/SchoolBusService.cs +++ b/Server/SchoolBusAPI/Services/SchoolBusService.cs @@ -294,6 +294,7 @@ private void AdjustSchoolBus(SchoolBus item) } item.NextInspectionDate = DateTime.SpecifyKind(item.NextInspectionDate.GetValueOrDefault(), DateTimeKind.Unspecified); + item.PermitIssueDate = DateTime.SpecifyKind(item.PermitIssueDate.GetValueOrDefault(), DateTimeKind.Unspecified); } } From 9c8a2348c89e761a007c618f916813ef81d63d73 Mon Sep 17 00:00:00 2001 From: Wang Date: Thu, 26 Sep 2024 13:05:33 -0700 Subject: [PATCH 08/11] TH-121015: fixed the error that dates for inspection updating are still utc format --- Server/SchoolBusAPI/Services/InspectionService.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Server/SchoolBusAPI/Services/InspectionService.cs b/Server/SchoolBusAPI/Services/InspectionService.cs index 69b0c3e8..8be8d334 100644 --- a/Server/SchoolBusAPI/Services/InspectionService.cs +++ b/Server/SchoolBusAPI/Services/InspectionService.cs @@ -197,6 +197,9 @@ public virtual IActionResult InspectionsIdPutAsync(int id, Inspection item) var exists = _context.Inspections.Any(a => a.Id == id); if (exists && id == item.Id) { + item.CreatedDate = DateTime.SpecifyKind(item.CreatedDate, DateTimeKind.Unspecified); + item.InspectionDate = DateTime.SpecifyKind(item.InspectionDate, DateTimeKind.Unspecified); + item.PreviousNextInspectionDate = DateTime.SpecifyKind(item.PreviousNextInspectionDate.GetValueOrDefault(), DateTimeKind.Unspecified); _context.Inspections.Update(item); // Save the changes _context.SaveChanges(); From 01e5ca081a06c26af699ab6db000d5a934ffa8bd Mon Sep 17 00:00:00 2001 From: Wang Date: Fri, 27 Sep 2024 10:26:00 -0700 Subject: [PATCH 09/11] TH-121015: set permit issued date to unspecified format when printing inspection --- Server/SchoolBusAPI/Services/SchoolBusService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Server/SchoolBusAPI/Services/SchoolBusService.cs b/Server/SchoolBusAPI/Services/SchoolBusService.cs index 0d36a004..76537d40 100644 --- a/Server/SchoolBusAPI/Services/SchoolBusService.cs +++ b/Server/SchoolBusAPI/Services/SchoolBusService.cs @@ -847,6 +847,7 @@ public virtual IActionResult SchoolbusesIdNewpermitPutAsync(int id) item.PermitNumber = permit; item.PermitIssueDate = DateTime.UtcNow; + item.PermitIssueDate = DateTime.SpecifyKind(item.PermitIssueDate.GetValueOrDefault(), DateTimeKind.Unspecified); _context.SchoolBuss.Update(item); _context.SaveChanges(); From 9cf298bbb7db74dee001397a791cc0faaa95e5d2 Mon Sep 17 00:00:00 2001 From: Wang Date: Thu, 3 Oct 2024 22:35:13 -0700 Subject: [PATCH 10/11] TH-121015: Fixed the redirect issue when refresh --- Server/SchoolBusAPI/SchoolBusAPI.csproj | 2 +- .../Services/SchoolBusOwnerService.cs | 1 + .../SchoolBusAPI/Services/SchoolBusService.cs | 19 ++++++++ client/src/js/Keycloak.js | 11 ++++- client/src/js/views/SchoolBusesDetail.jsx | 46 +++++++++++++++++-- 5 files changed, 72 insertions(+), 7 deletions(-) diff --git a/Server/SchoolBusAPI/SchoolBusAPI.csproj b/Server/SchoolBusAPI/SchoolBusAPI.csproj index c5680a53..7709346c 100644 --- a/Server/SchoolBusAPI/SchoolBusAPI.csproj +++ b/Server/SchoolBusAPI/SchoolBusAPI.csproj @@ -9,7 +9,7 @@ Ministry of Transportation and Infrastructure The API server for the schoolbus inspection application. Copyright© 2017, Province of British Columbia. - 2.0.6 + 2.0.7 diff --git a/Server/SchoolBusAPI/Services/SchoolBusOwnerService.cs b/Server/SchoolBusAPI/Services/SchoolBusOwnerService.cs index 687267b3..702d2617 100644 --- a/Server/SchoolBusAPI/Services/SchoolBusOwnerService.cs +++ b/Server/SchoolBusAPI/Services/SchoolBusOwnerService.cs @@ -452,6 +452,7 @@ public virtual IActionResult SchoolbusownersIdPutAsync(int id, SchoolBusOwner bo .OrderByDescending(x => x.NextInspectionDate) .First(); result = schoolbus.NextInspectionDate; + if (schoolbus.NextInspectionDate != null && schoolbus.NextInspectionDate.Value.Year == 1) { result = null; } } return result; } diff --git a/Server/SchoolBusAPI/Services/SchoolBusService.cs b/Server/SchoolBusAPI/Services/SchoolBusService.cs index 76537d40..98660f50 100644 --- a/Server/SchoolBusAPI/Services/SchoolBusService.cs +++ b/Server/SchoolBusAPI/Services/SchoolBusService.cs @@ -319,6 +319,14 @@ public virtual IActionResult SchoolbusesIdGetAsync(int id) .Include(x => x.Inspector) .Include(x => x.CCWData) .First(a => a.Id == id); + if (result.PermitIssueDate != null && result.PermitIssueDate.Value.Year == 1) + { + result.PermitIssueDate = null; + } + if (result.NextInspectionDate != null && result.NextInspectionDate.Value.Year == 1) + { + result.NextInspectionDate = null; + } return new ObjectResult(result); } else @@ -988,6 +996,17 @@ public IActionResult SchoolbusesSearchGetAsync(int?[] districts, int?[] inspecto } var result = data.ToList(); + foreach (var item in result) + { + if (item.NextInspectionDate.HasValue && item.NextInspectionDate.Value.Year == 1) + { + item.NextInspectionDate = null; + } + if (item.PermitIssueDate.HasValue && item.PermitIssueDate.Value.Year == 1) + { + item.PermitIssueDate = null; + } + } return new ObjectResult(result); } diff --git a/client/src/js/Keycloak.js b/client/src/js/Keycloak.js index 7395ef1f..d218043f 100644 --- a/client/src/js/Keycloak.js +++ b/client/src/js/Keycloak.js @@ -11,8 +11,17 @@ const keycloakConfig = { export const keycloak = Keycloak(keycloakConfig); export const init = (onSuccess) => { - keycloak.init({ onLoad: 'login-required', promiseType: 'native', pkceMethod: 'S256' }).then((authenticated) => { + keycloak.init({ + onLoad: 'login-required', + promiseType: 'native', + pkceMethod: 'S256', + }).then((authenticated) => { if (authenticated && onSuccess) { + // Clean up the URL by removing any unwanted query parameters like 'iss' + const url = window.location.href; + const cleanUrl = url.split('&iss=')[0]; // Remove everything after &iss= + // clean the URL without refreshing the page + window.history.replaceState(null, null, cleanUrl); onSuccess(); } }); diff --git a/client/src/js/views/SchoolBusesDetail.jsx b/client/src/js/views/SchoolBusesDetail.jsx index 4ab66ab4..842861e1 100644 --- a/client/src/js/views/SchoolBusesDetail.jsx +++ b/client/src/js/views/SchoolBusesDetail.jsx @@ -473,8 +473,14 @@ class SchoolBusesDetail extends React.Component { )} {bus.permitIssueDate && ( + // + //  (Issued: {formatDateTime(bus.permitIssueDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)}) + // + -  (Issued: {formatDateTime(bus.permitIssueDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)}) +  {bus.permitIssueDate && bus.permitIssueDate.includes("0001-01-01") + ? "" + : "(Issued: " + formatDateTime(bus.permitIssueDate, Constant.DATE_SHORT_MONTH_DAY_YEAR) + ")"} )} @@ -693,20 +699,48 @@ class SchoolBusesDetail extends React.Component { {ccw.nscPolicyNumber} - + {/* {formatDateTime(ccw.nscPolicyStatusDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)} + */} + + {ccw.nscPolicyStatusDate && ccw.nscPolicyStatusDate.includes("0001-01-01") + ? "" + : formatDateTime(ccw.nscPolicyStatusDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)} + + {ccw.nscPolicyStatus} - + {/* {formatDateTime(ccw.nscPolicyEffectiveDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)} + */} + + + + {ccw.nscPolicyEffectiveDate && ccw.nscPolicyEffectiveDate.includes("0001-01-01") + ? "" + : formatDateTime(ccw.nscPolicyEffectiveDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)} - + + + + + {/* {formatDateTime(ccw.nscPolicyExpiryDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)} + */} + + + {ccw.nscPolicyExpiryDate && ccw.nscPolicyExpiryDate.includes("0001-01-01") + ? "" + : formatDateTime(ccw.nscPolicyExpiryDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)} + + + + {ccw.nscPlateDecal} @@ -913,7 +947,9 @@ class SchoolBusesDetail extends React.Component { {ccw.icbcFleetUnitNo} - {formatDateTime(ccw.icbccvipExpiry, Constant.DATE_SHORT_MONTH_DAY_YEAR)} + {ccw.icbccvipExpiry && ccw.icbccvipExpiry.includes("0001-01-01") + ? "" + : formatDateTime(ccw.icbccvipExpiry, Constant.DATE_SHORT_MONTH_DAY_YEAR)} {ccw.icbcNotesAndOrders} From c12e5c2dde6f94313e8709ad8af7eec722657313 Mon Sep 17 00:00:00 2001 From: Wang Date: Tue, 8 Oct 2024 12:47:24 -0700 Subject: [PATCH 11/11] TH-121015: fix the datetime formate is still utc when adding new owner --- Server/SchoolBusAPI/Services/SchoolBusOwnerService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Server/SchoolBusAPI/Services/SchoolBusOwnerService.cs b/Server/SchoolBusAPI/Services/SchoolBusOwnerService.cs index 702d2617..bf67f449 100644 --- a/Server/SchoolBusAPI/Services/SchoolBusOwnerService.cs +++ b/Server/SchoolBusAPI/Services/SchoolBusOwnerService.cs @@ -532,6 +532,7 @@ public virtual IActionResult SchoolbusownersPostAsync(SchoolBusOwner body) { AdjustSchoolBusOwner(body); body.DateCreated = DateTime.UtcNow; + body.DateCreated = DateTime.SpecifyKind(body.DateCreated, DateTimeKind.Unspecified); _context.SchoolBusOwners.Add(body); _context.SaveChanges(); return new ObjectResult(body);