// Copyright (C) 2022-present Daniel31x13 // This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3. // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. // You should have received a copy of the GNU General Public License along with this program. If not, see . import { useState } from "react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faCircleUser, faClose } from "@fortawesome/free-solid-svg-icons"; import Checkbox from "../Checkbox"; import useAccountStore from "@/store/account"; import { AccountSettings } from "@/types/global"; type Props = { toggleSettingsModal: Function; }; export default function UserSettings({ toggleSettingsModal }: Props) { const { account, updateAccount } = useAccountStore(); let initialUser = { name: account.name, email: account.email, collectionProtection: account.collectionProtection, whitelistedUsers: account.whitelistedUsers, }; const [user, setUser] = useState(initialUser); const [selectedFile, setSelectedFile] = useState(null); const handleFileChange = (e: any) => { setSelectedFile(e.target.files[0]); }; const stateIsTampered = () => { return JSON.stringify(user) !== JSON.stringify(initialUser); }; const submit = async () => { updateAccount(user); initialUser = { name: account.name, email: account.email, collectionProtection: account.collectionProtection, whitelistedUsers: account.whitelistedUsers, }; }; return (

Settings

Profile Settings

Display Name

setUser({ ...user, name: e.target.value })} className="w-full rounded-md p-2 border-sky-100 border-solid border outline-none focus:border-sky-500 duration-100" />

Email

{user.email !== initialUser.email ? (

Please log back in if you change the Email.

) : null} setUser({ ...user, email: e.target.value })} className="w-full rounded-md p-2 border-sky-100 border-solid border outline-none focus:border-sky-500 duration-100" />

Password

Change Password
{/*

Profile Photo

// Image goes here
*/}

Data Settings

Export Data

Privacy Settings

setUser({ ...user, collectionProtection: !user.collectionProtection }) } /> {user.collectionProtection ? (

Please enter the email addresses of the users who are allowed to add you to additional collections in the box below, separated by spaces.

) : null} {stateIsTampered() ? (
Apply Settings
) : null}
); }