Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

cdk.out
node_modules
.serverless
coverage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import Typography from "@mui/material/Typography";
import Box from "@mui/material/Box";
import axios from "axios";

type CSVFileImportProps = {
url: string;
Expand All @@ -25,23 +26,34 @@ export default function CSVFileImport({ url, title }: CSVFileImportProps) {
const uploadFile = async () => {
console.log("uploadFile to", url);

// Get authorization token from localStorage
const authorization_token = localStorage.getItem("authorization_token");

// Get the presigned URL
// const response = await axios({
// method: "GET",
// url,
// params: {
// name: encodeURIComponent(file.name),
// },
// });
// console.log("File to upload: ", file.name);
// console.log("Uploading to: ", response.data);
// const result = await fetch(response.data, {
// method: "PUT",
// body: file,
// });
// console.log("Result: ", result);
// setFile("");
const response = await axios({
method: "GET",
url,
params: {
name: encodeURIComponent(file!.name),
},
headers: {
Authorization: `Basic ${authorization_token}`,
},
});

console.log("File to upload: ", file!.name);
console.log("Uploading to: ", response.data);

// Upload file to S3 using presigned URL
const result = await fetch(response.data, {
method: "PUT",
body: file,
});

console.log("Result: ", result);
setFile(undefined);
};

return (
<Box>
<Typography variant="h6" gutterBottom>
Expand All @@ -57,4 +69,4 @@ export default function CSVFileImport({ url, title }: CSVFileImportProps) {
)}
</Box>
);
}
}
2 changes: 1 addition & 1 deletion src/constants/apiPaths.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const API_PATHS = {
product: "https://.execute-api.eu-west-1.amazonaws.com/dev",
order: "https://.execute-api.eu-west-1.amazonaws.com/dev",
import: "https://.execute-api.eu-west-1.amazonaws.com/dev",
import: "https://mrtfclzte1.execute-api.ap-southeast-2.amazonaws.com/prod",
bff: "https://.execute-api.eu-west-1.amazonaws.com/dev",
cart: "https://.execute-api.eu-west-1.amazonaws.com/dev",
};
Expand Down