Skip to content

Commit 887cc09

Browse files
authored
feat(admin-ui): add org details layout with sidepanel (#897)
* feat: add org details page base layout * feat: add nav chips, actions and icon * feat: fetch org details * feat: show kyc details in side panel * chore: move usehooks-ts to dependency * chore: update apsara * chore: remove table wrapper * chore: move sidepabel to the seperate folder * feat: add sidepanel toggle * feat: add copy button component * chore: update apsara to v0.37.0 * chore: use new copy button * refactor: use apsara icons for org and sidebar * chore: remove extra icons * chore: show fields in org details * chore: show app url from config * fix: org list page link * feat: add kyc details section * feat: add plan details section * feat: add token details section layout * chore: fetch billing account for org * chore: update api-client * feat: show token balance * chore: update api client * chore: fix height and width of icon * refactor: rename showLoader to isDataLoading * feat: show used token * feat: add billing details section * feat: add upcoming invoice data to billing section * feat: add page title * fix: style of main content * chore: rename appUrl to app_url * feat: add app url to yaml config * chore: remove height and width from icon
1 parent ae8b656 commit 887cc09

25 files changed

+1008
-55
lines changed

pkg/server/config.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ type GRPCConfig struct {
2626
func (cfg Config) grpcAddr() string { return fmt.Sprintf("%s:%d", cfg.Host, cfg.GRPC.Port) }
2727

2828
type UIConfig struct {
29-
Port int `yaml:"port" mapstructure:"port"`
30-
Title string `yaml:"title" mapstructure:"title"`
31-
Logo string `yaml:"logo" mapstructure:"logo"`
29+
Port int `yaml:"port" mapstructure:"port"`
30+
Title string `yaml:"title" mapstructure:"title"`
31+
Logo string `yaml:"logo" mapstructure:"logo"`
32+
AppURL string `yaml:"app_url" mapstructure:"app_url"`
3233
}
3334

3435
type Config struct {

pkg/server/server.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ const (
5858
)
5959

6060
type UIConfigApiResponse struct {
61-
Title string `json:"title"`
62-
Logo string `json:"logo"`
61+
Title string `json:"title"`
62+
Logo string `json:"logo"`
63+
AppUrl string `json:"app_url"`
6364
}
6465

6566
func ServeUI(ctx context.Context, logger log.Logger, uiConfig UIConfig, apiServerConfig Config) {
@@ -93,8 +94,9 @@ func ServeUI(ctx context.Context, logger log.Logger, uiConfig UIConfig, apiServe
9394
http.HandleFunc("/configs", func(w http.ResponseWriter, r *http.Request) {
9495
w.Header().Set("Content-Type", "application/json")
9596
confResp := UIConfigApiResponse{
96-
Title: uiConfig.Title,
97-
Logo: uiConfig.Logo,
97+
Title: uiConfig.Title,
98+
Logo: uiConfig.Logo,
99+
AppUrl: uiConfig.AppURL,
98100
}
99101
json.NewEncoder(w).Encode(confResp)
100102
})

ui/package-lock.json

Lines changed: 5 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@hookform/resolvers": "^3.0.1",
1515
"@radix-ui/react-form": "^0.0.2",
1616
"@radix-ui/react-icons": "^1.3.0",
17-
"@raystack/apsara": "^0.34.2",
17+
"@raystack/apsara": "^0.37.0",
1818
"@raystack/frontier": "^0.49.0",
1919
"@stitches/react": "^1.2.8",
2020
"@tanstack/react-table": "^8.9.3",
@@ -31,6 +31,7 @@
3131
"slugify": "^1.6.6",
3232
"sonner": "^1.4.41",
3333
"swr": "^2.1.2",
34+
"usehooks-ts": "^3.1.1",
3435
"vite-tsconfig-paths": "^4.0.7",
3536
"zod": "^3.22.3"
3637
},
@@ -43,7 +44,6 @@
4344
"eslint": "^8.56.0",
4445
"swagger-typescript-api": "^13.0.23",
4546
"typescript": "^5.8.2",
46-
"usehooks-ts": "^3.1.1",
4747
"vite": "^4.5.9",
4848
"vite-plugin-svgr": "^4.3.0"
4949
}

ui/src/api/frontier.ts

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export interface GooglerpcStatus {
189189
* foo = any.unpack(Foo.getDefaultInstance());
190190
* }
191191
*
192-
* Example 3: Pack and unpack a message in Python.
192+
* Example 3: Pack and unpack a message in Python.
193193
*
194194
* foo = Foo(...)
195195
* any = Any()
@@ -199,7 +199,7 @@ export interface GooglerpcStatus {
199199
* any.Unpack(foo)
200200
* ...
201201
*
202-
* Example 4: Pack and unpack a message in Go
202+
* Example 4: Pack and unpack a message in Go
203203
*
204204
* foo := &pb.Foo{...}
205205
* any, err := anypb.New(foo)
@@ -219,7 +219,7 @@ export interface GooglerpcStatus {
219219
* name "y.z".
220220
*
221221
* JSON
222-
*
222+
* ====
223223
* The JSON representation of an `Any` value uses the regular
224224
* representation of the deserialized, embedded message, with an
225225
* additional field `@type` which contains the type URL. Example:
@@ -271,7 +271,8 @@ export interface ProtobufAny {
271271
*
272272
* Note: this functionality is not currently available in the official
273273
* protobuf release, and it is not used for type URLs beginning with
274-
* type.googleapis.com.
274+
* type.googleapis.com. As of May 2023, there are no widely used type server
275+
* implementations and no plans to implement one.
275276
*
276277
* Schemes other than `http`, `https` (or the empty scheme) might be
277278
* used with implementation specific semantics.
@@ -284,7 +285,7 @@ export interface ProtobufAny {
284285
* `NullValue` is a singleton enumeration to represent the null value for the
285286
* `Value` type union.
286287
*
287-
* The JSON representation for `NullValue` is JSON `null`.
288+
* The JSON representation for `NullValue` is JSON `null`.
288289
*
289290
* - NULL_VALUE: Null value.
290291
* @default "NULL_VALUE"
@@ -1440,6 +1441,8 @@ export interface V1Beta1ListProjectsResponse {
14401441

14411442
export interface V1Beta1ListProspectsResponse {
14421443
prospects?: V1Beta1Prospect[];
1444+
pagination?: V1Beta1RQLQueryPaginationResponse;
1445+
group?: V1Beta1RQLQueryGroupResponse;
14431446
}
14441447

14451448
export interface V1Beta1ListRelationsResponse {
@@ -2217,6 +2220,11 @@ export interface V1Beta1Subscription {
22172220
plan?: V1Beta1Plan;
22182221
}
22192222

2223+
export interface V1Beta1TotalDebitedTransactionsResponse {
2224+
/** Total debited amount in the billing account */
2225+
debited?: BillingAccountBalance;
2226+
}
2227+
22202228
export type V1Beta1UpdateBillingAccountLimitsResponse = object;
22212229

22222230
export interface V1Beta1UpdateBillingAccountResponse {
@@ -4607,6 +4615,24 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
46074615
...params,
46084616
}),
46094617

4618+
/**
4619+
* @description Sum of amount of debited transactions including refunds
4620+
*
4621+
* @tags Transaction
4622+
* @name FrontierServiceTotalDebitedTransactions
4623+
* @summary Sum of amount of debited transactions including refunds
4624+
* @request GET:/v1beta1/organizations/{org_id}/billing/{billing_id}/debited_transactions_total
4625+
* @secure
4626+
*/
4627+
frontierServiceTotalDebitedTransactions: (orgId: string, billingId: string, params: RequestParams = {}) =>
4628+
this.request<V1Beta1TotalDebitedTransactionsResponse, GooglerpcStatus>({
4629+
path: `/v1beta1/organizations/${orgId}/billing/${billingId}/debited_transactions_total`,
4630+
method: "GET",
4631+
secure: true,
4632+
format: "json",
4633+
...params,
4634+
}),
4635+
46104636
/**
46114637
* @description List all invoices of a billing account.
46124638
*
Lines changed: 11 additions & 0 deletions
Loading

ui/src/assets/icons/coin.svg

Lines changed: 5 additions & 0 deletions
Loading

ui/src/assets/icons/organization.svg

Lines changed: 0 additions & 5 deletions
This file was deleted.

ui/src/components/Sidebar/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import {
99
import { api } from "~/api";
1010

1111
import styles from "./sidebar.module.css";
12-
12+
import { OrganizationIcon } from "@raystack/apsara/icons";
1313
import IAMIcon from "~/assets/icons/iam.svg?react";
14-
import OrganizationsIcon from "~/assets/icons/organization.svg?react";
1514
import UserIcon from "~/assets/icons/users.svg?react";
1615
import InvoicesIcon from "~/assets/icons/invoices.svg?react";
1716
import RolesIcon from "~/assets/icons/roles.svg?react";
@@ -37,7 +36,7 @@ const navigationItems: NavigationItemsTypes[] = [
3736
{
3837
name: "Organizations",
3938
to: `/organisations`,
40-
icon: <OrganizationsIcon />,
39+
icon: <OrganizationIcon />,
4140
},
4241
{
4342
name: "Users",

ui/src/components/states/Loading.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import { Flex, Spinner } from "@raystack/apsara/v1";
22

33
export default function LoadingState() {
44
return (
5-
<Flex style={{ height: "100vh" }} justify={"center"} align={"center"}>
5+
<Flex
6+
style={{ height: "100vh", width: "100%" }}
7+
justify={"center"}
8+
align={"center"}
9+
>
610
<Spinner size={6} />
711
</Flex>
812
);

0 commit comments

Comments
 (0)