Skip to content

Commit

Permalink
Merge pull request #368 from TogetherCrew/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
cyri113 authored Dec 12, 2024
2 parents ea29a41 + df41ce7 commit c373e3c
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-case-declarations */
import React, { useEffect, useState } from 'react';
import { Box, CircularProgress, Paper, Tab, Tabs } from '@mui/material';
import clsx from 'clsx';
Expand Down Expand Up @@ -52,6 +53,18 @@ function a11yProps(index: number) {
};
}

const PLATFORM_ORDER = [
IntegrationPlatform.Discord,
IntegrationPlatform.Github,
IntegrationPlatform.Notion,
IntegrationPlatform.MediaWiki,
IntegrationPlatform.Discourse,
IntegrationPlatform.Telegram,
IntegrationPlatform.X,
IntegrationPlatform.Snapshot,
IntegrationPlatform.GDrive,
];

function HivemindSettings() {
const { retrievePlatforms, retrieveModules, patchModule } = useAppStore();
const [loading, setLoading] = useState<boolean>(false);
Expand Down Expand Up @@ -113,22 +126,6 @@ function HivemindSettings() {
case 1:
setIsActivePlatformLoading(true);
const { results: googleResults } = await retrievePlatforms({
name: 'google',
community: communityId,
});
const gdriveHivemindModule = hivemindModules.results.find(
(hivemindModule: IModuleProps) =>
hivemindModule.community === communityId
);

setHivemindModule(gdriveHivemindModule);
setPlatforms(googleResults);
setIsActivePlatformLoading(false);
break;

case 2:
setIsActivePlatformLoading(true);
const { results: githubResults } = await retrievePlatforms({
name: 'github',
community: communityId,
});
Expand All @@ -138,28 +135,27 @@ function HivemindSettings() {
);

setHivemindModule(githubHivemindModule);
setPlatforms(githubResults);
setPlatforms(googleResults);
setIsActivePlatformLoading(false);
break;

case 3:
case 2:
setIsActivePlatformLoading(true);
const { results: notionResults } = await retrievePlatforms({
const { results: githubResults } = await retrievePlatforms({
name: 'notion',
community: communityId,
});

const notionHivemindModule = hivemindModules.results.find(
(hivemindModule: IModuleProps) =>
hivemindModule.community === communityId
);

setHivemindModule(notionHivemindModule);
setPlatforms(notionResults);
setPlatforms(githubResults);
setIsActivePlatformLoading(false);
break;

case 4:
case 3:
setIsActivePlatformLoading(true);
const { results: mediaWikiResults } = await retrievePlatforms({
name: 'mediaWiki',
Expand All @@ -174,6 +170,8 @@ function HivemindSettings() {
setHivemindModule(mediaWikiHivemindModule);
setPlatforms(mediaWikiResults);
setIsActivePlatformLoading(false);
break;

default:
break;
}
Expand Down Expand Up @@ -341,14 +339,14 @@ function HivemindSettings() {

return (
<>
<div className='bg-gray-100 py-4 px-5'>
<div className='bg-gray-100 px-5 py-4'>
<Tabs
orientation='horizontal'
variant='scrollable'
value={activePlatform}
onChange={(event, newValue) => setActivePlatform(newValue)}
>
{Object.keys(IntegrationPlatform).map((platform, index) => (
{PLATFORM_ORDER.map((platform, index) => (
<Tab
className={clsx(
'mr-3 min-h-[6rem] min-w-[10rem] rounded-sm shadow-lg',
Expand All @@ -365,7 +363,7 @@ function HivemindSettings() {
<div className='flex flex-col items-center space-x-2'>
<TcCommunityPlatformIcon platform={platform} />
<TcText text={platform} variant='body2' />
{platform === 'GDrive' && (
{platform === IntegrationPlatform.GDrive && (
<TcText
variant='caption'
className='text-gray-300'
Expand All @@ -382,7 +380,7 @@ function HivemindSettings() {
))}
</Tabs>
</div>
<div className='bg-gray-100 py-4 px-5'>
<div className='bg-gray-100 px-5 py-4'>
{platforms && platforms.length > 0 ? (
<Tabs
orientation='horizontal'
Expand Down Expand Up @@ -476,23 +474,6 @@ function HivemindSettings() {
)}
{activePlatform === 1 && (
<TabPanel value={activePlatform} index={1}>
{platforms && platforms.length > 0 && (
<TcHivemindGoogle
defaultGoogleHivemindConfig={
hivemindModule?.options?.platforms.find(
(platform) => platform.name === 'google'
)?.metadata || { driveIds: [], folderIds: [], fileIds: [] }
}
handlePatchHivemindGoogle={(payload) =>
handlePatchModule('google', payload)
}
isLoading={loading}
/>
)}
</TabPanel>
)}
{activePlatform === 2 && (
<TabPanel value={activePlatform} index={2}>
{platforms && platforms.length > 0 && (
<TcHivemindGithub
defaultGithubHivemindConfig={
Expand All @@ -508,8 +489,8 @@ function HivemindSettings() {
)}
</TabPanel>
)}
{activePlatform === 3 && (
<TabPanel value={activePlatform} index={3}>
{activePlatform === 2 && (
<TabPanel value={activePlatform} index={2}>
{platforms && platforms.length > 0 && (
<TcHivemindNotion
isLoading={loading}
Expand All @@ -525,8 +506,8 @@ function HivemindSettings() {
)}
</TabPanel>
)}
{activePlatform === 4 && (
<TabPanel value={activePlatform} index={4}>
{activePlatform === 3 && (
<TabPanel value={activePlatform} index={3}>
{platforms && platforms.length > 0 && (
<TcHivemindMediaWiki
isLoading={loading}
Expand All @@ -542,6 +523,23 @@ function HivemindSettings() {
)}
</TabPanel>
)}
{activePlatform === 4 && (
<TabPanel value={activePlatform} index={4}>
{platforms && platforms.length > 0 && (
<TcHivemindGoogle
defaultGoogleHivemindConfig={
hivemindModule?.options?.platforms.find(
(platform) => platform.name === 'google'
)?.metadata || { driveIds: [], folderIds: [], fileIds: [] }
}
handlePatchHivemindGoogle={(payload) =>
handlePatchModule('google', payload)
}
isLoading={loading}
/>
)}
</TabPanel>
)}
</Paper>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { FaGoogleDrive } from 'react-icons/fa';
import { FaWikipediaW } from 'react-icons/fa';
import { FaGoogle } from 'react-icons/fa';
import { FaTelegram, FaTwitter } from 'react-icons/fa6';
import { FaSquareXTwitter } from "react-icons/fa6";
import { RiNotionFill } from 'react-icons/ri';

interface TcCommunityPlatformIconProps {
Expand All @@ -24,6 +25,8 @@ function TcCommunityPlatformIcon({
return <FaDiscord size={size} />;
case 'Twitter':
return <FaTwitter size={size} />;
case 'X':
return <FaSquareXTwitter size={size} />;
case 'Discourse':
return <FaDiscourse size={size} />;
case 'Telegram':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ function TcCommunityPlatforms() {
const fetchPlatformsByType = async () => {
const platformNames = [
'discord',
'google',
'github',
'discourse',
'notion',
'mediaWiki',
'discourse',
'google',
];

const platformName = platformNames[activeTab];
Expand Down Expand Up @@ -180,7 +180,7 @@ function TcCommunityPlatforms() {
return (
<div>
<Paper className='rounded-none bg-gray-100 p-4 shadow-none'>
<div className='flex flex-col space-y-3 md:flex-row md:items-center md:space-y-0 md:space-x-3'>
<div className='flex flex-col space-y-3 md:flex-row md:items-center md:space-x-3 md:space-y-0'>
<TcText text='Platforms' variant='h6' fontWeight='bold' />
<TcText text='Add/remove platform integrations' variant='body1' />
</div>
Expand Down Expand Up @@ -246,7 +246,7 @@ function TcCommunityPlatforms() {
)}
{activeTab === 1 && (
<TabPanel value={activeTab} index={1}>
<TcGdriveIntegration
<TcGithubIntegration
isLoading={isLoading}
connectedPlatforms={platforms}
handleUpdateCommunityPlatform={handleUpdateCommunityPlatform}
Expand All @@ -255,7 +255,7 @@ function TcCommunityPlatforms() {
)}
{activeTab === 2 && (
<TabPanel value={activeTab} index={2}>
<TcGithubIntegration
<TcDiscourse
isLoading={isLoading}
connectedPlatforms={platforms}
handleUpdateCommunityPlatform={handleUpdateCommunityPlatform}
Expand All @@ -282,7 +282,7 @@ function TcCommunityPlatforms() {
)}
{activeTab === 5 && (
<TabPanel value={activeTab} index={5}>
<TcDiscourse
<TcGdriveIntegration
isLoading={isLoading}
connectedPlatforms={platforms}
handleUpdateCommunityPlatform={handleUpdateCommunityPlatform}
Expand All @@ -292,15 +292,15 @@ function TcCommunityPlatforms() {
</Box>
</Paper>
<div className='py-4'>
<div className='flex flex-col space-y-3 md:flex-row md:items-center md:space-y-0 md:space-x-3'>
<div className='flex flex-col space-y-3 md:flex-row md:items-center md:space-x-3 md:space-y-0'>
<TcText text='Modules' variant='h6' fontWeight='bold' />
<TcText
text='Turn on/off modules and change their settings'
variant='body1'
/>
</div>

<div className='flex flex-col space-y-4 md:flex-row md:space-y-0 md:space-x-4'>
<div className='flex flex-col space-y-4 md:flex-row md:space-x-4 md:space-y-0'>
<TcCard
className='max-h-[6rem] min-h-[6rem] min-w-[10rem] max-w-[10rem] flex-grow'
children={
Expand Down
21 changes: 0 additions & 21 deletions src/components/global/SafaryClubScript.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import 'react-toastify/dist/ReactToastify.css';
import { wagmiConfig } from '@/rainbowKitConfig';

import AmplitudeAnalytics from '../components/global/AmplitudeAnalytics';
import SafaryClubScript from '../components/global/SafaryClubScript';
import { conf } from '../configs';
import { ChannelProvider } from '../context/ChannelContext';
import { TokenProvider } from '../context/TokenContext';
Expand All @@ -56,7 +55,6 @@ export default function App({ Component, pageProps }: ComponentWithPageLayout) {
return (
<>
<AmplitudeAnalytics />
<SafaryClubScript />
<Script id='tawk' strategy='lazyOnload'>
{`
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
Expand Down
6 changes: 3 additions & 3 deletions src/utils/enums.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export enum IntegrationPlatform {
Discord = 'Discord',
GDrive = 'GDrive',
Github = 'Github',
Discourse = 'Discourse',
Notion = 'Notion',
MediaWiki = 'MediaWiki',
Discourse = 'Discourse',
Twitter = 'Twitter',
Telegram = 'Telegram',
X = 'X',
Snapshot = 'Snapshot',
GDrive = 'GDrive',
}

export enum StatusCode {
Expand Down

0 comments on commit c373e3c

Please sign in to comment.