// Dependencies import { linkClasses, cloudflareImageUrl, getSearchParam } from '@freesewing/utils' // Context import { ModalContext } from '@freesewing/react/context/Modal' // Hooks import React, { useState, useEffect, useContext } from 'react' import { useAccount } from '@freesewing/react/hooks/useAccount' import { useBackend } from '@freesewing/react/hooks/useBackend' // Components import { ModalWrapper } from '@freesewing/react/components/Modal' import { Link as WebLink } from '@freesewing/react/components/Link' import { NoIcon, OkIcon, SaveIcon, RightIcon, WarningIcon } from '@freesewing/react/components/Icon' import { MiniWarning } from '@freesewing/react/components/Mini' import { KeyVal } from '@freesewing/react/components/KeyVal' import Markdown from 'react-markdown' /* * Component for the currently authenticated user's profile * * @params {object} props - All React props * @param {number} props.uid - The user ID for which to show the profile * @param {function} props.Link - An optional framework-specific Link component */ export const OwnProfile = (props) => { const { account } = useAccount() return } /* * Component for a user profile * * @params {object} props - All React props * @param {number} props.uid - The user ID for which to show the profile * @param {function} props.Link - An optional framework-specific Link component */ export const UserProfile = ({ Link = false, setTitle = false, uid = false, noBox = false, fromUrl = false, }) => { if (!uid && !fromUrl) return ( You must provide either a uid or fromUrl prop ) if (!Link) Link = WebLink const [ruid, setRuid] = useState() // Hooks const backend = useBackend() // State const [data, setData] = useState(false) // Effect useEffect(() => { if (uid && uid !== ruid) setRuid(uid) if (fromUrl) { const urlId = getSearchParam(fromUrl) if (urlId && urlId !== ruid) setRuid(urlId) } if (ruid) loadProfileData(ruid, backend, setData) }, [uid, fromUrl, ruid]) return ( <>

{data.username}

Permalink: {`freesewing.eu/users?id=${ruid}`}
{data.bio} ) } /* * Shows an avatar image * * @param {string} ihash - The ihash of the account */ export const Avatar = ({ ihash }) => { const { setModal } = useContext(ModalContext) return ( ) } async function loadProfileData(uid, backend, setData) { const [status, body] = await backend.getUserProfile(uid) if (status === 200 && body.result === 'success' && body.profile) setData(body.profile) }