Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Convert AccountLayout to TypeScript (#69067)

Fraser43daa3b222b2
diff --git a/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.jsx b/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.jsx
deleted file mode 100644
index 93d69034eb5..00000000000
--- a/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.jsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import PropTypes from "prop-types";
-
-import { AccountHeader } from "../AccountHeader";
-
-import { AccountContent } from "./AccountLayout.styled";
-
-const propTypes = {
- ...AccountHeader.propTypes,
- children: PropTypes.node,
-};
-
-const AccountLayout = ({ children, ...props }) => {
- return (
- <div>
- <AccountHeader {...props} />
- <AccountContent>{children}</AccountContent>
- </div>
- );
-};
-
-AccountLayout.propTypes = propTypes;
-
-// eslint-disable-next-line import/no-default-export -- deprecated usage
-export default AccountLayout;
diff --git a/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.tsx b/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.tsx
new file mode 100644
index 00000000000..c0ba0993bb7
--- /dev/null
+++ b/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.tsx
@@ -0,0 +1,40 @@
+import type { Path } from "history";
+import type { ReactNode } from "react";
+
+import type { User } from "metabase-types/api";
+
+import { AccountHeader } from "../AccountHeader";
+
+import { AccountContent } from "./AccountLayout.styled";
+
+interface AccountLayoutProps {
+ user: User | null;
+ path?: string;
+ onChangeLocation: (nextLocation: Path) => void;
+ children?: ReactNode;
+}
+
+const AccountLayout = ({
+ children,
+ user,
+ path,
+ onChangeLocation,
+}: AccountLayoutProps) => {
+ if (!user) {
+ return null;
+ }
+
+ return (
+ <div>
+ <AccountHeader
+ user={user}
+ path={path}
+ onChangeLocation={onChangeLocation}
+ />
+ <AccountContent>{children}</AccountContent>
+ </div>
+ );
+};
+
+// eslint-disable-next-line import/no-default-export -- deprecated usage
+export default AccountLayout;
diff --git a/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.unit.spec.js b/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.unit.spec.js
index 1addd9c6c55..e675adf62e0 100644
--- a/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.unit.spec.js
+++ b/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.unit.spec.js
@@ -13,7 +13,11 @@ describe("AccountLayout", () => {
it("should render header and content", () => {
const user = getUser();
- render(<AccountLayout user={user}>Content</AccountLayout>);
+ render(
+ <AccountLayout user={user} onChangeLocation={() => {}}>
+ Content
+ </AccountLayout>,
+ );
expect(screen.getByText("Profile")).toBeInTheDocument();
expect(screen.getByText("Content")).toBeInTheDocument();