quick fix noop context
This commit is contained in:
@@ -11,6 +11,7 @@ import { BracketData } from "@/features/bracket/types";
|
|||||||
import { Match } from "@/features/matches/types";
|
import { Match } from "@/features/matches/types";
|
||||||
import BracketView from "@/features/bracket/components/bracket-view";
|
import BracketView from "@/features/bracket/components/bracket-view";
|
||||||
import { SpotifyControlsBar } from "@/features/spotify/components";
|
import { SpotifyControlsBar } from "@/features/spotify/components";
|
||||||
|
import { useAuth } from "@/contexts/auth-context";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_authed/admin/tournaments/run/$id")({
|
export const Route = createFileRoute("/_authed/admin/tournaments/run/$id")({
|
||||||
beforeLoad: async ({ context, params }) => {
|
beforeLoad: async ({ context, params }) => {
|
||||||
@@ -39,6 +40,8 @@ export const Route = createFileRoute("/_authed/admin/tournaments/run/$id")({
|
|||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const { data: tournament } = useTournament(id);
|
const { data: tournament } = useTournament(id);
|
||||||
|
const { roles } = useAuth();
|
||||||
|
const isAdmin = roles?.includes('Admin') || false;
|
||||||
|
|
||||||
const bracket: BracketData = useMemo(() => {
|
const bracket: BracketData = useMemo(() => {
|
||||||
if (!tournament.matches || tournament.matches.length === 0) {
|
if (!tournament.matches || tournament.matches.length === 0) {
|
||||||
@@ -76,7 +79,7 @@ function RouteComponent() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Container size="md" px={0}>
|
<Container size="md" px={0}>
|
||||||
<SpotifyControlsBar />
|
{ isAdmin && <SpotifyControlsBar />}
|
||||||
{tournament.matches?.length ? (
|
{tournament.matches?.length ? (
|
||||||
<BracketView bracket={bracket} showControls />
|
<BracketView bracket={bracket} showControls />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import { useMemo } from "react";
|
|||||||
import { BracketData } from "@/features/bracket/types";
|
import { BracketData } from "@/features/bracket/types";
|
||||||
import { Match } from "@/features/matches/types";
|
import { Match } from "@/features/matches/types";
|
||||||
import BracketView from "@/features/bracket/components/bracket-view";
|
import BracketView from "@/features/bracket/components/bracket-view";
|
||||||
import { SpotifyControlsBar } from "@/features/spotify/components";
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/_authed/tournaments/$id/bracket")({
|
export const Route = createFileRoute("/_authed/tournaments/$id/bracket")({
|
||||||
beforeLoad: async ({ context, params }) => {
|
beforeLoad: async ({ context, params }) => {
|
||||||
|
|||||||
@@ -13,11 +13,39 @@ export const useSpotify = (): SpotifyContextType => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const useSpotifyAuth = () => {
|
export const useSpotifyAuth = () => {
|
||||||
const { isAuthenticated, login, logout } = useSpotify();
|
const context = useSpotify();
|
||||||
|
|
||||||
|
if (!context) {
|
||||||
|
return {
|
||||||
|
isAuthenticated: false,
|
||||||
|
login: async () => {},
|
||||||
|
logout: async () => {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const { isAuthenticated, login, logout } = context;
|
||||||
return { isAuthenticated, login, logout };
|
return { isAuthenticated, login, logout };
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useSpotifyPlayback = () => {
|
export const useSpotifyPlayback = () => {
|
||||||
|
const context = useSpotify();
|
||||||
|
|
||||||
|
if (!context) {
|
||||||
|
return {
|
||||||
|
playbackState: null,
|
||||||
|
currentTrack: null,
|
||||||
|
play: async () => {},
|
||||||
|
playTrack: async () => {},
|
||||||
|
pause: async () => {},
|
||||||
|
skipNext: async () => {},
|
||||||
|
skipPrevious: async () => {},
|
||||||
|
setVolume: async () => {},
|
||||||
|
refreshPlaybackState: async () => {},
|
||||||
|
isLoading: false,
|
||||||
|
isPlaying: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
playbackState,
|
playbackState,
|
||||||
currentTrack,
|
currentTrack,
|
||||||
@@ -29,7 +57,7 @@ export const useSpotifyPlayback = () => {
|
|||||||
setVolume,
|
setVolume,
|
||||||
refreshPlaybackState,
|
refreshPlaybackState,
|
||||||
isLoading,
|
isLoading,
|
||||||
} = useSpotify();
|
} = context;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
playbackState,
|
playbackState,
|
||||||
@@ -47,14 +75,26 @@ export const useSpotifyPlayback = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const useSpotifyDevices = () => {
|
export const useSpotifyDevices = () => {
|
||||||
|
const context = useSpotify();
|
||||||
|
|
||||||
|
if (!context) {
|
||||||
|
return {
|
||||||
|
devices: [],
|
||||||
|
activeDevice: null,
|
||||||
|
getDevices: async () => {},
|
||||||
|
setActiveDevice: async () => {},
|
||||||
|
isLoading: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
devices,
|
devices,
|
||||||
activeDevice,
|
activeDevice,
|
||||||
getDevices,
|
getDevices,
|
||||||
setActiveDevice,
|
setActiveDevice,
|
||||||
isLoading,
|
isLoading,
|
||||||
} = useSpotify();
|
} = context;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
devices,
|
devices,
|
||||||
activeDevice,
|
activeDevice,
|
||||||
|
|||||||
Reference in New Issue
Block a user