Merge pull request #8 from Antoninop/prop-types

[+] PropTypes support.
This commit is contained in:
Antoninop 2024-07-12 11:15:00 +02:00 committed by GitHub
commit 0a1487b806
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 71 additions and 8 deletions

2
package-lock.json generated
View File

@ -16,6 +16,7 @@
"@types/node": "^20.14.9", "@types/node": "^20.14.9",
"firebase": "^10.12.2", "firebase": "^10.12.2",
"jest": "^29.7.0", "jest": "^29.7.0",
"prop-types": "^15.8.1",
"react": "^18.3.1", "react": "^18.3.1",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",
"react-router-dom": "^6.24.0", "react-router-dom": "^6.24.0",
@ -9632,6 +9633,7 @@
"version": "15.8.1", "version": "15.8.1",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
"integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==",
"license": "MIT",
"dependencies": { "dependencies": {
"loose-envify": "^1.4.0", "loose-envify": "^1.4.0",
"object-assign": "^4.1.1", "object-assign": "^4.1.1",

View File

@ -19,6 +19,7 @@
"@types/node": "^20.14.9", "@types/node": "^20.14.9",
"firebase": "^10.12.2", "firebase": "^10.12.2",
"jest": "^29.7.0", "jest": "^29.7.0",
"prop-types": "^15.8.1",
"react": "^18.3.1", "react": "^18.3.1",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",
"react-router-dom": "^6.24.0", "react-router-dom": "^6.24.0",

View File

@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { BrowserRouter as Router, Route, Routes, Navigate } from 'react-router-dom'; import { BrowserRouter as Router, Route, Routes, Navigate } from 'react-router-dom';
import { ToastContainer } from 'react-toastify'; import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css'; import 'react-toastify/dist/ReactToastify.css';

View File

@ -1,7 +1,8 @@
import React, { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import styles from './CreateServer.module.scss'; import styles from './CreateServer.module.scss';
import { getUserSubdomain } from "../../service/firebase"; import { getUserSubdomain } from "../../service/firebase";
import serviiApi from "../../service/api.tsx"; import serviiApi from "../../service/api.tsx";
import PropTypes from "prop-types";
const CreateServer = ({ user, onCreateServer, onSubdomainUpdate, onCancel, noServers }) => { const CreateServer = ({ user, onCreateServer, onSubdomainUpdate, onCancel, noServers }) => {
const [subdomain, setSubdomain] = useState(null); const [subdomain, setSubdomain] = useState(null);
@ -113,4 +114,19 @@ const CreateServer = ({ user, onCreateServer, onSubdomainUpdate, onCancel, noSer
); );
}; };
CreateServer.propTypes = {
user: PropTypes.oneOfType([
PropTypes.shape({
uid: PropTypes.string.isRequired,
displayName: PropTypes.string,
email: PropTypes.string,
photoURL: PropTypes.string,
}),
]),
onCreateServer: PropTypes.func.isRequired,
onSubdomainUpdate: PropTypes.func.isRequired,
onCancel: PropTypes.func.isRequired,
noServers: PropTypes.any
};
export default CreateServer; export default CreateServer;

View File

@ -1,8 +1,9 @@
import React, { useState, useEffect, useRef } from 'react'; import { useState, useEffect, useRef } from 'react';
import { auth } from '../../service/firebase'; import { auth } from '../../service/firebase';
import styles from './Navbar.module.scss'; import styles from './Navbar.module.scss';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faUser, faCog, faSignOutAlt } from '@fortawesome/free-solid-svg-icons'; import { faUser, faCog, faSignOutAlt } from '@fortawesome/free-solid-svg-icons';
import PropTypes from "prop-types";
const Navbar = ({ user }) => { const Navbar = ({ user }) => {
const [dropdownOpen, setDropdownOpen] = useState(false); const [dropdownOpen, setDropdownOpen] = useState(false);
@ -66,4 +67,15 @@ const Navbar = ({ user }) => {
); );
}; };
Navbar.propTypes = {
user: PropTypes.oneOfType([
PropTypes.shape({
uid: PropTypes.string.isRequired,
displayName: PropTypes.string,
email: PropTypes.string,
photoURL: PropTypes.string,
}),
]),
};
export default Navbar; export default Navbar;

View File

@ -1,4 +1,3 @@
import React from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import styles from './serverCard.module.scss'; import styles from './serverCard.module.scss';
@ -7,6 +6,7 @@ import spigot from '../../assets/frameworks/spigot.png';
import bukkit from '../../assets/frameworks/bukkit.png'; import bukkit from '../../assets/frameworks/bukkit.png';
import vanilla from '../../assets/frameworks/vanilla.png'; import vanilla from '../../assets/frameworks/vanilla.png';
import delete_button from '../../assets/frameworks/delete.png'; import delete_button from '../../assets/frameworks/delete.png';
import PropTypes from "prop-types";
const ServerCard = ({ status, version, name, framework, onRunClick, onStopClick, onDeleteClick }) => { const ServerCard = ({ status, version, name, framework, onRunClick, onStopClick, onDeleteClick }) => {
@ -73,4 +73,16 @@ const ServerCard = ({ status, version, name, framework, onRunClick, onStopClick,
); );
}; };
ServerCard.propTypes = {
key: PropTypes.string,
status: PropTypes.bool,
version: PropTypes.string,
name: PropTypes.string,
framework: PropTypes.string,
onRunClick: PropTypes.func.isRequired,
onStopClick: PropTypes.func.isRequired,
onDeleteClick: PropTypes.func.isRequired,
subdomain: PropTypes.string,
};
export default ServerCard; export default ServerCard;

View File

@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import ServerCard from '../../components/serverCard/serverCard'; import ServerCard from '../../components/serverCard/serverCard';
import Navbar from '../../components/navbar/Navbar'; import Navbar from '../../components/navbar/Navbar';
import styles from './DashboardPage.module.scss'; import styles from './DashboardPage.module.scss';
@ -6,6 +6,7 @@ import Loading from '../Loading/loading';
import CreateServer from '../../components/CreateServer/CreateServer'; import CreateServer from '../../components/CreateServer/CreateServer';
import { getUserSubdomain } from "../../service/firebase"; import { getUserSubdomain } from "../../service/firebase";
import serviiApi from "../../service/api.tsx"; import serviiApi from "../../service/api.tsx";
import PropTypes from "prop-types";
const DashboardPage = ({ user }) => { const DashboardPage = ({ user }) => {
const [servers, setServers] = useState([]); const [servers, setServers] = useState([]);
@ -154,4 +155,14 @@ const DashboardPage = ({ user }) => {
); );
}; };
DashboardPage.propTypes = {
user: PropTypes.oneOfType([
PropTypes.shape({
uid: PropTypes.string.isRequired,
displayName: PropTypes.string,
email: PropTypes.string,
}),
]),
};
export default DashboardPage; export default DashboardPage;

