quick fixes
This commit is contained in:
@@ -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 (
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user