Skip to content

Commit b1e7d45

Browse files
authored
PR463: Front end auth checkup (#499)
* PR463: Front end auth checkup * PR463: Prettier and eslint adjustments * PR463: Adding api to programs api calls
1 parent cf05aef commit b1e7d45

13 files changed

+33
-34
lines changed

frontend/.babelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
["@babel/plugin-proposal-decorators", { "legacy": true }],
66
["@babel/plugin-proposal-class-properties", { "loose": true }, "classes-alias"],
77
["@babel/plugin-proposal-private-methods", { "loose": true }, "methods-alias"]
8-
]
8+
],
9+
"sourceMaps": true
910
}

frontend/src/api/authEndpoints.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import cookieValue, { setAuthCookie } from "./cookies"
22

33
export const createToken = api => async (username, password) => {
4-
const response = await api.post("/token/", { username, password })
4+
const response = await api.post("/api/token/", { username, password })
55
if (response.ok) {
66
setAuthCookie("JWT_ACCESS", response.data.access)
77
setAuthCookie("JWT_REFRESH", response.data.refresh)
@@ -11,6 +11,6 @@ export const createToken = api => async (username, password) => {
1111

1212
export const verifyToken = api => async () => {
1313
const accessToken = cookieValue("JWT_ACCESS")
14-
const response = await api.post("/token/verify/", { token: accessToken })
14+
const response = await api.post("/api/token/verify/", { token: accessToken })
1515
return response
1616
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export const getFrontDeskEvent = api => async id =>
2-
await api.get(`/front-desk-events/${id}/`)
2+
await api.get(`/api/front-desk-events/${id}/`)
33

44
export const postFrontDeskEvent = api => async data =>
5-
await api.post("/front-desk-events/", data)
5+
await api.post("/api/front-desk-events/", data)
66

77
export const patchFrontDeskEvent = api => async (id, data) =>
8-
await api.patch(`/front-desk-events/${id}/`, data)
8+
await api.patch(`/api/front-desk-events/${id}/`, data)

frontend/src/api/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ import { createSEP, getSepDataByVisitId } from "./sepEndpoints"
2424
import cookieValue from "./cookies"
2525

2626
const create = () => {
27-
const api = apisauce.create({
28-
baseURL: "/api",
29-
})
27+
const api = apisauce.create({})
3028

3129
createAuthRefreshInterceptor(api.axiosInstance, refreshAuthLogic(api))
3230

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const getInsurers = api => async () => await api.get("insurers/")
1+
export const getInsurers = api => async () => await api.get("/api/insurers/")

frontend/src/api/participantEndpoints.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,26 @@ const removeEmptyParams = params => {
1212
export const getParticipants = api => async params => {
1313
const queryParams = queryString.stringify(removeEmptyParams(params))
1414
return await api.get(
15-
queryParams ? `participants/?${queryParams}` : "participants/"
15+
queryParams ? `/api/participants/?${queryParams}` : "/api/participants/"
1616
)
1717
}
1818

1919
export const getParticipantById = api => async id =>
20-
await api.get(`participants/${id}/`)
20+
await api.get(`/api/participants/${id}/`)
2121

2222
export const getParticipantByName = api => async (firstname, lastname) =>
23-
await api.get(`participants/?first_name=${firstname}&last_name=${lastname}`)
23+
await api.get(
24+
`/api/participants/?first_name=${firstname}&last_name=${lastname}`
25+
)
2426

2527
export const getParticipant = api => async id =>
26-
await api.get(`/participants/${id}`)
28+
await api.get(`/api/participants/${id}`)
2729

2830
export const getParticipantVisits = api => async id =>
29-
await api.get(`/participants/${id}/visits/`)
31+
await api.get(`/api/participants/${id}/visits/`)
3032

3133
export const updateParticipant = api => async (id, body) =>
32-
await api.put(`/participants/${id}/`, body)
34+
await api.put(`/api/participants/${id}/`, body)
3335

3436
export const createParticipant = api => async body =>
35-
await api.post("/participants/", body)
36-
37-
// export const postParticipant = api => async (id, body) =>
38-
// await api.post(`/participant/${id}`, body)
37+
await api.post("/api/participants/", body)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export const getPrograms = api => async () => api.get("programs/")
2-
export const getProgram = api => async id => api.get(`programs/${id}/`)
1+
export const getPrograms = api => async () => api.get("/api/programs/")
2+
export const getProgram = api => async id => api.get(`/api/programs/${id}/`)
33
export const patchProgram = api => async (id, body) =>
4-
api.patch(`programs/${id}/`, body)
4+
api.patch(`/api/programs/${id}/`, body)
55

66
document.getElementsByClassName("header")

frontend/src/api/queueEndpoints.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export const getQueue = api => async programId =>
2-
await api.get(`programs/${programId}/queue/`)
2+
await api.get(`/api/programs/${programId}/queue/`)

frontend/src/api/refreshAuthLogic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import cookieValue, { setAuthCookie } from "./cookies"
22

33
const refreshAuthLogic = api => async failedRequest => {
44
const refreshToken = cookieValue("JWT_REFRESH")
5-
const tokenRefreshResponse = await api.post("/token/refresh/", {
5+
const tokenRefreshResponse = await api.post("/api/token/refresh/", {
66
refresh: refreshToken,
77
})
88
setAuthCookie("JWT_ACCESS", tokenRefreshResponse.data.access)

frontend/src/api/sepEndpoints.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export const createSEP = api => async body => await api.post("/sep/", body)
1+
export const createSEP = api => async body => await api.post("/api/sep/", body)
22
export const getSepDataByVisitId = api => async visitId =>
3-
await api.get(`/sep?visit_id=${visitId}`)
3+
await api.get(`/api/sep?visit_id=${visitId}`)

0 commit comments

Comments
 (0)