Skip to content

Commit

Permalink
Adding in identifier new author buttton and adding oldname to begin s…
Browse files Browse the repository at this point in the history
…aving logic
  • Loading branch information
vzhang03 committed Aug 2, 2024
1 parent dc7dc5a commit 9dbdf2f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/frontend/src/components/upload/AuthorForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const AuthorForm: React.FC<AuthorFormProps> = ({ jsPsychMetadata }) => {
const [authors, setAuthors] = useState<(AuthorFields)[]>(
jsPsychMetadata.getAuthorList().map((author: AuthorFields | string) => {
if (typeof author === 'string') {
return { name: author, identifier: '' };
return { name: author, identifier: '', oldName: author }; // need to check oldName with saving
} else {
return author;
return { ...author, oldName: author["name"] }; // need to check oldName when saving
}
})
);
Expand All @@ -31,6 +31,10 @@ const AuthorForm: React.FC<AuthorFormProps> = ({ jsPsychMetadata }) => {
setAuthors(newAuthors);
};

const addEmptyAuthor = () => {
setAuthors([...authors, { name: '', identifier: '' }]);
};

return (
<div>
<h2>Authors</h2>
Expand All @@ -54,7 +58,10 @@ const AuthorForm: React.FC<AuthorFormProps> = ({ jsPsychMetadata }) => {
</label>
</div>
))}
<button onClick={() => console.log(authors)}>testing</button>
<button onClick={() => {
console.log(authors);
addEmptyAuthor();
}}>testing</button>
</div>
);
};
Expand Down

0 comments on commit 9dbdf2f

Please sign in to comment.