Inicjalna wersja systemu zarządzania rezerwacjami (RMS)
SPA zbudowane w React 19 + Vite 8 z pełnym zestawem funkcjonalności: autentykacja z 2FA, kreator rezerwacji, panel admina, analityka, GraphQL (Apollo Client + SchemaLink), React Query, Storybook, testy jednostkowe (Vitest + RTL) i e2e (Playwright).
This commit is contained in:
22
src/api/reservations.js
Normal file
22
src/api/reservations.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// [REQ T5] Obsługa zapytań API – CRUD rezerwacji przez Axios
|
||||
// [REQ D7] React Query – te funkcje są queryFn/mutationFn w custom hookach
|
||||
import axios from 'axios';
|
||||
import { API_URL } from '../config';
|
||||
|
||||
export const createReservation = (data) =>
|
||||
axios.post(`${API_URL}/reservations`, data).then((res) => res.data);
|
||||
|
||||
export const getAllReservations = () =>
|
||||
axios.get(`${API_URL}/reservations`).then((res) => res.data);
|
||||
|
||||
export const getReservationsBySlot = (serviceId, date) =>
|
||||
axios.get(`${API_URL}/reservations`, { params: { serviceId, date } }).then((res) => res.data);
|
||||
|
||||
export const getUserReservations = (userId) =>
|
||||
axios.get(`${API_URL}/reservations`, { params: { userId } }).then((res) => res.data);
|
||||
|
||||
export const updateReservation = (id, patch) =>
|
||||
axios.patch(`${API_URL}/reservations/${id}`, patch).then((res) => res.data);
|
||||
|
||||
export const deleteReservation = (id) =>
|
||||
axios.delete(`${API_URL}/reservations/${id}`).then((res) => res.data);
|
||||
7
src/api/services.js
Normal file
7
src/api/services.js
Normal file
@@ -0,0 +1,7 @@
|
||||
// [REQ T5] Obsługa zapytań API – pobieranie listy usług
|
||||
// [REQ D7] React Query – queryFn dla useServices hook
|
||||
import axios from 'axios';
|
||||
import { API_URL } from '../config';
|
||||
|
||||
export const getServices = () =>
|
||||
axios.get(`${API_URL}/services`).then((res) => res.data);
|
||||
37
src/api/users.js
Normal file
37
src/api/users.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// [REQ F1] System uwierzytelniania – rejestracja i weryfikacja e-mail
|
||||
// [REQ T5] Obsługa zapytań API – zarządzanie użytkownikami
|
||||
import axios from 'axios';
|
||||
import { API_URL } from '../config';
|
||||
|
||||
const makeToken = () =>
|
||||
Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2);
|
||||
|
||||
export const registerUser = async ({ name, email, password }) => {
|
||||
const { data: existing } = await axios.get(`${API_URL}/users`, { params: { email } });
|
||||
if (existing.length > 0) throw new Error('An account with this email already exists.');
|
||||
|
||||
const verificationToken = makeToken();
|
||||
const { data } = await axios.post(`${API_URL}/users`, {
|
||||
name,
|
||||
email,
|
||||
password,
|
||||
role: 'client',
|
||||
avatarUrl: `https://i.pravatar.cc/150?u=${encodeURIComponent(email)}`,
|
||||
verified: false,
|
||||
verificationToken,
|
||||
});
|
||||
return { user: data, token: verificationToken };
|
||||
};
|
||||
|
||||
export const verifyUser = async (token) => {
|
||||
const { data } = await axios.get(`${API_URL}/users`, {
|
||||
params: { verificationToken: token },
|
||||
});
|
||||
if (!data.length) throw new Error('Invalid or expired verification link.');
|
||||
const user = data[0];
|
||||
await axios.patch(`${API_URL}/users/${user.id}`, {
|
||||
verified: true,
|
||||
verificationToken: null,
|
||||
});
|
||||
return user;
|
||||
};
|
||||
Reference in New Issue
Block a user