Skip to content

Commit

Permalink
Merge branch 'develop' into FIx-ohcnetwork#7244
Browse files Browse the repository at this point in the history
  • Loading branch information
AshrafMd-1 authored Mar 12, 2024
2 parents e6b342c + 4c51d3a commit e8532d4
Show file tree
Hide file tree
Showing 15 changed files with 402 additions and 278 deletions.
1 change: 1 addition & 0 deletions cypress/e2e/users_spec/user_homepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe("User Homepage", () => {
userPage.typeInFirstName("Dev");
userPage.typeInLastName("Doctor");
userPage.selectRole("Doctor");
userPage.selectState("Kerala");
userPage.selectDistrict("Ernakulam");
userPage.typeInPhoneNumber(phone_number);
userPage.typeInAltPhoneNumber(alt_phone_number);
Expand Down
9 changes: 6 additions & 3 deletions cypress/pageobject/Users/UserSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class UserPage {
.and("include", "phone_number=%2B919876543219")
.and("include", "alt_phone_number=%2B919876543219")
.and("include", "user_type=Doctor")
.and("include", "district_id=7");
.and("include", "district=7");
}

checkUsernameText(username: string) {
Expand Down Expand Up @@ -62,9 +62,12 @@ export class UserPage {
cy.get("[role='option']").contains(role).click();
}

selectState(state: string) {
cy.searchAndSelectOption("#state input", state);
}

selectDistrict(district: string) {
cy.get("input[name='district']").click().type(district);
cy.get("[role='option']").contains(district).click();
cy.searchAndSelectOption("#district input", district);
}

typeInPhoneNumber(phone: string) {
Expand Down
16 changes: 12 additions & 4 deletions src/Common/hooks/useMSEplayer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useEffect, useRef } from "react";
import axios from "axios";

export interface IAsset {
middlewareHostname: string;
Expand Down Expand Up @@ -45,9 +44,18 @@ const stopStream =
(payload: { id: string }, options: IOptions) => {
const { id } = payload;
ws?.close();
axios
.post(`https://${middlewareHostname}/stop`, {
id,
fetch(`https://${middlewareHostname}/stop`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ id }),
})
.then((res) => {
if (!res.ok) {
throw new Error("network response was not ok");
}
return res.json();
})
.then((res) => options?.onSuccess && options.onSuccess(res))
.catch((err) => options.onError && options.onError(err));
Expand Down
10 changes: 7 additions & 3 deletions src/Components/Assets/AssetType/ONVIFCamera.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useEffect, useState } from "react";
import { AssetData, ResolvedMiddleware } from "../AssetTypes";
import * as Notification from "../../../Utils/Notifications.js";
import { BedModel } from "../../Facility/models";
import axios from "axios";
import { getCameraConfig } from "../../../Utils/transformUtils";
import CameraConfigure from "../configure/CameraConfigure";
import Loading from "../../Common/Loading";
Expand Down Expand Up @@ -100,13 +99,18 @@ const ONVIFCamera = ({ assetId, facilityId, asset, onUpdated }: Props) => {
};
try {
setLoadingAddPreset(true);
const presetData = await axios.get(

const response = await fetch(
`https://${resolvedMiddleware?.hostname}/status?hostname=${config.hostname}&port=${config.port}&username=${config.username}&password=${config.password}`
);
if (!response.ok) {
throw new Error("Network error");
}
const presetData = await response.json();

const { res } = await request(routes.createAssetBed, {
body: {
meta: { ...data, ...presetData.data },
meta: { ...data, ...presetData },
asset: assetId,
bed: bed?.id as string,
},
Expand Down
18 changes: 17 additions & 1 deletion src/Components/Common/DateInputV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,22 @@ const DateInputV2: React.FC<Props> = ({
return true;
};

const isDateWithinLimits = (parsedDate: dayjs.Dayjs): boolean => {
if (parsedDate?.isValid()) {
if (
(max && parsedDate.toDate() > max) ||
(min && parsedDate.toDate() < min)
) {
Notification.Error({
msg: outOfLimitsErrorMessage ?? "Cannot select date out of range",
});
return false;
}
return true;
}
return false;
};

const isSelectedMonth = (month: number) =>
month === datePickerHeaderDate.getMonth();

Expand Down Expand Up @@ -261,7 +277,7 @@ const DateInputV2: React.FC<Props> = ({
onChange={(e) => {
setDisplayValue(e.target.value.replaceAll("/", ""));
const value = dayjs(e.target.value, "DD/MM/YYYY", true);
if (value.isValid()) {
if (isDateWithinLimits(value)) {
onChange(value.toDate());
close();
setIsOpen?.(false);
Expand Down
Loading

0 comments on commit e8532d4

Please sign in to comment.