From 913a9970096481c278a89bbd86505f8608866287 Mon Sep 17 00:00:00 2001 From: zuies Date: Fri, 22 Dec 2023 17:46:06 +0300 Subject: [PATCH 1/6] remove useless code on privateRoute.tsx --- src/utils/privateRoute.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/utils/privateRoute.tsx b/src/utils/privateRoute.tsx index eddcb90a..6af49fcf 100644 --- a/src/utils/privateRoute.tsx +++ b/src/utils/privateRoute.tsx @@ -17,9 +17,6 @@ export default function PrivateRoute({ [router.pathname] ); - const isObjectNotEmpty = (obj: Record): boolean => { - return Object.keys(obj).length > 0; - }; useEffect(() => { if (!isCentricRoute) { const storedToken = StorageService.readLocalStorage('user'); From 075e9cec784d67e50a2d88852862603dd5778652 Mon Sep 17 00:00:00 2001 From: zuies Date: Fri, 22 Dec 2023 17:48:57 +0300 Subject: [PATCH 2/6] remove useless code on index.tsx route and remove old components --- .../pages/pageIndex/FooterSection.tsx | 138 ------------------ .../pages/pageIndex/HeaderSection.tsx | 33 ----- src/pages/index.tsx | 11 -- 3 files changed, 182 deletions(-) delete mode 100644 src/components/pages/pageIndex/FooterSection.tsx delete mode 100644 src/components/pages/pageIndex/HeaderSection.tsx diff --git a/src/components/pages/pageIndex/FooterSection.tsx b/src/components/pages/pageIndex/FooterSection.tsx deleted file mode 100644 index be4b8392..00000000 --- a/src/components/pages/pageIndex/FooterSection.tsx +++ /dev/null @@ -1,138 +0,0 @@ -import Image from 'next/image'; - -import graph from '../../../assets/svg/graph.svg'; -import members from '../../../assets/svg/members.svg'; -import metrics from '../../../assets/svg/metrics.svg'; -import arrowBottom from '../../../assets/svg/arrowBottom.svg'; -import benchmark from '../../../assets/svg/benchmark.svg'; - -import { BsClockHistory } from 'react-icons/bs'; -import { HiOutlineArrowRight } from 'react-icons/hi'; -import Link from 'next/link'; - -export const FooterSection = (): JSX.Element => { - return ( - <> -
-
-
-

- Spot value-adding members in your community -

-
- Image Alt -
-
-
-

- Use data to improve onboarding -

-
- Image Alt -
-
-
-
-

- Explore all the metrics that determine
the health of your - community -

-
- Picture of the author -
- Read our research on - -
-
-
-

- Monitor members who disengage and take action to bring them back -

-
- Image Alt -
-
-
-

- Benchmark your metrics and learn from others -

-
- Image Alt -
-
-
-
- - ); -}; diff --git a/src/components/pages/pageIndex/HeaderSection.tsx b/src/components/pages/pageIndex/HeaderSection.tsx deleted file mode 100644 index c0620b51..00000000 --- a/src/components/pages/pageIndex/HeaderSection.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import React from 'react'; - -import { ImArrowDown } from 'react-icons/im'; - -export const HeaderSection = (): JSX.Element => { - return ( - <> -
-
-
-

- The new way to manage your community -

-
-
-

- We believe communities are the beating heart of DAOs. But there - was no way to assess and improve. We assembled a team of - scientists to empower you with deep, actionable insights. -

-

- And while the team is busy building a suite of tools, below is a - - small appetizer to get you started - - -

-
-
-
- - ); -}; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 6bcb0683..3aae153d 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,7 +1,5 @@ import { defaultLayout } from '../layouts/defaultLayout'; import SEO from '../components/global/SEO'; -import { useState } from 'react'; -import { StorageService } from '../services/StorageService'; import EmptyState from '../components/global/EmptyState'; import Image from 'next/image'; import emptyState from '../assets/svg/empty-state.svg'; @@ -13,17 +11,8 @@ import { ChannelProvider } from '../context/ChannelContext'; import { useToken } from '../context/TokenContext'; function Dashboard(): JSX.Element { - const [alertStateOpen, setAlertStateOpen] = useState(false); const { community } = useToken(); - const toggleAnalysisState = () => { - StorageService.writeLocalStorage('analysis_state', { - isRead: true, - visible: false, - }); - setAlertStateOpen(false); - }; - if (!community || community?.platforms?.length === 0) { return ( <> From cce04bd5343ff42e8ef58fabcd4e5702fa400de0 Mon Sep 17 00:00:00 2001 From: zuies Date: Fri, 22 Dec 2023 17:51:28 +0300 Subject: [PATCH 3/6] remove old settings components --- .../pages/settings/ChannelSelection.tsx | 400 ------------------ .../settings/ConfirmStartProcessing.spec.tsx | 85 ---- .../pages/settings/ConfirmStartProcessing.tsx | 75 ---- .../pages/settings/ConnectCommunities.tsx | 260 ------------ .../settings/ConnectedCommunitiesItem.tsx | 91 ---- .../settings/ConnectedCommunitiesList.tsx | 159 ------- .../pages/settings/ConnectedTwitter.tsx | 80 ---- .../pages/settings/DataAnalysis.tsx | 171 -------- .../pages/settings/IntegrateDiscord.tsx | 14 - 9 files changed, 1335 deletions(-) delete mode 100644 src/components/pages/settings/ChannelSelection.tsx delete mode 100644 src/components/pages/settings/ConfirmStartProcessing.spec.tsx delete mode 100644 src/components/pages/settings/ConfirmStartProcessing.tsx delete mode 100644 src/components/pages/settings/ConnectCommunities.tsx delete mode 100644 src/components/pages/settings/ConnectedCommunitiesItem.tsx delete mode 100644 src/components/pages/settings/ConnectedCommunitiesList.tsx delete mode 100644 src/components/pages/settings/ConnectedTwitter.tsx delete mode 100644 src/components/pages/settings/DataAnalysis.tsx delete mode 100644 src/components/pages/settings/IntegrateDiscord.tsx diff --git a/src/components/pages/settings/ChannelSelection.tsx b/src/components/pages/settings/ChannelSelection.tsx deleted file mode 100644 index fdd03676..00000000 --- a/src/components/pages/settings/ChannelSelection.tsx +++ /dev/null @@ -1,400 +0,0 @@ -import { - Accordion, - AccordionDetails, - AccordionSummary, - Dialog, -} from '@mui/material'; -import React, { useEffect, useState } from 'react'; -import { IoClose } from 'react-icons/io5'; -import useAppStore from '../../../store/useStore'; -import ChannelList from '../login/ChannelList'; -import { StorageService } from '../../../services/StorageService'; -import { - IGuild, - IGuildChannels, - IUser, - ISubChannels, - IChannelWithoutId, -} from '../../../utils/types'; -import { BiError } from 'react-icons/bi'; -import CustomButton from '../../global/CustomButton'; -import { FiRefreshCcw } from 'react-icons/fi'; -import Loading from '../../global/Loading'; -import { MdExpandMore } from 'react-icons/md'; -import ConfirmStartProcessing from './ConfirmStartProcessing'; -import clsx from 'clsx'; - -type IProps = { - emitable?: boolean; - submit?: (selectedChannels: IChannelWithoutId[]) => unknown; -}; -export default function ChannelSelection({ emitable, submit }: IProps) { - const [open, setOpen] = useState(false); - const [openProcessing, SetOpenProcessing] = useState(false); - - const [fullWidth, setFullWidth] = React.useState(true); - const [guild, setGuild] = useState(); - const [channels, setChannels] = useState>([]); - const [selectedChannels, setSelectedChannels] = useState< - Array - >([]); - - const { - guildChannels, - guildInfo, - updateSelectedChannels, - getUserGuildInfo, - guilds, - isRefetchLoading, - refetchGuildChannels, - } = useAppStore(); - - useEffect(() => { - const user = StorageService.readLocalStorage('user'); - if (user) { - setGuild(user.guild); - } - - const activeChannles = - guildInfo && guildInfo.selectedChannels - ? guildInfo.selectedChannels.map( - (channel: { - channelId: string; - channelName: string; - _id: string; - }) => { - return channel.channelId; - } - ) - : []; - - const channels = guildChannels.map( - (guild: IGuildChannels, _index: number) => { - const selected: Record = {}; - - guild.subChannels.forEach((subChannel: ISubChannels) => { - if (activeChannles.includes(subChannel.channelId)) { - selected[subChannel.channelId] = true; - } else { - selected[subChannel.channelId] = false; - } - }); - - return { ...guild, selected: selected }; - } - ); - - const subChannelsStatus = channels.map((channel: IGuildChannels) => { - return channel.selected; - }); - - const selectedChannelsStatus = Object.assign({}, ...subChannelsStatus); - let activeChannel: string[] = []; - for (const key in selectedChannelsStatus) { - if (selectedChannelsStatus[key]) { - activeChannel.push(key); - } - } - - const result = ([] as IChannelWithoutId[]).concat( - ...channels.map((channel: IGuildChannels) => { - return channel.subChannels - .filter((subChannel: ISubChannels) => { - if (activeChannel.includes(subChannel.channelId)) { - return subChannel; - } - }) - .map((filterdItem: ISubChannels) => { - return { - channelId: filterdItem.channelId, - channelName: filterdItem.name, - }; - }); - }) - ); - setSelectedChannels(result); - setChannels(channels); - }, [guildChannels]); - - const onChange = ( - channelId: string, - subChannelId: string, - status: boolean - ) => { - setChannels((preChannels) => { - return preChannels.map((preChannel) => { - if (preChannel.channelId !== channelId) return preChannel; - - const selected = preChannel.selected ?? {}; - selected[subChannelId] = status; - - return { ...preChannel, selected }; - }); - }); - }; - const handleCheckAll = (guild: IGuildChannels, status: boolean) => { - const selectedGuild = channels.find( - (channel) => channel.channelId === guild.channelId - ); - if (!selectedGuild) return; - - const updatedChannels = channels.map((channel: IGuildChannels) => { - if (channel === selectedGuild) { - const selected = { ...channel.selected }; - Object.keys(selected).forEach((key) => (selected[key] = status)); - return { ...channel, selected }; - } - return channel; - }); - - setChannels(updatedChannels); - }; - - const refetchChannels = () => { - refetchGuildChannels(guild?.guildId); - }; - - const submitChannels = () => { - const subChannelsStatus = channels.map((channel: IGuildChannels) => { - return channel.selected; - }); - - const selectedChannelsStatus = Object.assign({}, ...subChannelsStatus); - let activeChannel: string[] = []; - for (const key in selectedChannelsStatus) { - if (selectedChannelsStatus[key]) { - activeChannel.push(key); - } - } - - const result = ([] as IChannelWithoutId[]).concat( - ...channels.map((channel: IGuildChannels) => { - return channel.subChannels - .filter((subChannel: ISubChannels) => { - if ( - activeChannel.includes(subChannel.channelId) && - subChannel.canReadMessageHistoryAndViewChannel - ) { - return subChannel; - } - }) - .map((filterdItem: ISubChannels) => { - return { - channelId: filterdItem.channelId, - channelName: filterdItem.name, - }; - }); - }) - ); - - setSelectedChannels(result); - if (emitable) { - if (submit) submit(result); - setOpen(false); - } else { - setOpen(false); - SetOpenProcessing(true); - } - }; - - const handleClose = () => { - setOpen(false); - }; - - const handleCloseProcessingModal = () => { - SetOpenProcessing(false); - }; - const handleToProcess = () => { - updateSelectedChannels(guild?.guildId, selectedChannels).then( - (_res: unknown) => { - SetOpenProcessing(false); - getUserGuildInfo(guild?.guildId); - } - ); - }; - - if (guilds.length === 0) { - return ( -
- Selected channels: {selectedChannels.length}{' '} - setOpen(true)} - > - Show Channels - -

- - - There is no community connected at the moment. To be able to change - channels, please
connect your community first. -
-

-
- ); - } - - return ( -
-

- Selected channels:{' '} - - {guildInfo && guildInfo.isDisconnected ? 0 : selectedChannels.length} - {' '} - setOpen(true)} - > - Show Channels - -

- {guildInfo && guildInfo.isInProgress ? ( -
- -

- We are processing data from selected channels. It might take up to 6 - hours to complete. -

-
- ) : ( - '' - )} - -
-
-
-

- Import activities from channels -

- -
-

- Select channels to import activity in this workspace. Please give - Together Crew access to all selected private channels by updating - the channels permissions in Discord. Discord permission will - affect the channels the bot can see. -

-
-
- {isRefetchLoading ? ( - - ) : ( -
-
- } - size="large" - variant="outlined" - onClick={refetchChannels} - /> -
- {channels && channels.length > 0 - ? channels.map((guild: IGuildChannels, index: number) => { - return ( -
- -
- ); - }) - : ''} -
- )} -
- - - } - > -

- How to give access to the channel you want to import? -

-
- -
-
    -
  1. - Navigate to the channel you want to import on{' '} - - Discord - -
  2. -
  3. - Go to the settings for that specific channel (select the - wheel on the right of the channel name) -
  4. -
  5. - Select Permissions (left sidebar), and then in the - middle of the screen check Advanced permissions -
  6. -
  7. - With the TogetherCrew Bot selected, under Advanced - Permissions, make sure that [View channel] and [Read message - history] are marked as [✓] -
  8. -
  9. - Select the plus sign to the right of Roles/Members and under - members select TogetherCrew bot -
  10. -
  11. - Click on the Refresh List button on this window and - select the new channels -
  12. -
-
-
-
-
- -
-
-
- {' '} -
- ); -} - -ChannelSelection.defaultProps = { - emitable: false, -}; diff --git a/src/components/pages/settings/ConfirmStartProcessing.spec.tsx b/src/components/pages/settings/ConfirmStartProcessing.spec.tsx deleted file mode 100644 index 7d6ed312..00000000 --- a/src/components/pages/settings/ConfirmStartProcessing.spec.tsx +++ /dev/null @@ -1,85 +0,0 @@ -import { render, screen, fireEvent } from '@testing-library/react'; -import ConfirmStartProcessing from './ConfirmStartProcessing'; - -describe('ConfirmStartProcessing', () => { - const onClose = jest.fn(); - const onSubmitProcess = jest.fn(); - - beforeEach(() => { - onClose.mockClear(); - onSubmitProcess.mockClear(); - }); - - it('renders the correct text', () => { - render( - - ); - - expect( - screen.getByText( - /Data from selected channels may take some time to process/i - ) - ).toBeInTheDocument(); - expect( - screen.getByText( - /Please confirm you want to start data processing. It might take up to 6 hours to complete. Once it is done we will send you a message on Discord./i - ) - ).toBeInTheDocument(); - expect( - screen.getByText( - /During this period, it will not be possible to change your imported channels./i - ) - ).toBeInTheDocument(); - expect(screen.getByText(/Cancel/i)).toBeInTheDocument(); - expect(screen.getByText('Start data processing')).toBeInTheDocument(); - }); - - it('calls onClose when cancel button is clicked', () => { - render( - - ); - - const cancelButton = screen.getByText(/Cancel/i); - fireEvent.click(cancelButton); - - expect(onClose).toHaveBeenCalledTimes(1); - }); - - it('calls onSubmitProcess when start button is clicked', () => { - render( - - ); - - const startButton = screen.getByText('Start data processing'); - fireEvent.click(startButton); - - expect(onSubmitProcess).toHaveBeenCalledTimes(1); - }); - - it('calls onClose when close icon is clicked', () => { - render( - - ); - - const closeIcon = screen.getByTestId('close-modal-icon'); - fireEvent.click(closeIcon); - - expect(onClose).toHaveBeenCalledTimes(1); - }); -}); diff --git a/src/components/pages/settings/ConfirmStartProcessing.tsx b/src/components/pages/settings/ConfirmStartProcessing.tsx deleted file mode 100644 index 2e952cb4..00000000 --- a/src/components/pages/settings/ConfirmStartProcessing.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import { Dialog, DialogTitle } from '@mui/material'; -import React from 'react'; -import { BsClockHistory } from 'react-icons/bs'; -import CustomButton from '../../global/CustomButton'; -import { IoClose } from 'react-icons/io5'; - -interface ConfirmStartProcessingProps { - open: boolean; - onClose: () => void; - onSubmitProcess: () => void; -} - -function ConfirmStartProcessing(props: ConfirmStartProcessingProps) { - const { open, onClose, onSubmitProcess } = props; - return ( - - - - -
- -

- Data from selected channels may take some time to process -

-

- Please confirm you want to start data processing. It might take up to - 6 hours to complete. Once it is done we will send you a message on - Discord. -

-

- During this period, it will not be possible to change your imported - channels. -

-
- - -
-
-
- ); -} - -export default ConfirmStartProcessing; diff --git a/src/components/pages/settings/ConnectCommunities.tsx b/src/components/pages/settings/ConnectCommunities.tsx deleted file mode 100644 index 19a3f4b3..00000000 --- a/src/components/pages/settings/ConnectCommunities.tsx +++ /dev/null @@ -1,260 +0,0 @@ -import { Paper, Tooltip, Typography } from '@mui/material'; -import { useEffect, useState } from 'react'; -import { FaDiscord } from 'react-icons/fa'; -import { GoPlus } from 'react-icons/go'; -import CustomButton from '../../global/CustomButton'; -import DatePeriodRange from '../../global/DatePeriodRange'; -import CustomModal from '../../global/CustomModal'; -import ChannelSelection from './ChannelSelection'; -import { BsClockHistory, BsTwitter } from 'react-icons/bs'; -import useAppStore from '../../../store/useStore'; -import { useRouter } from 'next/router'; -import moment from 'moment'; -import { StorageService } from '../../../services/StorageService'; -import { IUser } from '../../../utils/types'; - -import { - setAmplitudeUserIdFromToken, - trackAmplitudeEvent, -} from '../../../helpers/amplitudeHelper'; -import { decodeUserTokenDiscordId } from '../../../helpers/helper'; - -export default function ConnectCommunities() { - const router = useRouter(); - - const user = StorageService.readLocalStorage('user'); - - const [open, setOpen] = useState(false); - const [confirmModalOpen, setConfirmModalOpen] = useState(false); - const [guildId, setGuildId] = useState(''); - const [activePeriod, setActivePeriod] = useState(1); - const [datePeriod, setDatePeriod] = useState(''); - const [selectedChannels, setSelectedChannels] = useState([]); - - const { - guilds, - connectNewGuild, - patchGuildById, - getUserGuildInfo, - authorizeTwitter, - } = useAppStore(); - - if (typeof window !== 'undefined') { - useEffect(() => { - if (Object.keys(router?.query).length > 0 && router.query.isSuccessful) { - const { guildId, guildName } = router?.query; - let user: any = StorageService.readLocalStorage('user'); - user = { token: user.token, guild: { guildId, guildName } }; - StorageService.writeLocalStorage('user', user); - setGuildId(guildId); - toggleModal(true); - setDatePeriod( - moment().subtract('35', 'days').format('YYYY-MM-DDTHH:mm:ss[Z]') - ); - } - }, [router]); - } - - const updateSelectedChannels = (channels: any) => { - setSelectedChannels(channels); - }; - - const handleActivePeriod = (dateRangeType: number | string) => { - let dateTime = ''; - switch (dateRangeType) { - case 1: - setActivePeriod(dateRangeType); - dateTime = moment() - .subtract('35', 'days') - .format('YYYY-MM-DDTHH:mm:ss[Z]'); - break; - case 2: - setActivePeriod(dateRangeType); - dateTime = moment() - .subtract('3', 'months') - .format('YYYY-MM-DDTHH:mm:ss[Z]'); - break; - case 3: - setActivePeriod(dateRangeType); - dateTime = moment() - .subtract('6', 'months') - .format('YYYY-MM-DDTHH:mm:ss[Z]'); - break; - case 4: - setActivePeriod(dateRangeType); - dateTime = moment() - .subtract('1', 'year') - .format('YYYY-MM-DDTHH:mm:ss[Z]'); - break; - default: - break; - } - setDatePeriod(dateTime); - }; - - const submitGuild = async () => { - await patchGuildById(guildId, datePeriod, selectedChannels).then( - (_res: any) => { - setOpen(false); - toggleConfirmModal(true); - } - ); - }; - - const toggleModal = (e: boolean) => { - setOpen(e); - }; - - const toggleConfirmModal = (e: boolean) => { - setConfirmModalOpen(e); - router.replace({ - pathname: '/settings', - }); - }; - - const handleConnectedGuild = () => { - const user: IUser | undefined = - StorageService.readLocalStorage('user'); - - setAmplitudeUserIdFromToken(); - - trackAmplitudeEvent({ - eventType: 'update_connected_guild_on_settings', - eventProperties: { - guild: user?.guild, - }, - }); - getUserGuildInfo(guildId); - setConfirmModalOpen(false); - }; - - const handleAuthorizeTwitter = () => { - authorizeTwitter(decodeUserTokenDiscordId(user)); - }; - const isAllTwitterPropertiesNull = - user && - user.twitter && - Object.values(user.twitter).every((value) => value == null); - - return ( - <> - -
- -

{"Perfect, you're all set!"}

-

- Data import just started. It might take up to 6 hours to finish. - Once it is done we will send you a message on Discord. -

- { - handleConnectedGuild(); - }} - /> -
-
- -
-

- Choose date period for data analysis -

-

- You will be able to change date period and selected channels in the - future. -

- -
-
-

- Confirm your imported channels -

- updateSelectedChannels(channels)} - /> -
- { - submitGuild(); - }} - /> -
-
-
-
-
-

- Connect your communities -

-
- {isAllTwitterPropertiesNull ? ( -
- handleAuthorizeTwitter()} - > -

Twitter

- -
- -

Connect

-
-
-
- ) : ( - <> - )} -
- {guilds.length >= 1 ? ( - - It will be possible to connect more communities soon. - - } - arrow - placement="right" - > - -

Discord

- -
- -

Connect

-
-
-
- ) : ( - connectNewGuild()} - > -

Discord

- -
- -

Connect

-
-
- )} -
-
-
-
- - ); -} diff --git a/src/components/pages/settings/ConnectedCommunitiesItem.tsx b/src/components/pages/settings/ConnectedCommunitiesItem.tsx deleted file mode 100644 index 787156e5..00000000 --- a/src/components/pages/settings/ConnectedCommunitiesItem.tsx +++ /dev/null @@ -1,91 +0,0 @@ -import { Paper, Tooltip, Typography } from '@mui/material'; -import { FaDiscord } from 'react-icons/fa'; -import Image from 'next/image'; -import moment from 'moment'; - -type IProps = { - guild: any; - onClick: (guildId: string) => void; -}; -export default function ConnectedCommunitiesItem({ guild, onClick }: IProps) { - return ( -
- -
-
-

Discord

- {!guild.isInProgress || guild.isDisconnected ? ( - - {guild.isDisconnected - ? 'We don’t have access to your server anymore. Please make sure the Bot is installed properly.' - : !guild.isInProgress - ? 'Discord is connected' - : 'The Discord bot has been connected, and we need time to analyze your data'} - - } - arrow - placement="right" - > - - - ) : ( - - )} -
- -
-
- {guild.guildId && guild.icon ? ( - {guild.name - ) : ( -
- )} -
-

{guild.name}

-

- {!guild.isInProgress || guild.isDisconnected - ? `Connected ${moment(guild.connectedAt).format('DD MMM yyyy')}` - : 'Data import in progress'} -

-
-
-
onClick(guild.guildId)} - > - Disconnect -
- -
- ); -} diff --git a/src/components/pages/settings/ConnectedCommunitiesList.tsx b/src/components/pages/settings/ConnectedCommunitiesList.tsx deleted file mode 100644 index f1972bb2..00000000 --- a/src/components/pages/settings/ConnectedCommunitiesList.tsx +++ /dev/null @@ -1,159 +0,0 @@ -import { useState } from 'react'; -import CustomModal from '../../global/CustomModal'; -import CustomButton from '../../global/CustomButton'; -import ConnectedCommunitiesItem from './ConnectedCommunitiesItem'; -import { toast } from 'react-toastify'; -import { FaRegCheckCircle } from 'react-icons/fa'; -import { Paper } from '@mui/material'; -import useAppStore from '../../../store/useStore'; -import { DISCONNECT_TYPE } from '../../../store/types/ISetting'; -import { StorageService } from '../../../services/StorageService'; -import { ITwitter, IUser } from '../../../utils/types'; - -import { - setAmplitudeUserIdFromToken, - trackAmplitudeEvent, -} from '../../../helpers/amplitudeHelper'; -import ConnectedTwitter from './ConnectedTwitter'; - -export default function ConnectedCommunitiesList({ guilds }: any) { - const { disconnecGuildById, getGuilds } = useAppStore(); - const [open, setOpen] = useState(false); - const [guildId, setGuildId] = useState(''); - const toggleModal = (e: boolean) => { - setOpen(e); - }; - let user: IUser | undefined = StorageService.readLocalStorage('user'); - const notify = () => { - toast('The integration has been disconnected succesfully.', { - position: 'top-center', - autoClose: 3000, - hideProgressBar: true, - closeOnClick: false, - pauseOnHover: true, - draggable: false, - progress: undefined, - closeButton: false, - theme: 'light', - icon: , - }); - }; - - const disconnectGuild = (discconectType: DISCONNECT_TYPE) => { - disconnecGuildById(guildId, discconectType).then((_res: any) => { - notify(); - getGuilds(); - - setAmplitudeUserIdFromToken(); - - trackAmplitudeEvent({ - eventType: 'disconnect_guild_on_setting', - eventProperties: { - guild: user?.guild, - }, - }); - - if (user) { - user = { token: user.token, guild: { guildId: '', guildName: '' } }; - StorageService.writeLocalStorage('user', user); - } - }); - }; - - function isAllTwitterPropertiesNull(twitter: ITwitter): boolean { - return ( - twitter.twitterConnectedAt === null && - twitter.twitterId === null && - twitter.twitterProfileImageUrl === null && - twitter.twitterUsername === null - ); - } - - return ( - <> - {guilds && guilds.length > 0 ? ( -
-

Connected communities

-
- {guilds && guilds.length > 0 - ? guilds.map((guild: any) => ( -
- { - setGuildId(guildId), setOpen(true); - }} - /> -
- )) - : ''} - {user?.twitter && !isAllTwitterPropertiesNull(user.twitter) ? ( -
- -
- ) : ( - <> - )} -
-
- ) : ( - '' - )} - -
-

- Are you sure you want to disconnect{' '} -
your community? -

-
- -
-

Disconnect and delete data

-

- Importing activities and members will be stopped. Historical - activities will be deleted. -

-
- { - disconnectGuild('hard'); - }} - /> -
- -
-

