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

Fixes deploy: missing plugin map missing import; calendar component; and other minor fixes #9632

Merged
merged 9 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
115 changes: 63 additions & 52 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@
"@radix-ui/react-avatar": "^1.1.2",
"@radix-ui/react-checkbox": "^1.1.3",
"@radix-ui/react-collapsible": "^1.1.2",
"@radix-ui/react-dialog": "^1.1.4",
"@radix-ui/react-dropdown-menu": "^2.1.4",
"@radix-ui/react-icons": "^1.3.2",
"@radix-ui/react-label": "^2.1.1",
"@radix-ui/react-menubar": "^1.1.4",
"@radix-ui/react-popover": "^1.1.4",
"@radix-ui/react-progress": "^1.1.1",
"@radix-ui/react-radio-group": "^1.2.2",
"@radix-ui/react-scroll-area": "^1.2.2",
Expand All @@ -71,17 +74,12 @@
"@radix-ui/react-slot": "^1.1.1",
"@radix-ui/react-switch": "^1.1.2",
"@radix-ui/react-tabs": "^1.1.1",
"@vitejs/plugin-react": "^4.3.4",
"@pnotify/core": "^5.2.0",
"@pnotify/mobile": "^5.2.0",
"@radix-ui/react-dialog": "^1.1.4",
"@radix-ui/react-label": "^2.1.1",
"@radix-ui/react-popover": "^1.1.4",
"@radix-ui/react-toast": "^1.2.4",
"@radix-ui/react-tooltip": "^1.1.6",
"@sentry/browser": "^8.47.0",
"@tanstack/react-query": "^5.62.8",
"@tanstack/react-query-devtools": "^5.62.7",
"@vitejs/plugin-react": "^4.3.4",
"@yudiel/react-qr-scanner": "^2.1.0",
"bowser": "^2.11.0",
"browser-image-compression": "^2.0.2",
Expand All @@ -91,8 +89,8 @@
"clsx": "^2.1.1",
"cmdk": "^1.0.4",
"cross-env": "^7.0.3",
"date-fns": "^3.6.0",
"cypress": "^13.17.0",
"date-fns": "^3.6.0",
"dayjs": "^1.11.13",
"echarts": "^5.5.1",
"echarts-for-react": "^3.0.2",
Expand All @@ -112,13 +110,13 @@
"raviger": "^4.1.2",
"react": "18.3.1",
"react-copy-to-clipboard": "^5.1.0",
"react-day-picker": "^9.5.0",
"react-day-picker": "^8.10.1",
"react-dom": "18.3.1",
"react-google-recaptcha": "^3.1.0",
"react-hook-form": "^7.53.2",
"react-intersection-observer": "^9.14.1",
"react-i18next": "^15.2.0",
"react-infinite-scroll-component": "^6.1.0",
"react-intersection-observer": "^9.14.1",
"react-pdf": "^9.2.1",
"react-webcam": "^7.2.0",
"recharts": "^2.15.0",
Expand Down Expand Up @@ -214,4 +212,4 @@
"node": ">=22.8.0"
},
"packageManager": "[email protected]"
}
}
3 changes: 2 additions & 1 deletion scripts/setup-care-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ const pluginMapContent = `// Use type assertion for the static import${plugins
(plugin) =>
`// @ts-expect-error Remote module will be available at runtime\nimport ${plugin.camelCaseName}Manifest from "${plugin.repo}/manifest";`,
)
.join("\n")}import type { PluginManifest } from "./pluginTypes";
.join("\n")}
import type { PluginManifest } from "./pluginTypes";

const pluginMap: PluginManifest[] = [${plugins.map((plugin) => `${plugin.camelCaseName}Manifest as PluginManifest`).join(",\n ")}];

Expand Down
12 changes: 11 additions & 1 deletion src/Utils/request/errorHandler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { navigate } from "raviger";
import { toast } from "sonner";

