user-logout-card.jsx (1651B)
1 /* 2 GoToSocial 3 Copyright (C) GoToSocial Authors admin@gotosocial.org 4 SPDX-License-Identifier: AGPL-3.0-or-later 5 6 This program is free software: you can redistribute it and/or modify 7 it under the terms of the GNU Affero General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU Affero General Public License for more details. 15 16 You should have received a copy of the GNU Affero General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 "use strict"; 21 22 const React = require("react"); 23 24 const query = require("../lib/query"); 25 26 const Loading = require("./loading"); 27 28 module.exports = function UserLogoutCard() { 29 const { data: profile, isLoading } = query.useVerifyCredentialsQuery(); 30 const { data: instance } = query.useInstanceQuery(); 31 const [logoutQuery] = query.useLogoutMutation(); 32 33 if (isLoading) { 34 return <Loading />; 35 } else { 36 return ( 37 <div className="account-card"> 38 <img className="avatar" src={profile.avatar} alt="" /> 39 <h3 className="text-cutoff">{profile.display_name?.length > 0 ? profile.display_name : profile.acct}</h3> 40 <span className="text-cutoff">@{profile.username}@{instance?.account_domain}</span> 41 <a onClick={logoutQuery} href="#" aria-label="Log out" title="Log out" className="logout"> 42 <i className="fa fa-fw fa-sign-out" aria-hidden="true" /> 43 </a> 44 </div> 45 ); 46 } 47 };