From 724f63e60585f00702a3427eaa6f8e6399a3bd6b Mon Sep 17 00:00:00 2001 From: Alexandre GLENAT Date: Thu, 23 Mar 2023 13:53:38 +0100 Subject: [PATCH 1/2] push --- R-Dash/redux/actions/sessions.ts | 5 +++-- R-Dash/redux/actions/teams.ts | 4 ++-- R-Dash/screens/CreateTeam.tsx | 14 +++++--------- R-Dash/screens/NewTrack.tsx | 17 ++++++++++++++--- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/R-Dash/redux/actions/sessions.ts b/R-Dash/redux/actions/sessions.ts index f883fd5..0e143d7 100644 --- a/R-Dash/redux/actions/sessions.ts +++ b/R-Dash/redux/actions/sessions.ts @@ -16,7 +16,8 @@ export const addXlsFile = async (file: File) => { try { const formData = new FormData(); formData.append('file', file); - const response = await fetch('https://codefirst.iut.uca.fr/containers/enzojolys-r-dash_container/upload', { + const response = await fetch( + 'https://r-dash.azurewebsites.net/File?' + "pseudoPilote=test_PILOTE" + "&Email=test@gmail.com" + "&password=test123" + "&nameSession=test_SESSION" + "&nameCircuit=test_CIRCUIT" + "&typeSession=Unknown", { method: 'POST', body: formData }); @@ -30,7 +31,7 @@ export const addXlsFile = async (file: File) => { export const getSessionsList = (user: User) => { return async dispatch => { try { - const sessionsPromise = await fetch('https://codefirst.iut.uca.fr/containers/enzojolys-r-dash_container/Sessions/'+user.getUsername); + const sessionsPromise = await fetch('https://r-dash.azurewebsites.net/Sessions/'+user.getUsername); const sessionsListJson = await sessionsPromise.json(); const sessionsList: Session[] = sessionsListJson.map(elt => { const laps: Lap[] = elt.laps.map(lap => { diff --git a/R-Dash/redux/actions/teams.ts b/R-Dash/redux/actions/teams.ts index 5f6c042..1b6d351 100644 --- a/R-Dash/redux/actions/teams.ts +++ b/R-Dash/redux/actions/teams.ts @@ -11,7 +11,7 @@ export const setTeamsList = (teamsList: Team[]) => { export const addNewTeam = (newTeam: Team) => { return async dispatch => { try { - const response = await fetch('https://codefirst.iut.uca.fr/containers/enzojolys-r-dash_container/Ecuries', { + const response = await fetch('https://r-dash.azurewebsites.net/Ecuries?' + "Email=test@gmail.com" + "&password=test123" + "&pseudoPilote=test_PILOTE", { method: 'POST', headers: { 'Content-Type': 'application/json' @@ -33,7 +33,7 @@ export const addNewTeam = (newTeam: Team) => { export const getTeamsList = () => { return async dispatch => { try { - const teamsPromise = await fetch('https://codefirst.iut.uca.fr/containers/enzojolys-r-dash_container/Ecuries'); + const teamsPromise = await fetch('https://r-dash.azurewebsites.net/Ecuries'); const teamsListJson = await teamsPromise.json(); const teamsList: Team[] = teamsListJson.map(elt => new Team(elt["name"], elt["owner"], elt["users"], elt["logo"])); dispatch(setTeamsList(teamsList)); diff --git a/R-Dash/screens/CreateTeam.tsx b/R-Dash/screens/CreateTeam.tsx index 292cc8b..9c3dfad 100644 --- a/R-Dash/screens/CreateTeam.tsx +++ b/R-Dash/screens/CreateTeam.tsx @@ -22,16 +22,12 @@ export default function CreateTeam(props: { navigation: any }) { } }; - const nList = useSelector(state => state.appReducer.teams); - const dispatch = useDispatch(); - useEffect(() => { - const addTeams = async () => { - await dispatch(addNewTeam()); - }; - addTeams(); - }, [dispatch]); + const onPressAddTeam = async () => { + dispatch(); + navigation.goBack(); + }; return ( @@ -67,7 +63,7 @@ export default function CreateTeam(props: { navigation: any }) { source={require('../assets/images/return.png')} /> - navigation.goBack()}> + { try { - const result = await DocumentPicker.getDocumentAsync({ type: 'excel/xls' }); + const result = await DocumentPicker.getDocumentAsync(); if (result.type === 'success') { setPickedDocument(result); } @@ -21,6 +23,15 @@ export default function NewTrack(props: { navigation: any }) { } }; + //const nList = useSelector(state => state.appReducer.teams); + + const dispatch = useDispatch(); + + const onPressAddFile = async () => { + dispatch(await addXlsFile(pickedDocument)); + navigation.goBack(); + }; + return ( @@ -68,7 +79,7 @@ export default function NewTrack(props: { navigation: any }) { source={require('../assets/images/return.png')} /> - navigation.goBack()}> + Date: Thu, 23 Mar 2023 15:04:26 +0100 Subject: [PATCH 2/2] tien --- R-Dash/redux/actions/sessions.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R-Dash/redux/actions/sessions.ts b/R-Dash/redux/actions/sessions.ts index 0e143d7..e7d3704 100644 --- a/R-Dash/redux/actions/sessions.ts +++ b/R-Dash/redux/actions/sessions.ts @@ -28,10 +28,10 @@ export const addXlsFile = async (file: File) => { } }; -export const getSessionsList = (user: User) => { +export const getSessionsList = () => { return async dispatch => { try { - const sessionsPromise = await fetch('https://r-dash.azurewebsites.net/Sessions/'+user.getUsername); + const sessionsPromise = await fetch('https://r-dash.azurewebsites.net/FullSession'); const sessionsListJson = await sessionsPromise.json(); const sessionsList: Session[] = sessionsListJson.map(elt => { const laps: Lap[] = elt.laps.map(lap => {