Skip to content
Merged
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
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 @@ -14,33 +15,39 @@ export default function CSVFileImport({ url, title }: CSVFileImportProps) {
const files = e.target.files;
if (files && files.length > 0) {
const file = files[0];
console.log("onFileChange", file);
setFile(file);
}
};

const removeFile = () => {
console.log("removeFile", file);
setFile(undefined);
};

const uploadFile = async () => {
console.log("uploadFile to", url);
console.log("upload file to", url);
if (!file) {
console.error("file not exist");
return;
}

// 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),
},
});
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("Uploading result: ", result);
setFile(undefined);
};
return (
<Box>
Expand Down
5 changes: 2 additions & 3 deletions src/constants/apiPaths.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const prefix = import.meta.env.VITE_API_PREFIX || ".execute-api2";
const awsAPI = "https://6563hjfn25.execute-api.us-east-1.amazonaws.com/prod";

const API_PATHS = {
product: awsAPI,
product: "https://o2jh3m7b57.execute-api.us-east-1.amazonaws.com/prod",
order: `https://${prefix}.eu-west-1.amazonaws.com/dev`,
import: `https://${prefix}.eu-west-1.amazonaws.com/dev`,
import: "https://i6gsu0m0sg.execute-api.us-east-1.amazonaws.com/prod",
bff: `https://${prefix}.eu-west-1.amazonaws.com/dev`,
cart: `https://${prefix}.eu-west-1.amazonaws.com/dev`,
};
Expand Down