Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fallback url for goBack() #10146

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f71c397
fallback url in goBack and user search feature
Rishith25 Jan 24, 2025
407dfd4
Merge branch 'develop' into fallbackurl-in-goBack
Rishith25 Jan 24, 2025
e44190c
Merge branch 'develop' into fallbackurl-in-goBack
Rishith25 Jan 25, 2025
adb0e2f
Merge branch 'develop' into fallbackurl-in-goBack
Rishith25 Jan 28, 2025
6561701
qParams undefined resolved
Rishith25 Jan 28, 2025
24df168
Merge branch 'fallbackurl-in-goBack' of https://github.com/Rishith25/…
Rishith25 Jan 28, 2025
d509275
changes
Rishith25 Jan 28, 2025
f7d3575
Merge branch 'develop' into fallbackurl-in-goBack
Rishith25 Feb 3, 2025
05da6fc
Merge branch 'develop' into fallbackurl-in-goBack
Rishith25 Feb 5, 2025
3bbfd43
Merge branch 'develop' into fallbackurl-in-goBack
Rishith25 Feb 7, 2025
3dac6e7
suggested change
Rishith25 Feb 7, 2025
9c2e5f7
Merge branch 'develop' into fallbackurl-in-goBack
Rishith25 Feb 10, 2025
b85ddae
i8n added for search users
Rishith25 Feb 10, 2025
5faa9ae
small change
Rishith25 Feb 10, 2025
44b7cf1
Merge branch 'develop' into fallbackurl-in-goBack
Rishith25 Feb 11, 2025
021aaff
Merge branch 'develop' into fallbackurl-in-goBack
Rishith25 Feb 11, 2025
88b2d5c
fixed broken search
Rishith25 Feb 11, 2025
ac488ba
Merge branch 'fallbackurl-in-goBack' of https://github.com/Rishith25/…
Rishith25 Feb 11, 2025
ec6787e
removed the search input
Rishith25 Feb 12, 2025
68f004a
Merge branch 'develop' into fallbackurl-in-goBack
Rishith25 Feb 12, 2025
04686e9
gaback in questionnaire fixed
Rishith25 Feb 12, 2025
0f7a9b8
Merge branch 'develop' into fallbackurl-in-goBack
Rishith25 Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/Auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@
const { reCaptchaSiteKey, urls, stateLogo, customLogo, customLogoAlt } =
careConfig;
const customDescriptionHtml = __CUSTOM_DESCRIPTION_HTML__;
const initForm: any = {

Check warning on line 79 in src/components/Auth/Login.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (1)

Unexpected any. Specify a different type
username: "",
password: "",
};
const { forgot } = props;
const [params] = useQueryParams();
const { mode } = params;
const initErr: any = {};

Check warning on line 86 in src/components/Auth/Login.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (1)

Unexpected any. Specify a different type
const [form, setForm] = useState(initForm);
const [errors, setErrors] = useState(initErr);
const [isCaptchaEnabled, setCaptcha] = useState(false);
Expand Down Expand Up @@ -649,6 +649,7 @@
}}
maxLength={5}
placeholder="Enter 5-digit OTP"
autoFocus
Rishith25 marked this conversation as resolved.
Show resolved Hide resolved
/>
{otpValidationError && (
<p className="text-sm text-red-500">
Expand Down
4 changes: 3 additions & 1 deletion src/components/Patient/EncounterQuestionnaire.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export default function EncounterQuestionnaire({
navigate(`/patient/${patientId}/updates`);
}
}}
onCancel={() => goBack()}
onCancel={() =>
Rishith25 marked this conversation as resolved.
Show resolved Hide resolved
goBack(`/facility/${facilityId}/encounter/${encounterId}/updates`)
}
/>
</CardContent>
</Card>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Patient/PatientRegistration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ export default function PatientRegistration(
<Button
variant={"secondary"}
type="button"
onClick={() => goBack()}
onClick={() => goBack(`/facility/${facilityId}/patients`)}
>
{t("cancel")}
</Button>
Expand Down
6 changes: 5 additions & 1 deletion src/components/Resource/ResourceCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,11 @@ export default function ResourceCreate(props: ResourceProps) {
<Button
type="button"
variant="outline"
onClick={() => goBack()}
onClick={() =>
goBack(
`/facility/${facilityId}/patient/${related_patient}/resource_requests`,
)
}
>
{t("cancel")}
</Button>
Expand Down
8 changes: 7 additions & 1 deletion src/components/Resource/ResourceDetailsUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,13 @@ export const ResourceDetailsUpdate = (props: resourceProps) => {
</div>

<div className="mt-4 flex flex-col justify-between gap-2 md:col-span-2 md:flex-row">
<Button type="button" variant="outline" onClick={() => goBack()}>
<Button
type="button"
variant="outline"
onClick={() =>
goBack(`/facility/${props.facilityId}/resource/${props.id}`)
}
>
{t("cancel")}
</Button>
<Button type="submit" variant="primary" onClick={handleSubmit}>
Expand Down
10 changes: 9 additions & 1 deletion src/pages/Appointments/BookAppointment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,15 @@ export default function BookAppointment(props: Props) {
</div>

<div className="flex justify-end gap-4">
<Button variant="outline" type="button" onClick={() => goBack()}>
<Button
variant="outline"
type="button"
onClick={() =>
goBack(
`/facility/${props.facilityId}/patient/${props.patientId}/appointments`,
)
}
>
{t("cancel")}
</Button>
<Button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useQuery } from "@tanstack/react-query";
import { useQueryParams } from "raviger";
import { useTranslation } from "react-i18next";

import CareIcon from "@/CAREUI/icons/CareIcon";

import { Button } from "@/components/ui/button";
import { Card, CardContent } from "@/components/ui/card";
import { Input } from "@/components/ui/input";

import { Avatar } from "@/components/Common/Avatar";
import {
Expand All @@ -14,34 +14,46 @@ import {
} from "@/components/Common/SkeletonLoading";
import { UserStatusIndicator } from "@/components/Users/UserListAndCard";

import useFilters from "@/hooks/useFilters";

import routes from "@/Utils/request/api";
import query from "@/Utils/request/query";
import EditFacilityUserRoleSheet from "@/pages/Facility/settings/organizations/components/EditFacilityUserRoleSheet";
import FacilityOrganizationLayout from "@/pages/Facility/settings/organizations/components/FacilityOrganizationLayout";
import LinkFacilityUserSheet from "@/pages/Facility/settings/organizations/components/LinkFacilityUserSheet";
import AddUserSheet from "@/pages/Organization/components/AddUserSheet";
import { OrganizationUserRole } from "@/types/organization/organization";

import EditFacilityUserRoleSheet from "./components/EditFacilityUserRoleSheet";
import FacilityOrganizationLayout from "./components/FacilityOrganizationLayout";
import LinkFacilityUserSheet from "./components/LinkFacilityUserSheet";

interface Props {
id: string;
facilityId: string;
}

export default function FacilityOrganizationUsers({ id, facilityId }: Props) {
const [qParams, setQueryParams] = useQueryParams<{
sheet: string;
username: string;
}>();
const { qParams, updateQuery, Pagination, resultsPerPage } = useFilters({
limit: 15,
cacheBlacklist: ["search"],
});
Rishith25 marked this conversation as resolved.
Show resolved Hide resolved
const { t } = useTranslation();

const openAddUserSheet = qParams.sheet === "add";
const openLinkUserSheet = qParams.sheet === "link";

const { data: users, isLoading: isLoadingUsers } = useQuery({
queryKey: ["facilityOrganizationUsers", facilityId, id],
queryFn: query(routes.facilityOrganization.listUsers, {
queryKey: [
"facilityOrganizationUsers",
facilityId,
id,
qParams.search,
qParams.page,
],
queryFn: query.debounced(routes.facilityOrganization.listUsers, {
pathParams: { facilityId, organizationId: id },
queryParams: {
username: qParams.search,
limit: resultsPerPage,
offset: ((qParams.page ?? 1) - 1) * resultsPerPage,
},
}),
enabled: !!id,
});
Expand All @@ -66,27 +78,43 @@ export default function FacilityOrganizationUsers({ id, facilityId }: Props) {
return (
<FacilityOrganizationLayout id={id} facilityId={facilityId}>
<div className="space-y-6">
<div className="flex justify-between items-center">
<div className="flex flex-col lg:flex-row justify-between item-start lg:items-center gap-4">
<h2 className="text-lg font-semibold">{t("users")}</h2>
<div className="flex gap-2">
<AddUserSheet
open={openAddUserSheet}
setOpen={(open) => {
setQueryParams({ sheet: open ? "add" : "", username: "" });
}}
onUserCreated={(user) => {
setQueryParams({ sheet: "link", username: user.username });
}}
/>
<LinkFacilityUserSheet
facilityId={facilityId}
organizationId={id}
open={openLinkUserSheet}
setOpen={(open) => {
setQueryParams({ sheet: open ? "link" : "", username: "" });
}}
preSelectedUsername={qParams.username}
/>
<div className="flex flex-col items-center md:flex-row sm:items-center gap-4 w-full lg:justify-end">
<div className="w-full lg:w-1/3">
<Input
type="text"
placeholder="Search users..."
Rishith25 marked this conversation as resolved.
Show resolved Hide resolved
value={qParams.search || ""}
onChange={(e) =>
updateQuery({
search: e.target.value as string,
})
}
className="w-full"
data-cy="search-user"
/>
</div>
<div className="flex flex-row lg:flex-row justify-between gap-2">
<AddUserSheet
open={openAddUserSheet}
setOpen={(open) => {
updateQuery({ sheet: open ? "add" : "" });
}}
onUserCreated={(user) => {
updateQuery({ sheet: "link", username: user.username });
}}
/>
<LinkFacilityUserSheet
facilityId={facilityId}
organizationId={id}
open={openLinkUserSheet}
setOpen={(open) => {
updateQuery({ sheet: open ? "link" : "", username: "" });
}}
preSelectedUsername={qParams.username}
/>
</div>
</div>
</div>

Expand Down Expand Up @@ -165,6 +193,8 @@ export default function FacilityOrganizationUsers({ id, facilityId }: Props) {
))
)}
</div>

<Pagination totalCount={users?.count || 0} />
</div>
</FacilityOrganizationLayout>
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Patients/VerifyPatient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export default function VerifyPatient(props: { facilityId: string }) {
<Button
variant={"primary_gradient"}
className="gap-3 group"
onClick={() => goBack()}
onClick={() => goBack(`/facility/${props.facilityId}/patients`)}
>
{t("go_back")}
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/PublicAppointments/Schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export function ScheduleAppointment(props: AppointmentsProps) {
<Button
variant="outline"
className="border border-secondary-400"
onClick={() => goBack()}
onClick={() => goBack(`/facility/${facilityId}`)}
>
<span className="text-sm underline">{t("back")}</span>
</Button>
Expand Down
9 changes: 7 additions & 2 deletions src/pages/PublicAppointments/auth/PatientLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,12 @@ export default function PatientLogin({
{t("enter_the_verification_code")}
</FormLabel>
<FormControl>
<InputOTP maxLength={5} {...field} className="focus:ring-0">
<InputOTP
maxLength={5}
{...field}
className="focus:ring-0"
autoFocus
>
<InputOTPGroup>
<InputOTPSlot index={0} />
</InputOTPGroup>
Expand Down Expand Up @@ -229,7 +234,7 @@ export default function PatientLogin({
className="border border-secondary-400"
onClick={() =>
page === "send"
? goBack()
? goBack(`/facility/${facilityId}`)
: navigate(
`/facility/${facilityId}/appointments/${staffId}/otp/send`,
)
Expand Down
Loading