@@ -118,8 +118,9 @@ export default function UserTemplates() {
118118 await refetch ( )
119119 }
120120
121- const isEmpty = ! isLoading && ( ! filteredTemplates || filteredTemplates . length === 0 ) && ! searchQuery . trim ( )
122- const isSearchEmpty = ! isLoading && ( ! filteredTemplates || filteredTemplates . length === 0 ) && searchQuery . trim ( ) !== ''
121+ const isCurrentlyLoading = isLoading || ( isFetching && ! userTemplates )
122+ const isEmpty = ! isCurrentlyLoading && ( ! filteredTemplates || filteredTemplates . length === 0 ) && ! searchQuery . trim ( )
123+ const isSearchEmpty = ! isCurrentlyLoading && ( ! filteredTemplates || filteredTemplates . length === 0 ) && searchQuery . trim ( ) !== ''
123124
124125 return (
125126 < div className = "flex w-full flex-col items-start gap-2" >
@@ -160,7 +161,31 @@ export default function UserTemplates() {
160161 </ Button >
161162 </ div >
162163
163- { isEmpty && (
164+ { isCurrentlyLoading && (
165+ < div
166+ className = "mb-12 grid transform-gpu animate-slide-up grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3"
167+ style = { { animationDuration : '500ms' , animationDelay : '100ms' , animationFillMode : 'both' } }
168+ >
169+ { [ ...Array ( 6 ) ] . map ( ( _ , i ) => (
170+ < Card key = { i } className = "px-4 py-5 sm:px-5 sm:py-6" >
171+ < div className = "flex items-start justify-between gap-2 sm:gap-3" >
172+ < div className = "min-w-0 flex-1" >
173+ < div className = "flex items-center gap-x-2" >
174+ < Skeleton className = "h-2 w-2 shrink-0 rounded-full" />
175+ < Skeleton className = "h-5 w-24 sm:w-32" />
176+ </ div >
177+ < div className = "space-y-2" >
178+ < Skeleton className = "h-4 w-32 sm:w-40 md:w-48" />
179+ < Skeleton className = "h-4 w-28 sm:w-36 md:w-40" />
180+ </ div >
181+ </ div >
182+ < Skeleton className = "h-8 w-8 shrink-0" />
183+ </ div >
184+ </ Card >
185+ ) ) }
186+ </ div >
187+ ) }
188+ { isEmpty && ! isCurrentlyLoading && (
164189 < Card className = "mb-12" >
165190 < CardContent className = "p-8 text-center" >
166191 < div className = "space-y-4" >
@@ -170,7 +195,7 @@ export default function UserTemplates() {
170195 </ CardContent >
171196 </ Card >
172197 ) }
173- { isSearchEmpty && (
198+ { isSearchEmpty && ! isCurrentlyLoading && (
174199 < Card className = "mb-12" >
175200 < CardContent className = "p-8 text-center" >
176201 < div className = "space-y-4" >
@@ -180,30 +205,12 @@ export default function UserTemplates() {
180205 </ CardContent >
181206 </ Card >
182207 ) }
183- { ! isEmpty && ! isSearchEmpty && (
208+ { ! isEmpty && ! isSearchEmpty && ! isCurrentlyLoading && (
184209 < div
185210 className = "mb-12 grid transform-gpu animate-slide-up grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3"
186211 style = { { animationDuration : '500ms' , animationDelay : '100ms' , animationFillMode : 'both' } }
187212 >
188- { isLoading
189- ? [ ...Array ( 6 ) ] . map ( ( _ , i ) => (
190- < Card key = { i } className = "px-4 py-5 sm:px-5 sm:py-6" >
191- < div className = "flex items-start justify-between gap-2 sm:gap-3" >
192- < div className = "min-w-0 flex-1" >
193- < div className = "flex items-center gap-x-2" >
194- < Skeleton className = "h-2 w-2 shrink-0 rounded-full" />
195- < Skeleton className = "h-5 w-24 sm:w-32" />
196- </ div >
197- < div className = "space-y-2" >
198- < Skeleton className = "h-4 w-32 sm:w-40 md:w-48" />
199- < Skeleton className = "h-4 w-28 sm:w-36 md:w-40" />
200- </ div >
201- </ div >
202- < Skeleton className = "h-8 w-8 shrink-0" />
203- </ div >
204- </ Card >
205- ) )
206- : filteredTemplates ?. map ( ( template : UserTemplateResponse ) => < UserTemplate onEdit = { handleEdit } template = { template } key = { template . id } onToggleStatus = { handleToggleStatus } /> ) }
213+ { filteredTemplates ?. map ( ( template : UserTemplateResponse ) => < UserTemplate onEdit = { handleEdit } template = { template } key = { template . id } onToggleStatus = { handleToggleStatus } /> ) }
207214 </ div >
208215 ) }
209216 </ div >
0 commit comments