diff --git a/components/modal/account/RenameAccountDialog.vue b/components/modal/account/RenameAccountDialog.vue new file mode 100644 index 0000000..8aa5e33 --- /dev/null +++ b/components/modal/account/RenameAccountDialog.vue @@ -0,0 +1,76 @@ + + + diff --git a/composables/useAccountNames.ts b/composables/useAccountNames.ts new file mode 100644 index 0000000..a2cbed2 --- /dev/null +++ b/composables/useAccountNames.ts @@ -0,0 +1,27 @@ +import { onMounted, ref } from "@nuxtjs/composition-api"; + +const store = ref({}); + +export function useAccountNames() { + + onMounted(() => { + store.value = JSON.parse( + window.localStorage.getItem(`account-names`) || "{}" + ); + }); + + function getAccountName(accountId) { + return store.value[accountId] || ""; + } + + function setAccountName(accountId, name) { + store.value[accountId] = name; + + window.localStorage.setItem(`account-names`, JSON.stringify(store.value)); + } + + return { + getAccountName, + setAccountName + }; +} diff --git a/pages/authority.vue b/pages/authority.vue index 6e09ea1..dc3ad16 100644 --- a/pages/authority.vue +++ b/pages/authority.vue @@ -55,7 +55,31 @@
#{{ activeAccount.id }}
- +
+ {{ getAccountName(activeAccount.id) || 'Account Name' }} + + +
@@ -109,7 +133,10 @@ Authorities - + Add authority
@@ -157,12 +184,14 @@ import { defineComponent, watch } from "@nuxtjs/composition-api"; import ButtonCTA from "~/components/common/input/ButtonCTA.vue"; import RemoveAuthorityDialog from "~/components/modal/authority/RemoveAuthorityDialog.vue"; import AddAuthorityDialog from "~/components/modal/authority/AddAuthorityDialog.vue"; +import RenameAccountDialog from "~/components/modal/account/RenameAccountDialog.vue"; import { useBalances } from "~/composables/useBalances"; import { useCopiedToClipboardUx } from "~/composables/useCopiedToClipboardUx"; import { useDSA } from "~/composables/useDSA"; import { useFormatting } from "~/composables/useFormatting"; import { useLink } from "~/composables/useLink"; import { useModal } from "~/composables/useModal"; +import { useAccountNames } from "~/composables/useAccountNames"; export default defineComponent({ components: { ButtonCTA }, @@ -180,6 +209,7 @@ export default defineComponent({ const { onCopy, tooltip, copied } = useCopiedToClipboardUx(); const { addressDetailsLink } = useLink(); const { showComponent } = useModal(); + const { getAccountName } = useAccountNames() watch(activeAccount, val => val && fetchBalances(true)); @@ -190,6 +220,9 @@ export default defineComponent({ const addAuthority = () => { showComponent(AddAuthorityDialog); }; + const renameAccount = (accountId: string) => { + showComponent(RenameAccountDialog, { accountId }); + }; return { addressDetailsLink, @@ -205,6 +238,8 @@ export default defineComponent({ copied, deleteAuthority, addAuthority, + renameAccount, + getAccountName, }; } });