Disconnect only

-

- Importing activities and members will be stopped. Historical - activities will not be affected. -

-
- { - disconnectGuild('soft'); - }} - /> -
-
-
-
- - ); -} diff --git a/src/components/pages/settings/ConnectedTwitter.tsx b/src/components/pages/settings/ConnectedTwitter.tsx deleted file mode 100644 index de5be7b0..00000000 --- a/src/components/pages/settings/ConnectedTwitter.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import { Avatar, Paper } from '@mui/material'; -import React from 'react'; -import { ITwitter } from '../../../utils/types'; -import useAppStore from '../../../store/useStore'; -import { BsTwitter } from 'react-icons/bs'; -import moment from 'moment'; -import { StorageService } from '../../../services/StorageService'; -import clsx from 'clsx'; - -interface IConnectedTwitter { - twitter?: ITwitter; -} - -function ConnectedTwitter({ twitter }: IConnectedTwitter) { - const { disconnectTwitter, getUserInfo } = useAppStore(); - - const handleDisconnect = async () => { - try { - await disconnectTwitter(); - - const userInfo = await getUserInfo(); - const { - twitterConnectedAt, - twitterId, - twitterProfileImageUrl, - twitterUsername, - } = userInfo; - - StorageService.updateLocalStorageWithObject('user', 'twitter', { - twitterConnectedAt, - twitterId, - twitterProfileImageUrl, - twitterUsername, - }); - - StorageService.removeLocalStorage('lastTwitterMetricsRefreshDate'); - } catch (error) { - console.error('Error handling disconnect:', error); - } - }; - - return ( -
- -
-
-

Twitter

- -
- -
-
- -
-

{twitter?.twitterUsername}

-

{`Connected ${moment( - twitter?.twitterConnectedAt - ).format('DD MMM yyyy')}`}

-
-
-
- Disconnect -
-
-
- ); -} - -export default ConnectedTwitter; diff --git a/src/components/pages/settings/DataAnalysis.tsx b/src/components/pages/settings/DataAnalysis.tsx deleted file mode 100644 index cd80b222..00000000 --- a/src/components/pages/settings/DataAnalysis.tsx +++ /dev/null @@ -1,171 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import CustomModal from '../../global/CustomModal'; -import CustomButton from '../../global/CustomButton'; -import DatePeriodRange from '../../global/DatePeriodRange'; -import { BsClockHistory } from 'react-icons/bs'; -import useAppStore from '../../../store/useStore'; -import { FiInfo } from 'react-icons/fi'; -import { BiError } from 'react-icons/bi'; -import moment from 'moment'; -import { StorageService } from '../../../services/StorageService'; -import { IGuild, IUser } from '../../../utils/types'; - -export default function DataAnalysis() { - const [activePeriod, setActivePeriod] = useState(1); - const [guild, setGuild] = useState(); - const [analysisStateDate, setAnalysisStartDate] = useState(''); - const [open, setOpen] = useState(false); - const [datePeriod, setDatePeriod] = useState(''); - const [isDisabled, toggleDisabled] = useState(true); - const { guildInfo, updateAnalysisDatePeriod, getUserGuildInfo, guilds } = - useAppStore(); - - const handleActivePeriod = (dateRangeType: number | string) => { - let dateTime = ''; - switch (dateRangeType) { - case 1: - setActivePeriod(dateRangeType); - dateTime = moment() - .subtract('35', 'days') - .format('YYYY-MM-DDTHH:mm:ss[Z]'); - break; - case 2: - setActivePeriod(dateRangeType); - dateTime = moment() - .subtract('3', 'months') - .format('YYYY-MM-DDTHH:mm:ss[Z]'); - break; - case 3: - setActivePeriod(dateRangeType); - dateTime = moment() - .subtract('6', 'months') - .format('YYYY-MM-DDTHH:mm:ss[Z]'); - break; - case 4: - setActivePeriod(dateRangeType); - dateTime = moment() - .subtract('1', 'year') - .format('YYYY-MM-DDTHH:mm:ss[Z]'); - break; - default: - break; - } - setDatePeriod(dateTime); - toggleDisabled(false); - }; - - useEffect(() => { - const user = StorageService.readLocalStorage('user'); - if (user) { - setGuild(user.guild); - } - const start = moment(guildInfo.period, 'YYYY-MM-DD'); - const end = moment(); - - const datePeriod = Math.round(moment.duration(end.diff(start)).asMonths()); - - if (datePeriod <= 1) { - setActivePeriod(1); - } else if (datePeriod <= 3) { - setActivePeriod(2); - } else if (datePeriod > 3 && datePeriod <= 6) { - setActivePeriod(3); - } else { - setActivePeriod(4); - } - - setAnalysisStartDate(guildInfo.period); - }, [guildInfo]); - - const toggleModal = (e: boolean) => { - setOpen(e); - }; - - const submitNewDatePeriod = () => { - updateAnalysisDatePeriod(guild?.guildId, datePeriod).then((_res: any) => { - getUserGuildInfo(guild?.guildId); - setOpen(false); - }); - }; - - if (guilds.length === 0) { - return ( -
-

- It might take up to 6 hours to finish new data import. Once it is done - we will
send you a message on Discord. -

-

- - - There is no community connected at the moment. To be able to select - the date period, -
please connect your community - first. -
-

-
- - toggleModal(true)} - /> -
-
- ); - } - - return ( -
-

- It might take up to 6 hours to finish new data import. Once it is done - we will
send you a message on Discord. -

-

- - - Data analysis runs from:{' '} - {moment(analysisStateDate).format('DD MMMM yyyy')} - -

- -
- toggleModal(true)} - /> -
- -
- -

