Skip to content

Commit

Permalink
ログアウトボタンの位置を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
MurakawaTakuya committed Jan 11, 2025
1 parent c15cb88 commit c0eb1f5
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 33 deletions.
2 changes: 1 addition & 1 deletion functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const verifyAppCheckToken = async (
console.log("Verified App Check Token:", decodedToken);
next();
} catch (error) {
console.error("Invalid App Check token:", error);
logger.error(`Invalid App Check token with ${appCheckToken}:`, error);
res.status(401).send("Invalid App Check token.");
}
};
Expand Down
32 changes: 12 additions & 20 deletions src/Components/Account/LoggedInView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function LoggedInView() {
successRate: 0,
completed: 0,
});

const { user } = useUser();

useEffect(() => {
Expand Down Expand Up @@ -67,16 +68,20 @@ export default function LoggedInView() {
ゲストユーザーは閲覧以外の機能は使用できません。
全ての機能を利用するにはログインが必要です。
</Typography>
<RoundedButton
variant="contained"
onClick={handleSignOut}
sx={{ width: "150px", margin: "0 auto" }}
>
ログアウト
</RoundedButton>
</>
)}

<div className={styles.buttonContainer} style={{ margin: "10px 0" }}>
<div>
<NameUpdate />
</div>
<div>
<RoundedButton variant="contained" onClick={handleSignOut}>
ログアウト
</RoundedButton>
</div>
</div>

{user.loginType !== "Guest" && user.isMailVerified && (
<>
<div
Expand All @@ -87,19 +92,6 @@ export default function LoggedInView() {
gap: "5px",
}}
>
<div
className={styles.buttonContainer}
style={{ margin: "10px 0" }}
>
<div>
<NameUpdate />
</div>
<div>
<RoundedButton variant="contained" onClick={handleSignOut}>
ログアウト
</RoundedButton>
</div>
</div>
<Typography level="title-md" sx={{ textAlign: "center" }}>
連続達成日数: {userStats.streak}日目
</Typography>
Expand Down
6 changes: 5 additions & 1 deletion src/Components/NameUpdate/NameUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ export default function NameUpdate() {

return (
<>
<RoundedButton variant="outlined" onClick={() => setOpen(true)}>
<RoundedButton
variant="outlined"
onClick={() => setOpen(true)}
disabled={user?.loginType === "Guest" || !user?.isMailVerified}
>
名前を変更
</RoundedButton>

Expand Down
9 changes: 6 additions & 3 deletions src/Components/PWAButton/PWAButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ declare global {

export const PWAButton = ({
defaultDisabled = true,
PWAReady,
setPWAReady,
}: {
defaultDisabled?: boolean;
PWAReady: boolean;
setPWAReady: (value: boolean) => void;
}) => {
const deferredPromptRef = useRef<BeforeInstallPromptEvent | null>(null);
const [ready, setReady] = useState(false);
const [isAleadyInstalled, setIsAlreadyInstalled] = useState(false);

useEffect(() => {
Expand All @@ -37,7 +40,7 @@ export const PWAButton = ({
checkIfInstalled();

const beforeInstallPromptHandler = (event: BeforeInstallPromptEvent) => {
setReady(true);
setPWAReady(true);
deferredPromptRef.current = event;
};

Expand Down Expand Up @@ -78,7 +81,7 @@ export const PWAButton = ({
) : (
<RoundedButton
variant="outlined"
disabled={!ready || defaultDisabled}
disabled={!PWAReady || defaultDisabled}
onClick={handleClickInstall}
>
アプリに追加
Expand Down
33 changes: 25 additions & 8 deletions src/app/account/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default function Account() {
const { user } = useUser();
const [isIOS, setIsIOS] = useState(false);
const [isPWA, setIsPWA] = useState(false);
const [PWAReady, setPWAReady] = useState(false);

// iOSか判定
useEffect(() => {
Expand Down Expand Up @@ -83,7 +84,7 @@ export default function Account() {
</Box>
</Card>

{user?.loginType !== "Guest" && user?.isMailVerified && (
{user && (
<Card variant="outlined" sx={{ padding: "25px 20px 30px" }}>
<Typography
level="h3"
Expand All @@ -95,21 +96,37 @@ export default function Account() {
</Typography>
<div className={styles.buttonContainer}>
<div>
<PWAButton defaultDisabled={isIOS || isPWA} />
<PWAButton
defaultDisabled={isIOS || isPWA}
PWAReady={PWAReady}
setPWAReady={setPWAReady}
/>
</div>
<div>
<NotificationButton defaultDisabled={isIOS && !isPWA} />
<NotificationButton
defaultDisabled={
(isIOS && !isPWA) ||
user?.loginType === "Guest" ||
!user?.isMailVerified
}
/>
</div>
</div>
{!PWAReady && (
<Typography color="danger" textAlign="center">
PWAを起動中です。しばらくしてから再度お試しください。
</Typography>
)}
{(user?.loginType === "Guest" || !user?.isMailVerified) && (
<Typography color="danger" textAlign="center">
通知を利用するには認証が必要です。
</Typography>
)}
<Typography>
アプリに追加をすると、端末のホーム画面やアプリ一覧から起動できるようになります。
<br />
<br />
通知を有効にすると、端末の目標が未達成の場合に期限の5分前に通知を送信します。
<br />
</Typography>
<Typography color="neutral" level="body-xs">
1ユーザー1端末のみ。最後に登録した端末に送信します
1ユーザー1端末のみ通知受信登録をできます。複数登録した場合あ最後に登録した端末に送信します
<br />
通知が受信できない場合はブラウザやサイトの権限を確認してください。
</Typography>
Expand Down

0 comments on commit c0eb1f5

Please sign in to comment.