Skip to content

Commit

Permalink
check name exist
Browse files Browse the repository at this point in the history
  • Loading branch information
yu23ki14 committed Jan 11, 2025
1 parent 2d64492 commit 3bad68c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pkgs/frontend/app/routes/$treeId_.splits.new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ const SplitterNew: FC = () => {
const availableName = useMemo(() => {
if (!splitterName) return false;

return addresses?.[0]?.length === 0;
return addresses[0].length === 0;
}, [splitterName, addresses]);

const { createSplits, previewSplits, isLoading } = useSplitsCreator(
Expand Down
51 changes: 31 additions & 20 deletions pkgs/frontend/app/routes/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useAddressesByNames, useSetName } from "hooks/useENS";
import { useUploadImageFileToIpfs } from "hooks/useIpfs";
import { useActiveWallet } from "hooks/useWallet";
import type { TextRecords } from "namestone-sdk";
import { type FC, useMemo, useState } from "react";
import { type FC, useCallback, useMemo, useState } from "react";
import { BasicButton } from "~/components/BasicButton";
import { CommonInput } from "~/components/common/CommonInput";
import { UserIcon } from "~/components/icon/UserIcon";
Expand All @@ -30,31 +30,42 @@ const Login: FC = () => {
const availableName = useMemo(() => {
if (!userName) return false;

return addresses?.[0]?.length === 0;
return addresses[0].length === 0;
}, [userName, addresses]);

const handleSubmit = async () => {
const handleSubmit = useCallback(async () => {
if (!wallet || !availableName) return;

const params: {
name: string;
address: string;
text_records: TextRecords;
} = {
name: userName,
address: wallet.account?.address,
text_records: {},
};
try {
const params: {
name: string;
address: string;
text_records: TextRecords;
} = {
name: userName,
address: wallet.account?.address,
text_records: {},
};

if (imageFile) {
const res = await uploadImageFileToIpfs();
if (res) params.text_records.avatar = res.ipfsUri;
}

await setName(params);
if (imageFile) {
const res = await uploadImageFileToIpfs();
if (res) params.text_records.avatar = res.ipfsUri;
}

window.location.href = "/workspace";
};
await setName(params);
} catch (error) {
console.error(error);
} finally {
window.location.href = "/workspace";
}
}, [
availableName,
imageFile,
setName,
uploadImageFileToIpfs,
userName,
wallet,
]);

return (
<Grid gridTemplateRows="1fr auto" h="calc(100vh - 72px)">
Expand Down

0 comments on commit 3bad68c

Please sign in to comment.