react-floating-profile
Version:
React component to display your github profile <p align="left"> <a href="https://www.npmjs.com/package/react-floating-profile"><img src="https://flat.badgen.net/npm/v/react-floating-profile" alt="react-floating-profile version" /></a> <a href="http
22 lines (21 loc) • 1.52 kB
JavaScript
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import FloatingIcon from "./floating-icon";
import FloatingModal from "./floating-modal";
import { useEffect } from "react";
import { useAuth, useProfile } from "../../context";
import { getRepoItem, getUserProfile } from "../../api";
export default function FloatingProfileContainer(_a) {
var location = _a.location, accessToken = _a.accessToken, userName = _a.userName, _b = _a.pinnedRepoArr, pinnedRepoArr = _b === void 0 ? [] : _b;
var _c = useProfile(), userObj = _c.userObj, setUserObj = _c.setUserObj, pinnedRepoItemArr = _c.pinnedRepoItemArr, setPinnedRepoItemArr = _c.setPinnedRepoItemArr;
var setAccessToken = useAuth().setAccessToken;
useEffect(function () {
setAccessToken(accessToken);
getUserProfile(userName, accessToken)
.then(function (data) { return setUserObj(data); })
.catch(function () { return console.error("유저정보 못 가져옴"); });
getRepoItem(userName, pinnedRepoArr, accessToken)
.then(function (data) { return setPinnedRepoItemArr(data); })
.catch(function () { return console.error("레포정보 못 가져옴"); });
}, []);
return (_jsx("div", { className: "floating-profile-container", children: userObj && (_jsxs(_Fragment, { children: [_jsx(FloatingIcon, { avatar_url: userObj.avatar_url, location: location }), _jsx(FloatingModal, { userObj: userObj, pinnedRepoArr: pinnedRepoItemArr })] })) }));
}