1<template>
2 <TeamsList v-if="step === 'team-list'" @update:step="updateStep" />
3 <NewTeam v-else-if="step === 'new-team'" @update:step="updateStep" />
4 <TeamEdit
5 v-else-if="step === 'team-edit'"
6 @update:step="updateStep"
7 :team-name="teamName"
8 />
9</template>
10
11<script setup lang="ts">
12import { onUnmounted, provide, Ref, ref } from "vue";
13import TeamEdit from "./TeamEdit.vue";
14import TeamsList from "./TeamsList.vue";
15import { createListResource } from "frappe-ui";
16import NewTeam from "./NewTeam.vue";
17import { TeamListResourceSymbol } from "@/types";
18
19type TeamStep = "team-list" | "team-edit" | "new-team";
20
21const step: Ref<TeamStep> = ref("team-list");
22const teamName: Ref<string> = ref("");
23function updateStep(newStep: TeamStep, team?: string): void {
24 step.value = newStep;
25 teamName.value = team;
26}
27const teamsSearchQuery = ref("");
28
29const teams = createListResource({
30 doctype: "OD Team",
31 cache: ["Teams"],
32 fields: ["name", "disabled"],
33 auto: true,
34 orderBy: "modified desc",
35 start: 0,
36 pageLength: 20,
37});
38
39provide("teamsSearchQuery", teamsSearchQuery);
40provide(TeamListResourceSymbol, teams);
41
42onUnmounted(() => {
43 teamsSearchQuery.value = "";
44 teams.filters = {};
45});
46</script>
47
48<style scoped></style>
49