Skip to content

Commit e6b9f6d

Browse files
committed
feat: Rollback customer portal changes.
1 parent 913f5b5 commit e6b9f6d

File tree

4 files changed

+19
-61
lines changed

4 files changed

+19
-61
lines changed

apps/customer-portal/app/credit-facilities/[credit-facility-id]/page.tsx

Lines changed: 17 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { LoanAndCreditFacilityStatusBadge } from "@/app/credit-facility"
2525
import { getCreditFacility } from "@/lib/graphql/query/get-cf"
2626
import { removeUnderscore } from "@/lib/kratos/utils"
2727
import { formatDate } from "@/lib/utils"
28-
import { meQuery } from "@/lib/graphql/query/me"
2928

3029
gql`
3130
query GetCreditFacility($id: UUID!) {
@@ -149,69 +148,33 @@ gql`
149148

150149
async function page({ params }: { params: Promise<{ "credit-facility-id": string }> }) {
151150
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+
})
153154

154-
if (!cfData || cfData instanceof Error || !cfData.creditFacility) {
155+
if (!data || data instanceof Error || !data.creditFacility) {
155156
return <div>Not found</div>
156157
}
157158

158-
if (!meData || meData instanceof Error) {
159-
return <div>Error loading customer data</div>
160-
}
161-
162159
const details: DetailItemProps[] = [
163160
{
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),
170163
},
171164
{
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),
204167
},
205168
{
206-
label: "Collateralization State",
207-
value: removeUnderscore(cfData.creditFacility.collateralizationState),
169+
label: "Matures At",
170+
value: formatDate(data.creditFacility.maturesAt) || "N/A",
208171
},
209172
{
210173
label: "Status",
211174
value: (
212175
<LoanAndCreditFacilityStatusBadge
213176
data-testid="credit-facility-status-badge"
214-
status={cfData.creditFacility.status}
177+
status={data.creditFacility.status}
215178
/>
216179
),
217180
},
@@ -231,10 +194,10 @@ async function page({ params }: { params: Promise<{ "credit-facility-id": string
231194
details={details}
232195
/>
233196
<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} />
236199
</div>
237-
<TermsCard data={cfData.creditFacility} />
200+
<TermsCard data={data.creditFacility} />
238201
<Tabs defaultValue="history" className="w-full">
239202
<TabsList className="flex h-12 w-full items-center rounded-lg bg-muted p-1">
240203
<TabsTrigger
@@ -261,13 +224,13 @@ async function page({ params }: { params: Promise<{ "credit-facility-id": string
261224
</TabsList>
262225

263226
<TabsContent value="history" className="mt-2">
264-
<CreditFacilityHistory creditFacility={cfData.creditFacility} />
227+
<CreditFacilityHistory creditFacility={data.creditFacility} />
265228
</TabsContent>
266229
<TabsContent value="repayments" className="mt-2">
267-
<CreditFacilityRepaymentPlan creditFacility={cfData.creditFacility} />
230+
<CreditFacilityRepaymentPlan creditFacility={data.creditFacility} />
268231
</TabsContent>
269232
<TabsContent value="disbursals" className="mt-2">
270-
<CreditFacilityDisbursals creditFacility={cfData.creditFacility} />
233+
<CreditFacilityDisbursals creditFacility={data.creditFacility} />
271234
</TabsContent>
272235
</Tabs>
273236
</main>

apps/customer-portal/app/credit-facilities/[credit-facility-id]/terms-card.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@ function TermsCard({ data }: { data: NonNullable<CreditFacility> }) {
1414
)}`,
1515
},
1616
{
17-
label: "Nominal Interest Rate",
17+
label: "Interest (APR)",
1818
value: `${data.creditFacilityTerms.annualRate}%`,
1919
},
20-
{
21-
label: "Effective Interest Rate",
22-
value: `${(Number(data.creditFacilityTerms.annualRate) + Number(data.creditFacilityTerms.oneTimeFeeRate)).toFixed(2)}%`,
23-
},
2420
{
2521
label: "Accrual Cycle Interval",
2622
value: removeUnderscore(data.creditFacilityTerms.accrualCycleInterval),

apps/customer-portal/lib/graphql/generated/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ export type GetCreditFacilityQuery = { __typename?: 'Query', creditFacility?: {
430430
export type MeQueryVariables = Exact<{ [key: string]: never; }>;
431431

432432

433-
export type MeQuery = { __typename?: 'Query', me: { __typename?: 'Subject', customer: { __typename?: 'Customer', id: string, customerId: any, status: AccountStatus, level: KycLevel, createdAt: any, email: string, telegramId: string, customerType: CustomerType, depositAccount: { __typename?: 'DepositAccount', id: string, depositAccountId: any, customerId: any, createdAt: any, balance: { __typename?: 'DepositAccountBalance', settled: any, pending: any }, deposits: Array<{ __typename?: 'Deposit', id: string, depositId: any, accountId: any, amount: any, createdAt: any, reference: string }>, withdrawals: Array<{ __typename?: 'Withdrawal', id: string, withdrawalId: any, accountId: any, amount: any, createdAt: any, reference: string, status: WithdrawalStatus }> }, creditFacilities: Array<{ __typename?: 'CreditFacility', id: string, creditFacilityId: any, collateralizationState: CollateralizationState, status: CreditFacilityStatus, createdAt: any, balance: { __typename?: 'CreditFacilityBalance', collateral: { __typename?: 'Collateral', btcBalance: any }, outstanding: { __typename?: 'Outstanding', usdBalance: any } } }> } } };
433+
export type MeQuery = { __typename?: 'Query', me: { __typename?: 'Subject', customer: { __typename?: 'Customer', id: string, customerId: any, status: AccountStatus, level: KycLevel, createdAt: any, email: string, telegramId: string, depositAccount: { __typename?: 'DepositAccount', id: string, depositAccountId: any, customerId: any, createdAt: any, balance: { __typename?: 'DepositAccountBalance', settled: any, pending: any }, deposits: Array<{ __typename?: 'Deposit', id: string, depositId: any, accountId: any, amount: any, createdAt: any, reference: string }>, withdrawals: Array<{ __typename?: 'Withdrawal', id: string, withdrawalId: any, accountId: any, amount: any, createdAt: any, reference: string, status: WithdrawalStatus }> }, creditFacilities: Array<{ __typename?: 'CreditFacility', id: string, creditFacilityId: any, collateralizationState: CollateralizationState, status: CreditFacilityStatus, createdAt: any, balance: { __typename?: 'CreditFacilityBalance', collateral: { __typename?: 'Collateral', btcBalance: any }, outstanding: { __typename?: 'Outstanding', usdBalance: any } } }> } } };
434434

435435
export type GetRealtimePriceUpdatesQueryVariables = Exact<{ [key: string]: never; }>;
436436

apps/customer-portal/lib/graphql/query/me.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ gql`
1515
createdAt
1616
email
1717
telegramId
18-
customerType
1918
depositAccount {
2019
id
2120
depositAccountId

0 commit comments

Comments
 (0)