File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed
src/components/leaderboard Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 9696 "genericError" : " Error joining leaderboard" ,
9797 "join" : " Join" ,
9898 "leaderboardCode" : " Leaderboard code" ,
99- "leaderboardCodeInvalid" : " Leaderboard code must start with \" ttlic_\" , and be followed by 24 alphanumeric characters." ,
99+ "leaderboardCodeInvalid" : " Leaderboard code must start with \" ttlic_\" , and be followed by 32 alphanumeric characters." ,
100100 "leaderboardCodeRequired" : " Leaderboard code is required" ,
101101 "notFound" : " Leaderboard not found"
102102 },
Original file line number Diff line number Diff line change 9696 "genericError" : " Tulostauluun liittyminen epäonnistui." ,
9797 "join" : " Liity" ,
9898 "leaderboardCode" : " Tulostaulukoodi" ,
99- "leaderboardCodeInvalid" : " Kutsukoodin tulee alkaa \" ttlic_\" , ja sen jälkeen täytyy olla 24 alphanumeerista kirjainta." ,
99+ "leaderboardCodeInvalid" : " Kutsukoodin tulee alkaa \" ttlic_\" , ja sen jälkeen täytyy olla 32 alphanumeerista kirjainta." ,
100100 "leaderboardCodeRequired" : " Kutsukoodi vaaditaan." ,
101101 "notFound" : " Tulostaulua ei löytynyt."
102102 },
Original file line number Diff line number Diff line change @@ -5,15 +5,27 @@ import {
55 postRequestWithoutResponse ,
66 postRequestWithResponse ,
77} from "../../api/baseApi" ;
8+ import { JoinLeaderboardError } from "../../types" ;
89
9- export const joinLeaderboard = ( inviteCode : string ) =>
10- postRequestWithResponse < {
10+ export const joinLeaderboard = async ( inviteCode : string ) => {
11+ const response = await postRequestWithResponse < {
1112 name : string ;
1213 member_count : number ;
1314 } > ( "/leaderboards/join" , {
1415 invite : inviteCode ,
1516 } ) ;
1617
18+ if ( "error" in response ) {
19+ if ( response . statusCode === 404 ) {
20+ return { error : JoinLeaderboardError . NotFound } ;
21+ } else if ( response . statusCode === 409 ) {
22+ return { error : JoinLeaderboardError . AlreadyMember } ;
23+ }
24+ }
25+
26+ return response ;
27+ } ;
28+
1729export const leaveLeaderboard = async ( leaderboardName : string ) => {
1830 const data = await postRequestWithoutResponse (
1931 `/leaderboards/${ leaderboardName } /leave` ,
You can’t perform that action at this time.
0 commit comments