summaryrefslogtreecommitdiff
path: root/client/src/mocks/handlers.ts
blob: 153a70cc43aecd98a5d2e1a70ed6b5af40491d21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { http, HttpResponse } from 'msw';
import { nanoid } from '@reduxjs/toolkit';

const token = nanoid();

export const initialGuest = {
  guest: {
    id: 1,
    firstName: 'Michael',
    lastName: 'Hunteman',
    attendance: 'decline',
    email: '',
    message: '',
    partySize: 1,
  },
  token: token,
};

export const updatedGuest = {
  id: 1,
  firstName: 'Michael',
  lastName: 'Hunteman',
  attendance: 'accept',
  email: 'mhunteman@cox.net',
  message: '',
  partySize: 1,
  partyList: [],
};

export const guests = {
  guests: [initialGuest],
  token: token,
};

export const handlers = [
  http.post(`${import.meta.env.VITE_BASE_URL}guests/login`, () => {
    return HttpResponse.json(initialGuest);
  }),
  http.put(`${import.meta.env.VITE_BASE_URL}guests/1`, () => {
    return HttpResponse.json(updatedGuest);
  }),
  http.post(`${import.meta.env.VITE_BASE_URL}admin/login`, () => {
    return HttpResponse.json(guests);
  }),
];