@@ -3,7 +3,6 @@ import React, { useEffect, useMemo, useState } from 'react'
3
3
import { extend } from 'dayjs'
4
4
import relativeTime from 'dayjs/plugin/relativeTime'
5
5
import { useAtom , useAtomValue } from 'jotai'
6
- import { toast } from 'sonner'
7
6
import { Accordion } from '@/components/ui/accordion'
8
7
import ControllerInstance from '@/lib/controller-instance'
9
8
import SecretLoader from '@/components/dashboard/secret/secretLoader'
@@ -55,35 +54,24 @@ function SecretPage(): React.JSX.Element {
55
54
)
56
55
57
56
useEffect ( ( ) => {
58
- const fetchSecrets = async ( ) => {
59
- if ( ! selectedProject ) {
60
- toast . error ( 'No project selected' , {
61
- description : (
62
- < p className = "text-xs text-red-300" >
63
- Please select a project to view secrets.
64
- </ p >
65
- )
66
- } )
67
- return
68
- }
69
-
70
- try {
71
- setIsLoading ( true )
72
- const { data, success } = await getAllSecretsOfProject ( )
73
- if ( success && data ) {
74
- setSecrets ( ( prev ) =>
75
- page === 0 ? data . items : [ ...prev , ...data . items ]
76
- )
77
- if ( data . metadata . links . next === null ) {
78
- setHasMore ( false )
57
+ if ( selectedProject ) {
58
+ setIsLoading ( true )
59
+
60
+ getAllSecretsOfProject ( )
61
+ . then ( ( { data, success } ) => {
62
+ if ( success && data ) {
63
+ setSecrets ( ( prev ) =>
64
+ page === 0 ? data . items : [ ...prev , ...data . items ]
65
+ )
66
+ if ( data . metadata . links . next === null ) {
67
+ setHasMore ( false )
68
+ }
79
69
}
80
- }
81
- } finally {
82
- setIsLoading ( false )
83
- }
70
+ } )
71
+ . finally ( ( ) => {
72
+ setIsLoading ( false )
73
+ } )
84
74
}
85
-
86
- fetchSecrets ( )
87
75
} , [ getAllSecretsOfProject , isDecrypted , page , selectedProject , setSecrets ] )
88
76
89
77
const handleLoadMore = ( ) => {
0 commit comments