diff --git a/src/components/MarkFormField/index.tsx b/src/components/MarkFormField/index.tsx index 02f34cc..9a14989 100644 --- a/src/components/MarkFormField/index.tsx +++ b/src/components/MarkFormField/index.tsx @@ -1,9 +1,8 @@ import { CurrentUserMark } from '../../types/mark.ts' import styles from './style.module.scss' - -import { MARK_TYPE_TRANSLATION } from '../../utils/const.ts' import { findNextIncompleteCurrentUserMark, + getToolboxLabelByMarkType, isCurrentUserMarksComplete, isCurrentValueLast } from '../../utils' @@ -53,6 +52,7 @@ const MarkFormField = ({ : handleCurrentUserMarkChange(findNext()!) } const toggleActions = () => setDisplayActions(!displayActions) + const markLabel = getToolboxLabelByMarkType(selectedMark.mark.type) return (
@@ -78,16 +78,14 @@ const MarkFormField = ({
-

Add your signature

+

Add {markLabel}

handleFormSubmit(e)}> diff --git a/src/pages/create/index.tsx b/src/pages/create/index.tsx index 90d359b..3374a08 100644 --- a/src/pages/create/index.tsx +++ b/src/pages/create/index.tsx @@ -246,17 +246,22 @@ export const CreatePage = () => { const input = userInput.toLowerCase() if (input.startsWith('npub')) { - const pubkey = npubToHex(input) - if (pubkey) { - addUser(pubkey) - setUserInput('') - } else { - setError('Provided npub is not valid. Please enter correct npub.') - } - return + return handleAddNpubUser(input) } if (input.includes('@')) { + return await handleAddNip05User(input) + } + + // If the user enters the domain (w/o @) assume it's the "root" and append _@ + // https://github.com/nostr-protocol/nips/blob/master/05.md#showing-just-the-domain-as-an-identifier + if (input.includes('.')) { + return await handleAddNip05User(`_@${input}`) + } + + setError('Invalid input! Make sure to provide correct npub or nip05.') + + async function handleAddNip05User(input: string) { setIsLoading(true) setLoadingSpinnerDesc('Querying for nip05') const nip05Profile = await queryNip05(input) @@ -279,7 +284,16 @@ export const CreatePage = () => { return } - setError('Invalid input! Make sure to provide correct npub or nip05.') + function handleAddNpubUser(input: string) { + const pubkey = npubToHex(input) + if (pubkey) { + addUser(pubkey) + setUserInput('') + } else { + setError('Provided npub is not valid. Please enter correct npub.') + } + return + } } const handleUserRoleChange = (role: UserRole, pubkey: string) => { diff --git a/src/utils/const.ts b/src/utils/const.ts index 8e53a46..38f138e 100644 --- a/src/utils/const.ts +++ b/src/utils/const.ts @@ -1,9 +1,4 @@ -import { MarkType } from '../types/drawing.ts' - export const EMPTY: string = '' -export const MARK_TYPE_TRANSLATION: { [key: string]: string } = { - [MarkType.FULLNAME.valueOf()]: 'Full Name' -} export const ARRAY_BUFFER = 'arraybuffer' export const DEFLATE = 'DEFLATE'