View File

@ -1,5 +1,4 @@
// src/pages/LoginPage/LoginPage.js // src/pages/LoginPage/LoginPage.js
import React from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { auth, googleProvider, signInWithPopup } from '../../service/firebase'; import { auth, googleProvider, signInWithPopup } from '../../service/firebase';
import styles from './LoginPage.module.scss'; import styles from './LoginPage.module.scss';

View File

@ -1,5 +1,4 @@
// src/pages/NotFoundPage/NotFoundPage.jsx // src/pages/NotFoundPage/NotFoundPage.jsx
import React from 'react';
import Navbar from '../../components/navbar/Navbar'; import Navbar from '../../components/navbar/Navbar';
import styles from './NotFoundPage.module.scss'; import styles from './NotFoundPage.module.scss';

View File

@ -1,9 +1,11 @@
import React, { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { useParams, useNavigate } from 'react-router-dom'; import { useParams, useNavigate } from 'react-router-dom';
import Navbar from '../../components/navbar/Navbar'; import Navbar from '../../components/navbar/Navbar';
import styles from './ServerDetails.module.scss'; import styles from './ServerDetails.module.scss';
import serviiApi from "../../service/api.tsx"; import serviiApi from "../../service/api.tsx";
import Loading from '../Loading/loading'; import Loading from '../Loading/loading';
import PropTypes from "prop-types";
const ServerDetails = ({ user }) => { const ServerDetails = ({ user }) => {
const { serverName } = useParams(); const { serverName } = useParams();
@ -148,4 +150,13 @@ const ServerDetails = ({ user }) => {
); );
}; };
ServerDetails.propTypes = {
user: PropTypes.oneOfType([
PropTypes.shape({
uid: PropTypes.string.isRequired,
displayName: PropTypes.string,
email: PropTypes.string,
}),
]),
};
export default ServerDetails; export default ServerDetails;