feat(dashboard,js-sdk,types): Update app layout, and add user sdk methods (#8182)
**What** - Updates app layout (sidebar and topbar) - Adds "System" option to theme toggle (we now default to system) - Adds sdk methods for user endpoints (RESOLVES CC-67)
This commit is contained in:
committed by
GitHub
parent
07205e4249
commit
75c5d5ad9e
@@ -23,6 +23,7 @@ import { Store } from "./store"
|
||||
import { TaxRate } from "./tax-rate"
|
||||
import { TaxRegion } from "./tax-region"
|
||||
import { Upload } from "./upload"
|
||||
import { User } from "./user"
|
||||
|
||||
export class Admin {
|
||||
public invite: Invite
|
||||
@@ -48,6 +49,7 @@ export class Admin {
|
||||
public taxRegion: TaxRegion
|
||||
public store: Store
|
||||
public productTag: ProductTag
|
||||
public user: User
|
||||
public return: Return
|
||||
|
||||
constructor(client: Client) {
|
||||
@@ -74,6 +76,7 @@ export class Admin {
|
||||
this.taxRegion = new TaxRegion(client)
|
||||
this.store = new Store(client)
|
||||
this.productTag = new ProductTag(client)
|
||||
this.user = new User(client)
|
||||
this.return = new Return(client)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { Client } from "../client"
|
||||
import { ClientHeaders } from "../types"
|
||||
|
||||
export class User {
|
||||
private client: Client
|
||||
constructor(client: Client) {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateUser,
|
||||
query?: HttpTypes.AdminUserParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return this.client.fetch<HttpTypes.AdminUserResponse>(`/admin/users`, {
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
})
|
||||
}
|
||||
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateUser,
|
||||
query?: HttpTypes.AdminUserParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return this.client.fetch<HttpTypes.AdminUserResponse>(
|
||||
`/admin/users/${id}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async list(
|
||||
queryParams?: HttpTypes.AdminUserListParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return this.client.fetch<HttpTypes.AdminUserListResponse>(`/admin/users`, {
|
||||
headers,
|
||||
query: queryParams,
|
||||
})
|
||||
}
|
||||
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminUserParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return this.client.fetch<HttpTypes.AdminUserResponse>(
|
||||
`/admin/users/${id}`,
|
||||
{
|
||||
query,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return this.client.fetch<HttpTypes.AdminUserDeleteResponse>(
|
||||
`/admin/users/${id}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async me(query?: HttpTypes.AdminUserParams, headers?: ClientHeaders) {
|
||||
return this.client.fetch<HttpTypes.AdminUserResponse>(`/admin/users/me`, {
|
||||
query,
|
||||
headers,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
import { BaseUserResponse } from "./common"
|
||||
|
||||
export type AdminUserResponse = BaseUserResponse
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
export type BaseUserResponse = {
|
||||
export interface AdminUser {
|
||||
id: string
|
||||
email: string
|
||||
first_name: string | null
|
||||
last_name: string | null
|
||||
avatar_url: string | null
|
||||
metadata: Record<string, unknown> | null
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
created_at: string
|
||||
updated_at: string
|
||||
deleted_at: string | null
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export * from "./entities"
|
||||
export * from "./payloads"
|
||||
export * from "./queries"
|
||||
export * from "./responses"
|
||||
@@ -0,0 +1,12 @@
|
||||
export interface AdminCreateUser {
|
||||
email: string
|
||||
first_name?: string | null
|
||||
last_name?: string | null
|
||||
avatar_url?: string | null
|
||||
}
|
||||
|
||||
export interface AdminUpdateUser {
|
||||
first_name?: string | null
|
||||
last_name?: string | null
|
||||
avatar_url?: string | null
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { OperatorMap } from "../../../dal"
|
||||
import { FindParams, SelectParams } from "../../common"
|
||||
|
||||
export interface AdminUserListParams extends FindParams {
|
||||
q?: string
|
||||
id?: string | string[]
|
||||
email?: string | null
|
||||
first_name?: string | null
|
||||
last_name?: string | null
|
||||
created_at?: OperatorMap<string>
|
||||
updated_at?: OperatorMap<string>
|
||||
deleted_at?: OperatorMap<string>
|
||||
}
|
||||
|
||||
export interface AdminUserParams extends SelectParams {}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { DeleteResponse, PaginatedResponse } from "../../common"
|
||||
import { AdminUser } from "./entities"
|
||||
|
||||
export interface AdminUserResponse {
|
||||
user: AdminUser
|
||||
}
|
||||
|
||||
export interface AdminUserListResponse
|
||||
extends PaginatedResponse<{ users: AdminUser[] }> {}
|
||||
|
||||
export interface AdminUserDeleteResponse extends DeleteResponse<"user"> {}
|
||||
Reference in New Issue
Block a user