import * as Notifications from "@/Utils/Notifications";
import { HTTPError } from "@/Utils/request/types";
Expand All @@ -19,13 +20,18 @@ export function handleHttpError(error: Error) {

const cause = error.cause;

if (isNotFound(error)) {
toast.error((cause?.detail as string) || "Not found");
return;
}

if (isSessionExpired(cause)) {
handleSessionExpired();
return;
}

if (isBadRequest(error)) {
Notifications.BadRequest({ errs: cause });
Notifications.BadRequest({ errs: cause?.errors });
return;
}

Expand All @@ -52,3 +58,7 @@ function handleSessionExpired() {
function isBadRequest(error: HTTPError) {
return error.status === 400 || error.status === 406;
}

function isNotFound(error: HTTPError) {
return error.status === 404;
}
9 changes: 2 additions & 7 deletions src/Utils/request/uploadFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,8 @@ const uploadFile = async (
} catch {
error = xhr.responseText;
}
if (typeof error === "object" && !Array.isArray(error)) {
Object.values(error).forEach((msg) => {
Notification.Error({ msg: msg || "Something went wrong!" });
});
} else {
Notification.Error({ msg: error || "Something went wrong!" });
}
Notification.BadRequest({ errs: error.errors });
reject(new Error("Client error"));
Comment on lines +32 to +33
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Eliminate redundant reject call and handle fallback for string errors.

Currently, the code calls reject(new Error("Client error")) twice in succession, which is unnecessary. After the first reject() call, the Promise is already rejected, so this second call never takes effect. Moreover, if JSON parsing fails, error will just be a string, and accessing error.errors would be undefined. A more resilient approach might handle both object and string cases.

Consider this patch to remove the duplicated reject call and safeguard against string-based errors:

- Notification.BadRequest({ errs: error.errors });
- reject(new Error("Client error"));
- reject(new Error("Client error"));
+ if (typeof error === "object" && "errors" in error) {
+   Notification.BadRequest({ errs: error.errors });
+ } else {
+   Notification.BadRequest({ errs: [String(error)] });
+ }
+ reject(new Error("Client error"));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Notification.BadRequest({ errs: error.errors });
reject(new Error("Client error"));
if (typeof error === "object" && "errors" in error) {
Notification.BadRequest({ errs: error.errors });
} else {
Notification.BadRequest({ errs: [String(error)] });
}
reject(new Error("Client error"));

reject(new Error("Client error"));
} else {
resolve();
Expand Down
8 changes: 4 additions & 4 deletions src/components/Resource/ResourceFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ const getDate = (value: any) =>
export default function ListFilter(props: any) {
const { filter, onChange, closeFilter, removeFilters } = props;
const [filterState, setFilterState] = useMergeState({
origin_facility: filter.origin_facility || "",
origin_facility: filter.origin_facility || null,
origin_facility_ref: null,
approving_facility: filter.approving_facility || "",
approving_facility: filter.approving_facility || null,
approving_facility_ref: null,
assigned_facility: filter.assigned_facility || "",
assigned_facility: filter.assigned_facility || null,
assigned_facility_ref: null,
emergency: filter.emergency || "--",
emergency: filter.emergency || null,
created_date_before: filter.created_date_before || null,
created_date_after: filter.created_date_after || null,
modified_date_before: filter.modified_date_before || null,
Expand Down
3 changes: 2 additions & 1 deletion src/components/Users/CreateUserForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export default function CreateUserForm({ onSubmitSuccess }: Props) {
<FormItem>
<FormLabel>Phone Number</FormLabel>
<FormControl>
<Input placeholder="+91XXXXXXXXXX" {...field} />
<Input type="tel" placeholder="+91XXXXXXXXXX" {...field} />
</FormControl>
<FormMessage />
</FormItem>
Expand All @@ -290,6 +290,7 @@ export default function CreateUserForm({ onSubmitSuccess }: Props) {
<FormControl>
<Input
placeholder="+91XXXXXXXXXX"
type="tel"
{...field}
disabled={isWhatsApp}
/>
Expand Down
6 changes: 2 additions & 4 deletions src/components/ui/calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use client";

import { ChevronLeftIcon, ChevronRightIcon } from "@radix-ui/react-icons";
import * as React from "react";
import { DayPicker } from "react-day-picker";
Expand Down Expand Up @@ -62,8 +60,8 @@ function Calendar({
...classNames,
}}
components={{
PreviousMonthButton: () => <ChevronLeftIcon className="h-4 w-4" />,
NextMonthButton: () => <ChevronRightIcon className="h-4 w-4" />,
IconLeft: () => <ChevronLeftIcon />,
IconRight: () => <ChevronRightIcon />,
}}
{...props}
/>
Expand Down
Loading