diff --git a/packages/frontend/src/components/AuthorPopup.tsx b/packages/frontend/src/components/popups/AuthorPopup.tsx similarity index 100% rename from packages/frontend/src/components/AuthorPopup.tsx rename to packages/frontend/src/components/popups/AuthorPopup.tsx diff --git a/packages/frontend/src/components/FieldPopup.tsx b/packages/frontend/src/components/popups/FieldPopup.tsx similarity index 100% rename from packages/frontend/src/components/FieldPopup.tsx rename to packages/frontend/src/components/popups/FieldPopup.tsx diff --git a/packages/frontend/src/components/ListPopup.tsx b/packages/frontend/src/components/popups/ListPopup.tsx similarity index 99% rename from packages/frontend/src/components/ListPopup.tsx rename to packages/frontend/src/components/popups/ListPopup.tsx index d3c8cee..2bb5b41 100644 --- a/packages/frontend/src/components/ListPopup.tsx +++ b/packages/frontend/src/components/popups/ListPopup.tsx @@ -1,6 +1,6 @@ import JsPsychMetadata from 'metadata'; import React, { useState } from 'react'; -import Trash from '../assets/trash.svg' +import Trash from '../../assets/trash.svg' type ListPopup = { jsPsychMetadata: JsPsychMetadata; diff --git a/packages/frontend/src/components/VariablePopup.tsx b/packages/frontend/src/components/popups/VariablePopup.tsx similarity index 100% rename from packages/frontend/src/components/VariablePopup.tsx rename to packages/frontend/src/components/popups/VariablePopup.tsx diff --git a/packages/frontend/src/components/upload/AuthorForm.tsx b/packages/frontend/src/components/upload/AuthorForm.tsx new file mode 100644 index 0000000..09c61da --- /dev/null +++ b/packages/frontend/src/components/upload/AuthorForm.tsx @@ -0,0 +1,69 @@ +import { useState } from 'react'; +import { AuthorFields } from '../../../../metadata/dist/AuthorsMap'; +import JsPsychMetadata from 'metadata'; + +interface AuthorFormProps { + jsPsychMetadata: JsPsychMetadata; +} + +/// need to rework the testing button to make it add another name and identifier field +// need to rework the save button to be built natively similar to the prompt form so that can handleSave with the state data +const AuthorForm: React.FC = ({ jsPsychMetadata }) => { + const [authors, setAuthors] = useState<(AuthorFields)[]>( + jsPsychMetadata.getAuthorList().map((author: AuthorFields | string) => { + if (typeof author === 'string') { + return { name: author, identifier: '', oldName: author }; // need to check oldName with saving + } else { + return { ...author, oldName: author["name"] }; // need to check oldName when saving + } + }) + ); + + const handleNameChange = (index: number, value: string) => { + const newAuthors = [...authors]; + newAuthors[index].name = value; + setAuthors(newAuthors); + }; + + const handleIdentifierChange = (index: number, value: string) => { + const newAuthors = [...authors]; + newAuthors[index].identifier = value; + setAuthors(newAuthors); + }; + + const addEmptyAuthor = () => { + setAuthors([...authors, { name: '', identifier: '' }]); + }; + + return ( +
+

Authors

+ {authors.map((author, index) => ( +
+ + +
+ ))} + +
+ ); +}; + +export default AuthorForm; \ No newline at end of file diff --git a/packages/frontend/src/components/PromptForm.tsx b/packages/frontend/src/components/upload/PromptForm.tsx similarity index 98% rename from packages/frontend/src/components/PromptForm.tsx rename to packages/frontend/src/components/upload/PromptForm.tsx index 4128349..d4e27f8 100644 --- a/packages/frontend/src/components/PromptForm.tsx +++ b/packages/frontend/src/components/upload/PromptForm.tsx @@ -36,7 +36,7 @@ const PromptForm: React.FC = ({ jsPsychMetadata, updateMetadata if (formData.author_name !== "") jsPsychMetadata.setAuthor({ "name": formData.author_name}); updateMetadataString(); - handleScreenChange('data', 'skip'); + handleScreenChange('author', 'Save'); }; return ( diff --git a/packages/frontend/src/components/UploadData.tsx b/packages/frontend/src/components/upload/UploadData.tsx similarity index 100% rename from packages/frontend/src/components/UploadData.tsx rename to packages/frontend/src/components/upload/UploadData.tsx diff --git a/packages/frontend/src/components/UploadMetadata.tsx b/packages/frontend/src/components/upload/UploadMetadata.tsx similarity index 100% rename from packages/frontend/src/components/UploadMetadata.tsx rename to packages/frontend/src/components/upload/UploadMetadata.tsx diff --git a/packages/frontend/src/pages/Options.tsx b/packages/frontend/src/pages/Options.tsx index 32266eb..63758dc 100644 --- a/packages/frontend/src/pages/Options.tsx +++ b/packages/frontend/src/pages/Options.tsx @@ -1,8 +1,8 @@ import React, { useState } from 'react'; -import FieldPopup, { FieldFormData } from '../components/FieldPopup'; -import AuthorPopup, { AuthorFormData } from '../components/AuthorPopup'; -import VariablePopup, { VariableFormData } from '../components/VariablePopup'; -import ListPopup from '../components/ListPopup'; +import FieldPopup, { FieldFormData } from '../components/popups/FieldPopup'; +import AuthorPopup, { AuthorFormData } from '../components/popups/AuthorPopup'; +import VariablePopup, { VariableFormData } from '../components/popups/VariablePopup'; +import ListPopup from '../components/popups/ListPopup'; import JsPsychMetadata, { AuthorFields, VariableFields } from 'metadata'; interface OptionsProps { diff --git a/packages/frontend/src/pages/Upload.tsx b/packages/frontend/src/pages/Upload.tsx index 0318e38..c4deeed 100644 --- a/packages/frontend/src/pages/Upload.tsx +++ b/packages/frontend/src/pages/Upload.tsx @@ -1,8 +1,9 @@ -import UploadMetadata from '../components/UploadMetadata.tsx'; -import UploadData from '../components/UploadData.tsx'; +import UploadMetadata from '../components/upload/UploadMetadata.tsx'; +import UploadData from '../components/upload/UploadData.tsx'; import JsPsychMetadata from 'metadata'; +import AuthorForm from '../components/upload/AuthorForm.tsx'; import { useState } from 'react'; -import PromptForm from '../components/PromptForm.tsx'; +import PromptForm from '../components/upload/PromptForm.tsx'; interface UploadProps { jsPsychMetadata: JsPsychMetadata; @@ -25,8 +26,11 @@ const Upload: React.FC = ( { jsPsychMetadata, setPage, updateMetada case 'form': setPageNumber(2); break; - case 'data': + case 'author': setPageNumber(3); + break; + case 'data': + setPageNumber(4); } } @@ -39,6 +43,8 @@ const Upload: React.FC = ( { jsPsychMetadata, setPage, updateMetada return case 'form': return ; + case 'author': + return case 'data': return } @@ -57,6 +63,15 @@ const Upload: React.FC = ( { jsPsychMetadata, setPage, updateMetada ; case 'form': return; // this will be handled internally to tie behavior with the form + case 'author': + return ; case 'data': return