import React, { useState } from 'react' import { useSnapshot } from 'valtio' import classNames from 'classnames' import CharLimitedFieldset from '~components/CharLimitedFieldset' import TextFieldset from '~components/TextFieldset' import { appState } from '~utils/appState' import './index.scss' import RaidDropdown from '~components/RaidDropdown' // Props interface Props { editable: boolean } const PartyDetails = (props: Props) => { const appSnapshot = useSnapshot(appState) const nameInput = React.createRef() const descriptionInput = React.createRef() const readOnlyClasses = classNames({ 'Details': true, 'ReadOnly': true, 'Visible': !appSnapshot.party.detailsVisible }) const editableClasses = classNames({ 'Details': true, 'Editable': true, 'Visible': appSnapshot.party.detailsVisible }) const [errors, setErrors] = useState<{ [key: string]: string }>({ name: '', description: '' }) function handleInputChange(event: React.ChangeEvent) { console.log(event) event.preventDefault() const { name, value } = event.target let newErrors = errors setErrors(newErrors) } function handleTextAreaChange(event: React.ChangeEvent) { event.preventDefault() const { name, value } = event.target let newErrors = errors setErrors(newErrors) } const editable = (
{} } onChange={handleInputChange} error={errors.name} ref={nameInput} /> {} } onChange={handleTextAreaChange} error={errors.description} ref={descriptionInput} />
) const readOnly = (

{ (appSnapshot.party.name) ? appSnapshot.party.name : 'No title' }

{ (appSnapshot.party.raid) ?
{appSnapshot.party.raid.name.en}
: '' }

{ (appSnapshot.party.description) ? appSnapshot.party.description : '' }

) return (
{readOnly} {editable}
) } export default PartyDetails