/
viktorphp
/
front-socket
Обзор
Документация
Войти
/
viktorphp
/
front-socket
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/widgets/profile/server/ui/Profile.tsx
49 строк
1 KB
Viktorphp84
feature-socket: Поправить верстку на странице профиля, исправить сохранение дат.
12 окт 2025, 01:53
12 окт 2025, 01:53
93fb0bf
Код
Авторство
О чём код?
'use server'; import { Stack } from '@mui/material'; import { headers } from 'next/headers'; import { getUserFromCookie } from '@shared/lib'; import { IUser } from '@shared/types'; import { ProfileForm } from '@widgets/profile'; export const Profile = async () => { const userData: IUser | null = await getUserFromCookie(); if (!userData) { return null; } const cookies = (await headers()).get('Cookie'); const cookieHeader = cookies ?.split(';') .map((cookie) => { const [name, value] = cookie.trim().split('='); return `${name}=${encodeURIComponent(value)}`; }) .join('; '); const avatar = await fetch('http://localhost:3010/api/profile/avatar', { credentials: 'include', headers: { Accept: 'image/*', Cookie: cookieHeader || '', }, }); const avatarSrc = await avatar.text(); return ( <Stack justifyContent={'center'} alignItems={'center'} borderRadius={3} sx={{ backgroundColor: 'white', width: '80%' }} boxShadow={3} padding={4} boxSizing={'border-box'} > <ProfileForm userData={userData} avatarSrc={avatarSrc} /> </Stack> ); };