Skip to content

Commit

Permalink
Merge pull request #203 from bryanlundberg/fix-import-sync
Browse files Browse the repository at this point in the history
fix: sync cubes after import
  • Loading branch information
bryanlundberg authored Dec 6, 2023
2 parents e82f362 + 6272100 commit 984629d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions src/components/menu-settings/DataImportExport.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
import exportDataToFile from "@/lib/exportDataToFile";
import translation from "@/translations/global.json";
import { Button } from "@/components/button";
import { Language } from "@/interfaces/types/Language";
import { useRef } from "react";
import importDataFromFile from "@/lib/importDataFromFile";
import Import from "@/icons/Import";
import Export from "@/icons/Export";
import translation from "@/translations/global.json";
import { useSettingsModalStore } from "@/store/SettingsModalStore";
import { useTimerStore } from "@/store/timerStore";
import { useRouter } from "next/navigation";

interface DataImportExport {
lang: Language;
}

export function DataImportExport({ lang }: DataImportExport) {
export function DataImportExport() {
const dataInputRef = useRef<HTMLInputElement>(null);

const { lang } = useSettingsModalStore();
const { setSelectedCube } = useTimerStore();
const router = useRouter();
return (
<div className="light flex justify-center gap-2">
<input
type="file"
accept=".txt"
ref={dataInputRef}
className="hidden"
onChange={importDataFromFile}
onChange={(e) => {
importDataFromFile(e);
router.push("/cubes");
setSelectedCube(null);
}}
/>
<Button
className="font-normal transition duration-400"
Expand Down
2 changes: 1 addition & 1 deletion src/components/menu-settings/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default function MenuSettings() {
icon={<Folder />}
title={translation.settings["data"][lang]}
>
<DataImportExport lang={lang} />
<DataImportExport />
</MenuSection>
<MenuSection
icon={<Shield />}
Expand Down

0 comments on commit 984629d

Please sign in to comment.