nicmart-dev / linguistnow

LinguistNow simplifies the hassle of finding available linguists for translation projects.
https://linguistnow.netlify.app
1 stars 1 forks source link

Return Available Users #20

Closed nicmart-dev closed 4 months ago

nicmart-dev commented 4 months ago

Filter users based on their availability, using availability set in #19

nicmart-dev commented 4 months ago

Best to rely on n8n for more flexible business logic, but if not here is a possible starter code:

const getAvailableUsers = (users, start, end, hoursPerDay) => {
  return users.filter(user => {
    const availableSlots = checkAvailability(user.accessToken, user.calendarId, start, end);
    // Logic to check if availableSlots meet the required hours per day
    return isAvailable(availableSlots, hoursPerDay);
  });
};

const isAvailable = (availableSlots, hoursPerDay) => {
  // Implement logic to check if the user is available for the required hours per day
};
nicmart-dev commented 4 months ago

Will do this with #5 using n8n, but if issues using n8n, may fallback to this and #19