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

fix: minor sonar issues #390

Merged
merged 1 commit into from
Nov 26, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ interface Props {
value: string;
}

interface languageMap {
interface LanguageMap {
[key: string]: string | undefined;
}

const programmingLanguages: languageMap = {
const programmingLanguages: LanguageMap = {
javascript: ".js",
python: ".py",
java: ".java",
Expand Down Expand Up @@ -65,7 +65,7 @@ const CodeBlock: FC<Props> = memo(({ language, value }) => {
if (typeof window === "undefined") {
return;
}
const fileExtension = programmingLanguages[language] || ".file";
const fileExtension = programmingLanguages[language] ?? ".file";
const suggestedFileName = `file-${generateRandomString(
3,
true,
Expand Down
22 changes: 10 additions & 12 deletions apps/nextjs/src/components/AppComponents/Chat/user-or-login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ export function UserOrLogin() {
return <></>;
}
return (
<>
<div className="flex items-center sm:ml-8">
<SignedIn>
<UserButton />
</SignedIn>
<SignedOut>
<Button variant="link" asChild className="-ml-7">
<Link href="/sign-in?callbackUrl=/">Log in</Link>
</Button>
</SignedOut>
</div>
</>
<div className="flex items-center sm:ml-8">
<SignedIn>
<UserButton />
</SignedIn>
<SignedOut>
<Button variant="link" asChild className="-ml-7">
<Link href="/sign-in?callbackUrl=/">Log in</Link>
</Button>
</SignedOut>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,35 @@ export const ModerationFeedbackForm = ({
/>
</div>
<Dialog.Close />
<>
<div className="flex flex-col gap-8">
<Dialog.Title>
<span className="font-bold">Guidance required</span>
</Dialog.Title>
<Dialog.Description>
<span>
Contains{" "}
{moderation.categories
.map(moderationSlugToDescription)
.join(", ")}
. Check content carefully. If you have feedback on this guidance,
please provide details below.
</span>
</Dialog.Description>
</div>
<form onSubmit={onSubmit}>
<Textarea
className="min-h-30 w-full resize-none rounded border border-gray-600 bg-transparent px-10 py-[0.6rem] text-base placeholder-gray-700 focus-within:outline-none"
onChange={(e) => setComment(e.target.value)}
value={comment}
placeholder="Your feedback"
/>
</form>
<div className="flex w-full justify-between gap-7">
<ChatButton variant="text-link" onClick={closeModal}>
Back to lesson
</ChatButton>
<ChatButton variant="primary" onClick={onSubmit} disabled={!isValid}>
Submit feedback
</ChatButton>
</div>
</>
<div className="flex flex-col gap-8">
<Dialog.Title>
<span className="font-bold">Guidance required</span>
</Dialog.Title>
<Dialog.Description>
<span>
Contains{" "}
{moderation.categories.map(moderationSlugToDescription).join(", ")}.
Check content carefully. If you have feedback on this guidance,
please provide details below.
</span>
</Dialog.Description>
</div>
<form onSubmit={onSubmit}>
<Textarea
className="min-h-30 w-full resize-none rounded border border-gray-600 bg-transparent px-10 py-[0.6rem] text-base placeholder-gray-700 focus-within:outline-none"
onChange={(e) => setComment(e.target.value)}
value={comment}
placeholder="Your feedback"
/>
</form>
<div className="flex w-full justify-between gap-7">
<ChatButton variant="text-link" onClick={closeModal}>
Back to lesson
</ChatButton>
<ChatButton variant="primary" onClick={onSubmit} disabled={!isValid}>
Submit feedback
</ChatButton>
</div>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ function GenerationInputAndText({
* instead of on every key-press. It also allows for undoing on closing "edit
* mode" by setting inputValue back to answer.value
*/
const [inputValue, setInputValue] = useState(item.value || "");
const [inputValue, setInputValue] = useState(item.value ?? "");

useEffect(() => {
setInputValue(item.value || "");
setInputValue(item.value ?? "");
}, [item.value]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ export const AnalyticsProvider: React.FC<AnalyticsProviderProps> = ({
avoOptions,
bootstrappedFeatures,
}) => {
const [hubspotScriptLoaded, setHubspotScriptLoadedFn] = useState(false);
const setHubspotScriptLoaded = useCallback(() => {
setHubspotScriptLoadedFn(true);
const [hubspotScriptLoaded, setHubspotScriptLoaded] = useState(false);
const setHubspotScriptLoadedOnce = useCallback(() => {
setHubspotScriptLoaded(true);
}, []);

/**
Expand Down Expand Up @@ -285,7 +285,10 @@ export const AnalyticsProvider: React.FC<AnalyticsProviderProps> = ({
return (
<analyticsContext.Provider value={analytics}>
{children}
<HubspotLoader consent={hubspotConsent} onLoad={setHubspotScriptLoaded} />
<HubspotLoader
consent={hubspotConsent}
onLoad={setHubspotScriptLoadedOnce}
/>
</analyticsContext.Provider>
);
};
Loading