reformat with prettier with semicolons and tabs

This commit is contained in:
m5r
2021-07-31 23:57:43 +08:00
parent fc4278ca7b
commit 079241ddb0
80 changed files with 1187 additions and 1270 deletions

View File

@ -1,11 +1,11 @@
import { Head, ErrorComponent } from "blitz"
import { Head, ErrorComponent } from "blitz";
// ------------------------------------------------------
// This page is rendered if a route match is not found
// ------------------------------------------------------
export default function Page404() {
const statusCode = 404
const title = "This page could not be found"
const statusCode = 404;
const title = "This page could not be found";
return (
<>
<Head>
@ -15,5 +15,5 @@ export default function Page404() {
</Head>
<ErrorComponent statusCode={statusCode} title={title} />
</>
)
);
}

View File

@ -1,4 +1,4 @@
import { Suspense } from "react"
import { Suspense } from "react";
import {
AppProps,
ErrorBoundary,
@ -7,14 +7,14 @@ import {
AuthorizationError,
ErrorFallbackProps,
useQueryErrorResetBoundary,
} from "blitz"
} from "blitz";
import LoginForm from "../auth/components/login-form"
import LoginForm from "../auth/components/login-form";
import "app/core/styles/index.css"
import "app/core/styles/index.css";
export default function App({ Component, pageProps }: AppProps) {
const getLayout = Component.getLayout || ((page) => page)
const getLayout = Component.getLayout || ((page) => page);
return (
<ErrorBoundary
@ -25,25 +25,25 @@ export default function App({ Component, pageProps }: AppProps) {
{getLayout(<Component {...pageProps} />)}
</Suspense>
</ErrorBoundary>
)
);
}
function RootErrorFallback({ error, resetErrorBoundary }: ErrorFallbackProps) {
if (error instanceof AuthenticationError) {
return <LoginForm onSuccess={resetErrorBoundary} />
return <LoginForm onSuccess={resetErrorBoundary} />;
} else if (error instanceof AuthorizationError) {
return (
<ErrorComponent
statusCode={error.statusCode}
title="Sorry, you are not authorized to access this"
/>
)
);
} else {
return (
<ErrorComponent
statusCode={error.statusCode || 400}
title={error.message || error.name}
/>
)
);
}
}

View File

@ -1,4 +1,4 @@
import { Document, Html, DocumentHead, Main, BlitzScript /*DocumentContext*/ } from "blitz"
import { Document, Html, DocumentHead, Main, BlitzScript /*DocumentContext*/ } from "blitz";
class MyDocument extends Document {
// Only uncomment if you need to customize this behaviour
@ -16,8 +16,8 @@ class MyDocument extends Document {
<BlitzScript />
</body>
</Html>
)
);
}
}
export default MyDocument
export default MyDocument;

View File

@ -1,9 +1,9 @@
import { render } from "../../test/utils"
import Home from "./index"
import useCurrentCustomer from "../core/hooks/use-current-customer"
import { render } from "../../test/utils";
import Home from "./index";
import useCurrentCustomer from "../core/hooks/use-current-customer";
jest.mock("../core/hooks/use-current-customer")
const mockUseCurrentCustomer = useCurrentCustomer as jest.MockedFunction<typeof useCurrentCustomer>
jest.mock("../core/hooks/use-current-customer");
const mockUseCurrentCustomer = useCurrentCustomer as jest.MockedFunction<typeof useCurrentCustomer>;
test.skip("renders blitz documentation link", () => {
// This is an example of how to ensure a specific item is in the document
@ -23,17 +23,17 @@ test.skip("renders blitz documentation link", () => {
user: {} as any,
},
hasCompletedOnboarding: false,
})
});
const { getByText } = render(<Home />)
const linkElement = getByText(/Documentation/i)
expect(linkElement).toBeInTheDocument()
})
const { getByText } = render(<Home />);
const linkElement = getByText(/Documentation/i);
expect(linkElement).toBeInTheDocument();
});
function uuidv4() {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
const r = (Math.random() * 16) | 0,
v = c == "x" ? r : (r & 0x3) | 0x8
return v.toString(16)
})
v = c == "x" ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
}

View File

@ -1,9 +1,9 @@
import { Suspense } from "react"
import { Link, BlitzPage, useMutation, Routes } from "blitz"
import { Suspense } from "react";
import { Link, BlitzPage, useMutation, Routes } from "blitz";
import BaseLayout from "../core/layouts/base-layout"
import logout from "../auth/mutations/logout"
import useCurrentCustomer from "../core/hooks/use-current-customer"
import BaseLayout from "../core/layouts/base-layout";
import logout from "../auth/mutations/logout";
import useCurrentCustomer from "../core/hooks/use-current-customer";
/*
* This file is just for a pleasant getting started page for your new app.
@ -11,8 +11,8 @@ import useCurrentCustomer from "../core/hooks/use-current-customer"
*/
const UserInfo = () => {
const { customer } = useCurrentCustomer()
const [logoutMutation] = useMutation(logout)
const { customer } = useCurrentCustomer();
const [logoutMutation] = useMutation(logout);
if (customer) {
return (
@ -20,7 +20,7 @@ const UserInfo = () => {
<button
className="button small"
onClick={async () => {
await logoutMutation()
await logoutMutation();
}}
>
Logout
@ -31,7 +31,7 @@ const UserInfo = () => {
User role: <code>{customer.encryptionKey}</code>
</div>
</>
)
);
} else {
return (
<>
@ -46,9 +46,9 @@ const UserInfo = () => {
</a>
</Link>
</>
)
);
}
}
};
const Home: BlitzPage = () => {
return (
@ -264,10 +264,10 @@ const Home: BlitzPage = () => {
}
`}</style>
</div>
)
}
);
};
Home.suppressFirstRenderFlicker = true
Home.getLayout = (page) => <BaseLayout title="Home">{page}</BaseLayout>
Home.suppressFirstRenderFlicker = true;
Home.getLayout = (page) => <BaseLayout title="Home">{page}</BaseLayout>;
export default Home
export default Home;