Skip to content

Commit b44053a

Browse files
committed
deployment added
1 parent baf4269 commit b44053a

File tree

7 files changed

+582
-473
lines changed

7 files changed

+582
-473
lines changed

frontend/.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
BACKEND_URL = "http://localhost:4000"
2-
ENVIRONMENT = DEVELOPMENT
1+
REACT_APP_BACKEND_URL = http://localhost:4000
2+
REACT_APP_ENVIRONMENT = DEVELOPMENT

frontend/src/api.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import axios from "axios";
2+
axios.defaults.baseURL = "https://api.recruitingwebsite.online";
23
// import { logout } from "./shared/utils/auth";
34

45
// const apiClient = axios.create({
@@ -47,6 +48,8 @@ import axios from "axios";
4748
// };
4849

4950
// secure routes
51+
52+
const base_url = process.env.REACT_APP_BACKEND_URL;
5053
export const sendFriendInvitation = async (data) => {
5154
try {
5255
const config = {
@@ -154,7 +157,7 @@ export const getGroup = async () => {
154157
// };
155158

156159
const api = axios.create({
157-
baseURL: '/api',
160+
baseURL: "/api",
158161
});
159162

160163
export default api;

frontend/src/features/auth/authActions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import axios from "axios";
22
import { createAsyncThunk } from "@reduxjs/toolkit";
33
import { useDispatch } from "react-redux";
4-
const base_url = process.env.BACKEND_URL;
4+
const base_url = process.env.REACT_APP_BACKEND_URL;
55

66
export const userLogin = createAsyncThunk(
77
"user/login",

frontend/src/store/actions/friendsActions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { openAlertMessage } from "./alertActions";
22
import * as api from "../../api";
33
import axios from "axios";
4+
axios.defaults.baseURL = "https://api.recruitingwebsite.online";
45
export const friendsActions = {
56
SET_FRIENDS: "FRIENDS.SET_FRIENDS",
67
SET_PENDING_FRIENDS_INVITATIONS: "FRIENDS.SET_PENDING_FRIENDS_INVITATIONS",
Lines changed: 137 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,165 @@
11
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
22
import axios from "axios";
3-
3+
axios.defaults.baseURL = "https://api.recruitingwebsite.online";
44
const config = {
5-
headers: {
6-
"content-type": "application/json",
7-
},
8-
withCredentials: true,
5+
headers: {
6+
"content-type": "application/json",
7+
},
8+
withCredentials: true,
99
};
1010

11-
export const createJobForms = createAsyncThunk('jobs/createJobForms', async (content, { rejectWithValue }) => {
11+
export const createJobForms = createAsyncThunk(
12+
"jobs/createJobForms",
13+
async (content, { rejectWithValue }) => {
1214
try {
13-
const response = await axios.post('/api/jobs/createJobForm', content, config);
14-
return response.data;
15+
const response = await axios.post(
16+
"/api/jobs/createJobForm",
17+
content,
18+
config
19+
);
20+
return response.data;
1521
} catch (exception) {
16-
return rejectWithValue(exception.response?.data || exception.message);
22+
return rejectWithValue(exception.response?.data || exception.message);
1723
}
18-
});
24+
}
25+
);
1926

20-
export const fetchMyJobForms = createAsyncThunk("jobs/fetchMyJobForms", async (_, { rejectWithValue }) => {
27+
export const fetchMyJobForms = createAsyncThunk(
28+
"jobs/fetchMyJobForms",
29+
async (_, { rejectWithValue }) => {
2130
try {
22-
const response = await axios.get(`/api/jobs/fetchMyJobForms`, config);
23-
if (response.data.error === "Forms not found") {
24-
return rejectWithValue('No Jobs available.');
25-
}
26-
return response.data;
31+
const response = await axios.get(`/api/jobs/fetchMyJobForms`, config);
32+
if (response.data.error === "Forms not found") {
33+
return rejectWithValue("No Jobs available.");
34+
}
35+
return response.data;
2736
} catch (exception) {
28-
return rejectWithValue(exception.response?.data || exception.message);
37+
return rejectWithValue(exception.response?.data || exception.message);
2938
}
30-
});
39+
}
40+
);
3141

32-
export const fetchAllJobForms = createAsyncThunk("jobs/fetchAllJobForms",async(_,{rejectWithValue})=>{
42+
export const fetchAllJobForms = createAsyncThunk(
43+
"jobs/fetchAllJobForms",
44+
async (_, { rejectWithValue }) => {
3345
try {
34-
const response = await axios.get(`/api/jobs/fetchAllJobForms`, config);
35-
if (response.data.error === "Forms not found") {
36-
return rejectWithValue('No Jobs available.');
37-
}
38-
return response.data;
46+
const response = await axios.get(`/api/jobs/fetchAllJobForms`, config);
47+
if (response.data.error === "Forms not found") {
48+
return rejectWithValue("No Jobs available.");
49+
}
50+
return response.data;
3951
} catch (exception) {
40-
return rejectWithValue(exception.response?.data || exception.message);
52+
return rejectWithValue(exception.response?.data || exception.message);
4153
}
42-
})
43-
54+
}
55+
);
4456

45-
export const fetchJobById = createAsyncThunk('jobs/fetchJobById',async (formId, { rejectWithValue }) => {
46-
try {
47-
const response = await axios.get(`/api/jobs/fetchJobById/${formId}`,config);
48-
return response.data;
49-
} catch (exception) {
50-
return rejectWithValue(exception.response?.data || exception.message);
51-
}
57+
export const fetchJobById = createAsyncThunk(
58+
"jobs/fetchJobById",
59+
async (formId, { rejectWithValue }) => {
60+
try {
61+
const response = await axios.get(
62+
`/api/jobs/fetchJobById/${formId}`,
63+
config
64+
);
65+
return response.data;
66+
} catch (exception) {
67+
return rejectWithValue(exception.response?.data || exception.message);
5268
}
69+
}
5370
);
5471

55-
export const applyForJob = createAsyncThunk("jobs/applyForJob", async (formId, { rejectWithValue }) => {
72+
export const applyForJob = createAsyncThunk(
73+
"jobs/applyForJob",
74+
async (formId, { rejectWithValue }) => {
5675
try {
57-
const response = await axios.put(`/api/jobs/applyForJob`,{formId:formId},config);
58-
return response.data;
76+
const response = await axios.put(
77+
`/api/jobs/applyForJob`,
78+
{ formId: formId },
79+
config
80+
);
81+
return response.data;
5982
} catch (exception) {
60-
return rejectWithValue(exception.response?.data || exception.message);
83+
return rejectWithValue(exception.response?.data || exception.message);
6184
}
62-
});
85+
}
86+
);
6387

6488
const JobSlice = createSlice({
65-
name: 'jobs',
66-
initialState: {
67-
isLoading: false,
68-
allJobForms: [],
69-
myJobForms:[],
70-
jobFormById: {},
71-
isError: false,
72-
message: '',
73-
errorMessage: '',
74-
},
75-
reducers: {},
76-
extraReducers: (builder) => {
77-
builder
78-
.addCase(createJobForms.pending, (state) => {
79-
state.isLoading = true;
80-
})
81-
.addCase(createJobForms.fulfilled, (state, action) => {
82-
state.isLoading = false;
83-
state.myJobForms.push(action.payload);
84-
})
85-
.addCase(createJobForms.rejected, (state, action) => {
86-
state.isLoading = false;
87-
state.isError = true;
88-
state.errorMessage = action.payload;
89-
})
90-
.addCase(fetchMyJobForms.pending, (state) => {
91-
state.isLoading = true;
92-
})
93-
.addCase(fetchMyJobForms.fulfilled, (state, action) => {
94-
state.isLoading = false;
95-
state.myJobForms = action.payload;
96-
})
97-
.addCase(fetchMyJobForms.rejected, (state, action) => {
98-
state.isLoading = false;
99-
state.isError = true;
100-
state.errorMessage = action.payload;
101-
})
102-
.addCase(fetchAllJobForms.pending, (state) => {
103-
state.isLoading = true;
104-
})
105-
.addCase(fetchAllJobForms.fulfilled, (state, action) => {
106-
state.isLoading = false;
107-
state.allJobForms = action.payload;
108-
})
109-
.addCase(fetchAllJobForms.rejected, (state, action) => {
110-
state.isLoading = false;
111-
state.isError = true;
112-
state.errorMessage = action.payload;
113-
})
114-
.addCase(fetchJobById.pending, (state) => {
115-
state.isLoading = true;
116-
})
117-
.addCase(fetchJobById.fulfilled, (state, action) => {
118-
state.isLoading = false;
119-
state.jobFormById = action.payload;
120-
})
121-
.addCase(fetchJobById.rejected, (state, action) => {
122-
state.isLoading = false;
123-
state.isError = true;
124-
state.errorMessage = action.payload;
125-
})
126-
.addCase(applyForJob.pending, (state) => {
127-
state.isLoading = true;
128-
})
129-
.addCase(applyForJob.fulfilled, (state, action) => {
130-
state.isLoading = false;
131-
state.message = "Successfully Applied..";
132-
})
133-
.addCase(applyForJob.rejected, (state, action) => {
134-
state.isLoading = false;
135-
state.isError = true;
136-
state.errorMessage = action.payload;
137-
});
138-
}
89+
name: "jobs",
90+
initialState: {
91+
isLoading: false,
92+
allJobForms: [],
93+
myJobForms: [],
94+
jobFormById: {},
95+
isError: false,
96+
message: "",
97+
errorMessage: "",
98+
},
99+
reducers: {},
100+
extraReducers: (builder) => {
101+
builder
102+
.addCase(createJobForms.pending, (state) => {
103+
state.isLoading = true;
104+
})
105+
.addCase(createJobForms.fulfilled, (state, action) => {
106+
state.isLoading = false;
107+
state.myJobForms.push(action.payload);
108+
})
109+
.addCase(createJobForms.rejected, (state, action) => {
110+
state.isLoading = false;
111+
state.isError = true;
112+
state.errorMessage = action.payload;
113+
})
114+
.addCase(fetchMyJobForms.pending, (state) => {
115+
state.isLoading = true;
116+
})
117+
.addCase(fetchMyJobForms.fulfilled, (state, action) => {
118+
state.isLoading = false;
119+
state.myJobForms = action.payload;
120+
})
121+
.addCase(fetchMyJobForms.rejected, (state, action) => {
122+
state.isLoading = false;
123+
state.isError = true;
124+
state.errorMessage = action.payload;
125+
})
126+
.addCase(fetchAllJobForms.pending, (state) => {
127+
state.isLoading = true;
128+
})
129+
.addCase(fetchAllJobForms.fulfilled, (state, action) => {
130+
state.isLoading = false;
131+
state.allJobForms = action.payload;
132+
})
133+
.addCase(fetchAllJobForms.rejected, (state, action) => {
134+
state.isLoading = false;
135+
state.isError = true;
136+
state.errorMessage = action.payload;
137+
})
138+
.addCase(fetchJobById.pending, (state) => {
139+
state.isLoading = true;
140+
})
141+
.addCase(fetchJobById.fulfilled, (state, action) => {
142+
state.isLoading = false;
143+
state.jobFormById = action.payload;
144+
})
145+
.addCase(fetchJobById.rejected, (state, action) => {
146+
state.isLoading = false;
147+
state.isError = true;
148+
state.errorMessage = action.payload;
149+
})
150+
.addCase(applyForJob.pending, (state) => {
151+
state.isLoading = true;
152+
})
153+
.addCase(applyForJob.fulfilled, (state, action) => {
154+
state.isLoading = false;
155+
state.message = "Successfully Applied..";
156+
})
157+
.addCase(applyForJob.rejected, (state, action) => {
158+
state.isLoading = false;
159+
state.isError = true;
160+
state.errorMessage = action.payload;
161+
});
162+
},
139163
});
140164

141165
export default JobSlice.reducer;

0 commit comments

Comments
 (0)