From 07fc63014123e96afc08964f1234f03410b5cbd2 Mon Sep 17 00:00:00 2001 From: Akbar Date: Tue, 30 Apr 2024 07:26:54 +0500 Subject: [PATCH 1/8] new -> AccountDataMain --- .../components/AccountData/AccountData.jsx | 115 +------------- .../AccountDataMain/AccountDataMain.jsx | 141 ++++++++++++++++++ 2 files changed, 143 insertions(+), 113 deletions(-) create mode 100644 src/pages/Main/components/Account/components/AccountData/components/AccountDataMain/AccountDataMain.jsx diff --git a/src/pages/Main/components/Account/components/AccountData/AccountData.jsx b/src/pages/Main/components/Account/components/AccountData/AccountData.jsx index 23fe7ed..23c6a26 100644 --- a/src/pages/Main/components/Account/components/AccountData/AccountData.jsx +++ b/src/pages/Main/components/Account/components/AccountData/AccountData.jsx @@ -5,21 +5,19 @@ import Input from '../../../../../../components/Input/Input' import Choose from '../../../../../../components/Choose/Choose' import Loading from '../../../../../../components/Loading/Loading' import Message from '../../../../../../components/Message/Message' -import Avatar from '../utils/Avatar' import AvatarToEdit from '../utils/AvatarToEdit' import Alert from '../../../../../../components/Alert/Alert' import Tooplit from '../../../../../../components/Tooplit/Tooplit' +import AccountDataMain from './components/AccountDataMain/AccountDataMain' import { loadLocal } from '../../../../../../js/db/localStorage' import { getAccount, editUser, - logout as dbLogout, deleteAccount as dbDeleteAccount, } from '../../../../../../js/account/account' import { getData } from '../../../../../../js/utils/form' import { msgData } from '../../../../../../js/utils/message' -import { elText } from '../../../../../../js/utils/copy' import { load } from '../../../../../../js/db/db' import { getImgBlob } from '../../../../../../js/utils/img' import { avatars } from '../utils/getAvatar' @@ -28,19 +26,14 @@ import './AccountData.css' export default function AccountData() { const form = useRef(null) - const nameRef = useRef(null) - const usernameRef = useRef(null) const deleteRef = useRef(null) const [account, setAccount] = useState(false) const [editing, setEditing] = useState(false) const [saving, setSaving] = useState(false) - const [logingout, setLogingout] = useState(false) const [deleting, setDeleting] = useState(false) const [showTooplit, setShowTooplit] = useState(false) const [tooplitPos, setTooplitPos] = useState({ x: 0, y: 0 }) const [profileImg, setProfileImg] = useState('') - const [bigProfilePic, setBigProfilePic] = useState(false) - const [openProfilePic, setOpenProfilePic] = useState(false) const [message, setMessage] = useState({ text: '', type: 'error', @@ -53,8 +46,6 @@ export default function AccountData() { async function loadAccount() { const account = await getAccount(username) setAccount(account) - - if (account?.img?.img) setOpenProfilePic(true) } loadAccount() }, [saving]) @@ -104,21 +95,6 @@ export default function AccountData() { ) } - function copy(elRef) { - const msg = elText(elRef) - - setMessage({ ...msg, type: 'success', show: true }) - setTimeout( - () => setMessage({ ...message, show: false }), - msgData.time * 1000 - ) - } - - async function logoutAccount() { - const username = loadLocal('quran').accounts.active - dbLogout(username) - } - async function deleteAccount() { const username = loadLocal('quran').accounts.active const dbPassword = await load(`accounts/${username}/user/password`) @@ -381,92 +357,5 @@ export default function AccountData() { ) } - return ( - <> -
-
- - {message.msg} - -
- openProfilePic && setBigProfilePic(true)} - > - {bigProfilePic && ( - setBigProfilePic(false)} simple="true"> -
setBigProfilePic(false)} - > - -
-
- )} -
-
- copy(nameRef)}> - {account?.name} - -
-
copy(usernameRef)} - > - @{account?.username} -
-
-
- {!account && Main account} -
- {account && ( -
- - - -
- )} -
- {logingout && ( - setLogingout(false)}> -
- You should reload the page to apply changes. -
-
- -
-
- )} - - ) + return } diff --git a/src/pages/Main/components/Account/components/AccountData/components/AccountDataMain/AccountDataMain.jsx b/src/pages/Main/components/Account/components/AccountData/components/AccountDataMain/AccountDataMain.jsx new file mode 100644 index 0000000..32a2c8e --- /dev/null +++ b/src/pages/Main/components/Account/components/AccountData/components/AccountDataMain/AccountDataMain.jsx @@ -0,0 +1,141 @@ +import { useEffect, useRef, useState } from 'react' + +import Message from '../../../../../../../../components/Message/Message' +import Avatar from '../../../utils/Avatar' +import Alert from '../../../../../../../../components/Alert/Alert' +import Button from '../../../../../../../../components/Button/Button' +import Loading from '../../../../../../../../components/Loading/Loading' + +import { loadLocal } from '../../../../../../../../js/db/localStorage' +import { getAccount, logout } from '../../../../../../../../js/account/account' +import { elText } from '../../../../../../../../js/utils/copy' +import { msgData } from '../../../../../../../../js/utils/message' + +export default function AccountDataMain({ setEditing }) { + const nameRef = useRef(null) + const usernameRef = useRef(null) + const [account, setAccount] = useState(false) + const [bigProfilePic, setBigProfilePic] = useState(false) + const [logingout, setLogingout] = useState(false) + const [openProfilePic, setOpenProfilePic] = useState(false) + const [message, setMessage] = useState({ + text: '', + type: 'error', + show: false, + }) + + useEffect(() => { + const username = loadLocal('quran').accounts.active + async function loadAccount() { + const account = await getAccount(username) + setAccount(account) + + if (account?.img?.img) setOpenProfilePic(true) + } + loadAccount() + }, []) + + function copy(elRef) { + const msg = elText(elRef) + + setMessage({ ...msg, type: 'success', show: true }) + setTimeout( + () => setMessage({ ...message, show: false }), + msgData.time * 1000 + ) + } + + async function logoutAccount() { + const username = loadLocal('quran').accounts.active + logout(username) + } + + return ( + <> +
+
+ + {message.msg} + +
+ openProfilePic && setBigProfilePic(true)} + > + {bigProfilePic && ( + setBigProfilePic(false)} simple="true"> +
setBigProfilePic(false)} + > + +
+
+ )} +
+
+ copy(nameRef)}> + {account?.name} + +
+
copy(usernameRef)} + > + @{account?.username} +
+
+
+ {!account && Main account} +
+ {account && ( +
+ + + +
+ )} +
+ {logingout && ( + setLogingout(false)}> +
+ You should reload the page to apply changes. +
+
+ +
+
+ )} + + ) +} From 7d45192b9f104b9706000b835082e5e9624b5847 Mon Sep 17 00:00:00 2001 From: Akbar Date: Tue, 30 Apr 2024 07:46:39 +0500 Subject: [PATCH 2/8] get Account data from AccountData.jsx --- .../components/Account/components/AccountData/AccountData.jsx | 2 +- .../components/AccountDataMain/AccountDataMain.jsx | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pages/Main/components/Account/components/AccountData/AccountData.jsx b/src/pages/Main/components/Account/components/AccountData/AccountData.jsx index 23c6a26..0f1e094 100644 --- a/src/pages/Main/components/Account/components/AccountData/AccountData.jsx +++ b/src/pages/Main/components/Account/components/AccountData/AccountData.jsx @@ -357,5 +357,5 @@ export default function AccountData() { ) } - return + return } diff --git a/src/pages/Main/components/Account/components/AccountData/components/AccountDataMain/AccountDataMain.jsx b/src/pages/Main/components/Account/components/AccountData/components/AccountDataMain/AccountDataMain.jsx index 32a2c8e..bf8eed3 100644 --- a/src/pages/Main/components/Account/components/AccountData/components/AccountDataMain/AccountDataMain.jsx +++ b/src/pages/Main/components/Account/components/AccountData/components/AccountDataMain/AccountDataMain.jsx @@ -11,10 +11,9 @@ import { getAccount, logout } from '../../../../../../../../js/account/account' import { elText } from '../../../../../../../../js/utils/copy' import { msgData } from '../../../../../../../../js/utils/message' -export default function AccountDataMain({ setEditing }) { +export default function AccountDataMain({ account, setEditing }) { const nameRef = useRef(null) const usernameRef = useRef(null) - const [account, setAccount] = useState(false) const [bigProfilePic, setBigProfilePic] = useState(false) const [logingout, setLogingout] = useState(false) const [openProfilePic, setOpenProfilePic] = useState(false) @@ -28,7 +27,6 @@ export default function AccountDataMain({ setEditing }) { const username = loadLocal('quran').accounts.active async function loadAccount() { const account = await getAccount(username) - setAccount(account) if (account?.img?.img) setOpenProfilePic(true) } From 6124151fbe1ffbe0e10e743eb686cccd6cdd9a64 Mon Sep 17 00:00:00 2001 From: Akbar Date: Tue, 30 Apr 2024 07:51:07 +0500 Subject: [PATCH 3/8] new -> AccountDataNotFound --- .../components/AccountData/AccountData.jsx | 59 +------------------ .../AccountDataNotFound.jsx | 58 ++++++++++++++++++ 2 files changed, 60 insertions(+), 57 deletions(-) create mode 100644 src/pages/Main/components/Account/components/AccountData/components/AccountDataNotFound/AccountDataNotFound.jsx diff --git a/src/pages/Main/components/Account/components/AccountData/AccountData.jsx b/src/pages/Main/components/Account/components/AccountData/AccountData.jsx index 0f1e094..4b42d1e 100644 --- a/src/pages/Main/components/Account/components/AccountData/AccountData.jsx +++ b/src/pages/Main/components/Account/components/AccountData/AccountData.jsx @@ -8,6 +8,7 @@ import Message from '../../../../../../components/Message/Message' import AvatarToEdit from '../utils/AvatarToEdit' import Alert from '../../../../../../components/Alert/Alert' import Tooplit from '../../../../../../components/Tooplit/Tooplit' +import AccountDataNotFound from './components/AccountDataNotFound/AccountDataNotFound' import AccountDataMain from './components/AccountDataMain/AccountDataMain' import { loadLocal } from '../../../../../../js/db/localStorage' @@ -148,63 +149,7 @@ export default function AccountData() { fileInput.value = '' } - if (account === null) - return ( - <> -
-
- There is no account with - @{loadLocal('quran').accounts.active} -
-
-
(window.location.href = '/account/signup')} - > - - person_add - - Sign up -
-
(window.location.href = '/account/login')} - > - login - Log in -
-
-
-
Reasons
-
-
-
-
- 1. Account deleted due to inactivity. -
-
- 2. Mistaken deletion during maintenance. -
-
3. Technical error during creation.
-
4. Flagged for suspicious activity.
-
- 5. Data corruption or loss incident. -
-
6. System upgrade complications.
-
- 7. Intentional removal for policy violation. -
-
- 8. Account archived during restructuring. -
-
- 9. Inadvertent loss during data transfer. -
-
10. Security breach precautions.
-
-
- - ) + if (account === null) return if (editing) { return ( diff --git a/src/pages/Main/components/Account/components/AccountData/components/AccountDataNotFound/AccountDataNotFound.jsx b/src/pages/Main/components/Account/components/AccountData/components/AccountDataNotFound/AccountDataNotFound.jsx new file mode 100644 index 0000000..a679e2c --- /dev/null +++ b/src/pages/Main/components/Account/components/AccountData/components/AccountDataNotFound/AccountDataNotFound.jsx @@ -0,0 +1,58 @@ +import { loadLocal } from '../../../../../../../../js/db/localStorage' + +export default function AccountDataNotFound() { + const reasonsArray = [ + 'Account deleted due to inactivity', + 'Mistaken deletion during maintenance', + 'Technical error during creation', + 'Flagged for suspicious activity', + 'Data corruption or loss incident', + 'System upgrade complications', + 'Intentional removal for policy violation', + 'Account archived during restructuring', + 'Inadvertent loss during data transfer', + 'Security breach precautions', + ] + + return ( + <> +
+
+ There is no account with + @{loadLocal('quran').accounts.active} +
+
+
(window.location.href = '/account/signup')} + > + + person_add + + Sign up +
+
(window.location.href = '/account/login')} + > + login + Log in +
+
+
+
Reasons
+
+
+
+ {reasonsArray.map((reason, i) => { + return ( +
+ {reason} +
+ ) + })} +
+
+ + ) +} From 8e65009d70b0022fe9a858aad7f0d52d43ae0666 Mon Sep 17 00:00:00 2001 From: Akbar Date: Tue, 30 Apr 2024 08:39:11 +0500 Subject: [PATCH 4/8] AccountDataMain fixed --- .../components/AccountDataMain/AccountDataMain.jsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/Main/components/Account/components/AccountData/components/AccountDataMain/AccountDataMain.jsx b/src/pages/Main/components/Account/components/AccountData/components/AccountDataMain/AccountDataMain.jsx index bf8eed3..09d52b5 100644 --- a/src/pages/Main/components/Account/components/AccountData/components/AccountDataMain/AccountDataMain.jsx +++ b/src/pages/Main/components/Account/components/AccountData/components/AccountDataMain/AccountDataMain.jsx @@ -11,17 +11,17 @@ import { getAccount, logout } from '../../../../../../../../js/account/account' import { elText } from '../../../../../../../../js/utils/copy' import { msgData } from '../../../../../../../../js/utils/message' -export default function AccountDataMain({ account, setEditing }) { +export default function AccountDataMain({ + account, + message, + setMessage, + setEditing, +}) { const nameRef = useRef(null) const usernameRef = useRef(null) const [bigProfilePic, setBigProfilePic] = useState(false) const [logingout, setLogingout] = useState(false) const [openProfilePic, setOpenProfilePic] = useState(false) - const [message, setMessage] = useState({ - text: '', - type: 'error', - show: false, - }) useEffect(() => { const username = loadLocal('quran').accounts.active From 0d2412b890e6a11b130caa537673f98356318e81 Mon Sep 17 00:00:00 2001 From: Akbar Date: Tue, 30 Apr 2024 08:39:26 +0500 Subject: [PATCH 5/8] new -> AccountDataEditing --- .../components/AccountData/AccountData.jsx | 294 ++---------------- .../AccountDataEditing/AccountDataEditing.jsx | 274 ++++++++++++++++ 2 files changed, 294 insertions(+), 274 deletions(-) create mode 100644 src/pages/Main/components/Account/components/AccountData/components/AccountDataEditing/AccountDataEditing.jsx diff --git a/src/pages/Main/components/Account/components/AccountData/AccountData.jsx b/src/pages/Main/components/Account/components/AccountData/AccountData.jsx index 4b42d1e..690cc43 100644 --- a/src/pages/Main/components/Account/components/AccountData/AccountData.jsx +++ b/src/pages/Main/components/Account/components/AccountData/AccountData.jsx @@ -1,46 +1,23 @@ -import { useEffect, useRef, useState } from 'react' +import { useEffect, useState } from 'react' -import Button from '../../../../../../components/Button/Button' -import Input from '../../../../../../components/Input/Input' -import Choose from '../../../../../../components/Choose/Choose' -import Loading from '../../../../../../components/Loading/Loading' -import Message from '../../../../../../components/Message/Message' -import AvatarToEdit from '../utils/AvatarToEdit' -import Alert from '../../../../../../components/Alert/Alert' -import Tooplit from '../../../../../../components/Tooplit/Tooplit' import AccountDataNotFound from './components/AccountDataNotFound/AccountDataNotFound' import AccountDataMain from './components/AccountDataMain/AccountDataMain' +import AccountDataEditing from './components/AccountDataEditing/AccountDataEditing' import { loadLocal } from '../../../../../../js/db/localStorage' -import { - getAccount, - editUser, - deleteAccount as dbDeleteAccount, -} from '../../../../../../js/account/account' -import { getData } from '../../../../../../js/utils/form' -import { msgData } from '../../../../../../js/utils/message' -import { load } from '../../../../../../js/db/db' -import { getImgBlob } from '../../../../../../js/utils/img' -import { avatars } from '../utils/getAvatar' +import { getAccount } from '../../../../../../js/account/account' import './AccountData.css' export default function AccountData() { - const form = useRef(null) - const deleteRef = useRef(null) const [account, setAccount] = useState(false) const [editing, setEditing] = useState(false) const [saving, setSaving] = useState(false) - const [deleting, setDeleting] = useState(false) - const [showTooplit, setShowTooplit] = useState(false) - const [tooplitPos, setTooplitPos] = useState({ x: 0, y: 0 }) - const [profileImg, setProfileImg] = useState('') const [message, setMessage] = useState({ text: '', type: 'error', show: false, }) - const profilePicLimit = 5 * 1024 * 1024 useEffect(() => { const username = loadLocal('quran').accounts.active @@ -51,256 +28,25 @@ export default function AccountData() { loadAccount() }, [saving]) - useEffect(() => { - setProfileImg(account?.img?.img) - }, [editing]) - - async function saveChanges() { - setSaving(true) - - const formData = getData(form.current) - if (!formData.ok) { - setMessage({ msg: formData.msg, type: 'error', show: true }) - setTimeout( - () => setMessage({ ...message, show: false }), - msgData.time * 1000 - ) - setSaving(false) - return - } - - const username = loadLocal('quran').accounts.active - - const userNewData = { ...formData, img: { img: profileImg } } - const editedData = await editUser(username, userNewData) - - avatars.get(username).img = profileImg - - if (!editedData.ok) { - setMessage({ msg: editedData.msg, type: editedData.msgType, show: true }) - setTimeout( - () => setMessage({ ...message, show: false }), - msgData.time * 1000 - ) - setSaving(false) - return - } - - setSaving(false) - setEditing(false) - - setMessage({ msg: 'Changes saved', type: 'success', show: true }) - setTimeout( - () => setMessage({ ...message, show: false }), - msgData.time * 1000 - ) - } - - async function deleteAccount() { - const username = loadLocal('quran').accounts.active - const dbPassword = await load(`accounts/${username}/user/password`) - const password = deleteRef.current?.value - - const correct = dbPassword === password - - if (!correct) { - setMessage({ msg: 'Password is not matching', type: 'error', show: true }) - setTimeout( - () => setMessage({ ...message, show: false }), - msgData.time * 1000 - ) - return - } - - dbDeleteAccount(username) - } - - function showUpTooplit(e) { - const { clientX: x, clientY: y } = e - - setTooplitPos({ x, y }) - setShowTooplit(true) - } - - function clickFileInput(e) { - const fileInput = e.target?.querySelector('input[type="file"]') - fileInput?.click() - } - - async function uploadFile(e) { - const fileInput = e.target - if (!fileInput) return - - const file = fileInput.files[0] - if (file.size > profilePicLimit) { - setMessage({ msg: 'Max file size is 5MB', type: 'error', show: true }) - setTimeout( - () => setMessage({ ...message, show: false }), - msgData.time * 1000 - ) - return - } - - const blob = await getImgBlob(file) - - setProfileImg(blob) - setShowTooplit(false) - - fileInput.value = '' - } - if (account === null) return - - if (editing) { + if (editing) return ( -
-
- - {message.msg} - -
- Edit -
- - -
-
-
- -
-
- edit -
-
-
- {showTooplit && ( - setShowTooplit(false)} pos={tooplitPos}> -
-
- - cloud_upload - - Upload - -
- {profileImg && ( -
{ - setProfileImg('') - setShowTooplit(false) - }} - > - - delete - - Delete -
- )} -
-
- )} -
-
- person - -
-
- - alternate_email - - -
-
-
- -
- - male - -
Male
-
-
- - female - -
Female
-
-
- - {saving && Saving} -
- {deleting && ( - setDeleting(false)}> - -
- You should reload the page to apply changes. -
-
- -
-
- )} -
+ ) - } - return + return ( + + ) } diff --git a/src/pages/Main/components/Account/components/AccountData/components/AccountDataEditing/AccountDataEditing.jsx b/src/pages/Main/components/Account/components/AccountData/components/AccountDataEditing/AccountDataEditing.jsx new file mode 100644 index 0000000..f6b900a --- /dev/null +++ b/src/pages/Main/components/Account/components/AccountData/components/AccountDataEditing/AccountDataEditing.jsx @@ -0,0 +1,274 @@ +import { useEffect, useRef, useState } from 'react' + +import Message from '../../../../../../../../components/Message/Message' +import Button from '../../../../../../../../components/Button/Button' +import Input from '../../../../../../../../components/Input/Input' +import Choose from '../../../../../../../../components/Choose/Choose' +import Loading from '../../../../../../../../components/Loading/Loading' +import AvatarToEdit from '../../../utils/AvatarToEdit' +import Alert from '../../../../../../../../components/Alert/Alert' +import Tooplit from '../../../../../../../../components/Tooplit/Tooplit' + +import { deleteAccount as dbDeleteAccount } from '../../../../../../../../js/account/account' +import { getImgBlob } from '../../../../../../../../js/utils/img' +import { msgData } from '../../../../../../../../js/utils/message' +import { getData } from '../../../../../../../../js/utils/form' +import { loadLocal } from '../../../../../../../../js/db/localStorage' +import { editUser } from '../../../../../../../../js/account/account' +import { avatars } from '../../../utils/getAvatar' +import { load } from '../../../../../../../../js/db/db' + +export default function AccountDataEditing({ + account, + saving, + message, + setEditing, + setSaving, + setMessage, +}) { + const form = useRef(null) + const deleteRef = useRef(null) + const [deleting, setDeleting] = useState(false) + const [showTooplit, setShowTooplit] = useState(false) + const [tooplitPos, setTooplitPos] = useState({ x: 0, y: 0 }) + const [profileImg, setProfileImg] = useState('') + const profilePicLimit = 5 * 1024 * 1024 + + useEffect(() => { + setProfileImg(account?.img?.img) + }, []) + + async function saveChanges() { + setSaving(true) + + const formData = getData(form.current) + if (!formData.ok) { + setMessage({ msg: formData.msg, type: 'error', show: true }) + setTimeout( + () => setMessage({ ...message, show: true }), + msgData.time * 1000 + ) + setSaving(false) + return + } + + const username = loadLocal('quran').accounts.active + + const userNewData = { ...formData, img: { img: profileImg } } + const editedData = await editUser(username, userNewData) + + avatars.get(username).img = profileImg + + if (!editedData.ok) { + setMessage({ msg: editedData.msg, type: editedData.msgType, show: true }) + setTimeout( + () => setMessage({ ...message, show: true }), + msgData.time * 1000 + ) + setSaving(false) + return + } + + setSaving(false) + setEditing(false) + + setMessage({ msg: 'Changes saved', type: 'success', show: true }) + setTimeout( + () => setMessage({ ...message, show: true }), + msgData.time * 1000 + ) + } + + async function deleteAccount() { + const username = loadLocal('quran').accounts.active + const dbPassword = await load(`accounts/${username}/user/password`) + const password = deleteRef.current?.value + + const correct = dbPassword === password + + if (!correct) { + setMessage({ msg: 'Password is not matching', type: 'error', show: true }) + setTimeout( + () => setMessage({ ...message, show: false }), + msgData.time * 1000 + ) + return + } + + dbDeleteAccount(username) + } + + function showUpTooplit(e) { + const { clientX: x, clientY: y } = e + + setTooplitPos({ x, y }) + setShowTooplit(true) + } + + function clickFileInput(e) { + const fileInput = e.target?.querySelector('input[type="file"]') + fileInput?.click() + } + + async function uploadFile(e) { + const fileInput = e.target + if (!fileInput) return + + const file = fileInput.files[0] + if (file.size > profilePicLimit) { + setMessage({ msg: 'Max file size is 5MB', type: 'error', show: true }) + setTimeout( + () => setMessage({ ...message, show: false }), + msgData.time * 1000 + ) + return + } + + const blob = await getImgBlob(file) + + setProfileImg(blob) + setShowTooplit(false) + + fileInput.value = '' + } + + return ( +
+ + {message.msg} + +
+
+ Edit +
+ + +
+
+
+ +
+
+ edit +
+
+
+ {showTooplit && ( + setShowTooplit(false)} pos={tooplitPos}> +
+
+ + cloud_upload + + Upload + +
+ {profileImg && ( +
{ + setProfileImg('') + setShowTooplit(false) + }} + > + + delete + + Delete +
+ )} +
+
+ )} +
+
+ person + +
+
+ alternate_email + +
+
+
+ +
+ + male + +
Male
+
+
+ + female + +
Female
+
+
+ + {saving && Saving} +
+ {deleting && ( + setDeleting(false)}> + +
+ You should reload the page to apply changes. +
+
+ +
+
+ )} +
+ ) +} From 44530df20290f6bb480752e99f35eb9f1e123919 Mon Sep 17 00:00:00 2001 From: Akbar Date: Tue, 30 Apr 2024 08:40:18 +0500 Subject: [PATCH 6/8] renaming --- .../Account/components/AccountData/AccountData.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/Main/components/Account/components/AccountData/AccountData.jsx b/src/pages/Main/components/Account/components/AccountData/AccountData.jsx index 690cc43..5cc6cfe 100644 --- a/src/pages/Main/components/Account/components/AccountData/AccountData.jsx +++ b/src/pages/Main/components/Account/components/AccountData/AccountData.jsx @@ -21,11 +21,11 @@ export default function AccountData() { useEffect(() => { const username = loadLocal('quran').accounts.active - async function loadAccount() { - const account = await getAccount(username) - setAccount(account) + async function loadData() { + const data = await getAccount(username) + setAccount(data) } - loadAccount() + loadData() }, [saving]) if (account === null) return From 8ef30f63be0f78eb8cff1f2b0fa0b8259d12c9d0 Mon Sep 17 00:00:00 2001 From: Akbar Date: Tue, 30 Apr 2024 08:44:49 +0500 Subject: [PATCH 7/8] message improved --- .../Account/components/AccountData/AccountData.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/Main/components/Account/components/AccountData/AccountData.jsx b/src/pages/Main/components/Account/components/AccountData/AccountData.jsx index 5cc6cfe..8fa2f82 100644 --- a/src/pages/Main/components/Account/components/AccountData/AccountData.jsx +++ b/src/pages/Main/components/Account/components/AccountData/AccountData.jsx @@ -15,7 +15,7 @@ export default function AccountData() { const [saving, setSaving] = useState(false) const [message, setMessage] = useState({ text: '', - type: 'error', + type: 'default', show: false, }) @@ -28,6 +28,10 @@ export default function AccountData() { loadData() }, [saving]) + useEffect(() => { + setMessage({ ...message, show: false }) + }, [editing]) + if (account === null) return if (editing) return ( From adb6839183ec63340025db72bbc59b6ce32fe4b8 Mon Sep 17 00:00:00 2001 From: Akbar Date: Tue, 30 Apr 2024 08:48:20 +0500 Subject: [PATCH 8/8] import improved --- .../components/Account/components/AccountData/AccountData.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Main/components/Account/components/AccountData/AccountData.jsx b/src/pages/Main/components/Account/components/AccountData/AccountData.jsx index 8fa2f82..7d873b6 100644 --- a/src/pages/Main/components/Account/components/AccountData/AccountData.jsx +++ b/src/pages/Main/components/Account/components/AccountData/AccountData.jsx @@ -1,8 +1,8 @@ import { useEffect, useState } from 'react' import AccountDataNotFound from './components/AccountDataNotFound/AccountDataNotFound' -import AccountDataMain from './components/AccountDataMain/AccountDataMain' import AccountDataEditing from './components/AccountDataEditing/AccountDataEditing' +import AccountDataMain from './components/AccountDataMain/AccountDataMain' import { loadLocal } from '../../../../../../js/db/localStorage' import { getAccount } from '../../../../../../js/account/account'