touchstudy-core 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ import { IChatListProps } from "./ChatList";
2
+ import { IInputChatProps } from "./InputChat";
3
+ import { IChatHeaderProps } from "./ChatHeader";
4
+ import { FC } from "react";
5
+ export interface IChatContainerProps {
6
+ chatHeaderProps: IChatHeaderProps;
7
+ chatListProps: IChatListProps;
8
+ inputProps: IInputChatProps;
9
+ height?: string;
10
+ onRead?: () => void;
11
+ }
12
+ declare const ChatContainer: FC<IChatContainerProps>;
13
+ export default ChatContainer;
@@ -0,0 +1,17 @@
1
+ import { FC } from "react";
2
+ import { Option } from "./configs/types";
3
+ export interface IExamOption {
4
+ id: number;
5
+ code: string;
6
+ title: string;
7
+ createdAt: string;
8
+ startTime: string;
9
+ }
10
+ export interface IChatHeaderProps {
11
+ name: string;
12
+ avatar?: string;
13
+ options?: IExamOption[];
14
+ onChangeOption?: (value: Option) => void;
15
+ }
16
+ declare const ChatHeader: FC<IChatHeaderProps>;
17
+ export default ChatHeader;
@@ -0,0 +1,39 @@
1
+ import { FC } from "react";
2
+ import React from "react";
3
+ import { MessageStatus } from "./configs/types";
4
+ export interface IChatItemProps {
5
+ id?: number;
6
+ isMe?: boolean;
7
+ name: string;
8
+ avatar?: string;
9
+ isSystemLog?: boolean;
10
+ content?: string;
11
+ createdAt: string;
12
+ isRead: boolean;
13
+ type?: ChatItemType;
14
+ examCode?: string;
15
+ examId?: number;
16
+ parentId?: number;
17
+ parentContent?: string;
18
+ showExamHeader?: boolean;
19
+ isFirst?: boolean;
20
+ isLast?: boolean;
21
+ actionLink?: string;
22
+ examTitle?: string;
23
+ selectedReplyMessageId?: number;
24
+ selectedReplyItemRef?: React.RefObject<HTMLLIElement>;
25
+ status: MessageStatus;
26
+ onToggleReply?: (id: number) => void;
27
+ }
28
+ export interface IChatItemWithActionProps extends IChatItemProps {
29
+ onAddExamMessage?: (examId: number, title: string) => void;
30
+ onReply?: (id: number, content: string, examId?: number) => void;
31
+ onReTrySendMessage?: () => void;
32
+ }
33
+ export declare enum ChatItemType {
34
+ Default = 0,
35
+ Exam = 1,
36
+ Class = 2
37
+ }
38
+ declare const ChatItem: FC<IChatItemWithActionProps>;
39
+ export default ChatItem;
@@ -0,0 +1,4 @@
1
+ import { FC } from "react";
2
+ import { IChatItemWithActionProps } from "./ChatItem";
3
+ declare const ChatLeftItem: FC<IChatItemWithActionProps>;
4
+ export default ChatLeftItem;
@@ -0,0 +1,13 @@
1
+ import React, { FC } from "react";
2
+ import { IChatItemProps } from "./ChatItem";
3
+ export interface IChatListProps {
4
+ messages?: IChatItemProps[];
5
+ onAddExamMessage: (examId: number, examTitle: string) => void;
6
+ onReTrySendMessage?: () => void;
7
+ onReply?: (id: number, content: string, examId?: number) => void;
8
+ }
9
+ interface Props extends IChatListProps {
10
+ listItemRef: React.RefObject<HTMLUListElement>;
11
+ }
12
+ declare const ChatList: FC<Props>;
13
+ export default ChatList;
@@ -0,0 +1,8 @@
1
+ import { FC } from "react";
2
+ import { IChatItemWithActionProps } from "./ChatItem";
3
+ import { MessageRequest } from "./configs/types";
4
+ interface Props extends IChatItemWithActionProps {
5
+ onReTrySendMessage?: (req?: MessageRequest) => void;
6
+ }
7
+ declare const ChatRightItem: FC<Props>;
8
+ export default ChatRightItem;
@@ -0,0 +1,14 @@
1
+ import React, { FC } from "react";
2
+ export interface IInputChatProps {
3
+ text: string;
4
+ parentText?: string;
5
+ examTitle?: string;
6
+ onSubmit: () => void;
7
+ onChangeInput: (text: string) => void;
8
+ onClearReply?: () => void;
9
+ }
10
+ interface Props extends IInputChatProps {
11
+ inputRef: React.RefObject<HTMLInputElement>;
12
+ }
13
+ declare const InputChat: FC<Props>;
14
+ export default InputChat;
@@ -0,0 +1,7 @@
1
+ import { ConversationFilter, MessageFilter, MessageRequest } from "../configs/types";
2
+ export declare const getListConversation: (query: ConversationFilter) => Promise<import("axios").AxiosResponse<any, any>>;
3
+ export declare const createConversation: (studentId: number) => Promise<import("axios").AxiosResponse<any, any>>;
4
+ export declare const apiAddMessage: (conversationId: number, message: MessageRequest) => Promise<import("axios").AxiosResponse<any, any>>;
5
+ export declare const getMessagesByConversation: (conversationId: number, filter: MessageFilter) => Promise<import("axios").AxiosResponse<any, any>>;
6
+ export declare const apiMarkReadMessage: (conversationId: number, messageId: number) => Promise<import("axios").AxiosResponse<any, any>>;
7
+ export declare const apiGetConversationByUserId: (userId: number) => Promise<import("axios").AxiosResponse<any, any>>;
@@ -0,0 +1 @@
1
+ export declare const getListExamApi: (query: any) => Promise<import("axios").AxiosResponse<any, any>>;
@@ -0,0 +1,2 @@
1
+ import { ConversationFilter } from "../configs/types";
2
+ export declare const getStudentConversationListApi: (query: ConversationFilter) => Promise<import("axios").AxiosResponse<any, any>>;
@@ -0,0 +1,9 @@
1
+ import { ConversationFilter, MessageFilter } from "./types";
2
+ export declare enum ExamStatus {
3
+ Default = "Default",
4
+ Pending = "Pending",
5
+ Inprogress = "Inprogress",
6
+ Completed = "Completed"
7
+ }
8
+ export declare const CONVERSATION_DEFAULT_FILTER: ConversationFilter;
9
+ export declare const MESSAGE_DEFAULT_FILTER: MessageFilter;
@@ -0,0 +1,97 @@
1
+ import { ExamStatus } from "./constants";
2
+ export declare type ConversationResponse = {
3
+ id: number;
4
+ student: UserResponse;
5
+ teacher: UserResponse;
6
+ lastMessage: MessageResponse;
7
+ totalUnReadMessage: number;
8
+ };
9
+ export declare type UserResponse = {
10
+ id: number;
11
+ displayName: string;
12
+ avatar: string;
13
+ };
14
+ export declare type ConversationFilter = {
15
+ currentPage: number;
16
+ pageSize: number;
17
+ textSearch: string;
18
+ };
19
+ export declare type MessageFilter = {
20
+ currentPage?: number;
21
+ pageSize?: number;
22
+ textSearch?: string;
23
+ sortColumnDirection?: OrderBy;
24
+ sortColumnName?: MessageSortBy;
25
+ examId?: number;
26
+ };
27
+ export declare enum MessageSortBy {
28
+ CreatedAt = "CreatedAt"
29
+ }
30
+ export declare enum OrderBy {
31
+ ASC = "ASC",
32
+ DESC = "DESC"
33
+ }
34
+ export declare enum StudentSortBy {
35
+ CreatedAt = "CreatedAt",
36
+ DisplayName = "DisplayName"
37
+ }
38
+ export declare enum StudentOrderBy {
39
+ ASC = "ASC",
40
+ DESC = "DESC"
41
+ }
42
+ export declare type MessageResponse = {
43
+ id?: number;
44
+ isStudent: boolean;
45
+ conversationId?: number;
46
+ content: string;
47
+ isRead: boolean;
48
+ readAt?: string;
49
+ examId?: number;
50
+ createdAt: string;
51
+ exam?: ExamResponse;
52
+ action?: MessageAction;
53
+ isSystemLog?: boolean;
54
+ type?: MessageSourceType;
55
+ parentId?: number;
56
+ parentContent?: string;
57
+ };
58
+ export declare type ExamResponse = {
59
+ id: number;
60
+ title: string;
61
+ code: string;
62
+ startTime: string;
63
+ createdAt: string;
64
+ };
65
+ export declare type MessageRequest = {
66
+ content: string;
67
+ examId?: number;
68
+ parentId?: number;
69
+ parentContent?: string;
70
+ examTitle?: string;
71
+ };
72
+ export declare enum MessageAction {
73
+ Default = 0,
74
+ Took = 1
75
+ }
76
+ export declare enum MessageSourceType {
77
+ Default = 0,
78
+ Exam = 1,
79
+ Class = 2
80
+ }
81
+ export declare type ExamFilter = {
82
+ currentPage: number;
83
+ pageSize: number;
84
+ sortColumnName: string;
85
+ textSearch: string;
86
+ sortColumnDirection: string;
87
+ statuses?: ExamStatus[];
88
+ };
89
+ export declare type Option = {
90
+ value: number;
91
+ label: string;
92
+ };
93
+ export declare enum MessageStatus {
94
+ Default = "Sent",
95
+ Sending = "Sending...",
96
+ SentError = "Sent fail, Retry"
97
+ }
@@ -0,0 +1,46 @@
1
+ /// <reference types="react" />
2
+ import { IChatItemProps } from "../ChatItem";
3
+ import { ConversationResponse, MessageResponse, MessageRequest, MessageStatus } from "../configs/types";
4
+ interface Props {
5
+ conversation?: ConversationResponse;
6
+ userId?: number;
7
+ onUpdateLastMessage?: (message: MessageResponse) => void;
8
+ onUpdateConversation?: (conversation: ConversationResponse) => void;
9
+ onCreateConversationSuccess?: Function;
10
+ onGetMessagesSuccess?: Function;
11
+ examId?: number;
12
+ }
13
+ declare const useChatContainer: (props: Props) => {
14
+ chatHeaderProps: {
15
+ name: string;
16
+ avatar: string;
17
+ options: import("../configs/types").ExamResponse[] | undefined;
18
+ onChangeOption: (val: any) => void;
19
+ };
20
+ chatListProps: {
21
+ messages: IChatItemProps[];
22
+ onAddExamMessage: (examId: number, title: string) => void;
23
+ onReply: (parentId: number, content: string, examId?: number | undefined) => void;
24
+ onReTrySendMessage: () => Promise<void>;
25
+ };
26
+ inputProps: {
27
+ text: string;
28
+ parentText: string | undefined;
29
+ examTitle: string | undefined;
30
+ onChangeInput: (text: string) => void;
31
+ onSubmit: () => Promise<void>;
32
+ onClearReply: (() => void) | undefined;
33
+ };
34
+ exams: import("../configs/types").ExamResponse[] | undefined;
35
+ messageList: IChatItemProps[];
36
+ selectedConversation: ConversationResponse | undefined;
37
+ messageStatus: MessageStatus;
38
+ messageFilter: import("../configs/types").MessageFilter;
39
+ getMessageList: (conversationId: number, examId?: number | undefined) => Promise<void>;
40
+ handleFilterExam: (val: any) => void;
41
+ setMessage: import("react").Dispatch<import("react").SetStateAction<MessageRequest | undefined>>;
42
+ resetMessages: () => void;
43
+ getMessageConversation: () => Promise<void>;
44
+ handleMarkRead: () => Promise<void>;
45
+ };
46
+ export default useChatContainer;
@@ -0,0 +1,20 @@
1
+ import { ChangeEvent } from "react";
2
+ import { ConversationFilter, ConversationResponse, MessageResponse } from "../configs/types";
3
+ declare const useConversationList: () => {
4
+ isStudent: any;
5
+ conversationFilter: ConversationFilter;
6
+ selectedConversation: ConversationResponse | undefined;
7
+ conversations: ConversationResponse[];
8
+ handleUpdateTotalUnreadMessage: () => void;
9
+ handleChangeFilter: (filter: ConversationFilter) => void;
10
+ handleChangeSelectedConversation: (val: ConversationResponse) => void;
11
+ handleChangeTextSearch: (e: ChangeEvent<HTMLInputElement>) => void;
12
+ setSelectedConversation: import("react").Dispatch<import("react").SetStateAction<ConversationResponse | undefined>>;
13
+ handleUpdateLastMessage: (lastMessage: MessageResponse) => void;
14
+ getConversationList: () => Promise<void>;
15
+ formatConversationLastMessageContent: (conversation: ConversationResponse) => string;
16
+ handleNewMessageConversation: (val: ConversationResponse) => void;
17
+ handleCreateConversationSuccess: (id: number) => Promise<void>;
18
+ handleMessageReadConversation: (id: number, totalUnread: number) => void;
19
+ };
20
+ export default useConversationList;
@@ -0,0 +1,6 @@
1
+ import { ExamResponse } from "../configs/types";
2
+ declare const useExamList: (isStudent?: boolean) => {
3
+ getListExam: (userId?: number | undefined) => Promise<void>;
4
+ exams: ExamResponse[] | undefined;
5
+ };
6
+ export default useExamList;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { MessageResponse, MessageFilter } from "../configs/types";
3
+ declare const useMessageList: (userId?: number | undefined, getListExamOptions?: Function | undefined) => {
4
+ messageFilter: MessageFilter;
5
+ messages: MessageResponse[];
6
+ getMessageList: (conversationId: number, examId?: number | undefined) => Promise<void>;
7
+ setMessages: import("react").Dispatch<import("react").SetStateAction<MessageResponse[]>>;
8
+ resetMessages: () => void;
9
+ handleChangeMessageFilter: (filter: MessageFilter) => void;
10
+ handleChangeExamId: (value: any) => void;
11
+ handleMarkReadMessage: (conversationId: number, messageId: number) => Promise<void>;
12
+ };
13
+ export default useMessageList;
@@ -0,0 +1,3 @@
1
+ import { ConversationResponse } from "../configs/types";
2
+ declare const usePusherConversation: (onNewMessageConversation?: ((data: ConversationResponse) => void) | undefined, onReadMessageConversation?: ((id: number, total: number) => void) | undefined) => {};
3
+ export default usePusherConversation;
package/dist/index.css CHANGED
@@ -122,3 +122,51 @@
122
122
  ._1krbH ._CzNMi {
123
123
  background-color: #f1faff;
124
124
  color: #009ef7; }
125
+
126
+ ._2oGcJ {
127
+ width: 48px;
128
+ height: 48px;
129
+ -o-object-fit: cover;
130
+ object-fit: cover; }
131
+
132
+ ._2y2XV {
133
+ width: 200px; }
134
+
135
+ ._ntGyI {
136
+ overflow-y: auto; }
137
+
138
+ ._m7Fwt {
139
+ list-style-type: none; }
140
+ ._3BM8N {
141
+ width: calc(100% + 2rem);
142
+ margin-inline: -1rem; }
143
+ ._1ReOK {
144
+ width: 100%;
145
+ height: 100%;
146
+ -o-object-fit: cover;
147
+ object-fit: cover; }
148
+ ._2qbld {
149
+ width: 32px;
150
+ min-width: 32px;
151
+ aspect-ratio: 1; }
152
+ ._3s01i {
153
+ width: -moz-fit-content;
154
+ width: fit-content;
155
+ border-radius: 20px; }
156
+ ._2Qxi3 {
157
+ border-radius: 20px 20px 20px 0;
158
+ font-size: 14px; }
159
+ ._34Vx4 {
160
+ border-radius: 20px 20px 0px 20px;
161
+ font-size: 14px; }
162
+ ._3uheq {
163
+ border-radius: 0 20px 20px 20px; }
164
+ ._2iBr7 {
165
+ border-radius: 20px 0px 20px 20px; }
166
+
167
+ ._3ZPjO {
168
+ text-overflow: ellipsis;
169
+ overflow: hidden;
170
+ display: -webkit-box;
171
+ -webkit-line-clamp: 1;
172
+ -webkit-box-orient: vertical; }
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import store from "./store";
7
7
  import NotFound from "./components/Commons/NotFound";
8
8
  import Loading from "./components/Loading/Loading";
9
9
  import LayoutContext from "./layouts/LayoutContext";
10
- import { api } from "./services/api";
10
+ import { api } from "./configs/api";
11
11
  import { ConfirmDialog } from "./components/Dialogs/ConfirmDialog";
12
12
  import CommonDialog from "./components/Dialogs/CommonDialog";
13
13
  import CommonAlert from "./components/Alerts/CommonAlert";
@@ -24,4 +24,12 @@ import toISOString from "./utils/toISOString";
24
24
  import canAccessRoute from "./utils/canAccessRoute";
25
25
  import CustomSelect from "./components/Selects/CustomSelect";
26
26
  import getAccessToken from "./utils/getAccessToken";
27
- export { diffFromNow, formatTime, utcToLocalTime, setLoading, BASE_URL, ACCESS_TOKEN, Login, store, historyCore, setAlert, setUser, Loading, NotFound, LayoutContext, api, ConfirmDialog, CommonDialog, CommonAlert, CustomPagination, useGoogleSignOut, PUSHER_CONFIG, ExamEvent, EXAM_CHANNEL, EXAM_STUDENT_CHANNEL, setLanguage, i18n, TheLanguageDropdown, useTranslation, I18nextProvider, DATE_MIN_VALUE, minutesToTimeSpan, toISOString, canAccessRoute, CustomSelect, getAccessToken };
27
+ import ChatContainer, { IChatContainerProps } from "./components/Chats/ChatContainer";
28
+ import { ChatItemType, IChatItemProps } from "./components/Chats/ChatItem";
29
+ import { IChatHeaderProps } from "./components/Chats/ChatHeader";
30
+ import { IInputChatProps } from "./components/Chats/InputChat";
31
+ import useChatContainer from "./components/Chats/hooks/useChatContainer";
32
+ import useConversationList from "./components/Chats/hooks/useConversationList";
33
+ import { ConversationResponse, ExamResponse } from "./components/Chats/configs/types";
34
+ import usePusherConversation from "./components/Chats/hooks/usePusherConversation";
35
+ export { diffFromNow, formatTime, utcToLocalTime, setLoading, BASE_URL, ACCESS_TOKEN, Login, store, historyCore, setAlert, setUser, Loading, NotFound, LayoutContext, api, ConfirmDialog, CommonDialog, CommonAlert, CustomPagination, useGoogleSignOut, PUSHER_CONFIG, ExamEvent, EXAM_CHANNEL, EXAM_STUDENT_CHANNEL, setLanguage, i18n, TheLanguageDropdown, useTranslation, I18nextProvider, DATE_MIN_VALUE, minutesToTimeSpan, toISOString, canAccessRoute, CustomSelect, getAccessToken, ChatContainer, IChatContainerProps, IChatItemProps, IChatHeaderProps, IInputChatProps, ChatItemType, useChatContainer, useConversationList, ConversationResponse, ExamResponse, usePusherConversation };