mirror of
https://github.com/hubHarmony/servii-frontend.git
synced 2024-11-18 05:40:31 +00:00
commit
beb4d09868
@ -46,6 +46,10 @@ const CreateServer = ({ user, onCreateServer, onSubdomainUpdate, onCancel, noSer
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const validateInput = (input) => {
|
||||||
|
return input.replace(/[^a-zA-Z]/g, '');
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
{noServers ? (
|
{noServers ? (
|
||||||
@ -68,7 +72,7 @@ const CreateServer = ({ user, onCreateServer, onSubdomainUpdate, onCancel, noSer
|
|||||||
className={styles.inputsubdomain}
|
className={styles.inputsubdomain}
|
||||||
type="text"
|
type="text"
|
||||||
value={subdomainInput}
|
value={subdomainInput}
|
||||||
onChange={(e) => setSubdomainInput(e.target.value)}
|
onChange={(e) => setSubdomainInput(validateInput(e.target.value))}
|
||||||
placeholder='Nom du sous domaine'
|
placeholder='Nom du sous domaine'
|
||||||
/>
|
/>
|
||||||
<button className={styles.btnSubCreate} onClick={handleSaveSubdomain}>
|
<button className={styles.btnSubCreate} onClick={handleSaveSubdomain}>
|
||||||
@ -86,7 +90,7 @@ const CreateServer = ({ user, onCreateServer, onSubdomainUpdate, onCancel, noSer
|
|||||||
type="text"
|
type="text"
|
||||||
placeholder="Nom du serveur"
|
placeholder="Nom du serveur"
|
||||||
value={serverName}
|
value={serverName}
|
||||||
onChange={(e) => setServerName(e.target.value)}
|
onChange={(e) => setServerName(validateInput(e.target.value))}
|
||||||
/>
|
/>
|
||||||
<select
|
<select
|
||||||
className={styles.select}
|
className={styles.select}
|
||||||
|
@ -37,9 +37,14 @@ const ServerDetails = ({ user }) => {
|
|||||||
fetchServer();
|
fetchServer();
|
||||||
}, [serverName]);
|
}, [serverName]);
|
||||||
|
|
||||||
|
const validateInput = (input) => {
|
||||||
|
return input.replace(/[^a-zA-Z]/g, '');
|
||||||
|
};
|
||||||
|
|
||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
const { name, value } = e.target;
|
const { name, value } = e.target;
|
||||||
setServer({ ...server, [name]: value });
|
const validatedValue = name === 'motd' ? validateInput(value) : value;
|
||||||
|
setServer({ ...server, [name]: validatedValue });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
@ -55,14 +60,12 @@ const ServerDetails = ({ user }) => {
|
|||||||
['pvp', server.pvp.toString()]
|
['pvp', server.pvp.toString()]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
await serviiApi.updateProperties(server.name, props);
|
await serviiApi.updateProperties(server.name, props);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error updating server:', error);
|
console.error('Error updating server:', error);
|
||||||
alert('Error updating server');
|
alert('Error updating server');
|
||||||
}
|
}
|
||||||
handleQuit()
|
handleQuit();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleQuit = () => {
|
const handleQuit = () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user