Added comments and documentation to codebase

This commit is contained in:
Ceferino Patino 2022-04-09 16:17:12 -05:00
commit 62a0cc96cc
22 changed files with 59 additions and 4 deletions

View file

@ -70,6 +70,7 @@ function OrgDashboard() {
return { ...res.org, memberCount: res.memberCount };
});
// Set org member rows to retrieved data and whether user is owner
setRows(() => res.org.member);
setStatus(() => res.status);
})
@ -104,6 +105,7 @@ function OrgDashboard() {
}
async function removeSelected() {
// Map all of the doomed users into object and send for deletion
const doomedUserIDs = selection.map((row) => row.id);
await axios.post(
@ -134,6 +136,7 @@ function OrgDashboard() {
}
async function play(id) {
// Retrieve audio file from server and play
axios
.get(
`${process.env.REACT_APP_DOMAIN_ROOT}/public/audio/${id}.mp3`,

View file

@ -32,6 +32,7 @@ function RecordMp3() {
)
.then((res) => {
setUploadedFile(() => {
// Retrieve audio file of user if exists
return new File([res.data], 'userAudio.mp3', {
type: res.data.type,
lastModified: Date.now(),
@ -42,10 +43,12 @@ function RecordMp3() {
function togglePlay() {
if (audio && !audio.ended) {
// Reset audio and reset if track is playing
audio.pause();
audio.currentTime = 0;
setAudio(() => null);
} else {
// Set audio to file and play
const audioFile = new Audio(URL.createObjectURL(uploadedFile));
setAudio(() => audioFile);
audioFile.play();
@ -54,6 +57,7 @@ function RecordMp3() {
function record() {
if (recording) {
// Stop recording then set uploaded file to mp3 instance
setRecording(() => false);
recorder
.stop()
@ -67,6 +71,7 @@ function RecordMp3() {
});
});
} else {
// Start recording
setRecording(() => true);
recorder.start().catch((e) => {
console.error(e);
@ -83,6 +88,7 @@ function RecordMp3() {
async function handleSubmit(e) {
e.preventDefault();
// Create form data object and attach file and user token
var formData = new FormData();
formData.append('audioFile', uploadedFile, 'userAudio.mp3');
formData.append('token', Cookies.get('token'));