Skip to content

Commit

Permalink
fix: disabled when shouldShowTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyLv committed Mar 13, 2023
1 parent a71638f commit 1e5cd0d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 6 additions & 1 deletion components/PromptOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function PromptOptions({
getValues: UseFormReturn["getValues"];
register: any;
}) {
const shouldShowTimestamp = getValues('showTimestamp');
return (
<div className="mt-10 grid grid-cols-3 items-center gap-x-10 gap-y-6">
<label className="relative inline-flex cursor-pointer items-center">
Expand All @@ -27,8 +28,8 @@ export function PromptOptions({
<label className="relative inline-flex cursor-pointer items-center">
<input
type="checkbox"
value=""
className="peer sr-only"
disabled={shouldShowTimestamp}
{...register("showEmoji")}
/>
<div className="peer h-6 w-11 rounded-full bg-gray-200 after:absolute after:top-[2px] after:left-[2px] after:h-5 after:w-5 after:rounded-full after:border after:border-gray-300 after:bg-white after:transition-all after:content-[''] peer-checked:bg-sky-400 peer-checked:after:translate-x-full peer-checked:after:border-white peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-sky-300 dark:border-gray-600 dark:bg-gray-700 dark:peer-focus:ring-sky-800"></div>
Expand All @@ -46,6 +47,7 @@ export function PromptOptions({
<select
id="outputLanguage"
className="block w-full rounded-md border border-gray-300 bg-gray-50 text-sm text-gray-900 focus:border-sky-500 focus:ring-sky-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 dark:focus:border-sky-500 dark:focus:ring-sky-500"
disabled={shouldShowTimestamp}
{...register("outputLanguage")}
>
{Object.keys(PROMPT_LANGUAGE_MAP).map((k: string) => (
Expand All @@ -69,6 +71,7 @@ export function PromptOptions({
max={10}
step={1}
className="h-2 w-full cursor-pointer accent-black rounded-lg bg-gray-200 dark:bg-gray-700"
disabled={shouldShowTimestamp}
{...register("sentenceNumber")}
/>
</div>
Expand All @@ -87,6 +90,7 @@ export function PromptOptions({
max={5}
step={1}
className="h-2 w-full cursor-pointer accent-black rounded-lg bg-gray-200 dark:bg-gray-700"
disabled={shouldShowTimestamp}
{...register("outlineLevel")}
/>
</div>
Expand All @@ -105,6 +109,7 @@ export function PromptOptions({
max={1000}
step={10}
className="h-2 w-full accent-black cursor-pointer rounded-lg bg-gray-200 dark:bg-gray-700"
disabled={shouldShowTimestamp}
{...register("detailLevel")}
/>
</div>
Expand Down
2 changes: 0 additions & 2 deletions pages/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ export const Home: NextPage<{
storage: typeof window !== "undefined" ? window.localStorage : undefined, // default window.sessionStorage
// exclude: ['baz']
});
// const formValues = getValues();
const shouldShowTimestamp = getValues("showTimestamp");
console.log("========formValues========", shouldShowTimestamp);

useEffect(() => {
licenseKey && setUserKey(licenseKey);
Expand Down

1 comment on commit 1e5cd0d

@vercel
Copy link

@vercel vercel bot commented on 1e5cd0d Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.