Lint new changes again

This commit is contained in:
sabaimran 2024-08-05 15:54:50 +05:30
parent 7cb14ff07a
commit 34d54c75f7
3 changed files with 203 additions and 190 deletions

View file

@ -5,7 +5,6 @@ import styles from "./suggestions.module.css";
import { converColorToBgGradient } from "@/app/common/colorUtils";
import { convertSuggestionTitleToIconClass } from "./suggestionsData";
interface SuggestionCardProps {
title: string;
body: string;
@ -23,10 +22,7 @@ export default function SuggestionCard(data: SuggestionCardProps) {
<Card className={cardClassName}>
<CardHeader className="m-0 p-2 pb-1 relative">
<div className="flex flex-row md:flex-col">
{convertSuggestionTitleToIconClass(
data.title,
data.color.toLowerCase(),
)}
{convertSuggestionTitleToIconClass(data.title, data.color.toLowerCase())}
<CardTitle className={titleClassName}>{data.title}</CardTitle>
</div>
</CardHeader>

View file

@ -41,29 +41,32 @@ addSuggestionColorMap(SuggestionType.Interviewing, "purple");
addSuggestionColorMap(SuggestionType.Home, "green");
addSuggestionColorMap(SuggestionType.Fun, "fuchsia");
addSuggestionColorMap(SuggestionType.Code, "purple");
addSuggestionColorMap(SuggestionType.Finance, "green")
addSuggestionColorMap(SuggestionType.Finance, "green");
const DEFAULT_COLOR = "orange";
export function convertSuggestionTitleToIconClass(title: string, color: string) {
if (title === SuggestionType.Automation) return getIconFromIconName("Robot", color, "w-8", "h-8");
if (title === SuggestionType.Automation)
return getIconFromIconName("Robot", color, "w-8", "h-8");
if (title === SuggestionType.Paint) return getIconFromIconName("Palette", color, "w-8", "h-8");
if (title === SuggestionType.PopCulture) return getIconFromIconName("Confetti", color, "w-8", "h-8");
if (title === SuggestionType.PopCulture)
return getIconFromIconName("Confetti", color, "w-8", "h-8");
if (title === SuggestionType.Travel) return getIconFromIconName("Jeep", color, "w-8", "h-8");
if (title === SuggestionType.Learning) return getIconFromIconName("Book", color, "w-8", "h-8");
if (title === SuggestionType.Health) return getIconFromIconName("Asclepius", color, "w-8", "h-8");
if (title === SuggestionType.Health)
return getIconFromIconName("Asclepius", color, "w-8", "h-8");
if (title === SuggestionType.Fun) return getIconFromIconName("Island", color, "w-8", "h-8");
if (title === SuggestionType.Home) return getIconFromIconName("House", color, "w-8", "h-8");
if (title === SuggestionType.Language) return getIconFromIconName("Translate", color, "w-8", "h-8");
if (title === SuggestionType.Language)
return getIconFromIconName("Translate", color, "w-8", "h-8");
if (title === SuggestionType.Code) return getIconFromIconName("Code", color, "w-8", "h-8");
if (title === SuggestionType.Food) return getIconFromIconName("BowlFood", color, "w-8", "h-8");
if (title === SuggestionType.Interviewing) return getIconFromIconName("Lectern", color, "w-8", "h-8");
if (title === SuggestionType.Interviewing)
return getIconFromIconName("Lectern", color, "w-8", "h-8");
if (title === SuggestionType.Finance) return getIconFromIconName("Wallet", color, "w-8", "h-8");
else return getIconFromIconName("Lightbulb", color, "w-8", "h-8");
}
export const suggestionsData: Suggestion[] = [
{
type: SuggestionType.Automation,
@ -516,19 +519,22 @@ export const suggestionsData: Suggestion[] = [
{
type: SuggestionType.Learning,
color: suggestionToColorMap[SuggestionType.Learning] || DEFAULT_COLOR,
description: "Guide a high school student through solving a quadratic equation step-by-step.",
description:
"Guide a high school student through solving a quadratic equation step-by-step.",
link: "",
},
{
type: SuggestionType.Learning,
color: suggestionToColorMap[SuggestionType.Learning] || DEFAULT_COLOR,
description: "Create a series of questions to help a student discover the principles of basic economics.",
description:
"Create a series of questions to help a student discover the principles of basic economics.",
link: "",
},
{
type: SuggestionType.Learning,
color: suggestionToColorMap[SuggestionType.Learning] || DEFAULT_COLOR,
description: "Develop a hands-on experiment to demonstrate the concept of density to middle schoolers.",
description:
"Develop a hands-on experiment to demonstrate the concept of density to middle schoolers.",
link: "",
},
{
@ -540,19 +546,22 @@ export const suggestionsData: Suggestion[] = [
{
type: SuggestionType.Learning,
color: suggestionToColorMap[SuggestionType.Learning] || DEFAULT_COLOR,
description: "Create a personalized learning plan for a student struggling with grammar concepts.",
description:
"Create a personalized learning plan for a student struggling with grammar concepts.",
link: "",
},
{
type: SuggestionType.Learning,
color: suggestionToColorMap[SuggestionType.Learning] || DEFAULT_COLOR,
description: "Design a series of questions to encourage critical thinking about climate change.",
description:
"Design a series of questions to encourage critical thinking about climate change.",
link: "",
},
{
type: SuggestionType.Learning,
color: suggestionToColorMap[SuggestionType.Learning] || DEFAULT_COLOR,
description: "Develop a step-by-step guide for conducting a basic science experiment on plant growth.",
description:
"Develop a step-by-step guide for conducting a basic science experiment on plant growth.",
link: "",
},
{
@ -576,7 +585,8 @@ export const suggestionsData: Suggestion[] = [
{
type: SuggestionType.Health,
color: suggestionToColorMap[SuggestionType.Health] || DEFAULT_COLOR,
description: "Explain the differences between various types of headaches and their treatments.",
description:
"Explain the differences between various types of headaches and their treatments.",
link: "",
},
{
@ -606,7 +616,8 @@ export const suggestionsData: Suggestion[] = [
{
type: SuggestionType.Health,
color: suggestionToColorMap[SuggestionType.Health] || DEFAULT_COLOR,
description: "Provide an overview of the different types of cancer screenings and their importance.",
description:
"Provide an overview of the different types of cancer screenings and their importance.",
link: "",
},
{
@ -624,13 +635,15 @@ export const suggestionsData: Suggestion[] = [
{
type: SuggestionType.Finance,
color: suggestionToColorMap[SuggestionType.Finance] || DEFAULT_COLOR,
description: "Explain the concept of compound interest and its importance in long-term savings.",
description:
"Explain the concept of compound interest and its importance in long-term savings.",
link: "",
},
{
type: SuggestionType.Finance,
color: suggestionToColorMap[SuggestionType.Finance] || DEFAULT_COLOR,
description: "Provide an overview of different types of retirement accounts (e.g., 401(k), IRA, Roth IRA).",
description:
"Provide an overview of different types of retirement accounts (e.g., 401(k), IRA, Roth IRA).",
link: "",
},
{
@ -654,7 +667,8 @@ export const suggestionsData: Suggestion[] = [
{
type: SuggestionType.Finance,
color: suggestionToColorMap[SuggestionType.Finance] || DEFAULT_COLOR,
description: "Describe different methods for paying off debt, such as the snowball and avalanche methods.",
description:
"Describe different methods for paying off debt, such as the snowball and avalanche methods.",
link: "",
},
{
@ -666,7 +680,8 @@ export const suggestionsData: Suggestion[] = [
{
type: SuggestionType.Finance,
color: suggestionToColorMap[SuggestionType.Finance] || DEFAULT_COLOR,
description: "Provide an overview of different types of insurance and their importance in financial planning.",
description:
"Provide an overview of different types of insurance and their importance in financial planning.",
link: "",
},
{

View file

@ -378,8 +378,8 @@ export default function SettingsView() {
initialUserConfig?.is_phone_number_verified
? PhoneNumberValidationState.Verified
: initialUserConfig?.phone_number
? PhoneNumberValidationState.SendOTP
: PhoneNumberValidationState.Setup,
? PhoneNumberValidationState.SendOTP
: PhoneNumberValidationState.Setup,
);
setName(initialUserConfig?.given_name);
setNotionToken(initialUserConfig?.notion_token ?? null);
@ -748,18 +748,18 @@ export default function SettingsView() {
)) ||
(userConfig.subscription_state ===
"unsubscribed" && (
<>
<p className="text-xl">Futurist</p>
<p className="text-gray-400">
Subscription <b>ends</b> on{" "}
<b>
{
userConfig.subscription_renewal_date
}
</b>
</p>
</>
)) ||
<>
<p className="text-xl">Futurist</p>
<p className="text-gray-400">
Subscription <b>ends</b> on{" "}
<b>
{
userConfig.subscription_renewal_date
}
</b>
</p>
</>
)) ||
(userConfig.subscription_state === "expired" && (
<>
<p className="text-xl">Free Plan</p>
@ -773,17 +773,17 @@ export default function SettingsView() {
</b>
</p>
)) || (
<p className="text-gray-400">
Check{" "}
<a
href="https://khoj.dev/pricing"
target="_blank"
>
pricing page
</a>{" "}
to compare plans.
</p>
)}
<p className="text-gray-400">
Check{" "}
<a
href="https://khoj.dev/pricing"
target="_blank"
>
pricing page
</a>{" "}
to compare plans.
</p>
)}
</>
))}
</CardContent>
@ -800,20 +800,20 @@ export default function SettingsView() {
)) ||
(userConfig.subscription_state ==
"unsubscribed" && (
<Button
variant="outline"
className="text-primary/80 hover:text-primary"
onClick={() =>
setSubscription("resubscribe")
}
>
<ArrowCircleUp
weight="bold"
className="h-5 w-5 mr-2"
/>
Resubscribe
</Button>
)) || (
<Button
variant="outline"
className="text-primary/80 hover:text-primary"
onClick={() =>
setSubscription("resubscribe")
}
>
<ArrowCircleUp
weight="bold"
className="h-5 w-5 mr-2"
/>
Resubscribe
</Button>
)) || (
<Button
variant="outline"
className="text-primary/80 hover:text-primary"
@ -848,11 +848,12 @@ export default function SettingsView() {
<CardHeader className="flex flex-row text-2xl">
<Laptop className="h-8 w-8 mr-2" />
Files
{
userConfig.enabled_content_source.computer && (
<CheckCircle className="h-6 w-6 ml-auto text-green-500" weight="fill" />
)
}
{userConfig.enabled_content_source.computer && (
<CheckCircle
className="h-6 w-6 ml-auto text-green-500"
weight="fill"
/>
)}
</CardHeader>
<CardContent className="overflow-hidden pb-12 text-gray-400">
Manage your synced files
@ -895,11 +896,11 @@ export default function SettingsView() {
Manage
</>
)) || (
<>
<Plugs className="h-5 w-5 inline mr-1" />
Connect
</>
)}
<>
<Plugs className="h-5 w-5 inline mr-1" />
Connect
</>
)}
</Button>
<Button
variant="outline"
@ -915,11 +916,12 @@ export default function SettingsView() {
<CardHeader className="text-xl flex flex-row">
<NotionLogo className="h-7 w-7 mr-2" />
Notion
{
userConfig.enabled_content_source.notion && (
<CheckCircle className="h-6 w-6 ml-auto text-green-500" weight="fill" />
)
}
{userConfig.enabled_content_source.notion && (
<CheckCircle
className="h-6 w-6 ml-auto text-green-500"
weight="fill"
/>
)}
</CardHeader>
<CardContent className="grid gap-4">
<p className="text-gray-400">
@ -938,7 +940,7 @@ export default function SettingsView() {
{
/* Show connect to notion button if notion oauth url setup and user disconnected*/
userConfig.notion_oauth_url &&
!userConfig.enabled_content_source.notion ? (
!userConfig.enabled_content_source.notion ? (
<Button
variant="outline"
size="sm"
@ -952,35 +954,35 @@ export default function SettingsView() {
Connect
</Button>
) : /* Show sync button if user connected to notion and API key unchanged */
userConfig.enabled_content_source.notion &&
notionToken === userConfig.notion_token ? (
<Button
variant="outline"
size="sm"
onClick={() => syncContent("notion")}
>
<ArrowsClockwise className="h-5 w-5 inline mr-1" />
Sync
</Button>
) : /* Show set API key button notion oauth url not set setup */
!userConfig.notion_oauth_url ? (
<Button
variant="outline"
size="sm"
onClick={saveNotionToken}
disabled={
notionToken === userConfig.notion_token
}
>
<FloppyDisk className="h-5 w-5 inline mr-1" />
{(userConfig.enabled_content_source
.notion &&
"Update API Key") ||
"Set API Key"}
</Button>
) : (
<></>
)
userConfig.enabled_content_source.notion &&
notionToken === userConfig.notion_token ? (
<Button
variant="outline"
size="sm"
onClick={() => syncContent("notion")}
>
<ArrowsClockwise className="h-5 w-5 inline mr-1" />
Sync
</Button>
) : /* Show set API key button notion oauth url not set setup */
!userConfig.notion_oauth_url ? (
<Button
variant="outline"
size="sm"
onClick={saveNotionToken}
disabled={
notionToken === userConfig.notion_token
}
>
<FloppyDisk className="h-5 w-5 inline mr-1" />
{(userConfig.enabled_content_source
.notion &&
"Update API Key") ||
"Set API Key"}
</Button>
) : (
<></>
)
}
<Button
variant="outline"
@ -1195,18 +1197,18 @@ export default function SettingsView() {
Chat on Whatsapp
{(numberValidationState ===
PhoneNumberValidationState.Verified && (
<CheckCircle
weight="bold"
className="h-4 w-4 ml-1 text-green-400"
/>
)) ||
<CheckCircle
weight="bold"
className="h-4 w-4 ml-1 text-green-400"
/>
)) ||
(numberValidationState !==
PhoneNumberValidationState.Setup && (
<ExclamationMark
weight="bold"
className="h-4 w-4 ml-1 text-yellow-400"
/>
))}
<ExclamationMark
weight="bold"
className="h-4 w-4 ml-1 text-yellow-400"
/>
))}
</CardHeader>
<CardContent className="grid gap-4">
<p className="text-gray-400">
@ -1235,85 +1237,85 @@ export default function SettingsView() {
/>
{numberValidationState ===
PhoneNumberValidationState.VerifyOTP && (
<>
<p>{`Enter the OTP sent to your number: ${phoneNumber}`}</p>
<InputOTP
autoFocus={true}
maxLength={6}
value={otp || ""}
onChange={setOTP}
onComplete={() =>
setNumberValidationState(
PhoneNumberValidationState.VerifyOTP,
)
}
>
<InputOTPGroup>
<InputOTPSlot index={0} />
<InputOTPSlot index={1} />
<InputOTPSlot index={2} />
<InputOTPSlot index={3} />
<InputOTPSlot index={4} />
<InputOTPSlot index={5} />
</InputOTPGroup>
</InputOTP>
</>
)}
<>
<p>{`Enter the OTP sent to your number: ${phoneNumber}`}</p>
<InputOTP
autoFocus={true}
maxLength={6}
value={otp || ""}
onChange={setOTP}
onComplete={() =>
setNumberValidationState(
PhoneNumberValidationState.VerifyOTP,
)
}
>
<InputOTPGroup>
<InputOTPSlot index={0} />
<InputOTPSlot index={1} />
<InputOTPSlot index={2} />
<InputOTPSlot index={3} />
<InputOTPSlot index={4} />
<InputOTPSlot index={5} />
</InputOTPGroup>
</InputOTP>
</>
)}
</div>
</CardContent>
<CardFooter className="flex flex-wrap gap-4">
{(numberValidationState ===
PhoneNumberValidationState.VerifyOTP && (
<Button variant="outline" onClick={verifyOTP}>
Verify
</Button>
)) || (
<Button
variant="outline"
disabled={
!phoneNumber ||
(phoneNumber === userConfig.phone_number &&
numberValidationState ===
<Button variant="outline" onClick={verifyOTP}>
Verify
</Button>
)) || (
<Button
variant="outline"
disabled={
!phoneNumber ||
(phoneNumber === userConfig.phone_number &&
numberValidationState ===
PhoneNumberValidationState.Verified) ||
!isValidPhoneNumber(phoneNumber)
}
onClick={sendOTP}
>
{!userConfig.phone_number ? (
<>
<Plugs className="inline mr-2" />
Setup Whatsapp
</>
) : !phoneNumber ||
(phoneNumber === userConfig.phone_number &&
numberValidationState ===
PhoneNumberValidationState.Verified) ||
!isValidPhoneNumber(phoneNumber) ? (
<>
<PlugsConnected className="inline mr-2 text-green-400" />
Switch Number
</>
) : (
<>
Send OTP{" "}
<ArrowRight
className="inline ml-2"
weight="bold"
/>
</>
)}
</Button>
)}
!isValidPhoneNumber(phoneNumber)
}
onClick={sendOTP}
>
{!userConfig.phone_number ? (
<>
<Plugs className="inline mr-2" />
Setup Whatsapp
</>
) : !phoneNumber ||
(phoneNumber === userConfig.phone_number &&
numberValidationState ===
PhoneNumberValidationState.Verified) ||
!isValidPhoneNumber(phoneNumber) ? (
<>
<PlugsConnected className="inline mr-2 text-green-400" />
Switch Number
</>
) : (
<>
Send OTP{" "}
<ArrowRight
className="inline ml-2"
weight="bold"
/>
</>
)}
</Button>
)}
{numberValidationState ===
PhoneNumberValidationState.Verified && (
<Button
variant="outline"
onClick={() => disconnectNumber()}
>
<CloudSlash className="h-5 w-5 mr-2" />
Disconnect
</Button>
)}
<Button
variant="outline"
onClick={() => disconnectNumber()}
>
<CloudSlash className="h-5 w-5 mr-2" />
Disconnect
</Button>
)}
</CardFooter>
</Card>
</div>