formatting cleanup

This commit is contained in:
Malte Delfs 2021-06-19 21:51:18 +02:00
parent 639341f701
commit 653509d655
2 changed files with 24 additions and 26 deletions

View file

@ -1,4 +1,3 @@
export enum EventTypeCustomInputType { export enum EventTypeCustomInputType {
Text = 'text', Text = 'text',
TextLong = 'textLong', TextLong = 'textLong',
@ -12,4 +11,3 @@ export interface EventTypeCustomInput {
label: string; label: string;
required: boolean; required: boolean;
} }

View file

@ -19,12 +19,12 @@ import {PlusIcon} from "@heroicons/react/solid";
export default function EventType(props) { export default function EventType(props) {
const router = useRouter(); const router = useRouter();
const inputOptions: OptionBase[] = [ const inputOptions: OptionBase[] = [
{ value: EventTypeCustomInputType.Text, label: 'Text' }, { value: EventTypeCustomInputType.Text, label: 'Text' },
{ value: EventTypeCustomInputType.TextLong, label: 'Multiline Text' }, { value: EventTypeCustomInputType.TextLong, label: 'Multiline Text' },
{ value: EventTypeCustomInputType.Number, label: 'Number', }, { value: EventTypeCustomInputType.Number, label: 'Number', },
{ value: EventTypeCustomInputType.Bool, label: 'Checkbox', }, { value: EventTypeCustomInputType.Bool, label: 'Checkbox', },
] ]
const [ session, loading ] = useSession(); const [ session, loading ] = useSession();
const [ showLocationModal, setShowLocationModal ] = useState(false); const [ showLocationModal, setShowLocationModal ] = useState(false);
@ -32,7 +32,7 @@ export default function EventType(props) {
const [ selectedLocation, setSelectedLocation ] = useState<OptionBase | undefined>(undefined); const [ selectedLocation, setSelectedLocation ] = useState<OptionBase | undefined>(undefined);
const [ selectedInputOption, setSelectedInputOption ] = useState<OptionBase>(inputOptions[0]); const [ selectedInputOption, setSelectedInputOption ] = useState<OptionBase>(inputOptions[0]);
const [ locations, setLocations ] = useState(props.eventType.locations || []); const [ locations, setLocations ] = useState(props.eventType.locations || []);
const [customInputs, setCustomInputs] = useState<EventTypeCustomInput[]>(props.eventType.customInputs.sort((a, b) => a.id - b.id) || []); const [customInputs, setCustomInputs] = useState<EventTypeCustomInput[]>(props.eventType.customInputs.sort((a, b) => a.id - b.id) || []);
const titleRef = useRef<HTMLInputElement>(); const titleRef = useRef<HTMLInputElement>();
const slugRef = useRef<HTMLInputElement>(); const slugRef = useRef<HTMLInputElement>();
@ -97,10 +97,10 @@ export default function EventType(props) {
setShowLocationModal(false); setShowLocationModal(false);
}; };
const closeAddCustomModal = () => { const closeAddCustomModal = () => {
setSelectedInputOption(inputOptions[0]); setSelectedInputOption(inputOptions[0]);
setShowAddCustomModal(false); setShowAddCustomModal(false);
}; };
const LocationOptions = () => { const LocationOptions = () => {
if (!selectedLocation) { if (!selectedLocation) {
@ -152,22 +152,22 @@ export default function EventType(props) {
setLocations(locations.filter( (location) => location.type !== selectedLocation.type )); setLocations(locations.filter( (location) => location.type !== selectedLocation.type ));
}; };
const updateCustom = (e) => { const updateCustom = (e) => {
e.preventDefault(); e.preventDefault();
const customInput: EventTypeCustomInput = { const customInput: EventTypeCustomInput = {
label: e.target.label.value, label: e.target.label.value,
required: e.target.required.checked, required: e.target.required.checked,
type: e.target.type.value type: e.target.type.value
};
setCustomInputs(customInputs.concat(customInput));
console.log(customInput)
setShowAddCustomModal(false);
}; };
setCustomInputs(customInputs.concat(customInput)); return (
console.log(customInput)
setShowAddCustomModal(false);
};
return (
<div> <div>
<Head> <Head>
<title>{props.eventType.title} | Event Type | Calendso</title> <title>{props.eventType.title} | Event Type | Calendso</title>