diff --git a/webclient/src/Account.js b/webclient/src/Account.js index 9c4c4d1..de4d5ea 100644 --- a/webclient/src/Account.js +++ b/webclient/src/Account.js @@ -229,6 +229,67 @@ export function AccountForm(props) { ); }; +export function BioNotesForm(props) { + const { token, user, refreshUser } = props; + const member = user.member; + const [input, setInput] = useState({ ...member, set_details: true }); + const [error, setError] = useState({}); + const [loading, setLoading] = useState(false); + const history = useHistory(); + + const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value }); + const handleUpload = (e, v) => setInput({ ...input, [v.name]: e.target.files[0] }); + const handleChange = (e) => handleValues(e, e.currentTarget); + const handleCheck = (e, v) => setInput({ ...input, [v.name]: v.checked }); + + const handleSubmit = (e) => { + if (loading) return; + setLoading(true); + requester('/members/' + member.id + '/', 'PATCH', token, input) + .then(res => { + setError({}); + refreshUser(); + history.push('/'); + }) + .catch(err => { + setLoading(false); + console.log(err); + setError(err.data); + }); + }; + + const makeProps = (name) => ({ + name: name, + onChange: handleChange, + value: input[name] || '', + error: error[name], + }); + + return ( +
+
Bio / Notes
+ + 400 ? ' — ' + input.public_bio.length + ' / 512' : '')} + {...makeProps('public_bio')} + /> + +

Bio shared with members. Example: contact info, allergies, hobbies, etc.

+ + 400 ? ' — ' + input.private_notes.length + ' / 512' : '')} + {...makeProps('private_notes')} + /> + +

Notes visible only to directors and admins.

+ + + Submit + + + ); +}; + export function Account(props) { return ( @@ -238,6 +299,7 @@ export function Account(props) { +