Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't allow wallet names to start with @ #4306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react";
import React, { useState } from "react";
import { useTranslation } from "@coral-xyz/i18n";
import {
BpInputInner,
Expand All @@ -14,6 +14,15 @@ import { _IncognitoAvatarFromUsername } from "../../Unlocked/Settings/AvatarPopo
export function AccountName({ onNext }: { onNext: (val?: string) => void }) {
const { t } = useTranslation();
const [name, setName] = useState("");
const [error, setError] = useState("");

const handleNext = () => {
if (name.startsWith("@")) {
setError("Account name cannot start with '@'");
} else {
onNext(name);
}
};

return (
<YStack f={1} gap={40} width="100%">
Expand Down Expand Up @@ -43,14 +52,17 @@ export function AccountName({ onNext }: { onNext: (val?: string) => void }) {
<BpPrimaryButton
disabled={name === ""}
label={t("next")}
onPress={() => onNext(name)}
onPress={() => handleNext()}
/>
<BpLinkButton
label={t("skip")}
labelProps={{ color: "$baseTextMedEmphasis" }}
onPress={() => onNext()}
/>
</YStack>
{error ? <StyledText color="red" textAlign="center">
{error}
</StyledText> : null}
</YStack>
);
}