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 updateCallback: (name?: string, description?: string, raid?: Raid) => void } const PartyDetails = (props: Props) => { const appSnapshot = useSnapshot(appState) const nameInput = React.createRef() const descriptionInput = React.createRef() const raidSelect = React.createRef() const readOnlyClasses = classNames({ 'PartyDetails': true, 'ReadOnly': true, 'Visible': !appSnapshot.party.detailsVisible }) const editableClasses = classNames({ 'PartyDetails': true, 'Editable': true, 'Visible': appSnapshot.party.detailsVisible }) const [errors, setErrors] = useState<{ [key: string]: string }>({ name: '', description: '' }) function handleInputChange(event: React.ChangeEvent) { 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) } function updateDetails(event: React.ChangeEvent) { const nameValue = nameInput.current?.value const descriptionValue = descriptionInput.current?.value const raid = appSnapshot.raids.find(raid => raid.id == raidSelect.current?.value) props.updateCallback(nameValue, descriptionValue, raid) } const editable = (
) 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