From b734f02c81254a7872863f0f582eed289bccd580 Mon Sep 17 00:00:00 2001 From: thisisommore Date: Wed, 4 Aug 2021 07:40:24 +0000 Subject: [PATCH] Clean code and remove unused objects --- src/App.tsx | 1 - src/common/api.tsx | 12 +------- .../contribution-page/contribution.tsx | 11 ++++--- .../detailed-post/detailed-post.tsx | 18 ++--------- src/components/do-post/do-post.tsx | 4 +-- src/components/hbox/hbox.tsx | 3 +- src/components/help/follow-post.tsx | 2 +- src/components/landing/landing.module.css | 1 - src/components/landing/landing.tsx | 30 +------------------ src/components/mapbox/mapbox.tsx | 4 +-- src/components/signin/signin.tsx | 3 +- src/components/thankyou/thankyou.tsx | 2 +- 12 files changed, 17 insertions(+), 74 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 346314d..c76e7bc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -9,7 +9,6 @@ import { } from "react-router-dom"; import { Home } from "./components/home/home"; import { Signin } from "./components/signin/signin"; -import { getToken } from "./common/user"; import GuardedRoute from "./components/guardedRoute"; import { DoPost } from "./components/do-post/do-post"; import { FindNeedy } from "./components/find-needy/find-needy"; diff --git a/src/common/api.tsx b/src/common/api.tsx index 5ae9084..10c6057 100644 --- a/src/common/api.tsx +++ b/src/common/api.tsx @@ -1,8 +1,7 @@ import axios from "axios"; import { toast } from "react-toastify"; import { Subject } from "rxjs"; -import { getPositionOfLineAndCharacter } from "typescript"; -import { getPhoneNumber, getToken, getUserId } from "./user"; +import { getToken } from "./user"; const baseURL = axios.create({ baseURL: process.env.REACT_APP_NODEJS_API, }); @@ -46,15 +45,6 @@ baseURL.interceptors.response.use( } ); export type TLatestOperation = "Completed" | "Started" | "Idle"; -interface updateStatus { - postId: string; - latestOperation: TLatestOperation; -} -interface IAuthReqBody { - userId: string; - phoneNumber: string; - token: string; -} interface userDataResponse { name: string; diff --git a/src/components/contribution-page/contribution.tsx b/src/components/contribution-page/contribution.tsx index 3f6bdbf..687dd66 100644 --- a/src/components/contribution-page/contribution.tsx +++ b/src/components/contribution-page/contribution.tsx @@ -1,6 +1,5 @@ -import { group } from "node:console"; import React from "react"; -import { Link,useHistory } from "react-router-dom"; +import { useHistory } from "react-router-dom"; import styles from "./contribution.module.css"; @@ -31,7 +30,7 @@ export function Contribution() {
- +profile pick

@@ -43,7 +42,7 @@ export function Contribution() {

- +profile pick

@@ -55,7 +54,7 @@ export function Contribution() {

- +profile pick

@@ -67,7 +66,7 @@ export function Contribution() {

- +profile pick

diff --git a/src/components/detailed-post/detailed-post.tsx b/src/components/detailed-post/detailed-post.tsx index 43c9681..47edf79 100644 --- a/src/components/detailed-post/detailed-post.tsx +++ b/src/components/detailed-post/detailed-post.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from "react"; -import { Link, RouteProps, useHistory } from "react-router-dom"; +import { RouteProps, useHistory } from "react-router-dom"; import styles from "./detailed-post.module.css"; import { fetchDetailedPost, @@ -9,21 +9,6 @@ import { } from "../../common/api"; import { MapBox } from "../mapbox/mapbox"; import mapboxgl from "mapbox-gl"; -// state = { -// Urls:[ -// {URL:"assets/detailed-post/poor1.jpg"}, -// {URL:"assets/detailed-post/poor2.jpg"}, -// {URL:"assets/detailed-post/poor3.jpg"}, -// ], -// }; -type File = { - URL: string; -}; -type Post = { - Name: string; - Images: string[]; - Description: string; -}; export function DetailedPost(props: RouteProps) { const [name, setName] = useState(""); @@ -80,6 +65,7 @@ export function DetailedPost(props: RouteProps) { profile pic

diff --git a/src/components/do-post/do-post.tsx b/src/components/do-post/do-post.tsx index 688aeb6..2935a20 100644 --- a/src/components/do-post/do-post.tsx +++ b/src/components/do-post/do-post.tsx @@ -1,11 +1,9 @@ -import React, { ChangeEventHandler, useState } from "react"; +import { useState } from "react"; import styles from "./do-post.module.css"; -import axios from "axios"; import { useHistory } from "react-router-dom"; import { MapBox } from "../mapbox/mapbox"; import { dopost } from "../../common/api"; -import { ThemeConsumer } from "react-bootstrap/esm/ThemeProvider"; type TTag = { name: string; diff --git a/src/components/hbox/hbox.tsx b/src/components/hbox/hbox.tsx index dca7d8c..85c98b4 100644 --- a/src/components/hbox/hbox.tsx +++ b/src/components/hbox/hbox.tsx @@ -8,7 +8,7 @@ export class hbox extends React.Component { @@ -23,6 +23,7 @@ export class hbox extends React.Component { height="60px" width="60px" src="assets/detailed-post/profile-pic.png" + alt="profile pic" >
diff --git a/src/components/help/follow-post.tsx b/src/components/help/follow-post.tsx index fe45dc5..3ab1398 100644 --- a/src/components/help/follow-post.tsx +++ b/src/components/help/follow-post.tsx @@ -29,7 +29,7 @@ export function FollowPost(props: RouteProps) { ]); function getIconName(name: string) { - const findIcon = iconTags.find((e) => e.name == name); + const findIcon = iconTags.find((e) => e.name === name); return findIcon?.icon; } function createMarker(post: postDetailResponse) { diff --git a/src/components/landing/landing.module.css b/src/components/landing/landing.module.css index f788f69..033aeee 100644 --- a/src/components/landing/landing.module.css +++ b/src/components/landing/landing.module.css @@ -71,7 +71,6 @@ margin-right: -100%; margin-left: -20vh; - /* margin-left: calc(100vw / 2 - 120vw); */ margin-top: calc(100vh / 1.2 - var(--size)); } .world-needs-your-help p { diff --git a/src/components/landing/landing.tsx b/src/components/landing/landing.tsx index 69b4b4b..ba0fe62 100644 --- a/src/components/landing/landing.tsx +++ b/src/components/landing/landing.tsx @@ -1,29 +1,8 @@ -import React, { CSSProperties } from "react"; -import { createRef } from "react"; +import React from "react"; import { Link } from "react-router-dom"; -import { fromEvent } from "rxjs"; import styles from "./landing.module.css"; export class Landing extends React.Component { - helpinHandsGreenCircleRef = createRef(); - constructor(props: any) { - super(props); - } - setCssVars() { - // TODO: Remove - // this.setState({ - // helpingHandsCircle: { - // eleHeight: this.helpinHandsGreenCircleRef.current?.offsetHeight + "px", - // eleWidth: this.helpinHandsGreenCircleRef.current?.offsetWidth + "px", - // }, - // }); - } - componentDidMount() { - this.setCssVars(); - fromEvent(window, "resize").subscribe((e) => { - this.setCssVars(); - }); - } state = { helpingHandsCircle: { eleWidth: "0px", eleHeight: "0px" }, worldNeedsYourHelpCirle: { eleWidth: "0px", eleHeight: "0px" }, @@ -33,14 +12,7 @@ export class Landing extends React.Component {

Helping diff --git a/src/components/mapbox/mapbox.tsx b/src/components/mapbox/mapbox.tsx index 2bc2547..2f6d521 100644 --- a/src/components/mapbox/mapbox.tsx +++ b/src/components/mapbox/mapbox.tsx @@ -1,5 +1,5 @@ -import mapboxgl, { Marker } from "mapbox-gl"; -import { useEffect, useRef, useState } from "react"; +import mapboxgl from "mapbox-gl"; +import { useEffect, useRef } from "react"; import { getLocation } from "../../common/location"; type Props = { markers?: mapboxgl.Marker[]; diff --git a/src/components/signin/signin.tsx b/src/components/signin/signin.tsx index 2c3eba2..ae22177 100644 --- a/src/components/signin/signin.tsx +++ b/src/components/signin/signin.tsx @@ -2,7 +2,6 @@ import React from "react"; import styles from "./signin.module.css"; import { auth } from "../../Services/Firebase"; import { setPhoneNumber, setToken, setUserId } from "../../common/user"; -import axios from "axios"; import { handleHttpError, signIn, toggleSpinner } from "../../common/api"; export class Signin extends React.Component { state = { @@ -128,7 +127,7 @@ export class Signin extends React.Component { className={styles.next1} onClick={this.onSendotp} disabled={ - !(this.state.name && this.state.phoneNumber.length == 13) + !(this.state.name && this.state.phoneNumber.length === 13) } > {this.state.otpSend?"Resend otp":"Get OTP"} diff --git a/src/components/thankyou/thankyou.tsx b/src/components/thankyou/thankyou.tsx index 7ead071..974a7e0 100644 --- a/src/components/thankyou/thankyou.tsx +++ b/src/components/thankyou/thankyou.tsx @@ -19,7 +19,7 @@ export class Thankyou extends React.Component {

Change the world by being yourself,

- + Keep Helping...