From fe4043cef87c673aebd84af449f6de5d055035be Mon Sep 17 00:00:00 2001 From: Clemence Kyara Date: Thu, 5 Sep 2024 09:55:12 +0300 Subject: [PATCH] Fix TS issues --- .../RobotsTxtGenerator/RobotsTxtGenerator.tsx | 255 +++++++++--------- .../components/MobileNavBar/MobileNavBar.tsx | 3 +- 2 files changed, 126 insertions(+), 132 deletions(-) diff --git a/apps/roboshield/src/components/RobotsTxtGenerator/RobotsTxtGenerator.tsx b/apps/roboshield/src/components/RobotsTxtGenerator/RobotsTxtGenerator.tsx index 63f080fa1..76c97e7a0 100644 --- a/apps/roboshield/src/components/RobotsTxtGenerator/RobotsTxtGenerator.tsx +++ b/apps/roboshield/src/components/RobotsTxtGenerator/RobotsTxtGenerator.tsx @@ -18,7 +18,7 @@ import { import { generateRobots } from "@/roboshield/lib/robots"; import RichText, { Children } from "@/roboshield/components/RichText"; -type Props = { [key: string]: string } & { +type Props = { steps: { title: string; hint?: Children; @@ -49,165 +49,160 @@ const slugComponentsMap = { "site-maps": Sitemaps, finish: Finish, }; -const RobotsGenerator: FC = React.forwardRef( - function RobotsGenerator(props, ref) { - const { steps, actions } = props; - const [activeStep, setActiveStep] = useState(0); - const { state, setState } = useGlobalState(); - const [code, setCode] = useState(state.robots || ""); +const RobotsGenerator = React.forwardRef(function RobotsGenerator( + props: Props, + ref: React.ForwardedRef, +) { + const { steps, actions } = props; + const [activeStep, setActiveStep] = useState(0); + const { state, setState } = useGlobalState(); + const [, setCode] = useState(state.robots || ""); - const handleNext = () => { - setActiveStep((prevActiveStep) => prevActiveStep + 1); - }; + const handleNext = () => { + setActiveStep((prevActiveStep) => prevActiveStep + 1); + }; - const handleBack = () => { - setActiveStep((prevActiveStep) => prevActiveStep - 1); - }; + const handleBack = () => { + setActiveStep((prevActiveStep) => prevActiveStep - 1); + }; - const handleReset = () => { - setState(defaultState); - setActiveStep(0); - }; + const handleReset = () => { + setState(defaultState); + setActiveStep(0); + }; - const handleNextStep = (data: any) => { - const newState = { ...state, ...data }; - setState(newState); - handleNext(); - }; + const handleNextStep = (data: any) => { + const newState = { ...state, ...data }; + setState(newState); + handleNext(); + }; - const handleSkipToLast = (data: any) => { - const newState = { ...state, ...data }; - setState(newState); - setActiveStep(props.steps.length - 1); - }; + const handleSkipToLast = (data: any) => { + const newState = { ...state, ...data }; + setState(newState); + setActiveStep(props.steps.length - 1); + }; - const handleStep = (step: number) => () => { - setActiveStep(step); - }; + const handleStep = (step: number) => () => { + setActiveStep(step); + }; - useEffect(() => { - const generateRobotsFile = async () => { - const robots = await generateRobots(state); - setCode(robots); - }; + useEffect(() => { + const generateRobotsFile = async () => { + const robots = await generateRobots(state); + setCode(robots); + }; - generateRobotsFile(); - }, [state]); + generateRobotsFile(); + }, [state]); - const activeStepSlug: - | "existing-robots-txt" - | "delays" - | "paths" - | "block-bots" - | "site-maps" - | "finish" = steps[activeStep]?.blockType; - const ActiveComponent = slugComponentsMap[activeStepSlug] ?? null; - const { hint, ...activeComponentProps } = steps[activeStep] ?? {}; - return ( -
+ - - + + + {steps?.map((step, index) => ( + + + {step?.title} + + + ))} + + {ActiveComponent && ( + - - - {steps?.map((step, index) => ( - - - {step?.title} - - - ))} - - {ActiveComponent && ( - - } - handleNext={handleNextStep} - handleBack={handleBack} - handleSkipToLast={handleSkipToLast} - lastStep={activeStep === steps.length - 1} - handleReset={handleReset} - actions={actions} - {...activeComponentProps} - /> - - )} - + > + } + handleNext={handleNextStep} + handleBack={handleBack} + handleSkipToLast={handleSkipToLast} + lastStep={activeStep === steps.length - 1} + handleReset={handleReset} + actions={actions} + {...activeComponentProps} + /> + + )} - -
- ); - }, -); + + + + ); +}); export default RobotsGenerator; diff --git a/apps/vpnmanager/src/components/MobileNavBar/MobileNavBar.tsx b/apps/vpnmanager/src/components/MobileNavBar/MobileNavBar.tsx index 13a215825..22e4e6ee0 100644 --- a/apps/vpnmanager/src/components/MobileNavBar/MobileNavBar.tsx +++ b/apps/vpnmanager/src/components/MobileNavBar/MobileNavBar.tsx @@ -53,8 +53,7 @@ const DialogContainer = styled(Dialog)(({ theme: { palette, spacing } }) => ({ const Transition: ForwardRefExoticComponent< Omit & RefAttributes -> = React.forwardRef(function Transition( - // @ts-expect-error: Let's ignore a compile on children for now +> = React.forwardRef(function Transition( { children, ...props }, ref: React.Ref | undefined, ) {