mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-11 04:45:02 +00:00
Add presetup-configurator to the repo
This commit is contained in:
parent
d4d89327fd
commit
8c11349a8b
14 changed files with 829 additions and 0 deletions
46
presetup-configurator/src/Levels.tsx
Normal file
46
presetup-configurator/src/Levels.tsx
Normal file
|
@ -0,0 +1,46 @@
|
|||
import React, { useState } from "react";
|
||||
|
||||
const LEVEL_ADMIN = 100;
|
||||
const LEVEL_MODERATOR = 50;
|
||||
|
||||
export type LevelEntry = [string, number]; // id, level
|
||||
|
||||
export function Levels({ levels, setLevels }) {
|
||||
function addLevel() {
|
||||
setLevels(arr => [...arr, ["", LEVEL_MODERATOR]]);
|
||||
}
|
||||
|
||||
function removeLevel(index) {
|
||||
setLevels(arr => [...arr].splice(index, 1));
|
||||
}
|
||||
|
||||
function updateLevelId(index, id) {
|
||||
const validId = id.replace(/[^0-9]/g, "");
|
||||
setLevels(arr => {
|
||||
arr[index][0] = validId;
|
||||
return [...arr];
|
||||
});
|
||||
}
|
||||
|
||||
function updateLevelLevel(index, level) {
|
||||
setLevels(arr => {
|
||||
arr[index][1] = parseInt(level, 10);
|
||||
return [...arr];
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{levels.map(([id, level], index) => (
|
||||
<div key={index}>
|
||||
<input value={id} onChange={e => updateLevelId(index, e.target.value)} />
|
||||
<select value={level} onChange={e => updateLevelLevel(index, e.target.value)}>
|
||||
<option value={LEVEL_ADMIN}>Admin</option>
|
||||
<option value={LEVEL_MODERATOR}>Moderator</option>
|
||||
</select>
|
||||
</div>
|
||||
))}
|
||||
<button onClick={addLevel}>Add</button>
|
||||
</div>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue