Skip to content

Commit

Permalink
feat: Add Buddy component to display user's buddy
Browse files Browse the repository at this point in the history
  • Loading branch information
k-taro56 committed Jul 6, 2024
1 parent abfb405 commit 5dc0b65
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
9 changes: 8 additions & 1 deletion src/components/account-setting.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { useState } from "react";

const AccountSetting = ({ accessToken }: { accessToken: string }) => {
const AccountSetting = ({
accessToken,
setAccessToken,
}: {
accessToken: string;
setAccessToken: (token: string) => void;
}) => {
const [githubUser, setGithubUser] = useState<{ login: string; avatar_url: string } | null>(null);

const fetchGithubUser = async (token: string) => {
Expand All @@ -20,6 +26,7 @@ const AccountSetting = ({ accessToken }: { accessToken: string }) => {

const handleRemoveToken = () => {
chrome.storage.local.remove(["accessToken"]);
setAccessToken("");
};

return (
Expand Down
12 changes: 12 additions & 0 deletions src/components/buddy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const Buddy = () => {
return (
<div className="pb-4 border-b border-gray-300 w-60 h-72">
<h1 className="text-xl font-bold whitespace-nowrap mb-2 border-b border-gray-300">
Your buddy
</h1>
<img src="./images/buddy/gif0047.gif" alt="buddy" className="w-60 h-60" />
</div>
);
};

export default Buddy;
15 changes: 5 additions & 10 deletions src/pages/index.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import type { CustomNextPage } from "next";
import { Layout } from "src/layout";
import Navigation from "src/components/navigation";
import LoginWithGithub from "src/components/login-with-github";
import Buddy from "src/components/buddy";
import DurationSetting from "src/components/duration-setting";
import AccountSetting from "src/components/account-setting";

const requestDeviceCode = async () => {
Expand Down Expand Up @@ -164,18 +166,11 @@ const IndexPage: CustomNextPage = () => {
const renderContent = () => {
switch (currentView) {
case "buddy":
return (
<div className="pb-4 border-b border-gray-300 w-60 h-72">
<h1 className="text-xl font-bold whitespace-nowrap mb-2 border-b border-gray-300">
Your buddy
</h1>
<img src="./images/buddy/gif0047.gif" alt="buddy" className="w-60 h-60" />
</div>
);
return <Buddy />;
case "duration-setting":
return <div>Duration Setting Component</div>;
return <DurationSetting />;
case "account-setting":
return <AccountSetting accessToken={accessToken} />;
return <AccountSetting accessToken={accessToken} setAccessToken={setAccessToken} />;
default:
return null;
}
Expand Down

0 comments on commit 5dc0b65

Please sign in to comment.