diff --git a/src/components/pages/admin/PageProductImport/components/CSVFileImport.tsx b/src/components/pages/admin/PageProductImport/components/CSVFileImport.tsx index d11028c96..546b24d5f 100755 --- a/src/components/pages/admin/PageProductImport/components/CSVFileImport.tsx +++ b/src/components/pages/admin/PageProductImport/components/CSVFileImport.tsx @@ -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; @@ -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 ( diff --git a/src/constants/apiPaths.ts b/src/constants/apiPaths.ts index 88776a1c9..1cab38745 100755 --- a/src/constants/apiPaths.ts +++ b/src/constants/apiPaths.ts @@ -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`, };