Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move stuff around #391

Merged
merged 1 commit into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 10 additions & 32 deletions cli/template/page-studs/index/with-auth-trpc-tw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,6 @@ import Head from "next/head";
import { signIn, signOut, useSession } from "next-auth/react";
import { trpc } from "../utils/trpc";

type TechnologyCardProps = {
name: string;
description: string;
documentation: string;
};

const AuthShowcase: React.FC = () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was duplicated

const { data: secretMessage, isLoading } = trpc.useQuery([
"auth.getSecretMessage",
]);

const { data: sessionData } = useSession();

return (
<div>
{sessionData && <p>Logged in as {sessionData?.user?.name}</p>}
{secretMessage && <p>{secretMessage}</p>}
<button
className="px-4 py-2 border-2 border-blue-500 rounded-md"
onClick={sessionData ? () => signOut() : () => signIn()}
>
{sessionData ? "Sign out" : "Sign in"}
</button>
</div>
);
};

const Home: NextPage = () => {
const hello = trpc.useQuery(["example.hello", { text: "from tRPC" }]);

Expand Down Expand Up @@ -81,15 +54,16 @@ const Home: NextPage = () => {
<div className="pt-6 text-2xl text-blue-500 flex justify-center items-center w-full">
{hello.data ? <p>{hello.data.greeting}</p> : <p>Loading..</p>}
</div>
<AuthShowcase />
</main>
</>
);
};

export default Home;

const AuthShowcase: React.FC = () => {
const { data: secretMessage, isLoading } = trpc.useQuery([
"auth.getSecretMessage",
]);
const { data: secretMessage } = trpc.useQuery(["auth.getSecretMessage"]);

const { data: sessionData } = useSession();

Expand All @@ -113,6 +87,12 @@ const AuthShowcase: React.FC = () => {
);
};

type TechnologyCardProps = {
name: string;
description: string;
documentation: string;
};

const TechnologyCard = ({
name,
description,
Expand All @@ -133,5 +113,3 @@ const TechnologyCard = ({
</section>
);
};

export default Home;
4 changes: 1 addition & 3 deletions cli/template/page-studs/index/with-auth-trpc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ const Home: NextPage = () => {
export default Home;

const AuthShowcase: React.FC = () => {
const { data: secretMessage, isLoading } = trpc.useQuery([
"auth.getSecretMessage",
]);
const { data: secretMessage } = trpc.useQuery(["auth.getSecretMessage"]);

const { data: sessionData } = useSession();

Expand Down
16 changes: 8 additions & 8 deletions cli/template/page-studs/index/with-trpc-tw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import type { NextPage } from "next";
import Head from "next/head";
import { trpc } from "../utils/trpc";

type TechnologyCardProps = {
name: string;
description: string;
documentation: string;
};

const Home: NextPage = () => {
const hello = trpc.useQuery(["example.hello", { text: "from tRPC" }]);

Expand Down Expand Up @@ -64,6 +58,14 @@ const Home: NextPage = () => {
);
};

export default Home;

type TechnologyCardProps = {
name: string;
description: string;
documentation: string;
};

const TechnologyCard = ({
name,
description,
Expand All @@ -84,5 +86,3 @@ const TechnologyCard = ({
</section>
);
};

export default Home;
16 changes: 8 additions & 8 deletions cli/template/page-studs/index/with-tw.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import type { NextPage } from "next";
import Head from "next/head";

type TechnologyCardProps = {
name: string;
description: string;
documentation: string;
};

const Home: NextPage = () => {
return (
<>
Expand Down Expand Up @@ -58,6 +52,14 @@ const Home: NextPage = () => {
);
};

export default Home;

type TechnologyCardProps = {
name: string;
description: string;
documentation: string;
};

const TechnologyCard = ({
name,
description,
Expand All @@ -78,5 +80,3 @@ const TechnologyCard = ({
</section>
);
};

export default Home;