Skip to content

Commit 1338a01

Browse files
Fix/wallet creation refresh issue (#1079)
* Managed state for the wallet creation steps Signed-off-by: alokmore-awts <alok.more@ayanworks.com> * minor ui fixes and text changes Signed-off-by: alokmore-awts <alok.more@ayanworks.com> * enum added in common enums file Signed-off-by: alokmore-awts <alok.more@ayanworks.com> * Added loaders to all the buttons Signed-off-by: alokmore-awts <alok.more@ayanworks.com> * sonarcube issues resolved Signed-off-by: alokmore-awts <alok.more@ayanworks.com> * Resolved issues of sonarqube Signed-off-by: alokmore-awts <alok.more@ayanworks.com> * Resolved issues of sonarqube Signed-off-by: alokmore-awts <alok.more@ayanworks.com> * Sonarqube issues resolved Signed-off-by: alokmore-awts <alok.more@ayanworks.com> * Added loaders for remaining components Signed-off-by: alokmore-awts <alok.more@ayanworks.com> * resolved comments of ellipsis bot Signed-off-by: alokmore-awts <alok.more@ayanworks.com> * Minor changes done Signed-off-by: alokmore-awts <alok.more@ayanworks.com> * moved interfaces in common file Signed-off-by: alokmore-awts <alok.more@ayanworks.com> --------- Signed-off-by: alokmore-awts <alok.more@ayanworks.com>
1 parent 1e9f7fb commit 1338a01

38 files changed

+776
-318
lines changed

nextjs/src/app/reset-password/ResetPassword.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const ResetPassword = (): JSX.Element => {
122122
<div className="flex w-full justify-center">
123123
<Card className="relative z-10 w-full max-w-lg overflow-hidden rounded-xl border p-8 shadow-xl transition-transform duration-300 lg:max-w-md">
124124
<div className="flex w-full flex-col gap-4 lg:mt-8">
125-
<div className="text-custom-900 dark:text-custom-100 font-inter flex justify-center text-center text-3xl leading-10 font-bold">
125+
<div className="font-inter flex justify-center text-center text-3xl leading-10 font-bold">
126126
Reset Password
127127
</div>
128128
<div className="font-inter h-5.061 text-muted-foreground flex w-full flex-shrink-0 flex-col items-center justify-center text-base leading-5 font-medium">

nextjs/src/components/AlertComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const AlertComponent = ({
3636
<div className="flex w-full flex-wrap items-center justify-between">
3737
<div>{message}</div>
3838
{viewButton && (
39-
<div className="text-primary-700 mr-2 flex justify-end text-right text-base md:w-32 lg:w-48">
39+
<div className="mr-2 flex justify-end text-right text-base md:w-32 lg:w-48">
4040
<a href={path}>View more... </a>
4141
</div>
4242
)}

nextjs/src/components/BackButton.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
'use client'
22

3+
import { JSX, useState } from 'react'
34
import { ArrowLeft } from 'lucide-react'
45
import { Button } from './ui/button'
5-
import { JSX } from 'react'
6+
import Loader from './Loader'
67
import { useRouter } from 'next/navigation'
78

89
interface BackButtonProps {
@@ -11,23 +12,34 @@ interface BackButtonProps {
1112

1213
const BackButton = ({ path }: BackButtonProps): JSX.Element => {
1314
const router = useRouter()
15+
const [isLoading, setIsLoading] = useState(false)
1416

1517
const handleClick = (): void => {
18+
setIsLoading(true)
1619
if (path) {
1720
router.push(path)
1821
} else {
1922
router.back()
2023
}
24+
25+
setTimeout(() => setIsLoading(false), 2000)
2126
}
2227

2328
return (
2429
<Button
2530
variant="default"
2631
onClick={handleClick}
32+
disabled={isLoading}
2733
className="mb-4 flex items-center gap-2 rounded-md px-4 py-2 transition-colors"
2834
>
29-
<ArrowLeft size={18} />
30-
Back
35+
{isLoading ? (
36+
<Loader size={20} />
37+
) : (
38+
<>
39+
<ArrowLeft size={18} />
40+
Back
41+
</>
42+
)}
3143
</Button>
3244
)
3345
}

nextjs/src/components/EmptyListComponent.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ export const EmptyListMessage = ({
1414
<div
1515
className={`flex ${noExtraHeight ? '' : 'mt-20 mb-16'} flex-col items-center justify-start`}
1616
>
17-
<p className="mb-4 text-2xl font-bold text-gray-900 dark:text-white">
18-
{message}
19-
</p>
20-
<p className="mb-4 text-lg text-gray-900 dark:text-white">{description}</p>
17+
<p className="mb-4 text-2xl font-bold dark:text-white">{message}</p>
18+
<p className="mb-4 text-lg dark:text-white">{description}</p>
2119
{buttonContent && (
2220
<RoleViewButton
2321
buttonTitle={buttonContent}

nextjs/src/components/RoleViewButton.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Features, Roles } from '@/common/enums'
22
import { JSX, ReactElement } from 'react'
33

44
import { Button } from './ui/button'
5+
import Loader from './Loader'
56
import { useAppSelector } from '@/lib/hooks'
67

78
interface RoleViewButtonProps {
@@ -13,6 +14,7 @@ interface RoleViewButtonProps {
1314
isOutline?: boolean
1415
isPadding?: boolean
1516
disabled?: boolean
17+
loading?: boolean
1618
}
1719

1820
const RoleViewButton = ({
@@ -23,6 +25,7 @@ const RoleViewButton = ({
2325
feature,
2426
isOutline,
2527
disabled,
28+
loading,
2629
}: RoleViewButtonProps): JSX.Element => {
2730
const roles = useAppSelector(
2831
(state) => state.organization.orgInfo?.roles || [],
@@ -59,6 +62,7 @@ const RoleViewButton = ({
5962
onClick={isRoleAccess() ? onClickEvent : undefined}
6063
disabled={disabled || !isRoleAccess()}
6164
>
65+
{loading && <Loader size={20} />}
6266
{svgComponent}
6367
{buttonTitle}
6468
</Button>

nextjs/src/components/layout/app-sidebar.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
'use client'
2-
32
import {
43
Collapsible,
54
CollapsibleContent,
@@ -22,6 +21,7 @@ import {
2221
import { currentPageNumber, itemPerPage } from '@/config/CommonConstant'
2322
import { setOrgId, setOrgInfo } from '@/lib/orgSlice'
2423
import { useAppDispatch, useAppSelector } from '@/lib/hooks'
24+
import { usePathname, useRouter } from 'next/navigation'
2525

2626
import { IconChevronRight } from '@tabler/icons-react'
2727
import { Icons } from '../icons'
@@ -32,11 +32,11 @@ import { Organization } from '@/features/dashboard/type/organization'
3232
import { getOrganizations } from '@/app/api/organization'
3333
import { navItems } from '@/constants/data'
3434
import { setSidebarCollapsed } from '@/lib/sidebarSlice'
35-
import { usePathname } from 'next/navigation'
3635
import { useTheme } from 'next-themes'
3736
import { useThemeConfig } from '../active-theme'
3837

3938
export default function AppSidebar(): React.JSX.Element {
39+
const router = useRouter()
4040
const pathname = usePathname()
4141

4242
const { activeTheme } = useThemeConfig()
@@ -124,7 +124,11 @@ export default function AppSidebar(): React.JSX.Element {
124124
return (
125125
<Sidebar collapsible="icon">
126126
<SidebarHeader className="group" data-collapsed>
127-
<div className="relative transition-all duration-300">
127+
<button
128+
onClick={() => router.push('/dashboard')}
129+
className="focus-visible:ring-primary relative cursor-pointer rounded transition-all duration-300 focus:outline-none focus-visible:ring-2"
130+
aria-label="Go to dashboard"
131+
>
128132
{isCollapsed ? (
129133
<div className="h-[40px] w-[150px] overflow-hidden">
130134
<Image
@@ -146,7 +150,7 @@ export default function AppSidebar(): React.JSX.Element {
146150
/>
147151
</div>
148152
)}
149-
</div>
153+
</button>
150154
</SidebarHeader>
151155

152156
<SidebarContent className="overflow-x-hidden">

nextjs/src/features/common/enum.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,22 @@ export enum ProofRequestState {
169169
done = 'done',
170170
abandoned = 'abandoned',
171171
}
172+
173+
export enum AgentType {
174+
SHARED = 'shared',
175+
DEDICATED = 'dedicated',
176+
}
177+
178+
// Define wallet spinup status enum
179+
export enum WalletSpinupStatus {
180+
NOT_STARTED = 'not_started',
181+
AGENT_CONFIG_SET = 'agent_config_set',
182+
AGENT_SPINUP_INITIATED = 'agent_spinup_initiated',
183+
AGENT_SPINUP_COMPLETED = 'agent_spinup_completed',
184+
DID_PUBLISH_INITIATED = 'did_publish_initiated',
185+
DID_PUBLISH_COMPLETED = 'did_publish_completed',
186+
INVITATION_CREATION_STARTED = 'invitation_creation_started',
187+
INVITATION_CREATION_SUCCESS = 'invitation_creation_success',
188+
COMPLETED = 'completed',
189+
FAILED = 'failed',
190+
}

nextjs/src/features/components/user-auth-form.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import * as z from 'zod'
44

5-
import { Eye, EyeOff, KeyRound, Loader2, LockKeyhole, Mail } from 'lucide-react'
5+
import { Eye, EyeOff, KeyRound, LockKeyhole, Mail } from 'lucide-react'
66
import {
77
Form,
88
FormControl,
@@ -26,6 +26,7 @@ import { Button } from '@/components/ui/button'
2626
import { Icons } from '@/config/svgs/Auth'
2727
import { Input } from '@/components/ui/input'
2828
import Link from 'next/link'
29+
import Loader from '@/components/Loader'
2930
import { apiStatusCodes } from '@/config/CommonConstant'
3031
import { generateAuthenticationOption } from '@/app/api/Fido'
3132
import { setProfile } from '@/lib/profileSlice'
@@ -422,7 +423,7 @@ export default function SignInViewPage(): React.JSX.Element {
422423
disabled={loading}
423424
className="w-full text-xs md:text-sm"
424425
>
425-
{loading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
426+
{loading && <Loader />}
426427
{isPasswordTab ? 'Sign in' : 'Continue with passkey'}
427428
</Button>
428429

nextjs/src/features/dashboard/components/OrganizationCardList.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { currentPageNumber, itemPerPage } from '@/config/CommonConstant'
2929
import { Badge } from '@/components/ui/badge'
3030
import { Button } from '@/components/ui/button'
3131
import Link from 'next/link'
32+
import Loader from '@/components/Loader'
3233
import { Organisation } from '../type/organization'
3334
import { OrganizationRoles } from '@/common/enums'
3435
import { Plus } from 'lucide-react'
@@ -46,6 +47,7 @@ const OrganizationCardList = (): React.JSX.Element => {
4647
const [currentPage] = useState(currentPageNumber)
4748
const [pageSize] = useState(itemPerPage)
4849
const [searchTerm] = useState('')
50+
const [isCreatingOrg, setIsCreatingOrg] = useState(false)
4951

5052
const fetchOrganizations = async (): Promise<void> => {
5153
try {
@@ -91,10 +93,20 @@ const OrganizationCardList = (): React.JSX.Element => {
9193
<CardDescription>Manage your organizations</CardDescription>
9294
</div>
9395
<Button
94-
onClick={() => route.push('/organizations/create-organization')}
95-
// className="text-primary-foreground bg-primary"
96+
onClick={() => {
97+
setIsCreatingOrg(true)
98+
route.push('/organizations/create-organization')
99+
}}
100+
disabled={isCreatingOrg}
96101
>
97-
<Plus className="h-4 w-4" /> New Organization
102+
{isCreatingOrg ? (
103+
<Loader />
104+
) : (
105+
<>
106+
<Plus className="mr-2 h-4 w-4" />
107+
New Organization
108+
</>
109+
)}
98110
</Button>
99111
</CardHeader>
100112

nextjs/src/features/dashboard/components/RecentActivity.tsx

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,29 @@ export interface UserActivity {
2727
deletedAt: Date | string
2828
}
2929

30+
// 👇 Helper function to convert date to "Created X ago"
31+
const getTimeAgo = (dateStr: string): string => {
32+
const date = new Date(dateStr)
33+
const now = new Date()
34+
const diffMs = now.getTime() - date.getTime()
35+
36+
const seconds = Math.floor(diffMs / 1000)
37+
const minutes = Math.floor(seconds / 60)
38+
const hours = Math.floor(minutes / 60)
39+
const days = Math.floor(hours / 24)
40+
41+
if (seconds < 60) {
42+
return 'Created just now'
43+
}
44+
if (minutes < 60) {
45+
return `Created ${minutes} minute${minutes > 1 ? 's' : ''} ago`
46+
}
47+
if (hours < 24) {
48+
return `Created ${hours} hour${hours > 1 ? 's' : ''} ago`
49+
}
50+
return `Created ${days} day${days > 1 ? 's' : ''} ago`
51+
}
52+
3053
const RecentActivity = (): React.JSX.Element => {
3154
const [activityList, setActivityList] = useState<UserActivity[]>([])
3255
const [loading, setLoading] = useState(true)
@@ -64,16 +87,19 @@ const RecentActivity = (): React.JSX.Element => {
6487
<div key={index} className="flex gap-3">
6588
<div className="relative mt-1">
6689
<div className="flex h-2 w-2 items-center justify-center">
67-
<div className="absolute h-2 w-2 rounded-full" />
90+
<div className="bg-primary absolute h-2 w-2 rounded-full" />
6891
</div>
69-
<div className="ml-1 h-full w-px" />
92+
<div className="bg-muted ml-1 h-full w-px" />
7093
</div>
7194
<div className="space-y-1">
7295
<div className="max-w-[400px] truncate font-medium">
7396
{activity.action || 'Performed an action'}
7497
</div>
75-
<div className="text-muted-foreground">
76-
{new Date(activity.createDateTime).toLocaleString()}
98+
{/* <div className="max-w-full font-medium break-words">
99+
{activity.action || 'Performed an action'}
100+
</div> */}
101+
<div className="text-muted-foreground text-sm italic">
102+
{getTimeAgo(activity.createDateTime)}
77103
</div>
78104
</div>
79105
</div>

0 commit comments

Comments
 (0)