mirror of
https://github.com/wassname/talk.git
synced 2026-09-11 12:51:33 +08:00
SignOff Mutation
This commit is contained in:
@@ -7,13 +7,13 @@ import MatchMedia from "talk-ui/components/MatchMedia";
|
||||
import { User } from "../containers/UserBoxContainer";
|
||||
import * as styles from "./UserBoxAuthenticated.css";
|
||||
|
||||
export interface UserBoxUnauthenticatedProps {
|
||||
onSignOut: () => void;
|
||||
export interface UserBoxAuthenticatedProps {
|
||||
onSignOff: () => void;
|
||||
user: User;
|
||||
}
|
||||
|
||||
const UserBoxAuthenticated: StatelessComponent<
|
||||
UserBoxUnauthenticatedProps
|
||||
UserBoxAuthenticatedProps
|
||||
> = props => {
|
||||
return (
|
||||
<Flex itemGutter="half">
|
||||
@@ -40,7 +40,7 @@ const UserBoxAuthenticated: StatelessComponent<
|
||||
color="primary"
|
||||
size="small"
|
||||
variant="underlined"
|
||||
onClick={props.onSignOut}
|
||||
onClick={props.onSignOff}
|
||||
>
|
||||
Sign Out
|
||||
</Button>
|
||||
|
||||
@@ -9,7 +9,6 @@ import * as styles from "./UserBoxUnauthenticated.css";
|
||||
export interface UserBoxUnauthenticatedProps {
|
||||
onSignIn: () => void;
|
||||
onRegister: () => void;
|
||||
onSignOff: () => void;
|
||||
}
|
||||
|
||||
const UserBoxUnauthenticated: StatelessComponent<
|
||||
|
||||
@@ -1,29 +1,25 @@
|
||||
import React, { Component } from "react";
|
||||
import UserBoxUnauthenticated from "talk-stream/components/UserBoxUnauthenticated";
|
||||
import { withSignOffMutation } from "../../auth/mutations";
|
||||
import UserBoxAuthenticated from "talk-stream/components/UserBoxAuthenticated";
|
||||
import { SignOffMutation, withSignOffMutation } from "../../auth/mutations";
|
||||
import { User } from "../containers/UserBoxContainer";
|
||||
|
||||
interface SignInContainerProps {
|
||||
onSignIn: () => void;
|
||||
onRegister: () => void;
|
||||
signOff: () => void;
|
||||
interface UserBoxAuthenticatedProps {
|
||||
signOff: SignOffMutation;
|
||||
user: User;
|
||||
}
|
||||
|
||||
export type View = "SIGN_UP" | "FORGOT_PASSWORD";
|
||||
|
||||
class UserBoxUnauthenticatedContainer extends Component<SignInContainerProps> {
|
||||
private signOff = () => {
|
||||
this.props.signOff();
|
||||
class UserBoxAuthenticatedContainer extends Component<
|
||||
UserBoxAuthenticatedProps
|
||||
> {
|
||||
private onSignOff = () => {
|
||||
this.props.signOff({});
|
||||
};
|
||||
public render() {
|
||||
return (
|
||||
<UserBoxUnauthenticated
|
||||
onSignOff={this.signOff}
|
||||
onRegister={this.props.onRegister}
|
||||
onSignIn={this.props.onSignIn}
|
||||
/>
|
||||
<UserBoxAuthenticated onSignOff={this.onSignOff} user={this.props.user} />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const enhanced = withSignOffMutation(UserBoxUnauthenticatedContainer);
|
||||
const enhanced = withSignOffMutation(UserBoxAuthenticatedContainer);
|
||||
export default enhanced;
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from "talk-stream/mutations";
|
||||
import { Popup } from "talk-ui/components";
|
||||
|
||||
import UserBoxAuthenticated from "../components/UserBoxAuthenticated";
|
||||
import UserBoxUnauthenticated from "talk-stream/components/UserBoxUnauthenticated";
|
||||
import UserBoxAuthenticatedContainer from "../containers/UserBoxAuthenticatedContainer";
|
||||
|
||||
export type USER_ROLE =
|
||||
@@ -50,9 +50,7 @@ export class UserBoxContainer extends Component<InnerProps> {
|
||||
} = this.props;
|
||||
|
||||
if (user) {
|
||||
return (
|
||||
<UserBoxAuthenticated onSignOut={this.handleRegister} user={user} />
|
||||
);
|
||||
return <UserBoxAuthenticatedContainer user={user} />;
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -67,7 +65,7 @@ export class UserBoxContainer extends Component<InnerProps> {
|
||||
onBlur={this.handleBlur}
|
||||
onClose={this.handleClose}
|
||||
/>
|
||||
<UserBoxAuthenticatedContainer
|
||||
<UserBoxUnauthenticated
|
||||
onSignIn={this.handleSignIn}
|
||||
onRegister={this.handleRegister}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user