From a7f359f5208d020ecc6e91c7da18d9b8b3523548 Mon Sep 17 00:00:00 2001 From: Yash Patel <109963122+PatelYash7@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:56:32 +0530 Subject: [PATCH 1/4] Fixes Lint Errors --- Frontend/.eslintrc.cjs | 1 + Frontend/src/Atoms/State.tsx | 4 +-- Frontend/src/Components/Dropdown.tsx | 9 +++-- Frontend/src/Components/StatusCardBox.tsx | 15 +++++++++ Frontend/src/Hooks/Login-hook.tsx | 9 ++--- Frontend/src/Hooks/User-data-hook.tsx | 12 ++++--- Frontend/src/Hooks/window-size.ts | 14 ++++---- Frontend/src/Interface/index.ts | 14 ++++---- Frontend/src/Pages/ChannelContent.tsx | 8 ++--- Frontend/src/Pages/Commands.tsx | 4 +-- Frontend/src/Pages/JoinRoles.tsx | 6 ++-- Frontend/src/Pages/LeaveMessage.tsx | 4 +-- Frontend/src/Pages/LevelSetup.tsx | 4 +-- Frontend/src/Pages/Login.tsx | 4 +-- Frontend/src/Pages/MainRoute.tsx | 7 ++-- Frontend/src/Pages/Notifications.tsx | 12 +++---- Frontend/src/Pages/ReactionRoles.tsx | 6 ++-- Frontend/src/Pages/ServerlistPage.tsx | 4 +-- Frontend/src/Pages/Status.tsx | 41 ++++++++--------------- Frontend/src/Pages/WelcomeMes.tsx | 4 +-- 20 files changed, 94 insertions(+), 88 deletions(-) create mode 100644 Frontend/src/Components/StatusCardBox.tsx diff --git a/Frontend/.eslintrc.cjs b/Frontend/.eslintrc.cjs index d6c9537..5ccfe1f 100644 --- a/Frontend/.eslintrc.cjs +++ b/Frontend/.eslintrc.cjs @@ -14,5 +14,6 @@ module.exports = { 'warn', { allowConstantExport: true }, ], + "react-hooks/rules-of-hooks": "off" }, } diff --git a/Frontend/src/Atoms/State.tsx b/Frontend/src/Atoms/State.tsx index 27c3c29..3138517 100644 --- a/Frontend/src/Atoms/State.tsx +++ b/Frontend/src/Atoms/State.tsx @@ -1,7 +1,7 @@ import { atom} from "recoil"; import { ChannelListArray, Guild, Roles, ServerList,ServerWithPresenceObject, User, userData} from "../Interface"; -export const toggleState = atom({ +export const ToggleState = atom({ key: "toggleState", default: false, }) @@ -21,7 +21,7 @@ export const UserData =atom({ guilds:[] as Guild[] } }) -export const loading = atom({ +export const Loading = atom({ key:"loading", default:true }) diff --git a/Frontend/src/Components/Dropdown.tsx b/Frontend/src/Components/Dropdown.tsx index 82f12b6..f41b423 100644 --- a/Frontend/src/Components/Dropdown.tsx +++ b/Frontend/src/Components/Dropdown.tsx @@ -1,15 +1,14 @@ -import { setLogout } from "../Hooks/Login-hook"; +import { useSetLogout } from "../Hooks/Login-hook"; import Logout from "../Resources/images/Logout.png" function Dropdown():JSX.Element { // const navigate = useNavigate(); return (
-
{ - - await setLogout() - }} className="flex items-center justify-around gap-3 px-2 py-1 rounded hover:bg-hoverbg hover:transition"> +
Logout
diff --git a/Frontend/src/Components/StatusCardBox.tsx b/Frontend/src/Components/StatusCardBox.tsx new file mode 100644 index 0000000..7a51036 --- /dev/null +++ b/Frontend/src/Components/StatusCardBox.tsx @@ -0,0 +1,15 @@ +import { Switch } from "@mui/material" +import { Button } from "./Button" + +export const StatusCardBox = ({heading,route,handleChange,value}:{heading:string,route:string,handleChange:()=>void,value:boolean})=>{ + return
+
{heading}
+
+
Set Status of {heading}
+
+ +
+
+
+ } \ No newline at end of file diff --git a/Frontend/src/Hooks/Login-hook.tsx b/Frontend/src/Hooks/Login-hook.tsx index 64dba8b..092f5e3 100644 --- a/Frontend/src/Hooks/Login-hook.tsx +++ b/Frontend/src/Hooks/Login-hook.tsx @@ -1,19 +1,19 @@ import { useEffect, useRef, useState} from "react"; import axios from "axios"; -export const setLogin = ({ code }: { code: string }) => { +export const useSetLogin = ({ code }: { code: string }) => { window.localStorage.setItem("code", code); window.location.assign('/') }; -export const setLogout = async () => { +export const useSetLogout = async () => { await window.localStorage.removeItem("code"); await window.localStorage.removeItem("id"); await window.localStorage.removeItem("guild_id"); window.location.replace(import.meta.env.VITE_LOGOUT_URI) }; -export const getData = () => { +export const useGetData = () => { const code = window.localStorage.getItem("code"); const id = window.localStorage.getItem("id"); const [idData,setidData]=useState(); @@ -33,6 +33,7 @@ export const getData = () => { return () => { effectRan.current = true; }; - }, []); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [id]); return idData; }; diff --git a/Frontend/src/Hooks/User-data-hook.tsx b/Frontend/src/Hooks/User-data-hook.tsx index 4964bf9..231d8b6 100644 --- a/Frontend/src/Hooks/User-data-hook.tsx +++ b/Frontend/src/Hooks/User-data-hook.tsx @@ -1,14 +1,14 @@ import axios from "axios"; import { useEffect, useRef, useState } from "react"; import { useRecoilValue, useSetRecoilState } from "recoil"; -import {AllServer, UserData, loading } from "../Atoms/State"; +import {AllServer, UserData, Loading } from "../Atoms/State"; import { ServerWithPresence } from "../Interface"; export const useUserData = () => { const id = window.localStorage.getItem("id"); const setUser = useSetRecoilState(UserData); const setTotalServer = useSetRecoilState(AllServer) - const setLoader = useSetRecoilState(loading); + const setLoader = useSetRecoilState(Loading); const effectRan = useRef(false); useEffect(() => { if (effectRan.current === false && id) { @@ -28,7 +28,8 @@ export const useUserData = () => { return () => { effectRan.current = true; }; - }, []); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [id]); }; export const useGetserverdata = () => { const { guilds } = useRecoilValue(UserData); @@ -48,9 +49,10 @@ export const useGetserverdata = () => { }); setUserServerWithPresence(userServerWithPresence1); setLoading(false); - }else { - + }else{ + setLoading(true) } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [guilds]); if (loading) { return { userServerWithPresence: [] }; // or return a loading state diff --git a/Frontend/src/Hooks/window-size.ts b/Frontend/src/Hooks/window-size.ts index 2f18f83..5992385 100644 --- a/Frontend/src/Hooks/window-size.ts +++ b/Frontend/src/Hooks/window-size.ts @@ -12,15 +12,15 @@ export const useWindowSize = () => { useEffect(() => { // only execute all the code below in client side + function handleResize() { + // Set window width/height to state + setWindowSize({ + width: window.innerWidth, + height: window.innerHeight + }); + } if (typeof window !== "undefined") { // Handler to call on window resize - function handleResize() { - // Set window width/height to state - setWindowSize({ - width: window.innerWidth, - height: window.innerHeight - }); - } // Add event listener window.addEventListener("resize", handleResize); diff --git a/Frontend/src/Interface/index.ts b/Frontend/src/Interface/index.ts index c497ccd..3bd6966 100644 --- a/Frontend/src/Interface/index.ts +++ b/Frontend/src/Interface/index.ts @@ -9,11 +9,11 @@ export interface userData { discriminator: string; public_flags: number; flags: number; - banner: any; - accent_color: any; + banner: string | null; + accent_color: number | null; global_name: string; - avatar_decoration_data: any; - banner_color: any; + avatar_decoration_data: null; + banner_color: string | null; mfa_enabled: boolean; locale: string; premium_type: number; @@ -26,7 +26,7 @@ export interface userData { owner: boolean; permissions: number; permissions_new: string; - features: any[]; + features: string[]; } export interface ServerList { @@ -37,7 +37,7 @@ export interface userData { export interface ServerWithPresenceObject { - features?: any[] + features?: string[] id?: string, owner?: boolean, permissions_new?: string, @@ -63,7 +63,7 @@ export interface Server { owner: boolean; permissions: number; permissions_new: string; - features: any[]; + features: string[]; } export interface ServerWithPresence extends Server { diff --git a/Frontend/src/Pages/ChannelContent.tsx b/Frontend/src/Pages/ChannelContent.tsx index 3200a3c..e70780c 100644 --- a/Frontend/src/Pages/ChannelContent.tsx +++ b/Frontend/src/Pages/ChannelContent.tsx @@ -10,7 +10,7 @@ export default function Messages(): JSX.Element { const handleChange = (e: React.ChangeEvent) => { SetChannel(e.target.value); }; - const handleSubmitImage = async () => { + const useHandleSubmitImage = async () => { if(channel){ const Response = await useSetImageChannel({channel_id:channel}); // log(Response) @@ -20,7 +20,7 @@ export default function Messages(): JSX.Element { const handleChangeLink= (e:React.ChangeEvent)=>{ SetChannel_link(e.target.value) } - const handleSubmitLink = async ()=>{ + const useHandleSubmitLink = async ()=>{ if(channel_Link){ const Response = await useSetLinkChannel({channel_id:channel_Link}) alert(Response.message) @@ -42,7 +42,7 @@ export default function Messages(): JSX.Element {
- +
@@ -58,7 +58,7 @@ export default function Messages(): JSX.Element {
- +
diff --git a/Frontend/src/Pages/Commands.tsx b/Frontend/src/Pages/Commands.tsx index 7695448..ca5498c 100644 --- a/Frontend/src/Pages/Commands.tsx +++ b/Frontend/src/Pages/Commands.tsx @@ -9,7 +9,7 @@ function Commands(): JSX.Element { const handleChange = (e: React.ChangeEvent) => { Setprefix(e.target.value); }; - const handleSubmit = async () => { + const useHandleSubmit = async () => { if (prefix) { const Response = await useSetPrefix({ new_prefix: prefix }); alert(Response); @@ -39,7 +39,7 @@ function Commands(): JSX.Element { >
- +
diff --git a/Frontend/src/Pages/JoinRoles.tsx b/Frontend/src/Pages/JoinRoles.tsx index 4a9a2fa..5fd04c6 100644 --- a/Frontend/src/Pages/JoinRoles.tsx +++ b/Frontend/src/Pages/JoinRoles.tsx @@ -18,10 +18,10 @@ function JoinRoles(): JSX.Element { const handleChangeChannel = (e:React.ChangeEvent) => { setChannelid(e.target.value); }; - const handleSubmit = async ()=>{ + const useHandleSubmit = async ()=>{ if(roleId && channelid){ const response = await useSetJoinMemberRole({channel_id:channelid,role_id:roleId}) - alert(response.message); + alert(response.role_name + ' is Set'); } } return ( @@ -42,7 +42,7 @@ function JoinRoles(): JSX.Element { - + diff --git a/Frontend/src/Pages/LeaveMessage.tsx b/Frontend/src/Pages/LeaveMessage.tsx index bb01f14..6f24dc8 100644 --- a/Frontend/src/Pages/LeaveMessage.tsx +++ b/Frontend/src/Pages/LeaveMessage.tsx @@ -13,7 +13,7 @@ function LeaveMessage(): JSX.Element { const [value, setValue] = useState(); const ChannelArrays = useRecoilValue(ChannelArray); - const handleSubmit = async () => { + const useHandleSubmit = async () => { if (value) { const response = await useSetLeaveMessage({message}); const responseChannel= await useSelectLeaveChannel({guild_id:window.localStorage.getItem('guild_id') as string, channel_id:value as string}) @@ -57,7 +57,7 @@ function LeaveMessage(): JSX.Element {
- +
); diff --git a/Frontend/src/Pages/LevelSetup.tsx b/Frontend/src/Pages/LevelSetup.tsx index 2bf4d6f..2f6027a 100644 --- a/Frontend/src/Pages/LevelSetup.tsx +++ b/Frontend/src/Pages/LevelSetup.tsx @@ -32,7 +32,7 @@ function LevelingUp() { const handleLevelInput = (e:React.ChangeEvent) => { setLevel(e.target.value); } - const handleSubmit = async ()=>{ + const useHandleSubmit = async ()=>{ if(value && level){ const response = await useSetLevelRole({role_id:value,level:level}); await alert(response.message); @@ -57,7 +57,7 @@ function LevelingUp() { - + ); } diff --git a/Frontend/src/Pages/Login.tsx b/Frontend/src/Pages/Login.tsx index 433455b..d8e3820 100644 --- a/Frontend/src/Pages/Login.tsx +++ b/Frontend/src/Pages/Login.tsx @@ -1,5 +1,5 @@ import {Navigate, Outlet, useLocation, useSearchParams } from "react-router-dom"; -import { setLogin } from "../Hooks/Login-hook"; +import {useSetLogin } from "../Hooks/Login-hook"; import { LandingNavbar } from "./Landing page/components/LandingNavbar"; import { Footer } from "./Landing page/components/Footer"; import { useWindowSize } from "../Hooks/window-size"; @@ -9,7 +9,7 @@ import { DimensionIssue } from "../Components/DimensionIssue"; function Login() { const code = useSearchParams()[0].get("code"); if (code) { - setLogin({ code }); + useSetLogin({ code }); } const dimension = useWindowSize(); const {pathname} = useLocation() diff --git a/Frontend/src/Pages/MainRoute.tsx b/Frontend/src/Pages/MainRoute.tsx index a07f732..8f9cd1e 100644 --- a/Frontend/src/Pages/MainRoute.tsx +++ b/Frontend/src/Pages/MainRoute.tsx @@ -18,7 +18,7 @@ export const MainRoute=()=>{ useEffect(()=>{ if(!EffectRan.current && guild!=null){ - const fetchData = async ()=>{ + const useFetchData = async ()=>{ const Data = await axios.get( `${import.meta.env.VITE_IP}available_users?user_id=${id}` ); @@ -28,11 +28,12 @@ export const MainRoute=()=>{ setRole(RoleArray) setChannels(ChannelArray); } - fetchData() + useFetchData() return ()=>{ EffectRan.current=true; } } - },[]) + // eslint-disable-next-line react-hooks/exhaustive-deps + },[id]) return guild?: } \ No newline at end of file diff --git a/Frontend/src/Pages/Notifications.tsx b/Frontend/src/Pages/Notifications.tsx index 1f5b3d5..138ba95 100644 --- a/Frontend/src/Pages/Notifications.tsx +++ b/Frontend/src/Pages/Notifications.tsx @@ -29,12 +29,12 @@ const SubscribedChannelList = ()=>{ const EffectRan= useRef(false) useEffect(()=>{ if(EffectRan.current===false){ - const fetchData = async()=>{ + const useFetchData = async()=>{ const response = await useGetYoutubeChannel(); setChannels(response) EffectRan.current=true } - fetchData(); + useFetchData(); } return ()=>{ EffectRan.current=true @@ -53,7 +53,7 @@ const SubscribedChannelList = ()=>{ } const RemoveChannel = ()=>{ const [channel, SetChannel] = useState(""); - const handleSubmit = async () => { + const useHandleSubmit = async () => { if(channel){ const response = await useRemoveChannel({channel}); alert(response.message); @@ -86,7 +86,7 @@ const RemoveChannel = ()=>{ @@ -100,7 +100,7 @@ export function NotificationPopUp(): JSX.Element { const [value, setValue] = useState(); const guild_id = window.localStorage.getItem("guild_id") as string; - const handleSubmit = async () => { + const useHandleSubmit = async () => { if(value){ const response = await useYtChannelSet({guild_id,channel_id:value as string}); const ChannelSetResponse = await useSetYoutubeCreatorChannel({guild_id,yt_Channel_name:channel}); @@ -143,7 +143,7 @@ export function NotificationPopUp(): JSX.Element { diff --git a/Frontend/src/Pages/ReactionRoles.tsx b/Frontend/src/Pages/ReactionRoles.tsx index 023d0d8..d1af3e3 100644 --- a/Frontend/src/Pages/ReactionRoles.tsx +++ b/Frontend/src/Pages/ReactionRoles.tsx @@ -18,10 +18,10 @@ function ReactionRoles():JSX.Element { const handleChangeChannel = (e:React.ChangeEvent) => { setChannelid(e.target.value); }; - const handleSubmit = async ()=>{ + const useHandleSubmit = async ()=>{ if(roleId && channelid){ const response = await useSetJoinMemberRole({channel_id:channelid,role_id:roleId}) - alert(response.message); + alert(response.role_name + ' is Set'); } } return ( @@ -42,7 +42,7 @@ function ReactionRoles():JSX.Element { - + diff --git a/Frontend/src/Pages/ServerlistPage.tsx b/Frontend/src/Pages/ServerlistPage.tsx index 3164d6d..af6ecd0 100644 --- a/Frontend/src/Pages/ServerlistPage.tsx +++ b/Frontend/src/Pages/ServerlistPage.tsx @@ -1,9 +1,9 @@ import Navbar from "../Components/Navbar"; import { ServerlistComponent } from "../Components/ServerlistComponent"; -import { getData } from "../Hooks/Login-hook"; +import {useGetData } from "../Hooks/Login-hook"; export const ServerlistPage = () => { - const id = getData(); + const id = useGetData() const flag = window.localStorage.getItem("id"); return (
diff --git a/Frontend/src/Pages/Status.tsx b/Frontend/src/Pages/Status.tsx index 02043b5..96545d7 100644 --- a/Frontend/src/Pages/Status.tsx +++ b/Frontend/src/Pages/Status.tsx @@ -1,8 +1,7 @@ -import { Switch } from "@mui/material"; import Heading from "../Components/Heading"; -import { Button } from "../Components/Button"; import { useState } from "react"; import { useChangeStatusImageChannel, useChangeStatusLevelSystem, useChangeStatusLinkChannel, useChangeStatusMessage, useChangeStatusSocialNotification, useChangeStatusleaveMessage } from "../Hooks/Status-hook"; +import { StatusCardBox } from "../Components/StatusCardBox"; function Settings_general(): JSX.Element { const [welcome,setWelcome] = useState(false); @@ -12,27 +11,27 @@ function Settings_general(): JSX.Element { const [image,setImage] = useState(false) const [Link,setLink] = useState(false) - const handleChangeWelcomeMessage = async ()=>{ + const useHandleChangeWelcomeMessage = async ()=>{ await setWelcome(!welcome); await useChangeStatusMessage({bool:!welcome}) } - const handleChangeLeaveMessage = async ()=>{ + const useHandleChangeLeaveMessage = async ()=>{ await setLeave(!leave) await useChangeStatusleaveMessage({bool:!leave}) } - const handleChangeLevelSystem = async ()=>{ + const useHandleChangeLevelSystem = async ()=>{ await setLevel(!level) await useChangeStatusLevelSystem({bool:!level}) } - const handleChangeNotificationSetup= async()=>{ + const useHandleChangeNotificationSetup= async()=>{ await setnotification(!notification) await useChangeStatusSocialNotification({bool:!notification}) } - const handleChangeImageStatus=async()=>{ + const useHandleChangeImageStatus=async()=>{ await setImage(!image) await useChangeStatusImageChannel({bool:!image}) } - const handleChangeLinkStatus=async()=>{ + const useHandleChangeLinkStatus=async()=>{ await setLink(!Link) await useChangeStatusLinkChannel({bool:!Link}) } @@ -41,29 +40,17 @@ function Settings_general(): JSX.Element {
- - - - - - + + + + + +
-
); } -const CardBox = ({heading,route,handleChange,value}:{heading:string,route:string,handleChange:()=>void,value:boolean})=>{ - return
-
{heading}
-
-
Set Status of {heading}
-
- -
-
-
-} + export default Settings_general; diff --git a/Frontend/src/Pages/WelcomeMes.tsx b/Frontend/src/Pages/WelcomeMes.tsx index 7d10ee9..b656238 100644 --- a/Frontend/src/Pages/WelcomeMes.tsx +++ b/Frontend/src/Pages/WelcomeMes.tsx @@ -13,7 +13,7 @@ function WelcomeMes(): JSX.Element { const [value, setValue] = useState(); const ChannelArrays = useRecoilValue(ChannelArray); - const handleSubmit = async () => { + const useHandleSubmit = async () => { if (value) { const response = await useSetWelcomeMessage({message}); const responseChannel= await useSelectChannel({guild_id:window.localStorage.getItem('guild_id') as string, channel_id:value as string}) @@ -57,7 +57,7 @@ function WelcomeMes(): JSX.Element {
- +
); From ef05af3f7dcc0219a50eb777f3e2c6f311635abb Mon Sep 17 00:00:00 2001 From: Yash Patel <109963122+PatelYash7@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:57:01 +0530 Subject: [PATCH 2/4] Added Catch in Serverlist component --- Frontend/src/Components/ServerlistComponent.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Frontend/src/Components/ServerlistComponent.tsx b/Frontend/src/Components/ServerlistComponent.tsx index 68131f0..af639d5 100644 --- a/Frontend/src/Components/ServerlistComponent.tsx +++ b/Frontend/src/Components/ServerlistComponent.tsx @@ -5,6 +5,7 @@ import { useNavigate } from "react-router-dom"; export const ServerlistComponent = () => { const {userServerWithPresence}=useGetserverdata(); + console.log(userServerWithPresence) return (
@@ -14,9 +15,15 @@ export const ServerlistComponent = () => {
- {userServerWithPresence.map((server:any) => ( - - ))} + { + userServerWithPresence ? + userServerWithPresence.map((server) => ( + + )): +
+ You don't have admin Access in Any server +
+ }
From 7d2eea5adc3a429a99c73d8460dc57fe7e3da0d2 Mon Sep 17 00:00:00 2001 From: Yash Patel <109963122+PatelYash7@users.noreply.github.com> Date: Mon, 24 Jun 2024 12:25:10 +0530 Subject: [PATCH 3/4] Added code formating --- Frontend/.prettierignore | 16 ++ Frontend/.prettierrc | 9 ++ Frontend/README.md | 8 +- Frontend/package-lock.json | 16 ++ Frontend/package.json | 5 +- Frontend/src/Atoms/State.tsx | 82 +++++----- Frontend/src/Components/Button.tsx | 46 +++--- Frontend/src/Components/Card.tsx | 46 +++--- Frontend/src/Components/CardBox.tsx | 89 ++++++----- Frontend/src/Components/Dropdown.tsx | 18 ++- Frontend/src/Components/Heading.tsx | 16 +- Frontend/src/Components/HomeHeading.tsx | 1 - Frontend/src/Components/InputBox.tsx | 10 +- Frontend/src/Components/MenuDropdown.tsx | 67 ++++---- Frontend/src/Components/MessageType.tsx | 32 ++-- Frontend/src/Components/Midheading.tsx | 16 +- Frontend/src/Components/Navbar.tsx | 25 ++- Frontend/src/Components/ProfileBox.tsx | 15 +- Frontend/src/Components/SectionComponent.tsx | 30 ++-- .../src/Components/ServerlistComponent.tsx | 66 +++++--- Frontend/src/Components/Sidebar.tsx | 2 +- Frontend/src/Components/SidebarHeader.tsx | 11 +- Frontend/src/Components/SidebarSecondHalf.tsx | 28 ++-- Frontend/src/Components/StatusCardBox.tsx | 30 +++- Frontend/src/Components/Subsidebar.tsx | 13 +- Frontend/src/Components/SubsidebarModule.tsx | 20 +-- Frontend/src/Components/Userprofile.tsx | 48 ++++-- Frontend/src/Hooks/Channel-content-hook.ts | 30 ++-- Frontend/src/Hooks/Channel-hook.tsx | 11 +- Frontend/src/Hooks/Command-hook.ts | 12 +- Frontend/src/Hooks/Levelrole-hook.ts | 14 +- Frontend/src/Hooks/Login-hook.tsx | 24 +-- Frontend/src/Hooks/Message-Hook.ts | 58 ++++--- Frontend/src/Hooks/Roles-hook.ts | 35 +++-- Frontend/src/Hooks/Status-hook.ts | 82 +++++++--- Frontend/src/Hooks/User-data-hook.tsx | 46 +++--- Frontend/src/Hooks/Youtube-Notification.ts | 54 +++++-- Frontend/src/Hooks/window-size.ts | 58 +++---- Frontend/src/Interface/index.ts | 91 ++++++----- Frontend/src/Pages/AutoModeration.tsx | 6 +- Frontend/src/Pages/Branding.tsx | 6 +- Frontend/src/Pages/ChannelContent.tsx | 27 ++-- Frontend/src/Pages/Commands.tsx | 1 - Frontend/src/Pages/ErrorRouter.tsx | 7 +- Frontend/src/Pages/Home.tsx | 8 +- Frontend/src/Pages/HomeMain.tsx | 4 +- Frontend/src/Pages/JoinRoles.tsx | 57 ++++--- Frontend/src/Pages/Landing page/AboutPage.tsx | 24 +-- .../src/Pages/Landing page/ContactPage.tsx | 21 +-- .../Landing page/components/Features.tsx | 67 ++++---- .../Pages/Landing page/components/Footer.tsx | 42 ++++- .../Landing page/components/Hero-About.tsx | 37 +++-- .../Landing page/components/Hero-Contact.tsx | 33 ++-- .../Landing page/components/Herosection.tsx | 23 +-- .../Landing page/components/LandingNavbar.tsx | 54 +++++-- .../Pages/Landing page/components/Story.tsx | 35 +++-- .../Pages/Landing page/components/Vision.tsx | 38 +++-- .../Landing page/components/Whoarewe.tsx | 35 +++-- .../src/Pages/Landing page/home/Homepage.tsx | 16 +- Frontend/src/Pages/LeaveMessage.tsx | 37 +++-- Frontend/src/Pages/LevelSetup.tsx | 38 +++-- Frontend/src/Pages/Logging.tsx | 9 +- Frontend/src/Pages/Login.tsx | 34 ++-- Frontend/src/Pages/MainRoute.tsx | 60 +++---- Frontend/src/Pages/Moderation.tsx | 75 +++++---- Frontend/src/Pages/Notifications.tsx | 96 +++++++----- Frontend/src/Pages/ProtectedRoute.tsx | 7 +- Frontend/src/Pages/ReactionRoles.tsx | 86 ++++++---- Frontend/src/Pages/ServerlistPage.tsx | 7 +- Frontend/src/Pages/Status.tsx | 111 ++++++++----- Frontend/src/Pages/WelcomeMes.tsx | 32 ++-- Frontend/src/Resources/Data.tsx | 147 +++++++++--------- Frontend/src/Resources/Svg/SVG.tsx | 28 ++-- Frontend/src/main.tsx | 30 ++-- Frontend/vite.config.ts | 6 +- 75 files changed, 1530 insertions(+), 1094 deletions(-) create mode 100644 Frontend/.prettierignore create mode 100644 Frontend/.prettierrc diff --git a/Frontend/.prettierignore b/Frontend/.prettierignore new file mode 100644 index 0000000..dac561e --- /dev/null +++ b/Frontend/.prettierignore @@ -0,0 +1,16 @@ +dist +node_modules +.env +tailwind.config.js + +# Ignore artifacts: +build +coverage + +# Ignore all HTML files: +**/*.html + +vite-env.d.ts +vite.config.ts + +**.md \ No newline at end of file diff --git a/Frontend/.prettierrc b/Frontend/.prettierrc new file mode 100644 index 0000000..9d8de21 --- /dev/null +++ b/Frontend/.prettierrc @@ -0,0 +1,9 @@ +{ + "tabWidth": 2, + "semi": true, + "singleQuote": false, + "trailingComma": "all", + "printWidth": 80, + "useTabs": false, + "endOfLine":"auto" +} \ No newline at end of file diff --git a/Frontend/README.md b/Frontend/README.md index 0d6babe..bb15685 100644 --- a/Frontend/README.md +++ b/Frontend/README.md @@ -17,12 +17,12 @@ If you are developing a production application, we recommend updating the config export default { // other rules... parserOptions: { - ecmaVersion: 'latest', - sourceType: 'module', - project: ['./tsconfig.json', './tsconfig.node.json'], + ecmaVersion: "latest", + sourceType: "module", + project: ["./tsconfig.json", "./tsconfig.node.json"], tsconfigRootDir: __dirname, }, -} +}; ``` - Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` diff --git a/Frontend/package-lock.json b/Frontend/package-lock.json index b1f9b28..b08c431 100644 --- a/Frontend/package-lock.json +++ b/Frontend/package-lock.json @@ -30,6 +30,7 @@ "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.5", "postcss": "^8.4.35", + "prettier": "3.3.2", "tailwindcss": "^3.4.1", "typescript": "^5.2.2", "vite": "^5.1.0" @@ -10157,6 +10158,21 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", + "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-format": { "version": "26.6.2", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-26.6.2.tgz", diff --git a/Frontend/package.json b/Frontend/package.json index eff86d6..40d6c32 100644 --- a/Frontend/package.json +++ b/Frontend/package.json @@ -7,7 +7,9 @@ "dev": "vite --port 3000", "build": "tsc && vite build", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", - "preview": "vite preview " + "preview": "vite preview ", + "format": "prettier --write \"**/*.{ts,tsx,md}\"", + "checks":"npm run lint && npm run format" }, "dependencies": { "@emotion/react": "^11.11.3", @@ -33,6 +35,7 @@ "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.5", "postcss": "^8.4.35", + "prettier": "3.3.2", "tailwindcss": "^3.4.1", "typescript": "^5.2.2", "vite": "^5.1.0" diff --git a/Frontend/src/Atoms/State.tsx b/Frontend/src/Atoms/State.tsx index 3138517..a4ab1b1 100644 --- a/Frontend/src/Atoms/State.tsx +++ b/Frontend/src/Atoms/State.tsx @@ -1,49 +1,57 @@ -import { atom} from "recoil"; -import { ChannelListArray, Guild, Roles, ServerList,ServerWithPresenceObject, User, userData} from "../Interface"; +import { atom } from "recoil"; +import { + ChannelListArray, + Guild, + Roles, + ServerList, + ServerWithPresenceObject, + User, + userData, +} from "../Interface"; export const ToggleState = atom({ - key: "toggleState", - default: false, -}) + key: "toggleState", + default: false, +}); export const ModerationPath = atom({ - key:"ModerationPath", - default:" " -}) + key: "ModerationPath", + default: " ", +}); export const NotifPopup = atom({ - key:"NotifPopup", - default:false -}) + key: "NotifPopup", + default: false, +}); -export const UserData =atom({ - key:"UserData", - default:{ - user:{} as User, - guilds:[] as Guild[] - } -}) +export const UserData = atom({ + key: "UserData", + default: { + user: {} as User, + guilds: [] as Guild[], + }, +}); export const Loading = atom({ - key:"loading", - default:true -}) + key: "loading", + default: true, +}); export const ChannelId = atom({ - key:"ChannelIt", - default:"" -}) + key: "ChannelIt", + default: "", +}); export const ChannelArray = atom({ - key:"ChannelArrayInterface", - default: [] as ChannelListArray[] -}) + key: "ChannelArrayInterface", + default: [] as ChannelListArray[], +}); export const RoleArray = atom({ - key:'roles', - default:[] as Roles[] -}) + key: "roles", + default: [] as Roles[], +}); export const AllServer = atom({ - key:"Server List", - default:[] as ServerList[] -}) -export const ServerWithPresenceArray=atom({ - key:"Server with Presence", - default:[] as ServerWithPresenceObject[] -}) \ No newline at end of file + key: "Server List", + default: [] as ServerList[], +}); +export const ServerWithPresenceArray = atom({ + key: "Server with Presence", + default: [] as ServerWithPresenceObject[], +}); diff --git a/Frontend/src/Components/Button.tsx b/Frontend/src/Components/Button.tsx index 992cfa9..bab7d48 100644 --- a/Frontend/src/Components/Button.tsx +++ b/Frontend/src/Components/Button.tsx @@ -1,29 +1,37 @@ import { Link } from "react-router-dom"; -interface Props{ - text:string; - route:string; - setRed?:boolean +interface Props { + text: string; + route: string; + setRed?: boolean; } -export const Button=(props:Props)=> { - const{route,text,setRed}=props +export const Button = (props: Props) => { + const { route, text, setRed } = props; return ( -
- { - setRed?: - } + ) : ( + + )}
- ) -} -export const SubmitButton = ({handleSubmit,text}:{handleSubmit: () => void; text:string}) => { + ); +}; +export const SubmitButton = ({ + handleSubmit, + text, +}: { + handleSubmit: () => void; + text: string; +}) => { return ( ); -}; \ No newline at end of file +}; diff --git a/Frontend/src/Components/Card.tsx b/Frontend/src/Components/Card.tsx index 71b0326..59fe322 100644 --- a/Frontend/src/Components/Card.tsx +++ b/Frontend/src/Components/Card.tsx @@ -1,35 +1,29 @@ -import {Button }from "./Button"; +import { Button } from "./Button"; interface Props { - img:string; - heading:string; - description:string; - buttonDesc:string; - route:string - + img: string; + heading: string; + description: string; + buttonDesc: string; + route: string; } -function Card(props:Props):JSX.Element { - const {img,heading,description,buttonDesc,route}= props +function Card(props: Props): JSX.Element { + const { img, heading, description, buttonDesc, route } = props; return (
-
- Icon -
-
- {heading} -
-
- {description} -
-
-
+
+ Icon +
+
{heading}
+
+ {description} +
+
+
- ) + ); } -export default Card \ No newline at end of file +export default Card; diff --git a/Frontend/src/Components/CardBox.tsx b/Frontend/src/Components/CardBox.tsx index b401c50..628f2b4 100644 --- a/Frontend/src/Components/CardBox.tsx +++ b/Frontend/src/Components/CardBox.tsx @@ -4,49 +4,52 @@ import MessageIcon from "../Resources/images/ChatIcon.png"; function CardBox(): JSX.Element { return (
- - - - - - + + + + + +
); } diff --git a/Frontend/src/Components/Dropdown.tsx b/Frontend/src/Components/Dropdown.tsx index f41b423..bd47da7 100644 --- a/Frontend/src/Components/Dropdown.tsx +++ b/Frontend/src/Components/Dropdown.tsx @@ -1,16 +1,18 @@ - import { useSetLogout } from "../Hooks/Login-hook"; -import Logout from "../Resources/images/Logout.png" +import Logout from "../Resources/images/Logout.png"; -function Dropdown():JSX.Element { +function Dropdown(): JSX.Element { // const navigate = useNavigate(); return (
-
- -
Logout
+
+ +
+ Logout +
); diff --git a/Frontend/src/Components/Heading.tsx b/Frontend/src/Components/Heading.tsx index 7bf80c9..9539782 100644 --- a/Frontend/src/Components/Heading.tsx +++ b/Frontend/src/Components/Heading.tsx @@ -1,16 +1,14 @@ -interface Props{ - head:string +interface Props { + head: string; } -function Heading(props:Props) { - const{head}=props +function Heading(props: Props) { + const { head } = props; return (
-
- {head} -
+
{head}
- ) + ); } -export default Heading \ No newline at end of file +export default Heading; diff --git a/Frontend/src/Components/HomeHeading.tsx b/Frontend/src/Components/HomeHeading.tsx index 18d6c76..eff2e8f 100644 --- a/Frontend/src/Components/HomeHeading.tsx +++ b/Frontend/src/Components/HomeHeading.tsx @@ -4,7 +4,6 @@ interface Props { function HomeHeading(props: Props): JSX.Element { const { name } = props; - return (
diff --git a/Frontend/src/Components/InputBox.tsx b/Frontend/src/Components/InputBox.tsx index 4b178d0..40a068a 100644 --- a/Frontend/src/Components/InputBox.tsx +++ b/Frontend/src/Components/InputBox.tsx @@ -1,10 +1,10 @@ -interface Props{ - type:string; - placeholder:string +interface Props { + type: string; + placeholder: string; } -function InputBox(props:Props) { - const{type,placeholder}=props +function InputBox(props: Props) { + const { type, placeholder } = props; return (
) => void,value:string|unknown,roles?:Roles[]}) => { +export const MenuDropdown = ({ + handleChange, + value, + roles, +}: { + handleChange: (e: React.ChangeEvent) => void; + value: string | unknown; + roles?: Roles[]; +}) => { const ChannelArrays = useRecoilValue(ChannelArray); return ( - - - + ); }; diff --git a/Frontend/src/Components/MessageType.tsx b/Frontend/src/Components/MessageType.tsx index c231fac..fe61650 100644 --- a/Frontend/src/Components/MessageType.tsx +++ b/Frontend/src/Components/MessageType.tsx @@ -1,23 +1,23 @@ -import Typesection from "./Typesection" +import Typesection from "./Typesection"; function MessageType() { return (
- - - - - - - - - - - - - + + + + + + + + + + + + +
- ) + ); } -export default MessageType \ No newline at end of file +export default MessageType; diff --git a/Frontend/src/Components/Midheading.tsx b/Frontend/src/Components/Midheading.tsx index be4d8f2..82adaf8 100644 --- a/Frontend/src/Components/Midheading.tsx +++ b/Frontend/src/Components/Midheading.tsx @@ -1,14 +1,10 @@ -interface Props{ - head:string +interface Props { + head: string; } -function Midheading(props:Props) :JSX.Element { - const head = props.head; - return ( -
- {head} -
- ) +function Midheading(props: Props): JSX.Element { + const head = props.head; + return
{head}
; } -export default Midheading \ No newline at end of file +export default Midheading; diff --git a/Frontend/src/Components/Navbar.tsx b/Frontend/src/Components/Navbar.tsx index 47371a5..4abcdef 100644 --- a/Frontend/src/Components/Navbar.tsx +++ b/Frontend/src/Components/Navbar.tsx @@ -1,24 +1,23 @@ import { useRecoilValue } from "recoil"; -import image from "../Resources/images/TechTOnions Logo Compact 13.png" +import image from "../Resources/images/TechTOnions Logo Compact 13.png"; import Userprofile from "./Userprofile"; import { UserData } from "../Atoms/State"; function Navbar(): JSX.Element { - - const {user} = useRecoilValue(UserData); + const { user } = useRecoilValue(UserData); return ( -
-
- {/* Logo and Name */} -
- -

TechTOnion

-
-
-
- +
+
+ {/* Logo and Name */} +
+ +

TechTOnion

+
+ +
+
); } diff --git a/Frontend/src/Components/ProfileBox.tsx b/Frontend/src/Components/ProfileBox.tsx index 37a4326..ace7afc 100644 --- a/Frontend/src/Components/ProfileBox.tsx +++ b/Frontend/src/Components/ProfileBox.tsx @@ -1,5 +1,3 @@ - - interface Props { name: string; img: string; @@ -7,8 +5,11 @@ interface Props { function ProfileBox(props: Props): JSX.Element { const { name, img } = props; return ( - -
+
@@ -16,11 +17,7 @@ function ProfileBox(props: Props): JSX.Element {
{name}
- ); }; -const ButtonSetup=({server_id}:{server_id?:string})=>{ - const handleClick= ()=>{ - window.open(`https://discord.com/oauth2/authorize?client_id=1075305629641621504&permissions=8&scope=bot&guild_id=${server_id}`, '_blank', 'toolbar=0,location=0,menubar=0'); - setTimeout(()=>{ +const ButtonSetup = ({ server_id }: { server_id?: string }) => { + const handleClick = () => { + window.open( + `https://discord.com/oauth2/authorize?client_id=1075305629641621504&permissions=8&scope=bot&guild_id=${server_id}`, + "_blank", + "toolbar=0,location=0,menubar=0", + ); + setTimeout(() => { window.location.reload(); - },10000) - } + }, 10000); + }; return ( - - ) -} + ); +}; diff --git a/Frontend/src/Components/Sidebar.tsx b/Frontend/src/Components/Sidebar.tsx index 88a7080..db889f1 100644 --- a/Frontend/src/Components/Sidebar.tsx +++ b/Frontend/src/Components/Sidebar.tsx @@ -9,7 +9,7 @@ function Sidebar() {
{DataSidebar.map((item, key) => (
{ + const handleClick = () => { window.location.reload(); - } + }; return (
- +
svg
Home
-
+
diff --git a/Frontend/src/Components/SidebarSecondHalf.tsx b/Frontend/src/Components/SidebarSecondHalf.tsx index 958644f..ffff81c 100644 --- a/Frontend/src/Components/SidebarSecondHalf.tsx +++ b/Frontend/src/Components/SidebarSecondHalf.tsx @@ -1,20 +1,26 @@ import { useLocation } from "react-router-dom"; -import {Modules} from "../Resources/Data" -import SubsidebarModule from "./SubsidebarModule" +import { Modules } from "../Resources/Data"; +import SubsidebarModule from "./SubsidebarModule"; function SidebarSecondHalf() { const { pathname } = useLocation(); return (
-
- {Modules.map((item,key)=> -
- -
- - )} +
+ {Modules.map((item, key) => ( +
+ +
+ ))}
- ) + ); } -export default SidebarSecondHalf \ No newline at end of file +export default SidebarSecondHalf; diff --git a/Frontend/src/Components/StatusCardBox.tsx b/Frontend/src/Components/StatusCardBox.tsx index 7a51036..8e00560 100644 --- a/Frontend/src/Components/StatusCardBox.tsx +++ b/Frontend/src/Components/StatusCardBox.tsx @@ -1,15 +1,29 @@ -import { Switch } from "@mui/material" -import { Button } from "./Button" +import { Switch } from "@mui/material"; +import { Button } from "./Button"; -export const StatusCardBox = ({heading,route,handleChange,value}:{heading:string,route:string,handleChange:()=>void,value:boolean})=>{ - return
+export const StatusCardBox = ({ + heading, + route, + handleChange, + value, +}: { + heading: string; + route: string; + handleChange: () => void; + value: boolean; +}) => { + return ( +
{heading}
-
Set Status of {heading}
+
+ Set Status of {heading}{" "} +
- -
- } \ No newline at end of file + ); +}; diff --git a/Frontend/src/Components/Subsidebar.tsx b/Frontend/src/Components/Subsidebar.tsx index 86638f9..042905d 100644 --- a/Frontend/src/Components/Subsidebar.tsx +++ b/Frontend/src/Components/Subsidebar.tsx @@ -7,16 +7,17 @@ interface Props { } function Subsidebar(props: Props): JSX.Element { - const { name, img, route } = props; return ( -
-
- -
-
{name}
+
+
+
+
{name}
+
); } diff --git a/Frontend/src/Components/SubsidebarModule.tsx b/Frontend/src/Components/SubsidebarModule.tsx index d1d8898..09face2 100644 --- a/Frontend/src/Components/SubsidebarModule.tsx +++ b/Frontend/src/Components/SubsidebarModule.tsx @@ -6,16 +6,16 @@ interface Props { route: string; } -function SubsidebarModule(props:Props):JSX.Element { - const { name, img, route } = props; +function SubsidebarModule(props: Props): JSX.Element { + const { name, img, route } = props; return ( -
-
- -
{name}
-
- {/*
+
+
+ +
{name}
+
+ {/*
*/} -
+
); } -export default SubsidebarModule \ No newline at end of file +export default SubsidebarModule; diff --git a/Frontend/src/Components/Userprofile.tsx b/Frontend/src/Components/Userprofile.tsx index 123dc01..dc068e4 100644 --- a/Frontend/src/Components/Userprofile.tsx +++ b/Frontend/src/Components/Userprofile.tsx @@ -3,27 +3,41 @@ import { useState } from "react"; interface Props { name: string; - id:string; - avatar:string + id: string; + avatar: string; } - function Userprofile(props: Props): JSX.Element { - const { name,id,avatar } = props; - const[isOpen,SetIsopen]=useState(false); - + const { name, id, avatar } = props; + const [isOpen, SetIsopen] = useState(false); + return ( -
- {/* Image And Name*/} +
+ {/* Image And Name*/}
- + +
+
+ {name}
-
{name}
{/* Logo */}
-
- {isOpen? -
- -
: - ""} + {isOpen ? ( +
+ +
+ ) : ( + "" + )}
); } diff --git a/Frontend/src/Hooks/Channel-content-hook.ts b/Frontend/src/Hooks/Channel-content-hook.ts index 2077815..635ac94 100644 --- a/Frontend/src/Hooks/Channel-content-hook.ts +++ b/Frontend/src/Hooks/Channel-content-hook.ts @@ -1,11 +1,23 @@ -import axios from "axios" +import axios from "axios"; -export const useSetImageChannel = async ({channel_id}:{channel_id:string})=>{ - const Response = await axios.post(`${import.meta.env.VITE_IP}add_img_chhannel/?guild=${window.localStorage.getItem("guild_id")}&channel_id=${channel_id}`) - return await Response.data -} +export const useSetImageChannel = async ({ + channel_id, +}: { + channel_id: string; +}) => { + const Response = await axios.post( + `${import.meta.env.VITE_IP}add_img_chhannel/?guild=${window.localStorage.getItem("guild_id")}&channel_id=${channel_id}`, + ); + return await Response.data; +}; -export const useSetLinkChannel = async ({channel_id}:{channel_id:string})=>{ - const Response = await axios.post(`${import.meta.env.VITE_IP}add_link_chhannel/?guild=${window.localStorage.getItem("guild_id")}&channel_id=${channel_id}`) - return await Response.data -} \ No newline at end of file +export const useSetLinkChannel = async ({ + channel_id, +}: { + channel_id: string; +}) => { + const Response = await axios.post( + `${import.meta.env.VITE_IP}add_link_chhannel/?guild=${window.localStorage.getItem("guild_id")}&channel_id=${channel_id}`, + ); + return await Response.data; +}; diff --git a/Frontend/src/Hooks/Channel-hook.tsx b/Frontend/src/Hooks/Channel-hook.tsx index d1c830f..6dfe0f2 100644 --- a/Frontend/src/Hooks/Channel-hook.tsx +++ b/Frontend/src/Hooks/Channel-hook.tsx @@ -3,12 +3,13 @@ import axios from "axios"; export const useGetChannels = async () => { const Response = await axios.get( `${import.meta.env.VITE_IP}server_Channels_List/?guild=${window.localStorage.getItem( - "guild_id" - )}` - ); - const ChannelArray = Object.entries(Response.data).map( - ([channel, id]) => ({ channel, id }) + "guild_id", + )}`, ); + const ChannelArray = Object.entries(Response.data).map(([channel, id]) => ({ + channel, + id, + })); return ChannelArray; }; diff --git a/Frontend/src/Hooks/Command-hook.ts b/Frontend/src/Hooks/Command-hook.ts index 7c584f8..9572e9e 100644 --- a/Frontend/src/Hooks/Command-hook.ts +++ b/Frontend/src/Hooks/Command-hook.ts @@ -1,6 +1,8 @@ -import axios from "axios" +import axios from "axios"; -export const useSetPrefix =async ({new_prefix}:{new_prefix:string})=>{ - const Response = await axios.post(`${import.meta.env.VITE_IP}change_prefix/?guild=${window.localStorage.getItem("guild_id")}&new_prefix=${new_prefix}`) - return Response.data -} \ No newline at end of file +export const useSetPrefix = async ({ new_prefix }: { new_prefix: string }) => { + const Response = await axios.post( + `${import.meta.env.VITE_IP}change_prefix/?guild=${window.localStorage.getItem("guild_id")}&new_prefix=${new_prefix}`, + ); + return Response.data; +}; diff --git a/Frontend/src/Hooks/Levelrole-hook.ts b/Frontend/src/Hooks/Levelrole-hook.ts index db9feae..92960fe 100644 --- a/Frontend/src/Hooks/Levelrole-hook.ts +++ b/Frontend/src/Hooks/Levelrole-hook.ts @@ -1,6 +1,14 @@ import axios from "axios"; -export const useSetLevelRole = async ({role_id,level}:{role_id:string,level:string})=>{ - const Response = await axios.post(`${import.meta.env.VITE_IP}LVL_role_set/?guild=${window.localStorage.getItem("guild_id")}&role=${role_id}&lvl=${level}`); +export const useSetLevelRole = async ({ + role_id, + level, +}: { + role_id: string; + level: string; +}) => { + const Response = await axios.post( + `${import.meta.env.VITE_IP}LVL_role_set/?guild=${window.localStorage.getItem("guild_id")}&role=${role_id}&lvl=${level}`, + ); return await Response.data; -} \ No newline at end of file +}; diff --git a/Frontend/src/Hooks/Login-hook.tsx b/Frontend/src/Hooks/Login-hook.tsx index 092f5e3..4b33b9a 100644 --- a/Frontend/src/Hooks/Login-hook.tsx +++ b/Frontend/src/Hooks/Login-hook.tsx @@ -1,32 +1,34 @@ -import { useEffect, useRef, useState} from "react"; +import { useEffect, useRef, useState } from "react"; import axios from "axios"; export const useSetLogin = ({ code }: { code: string }) => { - window.localStorage.setItem("code", code); - window.location.assign('/') + window.localStorage.setItem("code", code); + window.location.assign("/"); }; export const useSetLogout = async () => { await window.localStorage.removeItem("code"); await window.localStorage.removeItem("id"); await window.localStorage.removeItem("guild_id"); - window.location.replace(import.meta.env.VITE_LOGOUT_URI) + window.location.replace(import.meta.env.VITE_LOGOUT_URI); }; export const useGetData = () => { const code = window.localStorage.getItem("code"); const id = window.localStorage.getItem("id"); - const [idData,setidData]=useState(); + const [idData, setidData] = useState(); const effectRan = useRef(false); - + useEffect(() => { - if (effectRan.current === false && id===null) { + if (effectRan.current === false && id === null) { const fetchData = async () => { - const Response = await axios.get(`${import.meta.env.VITE_IP}callback/?code=${code}`); - if(Response.data){ - await window.localStorage.setItem("id",Response.data.user.id) + const Response = await axios.get( + `${import.meta.env.VITE_IP}callback/?code=${code}`, + ); + if (Response.data) { + await window.localStorage.setItem("id", Response.data.user.id); setidData(Response.data.user.id); - } + } }; fetchData(); } diff --git a/Frontend/src/Hooks/Message-Hook.ts b/Frontend/src/Hooks/Message-Hook.ts index ebe0dbd..21d133b 100644 --- a/Frontend/src/Hooks/Message-Hook.ts +++ b/Frontend/src/Hooks/Message-Hook.ts @@ -1,29 +1,49 @@ -import axios from "axios" +import axios from "axios"; -export const useSelectChannel = async({guild_id,channel_id}:{guild_id:string,channel_id:string}) => { - const Response = await axios.post(`${import.meta.env.VITE_IP}welcome_channel_set/?guild=${guild_id}&channel=${channel_id}`) - return (await Response).data -} +export const useSelectChannel = async ({ + guild_id, + channel_id, +}: { + guild_id: string; + channel_id: string; +}) => { + const Response = await axios.post( + `${import.meta.env.VITE_IP}welcome_channel_set/?guild=${guild_id}&channel=${channel_id}`, + ); + return (await Response).data; +}; -export const useSetWelcomeMessage = async ({message}:{message:string}) => { +export const useSetWelcomeMessage = async ({ + message, +}: { + message: string; +}) => { const Response = await axios.post( `${import.meta.env.VITE_IP}welcome_message/?guild=${window.localStorage.getItem( - "guild_id" - )}&message=${message}` + "guild_id", + )}&message=${message}`, ); - return Response.data -} + return Response.data; +}; -export const useSetLeaveMessage = async ({message}:{message:string}) => { +export const useSetLeaveMessage = async ({ message }: { message: string }) => { const Response = await axios.post( `${import.meta.env.VITE_IP}leave_message/?guild=${window.localStorage.getItem( - "guild_id" - )}&message=${message}` + "guild_id", + )}&message=${message}`, ); - return Response.data -} + return Response.data; +}; -export const useSelectLeaveChannel = async({guild_id,channel_id}:{guild_id:string,channel_id:string}) => { - const Response = await axios.post(`${import.meta.env.VITE_IP}leave_channel_set/?guild=${guild_id}&channel=${channel_id}`) - return (await Response).data -} \ No newline at end of file +export const useSelectLeaveChannel = async ({ + guild_id, + channel_id, +}: { + guild_id: string; + channel_id: string; +}) => { + const Response = await axios.post( + `${import.meta.env.VITE_IP}leave_channel_set/?guild=${guild_id}&channel=${channel_id}`, + ); + return (await Response).data; +}; diff --git a/Frontend/src/Hooks/Roles-hook.ts b/Frontend/src/Hooks/Roles-hook.ts index 14fa71c..1496f40 100644 --- a/Frontend/src/Hooks/Roles-hook.ts +++ b/Frontend/src/Hooks/Roles-hook.ts @@ -1,14 +1,25 @@ -import axios from "axios" +import axios from "axios"; -export const useGetRoles = async () =>{ - const Response = await axios.get(`${import.meta.env.VITE_IP}server_Roles_List/?guild=${window.localStorage.getItem("guild_id")}`); - const Roles = Object.entries(Response.data).map( - ([role, id]) => ({ role, id }) - ); - return Roles; -} +export const useGetRoles = async () => { + const Response = await axios.get( + `${import.meta.env.VITE_IP}server_Roles_List/?guild=${window.localStorage.getItem("guild_id")}`, + ); + const Roles = Object.entries(Response.data).map(([role, id]) => ({ + role, + id, + })); + return Roles; +}; -export const useSetJoinMemberRole = async ({channel_id,role_id}:{channel_id:string,role_id:string}) =>{ - const Response = await axios.post(`${import.meta.env.VITE_IP}join_member_role/?guild=${window.localStorage.getItem('guild_id')}&channel=${channel_id}&role=${role_id}`); - return await Response.data; -} \ No newline at end of file +export const useSetJoinMemberRole = async ({ + channel_id, + role_id, +}: { + channel_id: string; + role_id: string; +}) => { + const Response = await axios.post( + `${import.meta.env.VITE_IP}join_member_role/?guild=${window.localStorage.getItem("guild_id")}&channel=${channel_id}&role=${role_id}`, + ); + return await Response.data; +}; diff --git a/Frontend/src/Hooks/Status-hook.ts b/Frontend/src/Hooks/Status-hook.ts index 40a7c9f..e1925e1 100644 --- a/Frontend/src/Hooks/Status-hook.ts +++ b/Frontend/src/Hooks/Status-hook.ts @@ -1,26 +1,58 @@ -import axios from "axios" +import axios from "axios"; -export const useChangeStatusMessage = async ({bool}:{bool:boolean})=>{ - const Response = await axios.post(`${import.meta.env.VITE_IP}welcome_status/?guild=${window.localStorage.getItem("guild_id")}&status=${bool}`) - return Response.data -} -export const useChangeStatusleaveMessage= async({bool}:{bool:boolean})=>{ - const Response = await axios.post(`${import.meta.env.VITE_IP}leave_status/?guild=${window.localStorage.getItem("guild_id")}&status=${bool}`) - return Response.data -} -export const useChangeStatusLevelSystem= async ({bool}:{bool:boolean})=>{ - const Response = await axios.post(`${import.meta.env.VITE_IP}LVLsystem_status/?guild=${window.localStorage.getItem("guild_id")}&status=${bool}`) - return Response.data -} -export const useChangeStatusSocialNotification= async ({bool}:{bool:boolean})=>{ - const Response = await axios.post(`${import.meta.env.VITE_IP}youtube_notification_status/?guild=${window.localStorage.getItem("guild_id")}&status=${bool}`) - return Response.data -} -export const useChangeStatusImageChannel= async ({bool}:{bool:boolean})=>{ - const Response = await axios.post(`${import.meta.env.VITE_IP}IMG_channel_status/?guild=${window.localStorage.getItem("guild_id")}&status=${bool}`) - return Response.data -} -export const useChangeStatusLinkChannel= async ({bool}:{bool:boolean})=>{ - const Response = await axios.post(`${import.meta.env.VITE_IP}link_channel_status/?guild=${window.localStorage.getItem("guild_id")}&status=${bool}`) - return Response.data -} \ No newline at end of file +export const useChangeStatusMessage = async ({ bool }: { bool: boolean }) => { + const Response = await axios.post( + `${import.meta.env.VITE_IP}welcome_status/?guild=${window.localStorage.getItem("guild_id")}&status=${bool}`, + ); + return Response.data; +}; +export const useChangeStatusleaveMessage = async ({ + bool, +}: { + bool: boolean; +}) => { + const Response = await axios.post( + `${import.meta.env.VITE_IP}leave_status/?guild=${window.localStorage.getItem("guild_id")}&status=${bool}`, + ); + return Response.data; +}; +export const useChangeStatusLevelSystem = async ({ + bool, +}: { + bool: boolean; +}) => { + const Response = await axios.post( + `${import.meta.env.VITE_IP}LVLsystem_status/?guild=${window.localStorage.getItem("guild_id")}&status=${bool}`, + ); + return Response.data; +}; +export const useChangeStatusSocialNotification = async ({ + bool, +}: { + bool: boolean; +}) => { + const Response = await axios.post( + `${import.meta.env.VITE_IP}youtube_notification_status/?guild=${window.localStorage.getItem("guild_id")}&status=${bool}`, + ); + return Response.data; +}; +export const useChangeStatusImageChannel = async ({ + bool, +}: { + bool: boolean; +}) => { + const Response = await axios.post( + `${import.meta.env.VITE_IP}IMG_channel_status/?guild=${window.localStorage.getItem("guild_id")}&status=${bool}`, + ); + return Response.data; +}; +export const useChangeStatusLinkChannel = async ({ + bool, +}: { + bool: boolean; +}) => { + const Response = await axios.post( + `${import.meta.env.VITE_IP}link_channel_status/?guild=${window.localStorage.getItem("guild_id")}&status=${bool}`, + ); + return Response.data; +}; diff --git a/Frontend/src/Hooks/User-data-hook.tsx b/Frontend/src/Hooks/User-data-hook.tsx index 231d8b6..a6544d4 100644 --- a/Frontend/src/Hooks/User-data-hook.tsx +++ b/Frontend/src/Hooks/User-data-hook.tsx @@ -1,25 +1,25 @@ import axios from "axios"; import { useEffect, useRef, useState } from "react"; import { useRecoilValue, useSetRecoilState } from "recoil"; -import {AllServer, UserData, Loading } from "../Atoms/State"; +import { AllServer, UserData, Loading } from "../Atoms/State"; import { ServerWithPresence } from "../Interface"; export const useUserData = () => { const id = window.localStorage.getItem("id"); const setUser = useSetRecoilState(UserData); - const setTotalServer = useSetRecoilState(AllServer) + const setTotalServer = useSetRecoilState(AllServer); const setLoader = useSetRecoilState(Loading); const effectRan = useRef(false); useEffect(() => { if (effectRan.current === false && id) { const fetchData = async () => { const Response = await axios.get( - `${import.meta.env.VITE_IP}available_users?user_id=${id}` + `${import.meta.env.VITE_IP}available_users?user_id=${id}`, ); const Response2 = await axios.get( - `${import.meta.env.VITE_IP}server_List/` + `${import.meta.env.VITE_IP}server_List/`, ); - setTotalServer(Response2.data) + setTotalServer(Response2.data); await setUser(Response.data); await setLoader(false); }; @@ -34,23 +34,29 @@ export const useUserData = () => { export const useGetserverdata = () => { const { guilds } = useRecoilValue(UserData); const totalServer = useRecoilValue(AllServer); - const [userServerWithPresence, setUserServerWithPresence] = useState([]); - const [loading, setLoading] = useState(true); + const [userServerWithPresence, setUserServerWithPresence] = useState< + ServerWithPresence[] + >([]); + const [loading, setLoading] = useState(true); useUserData(); useEffect(() => { - if (guilds.length>0 && totalServer.length >0) { - const userServerWithPresence1:ServerWithPresence[] = guilds.map((server) => { - const foundserver =totalServer.find((Tserver)=>Tserver.id == server.id); - return { - ...server, - isPresent: foundserver !==undefined , - iconURL: `https://cdn.discordapp.com/icons/${server.id}/${server.icon}.png?size=1024`, - }; - }); - setUserServerWithPresence(userServerWithPresence1); - setLoading(false); - }else{ - setLoading(true) + if (guilds.length > 0 && totalServer.length > 0) { + const userServerWithPresence1: ServerWithPresence[] = guilds.map( + (server) => { + const foundserver = totalServer.find( + (Tserver) => Tserver.id == server.id, + ); + return { + ...server, + isPresent: foundserver !== undefined, + iconURL: `https://cdn.discordapp.com/icons/${server.id}/${server.icon}.png?size=1024`, + }; + }, + ); + setUserServerWithPresence(userServerWithPresence1); + setLoading(false); + } else { + setLoading(true); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [guilds]); diff --git a/Frontend/src/Hooks/Youtube-Notification.ts b/Frontend/src/Hooks/Youtube-Notification.ts index 8a0a590..e9e106f 100644 --- a/Frontend/src/Hooks/Youtube-Notification.ts +++ b/Frontend/src/Hooks/Youtube-Notification.ts @@ -1,19 +1,39 @@ -import axios from "axios" +import axios from "axios"; -export const useYtChannelSet = async ({guild_id,channel_id}:{guild_id:string,channel_id:string})=>{ - const Response = await axios.post(`${import.meta.env.VITE_IP}youtube_notification/?guild=${guild_id}&channel=${channel_id}`); - return (await Response).data -} +export const useYtChannelSet = async ({ + guild_id, + channel_id, +}: { + guild_id: string; + channel_id: string; +}) => { + const Response = await axios.post( + `${import.meta.env.VITE_IP}youtube_notification/?guild=${guild_id}&channel=${channel_id}`, + ); + return (await Response).data; +}; -export const useSetYoutubeCreatorChannel = async ({guild_id,yt_Channel_name}:{guild_id:string,yt_Channel_name:string})=>{ - const Response = await axios.post(`${import.meta.env.VITE_IP}Set_YT_channel/?guild=${guild_id}&YT_channel_usr=${yt_Channel_name}`) - return (await Response).data -} -export const useGetYoutubeChannel = async ()=>{ - const Response = await axios.get(`${import.meta.env.VITE_IP}GET_YT_SUB_channels_lst/?guild=${window.localStorage.getItem("guild_id")}`); - return (await Response).data -} -export const useRemoveChannel = async ({channel}:{channel:string})=>{ - const Response = await axios.post(`${import.meta.env.VITE_IP}remove_YT_channel/?guild=${window.localStorage.getItem("guild_id")}&YT_channel_usr=${channel}`); - return (await Response).data -} \ No newline at end of file +export const useSetYoutubeCreatorChannel = async ({ + guild_id, + yt_Channel_name, +}: { + guild_id: string; + yt_Channel_name: string; +}) => { + const Response = await axios.post( + `${import.meta.env.VITE_IP}Set_YT_channel/?guild=${guild_id}&YT_channel_usr=${yt_Channel_name}`, + ); + return (await Response).data; +}; +export const useGetYoutubeChannel = async () => { + const Response = await axios.get( + `${import.meta.env.VITE_IP}GET_YT_SUB_channels_lst/?guild=${window.localStorage.getItem("guild_id")}`, + ); + return (await Response).data; +}; +export const useRemoveChannel = async ({ channel }: { channel: string }) => { + const Response = await axios.post( + `${import.meta.env.VITE_IP}remove_YT_channel/?guild=${window.localStorage.getItem("guild_id")}&YT_channel_usr=${channel}`, + ); + return (await Response).data; +}; diff --git a/Frontend/src/Hooks/window-size.ts b/Frontend/src/Hooks/window-size.ts index 5992385..8508f0d 100644 --- a/Frontend/src/Hooks/window-size.ts +++ b/Frontend/src/Hooks/window-size.ts @@ -1,36 +1,36 @@ import { useState, useEffect } from "react"; -type Dimension ={ - width:number, - height:number -} +type Dimension = { + width: number; + height: number; +}; export const useWindowSize = () => { - const [windowSize, setWindowSize] = useState({ - width: 0, - height: 0 - }); + const [windowSize, setWindowSize] = useState({ + width: 0, + height: 0, + }); - useEffect(() => { - // only execute all the code below in client side - function handleResize() { - // Set window width/height to state - setWindowSize({ - width: window.innerWidth, - height: window.innerHeight - }); - } - if (typeof window !== "undefined") { - // Handler to call on window resize + useEffect(() => { + // only execute all the code below in client side + function handleResize() { + // Set window width/height to state + setWindowSize({ + width: window.innerWidth, + height: window.innerHeight, + }); + } + if (typeof window !== "undefined") { + // Handler to call on window resize - // Add event listener - window.addEventListener("resize", handleResize); + // Add event listener + window.addEventListener("resize", handleResize); - // Call handler right away so state gets updated with initial window size - handleResize(); + // Call handler right away so state gets updated with initial window size + handleResize(); - // Remove event listener on cleanup - return () => window.removeEventListener("resize", handleResize); - } - }, []); // Empty array ensures that effect is only run on mount - return windowSize; -}; \ No newline at end of file + // Remove event listener on cleanup + return () => window.removeEventListener("resize", handleResize); + } + }, []); // Empty array ensures that effect is only run on mount + return windowSize; +}; diff --git a/Frontend/src/Interface/index.ts b/Frontend/src/Interface/index.ts index 3bd6966..482f491 100644 --- a/Frontend/src/Interface/index.ts +++ b/Frontend/src/Interface/index.ts @@ -1,51 +1,50 @@ export interface userData { - user: User; - guilds: Guild[]; - } - export interface User { - id: string; - username: string; - avatar: string; - discriminator: string; - public_flags: number; - flags: number; - banner: string | null; - accent_color: number | null; - global_name: string; - avatar_decoration_data: null; - banner_color: string | null; - mfa_enabled: boolean; - locale: string; - premium_type: number; - } + user: User; + guilds: Guild[]; +} +export interface User { + id: string; + username: string; + avatar: string; + discriminator: string; + public_flags: number; + flags: number; + banner: string | null; + accent_color: number | null; + global_name: string; + avatar_decoration_data: null; + banner_color: string | null; + mfa_enabled: boolean; + locale: string; + premium_type: number; +} - export interface Guild { - id: string; - name: string; - icon?: string; - owner: boolean; - permissions: number; - permissions_new: string; - features: string[]; - } - - export interface ServerList { - name: string - id: string - icon_url: string - } +export interface Guild { + id: string; + name: string; + icon?: string; + owner: boolean; + permissions: number; + permissions_new: string; + features: string[]; +} +export interface ServerList { + name: string; + id: string; + icon_url: string; +} export interface ServerWithPresenceObject { - features?: string[] - id?: string, - owner?: boolean, - permissions_new?: string, - permissions?: number, - icon?: string, - name?: string, - isPresent?: boolean, - iconURL?:string + features?: string[]; + id?: string; + owner?: boolean; + permissions_new?: string; + permissions?: number; + icon?: string; + name?: string; + isPresent?: boolean; + iconURL?: string; } export interface ChannelListArray { @@ -53,8 +52,8 @@ export interface ChannelListArray { id: string | unknown; } export interface Roles { - role:string, - id:string | unknown + role: string; + id: string | unknown; } export interface Server { id: string; @@ -69,4 +68,4 @@ export interface Server { export interface ServerWithPresence extends Server { isPresent: boolean | undefined; iconURL: string; -} \ No newline at end of file +} diff --git a/Frontend/src/Pages/AutoModeration.tsx b/Frontend/src/Pages/AutoModeration.tsx index daa9564..7cafb3e 100644 --- a/Frontend/src/Pages/AutoModeration.tsx +++ b/Frontend/src/Pages/AutoModeration.tsx @@ -1,7 +1,5 @@ function AutoModeration() { - return ( -
AutoModeration
- ) + return
AutoModeration
; } -export default AutoModeration \ No newline at end of file +export default AutoModeration; diff --git a/Frontend/src/Pages/Branding.tsx b/Frontend/src/Pages/Branding.tsx index 65463d8..12db55f 100644 --- a/Frontend/src/Pages/Branding.tsx +++ b/Frontend/src/Pages/Branding.tsx @@ -1,9 +1,9 @@ function Branding(): JSX.Element { return (
- Comming Soon,Stay Tuned!!! + Comming Soon,Stay Tuned!!!
- ) + ); } -export default Branding \ No newline at end of file +export default Branding; diff --git a/Frontend/src/Pages/ChannelContent.tsx b/Frontend/src/Pages/ChannelContent.tsx index e70780c..f3b966c 100644 --- a/Frontend/src/Pages/ChannelContent.tsx +++ b/Frontend/src/Pages/ChannelContent.tsx @@ -2,7 +2,10 @@ import { useState } from "react"; import { MenuDropdown } from "../Components/MenuDropdown"; import { SubmitButton } from "../Components/Button"; import Heading from "../Components/Heading"; -import { useSetImageChannel, useSetLinkChannel } from "../Hooks/Channel-content-hook"; +import { + useSetImageChannel, + useSetLinkChannel, +} from "../Hooks/Channel-content-hook"; export default function Messages(): JSX.Element { const [channel, SetChannel] = useState(""); @@ -11,21 +14,21 @@ export default function Messages(): JSX.Element { SetChannel(e.target.value); }; const useHandleSubmitImage = async () => { - if(channel){ - const Response = await useSetImageChannel({channel_id:channel}); + if (channel) { + const Response = await useSetImageChannel({ channel_id: channel }); // log(Response) - alert(Response.message) + alert(Response.message); } }; - const handleChangeLink= (e:React.ChangeEvent)=>{ - SetChannel_link(e.target.value) - } - const useHandleSubmitLink = async ()=>{ - if(channel_Link){ - const Response = await useSetLinkChannel({channel_id:channel_Link}) - alert(Response.message) + const handleChangeLink = (e: React.ChangeEvent) => { + SetChannel_link(e.target.value); + }; + const useHandleSubmitLink = async () => { + if (channel_Link) { + const Response = await useSetLinkChannel({ channel_id: channel_Link }); + alert(Response.message); } - } + }; return (
diff --git a/Frontend/src/Pages/Commands.tsx b/Frontend/src/Pages/Commands.tsx index ca5498c..c4f9782 100644 --- a/Frontend/src/Pages/Commands.tsx +++ b/Frontend/src/Pages/Commands.tsx @@ -101,7 +101,6 @@ function Commands(): JSX.Element {
-
); } diff --git a/Frontend/src/Pages/ErrorRouter.tsx b/Frontend/src/Pages/ErrorRouter.tsx index 10f8709..0223525 100644 --- a/Frontend/src/Pages/ErrorRouter.tsx +++ b/Frontend/src/Pages/ErrorRouter.tsx @@ -1,11 +1,10 @@ -function ErrorRouter():JSX.Element { +function ErrorRouter(): JSX.Element { return (

404

Not Found

-
- ) + ); } -export default ErrorRouter \ No newline at end of file +export default ErrorRouter; diff --git a/Frontend/src/Pages/Home.tsx b/Frontend/src/Pages/Home.tsx index b3ab17b..d629e21 100644 --- a/Frontend/src/Pages/Home.tsx +++ b/Frontend/src/Pages/Home.tsx @@ -19,13 +19,11 @@ function Home(): JSX.Element {
- -
-
- MODULES +
+
MODULES
- +
{/* Display Components */} diff --git a/Frontend/src/Pages/HomeMain.tsx b/Frontend/src/Pages/HomeMain.tsx index 35e35f5..d6fea90 100644 --- a/Frontend/src/Pages/HomeMain.tsx +++ b/Frontend/src/Pages/HomeMain.tsx @@ -4,14 +4,14 @@ import HomeHeading from "../Components/HomeHeading"; import { UserData } from "../Atoms/State"; function HomeMain(): JSX.Element { - const {user}= useRecoilValue(UserData); + const { user } = useRecoilValue(UserData); return (
- +
); diff --git a/Frontend/src/Pages/JoinRoles.tsx b/Frontend/src/Pages/JoinRoles.tsx index 5fd04c6..0211020 100644 --- a/Frontend/src/Pages/JoinRoles.tsx +++ b/Frontend/src/Pages/JoinRoles.tsx @@ -1,5 +1,5 @@ -import React, { useState } from "react" -import Heading from "../Components/Heading" +import React, { useState } from "react"; +import Heading from "../Components/Heading"; import { useRecoilValue } from "recoil"; import { RoleArray } from "../Atoms/State"; import { MenuDropdown } from "../Components/MenuDropdown"; @@ -9,21 +9,23 @@ import { useSetJoinMemberRole } from "../Hooks/Roles-hook"; function JoinRoles(): JSX.Element { const roles = useRecoilValue(RoleArray); const [roleId, setroleId] = useState(""); - const [channelid,setChannelid] = useState(""); + const [channelid, setChannelid] = useState(""); - - const handleChange = (e:React.ChangeEvent) => { + const handleChange = (e: React.ChangeEvent) => { setroleId(e.target.value); }; - const handleChangeChannel = (e:React.ChangeEvent) => { - setChannelid(e.target.value); + const handleChangeChannel = (e: React.ChangeEvent) => { + setChannelid(e.target.value); }; - const useHandleSubmit = async ()=>{ - if(roleId && channelid){ - const response = await useSetJoinMemberRole({channel_id:channelid,role_id:roleId}) - alert(response.role_name + ' is Set'); + const useHandleSubmit = async () => { + if (roleId && channelid) { + const response = await useSetJoinMemberRole({ + channel_id: channelid, + role_id: roleId, + }); + alert(response.role_name + " is Set"); } - } + }; return (
@@ -35,18 +37,37 @@ function JoinRoles(): JSX.Element { server.
- - + +
- - + +
- +
); } -export default JoinRoles \ No newline at end of file +export default JoinRoles; diff --git a/Frontend/src/Pages/Landing page/AboutPage.tsx b/Frontend/src/Pages/Landing page/AboutPage.tsx index 08bf2a0..e0c5e49 100644 --- a/Frontend/src/Pages/Landing page/AboutPage.tsx +++ b/Frontend/src/Pages/Landing page/AboutPage.tsx @@ -1,13 +1,15 @@ -import { AboutHero } from "./components/Hero-About" -import { Story } from "./components/Story" -import { Vision } from "./components/Vision" -import { Whoarewe } from "./components/Whoarewe" +import { AboutHero } from "./components/Hero-About"; +import { Story } from "./components/Story"; +import { Vision } from "./components/Vision"; +import { Whoarewe } from "./components/Whoarewe"; -export const AboutPage = ()=>{ - return
- - - - +export const AboutPage = () => { + return ( +
+ + + +
-} + ); +}; diff --git a/Frontend/src/Pages/Landing page/ContactPage.tsx b/Frontend/src/Pages/Landing page/ContactPage.tsx index 0697b33..8c768cb 100644 --- a/Frontend/src/Pages/Landing page/ContactPage.tsx +++ b/Frontend/src/Pages/Landing page/ContactPage.tsx @@ -6,16 +6,17 @@ export const ContactPage = () => {
-
-
- For the most effective communication, please utilize our support channel. Click the link below to submit a ticket. -
-
- - https://support.techtonions.com - -
-
+
+
+ For the most effective communication, please utilize our support + channel. Click the link below to submit a ticket. +
+
+ + https://support.techtonions.com + +
+
); diff --git a/Frontend/src/Pages/Landing page/components/Features.tsx b/Frontend/src/Pages/Landing page/components/Features.tsx index 259737b..74febc8 100644 --- a/Frontend/src/Pages/Landing page/components/Features.tsx +++ b/Frontend/src/Pages/Landing page/components/Features.tsx @@ -1,6 +1,6 @@ -import svg from "../../../Resources/images/FeatureLogo.png" -import feature from '../../../Resources/Svg/1.svg' -import socialNotif from "../../../Resources/Svg/2.svg" +import svg from "../../../Resources/images/FeatureLogo.png"; +import feature from "../../../Resources/Svg/1.svg"; +import socialNotif from "../../../Resources/Svg/2.svg"; export const Features = () => { return (
@@ -14,44 +14,49 @@ export const Features = () => {
-
-
Message Components
-
-
Let users assign themselves roles
-
Create beautiful info messages
-
Send messages based on keywords
-
+
+
+ Message Components
-
- +
+
Let users assign themselves roles
+
Create beautiful info messages
+
Send messages based on keywords
+
+
+ +
-
- +
+ +
+
+
+ Moderation
-
-
Moderation
-
-
Easily Manage Cases
-
Define reason aliases
-
Custom DM notifications
-
+
+
Easily Manage Cases
+
Define reason aliases
+
Custom DM notifications
- +
-
-
Manage Social Media
-
-
Create beautiful Social Notification
-
Let User Assign their favourite Creator
-
Live Updates from the Channel
-
+
+
+ Manage Social Media
-
- +
+
Create beautiful Social Notification
+
Let User Assign their favourite Creator
+
Live Updates from the Channel
+
+
+ +
); diff --git a/Frontend/src/Pages/Landing page/components/Footer.tsx b/Frontend/src/Pages/Landing page/components/Footer.tsx index 8b7f9b5..10dcfe5 100644 --- a/Frontend/src/Pages/Landing page/components/Footer.tsx +++ b/Frontend/src/Pages/Landing page/components/Footer.tsx @@ -2,7 +2,7 @@ import { useLocation, useNavigate } from "react-router-dom"; import { Discord, Github, LinkedIn, X } from "../../../Resources/Svg/SVG"; import TechTOnionsLogo from "../../../Resources/images/TechTOnions_Bot.png"; export const Footer = () => { - const {pathname} = useLocation(); + const { pathname } = useLocation(); const navigate = useNavigate(); return (
@@ -11,12 +11,40 @@ export const Footer = () => {
-
-
{navigate('/login/home')}} className={`${pathname=='/login/home'?'text-white font-medium':'text-gray-400' } transition-all cursor-pointer hover:font-medium hover:text-white hover:transition-all`}>Home
-
{navigate('/login/about-us')}} className={`${pathname=='/login/about-us'?'text-white font-medium':'text-gray-400' } transition-all cursor-pointer hover:font-medium hover:text-white hover:transition-all`}>About us
-
{navigate('/login/contact-us')}} className={`${pathname=='/login/contact-us'?'text-white font-medium':'text-gray-400' } transition-all cursor-pointer hover:font-medium hover:text-white hover:transition-all`}>Contact us
-
{window.location.assign(`${import.meta.env.VITE_GITHUB_URI}`)}} className="text-red-400 cursor-pointer">Contribute
+
+
{ + navigate("/login/home"); + }} + className={`${pathname == "/login/home" ? "text-white font-medium" : "text-gray-400"} transition-all cursor-pointer hover:font-medium hover:text-white hover:transition-all`} + > + Home
+
{ + navigate("/login/about-us"); + }} + className={`${pathname == "/login/about-us" ? "text-white font-medium" : "text-gray-400"} transition-all cursor-pointer hover:font-medium hover:text-white hover:transition-all`} + > + About us +
+
{ + navigate("/login/contact-us"); + }} + className={`${pathname == "/login/contact-us" ? "text-white font-medium" : "text-gray-400"} transition-all cursor-pointer hover:font-medium hover:text-white hover:transition-all`} + > + Contact us +
+
{ + window.location.assign(`${import.meta.env.VITE_GITHUB_URI}`); + }} + className="text-red-400 cursor-pointer" + > + Contribute +
+
@@ -29,7 +57,7 @@ export const Footer = () => {
- +
diff --git a/Frontend/src/Pages/Landing page/components/Hero-About.tsx b/Frontend/src/Pages/Landing page/components/Hero-About.tsx index 840d99d..c5b5e46 100644 --- a/Frontend/src/Pages/Landing page/components/Hero-About.tsx +++ b/Frontend/src/Pages/Landing page/components/Hero-About.tsx @@ -1,19 +1,24 @@ -export const AboutHero = ()=>{ - return
-
-
-
- Discover - TechTOnions.com +export const AboutHero = () => { + return ( +
+
+
+
+ Discover TechTOnions.com +
+
+ Unveiling Excellence with +
+
Gladness
+
+
+
+ At TechTOnions.com, we believe in transforming ideas into + innovation. Explore our story, meet our passionate team, and join us + on the journey of technological excellence. +
-
Unveiling Excellence with
-
Gladness
-
-
-
- At TechTOnions.com, we believe in transforming ideas into innovation. Explore our story, meet our passionate team, and join us on the journey of technological excellence. -
-
-} \ No newline at end of file + ); +}; diff --git a/Frontend/src/Pages/Landing page/components/Hero-Contact.tsx b/Frontend/src/Pages/Landing page/components/Hero-Contact.tsx index b4d2159..9666761 100644 --- a/Frontend/src/Pages/Landing page/components/Hero-Contact.tsx +++ b/Frontend/src/Pages/Landing page/components/Hero-Contact.tsx @@ -1,17 +1,22 @@ -export const ContactHero = ()=>{ - return
-
-
-
- TechTOnions.com +export const ContactHero = () => { + return ( +
+
+
+
+ TechTOnions.com +
+
+ It's Easy to Contact us +
+
+
+
+ TechTOnions.com: Where Support is Seamless and Solutions are + Limitless. +
-
It's Easy to Contact us
-
-
-
- TechTOnions.com: Where Support is Seamless and Solutions are Limitless. -
-
-} \ No newline at end of file + ); +}; diff --git a/Frontend/src/Pages/Landing page/components/Herosection.tsx b/Frontend/src/Pages/Landing page/components/Herosection.tsx index 1a42212..870f9cc 100644 --- a/Frontend/src/Pages/Landing page/components/Herosection.tsx +++ b/Frontend/src/Pages/Landing page/components/Herosection.tsx @@ -13,19 +13,20 @@ export const Herosection = () => {
-
- Multipurpose Discord bot. -
-
- Fully Customizable. -
-
- Completely Free and OpenSource. -
+
Multipurpose Discord bot.
+
Fully Customizable.
+
Completely Free and OpenSource.
-
diff --git a/Frontend/src/Pages/Landing page/components/LandingNavbar.tsx b/Frontend/src/Pages/Landing page/components/LandingNavbar.tsx index b1f80c7..29ffd5b 100644 --- a/Frontend/src/Pages/Landing page/components/LandingNavbar.tsx +++ b/Frontend/src/Pages/Landing page/components/LandingNavbar.tsx @@ -1,30 +1,54 @@ import { useLocation, useNavigate } from "react-router-dom"; import { Button } from "../../../Components/Button"; -import TechTOnionsLogo from "../../../Resources/images/TechTOnions_Bot.png" +import TechTOnionsLogo from "../../../Resources/images/TechTOnions_Bot.png"; import { useEffect, useState } from "react"; - export const LandingNavbar = () => { const navigate = useNavigate(); - const[url,setUrl]=useState('home') - const {pathname} =useLocation(); - useEffect(()=>{ + const [url, setUrl] = useState("home"); + const { pathname } = useLocation(); + useEffect(() => { setUrl(pathname); - },[pathname]) + }, [pathname]); return (
-
-

+
+

-

-
-
{navigate('home')}} className={`text-lg font-semibold transition ${url==='/login/home'?'border-blue-600':'border-navColor'} duration-700 border-b-2 cursor-pointer hover:duration-700 hover:border-b-2 hover:border-blue-600 hover:transition`}>Home
-
{navigate('about-us')}} className={`text-lg font-semibold transition duration-700 border-b-2 cursor-pointer hover:duration-700 ${url==='/login/about-us'?'border-blue-600':'border-navColor'} hover:border-b-2 hover:border-blue-600 hover:transition`}>About Us
-
{navigate('contact-us')}}className={`text-lg font-semibold transition duration-700 border-b-2 cursor-pointer hover:duration-700 ${url==='/login/contact-us'?'border-blue-600':'border-navColor'} hover:border-b-2 hover:border-blue-600 hover:transition`}>Contact Us
-

+
+
{ + navigate("home"); + }} + className={`text-lg font-semibold transition ${url === "/login/home" ? "border-blue-600" : "border-navColor"} duration-700 border-b-2 cursor-pointer hover:duration-700 hover:border-b-2 hover:border-blue-600 hover:transition`} + > + Home +
+
{ + navigate("about-us"); + }} + className={`text-lg font-semibold transition duration-700 border-b-2 cursor-pointer hover:duration-700 ${url === "/login/about-us" ? "border-blue-600" : "border-navColor"} hover:border-b-2 hover:border-blue-600 hover:transition`} + > + About Us +
+
{ + navigate("contact-us"); + }} + className={`text-lg font-semibold transition duration-700 border-b-2 cursor-pointer hover:duration-700 ${url === "/login/contact-us" ? "border-blue-600" : "border-navColor"} hover:border-b-2 hover:border-blue-600 hover:transition`} + > + Contact Us
+
+
); }; diff --git a/Frontend/src/Pages/Landing page/components/Story.tsx b/Frontend/src/Pages/Landing page/components/Story.tsx index 3209b33..d7d1c1a 100644 --- a/Frontend/src/Pages/Landing page/components/Story.tsx +++ b/Frontend/src/Pages/Landing page/components/Story.tsx @@ -1,19 +1,22 @@ -import StoryImg from "../../../Resources/Svg/TechTOnions_our_story-1320x1209.webp" +import StoryImg from "../../../Resources/Svg/TechTOnions_our_story-1320x1209.webp"; -export const Story = ()=>{ - return
-
-
- Our Story -
-
-
- Founded in 2020, TechTOnions.com has evolved from a visionary idea to a dynamic reality. Our journey began with a passion for pushing technological boundaries and a commitment to providing cutting-edge solutions. -
-
- -
-
+export const Story = () => { + return ( +
+
+
Our Story
+
+
+ Founded in 2020, TechTOnions.com has evolved from a visionary idea + to a dynamic reality. Our journey began with a passion for pushing + technological boundaries and a commitment to providing cutting-edge + solutions. +
+
+ +
+
-} \ No newline at end of file + ); +}; diff --git a/Frontend/src/Pages/Landing page/components/Vision.tsx b/Frontend/src/Pages/Landing page/components/Vision.tsx index 3542f22..5832f5b 100644 --- a/Frontend/src/Pages/Landing page/components/Vision.tsx +++ b/Frontend/src/Pages/Landing page/components/Vision.tsx @@ -1,18 +1,26 @@ -import VisionImg from "../../../Resources/Svg/TechTOnions_Our_Vision-1320x1177.png" -export const Vision =()=>{ - return
-
-
- Our Vision -
+import VisionImg from "../../../Resources/Svg/TechTOnions_Our_Vision-1320x1177.png"; +export const Vision = () => { + return ( +
+
+
Our Vision
-
- At TechTOnions.com, we envision a future where technology seamlessly integrates into every aspect of our lives. Our goal is to enhance efficiency and accessibility, making advanced technological solutions available to everyone. We are committed to driving transformative innovations that not only simplify daily tasks but also open up new possibilities for growth and progress. By focusing on user-centric designs and cutting-edge advancements, we aim to create a world where technology empowers individuals and communities to achieve more and experience life to its fullest potential. -
-
- -
+
+ At TechTOnions.com, we envision a future where technology seamlessly + integrates into every aspect of our lives. Our goal is to enhance + efficiency and accessibility, making advanced technological + solutions available to everyone. We are committed to driving + transformative innovations that not only simplify daily tasks but + also open up new possibilities for growth and progress. By focusing + on user-centric designs and cutting-edge advancements, we aim to + create a world where technology empowers individuals and communities + to achieve more and experience life to its fullest potential. +
+
+ +
+
-
-} \ No newline at end of file + ); +}; diff --git a/Frontend/src/Pages/Landing page/components/Whoarewe.tsx b/Frontend/src/Pages/Landing page/components/Whoarewe.tsx index 211e270..9f6f30e 100644 --- a/Frontend/src/Pages/Landing page/components/Whoarewe.tsx +++ b/Frontend/src/Pages/Landing page/components/Whoarewe.tsx @@ -1,18 +1,23 @@ -import WhoImg from "../../../Resources/Svg/TechTOnions_Who_We_Are-1320x867.png" -export const Whoarewe=()=>{ - return
-
-
- Who We Are -
+import WhoImg from "../../../Resources/Svg/TechTOnions_Who_We_Are-1320x867.png"; +export const Whoarewe = () => { + return ( +
+
+
Who We Are
-
- -
-
- TechTOnions.com is more than a company; it's a collaborative community of creative minds, tech enthusiasts, and industry experts. Our team is driven by a shared goal - revolutionizing the tech landscape. From software development and embedded solutions to test jigs and 3D printing, our diverse skills ensure comprehensive and innovative solutions. -
+
+ +
+
+ TechTOnions.com is more than a company; it's a collaborative + community of creative minds, tech enthusiasts, and industry experts. + Our team is driven by a shared goal - revolutionizing the tech + landscape. From software development and embedded solutions to test + jigs and 3D printing, our diverse skills ensure comprehensive and + innovative solutions. +
+
-
-} \ No newline at end of file + ); +}; diff --git a/Frontend/src/Pages/Landing page/home/Homepage.tsx b/Frontend/src/Pages/Landing page/home/Homepage.tsx index e20fabf..7af1c9a 100644 --- a/Frontend/src/Pages/Landing page/home/Homepage.tsx +++ b/Frontend/src/Pages/Landing page/home/Homepage.tsx @@ -1,9 +1,11 @@ -import { Features } from "../components/Features" -import { Herosection } from "../components/Herosection" +import { Features } from "../components/Features"; +import { Herosection } from "../components/Herosection"; -export const Homepage = ()=>{ - return
- - +export const Homepage = () => { + return ( +
+ +
-} \ No newline at end of file + ); +}; diff --git a/Frontend/src/Pages/LeaveMessage.tsx b/Frontend/src/Pages/LeaveMessage.tsx index 6f24dc8..9320b0f 100644 --- a/Frontend/src/Pages/LeaveMessage.tsx +++ b/Frontend/src/Pages/LeaveMessage.tsx @@ -1,6 +1,9 @@ -import {useState } from "react"; +import { useState } from "react"; import Heading from "../Components/Heading"; -import { useSelectLeaveChannel, useSetLeaveMessage } from "../Hooks/Message-Hook"; +import { + useSelectLeaveChannel, + useSetLeaveMessage, +} from "../Hooks/Message-Hook"; import { SubmitButton } from "../Components/Button"; import { useRecoilValue } from "recoil"; import { ChannelArray } from "../Atoms/State"; @@ -10,20 +13,25 @@ const defaultText = function LeaveMessage(): JSX.Element { const [message, setMessage] = useState(defaultText); - const [value, setValue] = useState(); + const [value, setValue] = useState(); const ChannelArrays = useRecoilValue(ChannelArray); const useHandleSubmit = async () => { if (value) { - const response = await useSetLeaveMessage({message}); - const responseChannel= await useSelectLeaveChannel({guild_id:window.localStorage.getItem('guild_id') as string, channel_id:value as string}) - - if(response && responseChannel){ - alert("Welcome Message Updated on " + `"${ChannelArrays?.find((channel)=>channel.id===value)?.channel}" Channel`) + const response = await useSetLeaveMessage({ message }); + const responseChannel = await useSelectLeaveChannel({ + guild_id: window.localStorage.getItem("guild_id") as string, + channel_id: value as string, + }); + + if (response && responseChannel) { + alert( + "Welcome Message Updated on " + + `"${ChannelArrays?.find((channel) => channel.id === value)?.channel}" Channel`, + ); } - } - else{ - alert("Please select a channel") + } else { + alert("Please select a channel"); } }; const handleChange = (e: React.ChangeEvent) => { @@ -40,7 +48,7 @@ function LeaveMessage(): JSX.Element {
- +
- - +
); } export default LeaveMessage; - - diff --git a/Frontend/src/Pages/LevelSetup.tsx b/Frontend/src/Pages/LevelSetup.tsx index 2f6027a..d40945c 100644 --- a/Frontend/src/Pages/LevelSetup.tsx +++ b/Frontend/src/Pages/LevelSetup.tsx @@ -22,24 +22,24 @@ function LevelSetup() { } function LevelingUp() { - const [value,setValue] = useState(" "); - const [level,setLevel] = useState(""); + const [value, setValue] = useState(" "); + const [level, setLevel] = useState(""); const roles = useRecoilValue(RoleArray); const handleChange = (e: React.ChangeEvent) => { - setValue(e.target.value); + setValue(e.target.value); }; - const handleLevelInput = (e:React.ChangeEvent) => { - setLevel(e.target.value); - } - const useHandleSubmit = async ()=>{ - if(value && level){ - const response = await useSetLevelRole({role_id:value,level:level}); - await alert(response.message); - setValue(""); - setLevel(""); + const handleLevelInput = (e: React.ChangeEvent) => { + setLevel(e.target.value); + }; + const useHandleSubmit = async () => { + if (value && level) { + const response = await useSetLevelRole({ role_id: value, level: level }); + await alert(response.message); + setValue(""); + setLevel(""); } - } + }; return (
Levelling Up
@@ -48,16 +48,20 @@ function LevelingUp() { the user.
-
Level up announcement
- +
Level up announcement
+
Enter Level (Number)
- +
- +
); } diff --git a/Frontend/src/Pages/Logging.tsx b/Frontend/src/Pages/Logging.tsx index 06c8a94..f57afcb 100644 --- a/Frontend/src/Pages/Logging.tsx +++ b/Frontend/src/Pages/Logging.tsx @@ -1,10 +1,9 @@ -function Logging():JSX.Element { +function Logging(): JSX.Element { return ( -
- Comming Soon,Stay Tuned!!! + Comming Soon,Stay Tuned!!!
- ) + ); } -export default Logging \ No newline at end of file +export default Logging; diff --git a/Frontend/src/Pages/Login.tsx b/Frontend/src/Pages/Login.tsx index d8e3820..26db487 100644 --- a/Frontend/src/Pages/Login.tsx +++ b/Frontend/src/Pages/Login.tsx @@ -1,5 +1,10 @@ -import {Navigate, Outlet, useLocation, useSearchParams } from "react-router-dom"; -import {useSetLogin } from "../Hooks/Login-hook"; +import { + Navigate, + Outlet, + useLocation, + useSearchParams, +} from "react-router-dom"; +import { useSetLogin } from "../Hooks/Login-hook"; import { LandingNavbar } from "./Landing page/components/LandingNavbar"; import { Footer } from "./Landing page/components/Footer"; import { useWindowSize } from "../Hooks/window-size"; @@ -12,18 +17,23 @@ function Login() { useSetLogin({ code }); } const dimension = useWindowSize(); - const {pathname} = useLocation() + const { pathname } = useLocation(); return ( <> - {dimension.width>1000? -
- - {pathname=='/login'? : } - -
-
: - - } + {dimension.width > 1000 ? ( +
+ + {pathname == "/login" ? ( + + ) : ( + + )} + +
+
+ ) : ( + + )} ); } diff --git a/Frontend/src/Pages/MainRoute.tsx b/Frontend/src/Pages/MainRoute.tsx index 8f9cd1e..3306416 100644 --- a/Frontend/src/Pages/MainRoute.tsx +++ b/Frontend/src/Pages/MainRoute.tsx @@ -1,5 +1,5 @@ import { useEffect, useRef } from "react"; -import { Navigate, Outlet, } from "react-router-dom"; +import { Navigate, Outlet } from "react-router-dom"; import { useGetChannels } from "../Hooks/Channel-hook"; import { useSetRecoilState } from "recoil"; import { ChannelArray, RoleArray, UserData } from "../Atoms/State"; @@ -8,32 +8,32 @@ import { useGetRoles } from "../Hooks/Roles-hook"; import axios from "axios"; -export const MainRoute=()=>{ - const guild= window.localStorage.getItem('guild_id'); - const id = window.localStorage.getItem('id'); - const setUser = useSetRecoilState(UserData) - const setChannels= useSetRecoilState(ChannelArray) - const setRole = useSetRecoilState(RoleArray); - const EffectRan = useRef(false); - - useEffect(()=>{ - if(!EffectRan.current && guild!=null){ - const useFetchData = async ()=>{ - const Data = await axios.get( - `${import.meta.env.VITE_IP}available_users?user_id=${id}` - ); - setUser(Data.data) - const ChannelArray = await useGetChannels(); - const RoleArray = await useGetRoles(); - setRole(RoleArray) - setChannels(ChannelArray); - } - useFetchData() - return ()=>{ - EffectRan.current=true; - } - } - // eslint-disable-next-line react-hooks/exhaustive-deps - },[id]) - return guild?: - } \ No newline at end of file +export const MainRoute = () => { + const guild = window.localStorage.getItem("guild_id"); + const id = window.localStorage.getItem("id"); + const setUser = useSetRecoilState(UserData); + const setChannels = useSetRecoilState(ChannelArray); + const setRole = useSetRecoilState(RoleArray); + const EffectRan = useRef(false); + + useEffect(() => { + if (!EffectRan.current && guild != null) { + const useFetchData = async () => { + const Data = await axios.get( + `${import.meta.env.VITE_IP}available_users?user_id=${id}`, + ); + setUser(Data.data); + const ChannelArray = await useGetChannels(); + const RoleArray = await useGetRoles(); + setRole(RoleArray); + setChannels(ChannelArray); + }; + useFetchData(); + return () => { + EffectRan.current = true; + }; + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [id]); + return guild ? : ; +}; diff --git a/Frontend/src/Pages/Moderation.tsx b/Frontend/src/Pages/Moderation.tsx index 502c8ad..f784f25 100644 --- a/Frontend/src/Pages/Moderation.tsx +++ b/Frontend/src/Pages/Moderation.tsx @@ -5,47 +5,56 @@ import { useRecoilState } from "recoil"; import { ModerationPath } from "../Atoms/State"; function Moderation(): JSX.Element { - const DesiredRoute = "/moderation/message-type"; - const [modePathValue,setModePathValue] = useRecoilState(ModerationPath); - if(modePathValue === DesiredRoute){ + const [modePathValue, setModePathValue] = useRecoilState(ModerationPath); + if (modePathValue === DesiredRoute) { return ( -
-
- {setModePathValue("/moderation")}}> - - - -
- +
+
+ { + setModePathValue("/moderation"); + }} + > + + +
- ) - } - + +
+ ); + } + return (
- +
- {setModePathValue("/moderation/message-type")}} > -
- - - - -
-

Message type

-

- Select the type of Messages for a channel (Image or Text) -

-
+ { + setModePathValue("/moderation/message-type"); + }} + > +
+ + + + +
+

Message type

+

+ Select the type of Messages for a channel (Image or Text) +

- +
+
); } diff --git a/Frontend/src/Pages/Notifications.tsx b/Frontend/src/Pages/Notifications.tsx index 138ba95..79bc505 100644 --- a/Frontend/src/Pages/Notifications.tsx +++ b/Frontend/src/Pages/Notifications.tsx @@ -2,7 +2,12 @@ import { useEffect, useRef, useState } from "react"; import Heading from "../Components/Heading"; import YT from "../Resources/images/YT.png"; import { MenuDropdown } from "../Components/MenuDropdown"; -import { useGetYoutubeChannel, useRemoveChannel, useSetYoutubeCreatorChannel, useYtChannelSet } from "../Hooks/Youtube-Notification"; +import { + useGetYoutubeChannel, + useRemoveChannel, + useSetYoutubeCreatorChannel, + useYtChannelSet, +} from "../Hooks/Youtube-Notification"; function Notifications(): JSX.Element { return ( @@ -18,48 +23,54 @@ function Notifications(): JSX.Element {
-
Subscribed Channel List
- +
+ Subscribed Channel List +
+
); } -const SubscribedChannelList = ()=>{ - const [channels,setChannels]=useState([]); - const EffectRan= useRef(false) - useEffect(()=>{ - if(EffectRan.current===false){ - const useFetchData = async()=>{ +const SubscribedChannelList = () => { + const [channels, setChannels] = useState([]); + const EffectRan = useRef(false); + useEffect(() => { + if (EffectRan.current === false) { + const useFetchData = async () => { const response = await useGetYoutubeChannel(); - setChannels(response) - EffectRan.current=true - } + setChannels(response); + EffectRan.current = true; + }; useFetchData(); } - return ()=>{ - EffectRan.current=true - } - - },[]) + return () => { + EffectRan.current = true; + }; + }, []); - return
- {channels.map((item,key)=>( -
-
{key + 1}
-
{item}
-
- )) } -
-} -const RemoveChannel = ()=>{ + return ( +
+ {channels.map((item, key) => ( +
+
{key + 1}
+
{item}
+
+ ))} +
+ ); +}; +const RemoveChannel = () => { const [channel, SetChannel] = useState(""); const useHandleSubmit = async () => { - if(channel){ - const response = await useRemoveChannel({channel}); + if (channel) { + const response = await useRemoveChannel({ channel }); alert(response.message); } }; - return( + return (
{/* TopBar */}
@@ -92,19 +103,24 @@ const RemoveChannel = ()=>{
- ) -} + ); +}; export function NotificationPopUp(): JSX.Element { const [channel, SetChannel] = useState(""); - - + const [value, setValue] = useState(); const guild_id = window.localStorage.getItem("guild_id") as string; const useHandleSubmit = async () => { - if(value){ - const response = await useYtChannelSet({guild_id,channel_id:value as string}); - const ChannelSetResponse = await useSetYoutubeCreatorChannel({guild_id,yt_Channel_name:channel}); - if(response && ChannelSetResponse){ + if (value) { + const response = await useYtChannelSet({ + guild_id, + channel_id: value as string, + }); + const ChannelSetResponse = await useSetYoutubeCreatorChannel({ + guild_id, + yt_Channel_name: channel, + }); + if (response && ChannelSetResponse) { alert("Channel Added Successfully"); } } @@ -112,7 +128,7 @@ export function NotificationPopUp(): JSX.Element { const handleChange = (e: React.ChangeEvent) => { setValue(e.target.value); }; - return ( + return (
{/* TopBar */}
@@ -126,7 +142,7 @@ export function NotificationPopUp(): JSX.Element { Enter the Youtube Channel ID.
- +
diff --git a/Frontend/src/Pages/ProtectedRoute.tsx b/Frontend/src/Pages/ProtectedRoute.tsx index 79ca31a..d038169 100644 --- a/Frontend/src/Pages/ProtectedRoute.tsx +++ b/Frontend/src/Pages/ProtectedRoute.tsx @@ -1,9 +1,8 @@ - -import { Navigate, Outlet} from "react-router-dom"; +import { Navigate, Outlet } from "react-router-dom"; function ProtectedRoute() { - const code : string | null = window.localStorage.getItem("code"); - return
{ code ? : }
; + const code: string | null = window.localStorage.getItem("code"); + return
{code ? : }
; } export default ProtectedRoute; diff --git a/Frontend/src/Pages/ReactionRoles.tsx b/Frontend/src/Pages/ReactionRoles.tsx index d1af3e3..c066bfc 100644 --- a/Frontend/src/Pages/ReactionRoles.tsx +++ b/Frontend/src/Pages/ReactionRoles.tsx @@ -1,52 +1,72 @@ -import React, { useState } from "react" -import Heading from "../Components/Heading" +import React, { useState } from "react"; +import Heading from "../Components/Heading"; import { useRecoilValue } from "recoil"; import { RoleArray } from "../Atoms/State"; import { MenuDropdown } from "../Components/MenuDropdown"; import { SubmitButton } from "../Components/Button"; import { useSetJoinMemberRole } from "../Hooks/Roles-hook"; -function ReactionRoles():JSX.Element { +function ReactionRoles(): JSX.Element { const roles = useRecoilValue(RoleArray); const [roleId, setroleId] = useState(""); - const [channelid,setChannelid] = useState(""); + const [channelid, setChannelid] = useState(""); - - const handleChange = (e:React.ChangeEvent) => { + const handleChange = (e: React.ChangeEvent) => { setroleId(e.target.value); }; - const handleChangeChannel = (e:React.ChangeEvent) => { - setChannelid(e.target.value); + const handleChangeChannel = (e: React.ChangeEvent) => { + setChannelid(e.target.value); }; - const useHandleSubmit = async ()=>{ - if(roleId && channelid){ - const response = await useSetJoinMemberRole({channel_id:channelid,role_id:roleId}) - alert(response.role_name + ' is Set'); + const useHandleSubmit = async () => { + if (roleId && channelid) { + const response = await useSetJoinMemberRole({ + channel_id: channelid, + role_id: roleId, + }); + alert(response.role_name + " is Set"); } - } + }; return ( - -
- -
-
-
Reaction Role
-
- On Reacting to the Emoji Roles will be Assigned to the Member -
-
- - -
-
- - -
- +
+ +
+
+
Reaction Role
+
+ On Reacting to the Emoji Roles will be Assigned to the Member +
+
+ + +
+
+ +
+
- ); +
+ ); } -export default ReactionRoles \ No newline at end of file +export default ReactionRoles; diff --git a/Frontend/src/Pages/ServerlistPage.tsx b/Frontend/src/Pages/ServerlistPage.tsx index af6ecd0..b5112b3 100644 --- a/Frontend/src/Pages/ServerlistPage.tsx +++ b/Frontend/src/Pages/ServerlistPage.tsx @@ -1,9 +1,9 @@ import Navbar from "../Components/Navbar"; import { ServerlistComponent } from "../Components/ServerlistComponent"; -import {useGetData } from "../Hooks/Login-hook"; +import { useGetData } from "../Hooks/Login-hook"; export const ServerlistPage = () => { - const id = useGetData() + const id = useGetData(); const flag = window.localStorage.getItem("id"); return (
@@ -12,7 +12,7 @@ export const ServerlistPage = () => {
{id || flag ? (
- +
) : (
@@ -22,4 +22,3 @@ export const ServerlistPage = () => {
); }; - diff --git a/Frontend/src/Pages/Status.tsx b/Frontend/src/Pages/Status.tsx index 96545d7..0783806 100644 --- a/Frontend/src/Pages/Status.tsx +++ b/Frontend/src/Pages/Status.tsx @@ -1,56 +1,91 @@ import Heading from "../Components/Heading"; import { useState } from "react"; -import { useChangeStatusImageChannel, useChangeStatusLevelSystem, useChangeStatusLinkChannel, useChangeStatusMessage, useChangeStatusSocialNotification, useChangeStatusleaveMessage } from "../Hooks/Status-hook"; +import { + useChangeStatusImageChannel, + useChangeStatusLevelSystem, + useChangeStatusLinkChannel, + useChangeStatusMessage, + useChangeStatusSocialNotification, + useChangeStatusleaveMessage, +} from "../Hooks/Status-hook"; import { StatusCardBox } from "../Components/StatusCardBox"; function Settings_general(): JSX.Element { - const [welcome,setWelcome] = useState(false); - const [leave,setLeave] = useState(false); - const [level,setLevel] = useState(false) - const [notification,setnotification] = useState(false) - const [image,setImage] = useState(false) - const [Link,setLink] = useState(false) + const [welcome, setWelcome] = useState(false); + const [leave, setLeave] = useState(false); + const [level, setLevel] = useState(false); + const [notification, setnotification] = useState(false); + const [image, setImage] = useState(false); + const [Link, setLink] = useState(false); - const useHandleChangeWelcomeMessage = async ()=>{ + const useHandleChangeWelcomeMessage = async () => { await setWelcome(!welcome); - await useChangeStatusMessage({bool:!welcome}) - } - const useHandleChangeLeaveMessage = async ()=>{ - await setLeave(!leave) - await useChangeStatusleaveMessage({bool:!leave}) - } - const useHandleChangeLevelSystem = async ()=>{ - await setLevel(!level) - await useChangeStatusLevelSystem({bool:!level}) - } - const useHandleChangeNotificationSetup= async()=>{ - await setnotification(!notification) - await useChangeStatusSocialNotification({bool:!notification}) - } - const useHandleChangeImageStatus=async()=>{ - await setImage(!image) - await useChangeStatusImageChannel({bool:!image}) - } - const useHandleChangeLinkStatus=async()=>{ - await setLink(!Link) - await useChangeStatusLinkChannel({bool:!Link}) - } + await useChangeStatusMessage({ bool: !welcome }); + }; + const useHandleChangeLeaveMessage = async () => { + await setLeave(!leave); + await useChangeStatusleaveMessage({ bool: !leave }); + }; + const useHandleChangeLevelSystem = async () => { + await setLevel(!level); + await useChangeStatusLevelSystem({ bool: !level }); + }; + const useHandleChangeNotificationSetup = async () => { + await setnotification(!notification); + await useChangeStatusSocialNotification({ bool: !notification }); + }; + const useHandleChangeImageStatus = async () => { + await setImage(!image); + await useChangeStatusImageChannel({ bool: !image }); + }; + const useHandleChangeLinkStatus = async () => { + await setLink(!Link); + await useChangeStatusLinkChannel({ bool: !Link }); + }; return (
- - - - - - + + + + + +
); } - - export default Settings_general; diff --git a/Frontend/src/Pages/WelcomeMes.tsx b/Frontend/src/Pages/WelcomeMes.tsx index b656238..9b790d5 100644 --- a/Frontend/src/Pages/WelcomeMes.tsx +++ b/Frontend/src/Pages/WelcomeMes.tsx @@ -1,4 +1,4 @@ -import {useState } from "react"; +import { useState } from "react"; import Heading from "../Components/Heading"; import { useSelectChannel, useSetWelcomeMessage } from "../Hooks/Message-Hook"; import { SubmitButton } from "../Components/Button"; @@ -10,20 +10,25 @@ const defaultText = function WelcomeMes(): JSX.Element { const [message, setMessage] = useState(defaultText); - const [value, setValue] = useState(); + const [value, setValue] = useState(); const ChannelArrays = useRecoilValue(ChannelArray); const useHandleSubmit = async () => { if (value) { - const response = await useSetWelcomeMessage({message}); - const responseChannel= await useSelectChannel({guild_id:window.localStorage.getItem('guild_id') as string, channel_id:value as string}) - - if(response && responseChannel){ - alert("Welcome Message Updated on " + `"${ChannelArrays?.find((channel)=>channel.id===value)?.channel}" Channel`) + const response = await useSetWelcomeMessage({ message }); + const responseChannel = await useSelectChannel({ + guild_id: window.localStorage.getItem("guild_id") as string, + channel_id: value as string, + }); + + if (response && responseChannel) { + alert( + "Welcome Message Updated on " + + `"${ChannelArrays?.find((channel) => channel.id === value)?.channel}" Channel`, + ); } - } - else{ - alert("Please select a channel") + } else { + alert("Please select a channel"); } }; const handleChange = (e: React.ChangeEvent) => { @@ -40,7 +45,7 @@ function WelcomeMes(): JSX.Element {
- +
- - +
); } export default WelcomeMes; - - diff --git a/Frontend/src/Resources/Data.tsx b/Frontend/src/Resources/Data.tsx index b0ff97b..9709185 100644 --- a/Frontend/src/Resources/Data.tsx +++ b/Frontend/src/Resources/Data.tsx @@ -1,80 +1,77 @@ -import img1 from "../Resources/images/IconSetting.png" -import img2 from "../Resources/images/IconCommand.png" -import img3 from "../Resources/images/IconChat.png" -import img4 from "../Resources/images/IconBranding.png" +import img1 from "../Resources/images/IconSetting.png"; +import img2 from "../Resources/images/IconCommand.png"; +import img3 from "../Resources/images/IconChat.png"; +import img4 from "../Resources/images/IconBranding.png"; -import img5 from "../Resources/images/IconAutoModeration.png" -import img7 from "../Resources/images/IconNotification.png" -import img8 from "../Resources/images/IconRoles.png" -import img9 from "../Resources/images/IconReactionRole.png" -import img10 from "../Resources/images/IconWelcomeMessage.png" -import img11 from "../Resources/images/IconLogging.png" +import img5 from "../Resources/images/IconAutoModeration.png"; +import img7 from "../Resources/images/IconNotification.png"; +import img8 from "../Resources/images/IconRoles.png"; +import img9 from "../Resources/images/IconReactionRole.png"; +import img10 from "../Resources/images/IconWelcomeMessage.png"; +import img11 from "../Resources/images/IconLogging.png"; export const DataSidebar = [ - { - name:"Status", - img:img1, - route:'/status' - }, - { - name:"Commands", - img:img2, - route:'/commands' - }, - { - name:"Channel Content", - img:img3, - route:'/Channel-content' - }, - { - name:"Custom Branding", - img:img4, - route:'/branding' - }, -] + { + name: "Status", + img: img1, + route: "/status", + }, + { + name: "Commands", + img: img2, + route: "/commands", + }, + { + name: "Channel Content", + img: img3, + route: "/Channel-content", + }, + { + name: "Custom Branding", + img: img4, + route: "/branding", + }, +]; export const Modules = [ - { - name:"Welcome Message", - img:img10, - route:'/welcome-message' - }, - { - name:"Leave Message", - img:img10, - route:'/leave-message' - }, - { - name:"Levels", - img:img5, - route:'/level-setup' - }, - // { - // name:"Moderation", - // img:img6, - // route:'/moderation' - // }, - { - name:"Social Notifications", - img:img7, - route:'/notification' - }, - { - name:"Join Roles", - img:img8, - route:'/join-roles' - }, - { - name:"Reaction Roles", - img:img9, - route:'/reaction-roles' - }, - { - name:"Logging", - img:img11, - route:'/logging' - } - - -] - + { + name: "Welcome Message", + img: img10, + route: "/welcome-message", + }, + { + name: "Leave Message", + img: img10, + route: "/leave-message", + }, + { + name: "Levels", + img: img5, + route: "/level-setup", + }, + // { + // name:"Moderation", + // img:img6, + // route:'/moderation' + // }, + { + name: "Social Notifications", + img: img7, + route: "/notification", + }, + { + name: "Join Roles", + img: img8, + route: "/join-roles", + }, + { + name: "Reaction Roles", + img: img9, + route: "/reaction-roles", + }, + { + name: "Logging", + img: img11, + route: "/logging", + }, +]; diff --git a/Frontend/src/Resources/Svg/SVG.tsx b/Frontend/src/Resources/Svg/SVG.tsx index aba2862..05f6636 100644 --- a/Frontend/src/Resources/Svg/SVG.tsx +++ b/Frontend/src/Resources/Svg/SVG.tsx @@ -44,8 +44,12 @@ export const LinkedIn = () => { }; export const Github = () => { return ( - + - ) -} -// export const \ No newline at end of file +export const X = () => { + return ( + + + + ); +}; +// export const diff --git a/Frontend/src/main.tsx b/Frontend/src/main.tsx index 9bdf324..7f00d2c 100644 --- a/Frontend/src/main.tsx +++ b/Frontend/src/main.tsx @@ -29,12 +29,12 @@ const router = createBrowserRouter([ { path: "/", element: , - errorElement:, + errorElement: , children: [ { path: "", element: , - errorElement:, + errorElement: , children: [ { path: "", @@ -112,18 +112,20 @@ const router = createBrowserRouter([ { path: "/login", element: , - children:[ + children: [ + { + path: "home", + element: , + }, { - path:'home', - element: - },{ - path:'about-us', - element: - },{ - path:'contact-us', - element: - } - ] + path: "about-us", + element: , + }, + { + path: "contact-us", + element: , + }, + ], }, ]); ReactDOM.createRoot(document.getElementById("root")!).render( @@ -131,5 +133,5 @@ ReactDOM.createRoot(document.getElementById("root")!).render( - + , ); diff --git a/Frontend/vite.config.ts b/Frontend/vite.config.ts index 5a33944..9cc50ea 100644 --- a/Frontend/vite.config.ts +++ b/Frontend/vite.config.ts @@ -1,7 +1,7 @@ -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], -}) +}); From c49e8acc8b4e34e201c4d56b94148108fe273eb0 Mon Sep 17 00:00:00 2001 From: Yash Patel <109963122+PatelYash7@users.noreply.github.com> Date: Mon, 24 Jun 2024 12:25:37 +0530 Subject: [PATCH 4/4] updated the checks on pull_request --- .github/workflows/Frontend-deploy.yml | 80 +++++++++++++++++---------- 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/.github/workflows/Frontend-deploy.yml b/.github/workflows/Frontend-deploy.yml index 8727040..8b779fb 100644 --- a/.github/workflows/Frontend-deploy.yml +++ b/.github/workflows/Frontend-deploy.yml @@ -1,43 +1,65 @@ on: push: branches: - - Deployment-branch - - release/* - + - Deployment-branch + - release/* + pull_request: + branches: + - main + defaults: - run: - working-directory: ./Frontend + run: + working-directory: ./Frontend env: VITE_DISCORD_AUTH: ${{ secrets.VITE_DISCORD_AUTH }} VITE_IP: ${{ secrets.VITE_IP }} VITE_LOGOUT_URI: ${{ secrets.VITE_LOGOUT_URI }} VITE_GITHUB_URI: ${{ secrets.VITE_GITHUB_URI }} - + jobs: build: + if: github.event_name == 'push' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '20.x' + + - name: Install dependencies + run: npm install + + - name: Build the project + run: npm run build + + - name: Deploy to Server + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + SSH_HOST: ${{ secrets.SSH_HOST }} + SSH_USERNAME: ${{ secrets.SSH_USERNAME }} + run: | + echo "$SSH_PRIVATE_KEY" > private_key + chmod 600 private_key + rsync -avz -e "ssh -i private_key -o StrictHostKeyChecking=no" dist/. $SSH_USERNAME@$SSH_HOST:/www/wwwroot/TechTOnions_Bot/Frontend/ + + format: + if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '20.x' - - - name: Install dependencies - run: npm install - - - name: Build the project - run: npm run build - - - name: Deploy to Server - env: - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} - SSH_HOST: ${{ secrets.SSH_HOST }} - SSH_USERNAME: ${{ secrets.SSH_USERNAME }} - run: | - echo "$SSH_PRIVATE_KEY" > private_key - chmod 600 private_key - rsync -avz -e "ssh -i private_key -o StrictHostKeyChecking=no" dist/. $SSH_USERNAME@$SSH_HOST:/www/wwwroot/TechTOnions_Bot/Frontend/ + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '20.x' + + - name: Install dependencies + run: npm install + + - name: Format code + run: npm run format \ No newline at end of file