Skip to content

Commit

Permalink
added spinner for promote/demote
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankreedX committed Aug 15, 2024
1 parent 93695d3 commit f9647d5
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions app/content/team/users/[user]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import { useLocalSearchParams, useNavigation } from "expo-router";
import { doc, setDoc, updateDoc } from "firebase/firestore";
import { useState } from "react";
import { FlatList, View } from "react-native";
import { Appbar, Divider, Menu, SegmentedButtons } from "react-native-paper";
import {
ActivityIndicator,
Appbar,
Divider,
Menu,
SegmentedButtons,
Text,
} from "react-native-paper";
import { SafeAreaView } from "react-native-safe-area-context";
import { themeColors } from "~/Constants";
import { getErrorString } from "~/Utility";
Expand Down Expand Up @@ -71,6 +78,8 @@ function Index() {
const hideBanDialog = () => setBanDialogVisible(false);
const [banLoading, setBanLoading] = useState(false);

const [promoteLoading, setPromoteLoading] = useState(false);

const { showDialog, showSnackBar } = useAlertContext();

const { currentUserId, currentTeamId } = useAuthContext();
Expand Down Expand Up @@ -246,6 +255,7 @@ function Index() {
}
onPress={async () => {
try {
setPromoteLoading(true);
await changeRole(
currentTeamId,
userId,
Expand All @@ -258,8 +268,19 @@ function Index() {
console.log(e);
showDialog("Error", getErrorString(e));
}
setPromoteLoading(false);
}}
title={userInfo.role === "player" ? "Promote" : "Demote"}
title={
<>
{promoteLoading ? (
<ActivityIndicator color={"#1C1B1F"} />
) : (
<Text>
{userInfo.role === "player" ? "Promote" : "Demote"}
</Text>
)}
</>
}
/>
<Divider />
<Menu.Item
Expand Down

0 comments on commit f9647d5

Please sign in to comment.