From d53b4a88952d2138e74f884b02ce4d022d71de25 Mon Sep 17 00:00:00 2001 From: Brian Cao Date: Tue, 30 Aug 2022 00:03:22 -0700 Subject: [PATCH] roll back bigint. add loading --- components/common/Loading.js | 5 +- components/common/Loading.module.css | 12 +++ components/forms/DeleteForm.js | 7 ++ db/mysql/migrations/03_big_int/migration.sql | 102 ------------------ .../migration.sql | 0 .../migrations/03_big_int/migration.sql | 97 ----------------- .../migration.sql | 0 db/postgresql/schema.prisma | 32 +++--- lib/redis.js | 2 +- 9 files changed, 39 insertions(+), 218 deletions(-) delete mode 100644 db/mysql/migrations/03_big_int/migration.sql rename db/mysql/migrations/{04_remove_cascade_delete => 03_remove_cascade_delete}/migration.sql (100%) delete mode 100644 db/postgresql/migrations/03_big_int/migration.sql rename db/postgresql/migrations/{04_remove_casade_delete => 03_remove_casade_delete}/migration.sql (100%) diff --git a/components/common/Loading.js b/components/common/Loading.js index 16d8bb8a..81c8a77e 100644 --- a/components/common/Loading.js +++ b/components/common/Loading.js @@ -3,9 +3,9 @@ import PropTypes from 'prop-types'; import classNames from 'classnames'; import styles from './Loading.module.css'; -function Loading({ className }) { +function Loading({ className, overlay = false }) { return ( -
+
@@ -15,6 +15,7 @@ function Loading({ className }) { Loading.propTypes = { className: PropTypes.string, + overlay: PropTypes.bool, }; export default Loading; diff --git a/components/common/Loading.module.css b/components/common/Loading.module.css index 4e56dd8e..a69559e3 100644 --- a/components/common/Loading.module.css +++ b/components/common/Loading.module.css @@ -21,6 +21,14 @@ margin: 0; } +.loading.overlay { + height: 100%; + width: 100%; + z-index: 10; + background: var(--gray400); + opacity: 0.4; +} + .loading div { width: 10px; height: 10px; @@ -30,6 +38,10 @@ animation-fill-mode: both; } +.loading.overlay div { + background: var(--gray900); +} + .loading div + div { margin-left: 10px; } diff --git a/components/forms/DeleteForm.js b/components/forms/DeleteForm.js index 7fa5d6f6..09da94d6 100644 --- a/components/forms/DeleteForm.js +++ b/components/forms/DeleteForm.js @@ -8,6 +8,7 @@ import FormLayout, { FormMessage, FormRow, } from 'components/layout/FormLayout'; +import Loading from 'components/common/Loading'; import useApi from 'hooks/useApi'; const CONFIRMATION_WORD = 'DELETE'; @@ -29,8 +30,11 @@ const validate = ({ confirmation }) => { export default function DeleteForm({ values, onSave, onClose }) { const { del } = useApi(); const [message, setMessage] = useState(); + const [deleting, setDeleting] = useState(false); const handleSubmit = async ({ type, id }) => { + setDeleting(true); + const { ok, data } = await del(`/${type}/${id}`); if (ok) { @@ -39,11 +43,14 @@ export default function DeleteForm({ values, onSave, onClose }) { setMessage( data || , ); + + setDeleting(false); } }; return ( + {deleting && } { - if (!(await redis.get(INITIALIZED))) { + if (redis && !(await redis.get(INITIALIZED))) { await stageData(); } })();