mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-17 18:21:28 +10:00
Remove useTranslation hook from util functions
This commit is contained in:
@ -21,7 +21,7 @@ const List = ({
|
|||||||
hasDate,
|
hasDate,
|
||||||
event,
|
event,
|
||||||
}) => {
|
}) => {
|
||||||
const { i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
const items = useSelector(path, []);
|
const items = useSelector(path, []);
|
||||||
const { emitter } = useContext(ModalContext);
|
const { emitter } = useContext(ModalContext);
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ const List = ({
|
|||||||
startDate: x.startDate,
|
startDate: x.startDate,
|
||||||
endDate: x.endDate,
|
endDate: x.endDate,
|
||||||
language: i18n.language,
|
language: i18n.language,
|
||||||
}))
|
}, t))
|
||||||
}
|
}
|
||||||
text={text || get(x, textPath, '')}
|
text={text || get(x, textPath, '')}
|
||||||
onEdit={() => handleEdit(x)}
|
onEdit={() => handleEdit(x)}
|
||||||
|
|||||||
@ -85,7 +85,7 @@ const DataModal = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getTitle = isEmpty(title)
|
const getTitle = isEmpty(title)
|
||||||
? getModalText(isEditMode, name)
|
? getModalText(isEditMode, name, t)
|
||||||
: isEditMode
|
: isEditMode
|
||||||
? title.edit
|
? title.edit
|
||||||
: title.create;
|
: title.create;
|
||||||
|
|||||||
@ -1,37 +1,41 @@
|
|||||||
import React, { memo, useContext } from 'react';
|
import React, { memo, useContext } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import ReactMarkdown from 'react-markdown';
|
import ReactMarkdown from 'react-markdown';
|
||||||
import PageContext from '../../../contexts/PageContext';
|
import PageContext from '../../../contexts/PageContext';
|
||||||
import { formatDateRange, safetyCheck } from '../../../utils';
|
import { formatDateRange, safetyCheck } from '../../../utils';
|
||||||
|
|
||||||
const EducationItem = ({ item, language }) => (
|
const EducationItem = ({ item, language }) => {
|
||||||
<div>
|
const { t } = useTranslation();
|
||||||
<div className="flex justify-between items-center">
|
return (
|
||||||
<div className="flex flex-col text-left mr-2">
|
<div>
|
||||||
<h6 className="font-semibold">{item.institution}</h6>
|
<div className="flex justify-between items-center">
|
||||||
<span className="text-xs">
|
<div className="flex flex-col text-left mr-2">
|
||||||
<strong>{item.degree}</strong> {item.field}
|
<h6 className="font-semibold">{item.institution}</h6>
|
||||||
</span>
|
<span className="text-xs">
|
||||||
</div>
|
<strong>{item.degree}</strong> {item.field}
|
||||||
<div className="flex flex-col items-end text-right">
|
</span>
|
||||||
{item.startDate && (
|
</div>
|
||||||
<h6 className="text-xs font-medium mb-1">
|
<div className="flex flex-col items-end text-right">
|
||||||
(
|
{item.startDate && (
|
||||||
{formatDateRange({
|
<h6 className="text-xs font-medium mb-1">
|
||||||
startDate: item.startDate,
|
(
|
||||||
endDate: item.endDate,
|
{formatDateRange({
|
||||||
language,
|
startDate: item.startDate,
|
||||||
})}
|
endDate: item.endDate,
|
||||||
)
|
language,
|
||||||
</h6>
|
}, t)}
|
||||||
)}
|
)
|
||||||
<span className="text-sm font-medium">{item.gpa}</span>
|
</h6>
|
||||||
|
)}
|
||||||
|
<span className="text-sm font-medium">{item.gpa}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{item.summary && (
|
||||||
|
<ReactMarkdown className="markdown mt-2 text-sm" source={item.summary} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{item.summary && (
|
);
|
||||||
<ReactMarkdown className="markdown mt-2 text-sm" source={item.summary} />
|
};
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
const EducationA = () => {
|
const EducationA = () => {
|
||||||
const { data, heading: Heading } = useContext(PageContext);
|
const { data, heading: Heading } = useContext(PageContext);
|
||||||
|
|||||||
@ -1,32 +1,36 @@
|
|||||||
import React, { memo, useContext } from 'react';
|
import React, { memo, useContext } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import ReactMarkdown from 'react-markdown';
|
import ReactMarkdown from 'react-markdown';
|
||||||
import PageContext from '../../../contexts/PageContext';
|
import PageContext from '../../../contexts/PageContext';
|
||||||
import { formatDateRange, safetyCheck } from '../../../utils';
|
import { formatDateRange, safetyCheck } from '../../../utils';
|
||||||
|
|
||||||
const WorkItem = ({ item, language }) => (
|
const WorkItem = ({ item, language }) => {
|
||||||
<div>
|
const { t } = useTranslation();
|
||||||
<div className="flex justify-between items-center">
|
return (
|
||||||
<div className="flex flex-col text-left mr-2">
|
<div>
|
||||||
<h6 className="font-semibold">{item.company}</h6>
|
<div className="flex justify-between items-center">
|
||||||
<span className="text-xs">{item.position}</span>
|
<div className="flex flex-col text-left mr-2">
|
||||||
|
<h6 className="font-semibold">{item.company}</h6>
|
||||||
|
<span className="text-xs">{item.position}</span>
|
||||||
|
</div>
|
||||||
|
{item.startDate && (
|
||||||
|
<h6 className="text-xs font-medium text-right">
|
||||||
|
(
|
||||||
|
{formatDateRange({
|
||||||
|
startDate: item.startDate,
|
||||||
|
endDate: item.endDate,
|
||||||
|
language,
|
||||||
|
}, t)}
|
||||||
|
)
|
||||||
|
</h6>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{item.startDate && (
|
{item.summary && (
|
||||||
<h6 className="text-xs font-medium text-right">
|
<ReactMarkdown className="markdown mt-2 text-sm" source={item.summary} />
|
||||||
(
|
|
||||||
{formatDateRange({
|
|
||||||
startDate: item.startDate,
|
|
||||||
endDate: item.endDate,
|
|
||||||
language,
|
|
||||||
})}
|
|
||||||
)
|
|
||||||
</h6>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{item.summary && (
|
);
|
||||||
<ReactMarkdown className="markdown mt-2 text-sm" source={item.summary} />
|
};
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
const WorkA = () => {
|
const WorkA = () => {
|
||||||
const { data, heading: Heading } = useContext(PageContext);
|
const { data, heading: Heading } = useContext(PageContext);
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { get, isEmpty } from 'lodash';
|
import { get, isEmpty } from 'lodash';
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
export const getModalText = (isEditMode, type) => {
|
export const getModalText = (isEditMode, type, t) => {
|
||||||
const { t } = useTranslation();
|
|
||||||
return isEditMode
|
return isEditMode
|
||||||
? `${t('shared.buttons.edit')} ${type}`
|
? `${t('shared.buttons.edit')} ${type}`
|
||||||
: `${t('shared.buttons.add')} ${type}`;
|
: `${t('shared.buttons.add')} ${type}`;
|
||||||
@ -26,8 +24,7 @@ export const formatDate = ({ date, language = 'en' }) => {
|
|||||||
return dayjs(date).locale(language.substr(0, 2)).format('MMMM YYYY');
|
return dayjs(date).locale(language.substr(0, 2)).format('MMMM YYYY');
|
||||||
};
|
};
|
||||||
|
|
||||||
export const formatDateRange = ({ startDate, endDate, language = 'en' }) => {
|
export const formatDateRange = ({ startDate, endDate, language = 'en' }, t) => {
|
||||||
const { t } = useTranslation();
|
|
||||||
const start = `${dayjs(startDate)
|
const start = `${dayjs(startDate)
|
||||||
.locale(language.substr(0, 2))
|
.locale(language.substr(0, 2))
|
||||||
.format('MMMM YYYY')}`;
|
.format('MMMM YYYY')}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user