Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS migration #96

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a050da3
chore: converts into tsx from jsx and added typs in some files
mohitvermax Aug 1, 2024
5f43232
fix: fixes closing of dropdown on selecting a project and added types
mohitvermax Aug 1, 2024
b5065d2
chore:userContext.js Done
kitretsu2809 Aug 2, 2024
ad09388
chore:components,context,pages Done
kitretsu2809 Aug 3, 2024
5c322dd
rfac: added typescript
mohitvermax Aug 3, 2024
d5bd604
chore:hooks done
kitretsu2809 Aug 3, 2024
41a90f8
resolved merge conflicts
kitretsu2809 Aug 3, 2024
2bc1b5e
resolved merge conflicts
kitretsu2809 Aug 3, 2024
035962f
Final commit
kitretsu2809 Aug 10, 2024
63a5d26
chore:Collected Interfeces and Modified FC
kitretsu2809 Aug 15, 2024
c2adcd2
chore:context,hooks,pages,api,utils declared seperately interfaces
kitretsu2809 Aug 15, 2024
d18c520
fix:chat_bot and websocket
kitretsu2809 Aug 15, 2024
f7761c3
fix:websocket
kitretsu2809 Aug 15, 2024
3ad70ff
Fix:errors fixed
kitretsu2809 Aug 16, 2024
fa9ee50
fix:WebSocket Issue
kitretsu2809 Aug 18, 2024
2d30b9e
fix:db localhost was changed
kitretsu2809 Aug 18, 2024
22f6503
fix: url-builder updated:
kitretsu2809 Aug 20, 2024
45d81e0
merge: with kitretsu
kitretsu2809 Aug 20, 2024
870ddd0
Fix:more fixes
kitretsu2809 Sep 1, 2024
e0964e7
Fix:more fixes
kitretsu2809 Sep 24, 2024
0e79cd3
Fix:more fixes
kitretsu2809 Sep 24, 2024
5b97a78
Fix:more fixes
kitretsu2809 Sep 24, 2024
de01a41
Fix:more fixes
kitretsu2809 Sep 24, 2024
e6f3161
Fix:more fixes
kitretsu2809 Sep 24, 2024
20414f0
Fix:NavigateToLogin Fixed
kitretsu2809 Sep 27, 2024
9af4f13
Update comments for clarity and consistency in code
kitretsu2809 Sep 29, 2024
365e743
useWebSocketForChatBot Errors fixed
kitretsu2809 Sep 29, 2024
3b2b92a
Fix:Uncommented useLeavechat
kitretsu2809 Sep 30, 2024
0993bc7
rfac: revert all backend changes
Aaditya-G Oct 25, 2024
09a1d53
Fix:topicDorpdown and channelswitching
kitretsu2809 Oct 26, 2024
c2a34a5
Merge branch 'feat/typescript' of https://github.com/mdgspace/echofy …
kitretsu2809 Oct 26, 2024
1976638
Fix:index.tsx redirect props
kitretsu2809 Oct 26, 2024
b3a29bd
chore: remove debug console logs
kitretsu2809 Oct 27, 2024
9e830f3
chore:ChatBotButton Disabled
kitretsu2809 Oct 29, 2024
b933b7f
Revert "chore:ChatBotButton Disabled"
kitretsu2809 Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore: converts into tsx from jsx and added typs in some files
mohitvermax committed Aug 1, 2024
commit a050da3135b14754c7a4a98ebf2ee9e5454ebe67
2 changes: 1 addition & 1 deletion backend/db/client.go
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ func Init() {
func redisInit(portNumber, dbNumber int, password string) {
ctx = context.Background()
redisClient = redis.NewClient(&redis.Options{
Addr: fmt.Sprintf("redis:%v", portNumber), //port number can be changed as per our wish
Addr: fmt.Sprintf("localhost:%v", portNumber), //port number can be changed as per our wish
Password: password,
DB: dbNumber,
})
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { useState, useRef } from "react";
import sendLogo from "../../assets/send.svg";
import Image from "next/image";
export default function ChatInputBox({ socketRef }) {
const [newMessage, setNewMessage] = useState("");
const [isTimeout, setIsTimeout] = useState(false);
const messageTimesRef = useRef([]);

function handleInputChange(event) {
setNewMessage(event.target.value);
interface ChatInputBoxProps {
socketRef: React.MutableRefObject<WebSocket | null>;
}

export default function ChatInputBox({ socketRef }:ChatInputBoxProps) {
const [newMessage, setNewMessage] = useState<string>("");
const [isTimeout, setIsTimeout] = useState<boolean>(false);
const messageTimesRef = useRef<number[]>([]);

function handleInputChange(event:any) {
setNewMessage(event.target.value);
}

function handleSendClick() {
@@ -23,7 +28,7 @@ export default function ChatInputBox({ socketRef }) {
}
}

function handleKeyPress(event) {
function handleKeyPress(event: any) {
if (event.key === "Enter") {
handleSendClick();
}
Original file line number Diff line number Diff line change
@@ -6,24 +6,29 @@ import setSessionUser from "../../utils/session/setSessionUser";
import removeSessionUserId from "../../utils/session/removeSessionUserId";
import checkAndPromptSessionChange from "../../utils/alerts/checkAndPromptSessionChange";

const LoginModal = ({ onClose, redirect }) => {
const popupRef = useRef();
const [username, setUsername] = useState("");
interface LoginModalProps{
onClose: ()=>void;
redirect:string;
}

const LoginModal = ({ onClose, redirect }: LoginModalProps) => {
const popupRef = useRef<HTMLDivElement | null>(null);
const [username, setUsername] = useState<string>("");
const router = useRouter();

function handleUsernameChange(event) {
function handleUsernameChange(event: React.ChangeEvent<HTMLInputElement>) {
setUsername(event.target.value);
}

function handleEnterClick(event) {
function handleEnterClick(event: React.KeyboardEvent<HTMLInputElement>) {
if (event.key === "Enter") {
handleChatWithUsClick();
}
}

useEffect(() => {
function handleClickOutside(event) {
if (popupRef.current && !popupRef.current.contains(event.target)) {
function handleClickOutside(event : MouseEvent) {
if (popupRef.current && !popupRef.current.contains(event.target as Node)) {
onClose();
}
}
@@ -37,6 +42,9 @@ const LoginModal = ({ onClose, redirect }) => {
const currentUser = getSessionUser();
const currentUserId = getSessionUserId();
const query={channel:chatType};



if (currentUser && currentUserId) {
if (currentUser === username) {
router.push({pathname:'/chat',query});
@@ -79,7 +87,7 @@ const LoginModal = ({ onClose, redirect }) => {
/>
</div>
<div
className="rounded-full bg-customBlue text-white text-Lato p-2 max-sm:text-xs text-center w-60 rounded-[12.5rem] text-md"
className="rounded-full bg-customBlue text-white text-Lato p-2 max-sm:text-xs text-center w-60 text-md"
onClick={handleChatWithUsClick}
>
CHAT WITH US
File renamed without changes.
18 changes: 12 additions & 6 deletions frontend/components/mail.jsx → frontend/components/mail.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import React from "react";
import React, { useEffect, useRef } from "react";
import { useState } from "react";
import subscribe from "../services/api/subscribeApi";
import getSessionUser from "../utils/session/getSessionUser";
import getSessionUserId from "../utils/session/getSessionUserId";


interface MailProps{
isOpen?:boolean;
onClose: () => void;
channel: string;
}
export default function Mail({
isOpen,
onClose,
channel,
}) {
const [email, setEmail] = useState("");
const popupRef = React.useRef();
} : MailProps) {
const [email, setEmail] = useState<string>("");
const popupRef = useRef<HTMLDivElement | null>(null);

const handleSubmit = async (e) => {
const handleSubmit = async (e:any) => {
let userId = getSessionUserId();
let username = getSessionUser();
e.preventDefault();
@@ -24,7 +30,7 @@ export default function Mail({
}
};

React.useEffect(() => {
useEffect(() => {
function handleClickOutside(event) {
if (popupRef.current && !popupRef.current.contains(event.target)) {
onClose();
Original file line number Diff line number Diff line change
@@ -5,7 +5,11 @@ import { useRouter } from "next/router";
import { fetchProjects } from "../services/api/projectsApi";
import { ProjectList } from "./projects/projectList";

export default function Box({ channel }) {
interface BoxProps {
channel: string;
}

export default function Box({ channel }: BoxProps) {
const router = useRouter();
const arr = ["public", "private", "chatbot"];
const newArr = arr.filter((item) => item !== channel);
@@ -51,7 +55,7 @@ export default function Box({ channel }) {
}
};
const [topic, setTopic] = useState(" ");
const handleDivClick = (e) => {
const handleDivClick = (e: any) => {
const content = e.target.textContent;
setTopic(content);
router.push({
File renamed without changes.
17 changes: 11 additions & 6 deletions frontend/components/navbar.jsx → frontend/components/navbar.tsx
Original file line number Diff line number Diff line change
@@ -6,12 +6,17 @@ import jinoraLogo from "../assets/logo.svg";
import slack from ".././assets/slack_blue.svg";
import { TopicDropdown } from "./topicDropdown";

export const Navbar = ({ currentPage, currentTopic }) => {
const [isMailOpen, setIsMailOpen] = useState(false);
const [logo, setLogo] = useState(jinoraLogo);
const [leftText, setLeftText] = useState("");
const [toShow, setToShow] = useState(false);
const [topic,setTopic]=useState(currentTopic);
interface NavbarProps{
currentPage: string;
currentTopic:string;
}

export const Navbar = ({ currentPage, currentTopic }: NavbarProps) => {
const [isMailOpen, setIsMailOpen] = useState<boolean>(false);
const [logo, setLogo] = useState<string>(jinoraLogo);
const [leftText, setLeftText] = useState<string>("");
const [toShow, setToShow] = useState<boolean>(false);
const [topic,setTopic]=useState<string>(currentTopic);

function openMail() {
setIsMailOpen(true);
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -8,18 +8,27 @@ import {
MdAudiotrack,
} from "react-icons/md";

interface SettingsPopupProps {
onClose: () => void;
soundEnabled: boolean;
setSoundEnabled: (enabled: boolean) => void;
notificationsEnabled: boolean;
setNotificationsEnabled: (enabled: boolean) => void;
}


const SettingsPopup = ({
onClose,
soundEnabled,
setSoundEnabled,
notificationsEnabled,
setNotificationsEnabled,
}) => {
const popupRef = useRef();
}: SettingsPopupProps) => {
const popupRef = useRef<HTMLDivElement | null>(null);

useEffect(() => {
function handleClickOutside(event) {
if (popupRef.current && !popupRef.current.contains(event.target)) {
if (popupRef.current && !popupRef.current.contains(event.target as Node)) {
onClose();
}
}
Original file line number Diff line number Diff line change
@@ -3,10 +3,28 @@ import React, { useState } from "react";
import { fetchProjects } from "../services/api/projectsApi";
import { useEffect, useRef } from "react";

export const TopicDropdown = ({ topic, setTopic,login }) => {
const popupRef = useRef();
const [isOpen, setIsOpen] = useState(false);
const [projects, setProjects] = useState([]);
interface TopicDropdownProps {
topic: string;
setTopic: (topic: string) => void;
login: boolean;
}

interface Project{
Category: string;
Name: string;
ShortDesc :string;
LongDesc:string;
ImageLink: string;
AppStoreLink: string;
GithubLink: string;
PlayStoreLink: string;
}

export const TopicDropdown = ({ topic, setTopic,login }:TopicDropdownProps) => {
const popupRef = useRef<HTMLDivElement | null>(null);
const [isOpen, setIsOpen] = useState<boolean>(false);
const [projects, setProjects] = useState<Project[]>([]);

const projectList = projects.filter(
(project) => project.Category === "Projects",
);
@@ -16,7 +34,7 @@ export const TopicDropdown = ({ topic, setTopic,login }) => {
setIsOpen(!isOpen);
};

const handleClick = (e) => {
const handleClick = (e:any) => {
const content = e.target.textContent;
setTopic(content);
if(!login){
@@ -37,8 +55,8 @@ export const TopicDropdown = ({ topic, setTopic,login }) => {
}, []);

useEffect(() => {
function handleClickOutside(event) {
if (popupRef.current && !popupRef.current.contains(event.target)) {
function handleClickOutside(event: MouseEvent) {
if (popupRef.current && !popupRef.current.contains(event.target as Node)) {
setIsOpen(false);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React from "react";
interface TopicSelectionModalProps{
onClose: () => void;
}

const TopicSelectionModal = ({ onClose }) => {
const TopicSelectionModal = ({ onClose }: TopicSelectionModalProps) => {
return (
<div className="fixed top-0 left-0 w-full h-full bg-gray-800 bg-opacity-50 flex justify-center items-center">
<div className="bg-white p-4 rounded shadow-lg">
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions frontend/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
43 changes: 43 additions & 0 deletions frontend/package-lock.json

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

4 changes: 4 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -24,5 +24,9 @@
"start": "^5.1.0",
"sweetalert2": "^11.10.1",
"tailwindcss": "^3.3.3"
},
"devDependencies": {
"@types/react": "18.3.3",
"typescript": "5.5.4"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions frontend/pages/index.jsx → frontend/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -76,7 +76,7 @@ export default function Home() {
onClick={goToChatbot}
>
<p className="font-Roboto font-medium text-xl tracking-tighter flex gap-2">
<Image src={ChatBot} />
<Image alt={"chat bot"} src={ChatBot} />
TALK TO OUR CHATBOT
</p>
</div>
@@ -85,7 +85,7 @@ export default function Home() {
onClick={goToPrivateChat}
>
<p className="font-Roboto font-medium text-xl tracking-tighter flex gap-2">
<Image src={SlackLogo} className="text-sky-400" />
<Image alt={"slack logo"} src={SlackLogo} className="text-sky-400" />
PRIVATE CHAT ON SLACK
</p>
</div>
@@ -94,7 +94,7 @@ export default function Home() {
onClick={goToPublicChat}
>
<p className="font-Roboto font-medium text-xl tracking-tighter flex gap-2">
<Image src={SlackLogo} />
<Image alt={"slack logo"} src={SlackLogo} />
PUBLIC MDG CHAT FORUM
</p>
</div>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
, "context/userContext.js" ],
"exclude": [
"node_modules"
]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.