generated from cepdnaclk/eYY-3yp-project-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from cepdnaclk/main
deploy
- Loading branch information
Showing
17 changed files
with
279 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
|
||
export async function getAccessTokenFromRefreshToken(refreshToken: string): Promise<string> { | ||
try { | ||
const response = await fetch('/api/token', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ refreshToken }), | ||
}); | ||
|
||
if (response.ok) { | ||
const data = await response.json(); | ||
const accessToken: string = data.accessToken; | ||
return accessToken; | ||
} else { | ||
throw new Error('Failed to get access token from refresh token'); | ||
} | ||
} catch (error) { | ||
console.error('Error getting access token:', error); | ||
throw error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,54 @@ | ||
import { sessionToBeUploaded } from "../types"; | ||
import { updatePlayersDetails } from "../states/updateAppStates"; | ||
import { Players, SessionToBeUploaded } from "../types"; | ||
|
||
export const uploadSession = async () => { | ||
if(localStorage.getItem("sessionDetails") === null) return; | ||
else{ | ||
if (localStorage.getItem("sessionDetails") === null) return; | ||
else { | ||
// Retrieve the array of objects from local storage | ||
const sessionDetails = JSON.parse(localStorage.getItem("sessionDetails") as string); | ||
|
||
// Iterate through each object in the array | ||
sessionDetails.forEach(function(object:sessionToBeUploaded) { | ||
// Send the object to the server | ||
sendToServer(object); | ||
|
||
// Remove the object from the array in local storage | ||
const index = sessionDetails.indexOf(object); | ||
if (index > -1) { | ||
sessionDetails.splice(index, 1); | ||
} | ||
}); | ||
|
||
// Update the modified array in local storage | ||
localStorage.setItem("sessionDetails", JSON.stringify(sessionDetails)); | ||
|
||
} | ||
const sessionsToBeUploaded: SessionToBeUploaded[] = JSON.parse( | ||
localStorage.getItem("sessionDetails") as string | ||
); | ||
|
||
if (sessionsToBeUploaded.length === 0) return; | ||
|
||
// Iterate through each object in the array | ||
sessionsToBeUploaded.forEach(function (object: SessionToBeUploaded) { | ||
// Send the object to the server | ||
sendToServer(object); | ||
|
||
// Remove the object from the array in local storage | ||
const index = sessionsToBeUploaded.indexOf(object); | ||
if (index > -1) { | ||
sessionsToBeUploaded.splice(index, 1); | ||
} | ||
}); | ||
|
||
|
||
// Update the modified array in local storage | ||
localStorage.setItem( | ||
"sessionDetails", | ||
JSON.stringify(sessionsToBeUploaded) | ||
); | ||
} | ||
}; | ||
|
||
function sendToServer(object: SessionToBeUploaded) { | ||
console.log(object); | ||
} | ||
|
||
function sendToServer(object:sessionToBeUploaded) { | ||
console.log(object); | ||
} | ||
export const getPlayers = async () => { | ||
const token = localStorage.getItem("accessToken"); | ||
try { | ||
const playersResponse = await fetch("http://13.235.86.11:5000/manager/getTeamPlayers",{ | ||
method: "GET", | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}); | ||
const playersData: Players = await playersResponse.json(); | ||
|
||
updatePlayersDetails(playersData); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.