-
Notifications
You must be signed in to change notification settings - Fork 881
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: subscribe forms and recommendations
- Loading branch information
Showing
6 changed files
with
185 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/renderer/src/components/subscribe/readok-user-form.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { z } from "zod" | ||
import { zodResolver } from "@hookform/resolvers/zod" | ||
import { useForm } from "react-hook-form" | ||
import { Button } from "@renderer/components/ui/button" | ||
import { | ||
Form, | ||
FormControl, | ||
FormField, | ||
FormItem, | ||
FormLabel, | ||
FormMessage, | ||
} from "@renderer/components/ui/form" | ||
import { Input } from "@renderer/components/ui/input" | ||
|
||
const formSchema = z.object({ | ||
url: z.string().min(1), | ||
}) | ||
|
||
export function ReadOKUserForm() { | ||
const form = useForm<z.infer<typeof formSchema>>({ | ||
resolver: zodResolver(formSchema), | ||
defaultValues: { | ||
url: "", | ||
}, | ||
}) | ||
function onSubmit(values: z.infer<typeof formSchema>) { | ||
console.log(values) | ||
} | ||
|
||
return ( | ||
<Form {...form}> | ||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8"> | ||
<FormField | ||
control={form.control} | ||
name="url" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>User Email</FormLabel> | ||
<FormControl> | ||
<Input {...field} /> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<Button type="submit">Search</Button> | ||
</form> | ||
</Form> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export function Recommendations({ type }: { type: string }) { | ||
return ( | ||
<div className="mt-8"> | ||
<div className="font-medium text-lg">Suggested</div> | ||
<ul className="mt-2"> | ||
<li>Suggestions1</li> | ||
<li>Suggestions2</li> | ||
</ul> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { z } from "zod" | ||
import { zodResolver } from "@hookform/resolvers/zod" | ||
import { useForm } from "react-hook-form" | ||
import { Button } from "@renderer/components/ui/button" | ||
import { | ||
Form, | ||
FormControl, | ||
FormField, | ||
FormItem, | ||
FormLabel, | ||
FormMessage, | ||
} from "@renderer/components/ui/form" | ||
import { Input } from "@renderer/components/ui/input" | ||
|
||
const formSchema = z.object({ | ||
url: z.string().min(1), | ||
}) | ||
|
||
export function RSSForm() { | ||
const form = useForm<z.infer<typeof formSchema>>({ | ||
resolver: zodResolver(formSchema), | ||
defaultValues: { | ||
url: "", | ||
}, | ||
}) | ||
function onSubmit(values: z.infer<typeof formSchema>) { | ||
console.log(values) | ||
} | ||
|
||
return ( | ||
<Form {...form}> | ||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8"> | ||
<FormField | ||
control={form.control} | ||
name="url" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>URL or Keyword</FormLabel> | ||
<FormControl> | ||
<Input {...field} /> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<Button type="submit">Search</Button> | ||
</form> | ||
</Form> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { z } from "zod" | ||
import { zodResolver } from "@hookform/resolvers/zod" | ||
import { useForm } from "react-hook-form" | ||
import { Button } from "@renderer/components/ui/button" | ||
import { | ||
Form, | ||
FormControl, | ||
FormField, | ||
FormItem, | ||
FormLabel, | ||
FormMessage, | ||
} from "@renderer/components/ui/form" | ||
import { Input } from "@renderer/components/ui/input" | ||
import { useEffect } from "react" | ||
|
||
const formSchema = z.object({ | ||
url: z.string().min(1), | ||
}) | ||
|
||
export function RSSHubForm() { | ||
const form = useForm<z.infer<typeof formSchema>>({ | ||
resolver: zodResolver(formSchema), | ||
defaultValues: { | ||
url: "rsshub://", | ||
}, | ||
}) | ||
function onSubmit(values: z.infer<typeof formSchema>) { | ||
console.log(values) | ||
} | ||
|
||
const url = form.watch("url") | ||
useEffect(() => { | ||
if (!url.startsWith("rsshub://")) { | ||
form.setValue("url", "rsshub://") | ||
} else if (url.startsWith("rsshub://rsshub://")) { | ||
form.setValue("url", url.slice(9)) | ||
} | ||
}, [url]) | ||
|
||
return ( | ||
<Form {...form}> | ||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8"> | ||
<FormField | ||
control={form.control} | ||
name="url" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>URL or Keyword</FormLabel> | ||
<FormControl> | ||
<Input {...field} /> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<Button type="submit">Search</Button> | ||
</form> | ||
</Form> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters