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 9e5a538
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ 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),
Expand All @@ -45,8 +48,18 @@ export default function CSVFileImport({ url, title }: CSVFileImportProps) {

console.log("Result: ", result);
setFile(undefined);
} catch (error) {
console.log(error, "Ddsdsds");
} catch (error: any) {
if (error.response) {
if (error.response.status === 401) {
console.log("Unauthorized: Invalid or expired token");
} else if (error.response.status === 403) {
console.log(
"Forbidden: You do not have permission to perform this action"
);
}
} else {
console.log(error);
}
}
};
return (
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 9e5a538

Please sign in to comment.