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

View File

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

View File

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

View File

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