-
Notifications
You must be signed in to change notification settings - Fork 0
sample #66
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
sample #66
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,65 @@ | ||||||
| .title { | ||||||
| text-align: center; | ||||||
| font-size: var(--text-2xl); | ||||||
| margin: var(--space-2xl) 0 var(--space-xl) 0; | ||||||
| } | ||||||
|
|
||||||
| .accountContainer { | ||||||
| display: flex; | ||||||
| gap: var(--space-2xl); | ||||||
| width: fit-content; | ||||||
| margin: 20px auto 20px auto; | ||||||
| border: 1px solid var(--color-base); | ||||||
| border-radius: 10px; | ||||||
| padding: var(--space-sm) var(--space-base); | ||||||
| } | ||||||
|
|
||||||
| @media screen and (min-width: 600px) { | ||||||
| .accountContainer { | ||||||
| display: flex; | ||||||
| gap: var(--space-2xl); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| @media screen and (max-width: 599px) { | ||||||
| .accountContainer { | ||||||
| display: flex; | ||||||
| gap: var(--space-lg); | ||||||
| flex-direction: column; | ||||||
| align-items: center; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| .iconWrapper { | ||||||
| display: flex; | ||||||
| width: 150px; | ||||||
| gap: var(--space-sm); | ||||||
| } | ||||||
|
|
||||||
| .icon { | ||||||
| width: 50px; | ||||||
| height: 50px; | ||||||
| fill: var(--color-base); | ||||||
| } | ||||||
|
|
||||||
| .iconLabel { | ||||||
| display: flex; | ||||||
| align-items: center; | ||||||
| font-size: var(--text-xl); | ||||||
| } | ||||||
|
|
||||||
| .button { | ||||||
| font-size: var(--color-base); | ||||||
|
||||||
| font-size: var(--color-base); | |
| font-size: var(--text-base); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,85 @@ | ||||||||||||||||||||||||
| import { useEffect, useState, type FC } from 'react'; | ||||||||||||||||||||||||
| // better-auth | ||||||||||||||||||||||||
| import { authClient } from '../../../../lib/auth'; | ||||||||||||||||||||||||
| // icons | ||||||||||||||||||||||||
| import { FaDiscord, FaGoogle } from 'react-icons/fa6'; | ||||||||||||||||||||||||
| // css | ||||||||||||||||||||||||
| import styles from './index.module.css'; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| type Provider = 'discord' | 'google'; | ||||||||||||||||||||||||
| type LinkedSocialAccount = { | ||||||||||||||||||||||||
| provider: Provider; | ||||||||||||||||||||||||
| isLinked: boolean; | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const SocialLink: FC = () => { | ||||||||||||||||||||||||
| const [linkedAccounts, setLinkedAccounts] = useState<LinkedSocialAccount[]>([]); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||
| const fetchSession = async () => { | ||||||||||||||||||||||||
| const session = await authClient.listAccounts(); | ||||||||||||||||||||||||
| if (session.data) { | ||||||||||||||||||||||||
| for (const account of session.data) { | ||||||||||||||||||||||||
| setLinkedAccounts((prev) => [ | ||||||||||||||||||||||||
| ...prev, | ||||||||||||||||||||||||
| { provider: account.providerId as 'discord' | 'google', isLinked: true }, | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+22
to
+27
|
||||||||||||||||||||||||
| for (const account of session.data) { | |
| setLinkedAccounts((prev) => [ | |
| ...prev, | |
| { provider: account.providerId as 'discord' | 'google', isLinked: true }, | |
| ]); | |
| } | |
| const accounts: LinkedSocialAccount[] = session.data.map((account) => ({ | |
| provider: account.providerId as Provider, | |
| isLinked: true, | |
| })); | |
| setLinkedAccounts(accounts); |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using console.log in production code is not recommended. The codebase doesn't use console.log elsewhere in the routes directory. If this logging is needed for debugging, it should be removed before merging. If it's intentional, consider using a proper logging library or removing it entirely since an empty data array is a valid state that doesn't require logging.
| } else { | |
| console.log('No linked accounts found.'); |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The async function fetchSession inside useEffect lacks error handling. If authClient.listAccounts() fails, the error will be unhandled and could cause the component to fail silently. Consider adding a try-catch block and providing appropriate error feedback to the user, consistent with error handling patterns used elsewhere in the codebase.
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The async functions handleDiscordLinkSocial and handleGoogleLinkSocial lack error handling. If authClient.linkSocial fails, the error will be unhandled. Consider adding try-catch blocks and providing user feedback via toast notifications, consistent with error handling patterns used elsewhere in the codebase (see products/frontend/src/routes/Profile/index.tsx lines 22, 33).
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The disabled prop is explicitly set to true and false, which is redundant. In React/JSX, you can simply use disabled without a value for true, and omit the prop entirely for false. This would make the code cleaner and more idiomatic.
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The disabled prop is explicitly set to true and false, which is redundant. In React/JSX, you can simply use disabled without a value for true, and omit the prop entirely for false. This would make the code cleaner and more idiomatic.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { default as SocialLink } from './SocialLink'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The media query for min-width: 600px repeats the same display: flex and gap properties that are already defined in the base .accountContainer rule (lines 8-9). This is redundant and can be removed. Only properties that differ from the base should be included in media queries.