mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-13 08:13:49 +10:00
extract strings for extars tab
This commit is contained in:
@ -31,7 +31,7 @@ const LeftSidebar = () => {
|
||||
const { state, dispatch } = context;
|
||||
const { data } = state;
|
||||
|
||||
const [currentTab, setCurrentTab] = useState('References');
|
||||
const [currentTab, setCurrentTab] = useState('Extras');
|
||||
const onChange = (key, value) => {
|
||||
dispatch({
|
||||
type: 'on_input',
|
||||
|
||||
@ -1,14 +1,18 @@
|
||||
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 AppContext from '../../../context/AppContext';
|
||||
import Checkbox from '../../../shared/Checkbox';
|
||||
import { addItem, deleteItem, moveItemUp, moveItemDown } from '../../../utils';
|
||||
import { addItem } from '../../../utils';
|
||||
import ItemActions from '../../../shared/ItemActions';
|
||||
import ItemHeading from '../../../shared/ItemHeading';
|
||||
import AddItemButton from '../../../shared/AddItemButton';
|
||||
|
||||
const ExtrasTab = ({ data, onChange }) => {
|
||||
const { t } = useTranslation();
|
||||
const context = useContext(AppContext);
|
||||
const { dispatch } = context;
|
||||
|
||||
@ -23,7 +27,7 @@ const ExtrasTab = ({ data, onChange }) => {
|
||||
</div>
|
||||
<div className="col-span-5">
|
||||
<TextField
|
||||
placeholder="Heading"
|
||||
placeholder={t('heading.placeholder')}
|
||||
value={data.extras.heading}
|
||||
onChange={v => onChange('data.extras.heading', v)}
|
||||
/>
|
||||
@ -44,12 +48,36 @@ const ExtrasTab = ({ data, onChange }) => {
|
||||
/>
|
||||
))}
|
||||
|
||||
<AddItem dispatch={dispatch} />
|
||||
<AddItem heading={data.extras.heading} dispatch={dispatch} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const AddItem = ({ dispatch }) => {
|
||||
const Form = ({ item, onChange, identifier = '' }) => {
|
||||
const { t } = useTranslation('leftSidebar');
|
||||
|
||||
return (
|
||||
<div>
|
||||
<TextField
|
||||
className="mb-6"
|
||||
label={t('extras.key.label')}
|
||||
placeholder={t('extras.key.placeholder')}
|
||||
value={item.key}
|
||||
onChange={v => onChange(`${identifier}key`, v)}
|
||||
/>
|
||||
|
||||
<TextField
|
||||
className="mb-6"
|
||||
label={t('extras.value.label')}
|
||||
placeholder={t('extras.value.placeholder')}
|
||||
value={item.value}
|
||||
onChange={v => onChange(`${identifier}value`, v)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const AddItem = ({ heading, dispatch }) => {
|
||||
const [isOpen, setOpen] = useState(false);
|
||||
const [item, setItem] = useState({
|
||||
id: uuidv4(),
|
||||
@ -77,41 +105,12 @@ const AddItem = ({ dispatch }) => {
|
||||
|
||||
return (
|
||||
<div className="my-4 border border-gray-200 rounded p-5">
|
||||
<div
|
||||
className="flex justify-between items-center cursor-pointer"
|
||||
onClick={() => setOpen(!isOpen)}
|
||||
>
|
||||
<h6 className="text-sm font-medium">Add Item</h6>
|
||||
<i className="material-icons">{isOpen ? 'expand_less' : 'expand_more'}</i>
|
||||
</div>
|
||||
<ItemHeading heading={heading} setOpen={setOpen} isOpen={isOpen} />
|
||||
|
||||
<div className={`mt-6 ${isOpen ? 'block' : 'hidden'}`}>
|
||||
<TextField
|
||||
label="Key"
|
||||
className="mb-6"
|
||||
placeholder="Date of Birth"
|
||||
value={item.key}
|
||||
onChange={v => onChange('key', v)}
|
||||
/>
|
||||
<Form item={item} onChange={onChange} />
|
||||
|
||||
<TextField
|
||||
label="Value"
|
||||
className="mb-6"
|
||||
placeholder="6th August 1995"
|
||||
value={item.value}
|
||||
onChange={v => onChange('value', v)}
|
||||
/>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={onSubmit}
|
||||
className="bg-gray-600 hover:bg-gray-700 text-white text-sm font-medium py-2 px-5 rounded"
|
||||
>
|
||||
<div className="flex items-center">
|
||||
<i className="material-icons mr-2 font-bold text-base">add</i>
|
||||
<span className="text-sm">Add</span>
|
||||
</div>
|
||||
</button>
|
||||
<AddItemButton onSubmit={onSubmit} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@ -119,46 +118,23 @@ const AddItem = ({ dispatch }) => {
|
||||
|
||||
const Item = ({ item, index, onChange, dispatch, first, last }) => {
|
||||
const [isOpen, setOpen] = useState(false);
|
||||
const identifier = `data.extras.items[${index}]`;
|
||||
const identifier = `data.extras.items[${index}].`;
|
||||
|
||||
return (
|
||||
<div className="my-4 border border-gray-200 rounded p-5">
|
||||
<div
|
||||
className="flex justify-between items-center cursor-pointer"
|
||||
onClick={() => setOpen(!isOpen)}
|
||||
>
|
||||
<h6 className="text-sm font-medium">{item.key}</h6>
|
||||
<i className="material-icons">{isOpen ? 'expand_less' : 'expand_more'}</i>
|
||||
</div>
|
||||
<ItemHeading title={item.key} setOpen={setOpen} isOpen={isOpen} />
|
||||
|
||||
<div className={`mt-6 ${isOpen ? 'block' : 'hidden'}`}>
|
||||
<TextField
|
||||
label="Key"
|
||||
className="mb-6"
|
||||
placeholder="Date of Birth"
|
||||
value={item.key}
|
||||
onChange={v => onChange(`${identifier}.key`, v)}
|
||||
/>
|
||||
|
||||
<TextField
|
||||
label="Value"
|
||||
className="mb-6"
|
||||
placeholder="6th August 1995"
|
||||
value={item.value}
|
||||
onChange={v => onChange(`${identifier}.value`, v)}
|
||||
/>
|
||||
<Form item={item} onChange={onChange} identifier={identifier} />
|
||||
|
||||
<ItemActions
|
||||
dispatch={dispatch}
|
||||
first={first}
|
||||
identifier={identifier}
|
||||
item={item}
|
||||
last={last}
|
||||
onChange={onChange}
|
||||
type="extras"
|
||||
identifier={identifier}
|
||||
dispatch={dispatch}
|
||||
deleteItem={deleteItem}
|
||||
first={first}
|
||||
moveItemUp={moveItemUp}
|
||||
last={last}
|
||||
moveItemDown={moveItemDown}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
10
src/i18n/resources/en/leftSidebar/extras.json
Normal file
10
src/i18n/resources/en/leftSidebar/extras.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"key": {
|
||||
"label": "Key",
|
||||
"placeholder": "Date of Birth"
|
||||
},
|
||||
"value": {
|
||||
"label": "Value",
|
||||
"placeholder": "6th August 1995"
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@ import certifications from './certifications.json';
|
||||
import skills from './skills.json';
|
||||
import languages from './languages.json';
|
||||
import references from './references.json';
|
||||
import extras from './extras.json';
|
||||
|
||||
export default {
|
||||
profile,
|
||||
@ -18,4 +19,5 @@ export default {
|
||||
skills,
|
||||
languages,
|
||||
references,
|
||||
extras,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user