Skip to content

Commit

Permalink
Fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
nishant0708 committed Jun 15, 2024
1 parent 38c938b commit cceea8a
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions envexample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_BASE_URL="localhost:8000/api/v1" 8000 can be replaced by the server you are running backend on
6 changes: 6 additions & 0 deletions server/envexample
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PORT=8000
DATABASE_URL=
JWT_SECRET=
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
2 changes: 1 addition & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const express = require("express");
const app = express();
const cors = require("cors");
var cookieParser = require("cookie-parser");
const PORT = process.env.PORT || 8000; //originally 4000 tha
const PORT = process.env.PORT || 4000;
const cloudinaryConfig = require("./config/cloudinaryConfig");
const contactRoutes = require('./routes/contactRoutes');
const bodyParser = require('body-parser');
Expand Down
6 changes: 3 additions & 3 deletions src/components/ModalForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const ModalForm = ({ onSubmit , sectionName , canteenData , id}) => {

if(sectionName === "Breakfast"){

const apiUrl = `http://localhost:8000/api/v1/${id}/breakfast/add`;
const apiUrl = `${process.env.REACT_APP_BASE_URL}/${id}/breakfast/add`;

axios.post(apiUrl , foodDetails)
.then((response)=>{
Expand All @@ -75,7 +75,7 @@ const ModalForm = ({ onSubmit , sectionName , canteenData , id}) => {
}
else if(sectionName === "Lunch"){

const apiUrl = `http://localhost:8000/api/v1/${id}/lunch/add`;
const apiUrl = `${process.env.REACT_APP_BASE_URL}/${id}/lunch/add`;

axios.post(apiUrl , foodDetails)
.then((response)=>{
Expand All @@ -92,7 +92,7 @@ const ModalForm = ({ onSubmit , sectionName , canteenData , id}) => {
}
else{

const apiUrl = `http://localhost:8000/api/v1/${id}/dinner/add`;
const apiUrl = `${process.env.REACT_APP_BASE_URL}/${id}/dinner/add`;

axios.post(apiUrl , foodDetails)
.then((response)=>{
Expand Down
6 changes: 3 additions & 3 deletions src/pages/AddFoodItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ function AddFoodItem() {

switch (mealType) {
case "Breakfast":
apiUrl = `http://localhost:8000/api/v1/${canteenId}/breakfast/add`;
apiUrl = `${process.env.REACT_APP_BASE_URL}/${canteenId}/breakfast/add`;
break;
case "Lunch":
apiUrl = `http://localhost:8000/api/v1/${canteenId}/lunch/add`;
apiUrl = `${process.env.REACT_APP_BASE_URL}/${canteenId}/lunch/add`;
break;
case "Dinner":
apiUrl = `http://localhost:8000/api/v1/${canteenId}/dinner/add`;
apiUrl = `${process.env.REACT_APP_BASE_URL}/${canteenId}/dinner/add`;
break;
default:
toast.error("Please select a meal type.");
Expand Down
4 changes: 2 additions & 2 deletions src/pages/EditProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const EditProfile = () => {

const fetchCanteenData = async () => {
try {
const getCanteen = await fetch(`http://localhost:8000/api/v1/getcanteen`, {
const getCanteen = await fetch(`${process.env.REACT_APP_BASE_URL}/getcanteen`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -69,7 +69,7 @@ const EditProfile = () => {
const handleSubmit = async (e) => {
e.preventDefault();
try {
const response = await fetch(`http://localhost:8000/api/v1/${_id}/update`, {
const response = await fetch(`${process.env.REACT_APP_BASE_URL}/${_id}/update`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Foodlist.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Foodlist = () => {
try {
setLoading(true);
const response = await fetch(
`http://localhost:8000/api/v1/${_id}/${mealType}`,
`${process.env.REACT_APP_BASE_URL}/${_id}/${mealType}`,
{
method: "GET",
headers: {
Expand All @@ -48,7 +48,7 @@ const Foodlist = () => {
}

await axios.delete(
`http://localhost:8000/api/v1/${_id}/${mealType}/remove`,
`${process.env.REACT_APP_BASE_URL}/${_id}/${mealType}/remove`,
{
headers: {
"Content-Type": "application/json",
Expand Down Expand Up @@ -84,7 +84,7 @@ const Foodlist = () => {
}

await axios.put(
`http://localhost:8000/api/v1/${_id}/${currentDish.mealType}/updateitem`,
`${process.env.REACT_APP_BASE_URL}/${_id}/${currentDish.mealType}/updateitem`,
{
dishId: currentDish._id,
dish: updatedDish,
Expand Down
6 changes: 3 additions & 3 deletions src/pages/MenuPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function MenuPage() {
try {
setLoading(true);
const getBreakfast = await fetch(
`http://localhost:8000/api/v1/${_id}/breakfast`,
`${process.env.REACT_APP_BASE_URL}/${_id}/breakfast`,
{
method: "GET",
headers: {
Expand All @@ -42,7 +42,7 @@ function MenuPage() {
try {
setLoading(true);
const getLunch = await fetch(
`http://localhost:8000/api/v1/${_id}/lunch`,
`${process.env.REACT_APP_BASE_URL}/${_id}/lunch`,
{
method: "GET",
headers: {
Expand All @@ -64,7 +64,7 @@ function MenuPage() {
try {
setLoading(true);
const getDinner = await fetch(
`http://localhost:8000/api/v1/${_id}/dinner`,
`${process.env.REACT_APP_BASE_URL}/${_id}/dinner`,
{
method: "GET",
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/SectionPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const SectionPage = () => {
try {
setLoading(true);
const getCanteen = await fetch(
`http://localhost:8000/api/v1/getcanteen`,
`${process.env.REACT_APP_BASE_URL}/getcanteen`,
{
method: "GET",
headers: {
Expand Down

0 comments on commit cceea8a

Please sign in to comment.