mirror of
https://github.com/rjNemo/devbook_ts
synced 2026-06-12 13:36:43 +00:00
create User type
This commit is contained in:
parent
9fdd759e5d
commit
43212d2acd
3 changed files with 14 additions and 3 deletions
|
|
@ -17,7 +17,6 @@ interface IProps {
|
||||||
* Main Navbar serves navigation routes.
|
* Main Navbar serves navigation routes.
|
||||||
*/
|
*/
|
||||||
const NavBar: FC<IProps> = ({isAuthenticated, loading}) => {
|
const NavBar: FC<IProps> = ({isAuthenticated, loading}) => {
|
||||||
console.log(isAuthenticated, loading);
|
|
||||||
const publicLinks = (
|
const publicLinks = (
|
||||||
<ul data-testid="publicLinks">
|
<ul data-testid="publicLinks">
|
||||||
<li>
|
<li>
|
||||||
|
|
|
||||||
8
src/models/User.ts
Normal file
8
src/models/User.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
interface User {
|
||||||
|
name: string;
|
||||||
|
email: string;
|
||||||
|
picture: string;
|
||||||
|
createdAt: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default User;
|
||||||
|
|
@ -1,17 +1,21 @@
|
||||||
|
// Redux
|
||||||
import {createSlice} from '@reduxjs/toolkit';
|
import {createSlice} from '@reduxjs/toolkit';
|
||||||
import {RootState} from '..';
|
import {RootState} from '..';
|
||||||
|
// Typing
|
||||||
|
import User from '../../models/User';
|
||||||
|
|
||||||
interface SliceState {
|
interface SliceState {
|
||||||
isAuthenticated: boolean;
|
isAuthenticated: boolean;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
// TODO: switch any by the actual user interface
|
user: User | null;
|
||||||
user: any;
|
error: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialState: SliceState = {
|
const initialState: SliceState = {
|
||||||
isAuthenticated: false,
|
isAuthenticated: false,
|
||||||
loading: true,
|
loading: true,
|
||||||
user: null,
|
user: null,
|
||||||
|
error: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const authSlice = createSlice({
|
const authSlice = createSlice({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue