Skip to content

Commit

Permalink
user types
Browse files Browse the repository at this point in the history
  • Loading branch information
Przemek committed Dec 18, 2024
1 parent 44c9225 commit 6153cbd
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 80 deletions.
81 changes: 3 additions & 78 deletions src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
PageParams,
DefaultResponseError,
DataResponseSuccess,
Category,
} from "./core-types";
import {
BookmarkableType,
Expand All @@ -26,6 +27,8 @@ import {
PaymentStatusType,
} from "./enums";

import { UserItem } from "./user-types";

export type IStatement = {
actor: unknown;
context: {
Expand All @@ -44,28 +47,6 @@ export type IEventException =
| "Questionnaire"
| "QuestionSet";

export type Category = {
id: number;
name: string;
slug: string;
is_active: boolean;
parent_id?: number;
icon?: string;
icon_class: string;
created_at: string;
updated_at: string;
order: number;
pivot?: {
course_id: number;
category_id: number;
};
subcategories?: Category[];
count?: number;
count_free?: number;
description?: string;
name_with_breadcrumbs?: string;
};

export type Tag = {
id: number;
title: string;
Expand Down Expand Up @@ -243,14 +224,6 @@ export type EventsList = DefaultMetaResponse<Event>;

export type TutorConsultationList = DefaultMetaResponse<AppointmentTerm>;

export type UserGroups = UserGroup[];

export type UserGroupRow = DefaultResponse<UserGroup>;

export type UserGroupAddRow = DefaultResponse<UserItem[]>;

export type UserGroupList = DefaultMetaResponse<UserGroup>;

export type Consultation = EscolaLms.Consultations.Models.Consultation & {
product?: Product;
executed_status?: null | "reported" | "not_reported" | "reject" | "approved";
Expand Down Expand Up @@ -480,33 +453,6 @@ export type AcademicYear = {
active: boolean;
};

export type UserItem = Partial<
Exclude<
EscolaLms.Auth.Models.User,
| "password"
| "remember_token"
| "password_reset_token"
| "email_verified_at"
| "is_active"
>
> & {
// id: number;
// name: string;
// first_name: string;
// last_name: string;
// email: string;
// is_active: boolean;
// created_at: string;
// onboarding_completed: boolean;
// email_verified: boolean;
avatar?: string;
url_avatar: string | null;
// path_avatar: string | null;
bio?: string | null;
categories?: Category[] | null;
interests?: Array<EscolaLms.Categories.Models.Category> | null | never[];
};

export type MembershipDetails = {
id: number;
value: string;
Expand All @@ -522,18 +468,6 @@ export type UserAsProfile = Omit<UserItem, "roles"> & {
}[];
};

export type UpdateUserDetails = {
first_name?: string;
last_name?: string;
age?: number;
gender?: number;
country?: string;
city?: string;
street?: string;
postcode?: string;
phone?: string;
} & Record<string, string | number | boolean | null>;

export type UpdateUserEmail = {
email?: string;
};
Expand Down Expand Up @@ -952,15 +886,6 @@ export type Payment = {
payable: Order;
};

export type UserGroup = {
id: number;
name: string;
users: UserItem[];
name_with_breadcrumbs?: string;
parent_id?: null | number;
registerable?: boolean;
};

export type UserGroupsParams = {
current?: number;
pageSize?: number;
Expand Down
24 changes: 22 additions & 2 deletions src/types/core-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// core-types.ts

export type Nullable<T> = T | null | undefined;

export type IStatementCategory = {
Expand Down Expand Up @@ -104,3 +102,25 @@ export type PageParams = {
};

export type Json = string | number | Json[] | { [key: string]: Json };

export type Category = {
id: number;
name: string;
slug: string;
is_active: boolean;
parent_id?: number;
icon?: string;
icon_class: string;
created_at: string;
updated_at: string;
order: number;
pivot?: {
course_id: number;
category_id: number;
};
subcategories?: Category[];
count?: number;
count_free?: number;
description?: string;
name_with_breadcrumbs?: string;
};
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./enums";
export * from "./core-types";
export * from "./user-types";
export * from "./api";
57 changes: 57 additions & 0 deletions src/types/user-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Category, DefaultMetaResponse, DefaultResponse } from "./core-types";

export type UserItem = Partial<
Exclude<
EscolaLms.Auth.Models.User,
| "password"
| "remember_token"
| "password_reset_token"
| "email_verified_at"
| "is_active"
>
> & {
// id: number;
// name: string;
// first_name: string;
// last_name: string;
// email: string;
// is_active: boolean;
// created_at: string;
// onboarding_completed: boolean;
// email_verified: boolean;
avatar?: string;
url_avatar: string | null;
// path_avatar: string | null;
bio?: string | null;
categories?: Category[] | null;
interests?: Array<EscolaLms.Categories.Models.Category> | null | never[];
};

export type UpdateUserDetails = {
first_name?: string;
last_name?: string;
age?: number;
gender?: number;
country?: string;
city?: string;
street?: string;
postcode?: string;
phone?: string;
} & Record<string, string | number | boolean | null>;

export type UserGroup = {
id: number;
name: string;
users: UserItem[];
name_with_breadcrumbs?: string;
parent_id?: null | number;
registerable?: boolean;
};

export type UserGroups = UserGroup[];

export type UserGroupRow = DefaultResponse<UserGroup>;

export type UserGroupAddRow = DefaultResponse<UserItem[]>;

export type UserGroupList = DefaultMetaResponse<UserGroup>;

0 comments on commit 6153cbd

Please sign in to comment.