Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-bes committed Nov 21, 2023
1 parent 68eb34f commit f26968a
Show file tree
Hide file tree
Showing 3 changed files with 1,064 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"homepage": "/viewer",
"dependencies": {
"@aws-sdk/client-s3": "^3.454.0",
"@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.56",
Expand Down
28 changes: 24 additions & 4 deletions src/api/useIPS.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useQuery } from "react-query";
import { request } from "./request";
import * as AWS from "@aws-sdk/client-s3";
// import { request } from "./request";

// const SAMPLE_RESULT = {
// id: "45d1d8bc-5df8-424d-8454-5277b455d96c",
Expand Down Expand Up @@ -643,8 +644,27 @@ import { request } from "./request";
// ],
// };

export const useIPS = ({ url }) => {
url = 's3://bes-tamanu-ips-public/ips-demo/IPS_58170297-d96b-45b6-bb27-ba9522b87be2_1700456070120.json';
return useQuery([url], () => request(url), { enabled: !!url });
const CONFIG = {
region: "ap-southeast-2",
bucketName: "bes-tamanu-ips-public",
bucketPath: "ips-demo",
filePath: "IPS_58170297-d96b-45b6-bb27-ba9522b87be2_1700456070120.json",
};

export const useIPS = async () => {
return useQuery(
[CONFIG.filePath],
() => {
const client = new AWS.S3({ region: CONFIG.region });
return client.send(
new AWS.GetObjectCommand({
Bucket: CONFIG.bucketName,
Key: CONFIG.filePath,
})
);
},
{ enabled: !!CONFIG.filePath }
);

// return { data: SAMPLE_RESULT };
};
Loading

0 comments on commit f26968a

Please sign in to comment.