From 461c45bbedd73ea04ee0eae78cfea73f06503bb6 Mon Sep 17 00:00:00 2001 From: AishDani Date: Wed, 9 Oct 2024 11:45:50 +0530 Subject: [PATCH 1/2] refactor:project bugs --- .../DestinationStack/Actions/LoadStacks.tsx | 3 +- ui/src/components/MainHeader/index.tsx | 34 +++++++++++-------- ui/src/components/ProfileHeader/index.tsx | 5 +++ ui/src/components/ProjectsHeader/index.tsx | 6 ++-- ui/src/context/app/app.interface.ts | 8 +++-- ui/src/context/app/app.provider.tsx | 2 +- ui/src/pages/Login/index.tsx | 11 ++++-- ui/src/pages/Projects/index.tsx | 2 +- ui/src/store/slice/authSlice.tsx | 10 ++++-- upload-api/src/config/index.ts | 2 +- 10 files changed, 53 insertions(+), 30 deletions(-) diff --git a/ui/src/components/DestinationStack/Actions/LoadStacks.tsx b/ui/src/components/DestinationStack/Actions/LoadStacks.tsx index adebdcc3..32117df5 100644 --- a/ui/src/components/DestinationStack/Actions/LoadStacks.tsx +++ b/ui/src/components/DestinationStack/Actions/LoadStacks.tsx @@ -192,7 +192,8 @@ const LoadStacks = (props: LoadFileFormatProps) => { (a: IDropDown, b: IDropDown) => new Date(b?.created_at)?.getTime() - new Date(a?.created_at)?.getTime() ); - + console.log("stack array: ", newMigrationData.destination_stack.stackArray, stackArray); + setAllStack(stackArray); //Set selected Stack const selectedStackData = validateArray(stackArray) diff --git a/ui/src/components/MainHeader/index.tsx b/ui/src/components/MainHeader/index.tsx index db86ecb2..5031ca46 100644 --- a/ui/src/components/MainHeader/index.tsx +++ b/ui/src/components/MainHeader/index.tsx @@ -1,6 +1,6 @@ // Libraries import { useEffect, useState } from 'react'; -import { useNavigate, useLocation } from 'react-router-dom'; +import { useNavigate, useLocation, Link } from 'react-router-dom'; import { cbModal, Dropdown, Tooltip} from '@contentstack/venus-components'; import { useDispatch, useSelector } from 'react-redux'; @@ -164,9 +164,9 @@ const MainHeader = () => { {logo?.image?.url ? (
- {/* */} + Contentstack - {/* */} +
) : ( @@ -189,18 +189,22 @@ const MainHeader = () => { {(location.pathname == '/projects' || location.pathname.includes('/projects/')) &&
- , - } - ]} - type="click" - className="Profile_card" - > -
{name}
-
+ + , + } + ]} + type="click" + className="Profile_card" + > +
{name}
+
+ +
+
} diff --git a/ui/src/components/ProfileHeader/index.tsx b/ui/src/components/ProfileHeader/index.tsx index 63c3a941..7b1846a6 100644 --- a/ui/src/components/ProfileHeader/index.tsx +++ b/ui/src/components/ProfileHeader/index.tsx @@ -29,6 +29,11 @@ const ProfileCard = () => {
{user?.first_name} {user?.last_name}
{user?.email}
+ +
Region : {user?.region}
+
+ +
- setSearchText(search?.trim()) + onChange={(search: string) =>{ + setSearchText(search)} } width="large" onClear={true} @@ -37,7 +37,7 @@ const ProjectsHeader = ({ debounceSearch={true} id="search-project-input" version="v2" - disabled={allProject && allProject?.length <= 0 && searchText?.length <= 0} + //disabled={allProject && allProject?.length <= 0 } />
{/* {allProject && allProject?.length > 0 ? ( diff --git a/ui/src/context/app/app.interface.ts b/ui/src/context/app/app.interface.ts index b14c3aba..67329ca2 100644 --- a/ui/src/context/app/app.interface.ts +++ b/ui/src/context/app/app.interface.ts @@ -45,6 +45,7 @@ export interface User { mobile_number: string; country_code: string; organizations: Organization[]; + region:string; } export interface FileDetails { isLocalPath?: boolean; @@ -221,7 +222,7 @@ export interface IAppContext { authToken: string; setAuthToken: (token: string) => void; user: User; - updateUser: (user: User) => void; + setUser: (user: User) => void; organisationsList: IDropDown[]; updateOrganisationsList: (list: IDropDown[]) => void; selectedOrganisation: IDropDown; @@ -264,7 +265,8 @@ export const DEFAULT_USER: User = { last_name: '', mobile_number: '', country_code: '', - organizations: [] + organizations: [], + region:'' }; export const DEFAULT_FILE: IFile = { @@ -413,7 +415,7 @@ export const DEFAULT_APP_CONTEXT: IAppContext = { return; }, user: DEFAULT_USER, - updateUser: function (): void { + setUser: function (): void { return; }, isAuthenticated: false, diff --git a/ui/src/context/app/app.provider.tsx b/ui/src/context/app/app.provider.tsx index d0cf355b..320729c2 100644 --- a/ui/src/context/app/app.provider.tsx +++ b/ui/src/context/app/app.provider.tsx @@ -139,7 +139,7 @@ const AppContextProvider: FC = ({ children }) => { authToken: authToken, setAuthToken: (token: string) => setAuthToken(() => token), user: user, - updateUser: (user: User) => setUser(user), + setUser: (user: User) => setUser(user), isAuthenticated: isAuthenticated, setIsAuthenticated: (flag: boolean) => setIsAuthenticated(flag), newMigrationData: newMigration, diff --git a/ui/src/pages/Login/index.tsx b/ui/src/pages/Login/index.tsx index 060ee5bd..8bc306a1 100644 --- a/ui/src/pages/Login/index.tsx +++ b/ui/src/pages/Login/index.tsx @@ -3,7 +3,7 @@ import { FC,useEffect, useState } from 'react'; import { useNavigate, useLocation } from 'react-router-dom'; import { useDispatch, useSelector } from 'react-redux'; -import { getUserDetails, setAuthToken } from '../../store/slice/authSlice'; +import { getUserDetails, setAuthToken, setUser } from '../../store/slice/authSlice'; import { Button, Field, @@ -36,6 +36,7 @@ import AccountPage from '../../components/AccountPage'; // Styles import './index.scss'; +import { RootState } from '../../store'; const Login: FC = () => { const [data, setData] = useState({}); @@ -56,7 +57,7 @@ const Login: FC = () => { }, []); const { login, two_factor_authentication: twoFactorAuthentication } = data; - + const user = useSelector((state:RootState)=>state?.authentication?.user); const accountData = { heading: data?.heading, subtitle: data?.subtitle, @@ -162,7 +163,11 @@ const Login: FC = () => { authToken: response?.data?.app_token, isAuthenticated: true } - + const userObj = { + ...user, + region : region, + } + dispatch( setUser(userObj)); dispatch(setAuthToken(authenticationObj)); setLoginStates((prev) => ({ ...prev, submitted: true })); diff --git a/ui/src/pages/Projects/index.tsx b/ui/src/pages/Projects/index.tsx index ebfc8d1f..76979842 100644 --- a/ui/src/pages/Projects/index.tsx +++ b/ui/src/pages/Projects/index.tsx @@ -4,7 +4,7 @@ import { PageLayout, EmptyState, Button, Icon, cbModal, StackCardSkeleton} from import { jsonToHtml } from '@contentstack/json-rte-serializer'; import HTMLReactParser from 'html-react-parser'; import { useLocation } from 'react-router-dom'; -import { useDispatch, useSelector } from 'react-redux'; +import {useSelector } from 'react-redux'; // Redux import { RootState } from '../../store'; diff --git a/ui/src/store/slice/authSlice.tsx b/ui/src/store/slice/authSlice.tsx index c57c1fc3..c202891b 100644 --- a/ui/src/store/slice/authSlice.tsx +++ b/ui/src/store/slice/authSlice.tsx @@ -80,7 +80,10 @@ const authSlice = createSlice({ state.isAuthenticated = action?.payload?.isAuthenticated; }, setUser : (state, action) => { - state.user = action?.payload; + state.user = { + ...state.user, + ...action?.payload, + }; }, reInitiliseState: (state) => { state.authToken = ''; @@ -101,7 +104,10 @@ const authSlice = createSlice({ }, extraReducers: (builder) => { builder.addCase(getUserDetails?.fulfilled,(state, action:any)=>{ - state.user = action?.payload?.user; + state.user = { + ...state.user, + ...action.payload.user, + }; state.organisationsList = action?.payload?.organisationsList; state.selectedOrganisation = action?.payload?.selectedOrganisation ; state.isAuthenticated = !isEmptyString(state?.authToken || ''); diff --git a/upload-api/src/config/index.ts b/upload-api/src/config/index.ts index 2ffc1d75..ea7aba8e 100644 --- a/upload-api/src/config/index.ts +++ b/upload-api/src/config/index.ts @@ -12,5 +12,5 @@ export default { bucketName: 'migartion-test', buketKey: 'project/package 45.zip' }, - localPath: '/Users/rohit/Desktop/package 45.zip' + localPath: '/Users/aishwarya.dani/Downloads/package 45.zip' }; From 5f105905c62afc4276353088ccc6f2184bf77700 Mon Sep 17 00:00:00 2001 From: AishDani Date: Wed, 9 Oct 2024 11:53:38 +0530 Subject: [PATCH 2/2] refactor:removed console --- ui/src/components/DestinationStack/Actions/LoadStacks.tsx | 1 - upload-api/src/config/index.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/src/components/DestinationStack/Actions/LoadStacks.tsx b/ui/src/components/DestinationStack/Actions/LoadStacks.tsx index 32117df5..157f1b48 100644 --- a/ui/src/components/DestinationStack/Actions/LoadStacks.tsx +++ b/ui/src/components/DestinationStack/Actions/LoadStacks.tsx @@ -192,7 +192,6 @@ const LoadStacks = (props: LoadFileFormatProps) => { (a: IDropDown, b: IDropDown) => new Date(b?.created_at)?.getTime() - new Date(a?.created_at)?.getTime() ); - console.log("stack array: ", newMigrationData.destination_stack.stackArray, stackArray); setAllStack(stackArray); //Set selected Stack diff --git a/upload-api/src/config/index.ts b/upload-api/src/config/index.ts index ea7aba8e..2ffc1d75 100644 --- a/upload-api/src/config/index.ts +++ b/upload-api/src/config/index.ts @@ -12,5 +12,5 @@ export default { bucketName: 'migartion-test', buketKey: 'project/package 45.zip' }, - localPath: '/Users/aishwarya.dani/Downloads/package 45.zip' + localPath: '/Users/rohit/Desktop/package 45.zip' };