@tycoonsystems/tycoon-modules
Version:
www.tv.tycoon.systems/documentation
1 lines • 994 B
JavaScript
import React from"react";import apiReq from"@tycoonsystems/tycoon-modules/utility/api/apiReq";const Module=a=>{const[e,o]=React.useState(null);var l=React.useCallback(async e=>{var l,t=a?.profileData?.user?.id;t&&a?._loggedIn?.identifier&&(l=a?.profileData?.isFollowing,o(l?"follow":"unfollow"),await apiReq("/p/generalrelationshipoperation",{apiUrl:a?.apiUrl,a:{id:a._loggedIn.identifier},aType:"userp",b:{id:t},bType:"userp",edge:{fw:!0,type:"follow"},status:"follow",identifier:a?._loggedIn?.identifier,hash:a?._loggedIn?.hash,unset:l}),a._LocalEventEmitter.dispatch("refetchDefaults",{dispatch:"simple"}))}),t=e?"follow"!==e:a?.profileData?.isFollowing??null;return React.createElement(React.Fragment,null,a?.profileData?.user?.id&&a?.profileData?.user?.id!==a?._loggedIn?.identifier?React.createElement("div",{className:`${a?.className??""} Profile_FollowContainer`},React.createElement("button",{style:{borderRadius:"1rem"},onClick:l},t?"Unfollow":"Follow")):null)};export default Module;