forked from
rocksky.app/rocksky
A decentralized music tracking and discovery platform built on AT Protocol 馃幍
1import { useMutation } from "@tanstack/react-query";
2import axios from "axios";
3import { joinBeta } from "../api/beta";
4import { API_URL } from "../consts";
5
6export const useJoinBetaMutation = () =>
7 useMutation({
8 mutationFn: ({ email, platform }: { email: string; platform: string }) =>
9 joinBeta(email, platform),
10 });
11
12function useBeta() {
13 const headers = {
14 authorization: `Bearer ${localStorage.getItem("token")}`,
15 };
16 const joinBeta = async (email: string, platform: string) => {
17 switch (platform) {
18 case "spotify":
19 return await axios.post(
20 `${API_URL}/spotify/join`,
21 { email },
22 { headers },
23 );
24 case "google":
25 return await axios.post(
26 `${API_URL}/googledrive/join`,
27 { email },
28 { headers },
29 );
30 case "dropbox":
31 return await axios.post(
32 `${API_URL}/dropbox/join`,
33 { email },
34 { headers },
35 );
36 default:
37 return;
38 }
39 };
40
41 return { joinBeta };
42}
43
44export default useBeta;