mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-20 12:46:01 -05:00
cleaned up admin
This commit is contained in:
@@ -28,7 +28,7 @@ const ConfirmEmail = (props) => {
|
||||
|
||||
useEffect(() => {
|
||||
checkConfirmation(userId, token);
|
||||
}, []);
|
||||
}, [userId, token]);
|
||||
|
||||
const dimmerProps = { active: loading };
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { connect } from "react-redux"
|
||||
import ConfirmEmail from "./ConfirmEmail"
|
||||
import * as userActions from "./user-actions"
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
user: state.user
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
userActions
|
||||
)(ConfirmEmail)
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
import React, { useEffect, useState, } from "react";
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useSearchParams, Link } from 'react-router-dom';
|
||||
import { loginUser } from "../features/user/userSlice";
|
||||
import { useSelector, useDispatch } from 'react-redux'
|
||||
import { useDispatch } from 'react-redux'
|
||||
import {
|
||||
Container,
|
||||
Header,
|
||||
@@ -33,7 +33,7 @@ const Login = (props) => {
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const navigate = useNavigate();
|
||||
let [searchParams, setSearchParams] = useSearchParams();
|
||||
let [searchParams] = useSearchParams();
|
||||
const nextLocation = searchParams.get("nextLocation");
|
||||
const dispatch = useDispatch();
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import { connect } from "react-redux"
|
||||
import * as userActions from "./user-actions"
|
||||
import Login from "./Login"
|
||||
import queryString from '../query-string';
|
||||
|
||||
|
||||
// Function passed in to `connect` to subscribe to Redux store updates.
|
||||
// Any time it updates, mapStateToProps is called.
|
||||
// The second argument "ownProps" contains props passed to the component
|
||||
const mapStateToProps = (state, props) => {
|
||||
|
||||
let nextPathname = false;
|
||||
|
||||
try {nextPathname = props.location.state.nextPathname}
|
||||
catch(err) {}
|
||||
const uri = queryString.parse(props.location.search);
|
||||
let nextLocation = uri['nextLocation'];
|
||||
|
||||
return {
|
||||
|
||||
user: state.user,
|
||||
nextPathname, // this prop passed in by React Router
|
||||
nextLocation
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Connects React component to the redux store
|
||||
// It does not modify the component class passed to it
|
||||
// Instead, it returns a new, connected component class, for you to use.
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
userActions
|
||||
)(Login)
|
||||
@@ -1,6 +1,5 @@
|
||||
import React, { useEffect, useState, } from "react";
|
||||
import { useState, } from "react";
|
||||
import { useSelector, useDispatch } from 'react-redux'
|
||||
import { useNavigate, useSearchParams, Link } from 'react-router-dom';
|
||||
import UserForm from "./UserForm";
|
||||
import {
|
||||
Container,
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import { connect } from "react-redux"
|
||||
import Profile from "./Profile"
|
||||
import * as userActions from "./user-actions"
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
user: state.user,
|
||||
isWaiting: state.user.isWaiting
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
userActions
|
||||
)(Profile)
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { registerUser } from "../features/user/userSlice";
|
||||
import { useNavigate, useSearchParams, Link } from 'react-router-dom';
|
||||
import { useSelector, useDispatch } from 'react-redux'
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useDispatch } from 'react-redux'
|
||||
import {
|
||||
Container,
|
||||
Header,
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { connect } from "react-redux"
|
||||
import * as userActions from "./user-actions"
|
||||
import Register from "./Register"
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
isWaiting: state.user.isWaiting
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
userActions
|
||||
)(Register)
|
||||
@@ -1,14 +0,0 @@
|
||||
import { connect } from "react-redux"
|
||||
import ResetPassword from "./ResetPassword"
|
||||
import * as userActions from "./user-actions"
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
user: state.user
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
userActions
|
||||
)(ResetPassword)
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from "react";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
Form,
|
||||
Grid,
|
||||
@@ -9,14 +9,12 @@ import {
|
||||
} from "semantic-ui-react";
|
||||
import { sendResetPassword } from "../features/user/userSlice";
|
||||
import { Link } from "react-router-dom";
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { useDispatch } from 'react-redux'
|
||||
|
||||
|
||||
|
||||
const SendResetPassword = (props) => {
|
||||
const SendResetPassword = () => {
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const [checkInputMessages, setCheckInputMessages] = useState("");
|
||||
const [email, setEmail] = useState("");
|
||||
const [emailError, setEmailError] = useState(false);
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { connect } from "react-redux"
|
||||
import SendResetPassword from "./SendResetPassword"
|
||||
import * as userActions from "./user-actions"
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
user: state.user
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
userActions
|
||||
)(SendResetPassword)
|
||||
@@ -1,14 +0,0 @@
|
||||
import { connect } from "react-redux"
|
||||
import SentConfirmEmail from "./SentConfirmEmail"
|
||||
import * as userActions from "./user-actions"
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
user: state.user
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
userActions
|
||||
)(SentConfirmEmail)
|
||||
@@ -1,40 +1,21 @@
|
||||
import React, { Component } from "react";
|
||||
import {
|
||||
Segment,
|
||||
Container,
|
||||
Button
|
||||
} from "semantic-ui-react";
|
||||
import React, { useState } from "react";
|
||||
import { Segment, Container, Button } from "semantic-ui-react";
|
||||
|
||||
class Terms extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.handleAccept = this.handleAccept.bind(this);
|
||||
this.handleDecline = this.handleDecline.bind(this);
|
||||
}
|
||||
const Terms = ({ user, acceptTerms }) => {
|
||||
const [requestMessage, setRequestMessage] = useState(null);
|
||||
|
||||
|
||||
|
||||
handleAccept() {
|
||||
this.props
|
||||
.acceptTerms(this.props.user.userId)
|
||||
.then(requestMessage => {
|
||||
const handleAccept = () => {
|
||||
acceptTerms(user.userId).then((requestMessage) => {
|
||||
if (requestMessage) {
|
||||
// report to the user is there was a problem during registration
|
||||
this.setState({
|
||||
requestMessage
|
||||
});
|
||||
setRequestMessage(requestMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
handleDecline() {
|
||||
const handleDecline = () => {};
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
|
||||
<Container text>
|
||||
<Segment attached>
|
||||
The agreement is useful to The Guardian to set the rules and guidelines for visitors, users and customers:
|
||||
@@ -61,24 +42,22 @@ class Terms extends Component {
|
||||
|
||||
Terms of Use (ToU)
|
||||
Terms of Service (ToS)
|
||||
Terms and Conditions (T&C)
|
||||
Terms and Conditions (T&C)
|
||||
User Agreement
|
||||
Conditions of Use
|
||||
And so on
|
||||
The “Conditions of Use” of Amazon could be named “Terms of Use”:
|
||||
</Segment>
|
||||
<Button.Group attached="bottom">
|
||||
<Button
|
||||
onClick={this.handleDecline}
|
||||
>Decline</Button>
|
||||
<Button onClick={handleDecline}>Decline</Button>
|
||||
<Button.Or />
|
||||
<Button positive
|
||||
onClick={this.handleAccept}
|
||||
>Accept</Button>
|
||||
<Button positive onClick={handleAccept}>
|
||||
Accept
|
||||
</Button>
|
||||
</Button.Group>
|
||||
</Container>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default Terms;
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { connect } from "react-redux"
|
||||
import * as userActions from "./user-actions"
|
||||
import Terms from "./Terms"
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
user: state.user
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
userActions
|
||||
)(Terms)
|
||||
@@ -27,7 +27,7 @@ const UserForm = (props) => {
|
||||
const [locationError, setLocationError] = useState(false);
|
||||
const [passwordError, setPasswordError] = useState(false);
|
||||
const [confirmPasswordError, setConfirmPasswordError] = useState(false);
|
||||
const [isEditing, setIsEditing] = useState(props.isEditing);
|
||||
const [isEditing] = useState(props.isEditing);
|
||||
const [changed, setChanged] = useState(false);
|
||||
const requestMessage = props.requestMessage;
|
||||
|
||||
@@ -156,7 +156,7 @@ const UserForm = (props) => {
|
||||
</Message>
|
||||
);
|
||||
}
|
||||
const buttonDisabled = changed?{}:{disabled:true}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Form
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React, { useState } from "react";
|
||||
import { sendConfirmEmail } from "../features/user/userSlice";
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useSelector, useDispatch } from 'react-redux'
|
||||
@@ -9,8 +8,8 @@ const WaitConfirmEmail = () => {
|
||||
const navigate = useNavigate();
|
||||
const { email, userId } = useSelector((state) => state.user);
|
||||
|
||||
const handleSendConfirmEmail = async (event) => {
|
||||
const message = await dispatch(sendConfirmEmail(userId)).unwrap();
|
||||
const handleSendConfirmEmail = async () => {
|
||||
await dispatch(sendConfirmEmail(userId)).unwrap();
|
||||
navigate("/sent-confirm-email")
|
||||
};
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { connect } from "react-redux"
|
||||
import WaitConfirmEmail from "./WaitConfirmEmail"
|
||||
import * as userActions from "./user-actions"
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
user: state.user
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
userActions
|
||||
)(WaitConfirmEmail)
|
||||
@@ -1,24 +1,7 @@
|
||||
// Import the RTK Query methods from the React-specific entry point
|
||||
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
|
||||
import { createSelector } from '@reduxjs/toolkit'
|
||||
|
||||
/*
|
||||
const axiosBaseQuery =
|
||||
({ baseUrl } = { baseUrl: '' }) =>
|
||||
async ({ url, method, data, params }) => {
|
||||
try {
|
||||
const result = await axios({ url: baseUrl + url, method, data, params })
|
||||
return { data: result.data }
|
||||
} catch (axiosError) {
|
||||
let err = axiosError
|
||||
return {
|
||||
error: {
|
||||
status: err.response?.status,
|
||||
data: err.response?.data || err.message,
|
||||
},
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// Define our single API slice object
|
||||
export const apiSlice = createApi({
|
||||
@@ -56,9 +39,9 @@ export const apiSlice = createApi({
|
||||
async onQueryStarted(group, { dispatch, queryFulfilled }) {
|
||||
try {
|
||||
const { data: updatedGroup } = await queryFulfilled
|
||||
const patchResult = dispatch(
|
||||
dispatch(
|
||||
apiSlice.util.updateQueryData('getGroups', updatedGroup.shortName, (groups) => {
|
||||
const groupIndex = groups.findIndex((obj => obj.groupId == updatedGroup.groupId));
|
||||
const groupIndex = groups.findIndex((obj => obj.groupId === updatedGroup.groupId));
|
||||
groups[groupIndex] = updatedGroup;
|
||||
})
|
||||
)
|
||||
@@ -75,7 +58,7 @@ export const apiSlice = createApi({
|
||||
async onQueryStarted(group, { dispatch, queryFulfilled }) {
|
||||
try {
|
||||
const { data: newGroup } = await queryFulfilled;
|
||||
const patchResult = dispatch(
|
||||
dispatch(
|
||||
apiSlice.util.updateQueryData('getGroups', newGroup.shortName, (groups) => {
|
||||
groups.push(newGroup);
|
||||
})
|
||||
@@ -93,9 +76,9 @@ export const apiSlice = createApi({
|
||||
async onQueryStarted(group, { dispatch, queryFulfilled }) {
|
||||
try {
|
||||
await queryFulfilled
|
||||
const patchResult = dispatch(
|
||||
dispatch(
|
||||
apiSlice.util.updateQueryData('getGroups', group.shortName, (groups) => {
|
||||
const groupIndex = groups.findIndex((obj => obj.groupId == group.groupId));
|
||||
const groupIndex = groups.findIndex((obj => obj.groupId === group.groupId));
|
||||
groups.splice(groupIndex,1);
|
||||
})
|
||||
)
|
||||
@@ -123,7 +106,7 @@ export const apiSlice = createApi({
|
||||
async onQueryStarted({shortName,file}, { dispatch, queryFulfilled }) {
|
||||
try {
|
||||
const { data: newTalkgroups } = await queryFulfilled;
|
||||
const patchResult = dispatch(
|
||||
dispatch(
|
||||
apiSlice.util.updateQueryData('getTalkgroups', shortName, (talkgroups) => {
|
||||
talkgroups.length = 0; // Clear your array
|
||||
talkgroups.push(...newTalkgroups);
|
||||
@@ -147,7 +130,7 @@ export const apiSlice = createApi({
|
||||
async onQueryStarted(system, { dispatch, queryFulfilled }) {
|
||||
try {
|
||||
const { data: newSystem } = await queryFulfilled
|
||||
const patchResult = dispatch(
|
||||
dispatch(
|
||||
apiSlice.util.updateQueryData('getSystems', undefined, (systemsData) => {
|
||||
const systems = systemsData.systems;
|
||||
systems.push(newSystem);
|
||||
@@ -166,10 +149,10 @@ export const apiSlice = createApi({
|
||||
async onQueryStarted(system, { dispatch, queryFulfilled }) {
|
||||
try {
|
||||
const { data: updatedSystem } = await queryFulfilled
|
||||
const patchResult = dispatch(
|
||||
dispatch(
|
||||
apiSlice.util.updateQueryData('getSystems', undefined, (systemsData) => {
|
||||
const systems = systemsData.systems;
|
||||
const systemIndex = systems.findIndex((obj => obj.shortName == updatedSystem.shortName));
|
||||
const systemIndex = systems.findIndex((obj => obj.shortName === updatedSystem.shortName));
|
||||
systems[systemIndex] = updatedSystem;
|
||||
})
|
||||
)
|
||||
@@ -185,10 +168,10 @@ export const apiSlice = createApi({
|
||||
async onQueryStarted(shortName, { dispatch, queryFulfilled }) {
|
||||
try {
|
||||
await queryFulfilled
|
||||
const patchResult = dispatch(
|
||||
dispatch(
|
||||
apiSlice.util.updateQueryData('getSystems', undefined, (systemsData) => {
|
||||
const systems = systemsData.systems;
|
||||
const systemIndex = systems.findIndex((obj => obj.shortName == shortName));
|
||||
const systemIndex = systems.findIndex((obj => obj.shortName === shortName));
|
||||
systems.splice(systemIndex, 1);
|
||||
})
|
||||
)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import {
|
||||
createSlice,
|
||||
createEntityAdapter,
|
||||
createSelector,
|
||||
createAsyncThunk
|
||||
} from '@reduxjs/toolkit'
|
||||
|
||||
@@ -145,7 +143,6 @@ export const resetPassword = createAsyncThunk(
|
||||
export const sendResetPassword = createAsyncThunk(
|
||||
'user/sendResetPassword',
|
||||
async (data) => {
|
||||
const {userId, token, password} = data;
|
||||
const url = process.env.REACT_APP_ACCOUNT_SERVER + "/api/send-reset-password"
|
||||
const res = await fetch(url, {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user