Skip to content

Commit

Permalink
Bug fixes in aidbox-forms smart app launch demo
Browse files Browse the repository at this point in the history
  • Loading branch information
olimsaidov committed Oct 28, 2024
1 parent e9afee9 commit 73d7195
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion aidbox-forms-smart-launch/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/svg+xml" href="/health-samurai.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Security-Policy" content="frame-ancestors 'self' https://form-builder.aidbox.app" />
<title>Aidbox Forms Smart App Launch</title>
Expand Down
15 changes: 15 additions & 0 deletions aidbox-forms-smart-launch/public/health-samurai.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 1 addition & 4 deletions aidbox-forms-smart-launch/src/hooks/use-client.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createContext, useContext } from "react";
import { client, oauth2 } from "fhirclient";
import { useLocation } from "react-router-dom";
import { useQuery } from "@tanstack/react-query";

export const clientId = "aidbox-forms";
Expand Down Expand Up @@ -33,15 +32,13 @@ export const useClient = () => {
};

export const ClientProvider = ({ children }) => {
let location = useLocation();

const { data: client } = useQuery({
queryKey: ["client"],
queryFn: () => {
return oauth2.init({
clientId,
scope,
redirectUri: location.pathname,
redirectUri: window.location.pathname,
});
},
retry: false,
Expand Down
2 changes: 1 addition & 1 deletion aidbox-forms-smart-launch/src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export function createSmartAppLauncherUrl({

export function unbundle(result) {
const resource =
result.resourceType === "Bundle" ? result.entry[0]?.resource : result;
result.resourceType === "Bundle" ? result.entry?.[0]?.resource : result;

if (!resource) {
throw new Error("Resource not found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const QuestionnaireResponses = () => {

const totalPages = Math.ceil(data.total / pageSize);

const questionnaireResponse = data.entry.map((x) => x.resource);
const questionnaireResponse = data.entry?.map((x) => x.resource) || [];

const dummy = Symbol("dummy");

Expand Down
9 changes: 5 additions & 4 deletions aidbox-forms-smart-launch/src/pages/questionnaires.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ export const Questionnaires = () => {

const totalPages = Math.ceil(data.total / pageSize);

const questionnaires = data.entry.map((x) => ({
publisher: "Health Samurai",
...x.resource,
}));
const questionnaires =
data.entry?.map((x) => ({
publisher: "Health Samurai",
...x.resource,
})) || [];

const [previewingQuestionnaire, setPreviewingQuestionnaire] = useState(null);

Expand Down

0 comments on commit 73d7195

Please sign in to comment.