@@ -25,7 +25,6 @@ import { LoanAndCreditFacilityStatusBadge } from "@/app/credit-facility"
25
25
import { getCreditFacility } from "@/lib/graphql/query/get-cf"
26
26
import { removeUnderscore } from "@/lib/kratos/utils"
27
27
import { formatDate } from "@/lib/utils"
28
- import { meQuery } from "@/lib/graphql/query/me"
29
28
30
29
gql `
31
30
query GetCreditFacility($id: UUID!) {
@@ -149,69 +148,33 @@ gql`
149
148
150
149
async function page ( { params } : { params : Promise < { "credit-facility-id" : string } > } ) {
151
150
const { "credit-facility-id" : id } = await params
152
- const [ cfData , meData ] = await Promise . all ( [ getCreditFacility ( { id } ) , meQuery ( ) ] )
151
+ const data = await getCreditFacility ( {
152
+ id,
153
+ } )
153
154
154
- if ( ! cfData || cfData instanceof Error || ! cfData . creditFacility ) {
155
+ if ( ! data || data instanceof Error || ! data . creditFacility ) {
155
156
return < div > Not found</ div >
156
157
}
157
158
158
- if ( ! meData || meData instanceof Error ) {
159
- return < div > Error loading customer data</ div >
160
- }
161
-
162
159
const details : DetailItemProps [ ] = [
163
160
{
164
- label : "Customer Type" ,
165
- value : removeUnderscore ( meData . me . customer . customerType ) ,
166
- } ,
167
- {
168
- label : "Issue Date" ,
169
- value : formatDate ( cfData . creditFacility . createdAt ) ,
161
+ label : "Created At" ,
162
+ value : formatDate ( data . creditFacility . createdAt ) ,
170
163
} ,
171
164
{
172
- label : "Maturity Date" ,
173
- value : formatDate ( cfData . creditFacility . maturesAt ) || "N/A" ,
174
- } ,
175
- {
176
- label : "Current Monthly Payment" ,
177
- value : cfData . creditFacility . repaymentPlan ?. length ? (
178
- < div className = "flex items-center" >
179
- $
180
- { (
181
- Number ( cfData . creditFacility . repaymentPlan [ 0 ] . outstanding ) / 100
182
- ) . toLocaleString ( undefined , {
183
- minimumFractionDigits : 2 ,
184
- maximumFractionDigits : 2 ,
185
- } ) }
186
- < span className = "text-sm text-muted-foreground ml-2" >
187
- Due { formatDate ( cfData . creditFacility . repaymentPlan [ 0 ] . dueAt ) }
188
- </ span >
189
- </ div >
190
- ) : (
191
- "–"
192
- ) ,
193
- } ,
194
- {
195
- label : "Interest Calculation Days" ,
196
- value : (
197
- < div className = "flex items-center" >
198
- < span > 365</ span >
199
- < span className = "text-sm text-muted-foreground ml-2" >
200
- Fixed number used for all interest calculations
201
- </ span >
202
- </ div >
203
- ) ,
165
+ label : "Collateralization State" ,
166
+ value : removeUnderscore ( data . creditFacility . collateralizationState ) ,
204
167
} ,
205
168
{
206
- label : "Collateralization State " ,
207
- value : removeUnderscore ( cfData . creditFacility . collateralizationState ) ,
169
+ label : "Matures At " ,
170
+ value : formatDate ( data . creditFacility . maturesAt ) || "N/A" ,
208
171
} ,
209
172
{
210
173
label : "Status" ,
211
174
value : (
212
175
< LoanAndCreditFacilityStatusBadge
213
176
data-testid = "credit-facility-status-badge"
214
- status = { cfData . creditFacility . status }
177
+ status = { data . creditFacility . status }
215
178
/>
216
179
) ,
217
180
} ,
@@ -231,10 +194,10 @@ async function page({ params }: { params: Promise<{ "credit-facility-id": string
231
194
details = { details }
232
195
/>
233
196
< div className = "flex flex-col gap-2 md:flex-row" >
234
- < FacilityCard data = { cfData . creditFacility } />
235
- < CollateralCard data = { cfData . creditFacility } />
197
+ < FacilityCard data = { data . creditFacility } />
198
+ < CollateralCard data = { data . creditFacility } />
236
199
</ div >
237
- < TermsCard data = { cfData . creditFacility } />
200
+ < TermsCard data = { data . creditFacility } />
238
201
< Tabs defaultValue = "history" className = "w-full" >
239
202
< TabsList className = "flex h-12 w-full items-center rounded-lg bg-muted p-1" >
240
203
< TabsTrigger
@@ -261,13 +224,13 @@ async function page({ params }: { params: Promise<{ "credit-facility-id": string
261
224
</ TabsList >
262
225
263
226
< TabsContent value = "history" className = "mt-2" >
264
- < CreditFacilityHistory creditFacility = { cfData . creditFacility } />
227
+ < CreditFacilityHistory creditFacility = { data . creditFacility } />
265
228
</ TabsContent >
266
229
< TabsContent value = "repayments" className = "mt-2" >
267
- < CreditFacilityRepaymentPlan creditFacility = { cfData . creditFacility } />
230
+ < CreditFacilityRepaymentPlan creditFacility = { data . creditFacility } />
268
231
</ TabsContent >
269
232
< TabsContent value = "disbursals" className = "mt-2" >
270
- < CreditFacilityDisbursals creditFacility = { cfData . creditFacility } />
233
+ < CreditFacilityDisbursals creditFacility = { data . creditFacility } />
271
234
</ TabsContent >
272
235
</ Tabs >
273
236
</ main >
0 commit comments