Skip to content
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 #207

Closed
wants to merge 112 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
6a04bc2
create simple layout
Aug 29, 2023
e598daa
update color palette
Aug 31, 2023
9ddac2d
create tcTitle component
Aug 31, 2023
68482a3
add document to tcTitle component
Aug 31, 2023
ecd1205
implement components for Account activity parts
Sep 1, 2023
f3cd1d8
add document
Sep 1, 2023
04d7097
add yourAccountActivity part components
Sep 1, 2023
1d5a211
add Audience response components part
Sep 1, 2023
f443d82
remove some code
Sep 1, 2023
612bf78
create engagment component
Sep 4, 2023
160f01c
add vote feature components
Sep 5, 2023
5c315ff
add route to menu
Sep 5, 2023
a176a06
add engagement components
Sep 6, 2023
0eecf52
update components
Sep 6, 2023
6ff1dac
make components responsive
Sep 6, 2023
fb52f94
complete ui
Sep 6, 2023
4f426a9
add style
Sep 6, 2023
b5bea31
change directory of shared components
Sep 15, 2023
80352c1
integrate auth
Sep 26, 2023
10a5a02
add apies
Sep 26, 2023
64755c3
update growth page and change apies
Sep 27, 2023
bb9adab
integrate UI with apies
Sep 27, 2023
2051448
update connected twitter
Sep 27, 2023
b3d7543
update unit tests
Sep 27, 2023
7af2d52
update twitter components and integration
Oct 2, 2023
345aed8
add inprogress field to twitter connected account for status
Oct 2, 2023
97392c1
Merge pull request #193 from TogetherCrew/feat/twitter
mehdi-torabiv Oct 2, 2023
1fb3994
fix button sizes
Oct 3, 2023
8674dd4
fix issue on update twitter status
Oct 3, 2023
32ee1c4
Merge pull request #200 from TogetherCrew/fix/twitter-integration
mehdi-torabiv Oct 3, 2023
31aea1c
fix loading page issue
Oct 3, 2023
dd1d950
Merge pull request #201 from TogetherCrew/fix/twitter-growth-loading
mehdi-torabiv Oct 3, 2023
2b33508
fix button size
Oct 7, 2023
157780d
Merge pull request #202 from TogetherCrew/fix/export-button-style
mehdi-torabiv Oct 7, 2023
da79071
add components for centric pages
Sep 18, 2023
c2b7707
add some component for select community page
Sep 18, 2023
19e40da
create create-new-community page and update node modules
Sep 18, 2023
2fd68d0
change the color
Sep 18, 2023
53b2fe9
implement community-settings page
Sep 20, 2023
e813e83
change variant
Sep 20, 2023
2940fea
create prompt component
Sep 20, 2023
f6a021a
responsive centric pages
Sep 20, 2023
bb93fe4
remove query from router.push
Sep 21, 2023
364aba3
add dialog component for integration on community-settings page
Sep 21, 2023
2f21cfa
update components
Oct 19, 2023
e838b71
create centric slice and integrate first api
Oct 19, 2023
cef4595
update callback funtion & axiosInstance
Oct 22, 2023
0837ba2
integrate community centric pages
Oct 22, 2023
bdba06b
update community centric select community
Oct 23, 2023
a41e341
comment codes relate to old structure
Oct 23, 2023
eb73e33
connect existing api for platforms
Oct 24, 2023
3d3aceb
add disable props to buttons
Oct 24, 2023
2139aad
fix issue on centric pages
Nov 2, 2023
0f2f7d2
integrate community settings integrated platforms parts
Nov 2, 2023
d067d4d
change some texts
Nov 2, 2023
cf78889
update community-settings components
Nov 5, 2023
31d7610
change some texts based on figma design
Nov 5, 2023
a7c66f3
add loading
Nov 9, 2023
0366eea
implement tc-select component
Nov 13, 2023
7537fab
implement popover component
Nov 13, 2023
5b18a33
implement autocomplete components
Nov 13, 2023
9a8df4e
add filter components
Nov 15, 2023
074411d
implement context for token and update privateRoute
Nov 21, 2023
5a544d3
update context
Nov 21, 2023
26e4c86
complete integration for community-settings
Nov 27, 2023
703947c
fix some issue on community platforms
Nov 27, 2023
a28ab4d
replace community input to community-settings page
Nov 28, 2023
fd9543d
add snackbar context and use
Nov 28, 2023
9604523
change some main files
Nov 28, 2023
a7bcb01
add breadcrumbs component
Nov 28, 2023
1ad4440
update tcperiodrange component
Nov 28, 2023
16afae8
add style
Nov 28, 2023
b4d876a
integrate member interaction
Nov 28, 2023
710d3b7
update metrics apies
Nov 28, 2023
401bc52
remove useless imports
Nov 28, 2023
3660423
update channelContext and update platform components integration
Nov 29, 2023
848c9d5
refactor heatmap
Nov 29, 2023
eed35d3
complete responsive size
Nov 29, 2023
8b53776
update community settings pages
Nov 30, 2023
19b6985
remove old routes
Nov 30, 2023
26bdd53
fix updating heatmap data
Nov 30, 2023
70894b3
replace switch-community with select-community routes
Nov 30, 2023
c91316a
fix unit test issue
Nov 30, 2023
6c9cf72
comment autocomplete component
Nov 30, 2023
1815309
remove useless component
Nov 30, 2023
e039aa2
revert changes on sentry.edge
Nov 30, 2023
82d4dc3
fix issue during last debug
Dec 1, 2023
a80c585
update unit tests
Dec 1, 2023
ffabb85
add empty state for statistic
Dec 1, 2023
1f1293c
update community interface and use based on API changes
Dec 3, 2023
b874629
check id for getting platformId
Dec 3, 2023
9efb0a5
Merge pull request #206 from TogetherCrew/feat/organization-centric-app
mehdi-torabiv Dec 4, 2023
1c389b3
add role pagination component
Dec 5, 2023
7e2851c
fix initial state error
Dec 5, 2023
7571ef6
add style
Dec 5, 2023
591f794
Merge pull request #208 from TogetherCrew/feat/role-pagination-component
mehdi-torabiv Dec 5, 2023
3ae63a9
fix style issue on TcPeriodRange
Dec 5, 2023
0e7d527
Merge pull request #209 from TogetherCrew/fix/style-issue
mehdi-torabiv Dec 5, 2023
f616470
fix tooltip on mobile version
Dec 6, 2023
0ed88c1
Merge pull request #211 from TogetherCrew/fix/tooltip-mobile-version
mehdi-torabiv Dec 6, 2023
1ebfb1f
assign avatar community platform to community avatar
Dec 6, 2023
72cf46a
update sidebar and community name avatar components
Dec 6, 2023
f3e8eac
update statement
Dec 7, 2023
35d4e1a
set interval to call channels api every 5 sec
Dec 7, 2023
25a1c9d
add ability to disable channels that we don not have access
Dec 7, 2023
86163f8
fix key issue on customtable
Dec 7, 2023
39de112
fix role filter issues
Dec 8, 2023
f8374fd
fix create new community issue
Dec 8, 2023
110210d
update 404 page
Dec 8, 2023
b970036
improve tcplatformchannel list compoennt
Dec 8, 2023
590bb3c
change component for list of roles
Dec 8, 2023
29b8e22
Merge pull request #213 from TogetherCrew/feat/cc-improvments
mehdi-torabiv Dec 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 48 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@
"zustand": "^4.3.1"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.5.1",
"@types/d3-force": "^3.0.4",
"@types/papaparse": "^5.3.8",
"@types/testing-library__user-event": "^4.2.0",
"autoprefixer": "^10.4.13",
"babel-jest": "^29.5.0",
"identity-obj-proxy": "^3.0.0",
Expand Down
32 changes: 14 additions & 18 deletions src/axiosInstance.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import axios, { AxiosError, AxiosResponse } from 'axios';
import { conf } from './configs/index';
import { StorageService } from './services/StorageService';
import router from 'next/router';
import * as Sentry from '@sentry/nextjs';

