From a613bdb4c54e86541d5ccdec85758a91a6982aa2 Mon Sep 17 00:00:00 2001 From: AshAnand34 Date: Mon, 7 Jul 2025 21:49:02 -0700 Subject: [PATCH] feat: enhance Crontab Guru tool with interaction tracking and improved validation feedback --- package-lock.json | 15 ++++++ src/pages/tools/time/crontab-guru/index.tsx | 58 ++++++++++++++++++--- 2 files changed, 66 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4600001..5cefa39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4821,6 +4821,21 @@ "node": ">= 6" } }, + "node_modules/cron-validator": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/cron-validator/-/cron-validator-1.3.1.tgz", + "integrity": "sha512-C1HsxuPCY/5opR55G5/WNzyEGDWFVG+6GLrA+fW/sCTcP6A6NTjUP2AK7B8n2PyFs90kDG2qzwm8LMheADku6A==", + "license": "MIT" + }, + "node_modules/cronstrue": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cronstrue/-/cronstrue-3.0.0.tgz", + "integrity": "sha512-acwNTPzndJUmfDmcUN2cpBH4EgVn30rg5BYDAP8n5ENPP8A3IH2Z0UbxaNjvCkKxccjtfsTVhF6d+eHhv/GK5g==", + "license": "MIT", + "bin": { + "cronstrue": "bin/cli.js" + } + }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", diff --git a/src/pages/tools/time/crontab-guru/index.tsx b/src/pages/tools/time/crontab-guru/index.tsx index 4d39ed2..20033c3 100644 --- a/src/pages/tools/time/crontab-guru/index.tsx +++ b/src/pages/tools/time/crontab-guru/index.tsx @@ -49,18 +49,27 @@ export default function CrontabGuru({ const [input, setInput] = useState(''); const [result, setResult] = useState(''); const [isValid, setIsValid] = useState(null); + const [hasInteracted, setHasInteracted] = useState(false); const compute = (values: InitialValuesType, input: string) => { - setIsValid(validateCrontab(input)); + if (hasInteracted) { + setIsValid(validateCrontab(input)); + } setResult(main(input, values)); }; const handleExample = (expr: string) => { setInput(expr); + setHasInteracted(true); setIsValid(validateCrontab(expr)); setResult(main(expr, initialValues)); }; + const handleInputChange = (val: string) => { + if (!hasInteracted) setHasInteracted(true); + setInput(val); + }; + const getGroups: GetGroupsType | null = () => []; return ( @@ -71,7 +80,7 @@ export default function CrontabGuru({ <> @@ -90,12 +99,47 @@ export default function CrontabGuru({ } resultComponent={ - <> - {isValid === false && ( - Invalid crontab expression. +
+ {hasInteracted && isValid === false && ( +
+ + Invalid crontab expression. + +
)} - - +
+ +
+
} initialValues={initialValues} exampleCards={exampleCards}