Skip to content

Commit

Permalink
Changed API
Browse files Browse the repository at this point in the history
  • Loading branch information
suyash-patil committed Feb 9, 2023
1 parent 7f78219 commit ba4edf4
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion client/src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Header = ({setUser,user,setProfileUpdated,profileUpdated}) => {
const fetchProfile = async() => {
try {
const {email} = JSON.parse(localStorage.getItem('userInfo'))
const { data } = await axios.post('https://covercove.onrender.com/api/users/profile', { email },config)
const { data } = await axios.post('https://booknation.onrender.com/api/users/profile', { email },config)
setUser(data)
setProfileUpdated(false)
} catch (error) {
Expand Down
8 changes: 4 additions & 4 deletions client/src/screens/CompleteOrderScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const CompleteOrderScreen = ({history,match}) => {
}
setUser(JSON.parse(localStorage.getItem('userInfo')))
const addPayPalScript = async () => {
const {data:clientId} = await axios.get('https://covercove.onrender.com/api/config/paypal')
const {data:clientId} = await axios.get('https://booknation.onrender.com/api/config/paypal')
const script = document.createElement('script')
script.type = 'text/javascript'
script.src = `https://www.paypal.com/sdk/js?client-id=${clientId}`
Expand All @@ -35,7 +35,7 @@ const CompleteOrderScreen = ({history,match}) => {
document.body.appendChild(script)
}
const getOrder = async () => {
const {data} = await axios.get(`https://covercove.onrender.com/api/order/${orderId}`)
const {data} = await axios.get(`https://booknation.onrender.com/api/order/${orderId}`)
setOrder(data)
setLoading(false)
}
Expand All @@ -51,7 +51,7 @@ const CompleteOrderScreen = ({history,match}) => {
}
},[orderId,delivUpdate])
const payHandler = async (paymentResult) => {
const { data } = await axios.put(`https://covercove.onrender.com/api/order/${orderId}/pay`,paymentResult)
const { data } = await axios.put(`https://booknation.onrender.com/api/order/${orderId}/pay`,paymentResult)
history.push('/')
// await axios.post('http://localhost:5000/api/create-pdf',{user,orderData: JSON.parse(localStorage.getItem('orderData')),cartItems:JSON.parse(localStorage.getItem('cart')),paymentResult})
// .then(async() => await axios.get('http://localhost:5000/api/fetch-pdf',{responseType:'blob'}))
Expand All @@ -69,7 +69,7 @@ const CompleteOrderScreen = ({history,match}) => {
}

const deliveryHandler = async () => {
const {data} = await axios.put(`https://covercove.onrender.com/api/order/${orderId}/delivered`,{})
const {data} = await axios.put(`https://booknation.onrender.com/api/order/${orderId}/delivered`,{})
setUpdate(true)
}

Expand Down
4 changes: 2 additions & 2 deletions client/src/screens/EditproductScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const EdituserScreen = ({ history, match }) => {

useEffect(() => {
const fetchProduct = async () => {
const { data } = await axios.get(`https://covercove.onrender.com/api/products/${match.params.id}`)
const { data } = await axios.get(`https://booknation.onrender.com/api/products/${match.params.id}`)
setProduct(data)
setLoading(false)
setName(data.name)
Expand All @@ -58,7 +58,7 @@ const EdituserScreen = ({ history, match }) => {

const updateHandler = async () => {
try {
const { data } = await axios.put(`https://covercove.onrender.com/api/products/update/${match.params.id}`, { name, price, author, description, image, countInStock })
const { data } = await axios.put(`https://booknation.onrender.com/api/products/update/${match.params.id}`, { name, price, author, description, image, countInStock })
message.success('Product updated successfully')
setEdit(false)
setIsUpdated(!isUpdated)
Expand Down
4 changes: 2 additions & 2 deletions client/src/screens/EdituserScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const EdituserScreen = ({history,match}) => {

useEffect(() => {
const fetchUser =async () => {
const {data} = await axios.get(`https://covercove.onrender.com/api/users/getuser/${match.params.id}`)
const {data} = await axios.get(`https://booknation.onrender.com/api/users/getuser/${match.params.id}`)
setUserData(data)
setAdmin(data.isAdmin)
setEmail(data.email)
Expand All @@ -47,7 +47,7 @@ const EdituserScreen = ({history,match}) => {

const updateHandler = async () => {
try {
const { data } = await axios.put(`https://covercove.onrender.com/api/users/edituser/${match.params.id}`, { name, isAdmin })
const { data } = await axios.put(`https://booknation.onrender.com/api/users/edituser/${match.params.id}`, { name, isAdmin })
message.success('Profile updated successfully')
setAdmin(data.isAdmin)
setName(data.name)
Expand Down
2 changes: 1 addition & 1 deletion client/src/screens/HomeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const HomeScreen = () => {

useEffect(() => {
const fetchProducts = async () => {
const { data } = await axios.get(`https://covercove.onrender.com/api/products`)
const { data } = await axios.get(`https://booknation.onrender.com/api/products`)
setProducts(data)
setLoading(false)
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/screens/LoginScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const LoginScreen = ({history,setUser,user}) => {

const loginHandler = async (e) => {
try {
const { data } = await axios.post(`https://covercove.onrender.com/api/users/login`, { email, password }, config);
const { data } = await axios.post(`https://booknation.onrender.com/api/users/login`, { email, password }, config);

if (data) {
localStorage.setItem('userInfo', JSON.stringify(data))
Expand Down
4 changes: 2 additions & 2 deletions client/src/screens/OrderScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ const OrderScreen = ({history}) => {
const placeOrder = async () => {
try {
const {email} = JSON.parse(localStorage.getItem('userInfo'))
const {data} = await axios.post('https://covercove.onrender.com/api/users/profile',{email})
const {data} = await axios.post('https://booknation.onrender.com/api/users/profile',{email})
if(data) {
const { data } = await axios.post(`https://covercove.onrender.com/api/order`, {
const { data } = await axios.post(`https://booknation.onrender.com/api/order`, {
orderItems,
shippingAddress,
paymentMethod,
Expand Down
2 changes: 1 addition & 1 deletion client/src/screens/OrderlistScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const OrderlistScreen = ({history}) => {

useEffect(() => {
const fetchOrders = async () => {
const { data } = await axios.post('https://covercove.onrender.com/api/order/getallorders')
const { data } = await axios.post('https://booknation.onrender.com/api/order/getallorders')
setOrders(data)
setLoading(false)
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/screens/ProductScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ProductScreen = ({history, match,setCartItems,cartItems}) => {
const [name,setName] = useState('')
useEffect(() => {
const fetchProduct = async () => {
const {data} = await axios.get(`https://covercove.onrender.com/api/products/${match.params.id}`)
const {data} = await axios.get(`https://booknation.onrender.com/api/products/${match.params.id}`)
setProduct(data)
setLoading(false)
if(localStorage.getItem('userInfo')){
Expand All @@ -41,7 +41,7 @@ const ProductScreen = ({history, match,setCartItems,cartItems}) => {
}
try {
const { _id, name } = JSON.parse(localStorage.getItem('userInfo'))
const { data } = await axios.post(`https://covercove.onrender.com/api/products/${match.params.id}/review`, { rating, comment, name, _id })
const { data } = await axios.post(`https://booknation.onrender.com/api/products/${match.params.id}/review`, { rating, comment, name, _id })
setReviewModal(false)
message.success("Review submitted successfully")
} catch (error) {
Expand Down
6 changes: 3 additions & 3 deletions client/src/screens/ProductlistScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const ProductlistScreen = ({ history }) => {

useEffect(() => {
const fetchProducts = async () => {
const { data } = await axios.get('https://covercove.onrender.com/api/products')
const { data } = await axios.get('https://booknation.onrender.com/api/products')
setProducts(data)
setLoading(false)
}
Expand Down Expand Up @@ -94,7 +94,7 @@ const ProductlistScreen = ({ history }) => {
}
const { _id } = JSON.parse
(localStorage.getItem('userInfo'))
const { data } = await axios.post('https://covercove.onrender.com/api/products/create', { name, description, price, author, countInStock, image:url, _id }, config2)
const { data } = await axios.post('https://booknation.onrender.com/api/products/create', { name, description, price, author, countInStock, image:url, _id }, config2)
setProductModal(false)
message.success("Product added")
setProgress(0)
Expand All @@ -107,7 +107,7 @@ const ProductlistScreen = ({ history }) => {

const deleteHandler = async (id) => {
try {
const { data } = await axios.delete(`https://covercove.onrender.com/api/products/delete/${id}`)
const { data } = await axios.delete(`https://booknation.onrender.com/api/products/delete/${id}`)
message.success(data.message)
setIsDeleted(!isDeleted)

Expand Down
4 changes: 2 additions & 2 deletions client/src/screens/ProfileScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const ProfileScreen = ({history,profileUpdated,setProfileUpdated}) => {
}
}
try{
const { data } = await axios.put(`https://covercove.onrender.com/api/users/profile/update`, { email, name, oldpassword, newpass }, config)
const { data } = await axios.put(`https://booknation.onrender.com/api/users/profile/update`, { email, name, oldpassword, newpass }, config)
localStorage.setItem('userInfo', JSON.stringify(data))
message.success("Profile Updated!")
setNewPass("")
Expand Down Expand Up @@ -85,7 +85,7 @@ const ProfileScreen = ({history,profileUpdated,setProfileUpdated}) => {
const fetchOrders = async () => {
try {
const { _id } = JSON.parse(localStorage.getItem('userInfo'))
const { data } = await axios.get(`https://covercove.onrender.com/api/order/getorders/${_id}`)
const { data } = await axios.get(`https://booknation.onrender.com/api/order/getorders/${_id}`)
setLoading(false)
setOrders(data)
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/screens/RegisterScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const RegisterScreen = ({history,setUser,user}) => {
}
else {
try {
const { data } = await axios.post(`https://covercove.onrender.com/api/users/register`, { name, email, password }, config)
const { data } = await axios.post(`https://booknation.onrender.com/api/users/register`, { name, email, password }, config)
if (data) {
localStorage.setItem('userInfo', JSON.stringify(data))
setUser(JSON.parse(localStorage.getItem('userInfo')))
Expand Down
4 changes: 2 additions & 2 deletions client/src/screens/UserlistScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const UserlistScreen = ({history}) => {
const fetchUsers = async() => {
try {
const { email } = JSON.parse(localStorage.getItem('userInfo'))
const { data } = await axios.post('https://covercove.onrender.com/api/users', { email }, config)
const { data } = await axios.post('https://booknation.onrender.com/api/users', { email }, config)
setUsers(data)
setLoading(false)
} catch (error) {
Expand All @@ -48,7 +48,7 @@ const UserlistScreen = ({history}) => {

const deleteHandler = async (id) => {
try {
const { data } = await axios.delete(`https://covercove.onrender.com/api/users/delete/${id}`)
const { data } = await axios.delete(`https://booknation.onrender.com/api/users/delete/${id}`)
message.success(data.message)
setIsDeleted(!isDeleted)

Expand Down

1 comment on commit ba4edf4

@vercel
Copy link

@vercel vercel bot commented on ba4edf4 Feb 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.