quick fixes

This commit is contained in:
yohlo
2025-10-06 13:33:25 -05:00
parent 45db283bc5
commit 49bbd1611c
4 changed files with 12 additions and 13 deletions

View File

@@ -19,6 +19,10 @@ const SpotifyControlsBar = () => {
const isAdmin = roles?.includes('Admin') || false;
const [sheetOpened, { open: openSheet, close: closeSheet }] = useDisclosure(false);
const spotify = useSpotify();
if (!isAdmin || !spotify) return null;
const {
isAuthenticated,
playbackState,
@@ -35,9 +39,7 @@ const SpotifyControlsBar = () => {
isResumeLoading,
capturePlaybackState,
resumePlaybackState,
} = useSpotify();
if (!isAdmin) return null;
} = spotify;
if (!isAuthenticated) {
return (

View File

@@ -27,7 +27,9 @@ interface SpotifySheetProps {
const SpotifySheet: React.FC<SpotifySheetProps> = ({ opened, onClose }) => {
const { roles } = useAuth();
const isAdmin = roles?.includes('Admin') || false;
const spotify = useSpotify();
if (!isAdmin || !spotify) return null;
const {
isAuthenticated,
login,
@@ -39,7 +41,7 @@ const SpotifySheet: React.FC<SpotifySheetProps> = ({ opened, onClose }) => {
setActiveDevice,
isLoading,
error,
} = useSpotify();
} = spotify;
if (!isAdmin) return null;

View File

@@ -37,9 +37,9 @@ export const createTeam = createServerFn()
const userId = context.userAuthId;
const isAdmin = context.roles.includes("Admin");
if (!isAdmin && !data.players.includes(userId)) {
throw new Error("You can only create teams that include yourself as a player");
}
//if (!isAdmin && !data.players.includes(userId)) {
// throw new Error("You can only create teams that include yourself as a player");
//}
logger.info("Creating team", { name: data.name, userId, isAdmin });
return pbAdmin.createTeam(data);

View File

@@ -2,13 +2,8 @@ import { useContext } from 'react';
import { SpotifyContext } from '@/contexts/spotify-context';
import type { SpotifyContextType } from './types';
export const useSpotify = (): SpotifyContextType => {
export const useSpotify = (): SpotifyContextType | null => {
const context = useContext(SpotifyContext);
if (!context) {
throw new Error('useSpotify must be used within a SpotifyProvider');
}
return context;
};