- Updated the `addContact` function to allow all users to add contacts, removing the previous restriction that only masters could do so. - Deleted the `become-master` feature and related utility functions, streamlining the codebase. - Adjusted command settings to reflect the removal of the master role functionality. - Refactored components and hooks to eliminate dependencies on the master role, enhancing user experience and simplifying logic.
45 lines
1.8 KiB
TypeScript
45 lines
1.8 KiB
TypeScript
import { getCustomer } from '@/actions/api/customers';
|
|
import { getSessionUser } from '@/actions/session';
|
|
import { Container } from '@/components/layout';
|
|
import { PageHeader } from '@/components/navigation';
|
|
import { ContactDataCard, PersonCard, ProfileOrdersList } from '@/components/profile';
|
|
import { ReadonlyServicesList } from '@/components/profile/services';
|
|
import { dehydrate, HydrationBoundary, QueryClient } from '@tanstack/react-query';
|
|
|
|
// Тип параметров страницы
|
|
type Props = { params: Promise<{ telegramId: string }> };
|
|
|
|
export default async function ProfilePage(props: Readonly<Props>) {
|
|
const { telegramId } = await props.params;
|
|
const contactTelegramId = Number(telegramId);
|
|
const queryClient = new QueryClient();
|
|
|
|
// Получаем профиль контакта
|
|
const { customer: profile } = await queryClient.fetchQuery({
|
|
queryFn: () => getCustomer({ telegramId: contactTelegramId }),
|
|
queryKey: ['customer', contactTelegramId],
|
|
});
|
|
|
|
// Получаем текущего пользователя
|
|
const sessionUser = await getSessionUser();
|
|
const { customer: currentUser } = await queryClient.fetchQuery({
|
|
queryFn: () => getCustomer({ telegramId: sessionUser.telegramId }),
|
|
queryKey: ['customer', sessionUser.telegramId],
|
|
});
|
|
|
|
// Проверка наличия данных
|
|
if (!profile || !currentUser) return null;
|
|
|
|
return (
|
|
<HydrationBoundary state={dehydrate(queryClient)}>
|
|
<PageHeader title="Профиль контакта" />
|
|
<Container className="px-0">
|
|
<PersonCard telegramId={contactTelegramId} />
|
|
<ContactDataCard telegramId={contactTelegramId} />
|
|
<ReadonlyServicesList masterId={profile.documentId} />
|
|
<ProfileOrdersList telegramId={contactTelegramId} />
|
|
</Container>
|
|
</HydrationBoundary>
|
|
);
|
|
}
|