import React, { useState, useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { v4 as uuidv4 } from 'uuid';
import set from 'lodash/set';
import TextField from '../../../shared/TextField';
import TextArea from '../../../shared/TextArea';
import AppContext from '../../../context/AppContext';
import Checkbox from '../../../shared/Checkbox';
import { addItem } from '../../../utils';
import ItemActions from '../../../shared/ItemActions';
import AddItemButton from '../../../shared/AddItemButton';
import ItemHeading from '../../../shared/ItemHeading';
const WorkTab = ({ data, onChange }) => {
const context = useContext(AppContext);
const { dispatch } = context;
return (
<>
onChange('data.work.enable', v)} />
onChange('data.work.heading', v)}
/>
{data.work.items.map((x, index) => (
))}
>
);
};
const Form = ({ item, onChange, identifier = '' }) => {
const { t } = useTranslation(['leftSidebar', 'app']);
return (
onChange(`${identifier}title`, v)}
/>
onChange(`${identifier}role`, v)}
/>
onChange(`${identifier}start`, v)}
/>
onChange(`${identifier}end`, v)}
/>
);
};
const AddItem = ({ heading, dispatch }) => {
const [isOpen, setOpen] = useState(false);
const [item, setItem] = useState({
id: uuidv4(),
enable: true,
title: '',
role: '',
start: '',
end: '',
description: '',
});
const onChange = (key, value) => setItem(set({ ...item }, key, value));
const onSubmit = () => {
if (item.title === '' || item.role === '') return;
addItem(dispatch, 'work', item);
setItem({
id: uuidv4(),
enable: true,
title: '',
role: '',
start: '',
end: '',
description: '',
});
setOpen(false);
};
return (
);
};
const Item = ({ item, index, onChange, dispatch, first, last }) => {
const [isOpen, setOpen] = useState(false);
const identifier = `data.work.items[${index}].`;
return (
);
};
export default WorkTab;