Skip to content

Commit

Permalink
feat: Disable settings save if no data changed
Browse files Browse the repository at this point in the history
  • Loading branch information
RezaRahemtola committed Jun 27, 2024
1 parent 0df48a8 commit 6f35bdd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 9 additions & 3 deletions front/src/components/WalletButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useProviderStore } from "@/stores/provider.ts";
import { parseGnoEvaluateJsonResponse } from "@/utils";
import { Link, useNavigate } from "@tanstack/react-router";
import { z } from "zod";
import { LogOut, Settings } from "lucide-react";

const userSchema = z.object({
address: z.string(),
Expand Down Expand Up @@ -109,10 +110,15 @@ const WalletButton: FC = () => {
<DropdownMenuLabel>My Account</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem>
<Link to="/settings">Settings</Link>
<Link to="/settings" className="flex gap-1">
<Settings />
<span className="my-auto">Settings</span>
</Link>
</DropdownMenuItem>
<DropdownMenuItem onClick={onLogout} className="cursor-pointer gap-1">
<LogOut />
<span className="my-auto">Logout</span>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={onLogout}>Logout</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)}
Expand Down
5 changes: 3 additions & 2 deletions front/src/routes/settings.lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const Settings = () => {
});

const onSubmit = async (values: ProfileFormSchema) => {
// TODO: check that username changed to avoid useless transactions
await AdenaService.sendTransaction(
[
{
Expand Down Expand Up @@ -83,7 +82,9 @@ const Settings = () => {
</Form>
</CardContent>
<CardFooter className="border-t px-6 py-4">
<Button onClick={form.handleSubmit(onSubmit)}>Save</Button>
<Button disabled={!form.formState.isDirty} onClick={form.handleSubmit(onSubmit)}>
Save
</Button>
</CardFooter>
</Card>
</div>
Expand Down

0 comments on commit 6f35bdd

Please sign in to comment.