filter and search inbox
This commit is contained in:
@@ -202,16 +202,16 @@ const List: FC = () => {
|
||||
|
||||
<Filters
|
||||
fields={[
|
||||
{ type: 'date', name: 'dateFrom', placeholder: t('received.from_date') },
|
||||
{ type: 'date', name: 'dateTo', placeholder: t('received.to_date') },
|
||||
{ type: 'date', name: 'datestart', placeholder: t('received.from_date') },
|
||||
{ type: 'date', name: 'dateend', placeholder: t('received.to_date') },
|
||||
{
|
||||
type: 'select',
|
||||
name: 'isRead',
|
||||
name: 'unseen',
|
||||
placeholder: t('received.all'),
|
||||
options: [
|
||||
{ value: '', label: t('received.all') },
|
||||
{ value: 'true', label: t('received.read') },
|
||||
{ value: 'false', label: t('received.unread') }
|
||||
{ value: 'false', label: t('received.read') },
|
||||
{ value: 'true', label: t('received.unread') }
|
||||
]
|
||||
},
|
||||
{ type: 'input', name: 'search', placeholder: t('received.search') }
|
||||
|
||||
@@ -27,7 +27,19 @@ export const getDraft = async (
|
||||
export const getInbox = async (
|
||||
query: MessageListQueryDto
|
||||
): Promise<InboxResponse> => {
|
||||
const { data } = await axios.get(`/email/messages/inbox`, { params: query });
|
||||
console.log("query", query);
|
||||
|
||||
const isSearch =
|
||||
!!query.search ||
|
||||
!!query.datestart ||
|
||||
query.dateend ||
|
||||
query.unseen ||
|
||||
query.from;
|
||||
const url = isSearch ? "search" : "messages/inbox";
|
||||
|
||||
const { data } = await axios.get(`/email/${url}`, {
|
||||
params: query,
|
||||
});
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -41,105 +53,75 @@ export const getMessageDetail = async (
|
||||
return data.data.message;
|
||||
};
|
||||
|
||||
export const deleteMessage = async (messageId: string): Promise<void> => {
|
||||
export const deleteMessage = async (messageId: string) => {
|
||||
const { data } = await axios.delete(`/email/messages/${messageId}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const moveToArchive = async (
|
||||
messageId: string,
|
||||
mailbox: string
|
||||
): Promise<void> => {
|
||||
export const moveToArchive = async (messageId: string, mailbox: string) => {
|
||||
const { data } = await axios.patch(
|
||||
`/email/messages/${messageId}/archive?mailbox=${mailbox}`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const moveToTrash = async (
|
||||
messageId: string,
|
||||
mailbox: string
|
||||
): Promise<void> => {
|
||||
export const moveToTrash = async (messageId: string, mailbox: string) => {
|
||||
const { data } = await axios.patch(
|
||||
`/email/messages/${messageId}/trash?mailbox=${mailbox}`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const moveToFavorite = async (
|
||||
messageId: string,
|
||||
mailbox: string
|
||||
): Promise<void> => {
|
||||
export const moveToFavorite = async (messageId: string, mailbox: string) => {
|
||||
const { data } = await axios.patch(
|
||||
`/email/messages/${messageId}/favorite?mailbox=${mailbox}`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const moveToJunk = async (
|
||||
messageId: string,
|
||||
mailbox: string
|
||||
): Promise<void> => {
|
||||
export const moveToJunk = async (messageId: string, mailbox: string) => {
|
||||
const { data } = await axios.patch(
|
||||
`/email/messages/${messageId}/junk?mailbox=${mailbox}`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const moveToNotJunk = async (
|
||||
messageId: string,
|
||||
mailbox: string
|
||||
): Promise<void> => {
|
||||
export const moveToNotJunk = async (messageId: string, mailbox: string) => {
|
||||
const { data } = await axios.patch(
|
||||
`/email/messages/${messageId}/not-junk?mailbox=${mailbox}`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const restoreMessage = async (
|
||||
messageId: string,
|
||||
mailbox: string
|
||||
): Promise<void> => {
|
||||
export const restoreMessage = async (messageId: string, mailbox: string) => {
|
||||
const { data } = await axios.patch(
|
||||
`/email/messages/${messageId}/restore?mailbox=${mailbox}`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const unFavoriteMessage = async (
|
||||
messageId: string,
|
||||
mailbox: string
|
||||
): Promise<void> => {
|
||||
export const unFavoriteMessage = async (messageId: string, mailbox: string) => {
|
||||
const { data } = await axios.patch(
|
||||
`/email/messages/${messageId}/unfavorite?mailbox=${mailbox}`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const unArchiveMessage = async (
|
||||
messageId: string,
|
||||
mailbox: string
|
||||
): Promise<void> => {
|
||||
export const unArchiveMessage = async (messageId: string, mailbox: string) => {
|
||||
const { data } = await axios.patch(
|
||||
`/email/messages/${messageId}/unarchive?mailbox=${mailbox}`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const markAsRead = async (
|
||||
messageId: string,
|
||||
mailbox: string
|
||||
): Promise<void> => {
|
||||
export const markAsRead = async (messageId: string, mailbox: string) => {
|
||||
const { data } = await axios.patch(
|
||||
`/email/messages/${messageId}/seen?mailbox=${mailbox}`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const markAsUnread = async (
|
||||
messageId: string,
|
||||
mailbox: string
|
||||
): Promise<void> => {
|
||||
export const markAsUnread = async (messageId: string, mailbox: string) => {
|
||||
const { data } = await axios.patch(
|
||||
`/email/messages/${messageId}/unseen?mailbox=${mailbox}`
|
||||
);
|
||||
|
||||
@@ -56,15 +56,15 @@ export interface SendEmailDto {
|
||||
export interface MessageListQueryDto {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
order?: string;
|
||||
search?: string;
|
||||
from?: string;
|
||||
subject?: string;
|
||||
dateFrom?: string;
|
||||
dateTo?: string;
|
||||
hasAttachment?: boolean;
|
||||
isRead?: boolean;
|
||||
isFlagged?: boolean;
|
||||
datestart?: string;
|
||||
dateend?: string;
|
||||
attachments?: boolean;
|
||||
unseen?: boolean;
|
||||
flagged?: boolean;
|
||||
order?: "asc" | "desc";
|
||||
}
|
||||
|
||||
// Updated types based on actual API response
|
||||
|
||||
Reference in New Issue
Block a user