mirror of
https://github.com/Luchexx/wacrm.git
synced 2026-11-02 09:19:51 +00:00
Merge pull request #254 from ArnasDon/feat/inbox-unread-filter
feat(inbox): add "Unread" filter to conversation list
This commit is contained in:
commit
d6c595c0ed
@ -36,8 +36,11 @@ const STATUS_COLORS: Record<ConversationStatus, string> = {
|
|||||||
closed: "bg-muted-foreground",
|
closed: "bg-muted-foreground",
|
||||||
};
|
};
|
||||||
|
|
||||||
const FILTER_OPTIONS: { label: string; value: ConversationStatus | "all" }[] = [
|
type InboxFilter = ConversationStatus | "all" | "unread";
|
||||||
|
|
||||||
|
const FILTER_OPTIONS: { label: string; value: InboxFilter }[] = [
|
||||||
{ label: "All", value: "all" },
|
{ label: "All", value: "all" },
|
||||||
|
{ label: "Unread", value: "unread" },
|
||||||
{ label: "Open", value: "open" },
|
{ label: "Open", value: "open" },
|
||||||
{ label: "Pending", value: "pending" },
|
{ label: "Pending", value: "pending" },
|
||||||
{ label: "Closed", value: "closed" },
|
{ label: "Closed", value: "closed" },
|
||||||
@ -51,7 +54,7 @@ export function ConversationList({
|
|||||||
resyncToken = 0,
|
resyncToken = 0,
|
||||||
}: ConversationListProps) {
|
}: ConversationListProps) {
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
const [filter, setFilter] = useState<ConversationStatus | "all">("all");
|
const [filter, setFilter] = useState<InboxFilter>("all");
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
// Keep the latest callback in a ref so the fetch effect below can
|
// Keep the latest callback in a ref so the fetch effect below can
|
||||||
@ -110,7 +113,9 @@ export function ConversationList({
|
|||||||
const filtered = useMemo(() => {
|
const filtered = useMemo(() => {
|
||||||
let result = conversations;
|
let result = conversations;
|
||||||
|
|
||||||
if (filter !== "all") {
|
if (filter === "unread") {
|
||||||
|
result = result.filter((c) => c.unread_count > 0);
|
||||||
|
} else if (filter !== "all") {
|
||||||
result = result.filter((c) => c.status === filter);
|
result = result.filter((c) => c.status === filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user