Hello!
I am wondering if there is a way to have my app display available shifts that users are able to claim if they are available. But also limit the user to only claiming two shifts per month. For example:
- 4/1/2022 has a morning and afternoon shift, so a user selects which shift the want and claims it, making it unavailable for other users.
- 4/2/2022 only has a morning shift available, so a user can claim the morning but not the afternoon shift.
- 4/3/2022 has a morning and afternoon shift available, but the user has already claimed 2 shifts for the calendar month and is therefore not able to claim any additional shifts unless they release a shift they already have.
Does anyone know of a way to implement a feature like this?
Any help is appreciated, thank you!
I think you can do it like this.
Add a form for admins to add shifts, with fields indicating which date it falls in, and what type is it (morning or afternoon).
Then, show a button in the details view of each shift, have a button for users to claim that shift. Set their email to a column in the row, let’s say “Claim Email”. Hide the button when “Claim Email” is not empty.
I don’t know if you have to face a race condition when multiple users will try to claim a shift at the same time, if yes, I would use Integromat/Make to sequentially process the claims, it might be a safer approach.
You would need to create some columns for this one.
For the Shifts table:
- A math column to derive the month of the shift: MONTH(T) with T being the date of the shift.
- A math column to derive the year of the shift: YEAR(T)
- A template column to join the month, the year and the email of the claimer. It would look something like: 3 - 2022 - example@example.com
For the Users table:
- A math column to derive the month of today’s date: MONTH(T) with T being the “now” value.
- A math column to derive the year of today’s date: YEAR(T).
- A template column to join the month, the year and the email of the user. It would look something like: 3 - 2022 - example@example.com
Create a multiple relation from the template column in the Users table to the template column in the Shifts table. Have a rollup to count the number of shifts that users have claimed this month.
So the final condition for the claim button would be:
Claim Email is empty
AND
Signed-in user’s Month Claim count less than 2.
1 Like