Skip to content

Commit

Permalink
Fix : Sonar issues (#74)
Browse files Browse the repository at this point in the history
* renamed interface , removed unused import

* removed unused prop type

* removed unused import

* removed unused import

* useState call is  destructured into value + setter pair

* sonar cloud issue

* removed unused variableand import

* removed keycloak code

* Fix-Sonar issues

* Fix-Sonar issue
  • Loading branch information
vidyaaKhandekar authored Dec 6, 2024
1 parent 3f26590 commit 9bac91d
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 31 deletions.
2 changes: 0 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import guestRoutes from "./routes/GuestRoutes";
import { Suspense, useEffect, useState } from "react";
import Loader from "./components/common/Loader";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
// import { useKeycloak } from "@react-keycloak/web";
import { AuthProvider } from "./utils/context/checkToken";
import "./assets/styles/App.css";
import Layout from "./components/common/layout/Layout";
Expand All @@ -16,7 +15,6 @@ function App() {
{ path: string; component: React.ElementType }[]
>([]);
const token = localStorage.getItem("authToken");
// const { keycloak } = useKeycloak();

useEffect(() => {
if (token) {
Expand Down
4 changes: 0 additions & 4 deletions src/components/ConfirmationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ interface ConfirmationDialogProps {
handleConfirmation: () => Promise<void>;
loading?: boolean;
consentText?: string;
documents?: string[];
}

const ConfirmationDialog: React.FC<ConfirmationDialogProps> = ({
Expand All @@ -38,15 +37,13 @@ const ConfirmationDialog: React.FC<ConfirmationDialogProps> = ({

consentText = consentText || t("CONFIRMATION_DIALOGUE_CONSENT_TEXT");

// Function to call the parent's function
const sendCloseDialog = () => {
closeDialog(false);
};

const openSubmitDialog = async () => {
if (handleConfirmation) {
handleConfirmation();
// navigate("/userprofile");
}
};
const closeSubmitDialog = () => {
Expand Down Expand Up @@ -87,7 +84,6 @@ const ConfirmationDialog: React.FC<ConfirmationDialogProps> = ({
{consentText}
</Text>
<VStack>
{/* need to add new document list as per figma {loading ? <Loader /> : <DocumentList documents={documents} />} */}
{loading ? <Loader /> : <Text>List of documents</Text>}
</VStack>
</ModalBody>
Expand Down
1 change: 0 additions & 1 deletion src/components/WebView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// import axios from "axios";
import { useEffect, useRef } from "react";
import { transformData } from "../utils/jsHelper/helper";
import Layout from "./common/layout/Layout";
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/UserDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from "react";
import React from "react";
import { Box, Text, HStack, VStack } from "@chakra-ui/react";
import { useTranslation } from "react-i18next";
import { formatDate } from "../../utils/jsHelper/helper";
Expand Down
3 changes: 0 additions & 3 deletions src/components/common/input/DisabledInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import { CheckIcon } from "@chakra-ui/icons";
interface CustomSelectProps {
label: string;
placeholder?: string;
width?: string;
height?: string;
border?: string;
}

const CustomDisableInput: React.FC<CustomSelectProps> = ({
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/input/FloatingSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const FloatingSelect: React.FC<FloatingSelectProps> = ({
px={1}
transform={isFocused || value ? "scale(0.85)" : "translateY(-50%)"}
transition="all 0.2s ease-out"
color={isFocused ? "gray.500" : "gray.500"}
color={"gray.500"}
fontSize={isFocused || value ? "17px" : "16px"}
zIndex={100}
pointerEvents="none"
Expand Down
3 changes: 0 additions & 3 deletions src/components/common/layout/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
} from "@chakra-ui/react";
import { HamburgerIcon } from "@chakra-ui/icons";
import CustomSelect from "../input/Select";
// import { useKeycloak } from "@react-keycloak/web";
import { useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { logoutUser } from "../../../services/auth/auth";
Expand All @@ -27,9 +26,7 @@ const Navbar: React.FC<{ isMenu?: boolean }> = ({ isMenu = true }) => {
const navigate = useNavigate();
const { t } = useTranslation();
const toast = useToast();
// const { keycloak } = useKeycloak();
const handleLogout = async () => {
// keycloak.logout({ redirectUri: window.location.origin });
try {
const response = await logoutUser();
if (response) {
Expand Down
18 changes: 9 additions & 9 deletions src/screens/auth/SignUpWithPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const SignUpWithPassword: React.FC = () => {
});
const [confirmPassword, setConfirmPassword] = useState<string>("");
const [loading, setLoading] = useState(false);
// const [isFormValid, setIsFormValid] = useState<boolean>(false);
const [UserName, SetUserName] = useState<string>("");

const [userName, setUserName] = useState<string>("");
const handleBack = () => {
navigate(-1);
};
Expand Down Expand Up @@ -82,7 +82,7 @@ const SignUpWithPassword: React.FC = () => {
// Generate username based on available values
const { firstName, lastName, phoneNumber } = updatedDetails;

SetUserName(
setUserName(
`${firstName?.trim().toLowerCase() || ""}_${
lastName?.charAt(0).toLowerCase() || ""
}_${phoneNumber?.slice(-4) || ""}`
Expand Down Expand Up @@ -152,10 +152,10 @@ const SignUpWithPassword: React.FC = () => {
const { firstName, lastName, phoneNumber } = userDetails;

if (firstName && lastName && phoneNumber.length >= 6) {
const username = `${firstName}_${lastName?.charAt(
0
)}_${phoneNumber?.slice(-4)}`;
SetUserName(username);
const name = `${firstName}_${lastName?.charAt(0)}_${phoneNumber?.slice(
-4
)}`;
setUserName(name);
}
}, [userDetails.firstName, userDetails.lastName, userDetails.phoneNumber]);
const validate = (phoneNumber) => {
Expand Down Expand Up @@ -217,11 +217,11 @@ const SignUpWithPassword: React.FC = () => {
isInvalid={confirmPassword.trim() === ""}
errorMessage={t("SIGNUP_CONFIRM_PASSWORD_IS_REQUIRED")}
/>
{UserName.length > 0 && (
{userName.length > 0 && (
<Text textAlign="center" fontSize="14px" mt={4}>
{"Your username will be "}
<Text as="span" fontWeight="bold" color="#06164B">
{UserName}
{userName}
</Text>
</Text>
)}
Expand Down
2 changes: 0 additions & 2 deletions src/screens/benefit/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Text,
UnorderedList,
ListItem,
useDisclosure,
HStack,
Icon,
Modal,
Expand Down Expand Up @@ -83,7 +82,6 @@ interface WebFormProps {
}

const BenefitsDetails: React.FC = () => {
const { isOpen, onClose } = useDisclosure();
const [context, setContext] = useState<FinancialSupportRequest | null>(null);
const [item, setItem] = useState<BenefitItem | null>(null);
const [loading, setLoading] = useState<boolean>(true);
Expand Down
9 changes: 4 additions & 5 deletions src/services/benefit/benefits.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import axios, { AxiosError } from "axios";
import { getToken } from "../auth/asyncStorage";
import { generateUUID } from "../../utils/jsHelper/helper";
const apiBaseUrl = import.meta.env.VITE_API_BASE_URL;
const bap_id = import.meta.env.VITE_API_BASE_ID;
Expand Down Expand Up @@ -36,10 +35,10 @@ export const getAll = async (userData: {
* Login a user
* @param {Object} loginData - Contains phoneNumber, password
*/
interface getOneParams {
interface GetOneParams {
id: string | undefined;
}
export const getOne = async ({ id }: getOneParams) => {
export const getOne = async ({ id }: GetOneParams) => {
const loginData = {
context: {
domain: "onest:financial-support",
Expand Down Expand Up @@ -207,7 +206,7 @@ export const confirmApplication = async ({
handleError(error);
}
};
interface createApplicationParams {
interface CreateApplicationParams {
user_id: string | undefined;
benefit_id: string | undefined;
benefit_provider_id: string | undefined;
Expand All @@ -217,7 +216,7 @@ interface createApplicationParams {
status: string;
application_data: unknown;
}
export const createApplication = async (data: createApplicationParams) => {
export const createApplication = async (data: CreateApplicationParams) => {
try {
const token = localStorage.getItem("authToken");

Expand Down

0 comments on commit 9bac91d

Please sign in to comment.