📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
typescript improvements
Blue Mouse5ea0f0c041ef
diff --git a/src/pages/Project/View/ViewProject.tsx b/src/pages/Project/View/ViewProject.tsxindex 540accefb..e0f7068a0 100644--- a/src/pages/Project/View/ViewProject.tsx+++ b/src/pages/Project/View/ViewProject.tsx@@ -1607,8 +1607,8 @@ const ViewProject = ({buttonClassName='group-hover:bg-gray-50 px-4 py-2 dark:group-hover:bg-gray-600 inline-flex w-full rounded-md shadow-sm bg-white text-sm font-medium text-gray-700 dark:text-gray-50 dark:border-gray-800 dark:bg-gray-700'keyExtractor={(event) => event.id}onSelect={(event, e) => {- e.stopPropagation()- e.preventDefault()+ e?.stopPropagation()+ e?.preventDefault()setActiveChartMetricsCustomEvents((prev) => {const newActiveChartMetricsCustomEvents = [...prev]diff --git a/src/ui/Alert.tsx b/src/ui/Alert.tsxindex d53f63dbd..4ac34f6cd 100644--- a/src/ui/Alert.tsx+++ b/src/ui/Alert.tsx@@ -6,16 +6,18 @@ import {CheckCircleIcon, InformationCircleIcon, XCircleIcon, XMarkIcon,} from '@heroicons/react/24/solid'-const AlertTemplate = ({- message, options, className, close,-}: {+interface IAlert {message: string,options: {type: 'info' | 'success' | 'error',},className: string,close: () => void,-}): JSX.Element => {+}++const AlertTemplate = ({+ message, options, className, close,+}: IAlert): JSX.Element => {const { type } = optionsconst isInfo = type === 'info'const isSuccess = type === 'success'diff --git a/src/ui/Beta.tsx b/src/ui/Beta.tsxindex 59ce88a30..07a2b92e0 100644--- a/src/ui/Beta.tsx+++ b/src/ui/Beta.tsx@@ -5,11 +5,13 @@ import { useTranslation } from 'react-i18next'import Tooltip from './Tooltip'import { WarningPin } from './Pin'+interface IBeta {+ className?: string,+}+const Beta = ({className,-}: {- className?: string,-}): JSX.Element => {+}: IBeta): JSX.Element => {const { t } = useTranslation('common')return (diff --git a/src/ui/Button.tsx b/src/ui/Button.tsxindex 2c13b1b64..1d12296da 100644--- a/src/ui/Button.tsx+++ b/src/ui/Button.tsx@@ -7,9 +7,7 @@ import PropTypes from 'prop-types'import Spin from './icons/Spin'import './ButtonChristmas.css'-const Button = ({- text, children, primary, secondary, danger, onClick, white, small, regular, large, giant, type, className, loading, semiSmall, semiDanger, noBorder, focus, disabled,-}: {+interface IButton {text?: string,children?: JSX.Element | string,primary?: boolean,@@ -29,7 +27,12 @@ const Button = ({focus?: boolean,noBorder?: boolean,disabled?: boolean,-}): JSX.Element => {+}++const Button = ({+ text, children, primary, secondary, danger, onClick, white, small, regular, large,+ giant, type, className, loading, semiSmall, semiDanger, noBorder, focus, disabled,+}: IButton): JSX.Element => {// const themeType = useSelector((state) => state.ui.theme.type)return (diff --git a/src/ui/Chart.tsx b/src/ui/Chart.tsxindex 351240b27..6914fbc84 100644--- a/src/ui/Chart.tsx+++ b/src/ui/Chart.tsx@@ -3,10 +3,12 @@ import bb from 'billboard.js'import 'billboard.js/dist/theme/datalab.css'import 'billboard.js/dist/billboard.css'-const Chart = ({ current, options }: {+interface IChart {current: string,options: any,-}): JSX.Element => {+}++const Chart = ({ current, options }: IChart): JSX.Element => {let chartInstance: any = {}const destroy = () => {diff --git a/src/ui/Checkbox.tsx b/src/ui/Checkbox.tsxindex 9d16885e3..cfa87fa57 100644--- a/src/ui/Checkbox.tsx+++ b/src/ui/Checkbox.tsx@@ -2,9 +2,7 @@ import React, { memo } from 'react'import cx from 'clsx'import PropTypes from 'prop-types'-const Checkbox = ({- label, hint, id, name, className, onChange, checked, hintClassName, disabled,-}: {+interface ICheckbox {label: string | JSX.Element,hint?: string | JSX.Element,id?: string,@@ -14,7 +12,11 @@ const Checkbox = ({checked?: boolean,hintClassName?: string,disabled?: boolean,-}): JSX.Element => {+}++const Checkbox = ({+ label, hint, id, name, className, onChange, checked, hintClassName, disabled,+}: ICheckbox): JSX.Element => {const identifier = id || namereturn (diff --git a/src/ui/Code.tsx b/src/ui/Code.tsxindex d4d322a3e..74c60b97d 100644--- a/src/ui/Code.tsx+++ b/src/ui/Code.tsx@@ -2,11 +2,13 @@ import React, { memo } from 'react'import PropTypes from 'prop-types'import cx from 'clsx'-const Code = ({ text, className, language }: {+interface ICode {text: string | number | React.ReactNode,className?: string,language: string,-}) => (+}++const Code = ({ text, className, language }: ICode) => (<pre className={cx('w-full rounded-md bg-gray-800 dark:bg-gray-750', className)}><code className={`whitespace-pre-wrap language-${language}`}>{text}</code></pre>diff --git a/src/ui/Dropdown.tsx b/src/ui/Dropdown.tsxindex 01267290a..ff29989c8 100644--- a/src/ui/Dropdown.tsx+++ b/src/ui/Dropdown.tsx@@ -6,21 +6,23 @@ import _map from 'lodash/map'import _isEmpty from 'lodash/isEmpty'import PropTypes from 'prop-types'-const Dropdown = ({- title, desc, className, items, labelExtractor, keyExtractor, onSelect, aside, buttonClassName, selectItemClassName, menuItemsClassName,-}: {+interface IDropdown {title: string | number | React.ReactNode,desc?: string | number | React.ReactNode,className?: string,items: any[],labelExtractor: (item: any) => string | number | React.ReactNode,keyExtractor: (item: any) => string | number | React.ReactNode,- onSelect: (item: any, e?: any) => void | null,+ onSelect: (item: any, e?: React.MouseEvent<HTMLElement>) => void | null,aside?: boolean,buttonClassName?: string,selectItemClassName?: string,menuItemsClassName?: string,-}): JSX.Element => (+}++const Dropdown = ({+ title, desc, className, items, labelExtractor, keyExtractor, onSelect, aside, buttonClassName, selectItemClassName, menuItemsClassName,+}: IDropdown): JSX.Element => (<Menu as='div' className={cx('relative inline-block text-left', className)}>{({ open }) => (<>@@ -59,7 +61,7 @@ const Dropdown = ({// @ts-ignoretabIndex='-1'id='menu-item-0'- onClick={(e) => onSelect(item, e)}+ onClick={(e: React.MouseEvent<HTMLElement>) => onSelect(item, e)}>{labelExtractor ? labelExtractor(item) : item}</span>diff --git a/src/ui/Input.tsx b/src/ui/Input.tsxindex dedadb410..90723ba53 100644--- a/src/ui/Input.tsx+++ b/src/ui/Input.tsx@@ -5,9 +5,7 @@ import PropTypes from 'prop-types'import { ExclamationCircleIcon } from '@heroicons/react/24/solid'import Beta from 'ui/Beta'-const Input = ({- label, hint, placeholder, type, id, name, className, onChange, error, value, disabled, onKeyDown, isBeta,-}: {+interface IInput {label: string | JSX.Element,hint?: string | JSX.Element,placeholder?: string,@@ -21,7 +19,11 @@ const Input = ({disabled?: boolean,onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void,isBeta?: boolean,-}): JSX.Element => {+}++const Input = ({+ label, hint, placeholder, type, id, name, className, onChange, error, value, disabled, onKeyDown, isBeta,+}: IInput): JSX.Element => {const identifier = id || name || typeconst isError = !_isEmpty(error)diff --git a/src/ui/Modal.tsx b/src/ui/Modal.tsxindex 7b0b54af9..d9860373a 100644--- a/src/ui/Modal.tsx+++ b/src/ui/Modal.tsx@@ -7,9 +7,7 @@ import {} from '@heroicons/react/24/outline'import Beta from 'ui/Beta'-const Modal = ({- className, type, title, message, isOpened, onClose, onSubmit, closeText, submitText, submitType, size, customButtons, isBeta,-}: {+interface IModal {className?: string,type: 'error' | 'success' | 'info' | 'warning' | 'confirmed',title: string,@@ -23,7 +21,11 @@ const Modal = ({size?: 'regular' | 'large',customButtons?: JSX.Element,isBeta?: boolean,-}): JSX.Element => (+}++const Modal = ({+ className, type, title, message, isOpened, onClose, onSubmit, closeText, submitText, submitType, size, customButtons, isBeta,+}: IModal): JSX.Element => (<Transition.Root show={isOpened} as={Fragment}><Dialogas='div'diff --git a/src/ui/Pagination.tsx b/src/ui/Pagination.tsxindex 9bd7a674b..b9fe025dc 100644--- a/src/ui/Pagination.tsx+++ b/src/ui/Pagination.tsx@@ -6,14 +6,16 @@ import { useTranslation } from 'react-i18next'import PropTypes from 'prop-types'import { usePagination, DOTS } from 'hooks/usePagination'-const Pagination = ({- page, setPage, pageAmount, total,-}: {+interface IPagination {page: number,setPage: (item: number) => void,pageAmount: number,total: number,-}): JSX.Element => {+}++const Pagination = ({+ page, setPage, pageAmount, total,+}: IPagination): JSX.Element => {const { t } = useTranslation('common')const paginationRange = usePagination(total, page)diff --git a/src/ui/Pin.tsx b/src/ui/Pin.tsxindex 3d194454d..ba1bd42e4 100644--- a/src/ui/Pin.tsx+++ b/src/ui/Pin.tsx@@ -2,51 +2,44 @@ import React from 'react'import cx from 'clsx'import PropTypes from 'prop-types'-const propTypes = {- label: PropTypes.string.isRequired,- className: PropTypes.string,-}--const defaultProps = {- className: '',-}--const ActivePin = ({ label, className }: {+interface IPin {label: string,className?: string,-}): JSX.Element => (+}++const ActivePin = ({ label, className }: IPin): JSX.Element => (<p className={cx('px-2 inline-flex text-sm leading-5 font-normal rounded-full bg-green-100 text-green-800 dark:bg-emerald-400 dark:text-green-900', className)}>{label}</p>)-const InactivePin = ({ label, className }: {- label: string,- className?: string,-}): JSX.Element => (+const InactivePin = ({ label, className }: IPin): JSX.Element => (<p className={cx('px-2 inline-flex text-sm leading-5 font-normal rounded-full bg-red-100 text-red-800 dark:bg-red-300 dark:text-red-900', className)}>{label}</p>)-const WarningPin = ({ label, className }: {- label: string,- className?: string,-}): JSX.Element => (+const WarningPin = ({ label, className }: IPin): JSX.Element => (<p className={cx('px-2 inline-flex text-sm leading-5 font-normal rounded-full bg-yellow-200 text-yellow-800 dark:bg-yellow-300 dark:text-yellow-900', className)}>{label}</p>)-const CustomPin = ({ label, className }: {- label: string,- className?: string,-}): JSX.Element => (+const CustomPin = ({ label, className }: IPin): JSX.Element => (<p className={cx('px-2 inline-flex text-sm leading-5 font-normal rounded-full', className)}>{label}</p>)+const propTypes = {+ label: PropTypes.string.isRequired,+ className: PropTypes.string,+}++const defaultProps = {+ className: '',+}+ActivePin.propTypes = propTypesActivePin.defaultProps = defaultPropsdiff --git a/src/ui/Progress.tsx b/src/ui/Progress.tsxindex 6302b47fe..8b395d58c 100644--- a/src/ui/Progress.tsx+++ b/src/ui/Progress.tsx@@ -1,9 +1,11 @@import React, { memo } from 'react'import PropTypes from 'prop-types'-const Progress = ({ now }: {+interface IProgress {now: number,-}): JSX.Element => (+}++const Progress = ({ now }: IProgress): JSX.Element => (<div className='relative' data-testid='progress'><div className='overflow-hidden h-2 text-xs flex rounded bg-blue-200 dark:bg-gray-500'><div style={{ width: `${now}%` }} className='shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center bg-blue-500 dark:bg-blue-700' />diff --git a/src/ui/Select.tsx b/src/ui/Select.tsxindex 29a4a1a37..67f6cff4c 100644--- a/src/ui/Select.tsx+++ b/src/ui/Select.tsx@@ -5,9 +5,7 @@ import { Listbox, Transition } from '@headlessui/react'import { CheckIcon, ChevronUpDownIcon } from '@heroicons/react/24/solid'import _map from 'lodash/map'-const Select = ({- title, label, className, items, labelExtractor, keyExtractor, iconExtractor, onSelect, id,-}: {+interface ISelect {title?: string,label: string,className?: string,@@ -17,7 +15,11 @@ const Select = ({keyExtractor?: (item: any, index: number) => string,iconExtractor?: (item: any, index: number) => JSX.Element | null,onSelect: (item: any) => void,-}): JSX.Element => (+}++const Select = ({+ title, label, className, items, labelExtractor, keyExtractor, iconExtractor, onSelect, id,+}: ISelect): JSX.Element => (// @ts-ignore<Listbox id={id || ''} className={className} value={title} onChange={onSelect}>{({ open }) => (diff --git a/src/ui/TimezonePicker.tsx b/src/ui/TimezonePicker.tsxindex a3e0fda79..1f3cf0d0e 100644--- a/src/ui/TimezonePicker.tsx+++ b/src/ui/TimezonePicker.tsx@@ -39,15 +39,17 @@ const options = _reduce().sort((a, b) => a.offset - b.offset)-const TimezoneSelect = ({- value, onChange,-}: {+interface ITimezoneSelect {value: string | {value: string,label: string,},onChange: (item: string) => void,-}): JSX.Element => {+}++const TimezoneSelect = ({+ value, onChange,+}: ITimezoneSelect): JSX.Element => {const { t }: {t: (key: string) => string,} = useTranslation('common')diff --git a/src/ui/Tooltip.tsx b/src/ui/Tooltip.tsxindex d6d3d6dae..cb6c19789 100644--- a/src/ui/Tooltip.tsx+++ b/src/ui/Tooltip.tsx@@ -3,13 +3,15 @@ import PropTypes from 'prop-types'import { QuestionMarkCircleIcon } from '@heroicons/react/24/solid'import cx from 'clsx'-const Tooltip = ({- text, className, tooltipNode,-}: {+interface ITooltip {text: string | number | React.ReactNode,className?: string,tooltipNode?: JSX.Element,-}): JSX.Element => (+}++const Tooltip = ({+ text, className, tooltipNode,+}: ITooltip): JSX.Element => (<div className={cx('w-5 h-5 relative flex flex-col group items-center', className)} data-testid='tooltip-wrapper'>{tooltipNode || (<QuestionMarkCircleIcon className='w-5 h-5 text-gray-700 dark:text-gray-300' data-testid='tooltip-icon' />