From 36596cbb88feab09ed8c103c9d7608f031a8a80b Mon Sep 17 00:00:00 2001 From: Akansha Sakhre Date: Sun, 24 Nov 2024 08:59:44 +0530 Subject: [PATCH] fixes --- src/config/logs.ts | 3 ++- src/config/menu.ts | 2 +- src/containers/Auth/Login/Login.tsx | 10 ++++------ .../Onboarding/Steps/PaymentDetails.tsx | 5 ++++- .../Template/List/HSMList/HSMList.test.tsx | 18 +----------------- 5 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/config/logs.ts b/src/config/logs.ts index ef1bbc050..af24a043b 100644 --- a/src/config/logs.ts +++ b/src/config/logs.ts @@ -8,10 +8,11 @@ const setLogs = (message: any, type: string) => { const userId = getUserSession('id'); let logger: any; + console.log(LOGFLARE_API, LOGFLARE_SOURCE, 'ss'); if (LOGFLARE_API && LOGFLARE_SOURCE) { - const apiKey = LOGFLARE_API; const sourceToken = LOGFLARE_SOURCE; + const apiKey = LOGFLARE_API; // create pino-logflare stream const stream = createWriteStream({ apiKey, diff --git a/src/config/menu.ts b/src/config/menu.ts index cab8516c6..3ca3334d2 100644 --- a/src/config/menu.ts +++ b/src/config/menu.ts @@ -1,5 +1,5 @@ import { organizationHasDynamicRole } from 'common/utils'; -import { ANALYTICS_URL, GLIFIC_DOCS_URL, NEW_UI_BLOG } from 'config'; +import { ANALYTICS_URL, GLIFIC_DOCS_URL } from 'config'; import { getOrganizationServices } from 'services/AuthService'; const allRoles = ['Staff', 'Manager', 'Admin', 'Dynamic', 'Glific_admin']; diff --git a/src/containers/Auth/Login/Login.tsx b/src/containers/Auth/Login/Login.tsx index 6caaa0ead..7ea83dd04 100644 --- a/src/containers/Auth/Login/Login.tsx +++ b/src/containers/Auth/Login/Login.tsx @@ -41,8 +41,7 @@ export const Login = () => { // get the information on current user const [getCurrentUser, { data: userData, error: userError }] = useLazyQuery(GET_CURRENT_USER); - const [getOrganizationServices, { data: organizationServicesData }] = - useLazyQuery(GET_ORGANIZATION_SERVICES); + const [getOrganizationServices, { data: organizationServicesData }] = useLazyQuery(GET_ORGANIZATION_SERVICES); useEffect(() => { if (userData && organizationServicesData) { @@ -59,10 +58,7 @@ export const Login = () => { const userAccessRoles = accessRoles.map((role: any) => role.label); // check for user role none or empty - if ( - (userAccessRoles.includes('None') && userAccessRoles.length === 1) || - userAccessRoles.length === 0 - ) { + if ((userAccessRoles.includes('None') && userAccessRoles.length === 1) || userAccessRoles.length === 0) { accessDenied(); } else { // needed to redirect after login @@ -127,6 +123,8 @@ export const Login = () => { setAuthSession(response.data.data); }) .catch((error) => { + console.log(error); + if (error?.response?.status === 403) { setErrorMessage(error?.response?.data?.error); setAuthError(' '); diff --git a/src/containers/Organization/Onboarding/Steps/PaymentDetails.tsx b/src/containers/Organization/Onboarding/Steps/PaymentDetails.tsx index 80512c1ef..cc342b24e 100644 --- a/src/containers/Organization/Onboarding/Steps/PaymentDetails.tsx +++ b/src/containers/Organization/Onboarding/Steps/PaymentDetails.tsx @@ -32,7 +32,10 @@ export const PaymentDetails = ({ handleStepChange, saveData }: FormStepProps) => designation: Yup.string() .required(t('Designation is required.')) .max(25, t('Please enter not more than 25 characters')), - phone: Yup.string().required(t('Phone number is required.')).min(7, t('Enter a valid phone number.')), + phone: Yup.string() + .required(t('Phone number is required.')) + .min(7, t('Enter a valid phone number.')) + .matches(/^\+\d{1,4}\d{7,15}$/, 'Please enter a valid phone number.'), email: Yup.string().required(t('Email is required.')).email(t('Enter a valid email.')), }); const initialFormValues: any = { diff --git a/src/containers/Template/List/HSMList/HSMList.test.tsx b/src/containers/Template/List/HSMList/HSMList.test.tsx index bffbc02c5..0408464c8 100644 --- a/src/containers/Template/List/HSMList/HSMList.test.tsx +++ b/src/containers/Template/List/HSMList/HSMList.test.tsx @@ -1,4 +1,4 @@ -import { fireEvent, render, screen, waitFor, within } from '@testing-library/react'; +import { render, waitFor } from '@testing-library/react'; import { BrowserRouter as Router } from 'react-router-dom'; import { MockedProvider } from '@apollo/client/testing'; @@ -128,19 +128,3 @@ test('sync api should render notification on error', async () => { expect(setNotification).toHaveBeenCalledWith('Sorry, failed to sync HSM updates.', 'warning'); }); }); - -test.only('', async () => { - render(template()); - - await waitFor(() => { - expect(screen.getByText('Templates')).toBeInTheDocument(); - }); - - fireEvent.mouseDown(screen.getByRole('button')); - - const listbox = within(screen.getByRole('listbox')); - - fireEvent.click(listbox.getByText(/Failed/i)); - - screen.debug(document, Infinity); -});