feat: lots updates
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
// import React from "react";
|
||||
import { NavLink, useNavigate } from "react-router-dom";
|
||||
import dayjs from "dayjs";
|
||||
import relativeTime from "dayjs/plugin/relativeTime";
|
||||
import { useDrop } from "react-dnd";
|
||||
import { NativeTypes } from "react-dnd-html5-backend";
|
||||
import Contact from "../../common/component/Contact";
|
||||
dayjs.extend(relativeTime);
|
||||
const NavItem = ({ data, setFiles }) => {
|
||||
const navigate = useNavigate();
|
||||
const [{ isActive }, drop] = useDrop(() => ({
|
||||
@@ -35,7 +37,7 @@ const NavItem = ({ data, setFiles }) => {
|
||||
<div className="details">
|
||||
<div className="up">
|
||||
<span className="name">{user.name}</span>
|
||||
<time>{dayjs(lastMsg.created_at).format("YYYY-MM-DD")}</time>
|
||||
<time>{dayjs(lastMsg.created_at).fromNow()}</time>
|
||||
</div>
|
||||
|
||||
<div className="down">
|
||||
|
||||
@@ -20,7 +20,6 @@ export default function HomePage() {
|
||||
const {
|
||||
ui: { menuExpand, setting, channelSetting },
|
||||
authData: { usersVersion, afterMid },
|
||||
contacts,
|
||||
} = useSelector((store) => {
|
||||
return {
|
||||
authData: store.authData,
|
||||
@@ -74,7 +73,7 @@ export default function HomePage() {
|
||||
<Outlet />
|
||||
</div>
|
||||
</StyledWrapper>
|
||||
{setting && <SettingModal contacts={contacts} />}
|
||||
{setting && <SettingModal />}
|
||||
{channelSetting && <ChannelSettingModal id={channelSetting} />}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
/* eslint-disable no-undef */
|
||||
import { useEffect } from "react";
|
||||
import { useGetOpenidMutation } from "../../app/services/auth";
|
||||
export default function SolidLoginButton({ login }) {
|
||||
export default function SolidLoginButton() {
|
||||
const [getOpenId, { data, isLoading, isSuccess }] = useGetOpenidMutation();
|
||||
|
||||
const handleSolidLogin = async () => {
|
||||
getOpenId({ issuer_url: "https://solidweb.org" });
|
||||
const handleSolidLogin = () => {
|
||||
getOpenId({
|
||||
issuer_url: "https://solidweb.org",
|
||||
redirect_uri: `${location.origin}/#/login`,
|
||||
});
|
||||
};
|
||||
useEffect(() => {
|
||||
if (isSuccess) {
|
||||
console.log("wtf", data);
|
||||
const { id, url } = data;
|
||||
window.open(url);
|
||||
login({
|
||||
id,
|
||||
type: "oidc",
|
||||
});
|
||||
// location.href = url;
|
||||
const { url } = data;
|
||||
location.href = url;
|
||||
}
|
||||
}, [data, isSuccess]);
|
||||
|
||||
@@ -32,7 +30,7 @@ export default function SolidLoginButton({ login }) {
|
||||
src="https://solidproject.org/assets/img/solid-emblem.svg"
|
||||
alt="solid logo icon"
|
||||
/>
|
||||
Sign in with Solid
|
||||
{isLoading ? `Redirecting...` : `Sign in with Solid`}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,14 +15,24 @@ import { setAuthData } from "../../app/slices/auth.data";
|
||||
|
||||
export default function LoginPage() {
|
||||
const [login, { data, isSuccess, isLoading, error }] = useLoginMutation();
|
||||
|
||||
// const { token } = useSelector((store) => store.authData);
|
||||
const navigateTo = useNavigate();
|
||||
const dispatch = useDispatch();
|
||||
const [input, setInput] = useState({
|
||||
email: "",
|
||||
password: "",
|
||||
});
|
||||
useEffect(() => {
|
||||
const query = new URLSearchParams(location.search);
|
||||
const code = query.get("code");
|
||||
const state = query.get("state");
|
||||
if (code && state) {
|
||||
login({
|
||||
code,
|
||||
state,
|
||||
type: "oidc",
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (error) {
|
||||
@@ -37,7 +47,6 @@ export default function LoginPage() {
|
||||
case 404:
|
||||
toast.error("account not exsit");
|
||||
break;
|
||||
|
||||
default:
|
||||
toast.error("something error");
|
||||
break;
|
||||
@@ -110,7 +119,7 @@ export default function LoginPage() {
|
||||
<hr className="or" />
|
||||
<GoogleLoginButton login={login} />
|
||||
<MetamaskLoginButton login={login} />
|
||||
<SolidLoginButton login={login} />
|
||||
<SolidLoginButton />
|
||||
</div>
|
||||
</StyledWrapper>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user