- We are changing date period for data analysis now -

-

- It might take up to 6 hours to finish new data import.{' '} -
Once it is done we will send you a - message on Discord. -

- -
-
-
- ); -} diff --git a/src/components/pages/settings/IntegrateDiscord.tsx b/src/components/pages/settings/IntegrateDiscord.tsx deleted file mode 100644 index 951025aa..00000000 --- a/src/components/pages/settings/IntegrateDiscord.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import useAppStore from '../../../store/useStore'; -import ConnectCommunities from './ConnectCommunities'; -import ConnectedCommunitiesList from './ConnectedCommunitiesList'; - -export default function IntegrateDiscord() { - const { guilds } = useAppStore(); - - return ( -
- - -
- ); -} From a4afd2488bf2670356f9799acb6fec498c62170c Mon Sep 17 00:00:00 2001 From: zuies Date: Fri, 22 Dec 2023 18:05:40 +0300 Subject: [PATCH 4/6] remove settingSlice & authSlice --- src/store/slices/authSlice.ts | 73 --------------------- src/store/slices/settingSlice.ts | 108 ------------------------------- src/store/types/IAuth.ts | 34 ---------- src/store/types/ISetting.ts | 59 ----------------- src/store/useStore.ts | 4 -- 5 files changed, 278 deletions(-) delete mode 100644 src/store/slices/authSlice.ts delete mode 100644 src/store/slices/settingSlice.ts delete mode 100644 src/store/types/IAuth.ts delete mode 100644 src/store/types/ISetting.ts diff --git a/src/store/slices/authSlice.ts b/src/store/slices/authSlice.ts deleted file mode 100644 index 0e116464..00000000 --- a/src/store/slices/authSlice.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { StateCreator } from 'zustand'; -import IAuth, { IUser } from '../types/IAuth'; -import { conf } from '../../configs'; -import { axiosInstance } from '../../axiosInstance'; -import { StorageService } from '../../services/StorageService'; - -const BASE_URL = conf.API_BASE_URL; - -const createAuthSlice: StateCreator = (set, get) => ({ - isLoggedIn: false, - isLoading: false, - user: {}, - guildChannels: [], - - signUp: () => { - location.replace(`${BASE_URL}/auth/try-now`); - }, - - login: () => { - location.replace(`${BASE_URL}/auth/login`); - }, - - loginWithDiscord: (user: IUser) => - set(() => { - StorageService.writeLocalStorage('user', { - guild: { - guildId: user.guildId, - guildName: user.guildName, - }, - token: { - accessToken: user.accessToken, - accessExp: user.accessExp, - refreshToken: user.refreshToken, - refreshExp: user.refreshExp, - }, - }); - - return { user }; - }), - - fetchGuildChannels: async (guild_id: string) => { - try { - set(() => ({ isLoading: true })); - const { data } = await axiosInstance.get(`/guilds/${guild_id}/channels`); - set({ guildChannels: [...data], isLoading: false }); - } catch (error) { - set(() => ({ isLoading: false })); - } - }, - - updateGuildById: async (guildId, period, selectedChannels) => { - try { - set(() => ({ isLoading: true })); - await axiosInstance.patch(`/guilds/${guildId}`, { - period, - selectedChannels: selectedChannels, - }); - set({ isLoading: false }); - } catch (error) { - set(() => ({ isLoading: false })); - } - }, - - changeEmail: async (emailAddress: string) => { - try { - await axiosInstance.patch(`/users/@me`, { - email: emailAddress, - }); - } catch (error) {} - }, -}); - -export default createAuthSlice; diff --git a/src/store/slices/settingSlice.ts b/src/store/slices/settingSlice.ts deleted file mode 100644 index 175ede5d..00000000 --- a/src/store/slices/settingSlice.ts +++ /dev/null @@ -1,108 +0,0 @@ -import { StateCreator } from 'zustand'; -import { axiosInstance } from '../../axiosInstance'; -import ISetting from '../types/ISetting'; -import { conf } from '../../configs'; - -const BASE_URL = conf.API_BASE_URL; - -const createSettingSlice: StateCreator = (set, get) => ({ - isLoading: false, - isRefetchLoading: false, - guildInfo: {}, - userInfo: {}, - guildInfoByDiscord: {}, - guilds: [], - guildChannels: [], - getUserGuildInfo: async (guildId: string) => { - try { - set(() => ({ isLoading: true })); - const { data } = await axiosInstance.get(`/guilds/${guildId}`); - - set({ guildInfo: data, isLoading: false }); - } catch (error) { - set(() => ({ guildInfo: {}, isLoading: false })); - } - }, - getUserInfo: async () => { - try { - const { data } = await axiosInstance.get('/users/@me'); - set({ userInfo: data }); - return data; - } catch (error) {} - }, - getGuildInfoByDiscord: async (guildId) => { - try { - set(() => ({ isLoading: true })); - const { data } = await axiosInstance.get(`/guilds/${guildId}`); - set({ guildInfoByDiscord: data, isLoading: false }); - } catch (error) { - set(() => ({ isLoading: false })); - } - }, - updateSelectedChannels: async (guildId, selectedChannels) => { - try { - set(() => ({ isLoading: true })); - await axiosInstance.patch(`/guilds/${guildId}`, { - selectedChannels: selectedChannels, - }); - set({ isLoading: false }); - } catch (error) { - set(() => ({ isLoading: false })); - } - }, - patchGuildById: async (guildId, period, selectedChannels) => { - try { - await axiosInstance.patch(`/guilds/${guildId}`, { - period, - selectedChannels: selectedChannels, - }); - } catch (error) {} - }, - updateAnalysisDatePeriod: async (guildId, period) => { - try { - set(() => ({ isLoading: true })); - await axiosInstance.patch(`/guilds/${guildId}`, { - period, - }); - set({ isLoading: false }); - } catch (error) { - set(() => ({ isLoading: false })); - } - }, - getGuilds: async () => { - try { - const { data } = await axiosInstance.get(`/guilds?isDisconnected=false`); - set({ - guilds: [...data.results], - }); - } catch (error) {} - }, - disconnecGuildById: async (guildId, disconnectType) => { - try { - set(() => ({ isLoading: true })); - await axiosInstance.post(`/guilds/${guildId}/disconnect`, { - disconnectType: disconnectType, - }); - set({ isLoading: false }); - } catch (error) { - set(() => ({ isLoading: false })); - } - }, - connectNewGuild: async () => { - try { - location.replace(`${BASE_URL}/guilds/connect`); - } catch (error) {} - }, - - refetchGuildChannels: async (guild_id: string) => { - try { - set(() => ({ isRefetchLoading: true })); - const { data } = await axiosInstance.get(`/guilds/${guild_id}/channels`); - set({ guildChannels: [...data], isRefetchLoading: false }); - } catch (error) { - set(() => ({ isRefetchLoading: false })); - } - }, -}); - -export default createSettingSlice; diff --git a/src/store/types/IAuth.ts b/src/store/types/IAuth.ts deleted file mode 100644 index ab03f71c..00000000 --- a/src/store/types/IAuth.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { IChannelWithoutId, IGuildChannels } from '../../utils/types'; - -export type IUser = { - readonly accessToken: string; - readonly accessExp: string; - readonly guildId: string; - readonly guildName: string; - readonly refreshExp: string; - readonly refreshToken: string; -}; - -export type ISubChannels = { - readonly id: string; - readonly name: string; - readonly canReadMessageHistoryAndViewChannel: boolean; - readonly parent_id: string; -}; - -export default interface IAuth { - user: IUser | {}; - isLoading: boolean; - isLoggedIn: boolean; - guildChannels: IGuildChannels[]; - signUp: () => void; - login: () => void; - loginWithDiscord: (user: IUser) => void; - fetchGuildChannels: (guild_id: string) => void; - updateGuildById: ( - guildId: string, - period: string, - selectedChannels: IChannelWithoutId[] - ) => any; - changeEmail: (email: string) => any; -} diff --git a/src/store/types/ISetting.ts b/src/store/types/ISetting.ts deleted file mode 100644 index 5de57107..00000000 --- a/src/store/types/ISetting.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { IChannelWithoutId, IGuildChannels } from '../../utils/types'; - -export type IGuildInfo = { - id?: string; - guildId?: string; - ownerId?: string; - name?: boolean; - period?: string; - selectedChannels?: IChannelWithoutId[]; -}; - -export type DISCONNECT_TYPE = 'soft' | 'hard'; - -export interface IUserInfo { - discordId: string; - email: string; - verified: boolean; - avatar: string; - twitterConnectedAt: string; - twitterId: string; - twitterProfileImageUrl: string; - twitterUsername: string; - twitterIsInProgress: boolean; - id: string; -} - -export default interface IGuildList extends IGuildInfo { - isInProgress?: boolean; - isDisconnected?: boolean; - connectedAt?: string; -} -export default interface ISetting { - isLoading: boolean; - isRefetchLoading: boolean; - guildInfo?: IGuildInfo | {}; - userInfo: IUserInfo | {}; - guildInfoByDiscord: {}; - guilds: IGuildList[]; - guildChannels: IGuildChannels[]; - getUserGuildInfo: (guildId: string) => void; - getUserInfo: () => any; - getGuildInfoByDiscord: (guildId: string) => void; - updateSelectedChannels: ( - guildId: string, - selectedChannels: IChannelWithoutId[] - ) => void; - patchGuildById: ( - guildId: string, - period: string, - selectedChannels: IChannelWithoutId[] - ) => any; - updateAnalysisDatePeriod: (guildId: string, period: string) => void; - getGuilds: () => void; - disconnecGuildById: ( - guildId: string, - disconnectType: DISCONNECT_TYPE - ) => void; - refetchGuildChannels: (guild_id: string) => void; -} diff --git a/src/store/useStore.ts b/src/store/useStore.ts index 63526092..16a674c6 100644 --- a/src/store/useStore.ts +++ b/src/store/useStore.ts @@ -1,7 +1,5 @@ import { create } from 'zustand'; -import createAuthSlice from './slices/authSlice'; import createChartSlice from './slices/chartSlice'; -import createSettingSlice from './slices/settingSlice'; import createBreakdownsSlice from './slices/breakdownsSlice'; import createMemberInteractionSlice from './slices/memberInteractionSlice'; import communityHealthSlice from './slices/communityHealthSlice'; @@ -11,9 +9,7 @@ import platformSlice from './slices/platformSlice'; import userSlice from './slices/userSlice'; const useAppStore = create()((...a) => ({ - ...createAuthSlice(...a), ...createChartSlice(...a), - ...createSettingSlice(...a), ...createBreakdownsSlice(...a), ...createMemberInteractionSlice(...a), ...communityHealthSlice(...a), From 8363c08bb6c27550a16b302afcecf1a06c0b5919 Mon Sep 17 00:00:00 2001 From: zuies Date: Fri, 22 Dec 2023 18:08:54 +0300 Subject: [PATCH 5/6] remove old channelList component --- src/components/pages/login/ChannelList.tsx | 91 ---------------------- 1 file changed, 91 deletions(-) delete mode 100644 src/components/pages/login/ChannelList.tsx diff --git a/src/components/pages/login/ChannelList.tsx b/src/components/pages/login/ChannelList.tsx deleted file mode 100644 index 91c38db6..00000000 --- a/src/components/pages/login/ChannelList.tsx +++ /dev/null @@ -1,91 +0,0 @@ -import { FormControlLabel, Checkbox } from '@mui/material'; -import { FiAlertTriangle } from 'react-icons/fi'; -import { ISubChannels } from '../../../utils/types'; - -type IChannelListProps = { - guild: any; - showFlag: boolean; - onChange: (channelId: string, subChannelId: string, status: boolean) => void; - handleCheckAll: (guild: any, status: boolean) => void; -}; - -export default function ChannelList({ - guild, - onChange, - handleCheckAll, - showFlag, -}: IChannelListProps) { - const subChannelsList = ( - <> -

Channels

- {guild.subChannels.map((channel: ISubChannels, index: any) => ( -
-
- - onChange( - guild.channelId, - channel.channelId, - e.target.checked - ) - } - /> - } - label={channel.name} - /> - {showFlag && !channel.canReadMessageHistoryAndViewChannel ? ( -
- - - {!channel.canReadMessageHistoryAndViewChannel - ? 'Bot needs access' - : ''} - -
- ) : ( - '' - )} -
-
- ))} - - ); - - return ( -
-

{guild.title}

-
- item)} - color="secondary" - onChange={(e) => handleCheckAll(guild, e.target.checked)} - /> - } - /> - {subChannelsList} -
-
- ); -} - -ChannelList.defaultProps = { - showFlag: false, -}; From 1e9faab738a4b2466919682bd05df038af883f05 Mon Sep 17 00:00:00 2001 From: zuies Date: Fri, 22 Dec 2023 18:18:07 +0300 Subject: [PATCH 6/6] remove useless global component --- src/components/global/Accardion.tsx | 66 ------------------- src/components/global/Card.tsx | 28 -------- src/components/global/CustomDatePicker.tsx | 77 ---------------------- src/components/global/CustomModal.tsx | 60 ----------------- src/components/global/DatePeriodRange.tsx | 63 ------------------ tsconfig.json | 2 +- 6 files changed, 1 insertion(+), 295 deletions(-) delete mode 100644 src/components/global/Accardion.tsx delete mode 100644 src/components/global/Card.tsx delete mode 100644 src/components/global/CustomDatePicker.tsx delete mode 100644 src/components/global/CustomModal.tsx delete mode 100644 src/components/global/DatePeriodRange.tsx diff --git a/src/components/global/Accardion.tsx b/src/components/global/Accardion.tsx deleted file mode 100644 index e4400f2a..00000000 --- a/src/components/global/Accardion.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import React, { ReactElement } from 'react'; -import { Accordion, AccordionDetails, AccordionSummary } from '@mui/material'; -import { MdExpandMore } from 'react-icons/md'; - -type AcProps = { - readonly title?: string; - childs: AcChildProps[]; -}; - -type AcChildProps = { - title: string; - id: string; - icon?: ReactElement; - detailsComponent: ReactElement; -}; - -export default function Accardion({ title, childs }: AcProps) { - const [expanded, setExpanded] = React.useState(false); - - const handleChange = - (panel: string) => (_event: React.SyntheticEvent, isExpanded: boolean) => { - setExpanded(isExpanded ? panel : false); - }; - - return ( - <> -

{title}

- {childs.map((el) => ( - - - } - aria-controls={`${el.id}-content`} - id={el.id} - > -
-
- {el.icon} -
-

{el.title}

-
-
- - {el.detailsComponent} - -
- ))} - - ); -} diff --git a/src/components/global/Card.tsx b/src/components/global/Card.tsx deleted file mode 100644 index fc0ae5c2..00000000 --- a/src/components/global/Card.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from "react"; -import clsx from "clsx"; -import Image from "next/image"; - -type Props = { - className?: string; - title: string; - srcImage: string; - srcWidth: number; -}; - -export default function Card({ className, title, srcImage, srcWidth }: Props) { - return ( -
-

{title}

-
-
- Picture of the author -
-
-
- ); -} - -Card.defaultProps = { - title: "", - srcWidth: "400", -}; diff --git a/src/components/global/CustomDatePicker.tsx b/src/components/global/CustomDatePicker.tsx deleted file mode 100644 index 45ede02b..00000000 --- a/src/components/global/CustomDatePicker.tsx +++ /dev/null @@ -1,77 +0,0 @@ -import React, { FC, RefObject, useState } from 'react'; -import '@hassanmojab/react-modern-calendar-datepicker/lib/DatePicker.css'; -import DatePicker, { - DayRange, -} from '@hassanmojab/react-modern-calendar-datepicker'; -import { FiCalendar } from 'react-icons/fi'; -import clsx from 'clsx'; -import moment from 'moment'; - -interface IProps { - placeholder?: string; - className: string; - onClick: any; -} - -const CustomDatePicker: FC = ({ - placeholder, - className, - onClick, -}): JSX.Element => { - const [dayRange, setDayRange] = useState({ - from: null, - to: null, - }); - - const renderCustomInput = ({ - ref, - }: { - ref: RefObject | any; - }) => ( -
- - -
- ); - - return ( - setDayRange(date)} - renderInput={renderCustomInput} - colorPrimary="#35B9B7" // added this - colorPrimaryLight="#D0FBF8" // and this - calendarPopperPosition="bottom" - /> - ); -}; - -CustomDatePicker.defaultProps = { - placeholder: 'Specific date', -}; - -export default CustomDatePicker; diff --git a/src/components/global/CustomModal.tsx b/src/components/global/CustomModal.tsx deleted file mode 100644 index 3209fa9a..00000000 --- a/src/components/global/CustomModal.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import { Dialog, DialogTitle, DialogContent } from '@mui/material'; -import { IoClose } from 'react-icons/io5'; - -type IModalProps = { - isOpen: boolean; - toggleModal: (arg0: boolean) => void; - children: any; - hasClose: boolean; -}; -export default function ConfirmModal({ - isOpen, - toggleModal, - children, - hasClose, - ...props -}: IModalProps) { - const handleClose = () => { - toggleModal(false); - }; - return ( - <> - - {hasClose ? ( - - - - ) : ( - '' - )} - {children} - - - ); -} diff --git a/src/components/global/DatePeriodRange.tsx b/src/components/global/DatePeriodRange.tsx deleted file mode 100644 index 826d0b95..00000000 --- a/src/components/global/DatePeriodRange.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import clsx from 'clsx'; -import React, { useState } from 'react'; -import CustomDatePicker from './CustomDatePicker'; - -type dateItems = { - title: string; - icon?: JSX.Element; - value: any; -}; - -const datePeriod: dateItems[] = [ - { - title: 'Last 35 days', - value: 1, - }, - { - title: '3M', - value: 2, - }, - { - title: '6M', - value: 3, - }, - { - title: '1Y', - value: 4, - }, -]; - -type datePeriodRangeProps = { - activePeriod: string | number; - onChangeActivePeriod: (e: number) => void; -}; - -export default function DatePeriodRange({ - activePeriod, - onChangeActivePeriod, -}: datePeriodRangeProps) { - return ( -
-
    - {datePeriod.length > 0 - ? datePeriod.map((el) => ( -
  • onChangeActivePeriod(el.value)} - > - {el.icon ? el.icon : ''} -
    {el.title}
    -
  • - )) - : ''} -
-
- ); -} diff --git a/tsconfig.json b/tsconfig.json index b194c6be..e313683d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,5 +22,5 @@ "jest.config.js", "jest.setup.js" ], - "exclude": ["node_modules", "./src/components/global/CustomDatePicker.tsx"] + "exclude": ["node_modules"] }