You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

login.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { fetchQueueByProfileId } from '../services'
  2. class Login {
  3. constructor() {
  4. this.currentProfileId = null
  5. this.survey = null
  6. this.queue = null
  7. this.matches = null
  8. }
  9. _setSurvey(survey) {
  10. this.survey = []
  11. }
  12. async getQueue() {
  13. this.queue = null
  14. try {
  15. const queueList = await fetchQueueByProfileId(this.currentProfileId)
  16. const formatted = this._reformatProfiles(queueList)
  17. this._SET_QUEUE(formatted)
  18. } catch (err) {
  19. console.error(err)
  20. }
  21. }
  22. _reformatProfiles(profiles) {
  23. const formattedList = profiles.map(profile => {
  24. return {
  25. pid: profile.profile_id,
  26. name: profile.user_name,
  27. avatar: profile.user_media,
  28. }
  29. })
  30. return formattedList
  31. }
  32. _SET_QUEUE(queue) {
  33. this.queue = queue
  34. }
  35. logout() {
  36. this.currentProfileId = null
  37. }
  38. async login(pid) {
  39. this.currentProfileId = parseInt(pid)
  40. }
  41. }
  42. export { Login }