Skip to content

Commit

Permalink
TH-121015: Fixed the redirect issue when refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
bcgov-brwang committed Oct 4, 2024
1 parent 01e5ca0 commit 9cf298b
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Server/SchoolBusAPI/SchoolBusAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Company>Ministry of Transportation and Infrastructure</Company>
<Description>The API server for the schoolbus inspection application.</Description>
<Copyright>Copyright© 2017, Province of British Columbia.</Copyright>
<Version>2.0.6</Version>
<Version>2.0.7</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
1 change: 1 addition & 0 deletions Server/SchoolBusAPI/Services/SchoolBusOwnerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
19 changes: 19 additions & 0 deletions Server/SchoolBusAPI/Services/SchoolBusService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down
11 changes: 10 additions & 1 deletion client/src/js/Keycloak.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
Expand Down
46 changes: 41 additions & 5 deletions client/src/js/views/SchoolBusesDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,14 @@ class SchoolBusesDetail extends React.Component {
</Button>
)}
{bus.permitIssueDate && (
// <small id="issued-date">
// &nbsp;(Issued: {formatDateTime(bus.permitIssueDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)})
// </small>

<small id="issued-date">
&nbsp;(Issued: {formatDateTime(bus.permitIssueDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)})
&nbsp;{bus.permitIssueDate && bus.permitIssueDate.includes("0001-01-01")
? ""
: "(Issued: " + formatDateTime(bus.permitIssueDate, Constant.DATE_SHORT_MONTH_DAY_YEAR) + ")"}
</small>
)}
</h1>
Expand Down Expand Up @@ -693,20 +699,48 @@ class SchoolBusesDetail extends React.Component {
<ColDisplay md={4} label="Policy #">
{ccw.nscPolicyNumber}
</ColDisplay>
<ColDisplay md={4} label="Status Date">
{/* <ColDisplay md={4} label="Status Date">
{formatDateTime(ccw.nscPolicyStatusDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)}
</ColDisplay> */}
<ColDisplay md={4} label="Status Date">
{ccw.nscPolicyStatusDate && ccw.nscPolicyStatusDate.includes("0001-01-01")
? ""
: formatDateTime(ccw.nscPolicyStatusDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)}
</ColDisplay>


<ColDisplay md={4} label="Status">
{ccw.nscPolicyStatus}
</ColDisplay>
</Row>
<Row>
<ColDisplay md={4} label="Effective Date">
{/* <ColDisplay md={4} label="Effective Date">
{formatDateTime(ccw.nscPolicyEffectiveDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)}
</ColDisplay> */}


<ColDisplay md={4} label="Effective Date">
{ccw.nscPolicyEffectiveDate && ccw.nscPolicyEffectiveDate.includes("0001-01-01")
? ""
: formatDateTime(ccw.nscPolicyEffectiveDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)}
</ColDisplay>
<ColDisplay md={4} label="Expiry Date">




{/* <ColDisplay md={4} label="Expiry Date">
{formatDateTime(ccw.nscPolicyExpiryDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)}
</ColDisplay> */}

<ColDisplay md={4} label="Expiry Date">
{ccw.nscPolicyExpiryDate && ccw.nscPolicyExpiryDate.includes("0001-01-01")
? ""
: formatDateTime(ccw.nscPolicyExpiryDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)}
</ColDisplay>




<ColDisplay md={4} label="Plate Decal #">
{ccw.nscPlateDecal}
</ColDisplay>
Expand Down Expand Up @@ -913,7 +947,9 @@ class SchoolBusesDetail extends React.Component {
{ccw.icbcFleetUnitNo}
</ColDisplay>
<ColDisplay md={3} label="CVIP Expiry">
{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)}
</ColDisplay>
<ColDisplay md={3} label="N&amp;O">
{ccw.icbcNotesAndOrders}
Expand Down

0 comments on commit 9cf298b

Please sign in to comment.