-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Development #377
Merged
Merged
Development #377
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
951b69c
Merge branch 'development' of github.com:TogetherCrew/frontend into d…
mehdi-torabiv 28eb56d
Merge branch 'main' into development
mehdi-torabiv 82734b1
Merge branch 'main' into development
mehdi-torabiv 3fb3536
Feat/telegram integration (#371)
mehdi-torabiv 4831688
merge
mehdi-torabiv de1bcf8
Feat/telegram metrics (#372)
mehdi-torabiv afcd7b8
merge conflicts
mehdi-torabiv 77e6574
Fix/telegram docs link (#373)
mehdi-torabiv 7e8e990
Merge branch 'development' of github.com:TogetherCrew/frontend into d…
mehdi-torabiv c7bfdcd
fix issue on showing data for community with telegram platform (#374)
mehdi-torabiv 5f375b3
fix (#375)
mehdi-torabiv fe44438
update copy (#376)
mehdi-torabiv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/components/communitySettings/communityPlatforms/TcConnectPlatformButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react'; | ||
import { Button, Paper, Stack } from '@mui/material'; | ||
import { BiPlus } from 'react-icons/bi'; | ||
|
||
import { IntegrationPlatform } from '@/utils/enums'; | ||
import { IPlatformProps } from '@/utils/interfaces'; | ||
|
||
import TcCommunityPlatformIcon from './TcCommunityPlatformIcon'; | ||
|
||
interface TcConnectPlatformButtonProps { | ||
platform: IntegrationPlatform; | ||
connectedPlatforms: IPlatformProps[]; | ||
handleConnectPlatform: () => void; | ||
} | ||
|
||
function TcConnectPlatformButton({ | ||
platform, | ||
connectedPlatforms, | ||
handleConnectPlatform, | ||
}: TcConnectPlatformButtonProps) { | ||
|
||
return ( | ||
<Paper className='flex h-[6rem] w-[10rem] flex-col items-center justify-center rounded-sm py-2 shadow-none'> | ||
<Stack | ||
className='pb-1' | ||
sx={{ | ||
backgroundColor: 'transparent', | ||
color: 'inherit', | ||
}} | ||
> | ||
<TcCommunityPlatformIcon platform={platform} /> | ||
</Stack> | ||
<Button | ||
className='text-sm' | ||
startIcon={<BiPlus />} | ||
onClick={handleConnectPlatform} | ||
disabled={connectedPlatforms?.length > 0} | ||
> | ||
Connect | ||
</Button> | ||
</Paper> | ||
); | ||
} | ||
|
||
export default TcConnectPlatformButton; |
94 changes: 94 additions & 0 deletions
94
src/components/communitySettings/communityPlatforms/TcDisconnectPlatform.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import React from 'react'; | ||
import { | ||
Button, | ||
Dialog, | ||
IconButton, | ||
Typography, | ||
} from '@mui/material'; | ||
import { AiOutlineClose } from 'react-icons/ai'; | ||
|
||
interface TcDisconnectPlatformProps { | ||
open: boolean; | ||
handleClose: () => void; | ||
handleDisconnect: (type: 'hard' | 'soft') => void; | ||
} | ||
|
||
function TcDisconnectPlatform({ | ||
open, | ||
handleClose, | ||
handleDisconnect, | ||
}: TcDisconnectPlatformProps) { | ||
const handleDisconnectPlatform = (type: 'hard' | 'soft') => { | ||
handleDisconnect(type); | ||
}; | ||
|
||
return ( | ||
<Dialog | ||
open={open} | ||
onClose={handleClose} | ||
fullWidth | ||
sx={{ | ||
'& .MuiDialog-container': { | ||
'& .MuiPaper-root': { | ||
width: '100%', | ||
maxWidth: '640px', | ||
borderRadius: '10px', | ||
}, | ||
}, | ||
}} | ||
> | ||
<div className='flex justify-end p-4'> | ||
<IconButton aria-label='close-disconnect-dialog' onClick={handleClose}> | ||
<AiOutlineClose className='cursor-pointer' size={24} /> | ||
</IconButton> | ||
</div> | ||
<div className='px-4 text-center md:px-8'> | ||
<div className='mx-auto text-center md:w-4/5'> | ||
<Typography variant='h6'> | ||
Are you sure you want to disconnect? | ||
</Typography> | ||
</div> | ||
<div className='flex flex-col justify-between space-y-4 pb-8 md:flex-row md:space-x-5 md:space-y-0 md:py-12'> | ||
<div className='space-y-4 rounded-md px-4 py-6 shadow-xl'> | ||
<Typography variant='body1' fontWeight='bold'> | ||
Disconnect and delete data | ||
</Typography> | ||
<Typography variant='body2' textAlign='left'> | ||
Importing new data will be stopped. Already imported and analyzed | ||
data <b>will be deleted.</b> | ||
</Typography> | ||
<Button | ||
variant='contained' | ||
fullWidth | ||
disableElevation | ||
onClick={() => handleDisconnectPlatform('hard')} | ||
> | ||
Disconnect and delete | ||
</Button> | ||
</div> | ||
<div className='space-y-4 rounded-md px-4 py-6 shadow-xl'> | ||
<Typography variant='body1' fontWeight='bold'> | ||
Disconnect only | ||
</Typography> | ||
<Typography textAlign='left' variant='body2'> | ||
<span> | ||
Importing new data will be stopped. Already imported and | ||
analyzed data <b>will be kept.</b> | ||
</span> | ||
</Typography> | ||
<Button | ||
variant='contained' | ||
fullWidth | ||
disableElevation | ||
onClick={() => handleDisconnectPlatform('soft')} | ||
> | ||
Disconnect | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
</Dialog> | ||
); | ||
} | ||
|
||
export default TcDisconnectPlatform; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
src/components/communitySettings/communityPlatforms/TcTelegram/TcConnectedTelegram.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import React, { useState } from 'react'; | ||
import { Paper } from '@mui/material'; | ||
import { IoSettingsSharp } from 'react-icons/io5'; | ||
|
||
import TcAvatar from '@/components/shared/TcAvatar'; | ||
import TcButton from '@/components/shared/TcButton'; | ||
|
||
import useAppStore from '@/store/useStore'; | ||
|
||
import { useSnackbar } from '@/context/SnackbarContext'; | ||
import { truncateCenter } from '@/helpers/helper'; | ||
import { IPlatformProps } from '@/utils/interfaces'; | ||
|
||
import TcConnectedTelegramDialog from './TcConnectedTelegramDialog'; | ||
import TcDisconnectPlatform from '../TcDisconnectPlatform'; | ||
|
||
interface TcConnectedTelegramProps { | ||
platforms: IPlatformProps[]; | ||
handleUpdateCommunityPlatform: () => void; | ||
} | ||
|
||
const TcConnectedTelegram: React.FC<TcConnectedTelegramProps> = ({ | ||
platforms, | ||
handleUpdateCommunityPlatform, | ||
}) => { | ||
const { deletePlatform, setTelegram } = useAppStore(); | ||
const { showMessage } = useSnackbar(); | ||
const [openDialog, setOpenDialog] = useState<boolean>(false); | ||
const [openDisconnectDialog, setOpenDisconnectDialog] = | ||
useState<boolean>(false); | ||
|
||
const handleOpenDisconnectDialog = () => { | ||
setOpenDialog(false); | ||
setOpenDisconnectDialog(true); | ||
}; | ||
|
||
const handleDisconnectPlatform = async (type: 'hard' | 'soft') => { | ||
try { | ||
const data = await deletePlatform({ | ||
id: platforms[0]?.id, | ||
deleteType: type, | ||
}); | ||
if (data === '') { | ||
showMessage('Platform disconnected successfully.', 'success'); | ||
setOpenDisconnectDialog(false); | ||
handleUpdateCommunityPlatform(); | ||
setTelegram({ | ||
value: null, | ||
expiresAt: null, | ||
}); | ||
} | ||
} catch (error) { | ||
showMessage('Error disconnecting platform.', 'error'); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className='flex flex-row space-x-3'> | ||
{platforms && | ||
platforms[0]?.name === 'telegram' && | ||
platforms.map((platform, index) => ( | ||
<Paper | ||
className='flex h-[6rem] w-[10rem] flex-col items-center justify-center space-y-1.5 overflow-hidden rounded-sm py-2 shadow-none' | ||
key={index} | ||
> | ||
<TcAvatar sizes='small' /> | ||
<TcButton | ||
text={truncateCenter(platform?.metadata?.chat?.title, 14)} | ||
className='w-10/12' | ||
variant='text' | ||
color='primary' | ||
startIcon={<IoSettingsSharp />} | ||
onClick={() => setOpenDialog(true)} | ||
/> | ||
</Paper> | ||
))} | ||
<TcConnectedTelegramDialog | ||
platform={platforms[0]} | ||
open={openDialog} | ||
handleClose={() => { | ||
setOpenDialog(false); | ||
handleUpdateCommunityPlatform(); | ||
}} | ||
handleDisconnect={handleOpenDisconnectDialog} | ||
/> | ||
<TcDisconnectPlatform | ||
open={openDisconnectDialog} | ||
handleClose={() => setOpenDisconnectDialog(false)} | ||
handleDisconnect={handleDisconnectPlatform} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default TcConnectedTelegram; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add confirmation step for destructive action.
The "Disconnect and delete data" action is destructive and should require additional confirmation to prevent accidental data loss.
Consider implementing a two-step confirmation process: