CoolFace
Apppublic

admin08077/Githubgemini

sourceHugging Faceotherupdated 10mo agoView on Hugging Face
0likes
AiCodingChallenge-BF05dv_l.js.map1 linesDownload Raw Back to assets
1{"version":3,"file":"AiCodingChallenge-BF05dv_l.js","sources":["../../components/features/AiCodingChallenge.tsx"],"sourcesContent":["import React, { useState, useCallback, useEffect } from 'react';\nimport { generateCodingChallengeStream } from '../../services/index.ts';\nimport { BeakerIcon } from '../icons.tsx';\nimport { LoadingSpinner } from '../shared/index.tsx';\nimport { MarkdownRenderer } from '../shared/index.tsx';\n\nexport const AiCodingChallenge: React.FC = () => {\n    const [challenge, setChallenge] = useState<string>('');\n    const [isLoading, setIsLoading] = useState<boolean>(false);\n    const [error, setError] = useState<string>('');\n\n    const handleGenerate = useCallback(async () => {\n        setIsLoading(true);\n        setError('');\n        setChallenge('');\n        try {\n            const stream = generateCodingChallengeStream(null);\n            let fullResponse = '';\n            for await (const chunk of stream) {\n                fullResponse += chunk;\n                setChallenge(fullResponse);\n            }\n        } catch (err) {\n            const errorMessage = err instanceof Error ? err.message : 'An unknown error occurred.';\n            setError(`Failed to generate challenge: ${errorMessage}`);\n        } finally {\n            setIsLoading(false);\n        }\n    }, []);\n\n    useEffect(() => {\n        // Generate a challenge on initial load for a better user experience\n        handleGenerate();\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n    }, []);\n\n    return (\n        <div className=\"h-full flex flex-col p-4 sm:p-6 lg:p-8 text-text-primary\">\n            <header className=\"mb-6 flex justify-between items-center\">\n                <div>\n                    <h1 className=\"text-3xl font-bold flex items-center\">\n                        <BeakerIcon />\n                        <span className=\"ml-3\">AI Coding Challenge Generator</span>\n                    </h1>\n                    <p className=\"text-text-secondary mt-1\">Generate a unique coding problem to test your skills.</p>\n                </div>\n                <button\n                    onClick={handleGenerate}\n                    disabled={isLoading}\n                    className=\"btn-primary flex items-center justify-center px-6 py-3\"\n                >\n                    {isLoading ? <LoadingSpinner /> : 'Generate New Challenge'}\n                </button>\n            </header>\n            <div className=\"flex-grow p-4 bg-surface border border-border rounded-md overflow-y-auto\">\n                {isLoading && (\n                     <div className=\"flex items-center justify-center h-full\">\n                        <LoadingSpinner />\n                     </div>\n                )}\n                {error && <p className=\"text-red-500\">{error}</p>}\n                {challenge && !isLoading && (\n                    <MarkdownRenderer content={challenge} />\n                )}\n                 {!isLoading && !challenge && !error && (\n                    <div className=\"text-text-secondary h-full flex items-center justify-center\">\n                        Click \"Generate New Challenge\" to start.\n                    </div>\n                )}\n            </div>\n        </div>\n    );\n};"],"names":["AiCodingChallenge","challenge","setChallenge","useState","isLoading","setIsLoading","error","setError","handleGenerate","useCallback","stream","generateCodingChallengeStream","fullResponse","chunk","err","errorMessage","useEffect","jsxs","jsx","BeakerIcon","LoadingSpinner","MarkdownRenderer"],"mappings":"8TAMO,MAAMA,EAA8B,IAAM,CAC7C,KAAM,CAACC,EAAWC,CAAY,EAAIC,EAAAA,SAAiB,EAAE,EAC/C,CAACC,EAAWC,CAAY,EAAIF,EAAAA,SAAkB,EAAK,EACnD,CAACG,EAAOC,CAAQ,EAAIJ,EAAAA,SAAiB,EAAE,EAEvCK,EAAiBC,EAAAA,YAAY,SAAY,CAC3CJ,EAAa,EAAI,EACjBE,EAAS,EAAE,EACXL,EAAa,EAAE,EACf,GAAI,CACA,MAAMQ,EAASC,EAA8B,IAAI,EACjD,IAAIC,EAAe,GACnB,gBAAiBC,KAASH,EACtBE,GAAgBC,EAChBX,EAAaU,CAAY,CAEjC,OAASE,EAAK,CACV,MAAMC,EAAeD,aAAe,MAAQA,EAAI,QAAU,6BAC1DP,EAAS,iCAAiCQ,CAAY,EAAE,CAC5D,QAAA,CACIV,EAAa,EAAK,CACtB,CACJ,EAAG,CAAA,CAAE,EAELW,OAAAA,EAAAA,UAAU,IAAM,CAEZR,EAAA,CAEJ,EAAG,CAAA,CAAE,EAGDS,EAAAA,KAAC,MAAA,CAAI,UAAU,2DACX,SAAA,CAAAA,EAAAA,KAAC,SAAA,CAAO,UAAU,yCACd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