From cb1856eae90679fc2be215b7cb8a6bacaa141e5d Mon Sep 17 00:00:00 2001 From: Tyler Tran Date: Thu, 26 Oct 2023 21:12:02 -0700 Subject: [PATCH] Change import statements, and add type for SwitchProps (#1093) * Change import statements, and add type for SwitchProps * Add space to argument of offImg in Switch.tsx --- src/components/common/Switch.test.js | 2 +- src/components/common/{Switch.js => Switch.tsx} | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) rename src/components/common/{Switch.js => Switch.tsx} (88%) diff --git a/src/components/common/Switch.test.js b/src/components/common/Switch.test.js index 0d59390d..12a46b00 100644 --- a/src/components/common/Switch.test.js +++ b/src/components/common/Switch.test.js @@ -1,6 +1,6 @@ import { shallow } from 'enzyme'; import React from 'react'; -import Switch from './Switch.js'; +import Switch from './Switch.tsx'; const switchOnClass = '.switch-body.switch-on'; // there has to be a better way of doing this const switchCheckboxClass = '.switch-input'; diff --git a/src/components/common/Switch.js b/src/components/common/Switch.tsx similarity index 88% rename from src/components/common/Switch.js rename to src/components/common/Switch.tsx index 918c3dfb..59ff434d 100644 --- a/src/components/common/Switch.js +++ b/src/components/common/Switch.tsx @@ -9,8 +9,14 @@ import '../../styles/Switch.scss'; * @param {JSX} onImg (optional): (JSX) element to be displayed on switch body when set to "on" * @param {JSX} offImg (optional): (JSX) element to be displayed on switch body when set to "off" */ +interface SwitchProps { + on: boolean; + onToggle: (on:boolean) => void; + onImg?: JSX.Element; + offImg?: JSX.Element; -const Switch = function (props) { +} +const Switch = function (props: SwitchProps) { const [on, setOn] = useState(!props.on ? false : props.on); useEffect(() => {