Skip to content

Commit

Permalink
update base url for frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
JaberHPranto committed Oct 28, 2021
1 parent 3cc6e56 commit d6f4368
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 26 deletions.
7 changes: 4 additions & 3 deletions client/src/redux/actions/blogActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import axios from "axios"
import { BLOG_DETAILS_REQUEST, BLOG_DETAILS_SUCCESS, BLOG_FETCH_FAIL, BLOG_FETCH_REQUEST, BLOG_FETCH_SUCCESS } from "../../constants/blogConstant"
import { PRODUCT_DETAILS_FAIL } from "../../constants/productConstants"

const baseUrl = 'https://plantland.herokuapp.com'
// @ GET blogs
export const fetchBlogs = () => async (dispatch) => {
try {
dispatch({ type:BLOG_FETCH_REQUEST})

const { data } = await axios.get(`/api/blogs`)
const { data } = await axios.get(`${baseUrl}/api/blogs`)

dispatch({
type: BLOG_FETCH_SUCCESS,
Expand All @@ -28,7 +29,7 @@ export const fetchBlogById = (id) => async (dispatch) => {
try {
dispatch({ type: BLOG_DETAILS_REQUEST })

const { data } = await axios.get(`/api/blogs/${id}`)
const { data } = await axios.get(`${baseUrl}/api/blogs/${id}`)
dispatch({
type: BLOG_DETAILS_SUCCESS,
payload: data
Expand Down Expand Up @@ -62,7 +63,7 @@ export const createBlog = (blogData) => async (dispatch,getState) => {
}
}

const { data } = await axios.post(`/api/blogs`,blogData,config)
const { data } = await axios.post(`${baseUrl}/api/blogs`,blogData,config)

console.log(data);
// dispatch({
Expand Down
8 changes: 4 additions & 4 deletions client/src/redux/actions/cartActions.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import axios from "axios";
import {
CART_ADD_ITEM,
CART_REMOVE_ITEM,
CART_SAVE_SHIPPING_ADDRESS,
CART_SAVE_PAYMENT_METHOD,
CART_REMOVE_ITEM, CART_SAVE_PAYMENT_METHOD, CART_SAVE_SHIPPING_ADDRESS
} from "../../constants/cartConstants";

const baseUrl = 'https://plantland.herokuapp.com'

export const addToCart = (id, qty) => async (dispatch, getState) => {
try {
const { data } = await axios.get(`/api/products/${id}`);
const { data } = await axios.get(`${baseUrl}/api/products/${id}`);

dispatch({
type: CART_ADD_ITEM,
Expand Down
19 changes: 10 additions & 9 deletions client/src/redux/actions/orderActions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import axios from "axios";
import {
ORDER_CREATE_FAIL, ORDER_CREATE_REQUEST, ORDER_CREATE_SUCCESS, ORDER_DATA_FAIL, ORDER_DATA_REQUEST, ORDER_DATA_SUCCESS, ORDER_DELIVER_FAIL, ORDER_DELIVER_REQUEST, ORDER_DELIVER_SUCCESS, ORDER_DETAILS_FAIL, ORDER_DETAILS_REQUEST, ORDER_DETAILS_SUCCESS, ORDER_LIST_FAIL, ORDER_LIST_REQUEST, ORDER_LIST_SUCCESS, ORDER_MY_LIST_FAIL, ORDER_MY_LIST_REQUEST, ORDER_MY_LIST_SUCCESS, ORDER_PAY_FAIL, ORDER_PAY_REQUEST, ORDER_PAY_SUCCESS, ORDER_SALE_DATA_FAIL, ORDER_SALE_DATA_REQUEST, ORDER_SALE_DATA_SUCCESS
ORDER_CREATE_FAIL, ORDER_CREATE_REQUEST, ORDER_CREATE_SUCCESS, ORDER_DATA_FAIL, ORDER_DATA_REQUEST, ORDER_DATA_SUCCESS, ORDER_DELIVER_FAIL, ORDER_DELIVER_REQUEST, ORDER_DELIVER_SUCCESS, ORDER_DETAILS_FAIL, ORDER_DETAILS_REQUEST, ORDER_DETAILS_SUCCESS, ORDER_LIST_FAIL, ORDER_LIST_REQUEST, ORDER_LIST_SUCCESS, ORDER_MY_LIST_FAIL, ORDER_MY_LIST_REQUEST, ORDER_MY_LIST_SUCCESS, ORDER_PAY_FAIL, ORDER_PAY_REQUEST, ORDER_PAY_SUCCESS, ORDER_SALE_DATA_FAIL, ORDER_SALE_DATA_REQUEST, ORDER_SALE_DATA_SUCCESS
} from "../../constants/orderConstants";

const baseUrl = 'https://plantland.herokuapp.com'

export const createOrder = (order) => async (dispatch, getState) => {
try {
Expand All @@ -21,7 +22,7 @@ export const createOrder = (order) => async (dispatch, getState) => {
},
};

const { data } = await axios.post(`/api/orders`, order, config);
const { data } = await axios.post(`${baseUrl}/api/orders`, order, config);

dispatch({
type: ORDER_CREATE_SUCCESS,
Expand Down Expand Up @@ -69,7 +70,7 @@ export const getOrderList = () => async (dispatch,getState) => {
}
}

const { data } = await axios.get(`/api/orders`,config)
const { data } = await axios.get(`${baseUrl}/api/orders`,config)

dispatch({
type: ORDER_LIST_SUCCESS,
Expand Down Expand Up @@ -105,7 +106,7 @@ export const getMyOrders = () => async (dispatch,getState) => {
}
}

const { data } = await axios.get(`/api/orders/my-orders`,config)
const { data } = await axios.get(`${baseUrl}/api/orders/my-orders`,config)

dispatch({
type: ORDER_MY_LIST_SUCCESS,
Expand Down Expand Up @@ -144,7 +145,7 @@ export const getOrderDetails = (id) => async (dispatch,getState) => {
}


const { data } = await axios.get(`/api/orders/${id}`,config)
const { data } = await axios.get(`${baseUrl}/api/orders/${id}`,config)
dispatch({
type: ORDER_DETAILS_SUCCESS,
payload:data
Expand Down Expand Up @@ -179,7 +180,7 @@ export const payOrder = (id,paymentResult) => async (dispatch,getState) => {

}

const { data } = await axios.put(`/api/orders/${id}/pay`,paymentResult,config)
const { data } = await axios.put(`${baseUrl}/api/orders/${id}/pay`,paymentResult,config)

console.log(data);
dispatch({
Expand Down Expand Up @@ -217,7 +218,7 @@ export const deliverOrder = (order) => async (dispatch,getState) => {

}

const { data } = await axios.put(`/api/orders/${order._id}/deliver`,{},config)
const { data } = await axios.put(`${baseUrl}/api/orders/${order._id}/deliver`,{},config)

console.log(data);
dispatch({
Expand Down Expand Up @@ -256,7 +257,7 @@ export const getOrderData = () => async (dispatch,getState) => {
}
}

const { data } = await axios.get(`/api/orders/order-data`, config)
const { data } = await axios.get(`${baseUrl}/api/orders/order-data`, config)

dispatch({
type: ORDER_DATA_SUCCESS,
Expand Down Expand Up @@ -293,7 +294,7 @@ export const getSaleData = () => async (dispatch,getState) => {
}
}

const { data } = await axios.get(`/api/orders/saleDataByYear`, config)
const { data } = await axios.get(`${baseUrl}/api/orders/saleDataByYear`, config)

dispatch({
type: ORDER_SALE_DATA_SUCCESS,
Expand Down
10 changes: 6 additions & 4 deletions client/src/redux/actions/productActions.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import axios from 'axios';
import { PRODUCT_CREATE_FAIL, PRODUCT_CREATE_REQUEST, PRODUCT_CREATE_REVIEW_FAIL, PRODUCT_CREATE_REVIEW_REQUEST, PRODUCT_CREATE_REVIEW_SUCCESS, PRODUCT_CREATE_SUCCESS, PRODUCT_DELETE_FAIL, PRODUCT_DELETE_REQUEST, PRODUCT_DELETE_SUCCESS, PRODUCT_DETAILS_FAIL, PRODUCT_DETAILS_REQUEST, PRODUCT_DETAILS_SUCCESS, PRODUCT_LIST_FAIL, PRODUCT_LIST_REQUEST, PRODUCT_LIST_SUCCESS, PRODUCT_UPDATE_FAIL, PRODUCT_UPDATE_REQUEST, PRODUCT_UPDATE_SUCCESS } from '../../constants/productConstants';

const baseUrl = 'https://plantland.herokuapp.com'

// @ GET products
export const fetchProducts = (keyword='',pageNumber='',category='',sort='') => async (dispatch) => {
try {
dispatch({ type: PRODUCT_LIST_REQUEST })

const { data } = await axios.get(`/api/products?category=${category}&keyword=${keyword}&pageNumber=${pageNumber}&sort=${sort}`)
const { data } = await axios.get(`${baseUrl}/api/products?category=${category}&keyword=${keyword}&pageNumber=${pageNumber}&sort=${sort}`)

dispatch({
type: PRODUCT_LIST_SUCCESS,
Expand All @@ -30,7 +32,7 @@ export const fetchProductById = (id) => async (dispatch) => {

dispatch({ type: PRODUCT_DETAILS_REQUEST })

const { data } = await axios.get(`/api/products/${id}`)
const { data } = await axios.get(`${baseUrl}/api/products/${id}`)
dispatch({
type: PRODUCT_DETAILS_SUCCESS,
payload: data
Expand Down Expand Up @@ -60,7 +62,7 @@ export const createProductReview = (productId,review) => async (dispatch,getStat
}
}

await axios.post(`/api/products/${productId}/reviews`,review,config)
await axios.post(`${baseUrl}/api/products/${productId}/reviews`,review,config)

dispatch({
type: PRODUCT_CREATE_REVIEW_SUCCESS,
Expand Down Expand Up @@ -95,7 +97,7 @@ export const deleteProduct = (id) => async (dispatch,getState) => {
}
}

await axios.delete(`/api/products/${id}`,config)
await axios.delete(`${baseUrl}/api/products/${id}`,config)

dispatch({
type: PRODUCT_DELETE_SUCCESS,
Expand Down
14 changes: 8 additions & 6 deletions client/src/redux/actions/userActions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import axios from 'axios'
import { USER_DELETE_FAIL, USER_DELETE_REQUEST, USER_DELETE_SUCCESS, USER_DETAILS_FAIL, USER_DETAILS_REQUEST, USER_DETAILS_SUCCESS, USER_LIST_FAIL, USER_LIST_REQUEST, USER_LIST_RESET, USER_LIST_SUCCESS, USER_LOGIN_FAIL, USER_LOGIN_REQUEST, USER_LOGIN_SUCCESS, USER_LOGOUT, USER_PROFILE_UPDATE_FAIL, USER_PROFILE_UPDATE_REQUEST, USER_PROFILE_UPDATE_SUCCESS, USER_REGISTER_FAIL, USER_REGISTER_REQUEST, USER_REGISTER_SUCCESS } from '../../constants/userConstants'

const baseUrl = 'https://plantland.herokuapp.com'

export const login = (email,password) => async (dispatch) => {

try {
Expand All @@ -14,7 +16,7 @@ export const login = (email,password) => async (dispatch) => {
}
}

const { data } = await axios.post('/api/users/login',
const { data } = await axios.post(`${baseUrl}/api/users/login`,
{email, password },config)

dispatch({
Expand Down Expand Up @@ -85,7 +87,7 @@ export const register = (name,email,password,confirmPassword) => async (dispatch
}
}

const { data } = await axios.post('/api/users/register',
const { data } = await axios.post(`${baseUrl}/api/users/register`,
{name,email,password,confirmPassword},config)

dispatch({
Expand Down Expand Up @@ -123,7 +125,7 @@ export const getUserDetails = (id) => async (dispatch,getState) => {
}
}

const { data } = await axios.get(`api/users/${id}`, config)
const { data } = await axios.get(`${baseUrl}/api/users/${id}`, config)

dispatch({
type: USER_DETAILS_SUCCESS,
Expand Down Expand Up @@ -160,7 +162,7 @@ export const updateUserProfile = (user) => async (dispatch,getState) => {
}
}

const { data } = await axios.put(`api/users/profile`,user, config)
const { data } = await axios.put(`${baseUrl}/api/users/profile`,user, config)

console.log(data);

Expand Down Expand Up @@ -199,7 +201,7 @@ export const getUserList = () => async (dispatch,getState) => {
}
}

const { data } = await axios.get(`/api/users`,config)
const { data } = await axios.get(`${baseUrl}/api/users`,config)

dispatch({
type: USER_LIST_SUCCESS,
Expand Down Expand Up @@ -236,7 +238,7 @@ export const deleteUser = (id) => async (dispatch,getState) => {
}
}

await axios.delete(`/api/users/${id}`,config)
await axios.delete(`${baseUrl}/api/users/${id}`,config)

dispatch({
type: USER_DELETE_SUCCESS,
Expand Down

0 comments on commit d6f4368

Please sign in to comment.