import React from 'react'; import { FileUp } from 'lucide-react'; import cleanupPreset from '~/utils/cleanupPreset.js'; import { useRecoilValue } from 'recoil'; import store from '~/store'; const FileUpload = ({ onFileSelected }) => { // const setPresets = useSetRecoilState(store.presets); const endpointsConfig = useRecoilValue(store.endpointsConfig); const handleFileChange = event => { const file = event.target.files[0]; if (!file) return; const reader = new FileReader(); reader.onload = e => { const jsonData = JSON.parse(e.target.result); onFileSelected({ ...cleanupPreset({ preset: jsonData, endpointsConfig }), presetId: null }); }; reader.readAsText(file); }; return ( ); }; export default FileUpload;