diff --git a/frontend/package.json b/frontend/package.json index e871cd1..07bf65d 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -22,7 +22,6 @@ "masonic": "^4.1.0", "react": "^19.0.0", "react-dom": "^19.0.0", - "react-i18next": "^15.5.1", "react-icons": "^5.5.0", "react-markdown": "^10.1.0", "react-router": "^7.5.3", diff --git a/frontend/public/cp.webp b/frontend/public/cp.webp new file mode 100644 index 0000000..cdc16dc Binary files /dev/null and b/frontend/public/cp.webp differ diff --git a/frontend/src/components/charactor_edit.tsx b/frontend/src/components/charactor_edit.tsx new file mode 100644 index 0000000..8217917 --- /dev/null +++ b/frontend/src/components/charactor_edit.tsx @@ -0,0 +1,97 @@ +import { useState } from "react"; +import { CharactorParams } from "../network/models"; +import { network } from "../network/network"; +import showToast from "./toast"; +import { useTranslation } from "../utils/i18n"; + +export default function CharactorEditor({charactor, setCharactor, onDelete}: { + charactor: CharactorParams; + setCharactor: (charactor: CharactorParams) => void; + onDelete: () => void; +}) { + const { t } = useTranslation(); + const [isUploading, setUploading] = useState(false); + + const uploadImage = async () => { + const input = document.createElement("input"); + input.type = "file"; + input.accept = "image/*"; + input.onchange = async () => { + if (!input.files || input.files.length === 0) { + return; + } + setUploading(true); + const file = input.files[0]; + const result = await network.uploadImage(file); + setUploading(false); + if (result.success) { + setCharactor({ + ...charactor, + image: result.data!, + }); + } else { + showToast({ + type: "error", + message: `Failed to upload image`, + }) + } + }; + input.click(); + } + + return
{t("Characters")}
+{t("Characters")}
+