🐛(fix) add enabled update your mailbox
can update your mailbox as viewer
This commit is contained in:
@@ -8,6 +8,8 @@ and this project adheres to
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- 🐛(fix) add enabled update your mailbox
|
||||
|
||||
## [1.19.0] - 2025-09-03
|
||||
|
||||
- ✨(front) add modal update mailboxes #954
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Box, Tag, Text, TextErrors } from '@/components';
|
||||
import { useAuthStore } from '@/core/auth';
|
||||
import { MailDomain } from '@/features/mail-domains/domains';
|
||||
import {
|
||||
MailDomainMailbox,
|
||||
@@ -40,6 +41,7 @@ export function MailBoxesListView({
|
||||
querySearch,
|
||||
}: MailBoxesListViewProps) {
|
||||
const { t } = useTranslation();
|
||||
const { userData } = useAuthStore();
|
||||
|
||||
const [sortModel] = useState<SortModel>([]);
|
||||
|
||||
@@ -68,29 +70,32 @@ export function MailBoxesListView({
|
||||
return [];
|
||||
}
|
||||
return data.pages.flatMap((page) =>
|
||||
page.results.map((mailbox: MailDomainMailbox) => ({
|
||||
page.results.map((mailbox: MailDomainMailbox) => {
|
||||
const email = `${mailbox.local_part}@${mailDomain.name}`;
|
||||
const isCurrentUser = userData?.email === email;
|
||||
|
||||
return {
|
||||
id: mailbox.id,
|
||||
email: `${mailbox.local_part}@${mailDomain.name}`,
|
||||
email,
|
||||
name: `${mailbox.first_name} ${mailbox.last_name}`,
|
||||
first_name: mailbox.first_name,
|
||||
last_name: mailbox.last_name,
|
||||
name: `${mailbox.first_name} ${mailbox.last_name}`,
|
||||
local_part: mailbox.local_part,
|
||||
secondary_email: mailbox.secondary_email,
|
||||
status: mailbox.status,
|
||||
mailbox,
|
||||
})),
|
||||
isCurrentUser,
|
||||
};
|
||||
}),
|
||||
);
|
||||
}, [data, mailDomain]);
|
||||
}, [data, mailDomain, userData?.email]);
|
||||
|
||||
const filteredMailboxes = useMemo(() => {
|
||||
if (typeof querySearch !== 'string' || !querySearch) {
|
||||
if (!querySearch) {
|
||||
return mailboxes;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
const lowerCaseSearch = querySearch.toLowerCase();
|
||||
return mailboxes.filter(
|
||||
(mailbox) =>
|
||||
typeof mailbox.email === 'string' &&
|
||||
return mailboxes.filter((mailbox) =>
|
||||
mailbox.email.toLowerCase().includes(lowerCaseSearch),
|
||||
);
|
||||
}, [querySearch, mailboxes]);
|
||||
@@ -133,7 +138,14 @@ export function MailBoxesListView({
|
||||
{
|
||||
field: 'email',
|
||||
headerName: `${t('Address')} • ${filteredMailboxes.length}`,
|
||||
renderCell: ({ row }) => <Text>{row.email}</Text>,
|
||||
renderCell: ({ row }) => (
|
||||
<Text
|
||||
$weight={row.isCurrentUser ? '600' : '400'}
|
||||
$theme={row.isCurrentUser ? 'primary' : 'greyscale'}
|
||||
>
|
||||
{row.email}
|
||||
</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
@@ -145,7 +157,7 @@ export function MailBoxesListView({
|
||||
$theme="greyscale"
|
||||
$css="text-transform: capitalize;"
|
||||
>
|
||||
{`${row.first_name} ${row.last_name}`}
|
||||
{row.name}
|
||||
</Text>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -69,7 +69,7 @@ export const PanelActions = ({ mailDomain, mailbox }: PanelActionsProps) => {
|
||||
if (
|
||||
mailbox.status === 'pending' ||
|
||||
mailbox.status === 'failed' ||
|
||||
mailDomain.abilities.post === false
|
||||
(mailDomain.abilities.post === false && !mailbox.isCurrentUser)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -18,9 +18,12 @@ export type MailDomainMailboxStatus =
|
||||
export interface ViewMailbox {
|
||||
id: string;
|
||||
email: string;
|
||||
name: string;
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
local_part: string;
|
||||
secondary_email: string;
|
||||
status: MailDomainMailboxStatus;
|
||||
mailbox: MailDomainMailbox;
|
||||
isCurrentUser?: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user