@@ -4,7 +4,7 @@ import { useOfflineVoting } from "@/hooks/useOfflineVoting";
44import { useUserPermissionsQuery } from "@/hooks/queries/auth/useUserPermissions" ;
55import { useOfflineSetsData } from "@/hooks/useOfflineSetsData" ;
66
7- export function useSetDetail ( slug : string | undefined ) {
7+ export function useSetDetail ( setId : string | undefined ) {
88 const { user, loading : authLoading } = useAuth ( ) ;
99 const { data : canEdit = false , isLoading : isLoadingPermissions } =
1010 useUserPermissionsQuery ( user ?. id , "edit_artists" ) ;
@@ -14,16 +14,16 @@ export function useSetDetail(slug: string | undefined) {
1414
1515 const sets = setsQuery . sets ;
1616 const currentSet = useMemo ( ( ) => {
17- if ( ! slug || ! sets . length ) {
17+ if ( ! setId || ! sets . length ) {
1818 return null ;
1919 }
2020
21- return sets . find ( ( a ) => a . slug === slug ) || null ;
22- } , [ slug , sets ] ) ;
21+ return sets . find ( ( a ) => a . id === setId ) || null ;
22+ } , [ setId , sets ] ) ;
2323
2424 async function handleVoteAction ( voteType : number ) {
25- if ( ! currentSet ?. id ) return ;
26- await handleVote ( currentSet . id , voteType ) ;
25+ if ( ! setId ) return ;
26+ await handleVote ( setId , voteType ) ;
2727 }
2828
2929 function getVoteCount ( voteType : number ) {
@@ -38,11 +38,9 @@ export function useSetDetail(slug: string | undefined) {
3838 ? 2 * getVoteCount ( 2 ) + getVoteCount ( 1 ) - getVoteCount ( - 1 )
3939 : 0 ;
4040
41- const userVote = userVotes [ currentSet ?. id || "" ] || null ;
41+ const userVote = userVotes [ setId || "" ] || null ;
4242
4343 return {
44- currentSet,
45- user,
4644 userVote,
4745 loading : authLoading || isLoadingPermissions || setsQuery . loading ,
4846 canEdit,
0 commit comments