Skip to content

Commit

Permalink
Fixed merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed Aug 7, 2024
2 parents ffce6bf + f3dd93d commit 5d3840e
Show file tree
Hide file tree
Showing 33 changed files with 197 additions and 79 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
stale-issue-message: "Hi, @coronasafe/care-frontend-maintainers, This issue has been automatically marked as stale because it has not had any recent activity."
stale-pr-message: "Hi, This pr has been automatically marked as stale because it has not had any recent activity. It will be automatically closed if no further activity occurs for 7 more days. Thank you for your contributions."
close-pr-message: "Hi, @coronasafe/care-frontend-maintainers, This PR has been automatically closed due to inactivity. Thank you for your contributions. Feel free to re-open the PR."
exempt-issue-labels: "blocked,waiting for related PR,waiting for back end,help wanted,work-in-progress,In Progress,wishlist,EPIC"
exempt-pr-labels: "tested,needs testing,need Review,waiting for related PR,waiting for back end,help wanted,blocked,work-in-progress,In Progress"
exempt-issue-labels: "blocked,waiting for related PR,waiting for back end,help wanted,work-in-progress,In Progress,wishlist,EPIC,backlog"
exempt-pr-labels: "tested,needs testing,need Review,waiting for related PR,waiting for back end,help wanted,blocked,work-in-progress,In Progress,backlog"
days-before-issue-stale: 14
days-before-pr-stale: 7
days-before-issue-close: -1
Expand Down
11 changes: 7 additions & 4 deletions cypress/e2e/facility_spec/facility_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@ describe("Facility Creation", () => {
"Invalid Phone Number",
];
const bedErrorMessage = [
"Field is required",
"This field is required",
"Total capacity cannot be 0",
"Field is required",
"This field is required",
];
const doctorErrorMessage = ["Field is required", "Field is required"];
const triageErrorMessage = ["Field is required"];
const doctorErrorMessage = [
"This field is required",
"This field is required",
];
const triageErrorMessage = ["This field is required"];

before(() => {
loginPage.loginAsDisctrictAdmin();
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/users_spec/user_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ describe("User Creation", () => {
];

const EXPECTED_PROFILE_ERROR_MESSAGES = [
"Field is required",
"Field is required",
"This field is required",
"This field is required",
"Please enter valid phone number",
];

Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Asset/AssetCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class AssetPage {
verifyEmptyStatusError() {
cy.get("[data-testid=asset-working-status-input] span").should(
"contain",
"Field is required",
"This field is required",
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Common/hooks/useAsyncOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function useAsyncOptions<T extends Record<string, unknown>>(
) {
const dispatch = useDispatch<any>();
const [queryOptions, setQueryOptions] = useState<T[]>([]);
const [isLoading, setIsLoading] = useState(false);
const [isLoading, setIsLoading] = useState(true);

const fetchOptions = useMemo(
() =>
Expand Down
11 changes: 8 additions & 3 deletions src/Common/hooks/useMSEplayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,14 @@ export const useMSEMediaPlayer = ({
} else {
mimeCodec = Utf8ArrayToStr(decoded_arr);
}
mseSourceBuffer = mse.addSourceBuffer(
`video/mp4; codecs="${mimeCodec}"`,
);
try {
mseSourceBuffer = mse.addSourceBuffer(
`video/mp4; codecs="${mimeCodec}"`,
);
} catch (error) {
onError?.(error);
return;
}
mseSourceBuffer.mode = "segments";
if (mseQueue.length > 0 && !mseSourceBuffer.updating) {
mseSourceBuffer.addEventListener("updateend", pushPacket);
Expand Down
13 changes: 9 additions & 4 deletions src/Components/Assets/AssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const AssetsList = () => {
if (!isValidURL(assetURL)) {
setIsLoading(false);
Notification.Error({
msg: "Invalid QR code scanned !!!",
msg: t("invalid_asset_id_msg"),
});
return;
}
Expand All @@ -137,7 +137,7 @@ const AssetsList = () => {
if (!data) {
setIsLoading(false);
Notification.Error({
msg: "Invalid QR code scanned !!!",
msg: t("invalid_asset_id_msg"),
});
return;
}
Expand All @@ -151,17 +151,22 @@ const AssetsList = () => {
} else {
setIsLoading(false);
Notification.Error({
msg: "Asset not found !!!",
msg: t("asset_not_found_msg"),
});
}
} else {
setIsLoading(false);
Notification.Error({
msg: "Invalid QR code scanned !!!",
msg: t("invalid_asset_id_msg"),
});
}
} catch (err) {
console.log(err);
Notification.Error({
msg: t("invalid_asset_id_msg"),
});
} finally {
setIsLoading(false);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/Components/Common/DateInputV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ const DateInputV2: React.FC<Props> = ({
type="text"
readOnly
disabled={disabled}
className={`cui-input-base cursor-pointer !px-2 disabled:cursor-not-allowed ${className}`}
className={`cui-input-base cursor-pointer disabled:cursor-not-allowed ${className}`}
placeholder={placeholder ?? t("select_date")}
value={value && dayjs(value).format("DD/MM/YYYY")}
/>
Expand Down
20 changes: 17 additions & 3 deletions src/Components/Common/UserAutocompleteFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import {
import { UserModel } from "../Users/models";
import { isUserOnline } from "../../Utils/utils";
import { UserRole } from "../../Common/constants";
import { useEffect } from "react";

type Props = FormFieldBaseProps<UserModel> & {
placeholder?: string;
facilityId?: string;
homeFacility?: string;
userType?: UserRole;
showActiveStatus?: boolean;
noResultsError?: string;
};

export default function UserAutocompleteFormField(props: Props) {
Expand Down Expand Up @@ -59,18 +61,30 @@ export default function UserAutocompleteFormField(props: Props) {
);
};

const items = options(field.value && [field.value]);

useEffect(() => {
if (props.required && !isLoading && !items.length && props.noResultsError) {
field.handleChange(undefined as unknown as UserModel);
}
}, [isLoading, items, props.required]);

const noResultError =
(props.required && !isLoading && !items.length && props.noResultsError) ||
undefined;

return (
<FormField field={field}>
<div className="relative">
<Autocomplete
id={field.id}
disabled={field.disabled}
disabled={field.disabled || !!noResultError}
// Voluntarily casting type as true to ignore type errors.
required={field.required as true}
placeholder={props.placeholder}
placeholder={noResultError || props.placeholder}
value={field.value}
onChange={field.handleChange}
options={options(field.value && [field.value])}
options={items}
optionLabel={getUserFullName}
optionIcon={getStatusIcon}
optionDescription={(option) => `${option.user_type}`}
Expand Down
4 changes: 3 additions & 1 deletion src/Components/ExternalResult/ResultUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import useQuery from "../../Utils/request/useQuery.js";
import routes from "../../Redux/api.js";
import request from "../../Utils/request/request.js";
import { compareBy } from "../../Utils/utils.js";
import { useTranslation } from "react-i18next";

const Loading = lazy(() => import("../Common/Loading"));

Expand Down Expand Up @@ -57,6 +58,7 @@ const initialWard = [{ id: 0, name: "Choose Ward", number: 0 }];
export default function UpdateResult(props: any) {
const { id } = props;
const { goBack } = useAppHistory();
const { t } = useTranslation();

const [state, dispatch] = useReducer(FormReducer, initialState);
const [isLoading, setIsLoading] = useState(true);
Expand Down Expand Up @@ -132,7 +134,7 @@ export default function UpdateResult(props: any) {
switch (field) {
case "address":
if (!state.form[field]) {
errors[field] = "Field is required";
errors[field] = t("field_required");
invalidForm = true;
}
return;
Expand Down
7 changes: 4 additions & 3 deletions src/Components/Facility/AssetCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ import { validateEmailAddress } from "../../Common/validation";
import { dateQueryString, parsePhoneNumber } from "../../Utils/utils.js";
import dayjs from "../../Utils/dayjs";
import DateFormField from "../Form/FormFields/DateFormField.js";
import { t } from "i18next";
import useQuery from "../../Utils/request/useQuery.js";
import routes from "../../Redux/api.js";
import request from "../../Utils/request/request.js";
import { useTranslation } from "react-i18next";

const Loading = lazy(() => import("../Common/Loading"));

Expand Down Expand Up @@ -101,6 +101,7 @@ type AssetFormSection =

const AssetCreate = (props: AssetProps) => {
const { goBack } = useAppHistory();
const { t } = useTranslation();
const { facilityId, assetId } = props;

let assetClassInitial: AssetClass;
Expand Down Expand Up @@ -212,7 +213,7 @@ const AssetCreate = (props: AssetProps) => {
return;
case "is_working":
if (is_working === undefined) {
errors[field] = "Field is required";
errors[field] = t("field_required");
invalidForm = true;
}
return;
Expand All @@ -224,7 +225,7 @@ const AssetCreate = (props: AssetProps) => {
return;
case "support_phone": {
if (!support_phone) {
errors[field] = "Field is required";
errors[field] = t("field_required");
invalidForm = true;
}
// eslint-disable-next-line no-case-declarations
Expand Down
4 changes: 3 additions & 1 deletion src/Components/Facility/BedCapacity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import useConfig from "../../Common/hooks/useConfig";
import { getBedTypes } from "../../Common/constants";
import routes from "../../Redux/api";
import request from "../../Utils/request/request";
import { useTranslation } from "react-i18next";

interface BedCapacityProps extends CapacityModal {
facilityId: string;
Expand Down Expand Up @@ -49,6 +50,7 @@ const bedCountReducer = (state = initialState, action: any) => {
};

export const BedCapacity = (props: BedCapacityProps) => {
const { t } = useTranslation();
const config = useConfig();
const { facilityId, handleClose, handleUpdate, className, id } = props;
const [state, dispatch] = useReducer(bedCountReducer, initialState);
Expand Down Expand Up @@ -127,7 +129,7 @@ export const BedCapacity = (props: BedCapacityProps) => {
let invalidForm = false;
Object.keys(state.form).forEach((field) => {
if (!state.form[field]) {
errors[field] = "Field is required";
errors[field] = t("field_required");
invalidForm = true;
} else if (
field === "currentOccupancy" &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,18 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => {
return;
}

const preset = data.results.find(
const presets = data.results.filter(
(obj) =>
obj.asset_object.meta?.asset_type === "CAMERA" &&
obj.meta.type !== "boundary",
);

const lastPresetId = sessionStorage.getItem(
getFeedPresetKey(props.consultationId),
);
const preset =
presets.find((obj) => obj.id === lastPresetId) ?? presets[0];

if (preset) {
setPreset(preset);
setAsset(preset.asset_object);
Expand Down Expand Up @@ -105,6 +111,13 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => {
}
}, [!!bed, loading, !!asset, divRef.current]);

useEffect(() => {
const feedPresetKey = getFeedPresetKey(props.consultationId);
if (preset) {
sessionStorage.setItem(feedPresetKey, preset.id);
}
}, [preset, props.consultationId]);

if (loading) {
return <Loading />;
}
Expand Down Expand Up @@ -167,7 +180,14 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => {
result: "success",
});
setHasMoved(false);
setPreset(value);
// Voluntarily copying to trigger change of reference of the position attribute, so that the useEffect of CameraFeed that handles the moves gets triggered.
setPreset({
...value,
meta: {
...value.meta,
position: { ...value.meta.position },
},
});
}}
/>
{isUpdatingPreset ? (
Expand Down Expand Up @@ -205,3 +225,7 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => {
</>
);
};

const getFeedPresetKey = (consultationId: string) => {
return `encounterFeedPreset[${consultationId}]`;
};
Original file line number Diff line number Diff line change
Expand Up @@ -555,24 +555,35 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
<div id="patient-weight">
Weight {" - "}
<span className="font-semibold">
{props.consultationData.weight ?? "-"} Kg
{props.consultationData.weight
? `${props.consultationData.weight} kg`
: "Unspecified"}
</span>
</div>
<div id="patient-height">
Height {" - "}
<span className="font-semibold">
{props.consultationData.height ?? "-"} cm
{props.consultationData.height
? `${props.consultationData.height} cm`
: "Unspecified"}
</span>
</div>
<div>
Body Surface Area {" - "}
<span className="font-semibold">
{Math.sqrt(
(Number(props.consultationData.weight) *
Number(props.consultationData.height)) /
3600,
).toFixed(2)}{" "}
m<sup>2</sup>
<span className="font-semibold ">
{props.consultationData.weight &&
props.consultationData.height ? (
<>
{Math.sqrt(
(Number(props.consultationData.weight) *
Number(props.consultationData.height)) /
3600,
).toFixed(2)}
m<sup>2</sup>
</>
) : (
"Unspecified"
)}
</span>
</div>
<div>
Expand Down
Loading

0 comments on commit 5d3840e

Please sign in to comment.