import React, { memo, useContext, useState } from 'react'; import { FaFileExport, FaFileImport } from 'react-icons/fa'; import { useTranslation } from 'react-i18next'; import ModalContext from '../../../../contexts/ModalContext'; import { useDispatch, useSelector } from '../../../../contexts/ResumeContext'; import Button from '../../../shared/Button'; import Heading from '../../../shared/Heading'; import Input from '../../../shared/Input'; import styles from './Actions.module.css'; const Actions = ({ id }) => { const { t } = useTranslation(); const [loadDemoText, setLoadDemoText] = useState( t('builder.actions.loadDemoData.button'), ); const [resetText, setResetText] = useState( t('builder.actions.resetEverything.button'), ); const state = useSelector(); const dispatch = useDispatch(); const { emitter, events } = useContext(ModalContext); const handleImport = () => emitter.emit(events.IMPORT_MODAL); const handleExport = () => emitter.emit(events.EXPORT_MODAL); const getSharableUrl = () => { const shareId = state.id; return `https://rxresu.me/r/${shareId}`; }; const handleOpenLink = () => { if (typeof window !== `undefined`) { window && window.open(getSharableUrl()); } }; const handleLoadDemo = () => { if (loadDemoText === t('builder.actions.loadDemoData.button')) { setLoadDemoText(t('shared.buttons.confirmation')); return; } dispatch({ type: 'load_demo_data' }); setLoadDemoText(t('builder.actions.loadDemoData.button')); }; const handleReset = () => { if (resetText === t('builder.actions.resetEverything.button')) { setResetText(t('shared.buttons.confirmation')); return; } setResetText(t('builder.actions.resetEverything.button')); dispatch({ type: 'reset_data' }); }; return (
{t('builder.actions.import.heading')}

{t('builder.actions.import.text')}

{t('builder.actions.export.heading')}

{t('builder.actions.export.text')}

{t('builder.actions.share.heading')}

{t('builder.actions.export.text')}

{t('builder.actions.loadDemoData.button')}

{t('builder.actions.loadDemoData.text')}

{t('builder.actions.resetEverything.button')}

{t('builder.actions.resetEverything.text')}

); }; export default memo(Actions);