Lib: Add seasonpickedusers fetcher
This commit is contained in:
@ -7,6 +7,7 @@ import type {
|
|||||||
RacePick,
|
RacePick,
|
||||||
RaceResult,
|
RaceResult,
|
||||||
SeasonPick,
|
SeasonPick,
|
||||||
|
SeasonPickedUser,
|
||||||
Substitution,
|
Substitution,
|
||||||
Team,
|
Team,
|
||||||
User,
|
User,
|
||||||
@ -183,3 +184,23 @@ export const fetch_currentpickedusers = async (
|
|||||||
|
|
||||||
return currentpickedusers;
|
return currentpickedusers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch all [Users] (with the extra field "picked" that is truthy
|
||||||
|
* if the user already picked for the season) with file URLs for the avatars
|
||||||
|
*/
|
||||||
|
export const fetch_seasonpickedusers = async (
|
||||||
|
fetch: (_: any) => Promise<Response>,
|
||||||
|
): Promise<SeasonPickedUser[]> => {
|
||||||
|
const seasonpickedusers: SeasonPickedUser[] = await pb
|
||||||
|
.collection("seasonpickedusers")
|
||||||
|
.getFullList({ fetch: fetch });
|
||||||
|
|
||||||
|
seasonpickedusers.map((seasonpickeduser: SeasonPickedUser) => {
|
||||||
|
if (seasonpickeduser.avatar) {
|
||||||
|
seasonpickeduser.avatar_url = pb.files.getURL(seasonpickeduser, seasonpickeduser.avatar);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return seasonpickedusers;
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user