better brackets, info types
This commit is contained in:
@@ -1,10 +1,26 @@
|
||||
import { logger } from "@/lib/logger";
|
||||
import PocketBase from "pocketbase";
|
||||
import { transformTeam } from "@/lib/pocketbase/util/transform-types";
|
||||
import { Team } from "@/features/teams/types";
|
||||
import { transformTeam, transformTeamInfo } from "@/lib/pocketbase/util/transform-types";
|
||||
import { Team, TeamInfo } from "@/features/teams/types";
|
||||
import { DataFetchOptions } from "./base";
|
||||
|
||||
export function createTeamsService(pb: PocketBase) {
|
||||
return {
|
||||
async getTeamInfo(id: string): Promise<TeamInfo> {
|
||||
logger.info("PocketBase | Getting team info", id);
|
||||
const result = await pb.collection("teams").getOne(id, {
|
||||
fields: "id,name,primary_color,accent_color"
|
||||
});
|
||||
return transformTeamInfo(result);
|
||||
},
|
||||
|
||||
async listTeamInfos(): Promise<TeamInfo[]> {
|
||||
logger.info("PocketBase | Listing team infos");
|
||||
const result = await pb.collection("teams").getFullList({
|
||||
fields: "id,name,primary_color,accent_color"
|
||||
});
|
||||
return result.map(transformTeamInfo);
|
||||
},
|
||||
async getTeam(id: string): Promise<Team | null> {
|
||||
logger.info("PocketBase | Getting team", id);
|
||||
const result = await pb.collection("teams").getOne(id, {
|
||||
|
||||
Reference in New Issue
Block a user