Skip to content

Commit

Permalink
Merge branch 'develop' into issue#6250
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranshu1902 committed Sep 11, 2023
2 parents 9101398 + 7cda789 commit 9f028bf
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
10 changes: 4 additions & 6 deletions src/Common/hooks/useAppHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ export default function useAppHistory() {
const resetHistory = useContext(ResetHistoryContext);

const goBack = (fallbackUrl?: string) => {
if (history.length > 1)
// Navigate to history present in the app navigation history stack.
return navigate(history[1]);

if (fallbackUrl)
// Otherwise, use provided fallback url if provided.
// use provided fallback url if provided.
return navigate(fallbackUrl);

if (history.length > 1)
// Otherwise, navigate to history present in the app navigation history stack.
return navigate(history[1]);
// Otherwise, fallback to browser's go back behaviour.
window.history.back();
};
Expand Down
6 changes: 3 additions & 3 deletions src/Components/Assets/AssetFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ function AssetFilter(props: any) {
const applyFilter = () => {
const data = {
facility: facilityId,
asset_type: asset_type,
asset_class: asset_class,
status: asset_status,
asset_type: asset_type ?? "",
asset_class: asset_class ?? "",
status: asset_status ?? "",
location: locationId,
};
onChange(data);
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Assets/AssetManage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { useTranslation } from "react-i18next";
const PageTitle = lazy(() => import("../Common/PageTitle"));
const Loading = lazy(() => import("../Common/Loading"));
import * as Notification from "../../Utils/Notifications.js";
import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
import AuthorizeFor, { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
import Uptime from "../Common/Uptime";
import useAuthUser from "../../Common/hooks/useAuthUser";
import dayjs from "dayjs";
Expand Down Expand Up @@ -452,7 +452,7 @@ const AssetManage = (props: AssetManageProps) => {
}
id="configure-asset"
data-testid="asset-configure-button"
authorizeFor={NonReadOnlyUsers}
authorizeFor={AuthorizeFor(["DistrictAdmin", "StateAdmin"])}
>
<CareIcon className="care-l-setting h-4" />
{t("configure")}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Facility/AddLocationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export const AddLocationForm = (props: LocationFormProps) => {
/>
</div>
</div>
<div className="mt-4 flex flex-col gap-3 sm:flex-row sm:justify-between">
<div className="mt-4 cui-form-button-group">
<Cancel
onClick={() =>
navigate(`/facility/${facilityId}/location`, {
Expand Down
23 changes: 13 additions & 10 deletions src/Components/Users/ManageUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export default function ManageUsers() {
name: string;
}>({ show: false, username: "", name: "" });

const [weeklyHoursError, setWeeklyHoursError] = useState<string>("");

const extremeSmallScreenBreakpoint = 320;
const isExtremeSmallScreen =
width <= extremeSmallScreenBreakpoint ? true : false;
Expand Down Expand Up @@ -144,7 +146,10 @@ export default function ManageUsers() {

const handleWorkingHourSubmit = async () => {
const username = selectedUser;
if (!username || weeklyHours < 0 || weeklyHours > 168) return;
if (!username || !weeklyHours || weeklyHours < 0 || weeklyHours > 168) {
setWeeklyHoursError("Value should be between 0 and 168");
return;
}
const res = await dispatch(
partialUpdateUser(username, {
weekly_working_hours: weeklyHours,
Expand All @@ -163,6 +168,7 @@ export default function ManageUsers() {
});
}
setWeeklyHours(0);
setWeeklyHoursError("");
fetchData({ aborted: false });
};

Expand Down Expand Up @@ -493,13 +499,14 @@ export default function ManageUsers() {
</SlideOverCustom>
<SlideOverCustom
open={expandWorkingHours}
setOpen={setExpandWorkingHours}
setOpen={(state) => {
setExpandWorkingHours(state);
setWeeklyHours(0);
setWeeklyHoursError("");
}}
slideFrom="right"
title="Average weekly working hours"
dialogClass="md:w-[400px]"
onCloseClick={() => {
setWeeklyHours(0);
}}
>
<div className="px-2">
<dt className="mb-3 text-sm font-medium leading-5 text-black">
Expand All @@ -512,11 +519,7 @@ export default function ManageUsers() {
onChange={(e) => {
setWeeklyHours(e.value);
}}
error={
weeklyHours < 0 || weeklyHours > 168
? "Average weekly working hours should be between 0 and 168"
: ""
}
error={weeklyHoursError}
required
label=""
type="number"
Expand Down

0 comments on commit 9f028bf

Please sign in to comment.