Skip to content

Commit

Permalink
Merge pull request #6387 from coronasafe/develop
Browse files Browse the repository at this point in the history
Production Release; Oct Week 1; HotFix
  • Loading branch information
mathew-alex authored Oct 3, 2023
2 parents e65ec30 + b7fc53c commit 02243c5
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 182 deletions.
1 change: 1 addition & 0 deletions cypress/e2e/facility_spec/locations.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe("Location Management Section", () => {
cy.intercept("GET", "**/api/v1/facility/**").as("getFacilities");
cy.get("[id='facility-details']").first().click();
cy.wait("@getFacilities").its("response.statusCode").should("eq", 200);
cy.get("h1.text-3xl.font-bold", { timeout: 10000 }).should("be.visible");
cy.get("#manage-facility-dropdown button").should("be.visible");
cy.get("[id='manage-facility-dropdown']").scrollIntoView().click();
cy.get("[id=location-management]").click();
Expand Down
3 changes: 1 addition & 2 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class FacilityPage {
}

clickManageFacilityDropdown() {
cy.get("h1.text-3xl.font-bold", { timeout: 20000 }).should("be.visible");
cy.get("#manage-facility-dropdown button").scrollIntoView();
cy.get("#manage-facility-dropdown button")
.contains("Manage Facility")
Expand Down Expand Up @@ -198,8 +199,6 @@ class FacilityPage {
cy.intercept("GET", "**/api/v1/facility/**").as("getManagePage");
cy.go("back");
cy.wait("@getManagePage").its("response.statusCode").should("eq", 200);
cy.get("#manage-facility-dropdown").scrollIntoView();
cy.get("#manage-facility-dropdown").should("exist");
}

verifyfacilityviewassetredirection() {
Expand Down
32 changes: 12 additions & 20 deletions src/Common/hooks/useRangePagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ interface Props {
bounds: DateRange;
perPage: number;
slots?: number;
snapToLatest?: boolean;
reverse?: boolean;
defaultEnd?: boolean;
}

const useRangePagination = ({ bounds, perPage, ...props }: Props) => {
const [currentRange, setCurrentRange] = useState(
getInitialBounds(bounds, perPage, props.snapToLatest)
getInitialBounds(bounds, perPage, props.defaultEnd)
);

useEffect(() => {
setCurrentRange(getInitialBounds(bounds, perPage, props.snapToLatest));
}, [bounds, perPage, props.snapToLatest]);
setCurrentRange(getInitialBounds(bounds, perPage, props.defaultEnd));
}, [bounds, perPage, props.defaultEnd]);

const next = () => {
const { end } = currentRange;
Expand Down Expand Up @@ -63,24 +62,17 @@ const useRangePagination = ({ bounds, perPage, ...props }: Props) => {
}

const slots: DateRange[] = [];
const { start, end } = currentRange;
const { start } = currentRange;
const delta = perPage / props.slots;

for (let i = 0; i < props.slots; i++) {
if (props.snapToLatest) {
slots.push({
start: new Date(end.valueOf() - delta * (i - 1)),
end: new Date(end.valueOf() - delta * i),
});
} else {
slots.push({
start: new Date(start.valueOf() + delta * i),
end: new Date(start.valueOf() + delta * (i + 1)),
});
}
slots.push({
start: new Date(start.valueOf() + delta * i),
end: new Date(start.valueOf() + delta * (i + 1)),
});
}

return props.reverse ? slots.reverse() : slots;
return slots;
}, [currentRange, props.slots, perPage]);

return {
Expand All @@ -98,15 +90,15 @@ export default useRangePagination;
const getInitialBounds = (
bounds: DateRange,
perPage: number,
snapToLatest?: boolean
defaultEnd?: boolean
) => {
const deltaBounds = bounds.end.valueOf() - bounds.start.valueOf();

if (deltaBounds < perPage) {
return bounds;
}

if (snapToLatest) {
if (defaultEnd) {
return {
start: new Date(bounds.end.valueOf() - perPage),
end: bounds.end,
Expand Down
Loading

1 comment on commit 02243c5

@vercel
Copy link

@vercel vercel bot commented on 02243c5 Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

care-storybook – ./

care-storybook-ohcnetwork.vercel.app
care-storybook-git-master-ohcnetwork.vercel.app

Please sign in to comment.