Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ELiuHub committed Nov 21, 2022
1 parent 5d34b86 commit af1de3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Pages/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function Form(props) {
let isAdmin = await AdminStatus();
let forms;
if (isAdmin) {
forms = await API.graphql(graphqlOperation(listForms));
forms = await API.graphql(graphqlOperation(listForms, {filter: {owner: {eq: user.username}}}));
} else {
forms = await API.graphql(graphqlOperation(listForms, {filter: {otherUser: {eq: user.username}}}));
}
Expand Down
7 changes: 5 additions & 2 deletions src/Pages/upload.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, useEffect } from 'react';
import { Collapse, Alert, Button, Box, Stack, TextField, Tabs, Tab, FormControl, InputLabel, Select, MenuItem } from "@mui/material";
import { UploadFile } from "@mui/icons-material";
import { API, graphqlOperation } from 'aws-amplify';
import { API, graphqlOperation, Auth } from 'aws-amplify';
import axios from 'axios';
import { createForm } from '../graphql/mutations';
import { listForms, getFormByName } from '../graphql/queries';
Expand Down Expand Up @@ -29,7 +29,8 @@ export default function Upload(props) {
useEffect(() => {
async function existingForms() {
try {
let forms = await API.graphql(graphqlOperation(listForms));
let user = await Auth.currentAuthenticatedUser();
let forms = await API.graphql(graphqlOperation(listForms, {filter: {owner: {eq: user.username}}}));
let formNames = [...new Set(forms.data.listForms.items.map((form)=>form.name))];
setAvailableForms(formNames);
} catch (error) {
Expand All @@ -54,6 +55,7 @@ export default function Upload(props) {
async function handleFormUpload(e) {
e.preventDefault();

let user = await Auth.currentAuthenticatedUser();
let uploadedFile = document.getElementById('uploadFile');
if (formTitle === '') {
setFieldError(true);
Expand All @@ -77,6 +79,7 @@ export default function Upload(props) {
name: formTitle,
version: 1,
otherUser: formUser,
owner: user.username,
formID: response.data.id
}
};
Expand Down

0 comments on commit af1de3f

Please sign in to comment.