-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from TogetherCrew/feat/twitter
Feat/twitter
- Loading branch information
Showing
88 changed files
with
2,866 additions
and
70 deletions.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
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 () => { | ||
await disconnectTwitter(); | ||
const { | ||
twitterConnectedAt, | ||
twitterId, | ||
twitterProfileImageUrl, | ||
twitterUsername, | ||
} = await getUserInfo(); | ||
|
||
StorageService.updateLocalStorageWithObject('user', 'twitter', { | ||
twitterConnectedAt, | ||
twitterId, | ||
twitterProfileImageUrl, | ||
twitterUsername, | ||
}); | ||
StorageService.removeLocalStorage('lastTwitterMetricsRefreshDate'); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Paper className="text-center mx-auto h-[200px] border border-gray-300 w-[200px] py-3 shadow-box rounded-xl flex flex-col justify-between"> | ||
<div> | ||
<div className="font-sm flex justify-center items-center text-center"> | ||
<p className="pr-1">Twitter</p> | ||
<span | ||
className={clsx( | ||
'md:h-3 md:w-3 rounded-full', | ||
twitter?.twitterIsInProgress ? 'bg-success' : 'bg-warning-500' | ||
)} | ||
/> | ||
</div> | ||
<BsTwitter size={30} className="mx-auto mt-2 mb-3" /> | ||
</div> | ||
<div className="flex items-center space-x-1 mx-auto"> | ||
<Avatar | ||
sx={{ height: 35, width: 35 }} | ||
src={twitter?.twitterProfileImageUrl} | ||
/> | ||
<div className="text-left"> | ||
<p className="font-bold text-sm">{twitter?.twitterUsername}</p> | ||
<p className="text-xs">{`Connected ${moment( | ||
twitter?.twitterConnectedAt | ||
).format('DD MMM yyyy')}`}</p> | ||
</div> | ||
</div> | ||
<div | ||
className="border-t text-secondary pt-2 font-semibold cursor-pointer" | ||
onClick={handleDisconnect} | ||
> | ||
Disconnect | ||
</div> | ||
</Paper> | ||
</div> | ||
); | ||
} | ||
|
||
export default ConnectedTwitter; |
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,26 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import TcAlert from './TcAlert'; // Replace with the correct import path | ||
|
||
describe('TcAlert Component', () => { | ||
it('renders the alert with custom message', () => { | ||
const message = 'This is a test alert'; | ||
|
||
const { getByText } = render(<TcAlert severity="info">{message}</TcAlert>); | ||
|
||
// Use the @testing-library/jest-dom assertions to check if the element is present | ||
expect(getByText(message)).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders the alert with a custom severity', () => { | ||
const message = 'Custom severity alert'; | ||
const customSeverity = 'warning'; | ||
|
||
const { container } = render( | ||
<TcAlert severity={customSeverity}>{message}</TcAlert> | ||
); | ||
|
||
// Check if the element has the correct class based on the custom severity | ||
expect(container).toHaveTextContent(message); | ||
}); | ||
}); |
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,20 @@ | ||
import { Alert, AlertProps } from '@mui/material'; | ||
import React from 'react'; | ||
|
||
/** | ||
* TcAlert Component | ||
* | ||
* A simple wrapper component for MUI's Alert component. It allows you to | ||
* use MUI Alert with the flexibility to pass any valid AlertProps. | ||
* | ||
* @param {ITcAlertProps} props - The props for the TcAlert component. | ||
* @returns {React.ReactElement} A React element representing the Alert component. | ||
*/ | ||
|
||
interface ITcAlertProps extends AlertProps {} | ||
|
||
function TcAlert({ ...rest }: ITcAlertProps) { | ||
return <Alert {...rest} />; | ||
} | ||
|
||
export default TcAlert; |
Oops, something went wrong.