Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/store-accordion-preference
Browse files Browse the repository at this point in the history
  • Loading branch information
patricio0312rev authored Nov 14, 2024
2 parents d2ec495 + 9c2a811 commit 7b32045
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 65 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
},
"dependencies": {
"@ardenthq/arkvault-url": "^1.2.0",
"@ardenthq/sdk": "^2.2.0",
"@ardenthq/sdk-ark": "^2.2.0",
"@ardenthq/sdk-cryptography": "^2.2.0",
"@ardenthq/sdk-helpers": "^2.2.0",
"@ardenthq/sdk-intl": "^2.2.0",
"@ardenthq/sdk-ledger": "^2.2.0",
"@ardenthq/sdk-profiles": "^2.2.0",
"@ardenthq/sdk": "^2.2.1",
"@ardenthq/sdk-ark": "^2.2.1",
"@ardenthq/sdk-cryptography": "^2.2.1",
"@ardenthq/sdk-helpers": "^2.2.1",
"@ardenthq/sdk-intl": "^2.2.1",
"@ardenthq/sdk-ledger": "^2.2.1",
"@ardenthq/sdk-profiles": "^2.2.1",
"@emotion/cache": "^11.11.0",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
Expand Down
104 changes: 52 additions & 52 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions src/domains/profile/pages/CreateProfile/CreateProfile.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,28 @@ describe("CreateProfile", () => {
expect(profile.usesPassword()).toBe(false);
});

it("should navigate to dashboard after creating profile", async () => {
const history = createHashHistory();

render(<CreateProfile />, { history });

await userEvent.type(nameInput(), "test profile 2");

await userEvent.click(screen.getByRole("checkbox"));

await waitFor(() => expect(submitButton()).toBeEnabled());

const historySpy = vi.spyOn(history, "push");

await userEvent.click(submitButton());

const profile = env.profiles().last();

expect(historySpy).toHaveBeenCalledWith(`/profiles/${profile.id()}/dashboard`);

historySpy.mockRestore();
});

it("should not be able to create new profile if name already exists", async () => {
const profile = await env.profiles().create(profileName);

Expand Down
16 changes: 10 additions & 6 deletions src/domains/profile/pages/CreateProfile/CreateProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { useHistory } from "react-router-dom";
import { Header } from "@/app/components/Header";
import { Page, Section } from "@/app/components/Layout";
import { useEnvironmentContext } from "@/app/contexts";
import { useLocaleCurrency, useProfileRestore, useTheme } from "@/app/hooks";
import { useAccentColor, useLocaleCurrency, useProfileRestore, useTheme } from "@/app/hooks";

import { ProfileForm, ProfileFormState } from "@/domains/profile/components/ProfileForm";
import { ThemeIcon } from "@/app/components/Icon";
import { generatePath } from "react-router-dom";
import { ProfilePaths } from "@/router/paths";

export const CreateProfile = () => {
const { env, persist } = useEnvironmentContext();
Expand All @@ -22,12 +24,11 @@ export const CreateProfile = () => {

useLayoutEffect(() => {
resetTheme();

return () => {
resetTheme();
};
}, [resetTheme]);

const { setProfileTheme } = useTheme();
const { setProfileAccentColor } = useAccentColor();

const handleSubmit = async ({ name, password, currency, viewingMode }: ProfileFormState) => {
const profile = await env.profiles().create(name.trim());
await env.profiles().restore(profile);
Expand All @@ -42,7 +43,10 @@ export const CreateProfile = () => {
restoreProfileConfig(profile);
await persist();

history.push("/");
setProfileTheme(profile);
setProfileAccentColor(profile);

history.push(generatePath(ProfilePaths.Dashboard, { profileId: profile.id() }));
};

return (
Expand Down

0 comments on commit 7b32045

Please sign in to comment.