From 653b8110a7e85d94cedb56925c7cb04e2ff0d9a8 Mon Sep 17 00:00:00 2001 From: Erik Hanson Date: Tue, 14 Mar 2023 21:47:45 -0700 Subject: [PATCH] Fix photo update UI/UX bug --- ui/src/components/auth/UploaderAuth.jsx | 2 +- ui/src/components/routes/UploaderLogin.jsx | 16 ++++++++++++++++ ui/src/components/uploader/PhotoUploader.jsx | 6 ++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ui/src/components/auth/UploaderAuth.jsx b/ui/src/components/auth/UploaderAuth.jsx index 8eb7327..4be0732 100644 --- a/ui/src/components/auth/UploaderAuth.jsx +++ b/ui/src/components/auth/UploaderAuth.jsx @@ -18,7 +18,7 @@ export function UploaderAuth() { const onSubmit = async (event) => { event.preventDefault(); - setIsSubmitting(false); + setIsSubmitting(true); setErrorMessage(""); try { diff --git a/ui/src/components/routes/UploaderLogin.jsx b/ui/src/components/routes/UploaderLogin.jsx index 88efb92..5f3c209 100644 --- a/ui/src/components/routes/UploaderLogin.jsx +++ b/ui/src/components/routes/UploaderLogin.jsx @@ -1,7 +1,23 @@ import { MainComponentWrapper } from "../MainComponentWrapper.jsx"; import { UploaderAuth } from "../auth/UploaderAuth.jsx"; +import { useUploaderAuthProtected } from "../../lib/customHooks.js"; +import { route } from "preact-router"; +import { constants } from "../../lib/constants.js"; +import { useEffect } from "preact/hooks"; export function UploaderLogin() { + const isUploader = useUploaderAuthProtected(); + + useEffect(() => { + if (isUploader) { + route(constants.ROUTES.UPLOADER.DASHBOARD, true); + } + }, [isUploader]); + + if (isUploader) { + return null; + } + return ( diff --git a/ui/src/components/uploader/PhotoUploader.jsx b/ui/src/components/uploader/PhotoUploader.jsx index 1e02d1a..4965a67 100644 --- a/ui/src/components/uploader/PhotoUploader.jsx +++ b/ui/src/components/uploader/PhotoUploader.jsx @@ -113,10 +113,12 @@ export function PhotoUploader() { value={file} onInput={async (e) => { setFile(e.target?.files[0]); - const dateTime = await tryGetDateTimeFromImage( + const currentDateTime = await tryGetDateTimeFromImage( e.target?.files[0] ); - setDateTime(dateTime); + if (currentDateTime !== null) { + setDateTime(currentDateTime); + } }} className="file-input file-input-bordered w-full" />