Skip to content

Commit

Permalink
task-7
Browse files Browse the repository at this point in the history
  • Loading branch information
smusaevdelhaize committed Apr 25, 2024
1 parent 5efe723 commit 82aa84f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,25 @@ export default function CSVFileImport({ url, title }: CSVFileImportProps) {
}
const response = await axios({
method: "GET",
headers: {
Authorization: `${localStorage.getItem("authorization_token")}`,
},
url,
params: {
name: encodeURIComponent(file.name),
},
});

if (response.status === 401) {
alert("Unauthorized: Invalid or expired token");
return;
}

if (response.status === 403) {
alert("Forbidden: You do not have permission to perform this action");
return;
}

console.log("File to upload: ", file.name);
console.log("Uploading to: ", response.data);
const result = await fetch(response.data, {
Expand Down
8 changes: 4 additions & 4 deletions src/constants/apiPaths.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const API_PATHS = {
product: "https://ji1e4k0oh0.execute-api.us-east-1.amazonaws.com/dev",
order: "https://ji1e4k0oh0.execute-api.us-east-1.amazonaws.com/dev",
product: "https://eu4wib264k.execute-api.us-east-1.amazonaws.com/dev",
order: "https://eu4wib264k.execute-api.us-east-1.amazonaws.com/dev",
import: "https://6mwzoxcnaf.execute-api.us-east-1.amazonaws.com/dev",
bff: "https://ji1e4k0oh0.execute-api.us-east-1.amazonaws.com/dev",
cart: "https://ji1e4k0oh0.execute-api.us-east-1.amazonaws.com/dev",
bff: "https://eu4wib264k.execute-api.us-east-1.amazonaws.com/dev",
cart: "https://eu4wib264k.execute-api.us-east-1.amazonaws.com/dev",
};

export default API_PATHS;
2 changes: 1 addition & 1 deletion src/queries/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function useRemoveProductCache() {

export function useUpsertAvailableProduct() {
return useMutation((values: AvailableProduct) =>
axios.put<AvailableProduct>(`${API_PATHS.bff}/product`, values, {
axios.post<AvailableProduct>(`${API_PATHS.bff}/products`, values, {
headers: {
Authorization: `Basic ${localStorage.getItem("authorization_token")}`,
},
Expand Down

0 comments on commit 82aa84f

Please sign in to comment.