import { get, post, put } from '../lib/apiService';

export function getUser(id) {
  return get('nominations', `users/${id}`);
}

export function getMe() {
  return get('v2', 'auth/account');
}

export function getUserList(pageNumber = 1, search, affiliationId) {
  pageNumber = pageNumber < 1 ? 1 : pageNumber;
  return get('nominations', 'users', {
    page: pageNumber,
    search,
    affiliationId
  });
}

export function getPendingUserList(pageNumber = 1, search) {
  return get('nominations', 'users/pending', {
    page: pageNumber,
    search: search
  });
}

export function createUser(user) {
  return post('nominations', 'users', user);
}

export function updateUser({ households, ...user }) {
  return put('nominations', `users/${user.id}`, user);
}

export function approveUser(id) {
  return post('nominations', `users/${id}/approve`);
}

export function declineUser(id) {
  return post('nominations', `users/${id}/decline`);
}

@@ -806,48 +806,122 @@
 rn p
-ost('nominations', %60users/$%7Bid%7D/approve%60
+ut('v2', %60auth/approve%60, %7B%0A    uid: id,%0A    app: 'nominations',%0A    role: 'nominator',%0A    nominationLimit: 10%0A  %7D
 );%0A%7D

Fix approval endpoint