Skip to content

Commit

Permalink
Merge pull request #45 from KSJaay/v0.5.1
Browse files Browse the repository at this point in the history
v0.5.1 -  Fixes issue with certificates and moves utils to shared folder
  • Loading branch information
KSJaay authored Jul 4, 2024
2 parents bf11cfc + 6110e54 commit 5103076
Show file tree
Hide file tree
Showing 101 changed files with 265 additions and 408 deletions.
2 changes: 1 addition & 1 deletion app/components/home/monitor/layout/card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useNavigate } from 'react-router-dom';
// import local files
import StatusBar from '../../../ui/statusBar';
import MonitorOptions from '../options';
import { monitorPropType } from '../../../../utils/propTypes';
import { monitorPropType } from '../../../../../shared/utils/propTypes';

const MonitorCard = ({ monitor = {} }) => {
const navigate = useNavigate();
Expand Down
2 changes: 1 addition & 1 deletion app/components/home/monitor/layout/compact.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import './compact.scss';
import { useNavigate } from 'react-router-dom';

// import local files
import { monitorPropType } from '../../../../utils/propTypes';
import { monitorPropType } from '../../../../../shared/utils/propTypes';

const MonitorList = ({ monitor = {} }) => {
const navigate = useNavigate();
Expand Down
2 changes: 1 addition & 1 deletion app/components/home/monitor/layout/list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useNavigate } from 'react-router-dom';

// import local files
import StatusBar from '../../../ui/statusBar';
import { monitorPropType } from '../../../../utils/propTypes';
import { monitorPropType } from '../../../../../shared/utils/propTypes';

const MonitorList = ({ monitor = {} }) => {
const navigate = useNavigate();
Expand Down
2 changes: 1 addition & 1 deletion app/components/modal/settings/account/password.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import RegisterChecklist from '../../../register/checklist';
import { useState } from 'react';
import { MdEye, MdEyeOff } from '../../../icons';
import handleChangePassword from '../../../../handlers/settings/account/password';
import validators from '../../../../../server/utils/validators';
import validators from '../../../../../shared/validators';

const SettingsAccountPasswordModal = ({ modalTitle, id, closeModal }) => {
const [values, setValues] = useState({
Expand Down
7 changes: 1 addition & 6 deletions app/components/modal/settings/account/username.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ const SettingsAccountUsernameModal = ({

const submit = async () => {
const value = document.getElementById(`settings-edit-${id}`).value;
const query = await handleChangeUsername(
value,
setError,
closeModal,
handleError
);
const query = await handleChangeUsername(value, handleError, closeModal);

if (query === true) {
updateUsingKey('displayName', value);
Expand Down
2 changes: 1 addition & 1 deletion app/components/modal/settings/avatar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { toast } from 'react-toastify';
import Modal from '../../ui/modal';
import useContextStore from '../../../context';
import { createPostRequest } from '../../../services/axios';
import { userPropType } from '../../../utils/propTypes';
import { userPropType } from '../../../../shared/utils/propTypes';

const avatars = [
'Ape',
Expand Down
2 changes: 1 addition & 1 deletion app/components/modal/settings/manage/approve.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { observer } from 'mobx-react-lite';
import { createPostRequest } from '../../../../services/axios';
import Modal from '../../../ui/modal';
import useTeamContext from '../../../../context/team';
import { userPropType } from '../../../../utils/propTypes';
import { userPropType } from '../../../../../shared/utils/propTypes';

const MemberApproveModal = ({ member, onClose }) => {
const { updateUserVerified } = useTeamContext();
Expand Down
2 changes: 1 addition & 1 deletion app/components/modal/settings/manage/decline.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { toast } from 'react-toastify';
import { createPostRequest } from '../../../../services/axios';
import Modal from '../../../ui/modal';
import useTeamContext from '../../../../context/team';
import { userPropType } from '../../../../utils/propTypes';
import { userPropType } from '../../../../../shared/utils/propTypes';

const MemberDeclineModal = ({ member, onClose }) => {
const { removeUser } = useTeamContext();
Expand Down
2 changes: 1 addition & 1 deletion app/components/modal/settings/manage/delete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { toast } from 'react-toastify';
import { createPostRequest } from '../../../../services/axios';
import Modal from '../../../ui/modal';
import useTeamContext from '../../../../context/team';
import { userPropType } from '../../../../utils/propTypes';
import { userPropType } from '../../../../../shared/utils/propTypes';

const MemberDeleteModal = ({ member, onClose }) => {
const { removeUser } = useTeamContext();
Expand Down
2 changes: 1 addition & 1 deletion app/components/modal/settings/manage/permissions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import classNames from 'classnames';
import { createPostRequest } from '../../../../services/axios';
import Modal from '../../../ui/modal';
import useTeamContext from '../../../../context/team';
import { userPropType } from '../../../../utils/propTypes';
import { userPropType } from '../../../../../shared/utils/propTypes';

const MemeberPermission = ({ title, description, isActive, ...props }) => {
const containerClasses = classNames('permissions-container', {
Expand Down
2 changes: 1 addition & 1 deletion app/components/monitor/graph/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Chart } from 'react-chartjs-2';
import useLocalStorageContext from '../../../hooks/useLocalstorage';
import GraphMenu from './menu';
import useGraphStatus from '../../../hooks/useGraphStatus';
import { fullMonitorPropType } from '../../../utils/propTypes';
import { fullMonitorPropType } from '../../../../shared/utils/propTypes';

ChartJs.register(
LineController,
Expand Down
2 changes: 1 addition & 1 deletion app/components/monitor/status.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import './status.scss';

// import local files
import { fullMonitorPropType } from '../../utils/propTypes';
import { fullMonitorPropType } from '../../../shared/utils/propTypes';

const MonitorStatus = ({ monitor = [] }) => {
const [lastHeartbeat = {}] = monitor.heartbeats;
Expand Down
2 changes: 1 addition & 1 deletion app/components/monitor/updateInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import moment from 'moment';
import classNames from 'classnames';

// import local files
import { heartbeatPropType } from '../../utils/propTypes';
import { heartbeatPropType } from '../../../shared/utils/propTypes';
import useLocalStorageContext from '../../hooks/useLocalstorage';

const UptimeInfo = ({ heartbeat = {} }) => {
Expand Down
2 changes: 1 addition & 1 deletion app/components/monitor/uptime.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'moment-timezone';
import PropTypes from 'prop-types';

// import local files
import { heartbeatPropType } from '../../utils/propTypes';
import { heartbeatPropType } from '../../../shared/utils/propTypes';
import UptimeInfo from './updateInfo';

const MonitorUptime = ({ heartbeats = [] }) => {
Expand Down
2 changes: 1 addition & 1 deletion app/components/settings/manage/member/actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import MemberDeclineModal from '../../../modal/settings/manage/decline';
import MemberDeleteModal from '../../../modal/settings/manage/delete';
import MemberPermissionsModal from '../../../modal/settings/manage/permissions';
import useContextStore from '../../../../context';
import { userPropType } from '../../../../utils/propTypes';
import { userPropType } from '../../../../../shared/utils/propTypes';

const MemberRowActions = ({ member = {}, canManage = false }) => {
const classes = classNames({
Expand Down
2 changes: 1 addition & 1 deletion app/components/settings/manage/member/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PropTypes from 'prop-types';

// import local files
import MemberTableRow from './row';
import { userPropType } from '../../../../utils/propTypes';
import { userPropType } from '../../../../../shared/utils/propTypes';

const MembersTable = ({ members = [] }) => {
const membersList = members.map((member, index) => (
Expand Down
2 changes: 1 addition & 1 deletion app/components/settings/manage/member/row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { observer } from 'mobx-react-lite';
// import local files
import MemberRowActions from './actions';
import useContextStore from '../../../../context';
import { userPropType } from '../../../../utils/propTypes';
import { userPropType } from '../../../../../shared/utils/propTypes';

const positions = { 1: 'Owner', 2: 'Admin', 3: 'Editor', 4: 'Guest' };

Expand Down
2 changes: 1 addition & 1 deletion app/components/ui/button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
import classNames from 'classnames';

// import local files
import { colorPropType } from '../../utils/propTypes';
import { colorPropType } from '../../../shared/utils/propTypes';

const Button = ({
children,
Expand Down
2 changes: 1 addition & 1 deletion app/components/ui/dropdown/item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classNames from 'classnames';
import PropTypes from 'prop-types';

// import local files
import { colorPropType } from '../../../utils/propTypes';
import { colorPropType } from '../../../../shared/utils/propTypes';

const Item = ({
dotColor,
Expand Down
2 changes: 1 addition & 1 deletion app/components/ui/modal/button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import './style.scss';
// import dependencies
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { colorPropType } from '../../../utils/propTypes';
import { colorPropType } from '../../../../shared/utils/propTypes';

const Button = ({ children, color, ...props }) => {
const classes = classNames('modal-button', {
Expand Down
2 changes: 1 addition & 1 deletion app/components/ui/select/item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classNames from 'classnames';
import PropTypes from 'prop-types';

// import local files
import { colorPropType } from '../../../utils/propTypes';
import { colorPropType } from '../../../../shared/utils/propTypes';

const Item = ({
dotColor,
Expand Down
2 changes: 1 addition & 1 deletion app/components/ui/statusBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import './statusBar.scss';
import PropTypes from 'prop-types';

// import local files
import { heartbeatPropType } from '../../utils/propTypes';
import { heartbeatPropType } from '../../../shared/utils/propTypes';

const StatusBar = ({ heartbeats = {}, maxHeartbeats = 12 }) => {
const heartbeatList = [];
Expand Down
2 changes: 1 addition & 1 deletion app/handlers/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { toast } from 'react-toastify';

// import local files
import { createPostRequest } from '../services/axios';
import * as validators from '../utils/validators';
import validators from '../../shared/validators';

const handleLogin = async (inputs, setErrors, navigate) => {
try {
Expand Down
4 changes: 2 additions & 2 deletions app/handlers/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { toast } from 'react-toastify';

// import local files
import { createPostRequest } from '../services/axios';
import * as validators from '../utils/validators';
import validators from '../../shared/validators';

const handleRegister = async (inputs, setErrors, setPage, navigate) => {
try {
Expand All @@ -12,7 +12,7 @@ const handleRegister = async (inputs, setErrors, setPage, navigate) => {
const isInvalidPassword = validators.auth.password(password);

if (isInvalidPassword) {
return setErrors({ password: isInvalidPassword });
return setErrors(isInvalidPassword);
}

if (password !== confirmPassword) {
Expand Down
4 changes: 2 additions & 2 deletions app/handlers/settings/account/password.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { toast } from 'react-toastify';

// import local files
import * as validators from '../../../utils/validators';
import validators from '../../../../shared/validators';
import { createPostRequest } from '../../../services/axios';

const handleChangePassword = async ({
Expand All @@ -20,7 +20,7 @@ const handleChangePassword = async ({
const isInvalid = validators.auth.password(newPassword);

if (isInvalid) {
return handleErrors('new', isInvalid);
return handleErrors('new', isInvalid.password);
}

const query = await createPostRequest('/api/user/update/password', {
Expand Down
19 changes: 5 additions & 14 deletions app/handlers/settings/account/username.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@
import { toast } from 'react-toastify';

// import local files
import * as validators from '../../../utils/validators';
import validators from '../../../../shared/validators';
import { createPostRequest } from '../../../services/axios';

const handleChangeUsername = async (
displayName,
setError,
closeModal,
handleErrors
) => {
const handleChangeUsername = async (displayName, handleError, closeModal) => {
try {
const isInvalid = validators.auth.username(displayName);

if (isInvalid) {
return setError(isInvalid);
return handleError(isInvalid.username);
}

const query = await createPostRequest('/api/user/update/username', {
Expand All @@ -29,12 +24,8 @@ const handleChangeUsername = async (

return true;
} catch (error) {
if (error.response?.data?.current) {
return handleErrors('current', error.response?.data?.current);
}

if (error?.response?.status === 400) {
return handleErrors('new', error.response.data?.message);
if (error.response?.data?.username) {
return handleError(error.response?.data?.username);
}

toast.error('Something went wrong, please try again later.');
Expand Down
14 changes: 10 additions & 4 deletions app/hooks/useLogin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { useState } from 'react';

// import local files
import * as validators from '../utils/validators';
import validators from '../../shared/validators';

const useLogin = () => {
const [values, setValues] = useState({
Expand All @@ -18,12 +18,18 @@ const useLogin = () => {

if (isInvalid) {
return setValues((prev) => ({
...prev,
errors: { ...prev.errors, [id]: isInvalid },
inputs: {
...prev.inputs,
[id]: value,
},
errors: { ...prev.errors, ...isInvalid },
}));
} else {
setValues((prev) => ({
...prev,
inputs: {
...prev.inputs,
[id]: value,
},
errors: { ...prev.errors, [id]: null },
}));
}
Expand Down
2 changes: 1 addition & 1 deletion app/hooks/useMonitorForm.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from 'react';
import handleMonitor from '../handlers/monitor';
import monitorValidators from '../utils/validators/monitor';
import monitorValidators from '../../shared/validators/monitor';

const initialPage = {
page: 1,
Expand Down
8 changes: 4 additions & 4 deletions app/hooks/useRegister.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { toast } from 'react-toastify';

// import local files
import { createPostRequest } from '../services/axios';
import * as validators from '../utils/validators';
import validators from '../../shared/validators';

const useRegister = () => {
const [values, setValues] = useState({
Expand All @@ -26,8 +26,8 @@ const useRegister = () => {
...prev,
errors: {
...prev.errors,
email: isInvalidEmail,
username: isInvalidUsername,
...isInvalidEmail,
...isInvalidUsername,
},
}));
}
Expand Down Expand Up @@ -79,7 +79,7 @@ const useRegister = () => {
},
errors: {
...prev.errors,
[id]: isInvalid,
...isInvalid,
},
}));
} else {
Expand Down
4 changes: 2 additions & 2 deletions app/pages/login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const Login = () => {
return (
<div className="auth-form-container">
<div className="auth-form">
<div className="auth-form-title">Create your account</div>
<div className="auth-form-title">Signin to Lunalytics</div>
<div className="auth-form-subtitle">
Please provide your name and email
Please provide your email and password
</div>

{errors['general'] && (
Expand Down
11 changes: 0 additions & 11 deletions app/utils/cookies.js

This file was deleted.

Loading

0 comments on commit 5103076

Please sign in to comment.