This commit is contained in:
D3vision 2023-02-07 22:32:36 +01:00
commit d7d7d84150

View File

@ -85,7 +85,6 @@ const Profile = () => {
const [file, setFile] = useState(null);
const [error, setError] = useState(null);
const fileSelector = useRef();
const usernameRef = useRef();
const displayNameRef = useRef();
const currPassRef = useRef();
@ -93,8 +92,8 @@ const Profile = () => {
const newPassRepeatRef = useRef();
const submit = async ({ target: button }) => {
button.disabled = true;
if (!file) return;
button.disabled = true;
const body = new FormData();
body.set('file', file, file.name);
@ -102,7 +101,7 @@ const Profile = () => {
const response = await post('/api/user/avatar', body, { headers: null });
if (!response.success) setError(response.message);
else fileSelector.current.value = null;
else setFile(null);
button.disabled = false;
};
@ -146,7 +145,7 @@ const Profile = () => {
<p><b>Change Profile Picture</b></p>
<form className="f-g f-b0">
<FileSelector cb={setFile} />
<button onClick={submit} className="button primary mt-3">Submit</button>
<button type='button' onClick={submit} className="button primary mt-3">Submit</button>
</form>
</div>
</div>