Skip to content

Commit

Permalink
readme updated, services commented and redirects-file added
Browse files Browse the repository at this point in the history
  • Loading branch information
Santeriii committed Dec 11, 2020
1 parent d1f5a2a commit ac6a924
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 11 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# Tapahtumavaraus
[![Coverage Status](https://coveralls.io/repos/github/breeku/OTP1-tapahtumavaraus/badge.svg?branch=master)](https://coveralls.io/github/breeku/OTP1-tapahtumavaraus?branch=master)

## Devaus
Tapahtumavaraus is an application with which event organizers are able to gather
their events into one application and travellers may filter their events in
order to reserve tickets.

[![Coverage Status](https://coveralls.io/repos/github/breeku/OTP1-tapahtumavaraus/badge.svg?branch=master)](https://coveralls.io/github/breeku/OTP1-tapahtumavaraus?branch=master)

### Projektin kloonaus
## Devaus
@ -7,7 +12,7 @@

Vs-code:ssa tai muussa kehitysympäristössä etsi "clone repository" -toiminto, ja kopioi alla oleva linkki sen URL-kenttään:

`git clone https://gitlab.com/breeku/tapahtumavaraus.git`
`git clone https://github.com/breeku/OTP1-tapahtumavaraus`

### Riippuvuuksien asennus

Expand Down
1 change: 1 addition & 0 deletions frontend/public/_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* /index.html 200
29 changes: 29 additions & 0 deletions frontend/src/services/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import axios from 'axios'
import jwt_decode from 'jwt-decode'
import { BASEURL } from './config'

/**
*
* @param {string} email
* @param {string} password
* @returns {string} token for login
*/

export const login = async (email, password) => {
const account = {
email,
Expand All @@ -17,6 +24,16 @@ export const login = async (email, password) => {
}
}

/**
*
* @param {string} firstName
* @param {string} lastName
* @param {string} username
* @param {string} email
* @param {string} password
* @returns {string} token for login
*/

export const register = async (firstName, lastName, username, email, password) => {
try {
const account = {
Expand All @@ -36,16 +53,28 @@ export const register = async (firstName, lastName, username, email, password) =
}
}

/**
* removes token for logging out
*/

export const logout = () => {
localStorage.removeItem('token')
}

/**
* @returns {string} decoded user data
*/

export const getProfileData = () => {
const token = localStorage.getItem('token')
const decoded = jwt_decode(token)
return decoded
}

/**
* @returns {string} current token
*/

export const getToken = () => {
return localStorage.getItem('token')
}
48 changes: 40 additions & 8 deletions frontend/src/services/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,40 @@ import axios from 'axios'
import { BASEURL } from './config'
import { getToken } from './auth'

/**
*
* @param {string} language
* @param {number} resultLimit
* @param {string} tags
* @returns {string} events by search
*/

export const getEvents = async (language, resultLimit, tags) => {
const response = await axios.get(
`${BASEURL}/api/events/${language}/${resultLimit}/${tags}`,
)
return response
}

/**
*
* @param {number} eventId
* @param {boolean} fetchEvent
* @returns {string} event
*/

export const getEvent = async (eventId, fetchEvent) => {
const response = await axios.get(`${BASEURL}/api/events/${eventId}/${fetchEvent}`)
return response
}

/**
*
* @param {number} eventId
* @param {number} reservationCount
* @returns {boolean} succesful
*/

export const postReservationCount = async (eventId, reservationCount) => {
try {
const token = getToken()
Expand All @@ -32,6 +54,13 @@ export const postReservationCount = async (eventId, reservationCount) => {
}
}

/**
*
* @param {string} arvostelu
* @param {number} eventId
* @returns {boolean} succesful
*/

export const postReview = async (arvostelu, eventId) => {
try {
const token = getToken()
Expand All @@ -47,18 +76,21 @@ export const postReview = async (arvostelu, eventId) => {
}
}

/**
*
* @param {string} arvostelu
* @param {number} eventId
* @returns {boolean} succesful
*/

export const updateReview = async (arvostelu, eventId) => {
try {
const token = getToken()
await axios.post(
`${BASEURL}/api/events/review/${eventId}/update`,
arvostelu,
{
headers: {
authorization: token,
},
await axios.post(`${BASEURL}/api/events/review/${eventId}/update`, arvostelu, {
headers: {
authorization: token,
},
)
})
return true
} catch (error) {
console.log(error)
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/services/getTagNames.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import axios from 'axios'
import { BASEURL } from './config'

/**
* @returns {string} tags' names
*/

export const getTagNames = async () => {
const response = await axios.get(`${BASEURL}/api/tags/`)
return response
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/services/profileEvents.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import axios from 'axios'
import { BASEURL } from './config'

/**
*
* @param {string} token
* @returns {string} single event
*/

export const getEvent = async token => {
try {
const { data } = await axios.get(`${BASEURL}/api/user/`, {
Expand All @@ -15,6 +21,13 @@ export const getEvent = async token => {
}
}

/**
*
* @param {string} token
* @param {number} eventID
* @returns {boolean} succesful
*/

export const removeReview = async (token, eventID) => {
try {
await axios.delete(`${BASEURL}/api/events/review/${eventID}/delete`, {
Expand Down

0 comments on commit ac6a924

Please sign in to comment.