-
Notifications
You must be signed in to change notification settings - Fork 184
WIP: Logout page #616
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
base: main
Are you sure you want to change the base?
WIP: Logout page #616
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
disabled={ | ||
!title || | ||
!type || | ||
(!!title && !!type && loading) || |
Check warning
Code scanning / CodeQL
Useless conditional Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 days ago
The fix involves removing the redundant !!title && !!type && loading
conditional in the disabled
prop for the Button and replacing it with just loading
. Specifically, change line 130 in apps/web/app/(with-contexts)/dashboard/(sidebar)/products/new/page.tsx from:
!!title && !!type && loading
to:
loading
This alteration ensures that the disabled state will only depend on loading
when both title
and type
are truthy, since the earlier conditions (!title
, !type
) already prevent the button from being enabled otherwise. No other code changes, imports, or method stubs are needed.
-
Copy modified line R130
@@ -127,7 +127,7 @@ | ||
disabled={ | ||
!title || | ||
!type || | ||
(!!title && !!type && loading) || | ||
loading || | ||
actionSuccessful | ||
} | ||
onClick={createCourse} |
disabled={ | ||
!title || | ||
!type || | ||
(!!title && !!type && loading) || |
Check warning
Code scanning / CodeQL
Useless conditional Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 days ago
To fix this problem, we should simplify the conditional for the disabled
prop of <Button>
. Since !!title && !!type
is always true in that part of expression (given the initial checks), we can remove them from the conjunction and simply check for loading
. The corrected condition should be:
!title || !type || loading || actionSuccessful
.
This maintains the same logical intended behavior: the button is disabled if the title or type is missing, if an action is in progress (loading), or if the action has already succeeded. The change is to file apps/web/app/(with-contexts)/dashboard/(sidebar)/products/new/page.tsx
on the block that spans the disabled
prop.
No import or new definition is needed.
-
Copy modified line R130
@@ -127,7 +127,7 @@ | ||
disabled={ | ||
!title || | ||
!type || | ||
(!!title && !!type && loading) || | ||
loading || | ||
actionSuccessful | ||
} | ||
onClick={createCourse} |
const [loading, setLoading] = useState(false); | ||
const address = useContext(AddressContext); | ||
const { profile } = useContext(ProfileContext); | ||
const course = useCourse(id, address); |
Check warning
Code scanning / CodeQL
Superfluous trailing arguments Warning
function useCourse
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 11 hours ago
To fix the problem, we need to remove the superfluous address
argument from the call to useCourse
on line 38 in apps/web/components/admin/blogs/editor/details.tsx
. This function call should only provide the expected arguments and nothing more; in this case, it appears that only id
is needed for useCourse
. No additional imports or definitions are necessary, and functionality will remain unchanged.
-
Copy modified line R38
@@ -35,7 +35,7 @@ | ||
const [loading, setLoading] = useState(false); | ||
const address = useContext(AddressContext); | ||
const { profile } = useContext(ProfileContext); | ||
const course = useCourse(id, address); | ||
const course = useCourse(id); | ||
const { toast } = useToast(); | ||
|
||
useEffect(() => { |
let course = useCourse(id, address, dispatch); | ||
export default function Publish({ id }: PublishProps) { | ||
const address = useContext(AddressContext); | ||
let course = useCourse(id, address); |
Check warning
Code scanning / CodeQL
Superfluous trailing arguments Warning
function useCourse
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 11 hours ago
The fix is to remove the second parameter address
passed to useCourse
at line 23 in apps/web/components/admin/blogs/editor/publish.tsx
. The best way to resolve the issue while preserving current functionality is simply to call useCourse(id)
instead, unless there is clear evidence the second argument is needed (which CodeQL indicates is not the case). No additional imports or definitions are required. Only line 23 needs to be modified within the file.
-
Copy modified line R23
@@ -20,7 +20,7 @@ | ||
|
||
export default function Publish({ id }: PublishProps) { | ||
const address = useContext(AddressContext); | ||
let course = useCourse(id, address); | ||
let course = useCourse(id); | ||
const [published, setPublished] = useState(course?.published); | ||
const [privacy, setPrivacy] = useState(course?.privacy); | ||
const [loading, setLoading] = useState(false); |
!name || !pageId || (!!name && !!pageId && loading) | ||
!name || | ||
!pageId || | ||
(!!name && !!pageId && loading) || |
Check warning
Code scanning / CodeQL
Useless conditional Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 11 hours ago
To fix the problem, we should remove the redundant !!name && !!pageId
part from line 103 within the disabled
prop of the <Button>
component. The logical expression currently reads:
disabled={
!name ||
!pageId ||
(!!name && !!pageId && loading) ||
loading
}
The segment !!name && !!pageId && loading
is always true under the condition where both !name
and !pageId
are false, meaning name
and pageId
are truthy. Thus, it can be replaced with simply loading
in the list of disjuncts. However, since loading
is already explicitly checked on line 104, line 103 is entirely redundant. The final condition should be:
disabled={!name || !pageId || loading}
This maintains all intended behavior, disables the button when mandatory fields are missing or when a submit is in progress, and is more concise.
Edit only the code inside apps/web/components/admin/pages/new-page.tsx
, specifically the disabled
attribute of the <Button>
component.
@@ -100,7 +100,6 @@ | ||
disabled={ | ||
!name || | ||
!pageId || | ||
(!!name && !!pageId && loading) || | ||
loading | ||
} | ||
onClick={createPage} |
!name || !pageId || (!!name && !!pageId && loading) | ||
!name || | ||
!pageId || | ||
(!!name && !!pageId && loading) || |
Check warning
Code scanning / CodeQL
Useless conditional Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 11 hours ago
The fix is to remove the redundant check !!name && !!pageId && loading
within the disabled prop for the <Button>
. Since the first two conditions (!name || !pageId
) already handle the case where name
or pageId
are empty, the extra check for !!name && !!pageId && loading
is unnecessary and can be replaced simply by loading
. The resulting conditional will be:
disabled={!name || !pageId || loading}
This should be done on the disabled prop of the Button on lines 100–105 of apps/web/components/admin/pages/new-page.tsx
. No further changes or imports are needed.
@@ -100,7 +100,6 @@ | ||
disabled={ | ||
!name || | ||
!pageId || | ||
(!!name && !!pageId && loading) || | ||
loading | ||
} | ||
onClick={createPage} |
No description provided.