📈 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
added ability to change timeBucket & other minor fixes & improvements
Blue Mouse27f84792b762
diff --git a/package.json b/package.jsonindex 441fb9c26..709af6c44 100644--- a/package.json+++ b/package.json@@ -13,8 +13,6 @@"@testing-library/user-event": "^12.8.3","axios": "^0.21.1","billboard.js": "^3.1.2",- "bootstrap": "^5.0.2",- "bootstrap-icons": "^1.4.1","classnames": "^2.3.1","d3": "^7.0.0","dayjs": "^1.10.6",@@ -27,7 +25,6 @@"react-alert": "^7.0.2","react-alert-template-basic": "^1.0.0","react-bootstrap": "^v2.0.0-beta.2",- "react-bootstrap-icons": "^1.4.0","react-dom": "^17.0.1","react-feather": "^2.0.9","react-redux": "^7.2.2",diff --git a/src/api/index.js b/src/api/index.jsindex 64286682b..fa2d0b194 100644--- a/src/api/index.js+++ b/src/api/index.js@@ -1,6 +1,7 @@import axios from 'axios'import { store } from 'redux/store'import Debug from 'debug'+import _map from 'lodash/map'import { authActions } from 'redux/actions/auth'import { getAccessToken, removeAccessToken } from 'utils/accessToken'@@ -177,3 +178,12 @@ export const getProjectData = (pid, tb = 'hour', period = '3d', from = '', to =debug('%s', error)throw error.response.data})++export const getOverallStats = (pids) =>+ api+ .get(`log/birdseye?pids=[${_map(pids, (pid) => `"${pid}"`).join(',')}]`)+ .then(response => response.data)+ .catch(error => {+ debug('%s', error)+ throw error.response.data+ })diff --git a/src/components/Header/index.jsx b/src/components/Header/index.jsxindex 116a63da2..f5d5eaec3 100644--- a/src/components/Header/index.jsx+++ b/src/components/Header/index.jsx@@ -17,19 +17,19 @@ const Header = ({ authenticated }) => {<span className='sr-only'>Analytics</span><img className='h-10 w-auto' src='https://tailwindui.com/img/logos/workflow-mark.svg?color=white' alt='' /></Link>- <div className='hidden ml-10 space-x-8 lg:block'>- <Link to='/' className='text-base font-medium text-white hover:text-indigo-50' key='Features'>Features</Link>- <Link to='/' className='text-base font-medium text-white hover:text-indigo-50' key='Pricing'>Pricing</Link>- <Link to='/' className='text-base font-medium text-white hover:text-indigo-50' key='FAQs'>FAQs</Link>- <Link to='/' className='text-base font-medium text-white hover:text-indigo-50' key='Docs'>Docs</Link>+ <div className='hidden ml-10 space-x-1 lg:block'>+ <Link to='/' className='text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' key='Features'>Features</Link>+ <Link to='/' className='text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' key='Pricing'>Pricing</Link>+ <Link to='/' className='text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' key='FAQs'>FAQs</Link>+ <Link to='/' className='text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' key='Docs'>Docs</Link></div></div><div className='ml-10 space-x-4'>{authenticated ? (<>- <Link to={routes.user_settings} className='text-base font-medium text-white hover:text-indigo-50'>You</Link>+ <Link to={routes.user_settings} className='text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md'>You</Link><Link to={routes.dashboard} className='inline-block bg-white py-2 px-4 border border-transparent rounded-md text-base font-medium text-indigo-600 hover:bg-indigo-50'>Dashboard</Link>- <Link to='#' className='text-base font-medium text-white hover:text-indigo-50' onClick={() => dispatch(authActions.logout())}>Logout</Link>+ <Link to='#' className='text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' onClick={() => dispatch(authActions.logout())}>Logout</Link></>) : (<>@@ -39,11 +39,11 @@ const Header = ({ authenticated }) => {)}</div></div>- <div className='py-4 flex flex-wrap justify-center space-x-6 lg:hidden'>- <Link to='/' className='text-base font-medium text-white hover:text-indigo-50' key='Features'>Features</Link>- <Link to='/' className='text-base font-medium text-white hover:text-indigo-50' key='Pricing'>Pricing</Link>- <Link to='/' className='text-base font-medium text-white hover:text-indigo-50' key='FAQs'>FAQs</Link>- <Link to='/' className='text-base font-medium text-white hover:text-indigo-50' key='Docs'>Docs</Link>+ <div className='py-4 flex flex-wrap justify-center space-x-2 lg:hidden'>+ <Link to='/' className='text-base font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' key='Features'>Features</Link>+ <Link to='/' className='text-base font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' key='Pricing'>Pricing</Link>+ <Link to='/' className='text-base font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' key='FAQs'>FAQs</Link>+ <Link to='/' className='text-base font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' key='Docs'>Docs</Link></div></nav></header>diff --git a/src/pages/Auth/VerifyEmail/index.jsx b/src/pages/Auth/VerifyEmail/index.jsxindex d1e974074..75ddf8db6 100644--- a/src/pages/Auth/VerifyEmail/index.jsx+++ b/src/pages/Auth/VerifyEmail/index.jsx@@ -1,9 +1,11 @@-import React, { useState, useEffect } from 'react'-import Spinner from 'react-bootstrap/Spinner'+import React, { useState, useEffect, memo } from 'react'import { useDispatch } from 'react-redux'import { useParams } from 'react-router-dom'+import { CheckCircleIcon } from '@heroicons/react/solid'+import { XCircleIcon } from '@heroicons/react/solid'import { authActions } from 'redux/actions/auth'+import Loader from 'ui/Loader'const VerifyEmail = () => {const dispatch = useDispatch()@@ -24,19 +26,45 @@ const VerifyEmail = () => {}))}, [dispatch, id])+ if (loading) {+ return (+ <Loader />+ )+ }++ if (error) {+ return (+ <div className='flex justify-center pt-10'>+ <div className='rounded-md p-4 w-11/12 bg-red-50 lg:w-4/6'>+ <div className='flex'>+ <div className='flex-shrink-0'>+ <XCircleIcon className='h-5 w-5 text-red-400' aria-hidden='true' />+ </div>+ <div className='ml-3'>+ <h3 className='text-sm font-medium text-red-800'>{error}</h3>+ </div>+ </div>+ </div>+ </div>+ )+ }+return (- <div className="container d-flex justify-content-center">- {loading- ? (- <Spinner animation="border" role="status" variant="primary" className="spinner-lg">- <span className="sr-only">Loading...</span>- </Spinner>- )- : (- <p>{ error ? error : 'Your email has been successfully verified!' }</p>- )}+ <div className='flex justify-center pt-10'>+ <div className='rounded-md p-4 w-11/12 bg-green-50 lg:w-4/6'>+ <div className='flex'>+ <div className='flex-shrink-0'>+ <CheckCircleIcon className='h-5 w-5 text-green-400' aria-hidden='true' />+ </div>+ <div className='ml-3'>+ <h3 className='text-sm font-medium text-green-800'>+ Your email has been successfully verified!+ </h3>+ </div>+ </div>+ </div></div>)}-export default VerifyEmail\ No newline at end of file+export default memo(VerifyEmail)diff --git a/src/pages/Dashboard/Dashboard.jsx b/src/pages/Dashboard/Dashboard.jsxindex 0a68273dd..ae228e18c 100644--- a/src/pages/Dashboard/Dashboard.jsx+++ b/src/pages/Dashboard/Dashboard.jsx@@ -1,56 +1,89 @@import React, { memo } from 'react'import { Link } from 'react-router-dom'-import Spinner from 'react-bootstrap/Spinner'-import Alert from 'react-bootstrap/Alert'+import cx from 'classnames'import dayjs from 'dayjs'import PropTypes from 'prop-types'import _isEmpty from 'lodash/isEmpty'import _map from 'lodash/map'import { EyeIcon } from '@heroicons/react/outline'-import { ChartBarIcon } from '@heroicons/react/outline'+// import { ChartBarIcon } from '@heroicons/react/outline'import { CalendarIcon } from '@heroicons/react/outline'+import { ArrowSmUpIcon } from '@heroicons/react/solid'+import { ArrowSmDownIcon } from '@heroicons/react/solid'+import { XCircleIcon } from '@heroicons/react/solid'+import Loader from 'ui/Loader'import { ActivePin, InactivePin } from 'ui/Pin'import routes from 'routes'-const ProjectCart = ({ name, url, created, active }) => (- <li>- <Link to={url} className='block hover:bg-gray-50'>- <div className='px-4 py-4 sm:px-6'>- <div className='flex items-center justify-between'>- <p className='text-base font-medium text-indigo-600 truncate'>- {name}- </p>- <div className='ml-2 flex-shrink-0 flex'>- {active ? (- <ActivePin label='Active' />- ) : (- <InactivePin label='Disabled' />- )}- </div>- </div>- <div className='mt-2 sm:flex sm:justify-between'>- <div className='sm:flex flex-col'>- <p className='flex items-center text-sm text-gray-500'>- <EyeIcon className='flex-shrink-0 mr-1.5 h-5 w-5 text-gray-400' />- Pageviews- </p>- <p className='mt-2 flex items-center text-sm text-gray-500 sm:mt-0'>- <ChartBarIcon className='flex-shrink-0 mr-1.5 h-5 w-5 text-gray-400' />- Average load time+const ProjectCart = ({ name, url, created, active, overall }) => {+ const statsDidGrowUp = overall.percChange >= 0++ return (+ <li>+ <Link to={url} className='block hover:bg-gray-50'>+ <div className='px-4 py-4 sm:px-6'>+ <div className='flex items-center justify-between'>+ <p className='text-lg font-medium text-indigo-600 truncate'>+ {name}</p>+ <div className='ml-2 flex-shrink-0 flex'>+ {active ? (+ <ActivePin label='Active' />+ ) : (+ <InactivePin label='Disabled' />+ )}+ </div></div>- <div className='mt-2 flex items-center text-sm text-gray-500'>- <CalendarIcon className='flex-shrink-0 mr-1.5 h-5 w-5 text-gray-400' />- <p>- Created at <time datetime='2020-01-07'>{dayjs(created).format('MMMM D, YYYY')}</time>- </p>+ <div className='mt-2 sm:flex sm:justify-between'>+ <div className='sm:flex flex-col'>+ <p className='flex items-center mt-2 text-sm text-gray-500'>+ <EyeIcon className='flex-shrink-0 mr-1.5 h-5 w-5 text-gray-400' />+ Pageviews: + <dd class="flex items-baseline">+ <p class="h-5 w-5 text-gray-500">+ {overall.thisWeek}+ </p>+ <p class={cx('flex text-xs -ml-1 items-baseline', {+ 'text-green-600': statsDidGrowUp,+ 'text-red-600': !statsDidGrowUp,+ })}>+ {statsDidGrowUp ? (+ <>+ <ArrowSmUpIcon className='self-center flex-shrink-0 h-4 w-4 text-green-500' />+ <span class="sr-only">+ Increased by+ </span>+ </>+ ) : (+ <>+ <ArrowSmDownIcon className='self-center flex-shrink-0 h-4 w-4 text-red-500' />+ <span class="sr-only">+ Descreased by+ </span>+ </>+ )}+ {overall.percChange}%+ </p>+ </dd>+ </p>+ {/* <p className='mt-2 flex items-center text-sm text-gray-500 sm:mt-0'>+ <ChartBarIcon className='flex-shrink-0 mr-1.5 h-5 w-5 text-gray-400' />+ Average load time+ </p> */}+ </div>+ <div className='mt-2 flex items-center text-sm text-gray-500'>+ <CalendarIcon className='flex-shrink-0 mr-1.5 h-5 w-5 text-gray-400' />+ <p>+ Created at <time datetime='2020-01-07'>{dayjs(created).format('MMMM D, YYYY')}</time>+ </p>+ </div></div></div>- </div>- </Link>- </li>-)+ </Link>+ </li>+ )+}const NoProjects = () => (<div className='mt-5'>@@ -71,10 +104,17 @@ const NoProjects = () => (const Dashboard = ({ projects, isLoading, error }) => {if (error && !isLoading) {return (- <div className='min-h-page bg-gray-50 flex flex-col py-6 sm:px-6 lg:px-8'>- <Alert variant='danger'>- {error}- </Alert>+ <div className="flex justify-center pt-10">+ <div className="rounded-md bg-red-50 p-4 w-11/12 lg:w-4/6">+ <div className="flex">+ <div className="flex-shrink-0">+ <XCircleIcon className="h-5 w-5 text-red-400" aria-hidden="true" />+ </div>+ <div className="ml-3">+ <h3 className="text-sm font-medium text-red-800">{error}</h3>+ </div>+ </div>+ </div></div>)}@@ -94,8 +134,8 @@ const Dashboard = ({ projects, isLoading, error }) => {) : (<div className='bg-white shadow overflow-hidden sm:rounded-md mt-10'><ul className='divide-y divide-gray-200'>- {_map(projects, ({ name, id, created, active }) => (- <ProjectCart key={id} name={name} created={created} active={active} url={routes.project.replace(':id', id)} />+ {_map(projects, ({ name, id, created, active, overall }) => (+ <ProjectCart key={id} name={name} created={created} active={active} overall={overall} url={routes.project.replace(':id', id)} />))}</ul></div>@@ -106,11 +146,7 @@ const Dashboard = ({ projects, isLoading, error }) => {}return (- <div className='min-h-page bg-gray-50 flex flex-col py-6 sm:px-6 lg:px-8'>- <Spinner animation='border' role='status' variant='primary' className='spinner-lg'>- <span className='sr-only'>Loading...</span>- </Spinner>- </div>+ <Loader />)}diff --git a/src/pages/Project/Settings/ProjectSettings.jsx b/src/pages/Project/Settings/ProjectSettings.jsxindex 57d704310..00072e4cf 100644--- a/src/pages/Project/Settings/ProjectSettings.jsx+++ b/src/pages/Project/Settings/ProjectSettings.jsx@@ -105,8 +105,8 @@ const ProjectSettings = ({allErrors.name = 'Please enter a project name.'}- if (form.name.length > 80) {- allErrors.name = 'Project name cannot be longer than 80 characters.'+ if (form.name.length > 50) {+ allErrors.name = 'Project name cannot be longer than 50 characters.'}const valid = Object.keys(allErrors).length === 0@@ -147,7 +147,7 @@ const ProjectSettings = ({error={beenSubmitted && errors.id}disabled/>- {isSettings && (+ {isSettings ? (<><Inputname='origins'@@ -159,16 +159,18 @@ const ProjectSettings = ({onChange={handleInput}error={beenSubmitted && errors.origins}/>- <Checkbox- checked={Boolean(form.active)}- onChange={handleInput}- name='active'- id='active'- className='mt-4'- label='Is project enabled'- hint={'Disabled projects will not count any newly incoming events or pageviews.\nYou will still be able to access the project\'s analytics in dashboard.'}- />+ <Checkbox+ checked={Boolean(form.active)}+ onChange={handleInput}+ name='active'+ id='active'+ className='mt-4'+ label='Is project enabled'+ hint={'Disabled projects will not count any newly incoming events or pageviews.\nYou will still be able to access the project\'s analytics in dashboard.'}+ /></>+ ) : (+ <p className='text-gray-500 italic mt-2 text-sm'>*you will be able to set up your project more thoroughly after you have created it</p>)}<div className='flex justify-between mt-4'><div>diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsxindex 93c83d5bc..6687f582b 100644--- a/src/pages/Project/View/ViewProject.jsx+++ b/src/pages/Project/View/ViewProject.jsx@@ -1,6 +1,7 @@import React, { useState, useEffect, useMemo, memo } from 'react'import { useHistory, useParams } from 'react-router-dom'import bb, { area, zoom } from 'billboard.js'+import cx from 'classnames'import * as d3 from 'd3'import dayjs from 'dayjs'import _keys from 'lodash/keys'@@ -8,6 +9,8 @@ import _map from 'lodash/map'import _reduce from 'lodash/reduce'import _size from 'lodash/size'import _isNull from 'lodash/isNull'+import _includes from 'lodash/includes'+import _last from 'lodash/last'import _isEmpty from 'lodash/isEmpty'import _replace from 'lodash/replace'import _find from 'lodash/find'@@ -53,7 +56,7 @@ const ViewProject = ({const [analyticsLoading, setAnalyticsLoading] = useState(true)const [period, setPeriod] = useState(tbPeriodPairs[1].period)const [timeBucket, setTimebucket] = useState(tbPeriodPairs[1].tbs[1])- const periodLabel = useMemo(() => _find(tbPeriodPairs, p => p.period === period).label, [period])+ const activePeriod = useMemo(() => _find(tbPeriodPairs, p => p.period === period), [period])// const [bbChart, setBbChart] = useState([])const { name } = project@@ -62,19 +65,19 @@ const ViewProject = ({if (!isLoading && !_isEmpty(project)) {try {const data = await getProjectData(id, timeBucket, period)-+if (_isEmpty(data)) {setAnalyticsLoading(false)return}-+const { chart, params } = data-+setPanelsData({types: _keys(params),data: params,})-+const bbSettings = {data: {x: 'x',@@ -110,7 +113,7 @@ const ViewProject = ({},bindto: '#dataChart',}-+bb.generate(bbSettings)setAnalyticsLoading(false)} catch (e) {@@ -121,7 +124,18 @@ const ViewProject = ({useEffect(() => {loadAnalytics()- }, [project, period])+ }, [project, period, timeBucket])++ const updatePeriod = (newPeriod) => {+ const newPeriodFull = _find(tbPeriodPairs, (el) => el.period === newPeriod)+ if (_isEmpty(newPeriodFull)) return++ if (!_includes(newPeriodFull.tbs, timeBucket)) {+ setTimebucket(_last(newPeriodFull.tbs))+ }++ setPeriod(newPeriod)+ }if (!isLoading && _isEmpty(project)) {showError('The selected project does not exist')@@ -135,15 +149,34 @@ const ViewProject = ({if (!isLoading) {return (<div className='min-h-page bg-gray-50 py-6 sm:px-6 lg:px-8'>- <div className='flex justify-between h-10 mb-10'>- <h2 className='text-3xl font-extrabold text-gray-900'>{name}</h2>- <div className='flex'>+ <div className='flex flex-col md:flex-row items-center md:items-start justify-between h-10 mb-10 pb-10'>+ <h2 className='text-3xl font-extrabold text-gray-900 break-words'>{name}</h2>+ <div className='flex mt-3 md:mt-0'>+ <div className='md:border-r border-gray-200 md:pr-3 mr-3'>+ <span className='relative z-0 inline-flex shadow-sm rounded-md'>+ {_map(activePeriod.tbs, (tb, index, { length }) => (+ <button+ key={tb}+ type='button'+ onClick={() => setTimebucket(tb)}+ className={cx('relative capitalize inline-flex items-center px-4 py-2 border border-gray-300 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:z-10 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500', {+ '-ml-px': index > 0,+ 'rounded-l-md': index === 0,+ 'rounded-r-md': 1 + index === length,+ 'z-10 border-indigo-500 text-indigo-600': timeBucket === tb,+ })}+ >+ {tb}+ </button>+ ))}+ </span>+ </div><Dropdownitems={tbPeriodPairs}- title={periodLabel}+ title={activePeriod.label}labelExtractor={pair => pair.label}keyExtractor={pair => pair.label}- onSelect={pair => setPeriod(pair.period)}+ onSelect={pair => updatePeriod(pair.period)}/><div className='h-full ml-3'><Button onClick={openSettingsHandler} className='py-2.5' secondary large>@@ -159,8 +192,8 @@ const ViewProject = ({<NoEvents />)) : (- <div>- <div id='dataChart' className='h4' />+ <div className='pt-4 md:pt-0'>+ <div id='dataChart' /><div className='mt-5 grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3'>{_map(panelsData.types, type => (<Panel key={type} name={typeNameMapping[type]} data={panelsData.data[type]} />diff --git a/src/redux/reducers/alerts.js b/src/redux/reducers/alerts.jsindex b797a002c..111daf40a 100644--- a/src/redux/reducers/alerts.js+++ b/src/redux/reducers/alerts.js@@ -14,7 +14,7 @@ export default (state = initialState, { type, payload }) => {case types.CREATE_NEW_PROJECT_SUCCESS:return { ...state, message: payload.message, type: payload.type }- case types.CLEAR_ERRORS:+ case types.CLEAR_ALERTS:return { ...state, message: null, type: 'info' }default:diff --git a/src/redux/sagas/ui/load_projects.js b/src/redux/sagas/ui/load_projects.jsindex 00903a0dd..1a37e0a3d 100644--- a/src/redux/sagas/ui/load_projects.js+++ b/src/redux/sagas/ui/load_projects.js@@ -1,14 +1,22 @@import { put, call } from 'redux-saga/effects'+import _map from 'lodash/map'import Debug from 'debug'-import { getProjects } from '../../../api'+import { getProjects, getOverallStats } from '../../../api'import UIActions from 'redux/actions/ui'const debug = Debug('analytics:rx:s:load-projects')export default function* () {try {- const { results } = yield call(getProjects)+ let { results } = yield call(getProjects)+ const pids = _map(results, result => result.id)+ const overall = yield call(getOverallStats, pids)++ results = _map(results, res => ({+ ...res,+ overall: overall[res.id],+ }))yield put(UIActions.setProjects(results))} catch (e) {const { message } = ediff --git a/src/ui/Modal.jsx b/src/ui/Modal.jsxnew file mode 100644index 000000000..1d35c15f1--- /dev/null+++ b/src/ui/Modal.jsx@@ -0,0 +1,93 @@+import React, { Fragment, useState, memo } from 'react'+import PropTypes from 'prop-types'+import cx from 'classnames'+import { Dialog, Transition } from '@headlessui/react'+import { CheckIcon } from '@heroicons/react/outline'+import { ExclamationIcon } from '@heroicons/react/outline'++// todo: onClose, onSubmit, closeText, submitText+const Modal = ({ className, type, title, message }) => {+ const [open, setOpen] = useState(true)++ return (+ <Transition.Root show={open} as={Fragment}>+ <Dialog as='div' className={cx('fixed z-10 inset-0 overflow-y-auto', className)} open={open} onClose={setOpen} static>+ <div className='flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0'>+ <Transition.Child+ as={Fragment}+ enter='ease-out duration-300'+ enterFrom='opacity-0'+ enterTo='opacity-100'+ leave='ease-in duration-200'+ leaveFrom='opacity-100'+ leaveTo='opacity-0'+ >+ <Dialog.Overlay className='fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity' />+ </Transition.Child>++ {/* This element is to trick the browser into centering the modal contents. */}+ <span className='hidden sm:inline-block sm:align-middle sm:h-screen' aria-hidden='true'>+ ​+ </span>+ <Transition.Child+ as={Fragment}+ enter='ease-out duration-300'+ enterFrom='opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95'+ enterTo='opacity-100 translate-y-0 sm:scale-100'+ leave='ease-in duration-200'+ leaveFrom='opacity-100 translate-y-0 sm:scale-100'+ leaveTo='opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95'+ >+ <div className='inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-sm sm:w-full sm:p-6'>+ <div>+ {type === 'success' && (+ <div className='mx-auto flex items-center justify-center h-12 w-12 rounded-full bg-green-100'>+ <CheckIcon className='h-6 w-6 text-green-600' aria-hidden='true' />+ </div>+ )}+ {type === 'error' && (+ <div className="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10">+ <ExclamationIcon className="h-6 w-6 text-red-600" aria-hidden="true" />+ </div>+ )}+ <div className='mt-3 text-center sm:mt-5'>+ <Dialog.Title as='h3' className='text-lg leading-6 font-medium text-gray-900'>+ {title}+ </Dialog.Title>+ <div className='mt-2'>+ <p className='text-sm text-gray-500'>+ {message}+ </p>+ </div>+ </div>+ </div>+ <div className='mt-5 sm:mt-6'>+ <button+ type='button'+ className='inline-flex justify-center w-full rounded-md border border-transparent shadow-sm px-4 py-2 bg-indigo-600 text-base font-medium text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:text-sm'+ onClick={() => setOpen(false)}+ >+ Go back to dashboard+ </button>+ </div>+ </div>+ </Transition.Child>+ </div>+ </Dialog>+ </Transition.Root>+ )+}++Modal.propTypes = {+ type: PropTypes.oneOfType(['error', 'success']).isRequired,+ title: PropTypes.string.isRequired,+ message: PropTypes.string,+ className: PropTypes.string,+}++Modal.defaultProps = {+ className: '',+ message: '',+}++export default memo(Modal)