Skip to content

Commit

Permalink
fix api url call
Browse files Browse the repository at this point in the history
  • Loading branch information
sevelinCa committed Jul 22, 2024
1 parent 8562c00 commit 1cb2274
Show file tree
Hide file tree
Showing 15 changed files with 14 additions and 37 deletions.
23 changes: 0 additions & 23 deletions src/Components/Homepage/BestDeals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,8 @@ const BestDeals: React.FC = () => {
console.log(hotDeal)


const productId = "084bfddb-c87a-42b0-aa27-2f71f39e7671";


useEffect(() => {
const fetchImage = async () => {
try {
setLoading(true);
const response = await fetch(`http://localhost:5000/readProduct/${productId}`);

if (!response.ok) {
throw new Error('Network response was not ok');
}

const data = await response.json();
const imageUrl = data.image;
setImageUrl(imageUrl);
} catch (error: any) {
setError('Failed to load image');
} finally {
setLoading(false);
}
};

fetchImage();
}, [productId]);

return (
<section className="bg-primary text-white p-8 sm:p-16 md:pl-24 flex flex-col md:flex-row items-center sm:items-center justify-center gap-10 sm:gap-0 md:gap-10 font-outfit text-lg md:text-xl sm:text-sm min=-h-screen">
Expand Down
2 changes: 1 addition & 1 deletion src/Redux/Analytic/SellerAnalytics/OrderStatusSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const fetchSellerOrderStatus = createAsyncThunk(
const decodedToken = jwtDecode<TokenPayload>(token);
const vendorId = decodedToken.vendor;
const response = await axios.get(
`http://localhost:5000/order/getSellerOrder/${vendorId}`
`${process.env.BACKEND_API_URL}/order/getSellerOrder/${vendorId}`
);
return response.data;
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/Redux/Analytic/SellerAnalytics/SellingReportSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const fetchSellerSellingReport = createAsyncThunk(
console.log(vendorId)

const response = await axios.get(
`http://localhost:5000/annualSellingReport/${vendorId}`
`${process.env.BACKEND_API_URL}/annualSellingReport/${vendorId}`
);
return response.data;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Redux/Analytic/SellerAnalytics/TopProductSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import axios from "axios";
export const fetchingSellerPopularProduct = createAsyncThunk(
"/product/popularity",
async () => {
const response = await axios.get("http://localhost:5000/popular-product");
const response = await axios.get(`${process.env.BACKEND_API_URL}/popular-product`);
return response.data;
}
);
Expand Down
2 changes: 1 addition & 1 deletion src/Redux/Analytic/SellerAnalytics/WeekSellingSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const fetchSellerWeeklyReport = createAsyncThunk(
const vendorId = decodedToken.vendor;
console.log(vendorId);
const response = await axios.get(
`http://localhost:5000/WeeklySellingReport/${vendorId}`
`${process.env.BACKEND_API_URL}/WeeklySellingReport/${vendorId}`
);

return response.data;
Expand Down
2 changes: 1 addition & 1 deletion src/Redux/Analytic/SellingReportSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const fetchSellingReport = createAsyncThunk(
"sellingReport/fetchSellingReport",
async () => {
const response = await axios.get(
"http://localhost:5000/overallAnnualSellingReport/"
`${process.env.BACKEND_API_URL}/overallAnnualSellingReport/`
);
return response.data;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Redux/Analytic/ToProductSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PayloadAction, createAsyncThunk, createSlice } from "@reduxjs/toolkit";
import axios from "axios";

export const fetchingPopularProduct = createAsyncThunk("/product/popularity", async () => {
const response = await axios.get("http://localhost:5000/popular-product");
const response = await axios.get(`${process.env.BACKEND_API_URL}/popular-product`);
return response.data;
});

Expand Down
2 changes: 1 addition & 1 deletion src/Redux/Analytic/WeeklySellingSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const fetchWeeklyReport = createAsyncThunk(
"analytics/fetchWeeklyReport",
async () => {
const response = await axios.get(
"http://localhost:5000/OverallWeeklySellingReport/"
`${process.env.BACKEND_API_URL}/OverallWeeklySellingReport/`
);


Expand Down
2 changes: 1 addition & 1 deletion src/Redux/Analytic/orderStatusSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const initialState: OrderState = {
};

export const fetchOrders = createAsyncThunk("orders/fetchOrders", async () => {
const response = await fetch("http://localhost:5000/order/getAllOrder");
const response = await fetch(`${process.env.BACKEND_API_URL}/order/getAllOrder`);
if (!response.ok) {
throw new Error("Failed to fetch orders");
}
Expand Down
2 changes: 1 addition & 1 deletion src/Redux/HomePage/PopularProductsSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface PopularProductsState {
export const fetchPopularProducts = createAsyncThunk(
"popularProducts/fetchPopularProducts",
async () => {
const response = await fetch("http://localhost:5000/popular-product");
const response = await fetch(`${process.env.BACKEND_API_URL}/popular-product`);
if (!response.ok) {
throw new Error("Failed to fetch products");
}
Expand Down
2 changes: 1 addition & 1 deletion src/Redux/HomePage/ProductsImagesSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const { fetchImagesRequest, fetchImagesSuccess, fetchImagesFailure } =
export const fetchImages = (): AppThunk => async (dispatch) => {
dispatch(fetchImagesRequest());
try {
const response = await fetch("http://localhost:5000/readAllProducts");
const response = await fetch(`${process.env.BACKEND_API_URL}/readAllProducts`);
if (!response.ok) {
throw new Error("Failed to fetch images");
}
Expand Down
2 changes: 1 addition & 1 deletion src/Redux/HomePage/contactSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const sendMessage = createAsyncThunk(
{ rejectWithValue }
) => {
try {
const response = await fetch("http://localhost:5000/addMessage", {
const response = await fetch(`${process.env.BACKEND_API_URL}/addMessage`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
2 changes: 1 addition & 1 deletion src/Redux/features/PopularProductsSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface PopularProductsState {
export const fetchPopularProducts = createAsyncThunk(
'popularProducts/fetchPopularProducts',
async () => {
const response = await fetch('http://localhost:5000/popular-product');
const response = await fetch(`${process.env.BACKEND_API_URL}/popular-product`);
if (!response.ok) {
throw new Error('Failed to fetch products');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Redux/features/analyticSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const initialState: OrderState = {
};

export const fetchOrders = createAsyncThunk("orders/fetchOrders", async () => {
const response = await fetch("http://localhost:5000/order/getAllOrder");
const response = await fetch(`${process.env.BACKEND_API_URL}/getAllOrder`);
if (!response.ok) {
throw new Error("Failed to fetch orders");
}
Expand Down
2 changes: 1 addition & 1 deletion src/Redux/features/contactSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const sendMessage = createAsyncThunk(
'contact/sendMessage',
async (messageData: { name: string; email: string; content: string }, { rejectWithValue }) => {
try {
const response = await fetch('http://localhost:5000/addMessage', {
const response = await fetch(`${process.env.BACKEND_API_URL}/addMessage`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down

0 comments on commit 1cb2274

Please sign in to comment.