import { toast } from 'react-toastify';
import { IUser } from './utils/types';
import { IToken } from './utils/types';
import { tokenRefreshEventEmitter } from './services/EventEmitter';

let isRefreshing = false;
Expand All @@ -16,14 +15,14 @@ export const axiosInstance = axios.create({

axiosInstance.interceptors.request.use(
async (config: any) => {
const user: IUser | undefined =
StorageService.readLocalStorage<IUser>('user');
const user: IToken | undefined =
StorageService.readLocalStorage<IToken>('user');

if (user) {
const { token } = user;
const { accessToken } = user;

if (token.accessToken) {
config.headers!['Authorization'] = `Bearer ${token.accessToken}`;
if (accessToken) {
config.headers!['Authorization'] = `Bearer ${accessToken}`;
}
}

Expand Down Expand Up @@ -52,8 +51,8 @@ axiosInstance.interceptors.response.use(
});
break;
case 401:
const user: IUser | undefined =
StorageService.readLocalStorage<IUser>('user');
const user: IToken | undefined =
StorageService.readLocalStorage<IToken>('user');

if (
error.response?.status === 401 &&
Expand All @@ -78,25 +77,22 @@ axiosInstance.interceptors.response.use(
!error.config.url?.endsWith('/auth/refresh-tokens') &&
user
) {
const { token } = user;
const { accessToken, refreshToken } = user;

if (token.refreshToken && !isRefreshing) {
if (refreshToken && !isRefreshing) {
isRefreshing = true;

try {
const response = await axiosInstance.post(
'/auth/refresh-tokens',
{
refreshToken: token.refreshToken,
refreshToken: refreshToken,
}
);

StorageService.writeLocalStorage('user', {
guild: user.guild,
token: {
accessToken: response.data.access.token,
refreshToken: response.data.refresh.token,
},
accessToken: response.data.access.token,
refreshToken: response.data.refresh.token,
});

axiosInstance.defaults.headers['Authorization'] =
Expand All @@ -118,7 +114,7 @@ axiosInstance.interceptors.response.use(
} finally {
isRefreshing = false;
}
} else if (token.refreshToken && isRefreshing) {
} else if (refreshToken && isRefreshing) {
// If a refresh is already in progress, listen for the completion event
return new Promise((resolve, reject) => {
tokenRefreshEventEmitter.subscribe('tokenRefresh', (newToken) => {
Expand Down
24 changes: 24 additions & 0 deletions src/components/centric/selectCommunity/TcCommunityList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { useEffect, useState } from 'react';
import TcCommunityListItems from './TcCommunityListItems';
import { IDiscordModifiedCommunity } from '../../../utils/interfaces';

function TcCommunityList({ fetchedCommunities, handleActiveCommunity }: any) {
const [activeCommunity, setActiveCommunity] =
useState<IDiscordModifiedCommunity>();
const handleSelectedCommunity = (community: IDiscordModifiedCommunity) => {
setActiveCommunity(community);
};

useEffect(() => {
handleActiveCommunity(activeCommunity);
}, [activeCommunity]);

return (
<TcCommunityListItems
communities={fetchedCommunities.results}
onSelectCommunity={handleSelectedCommunity}
/>
);
}

export default TcCommunityList;
123 changes: 123 additions & 0 deletions src/components/centric/selectCommunity/TcCommunityListItems.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import React, { useEffect, useState } from 'react';
import TcAvatar from '../../shared/TcAvatar';
import TcText from '../../shared/TcText';
import { IDiscordModifiedCommunity } from '../../../utils/interfaces';
import clsx from 'clsx';
import { StorageService } from '../../../services/StorageService';
import { MdGroups } from 'react-icons/md';
import { conf } from '../../../configs';
import Image from 'next/image';

/**
* Props for the TcCommunityListItems component.
*/
interface ITcCommunityListItemsProps {
/**
* Array of community objects with avatar URLs and labels.
*/
communities: IDiscordModifiedCommunity[];
onSelectCommunity: (selectedCommunity: IDiscordModifiedCommunity) => void;
}

/**
* TcCommunityListItems Component
*
* Renders a list of community items, each displaying an avatar and a label.
* Features include:
* - Reading the currently selected community from local storage on initial render.
* - Updating the selected community both internally and via `onSelectCommunity` callback when a community is clicked.
* - Responsive layout for different screen sizes.
* - Displaying a message when there are no communities.
*
* Props:
* - communities (IDiscordModifiedCommunity[]): Array of community objects with `avatarURL` and `name`.
* - onSelectCommunity (Function): Callback when a community is selected.
*
* Usage:
* <TcCommunityListItems
* communities={[{ id: 1, name: 'Community 1', avatarURL: 'url1' }]}
* onSelectCommunity={handleSelect}
* />
*/

function TcCommunityListItems({
communities,
onSelectCommunity,
}: ITcCommunityListItemsProps) {
const [selectedCommunity, setSelectedCommunity] =
useState<IDiscordModifiedCommunity>();

useEffect(() => {
const community =
StorageService.readLocalStorage<IDiscordModifiedCommunity>('community');
setSelectedCommunity(community);
}, []);

useEffect(() => {
if (selectedCommunity) {
onSelectCommunity(selectedCommunity);
}
}, [selectedCommunity]);

const renderPlatformAvatar = (community: IDiscordModifiedCommunity) => {
let activeCommunityPlatformIcon;

if (community?.platforms) {
activeCommunityPlatformIcon = community.platforms.find(
(platform) => platform.disconnectedAt === null
);
}

if (
activeCommunityPlatformIcon &&
activeCommunityPlatformIcon.metadata &&
activeCommunityPlatformIcon.metadata.icon
) {
return (
<Image
src={`${conf.DISCORD_CDN}icons/${activeCommunityPlatformIcon.metadata.id}/${activeCommunityPlatformIcon.metadata.icon}`}
width="100"
height="100"
alt={activeCommunityPlatformIcon.metadata.name || ''}
className="rounded-full"
/>
);
}

return <MdGroups size={28} />;
};

if (communities.length === 0) {
return (
<div className="py-8">
<TcText text="No community exist" variant={'body1'} color="gray" />
</div>
);
}

return (
<div className="flex justify-start flex-wrap mt-8 mx-2">
{communities.map((community, index) => (
<div
className={clsx(
selectedCommunity?.id === community.id ? 'bg-gray-100' : '',
'flex-shrink-0 w-1/2 md:w-1/4 min-h-[150px] rounded text-center px-8 py-4 cursor-pointer space-y-2 hover:bg-gray-100 transition-all delay-75 ease-in'
)}
key={community.name + index}
onClick={() => setSelectedCommunity(community)}
>
{community?.avatarURL ? (
<TcAvatar className="mx-auto" src={community.avatarURL} />
) : (
<TcAvatar className="mx-auto">
{renderPlatformAvatar(community)}
</TcAvatar>
)}
<TcText text={community.name} variant={'body1'} />
</div>
))}
</div>
);
}

export default TcCommunityListItems;
Loading
Loading