build fix
This commit is contained in:
parent
fdddb44c4d
commit
a7f64bdabd
@ -1,3 +1,57 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
|
export type MailFolder = string;
|
||||||
|
|
||||||
|
export interface Email {
|
||||||
|
id: string;
|
||||||
|
accountId?: string;
|
||||||
|
folder?: string;
|
||||||
|
subject: string;
|
||||||
|
from: string;
|
||||||
|
to: string;
|
||||||
|
date: string;
|
||||||
|
flags: {
|
||||||
|
seen: boolean;
|
||||||
|
flagged: boolean;
|
||||||
|
answered: boolean;
|
||||||
|
draft: boolean;
|
||||||
|
};
|
||||||
|
body?: string;
|
||||||
|
bodyHtml?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EmailData {
|
||||||
|
to: string;
|
||||||
|
cc?: string;
|
||||||
|
bcc?: string;
|
||||||
|
subject: string;
|
||||||
|
body: string;
|
||||||
|
attachments?: Array<{
|
||||||
|
name: string;
|
||||||
|
content: string;
|
||||||
|
type: string;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hook for managing email operations
|
||||||
|
export const useCourrier = () => {
|
||||||
|
// State for email data
|
||||||
|
const [emails, setEmails] = useState<Email[]>([]);
|
||||||
|
const [selectedEmail, setSelectedEmail] = useState<Email | null>(null);
|
||||||
|
const [selectedEmailIds, setSelectedEmailIds] = useState<string[]>([]);
|
||||||
|
const [currentFolder, setCurrentFolder] = useState<MailFolder>('INBOX');
|
||||||
|
const [mailboxes, setMailboxes] = useState<string[]>([]);
|
||||||
|
|
||||||
|
// State for UI
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [isSending, setIsSending] = useState(false);
|
||||||
|
const [isDeleting, setIsDeleting] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [searchQuery, setSearchQuery] = useState('');
|
||||||
|
const [page, setPage] = useState(1);
|
||||||
|
const [perPage, setPerPage] = useState(20);
|
||||||
|
const [totalPages, setTotalPages] = useState(0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the current folder and load emails from that folder
|
* Change the current folder and load emails from that folder
|
||||||
*/
|
*/
|
||||||
@ -134,3 +188,40 @@ const loadEmails = async (
|
|||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
// State
|
||||||
|
emails,
|
||||||
|
selectedEmail,
|
||||||
|
selectedEmailIds,
|
||||||
|
currentFolder,
|
||||||
|
mailboxes,
|
||||||
|
isLoading,
|
||||||
|
isSending,
|
||||||
|
isDeleting,
|
||||||
|
error,
|
||||||
|
searchQuery,
|
||||||
|
page,
|
||||||
|
perPage,
|
||||||
|
totalPages,
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
setEmails,
|
||||||
|
setSelectedEmail,
|
||||||
|
setSelectedEmailIds,
|
||||||
|
setCurrentFolder,
|
||||||
|
setMailboxes,
|
||||||
|
setIsLoading,
|
||||||
|
setIsSending,
|
||||||
|
setIsDeleting,
|
||||||
|
setError,
|
||||||
|
setSearchQuery,
|
||||||
|
setPage,
|
||||||
|
setPerPage,
|
||||||
|
setTotalPages,
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
changeFolder,
|
||||||
|
loadEmails
|
||||||
|
};
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue
Block a user