Skip to content

Commit

Permalink
fix: set disable button when not validated
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Jul 28, 2024
1 parent f5e2afb commit bff662c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/renderer/src/lib/query-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const persistConfig: OmitKeyof<
"queryClient"
> = {
persister: localStoragePersister,
// 7 day
maxAge: 7 * 24 * 60 * 60 * 1000,
dehydrateOptions: {
shouldDehydrateQuery: (query) => {
if (!query.meta?.persist) return false
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/src/modules/discover/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ export function DiscoverForm({ type }: { type: string }) {
)}
/>
<div className="center flex">
<StyledButton type="submit" isLoading={mutation.isPending}>
<StyledButton
disabled={!form.formState.isValid}
type="submit"
isLoading={mutation.isPending}
>
{info[type].showModal ? "Preview" : "Search"}
</StyledButton>
</div>
Expand Down
20 changes: 11 additions & 9 deletions src/renderer/src/pages/(main)/(layer)/(subview)/discover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { DiscoverForm } from "@renderer/modules/discover/form"
import { DiscoverImport } from "@renderer/modules/discover/import"
import { Recommendations } from "@renderer/modules/discover/recommendations"
import { DiscoverRSS3 } from "@renderer/modules/discover/rss3-form"
import { createElement } from "react"

export function Component() {
const tabs = [
Expand Down Expand Up @@ -55,19 +56,20 @@ export function Component() {
</TabsList>
{tabs.map((tab) => (
<TabsContent key={tab.name} value={tab.name} className="mt-8">
{tab.value === "import" ? (
<DiscoverImport />
) : tab.value === "rss3" ?
(
<DiscoverRSS3 />
) :
(
<DiscoverForm type={tab.value} />
)}
{TabComponent[tab.value] ? (
createElement(TabComponent[tab.value])
) : (
<DiscoverForm type={tab.value} />
)}
</TabsContent>
))}
</Tabs>
<Recommendations />
</div>
)
}

const TabComponent = {
import: DiscoverImport,
rss3: DiscoverRSS3,
}

0 comments on commit bff662c

Please sign in to comment.