diff --git a/src/FLAD/Model/StubManager.tsx b/src/FLAD/Model/StubManager.tsx deleted file mode 100644 index 10caca9..0000000 --- a/src/FLAD/Model/StubManager.tsx +++ /dev/null @@ -1,129 +0,0 @@ -// import { useState } from "react"; -// import SpotifyService from "../services/spotify/spotify.service"; -// import { makeRedirectUri, useAuthRequest } from 'expo-auth-session'; - -// class StubManager{ - -// // injection de dépences -// spotifyService = new SpotifyService(); -// // userService = new userService(); - -// private currentUser = useState(null); -// private discovery = { -// authorizationEndpoint: 'https://accounts.spotify.com/authorize', -// tokenEndpoint: 'https://accounts.spotify.com/api/token', -// }; -// constructor() { -// } - -// // spotify methods -// apiAuthorization(url : string){ -// const [, response, promptAsync] = useAuthRequest( -// { -// clientId: '1f1e34e4b6ba48b388469dba80202b10', -// scopes: ['user-read-email', 'playlist-modify-public'], -// // In order to follow the "Authorization Code Flow" to fetch token after authorizationEndpoint -// // this must be set to false -// usePKCE: false, -// redirectUri: makeRedirectUri({ -// scheme: 'flad' -// }), -// }, -// this.discovery -// ); - - -// } - -// getCompleteMusic = async (id : string) :Promise =>{ -// // Map info = await spotifyService.getTrackInfo(id); -// // return Music(id, info['name'], info['artist'], info['cover']); -// } - -// removeFromPlaylist(id : string) { -// this.spotifyService.removeFromPlaylist(id); -// } - - -// addToPlaylist(id : string) { -// this.spotifyService.addToPlaylist(id); -// } - -// playTrack(id : string) { -// this.spotifyService.playTrack(id); -// } -// //////////////////////////////////////////// - -// // private readonly getTaskById: RequestHandler = async ( -// // req: Request, -// // res: Response, -// // next: NextFunction -// // ): Promise => { -// // try { -// // const id = req.params.taskId; -// // const userId = req.params.userId; - -// // const data = await this.Taskservice.getTaskById(id, userId); -// // res.status(201).send(data); - -// // } -// // catch(error){ -// // next(new HttpException(400, 'Cannot create post')); -// // } - -// // } - - -// // private delete = async ( -// // req: Request, -// // res: Response, -// // next: NextFunction -// // ): Promise => { -// // try { -// // const id = req.params.taskId; -// // const userId = req.params.userId; -// // await this.Taskservice.DeleteTask(id, userId); -// // return res.status(200).send({ status: "Success", msg: "Data Removed" }); -// // } catch (error) { -// // next(new HttpException(400, 'Cannot create post')); -// // } -// // }; - -// // private updateTask = async ( -// // req: Request, -// // res: Response, -// // next: NextFunction -// // ): Promise => { -// // try { - -// // const taskId = req.params.taskId; -// // const userId = req.params.userId; -// // const reqBody:CreateTaskReqBody = Object.assign({}, req.body); - -// // const updatedTask = await this.Taskservice.UpdateTask( -// // // req.auth!.uid, -// // taskId, -// // userId, -// // // firebase.auth().currentUser.getIdToken() -// // reqBody.nom, -// // reqBody.description, -// // reqBody.logo, -// // reqBody.duration, -// // reqBody.done, -// // // reqBody.tags, -// // reqBody.repepat, -// // reqBody.deb, -// // reqBody.fin -// // ); -// // // res.send('Success add'); -// // // res.status(201).json({ task }); -// // res.status(204).send(`Update a new contact: ${updatedTask}`); -// // } catch (error) { -// // console.log(error); -// // next(new HttpException(403, 'Cannot create post')); -// // } -// // }; - -// } - -// export default StubManager; \ No newline at end of file diff --git a/src/FLAD/components/input.tsx b/src/FLAD/components/input.tsx deleted file mode 100644 index 7d22dbe..0000000 --- a/src/FLAD/components/input.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { useState } from 'react'; -import { View, Text, StyleSheet, TextInput } from 'react-native' - -interface InputProps { - name: string; - placeholder: string; -} - -const FladInput = ({ name, placeholder }: InputProps) => { - const [focused, setFocused] = useState(false); - - return ( - - - - - - - ); -}; - -const styles = StyleSheet.create({ - input: { - justifyContent: 'center', - alignItems: 'center', - placeholder: "placeholde" - }, -}) - -export default FladInput; \ No newline at end of file diff --git a/src/FLAD/screens/login.tsx b/src/FLAD/screens/login.tsx index 8249a29..318cdaa 100644 --- a/src/FLAD/screens/login.tsx +++ b/src/FLAD/screens/login.tsx @@ -6,24 +6,15 @@ import { makeRedirectUri, useAuthRequest } from 'expo-auth-session'; import { Buffer } from 'buffer'; import * as SecureStore from 'expo-secure-store'; - -//generate random string export const MY_SECURE_AUTH_STATE_KEY = 'MySecureAuthStateKey' WebBrowser.maybeCompleteAuthSession() -// Endpoint const discovery = { authorizationEndpoint: 'https://accounts.spotify.com/authorize', tokenEndpoint: 'https://accounts.spotify.com/api/token', }; -// save the spotifyToken -async function save(key: string, value: string) { - await SecureStore.setItemAsync(key, value) -} - - export default function Login() { const [request] = useAuthRequest( { @@ -42,7 +33,6 @@ export default function Login() { const scopesArr = ['user-read-private', 'user-read-email', 'user-read-playback-state', 'user-read-currently-playing', 'user-read-recently-played', 'playlist-modify-public', 'ugc-image-upload', 'user-modify-playback-state']; const scopes = scopesArr.join(' '); - //work so use this for my implementation const getAuthorizationCode = async () => { try { const redirectUrl = "https://auth.expo.io/@anonymous/FLAD-7eafd441-fd6b-4fb6-924c-ec2b0ed5ce6d" @@ -64,7 +54,7 @@ export default function Login() { const getTokens = async () => { try { const authorizationCode = await getAuthorizationCode() - const response = await fetch('https://accounts.spotify.com/api/token', { + await fetch('https://accounts.spotify.com/api/token', { method: 'POST', headers: { Authorization: 'Basic ' + (Buffer.from('1f1e34e4b6ba48b388469dba80202b10' + ':' + '779371c6d4994a68b8dd6e84b0873c82').toString('base64')), diff --git a/src/FLAD/services/spotify/spotify.service.ts b/src/FLAD/services/spotify/spotify.service.ts index 88c0a56..53c0755 100644 --- a/src/FLAD/services/spotify/spotify.service.ts +++ b/src/FLAD/services/spotify/spotify.service.ts @@ -67,7 +67,7 @@ export default class SpotifyService implements IspotifyService { } public async searchMusic(text: string): Promise { - var requestData: string = '/search'; + const requestData: string = '/search'; const fetchOptions: FetchOptions = { params: { q: text, @@ -114,7 +114,6 @@ export default class SpotifyService implements IspotifyService { }; const respMusic = await this.spotifyRequestHandler.spotifyFetch(requestData, fetchOptions, this.token); console.log(respMusic.data); - return; } public async getSimilarTrack(musicId: string, limit: number = 1, market?: string): Promise { @@ -122,7 +121,7 @@ export default class SpotifyService implements IspotifyService { '?limit=' + limit + '&market=FR' + '&seed_tracks=' + musicId; - var respSimilarMusic; + let respSimilarMusic; try { respSimilarMusic = await this.spotifyRequestHandler.spotifyFetch(requestData, {}, this.token); } catch (error) { diff --git a/src/FLAD/services/spotify/spotifyRequestHandler/utils.tsx b/src/FLAD/services/spotify/spotifyRequestHandler/utils.tsx index 4279e03..102114e 100644 --- a/src/FLAD/services/spotify/spotifyRequestHandler/utils.tsx +++ b/src/FLAD/services/spotify/spotifyRequestHandler/utils.tsx @@ -34,9 +34,7 @@ export class RequestHandler { }); return resp; } - catch(error : any){ - const errorMessage = error.response.data?.error?.message; - } + catch(error : any){} } }