Skip to content
Snippets Groups Projects
Commit d1e321f0 authored by Albin Henriksson's avatar Albin Henriksson
Browse files

Resolve "Remove proxy"

parent 5ee7eee1
No related branches found
No related tags found
1 merge request!90Resolve "Remove proxy"
Pipeline #42018 passed with warnings
Showing
with 44 additions and 41 deletions
......@@ -96,5 +96,5 @@
"html"
]
},
"proxy": "http://localhost:5000/api/"
"proxy": "http://localhost:5000/"
}
......@@ -4,7 +4,7 @@ import Types from './types'
export const getCities = () => async (dispatch: AppDispatch) => {
await axios
.get('/misc/cities')
.get('/api/misc/cities')
.then((res) => {
dispatch({
type: Types.SET_CITIES,
......
......@@ -15,7 +15,7 @@ export const getCompetitions = () => async (dispatch: AppDispatch, getState: ()
year: currentParams.year,
}
await axios
.get('/competitions/search', { params })
.get('/api/competitions/search', { params })
.then((res) => {
dispatch({
type: Types.SET_COMPETITIONS,
......
......@@ -4,7 +4,7 @@ import Types from './types'
export const getEditorCompetition = (id: string) => async (dispatch: AppDispatch, getState: () => RootState) => {
await axios
.get(`/competitions/${id}`)
.get(`/api/competitions/${id}`)
.then((res) => {
dispatch({
type: Types.SET_EDITOR_COMPETITION,
......
......@@ -6,7 +6,7 @@ import Types from './types'
export const getPresentationCompetition = (id: string) => async (dispatch: AppDispatch) => {
await axios
.get(`/competitions/${id}`)
.get(`/api/competitions/${id}`)
.then((res) => {
dispatch({
type: Types.SET_PRESENTATION_COMPETITION,
......@@ -20,7 +20,7 @@ export const getPresentationCompetition = (id: string) => async (dispatch: AppDi
export const getPresentationTeams = (id: string) => async (dispatch: AppDispatch) => {
await axios
.get(`/competitions/${id}/teams`)
.get(`/api/competitions/${id}/teams`)
.then((res) => {
dispatch({
type: Types.SET_PRESENTATION_TEAMS,
......
......@@ -4,7 +4,7 @@ import Types from './types'
export const getRoles = () => async (dispatch: AppDispatch) => {
await axios
.get('/misc/roles')
.get('/api/misc/roles')
.then((res) => {
dispatch({
type: Types.SET_ROLES,
......
......@@ -15,7 +15,7 @@ export const getSearchUsers = () => async (dispatch: AppDispatch, getState: () =
email: currentParams.email,
}
await axios
.get('/users/search', { params })
.get('/api/users/search', { params })
.then((res) => {
dispatch({
type: Types.SET_SEARCH_USERS,
......
......@@ -4,7 +4,7 @@ import Types from './types'
export const getTypes = () => async (dispatch: AppDispatch) => {
await axios
.get('/misc/types')
.get('/api/misc/types')
.then((res) => {
dispatch({
type: Types.SET_TYPES,
......
......@@ -7,7 +7,7 @@ import Types from './types'
export const loginUser = (userData: AccountLoginModel, history: History) => async (dispatch: AppDispatch) => {
dispatch({ type: Types.LOADING_UI })
await axios
.post('/auth/login', userData)
.post('/api/auth/login', userData)
.then((res) => {
const token = `Bearer ${res.data.access_token}`
localStorage.setItem('token', token) //setting token to local storage
......@@ -28,7 +28,7 @@ export const loginUser = (userData: AccountLoginModel, history: History) => asyn
export const getUserData = () => async (dispatch: AppDispatch) => {
dispatch({ type: Types.LOADING_USER })
await axios
.get('/users')
.get('/api/users')
.then((res) => {
dispatch({
type: Types.SET_USER,
......@@ -42,7 +42,7 @@ export const getUserData = () => async (dispatch: AppDispatch) => {
export const logoutUser = () => async (dispatch: AppDispatch) => {
localStorage.removeItem('token')
await axios.post('/auth/logout').then(() => {
await axios.post('/api/auth/logout').then(() => {
delete axios.defaults.headers.common['Authorization']
dispatch({
type: Types.SET_UNAUTHENTICATED,
......
......@@ -63,7 +63,7 @@ const AddCompetition: React.FC = (props: any) => {
}
await axios
.post('/competitions', params) // send to database
.post('/api/competitions', params) // send to database
.then(() => {
actions.resetForm() // reset the form
setAnchorEl(null)
......
......@@ -82,7 +82,7 @@ const CompetitionManager: React.FC = (props: any) => {
const handleDeleteCompetition = async () => {
if (activeId) {
await axios
.delete(`/competitions/${activeId}`)
.delete(`/api/competitions/${activeId}`)
.then(() => {
setAnchorEl(null)
dispatch(getCompetitions()) // refresh the competition list
......@@ -101,7 +101,7 @@ const CompetitionManager: React.FC = (props: any) => {
const handleDuplicateCompetition = async () => {
if (activeId) {
await axios
.post(`/competitions/${activeId}/copy`)
.post(`/api/competitions/${activeId}/copy`)
.then(() => {
setAnchorEl(null)
dispatch(getCompetitions())
......
......@@ -51,7 +51,7 @@ const AddRegion: React.FC = (props: any) => {
name: values.model.name,
}
await axios
.post('/misc/cities', params)
.post('/api/misc/cities', params)
.then(() => {
actions.resetForm()
dispatch(getCities())
......
......@@ -45,7 +45,7 @@ const RegionManager: React.FC = (props: any) => {
const handleDeleteCity = async () => {
if (activeId) {
await axios
.delete(`/misc/cities/${activeId}`)
.delete(`/api/misc/cities/${activeId}`)
.then(() => {
setAnchorEl(null)
dispatch(getCities())
......@@ -63,7 +63,7 @@ const RegionManager: React.FC = (props: any) => {
const handleAddCity = async () => {
await axios
.post(`/misc/cities`, { name: newCity })
.post(`/api/misc/cities`, { name: newCity })
.then(() => {
setAnchorEl(null)
dispatch(getCities())
......
......@@ -59,7 +59,7 @@ const AddUser: React.FC = (props: any) => {
role_id: selectedRole?.id as number,
}
await axios
.post('/auth/signup', params)
.post('/api/auth/signup', params)
.then(() => {
actions.resetForm()
setAnchorEl(null)
......
......@@ -110,7 +110,7 @@ const EditUser = ({ user }: UserIdProps) => {
const handleDeleteUsers = async () => {
setOpen(false)
await axios
.delete(`/auth/delete/${user.id}`)
.delete(`/api/auth/delete/${user.id}`)
.then(() => {
setAnchorEl(null)
dispatch(getSearchUsers())
......@@ -141,7 +141,7 @@ const EditUser = ({ user }: UserIdProps) => {
req['role_id'] = params.role_id
}
await axios
.put('/users/' + user.id, req)
.put('/api/users/' + user.id, req)
.then((res) => {
setAnchorEl(null)
dispatch(getSearchUsers())
......
......@@ -28,7 +28,7 @@ it('renders presentation editor', () => {
},
}
;(mockedAxios.get as jest.Mock).mockImplementation((path: string, params?: any) => {
if (path.startsWith('/competitions')) return Promise.resolve(competitionRes)
if (path.startsWith('/api/competitions')) return Promise.resolve(competitionRes)
return Promise.resolve(citiesRes)
})
render(
......
......@@ -104,7 +104,7 @@ const PresentationEditorPage: React.FC = () => {
}
const createNewSlide = async () => {
await axios.post(`/competitions/${id}/slides`, { title: 'new slide' })
await axios.post(`/api/competitions/${id}/slides`, { title: 'new slide' })
dispatch(getEditorCompetition(id))
}
......@@ -128,13 +128,13 @@ const PresentationEditorPage: React.FC = () => {
}
const handleRemoveSlide = async () => {
await axios.delete(`/competitions/${id}/slides/${contextState.slideId}`)
await axios.delete(`/api/competitions/${id}/slides/${contextState.slideId}`)
dispatch(getEditorCompetition(id))
setContextState(initialState)
}
const handleDuplicateSlide = async () => {
await axios.post(`/competitions/${id}/slides/${contextState.slideId}/copy`)
await axios.post(`/api/competitions/${id}/slides/${contextState.slideId}/copy`)
dispatch(getEditorCompetition(id))
setContextState(initialState)
}
......
......@@ -77,7 +77,7 @@ const CompetitionSettings: React.FC = () => {
const competition = useAppSelector((state) => state.editor.competition)
const updateCompetitionName = async (event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => {
await axios
.put(`/competitions/${id}`, { name: event.target.value })
.put(`/api/competitions/${id}`, { name: event.target.value })
.then(() => {
dispatch(getEditorCompetition(id))
})
......@@ -87,7 +87,7 @@ const CompetitionSettings: React.FC = () => {
const cities = useAppSelector((state) => state.cities.cities)
const updateCompetitionCity = async (city: City) => {
await axios
.put(`/competitions/${id}`, { city_id: city.id })
.put(`/api/competitions/${id}`, { city_id: city.id })
.then(() => {
dispatch(getEditorCompetition(id))
})
......@@ -104,7 +104,7 @@ const CompetitionSettings: React.FC = () => {
const removeTeam = async (tid: number) => {
await axios
.delete(`/competitions/${id}/teams/${tid}`)
.delete(`/api/competitions/${id}/teams/${tid}`)
.then(() => {
dispatch(getEditorCompetition(id))
})
......@@ -113,7 +113,7 @@ const CompetitionSettings: React.FC = () => {
const addTeam = async () => {
setAddTeamOpen(false)
await axios
.post(`/competitions/${id}/teams`, { name: selectedTeamName })
.post(`/api/competitions/${id}/teams`, { name: selectedTeamName })
.then(() => {
dispatch(getEditorCompetition(id))
})
......
......@@ -20,13 +20,13 @@ const RndComponent = ({ component }: ImageComponentProps) => {
const competitionId = useAppSelector((state) => state.editor.competition.id)
const slideId = useAppSelector((state) => state.editor.activeSlideId)
const handleUpdatePos = (pos: Position) => {
axios.put(`/competitions/${competitionId}/slides/${slideId}/components/${component.id}`, {
axios.put(`/api/competitions/${competitionId}/slides/${slideId}/components/${component.id}`, {
x: pos.x,
y: pos.y,
})
}
const handleUpdateSize = (size: Size) => {
axios.put(`/competitions/${competitionId}/slides/${slideId}/components/${component.id}`, {
axios.put(`/api/competitions/${competitionId}/slides/${slideId}/components/${component.id}`, {
w: size.w,
h: size.h,
})
......
......@@ -133,7 +133,7 @@ const SlideSettings: React.FC = () => {
if (selectedSlideType === 0) {
// Change slide type from a question type to information
await axios
.delete(`/competitions/${id}/slides/${activeSlide.id}/questions/${activeSlide.questions[0].id}`)
.delete(`/api/competitions/${id}/slides/${activeSlide.id}/questions/${activeSlide.questions[0].id}`)
.then(() => {
dispatch(getEditorCompetition(id))
})
......@@ -141,10 +141,10 @@ const SlideSettings: React.FC = () => {
} else {
// Change slide type from question type to another question type
await axios
.delete(`/competitions/${id}/slides/${activeSlide.id}/questions/${activeSlide.questions[0].id}`)
.delete(`/api/competitions/${id}/slides/${activeSlide.id}/questions/${activeSlide.questions[0].id}`)
.catch(console.log)
await axios
.post(`/competitions/${id}/slides/${activeSlide.id}/questions`, {
.post(`/api/competitions/${id}/slides/${activeSlide.id}/questions`, {
name: 'Ny fråga',
total_score: 0,
type_id: selectedSlideType,
......@@ -158,7 +158,7 @@ const SlideSettings: React.FC = () => {
} else if (selectedSlideType !== 0) {
// Change slide type from information to a question type
await axios
.post(`/competitions/${id}/slides/${activeSlide.id}/questions`, {
.post(`/api/competitions/${id}/slides/${activeSlide.id}/questions`, {
name: 'Ny fråga',
total_score: 0,
type_id: selectedSlideType,
......@@ -208,10 +208,13 @@ const SlideSettings: React.FC = () => {
const addAlternative = async () => {
if (activeSlide && activeSlide.questions[0]) {
await axios
.post(`/competitions/${id}/slides/${activeSlide?.id}/questions/${activeSlide?.questions[0].id}/alternatives`, {
text: '',
value: 0,
})
.post(
`/api/competitions/${id}/slides/${activeSlide?.id}/questions/${activeSlide?.questions[0].id}/alternatives`,
{
text: '',
value: 0,
}
)
.then(() => {
dispatch(getEditorCompetition(id))
})
......@@ -237,7 +240,7 @@ const SlideSettings: React.FC = () => {
const handleAddText = async () => {
if (activeSlide) {
await axios.post(`/competitions/${id}/slides/${activeSlide?.id}/components`, {
await axios.post(`/api/competitions/${id}/slides/${activeSlide?.id}/components`, {
type_id: 1,
data: { text: 'Ny text' },
w: 315,
......@@ -261,7 +264,7 @@ const SlideSettings: React.FC = () => {
setTimer(+event.target.value)
if (activeSlide) {
await axios
.put(`/competitions/${id}/slides/${activeSlide.id}`, { timer: event.target.value })
.put(`/api/competitions/${id}/slides/${activeSlide.id}`, { timer: event.target.value })
.then(() => {
dispatch(getEditorCompetition(id))
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment