fix: prettier formating

This commit is contained in:
Domenik 2025-02-20 20:49:24 +01:00
parent 544ebaa7cf
commit 7b4ef9c70b
13 changed files with 172 additions and 154 deletions

View file

@ -30,6 +30,7 @@ files, generate content, or using other handy digital utilities. This page is ma
To install and run the project locally, follow these steps:
1. **Clone the repository**:
```bash
git clone https://github.com/theoleuthardt/werkzeugkiste.git
cd werkzeugkiste

View file

@ -18,7 +18,8 @@ export async function colorConvert(app: FastifyInstance) {
if (!data) {
return reply.status(400).send({ error: "No RGB declared!" });
}
const hex = (`#${(+data.red).toString(16).padStart(2, "0")}${(+data.green).toString(16).padStart(2, "0")}${(+data.blue).toString(16).padStart(2, "0")}`).toUpperCase();
const hex =
`#${(+data.red).toString(16).padStart(2, "0")}${(+data.green).toString(16).padStart(2, "0")}${(+data.blue).toString(16).padStart(2, "0")}`.toUpperCase();
reply.header("Content-Type", "text/plain").status(200).send(hex);
} catch (error) {
console.error("Convert error:", error);

View file

@ -18,7 +18,9 @@ export async function passwordGenerate(app: FastifyInstance) {
try {
const data = request.body;
if (!data) {
return reply.status(400).send({ error: "No length or type declared!" });
return reply
.status(400)
.send({ error: "No length or type declared!" });
}
let numArray: string[] = "0123456789".split("");
let lowerArray: string[] = "abcdefghijklmnopqrstuvwxyz".split("");

View file

@ -20,7 +20,9 @@ export async function regexTest(app: FastifyInstance) {
// Überprüfe, ob die Felder regex und test vorhanden sind
if (!data.regex || !data.test) {
return reply.status(400).send({ error: "Regex or test string missing!" });
return reply
.status(400)
.send({ error: "Regex or test string missing!" });
}
// Versuche, den regulären Ausdruck zu erstellen
@ -28,7 +30,9 @@ export async function regexTest(app: FastifyInstance) {
try {
regexPattern = new RegExp(data.regex);
} catch (e) {
return reply.status(400).send({ error: "Invalid regular expression!" });
return reply
.status(400)
.send({ error: "Invalid regular expression!" });
}
// Teste den Eingabestring gegen das Regex

View file

@ -6,19 +6,21 @@ import Footer from "../../components/Footer";
import Button from "../../components/Button";
export default function RgbToHex() {
const [loading, setLoading] = useState(false);
const [password, setPassword] = useState("");
const generatePassword = async () => {
setLoading(true);
const length = (document.getElementById("length") as HTMLInputElement).value;
const length = (document.getElementById("length") as HTMLInputElement)
.value;
const numb = (document.getElementById("numb") as HTMLInputElement).checked;
const lower = (document.getElementById("lower") as HTMLInputElement).checked;
const upper = (document.getElementById("upper") as HTMLInputElement).checked;
const special = (document.getElementById("special") as HTMLInputElement).checked;
const lower = (document.getElementById("lower") as HTMLInputElement)
.checked;
const upper = (document.getElementById("upper") as HTMLInputElement)
.checked;
const special = (document.getElementById("special") as HTMLInputElement)
.checked;
try {
const response = await fetch(
@ -28,7 +30,13 @@ export default function RgbToHex() {
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ length: length, numb: numb, lower: lower, upper: upper, special: special }),
body: JSON.stringify({
length: length,
numb: numb,
lower: lower,
upper: upper,
special: special,
}),
},
);
if (!response.ok) {
@ -37,7 +45,6 @@ export default function RgbToHex() {
const password: string = await response.text();
console.log(password);
setPassword(password);
} catch (error) {
console.error("Error while converting:", error);
alert("Error while converting");
@ -61,7 +68,7 @@ export default function RgbToHex() {
};
const checkInput = (event: React.ChangeEvent<HTMLInputElement>) => {
const length = (document.getElementById(event.target.id) as HTMLInputElement);
const length = document.getElementById(event.target.id) as HTMLInputElement;
const lengthValue = +length.value;
if (lengthValue < 1 || lengthValue > 64) {
@ -72,20 +79,32 @@ export default function RgbToHex() {
} else if (lengthValue > 64) {
length.value = "64";
}
}
};
return (
<div className="h-screen w-screen bg-black text-white font-noto flex flex-col items-center">
<Navbar renderHomeLink={true} />
<div className="w-screen h-screen flex flex-col items-center justify-center">
<h2 className="text-5xl font-bold text-white mb-16">password-generator</h2>
<h2 className="text-5xl font-bold text-white mb-16">
password-generator
</h2>
<div className="border-2 border-white p-3 rounded-xl text-center text-white flex flex-row justify-between">
<div className="flex flex-col items-start">
<label className="mx-2" htmlFor="length">length:</label>
<label className="mx-2 text-white" htmlFor="numb">numbers</label>
<label className="mx-2" htmlFor="lower">lower case characters</label>
<label className="mx-2" htmlFor="upper">upper case characters</label>
<label className="mx-2" htmlFor="special">special characters</label>
<label className="mx-2" htmlFor="length">
length:
</label>
<label className="mx-2 text-white" htmlFor="numb">
numbers
</label>
<label className="mx-2" htmlFor="lower">
lower case characters
</label>
<label className="mx-2" htmlFor="upper">
upper case characters
</label>
<label className="mx-2" htmlFor="special">
special characters
</label>
</div>
<div className="flex flex-col items-end justify-evenly gap-2">
<input
@ -134,16 +153,12 @@ export default function RgbToHex() {
}
onClick={generatePassword}
/>
<Button
content="clear"
onClick={clearInAndOutput}
/>
<Button content="clear" onClick={clearInAndOutput} />
</div>
<div className="p-3 rounded-xl text-center">
<output
id="password"
className="text-blue-400 text-3xl"
>{password}</output>
<output id="password" className="text-blue-400 text-3xl">
{password}
</output>
</div>
</div>
<Footer />

View file

@ -6,12 +6,10 @@ import Footer from "../../components/Footer";
import Button from "../../components/Button";
export default function RgbToHex() {
const [loading, setLoading] = useState(false);
const [output, setOutput] = useState("");
const testRegex = async () => {
setLoading(true);
const regex = (document.getElementById("regex") as HTMLInputElement).value;
@ -34,7 +32,6 @@ export default function RgbToHex() {
const output: string = await response.text();
console.log(output);
setOutput(output);
} catch (error) {
console.error("Error while converting:", error);
alert("Error while converting");
@ -58,7 +55,9 @@ export default function RgbToHex() {
<h2 className="text-5xl font-bold text-white mb-16">regex-tester</h2>
<div className="border-2 border-white p-3 rounded-xl text-center text-white flex flex-col justify-between">
<div>
<label className="mr-2 m" htmlFor="regex">regex:</label>
<label className="mr-2 m" htmlFor="regex">
regex:
</label>
<input
type="text"
id="regex"
@ -67,7 +66,9 @@ export default function RgbToHex() {
/>
</div>
<div>
<label className="mr-2" htmlFor="test">test string:</label>
<label className="mr-2" htmlFor="test">
test string:
</label>
<input
type="text"
id="test"
@ -87,16 +88,12 @@ export default function RgbToHex() {
}
onClick={testRegex}
/>
<Button
content="clear"
onClick={clearInAndOutput}
/>
<Button content="clear" onClick={clearInAndOutput} />
</div>
<div className="p-3 rounded-xl text-center">
<output
id="output"
className="text-blue-400 text-3xl"
>{output}</output>
<output id="output" className="text-blue-400 text-3xl">
{output}
</output>
</div>
</div>
<Footer />

View file

@ -6,12 +6,10 @@ import Footer from "../../components/Footer";
import Button from "../../components/Button";
export default function RgbToHex() {
const [loading, setLoading] = useState(false);
const [hex, setHex] = useState("");
const convertToHex = async () => {
setLoading(true);
const red = (document.getElementById("red") as HTMLInputElement).value;
@ -34,7 +32,6 @@ export default function RgbToHex() {
}
const hex: string = await response.text();
setHex(hex);
} catch (error) {
console.error("Error while converting:", error);
alert("Error while converting");
@ -54,7 +51,7 @@ export default function RgbToHex() {
};
const checkInput = (event: React.ChangeEvent<HTMLInputElement>) => {
const color = (document.getElementById(event.target.id) as HTMLInputElement);
const color = document.getElementById(event.target.id) as HTMLInputElement;
const colorValue = +color.value;
if (colorValue < 0 || colorValue > 255) {
@ -65,7 +62,7 @@ export default function RgbToHex() {
} else if (colorValue > 255) {
color.value = "255";
}
}
};
return (
<div className="h-screen w-screen bg-black text-white font-noto flex flex-col items-center">
@ -73,7 +70,9 @@ export default function RgbToHex() {
<div className="w-screen h-screen flex flex-col items-center justify-center">
<h2 className="text-5xl font-bold text-white mb-16">rgb-to-hex</h2>
<div className="border-2 border-white p-3 rounded-xl text-center text-white">
<label className="mr-2" htmlFor="red">Red:</label>
<label className="mr-2" htmlFor="red">
Red:
</label>
<input
type="number"
id="red"
@ -83,7 +82,9 @@ export default function RgbToHex() {
className="w-16 bg-black border-1 border-white text-center"
onInput={checkInput}
/>
<label className="mx-2 text-white" htmlFor="green">Green:</label>
<label className="mx-2 text-white" htmlFor="green">
Green:
</label>
<input
type="number"
id="green"
@ -93,7 +94,9 @@ export default function RgbToHex() {
className="w-16 bg-black border-1 border-white text-center"
onChange={checkInput}
/>
<label className="mx-2" htmlFor="blue">Blue:</label>
<label className="mx-2" htmlFor="blue">
Blue:
</label>
<input
type="number"
id="blue"
@ -115,16 +118,12 @@ export default function RgbToHex() {
}
onClick={convertToHex}
/>
<Button
content="clear"
onClick={clearInAndOutput}
/>
<Button content="clear" onClick={clearInAndOutput} />
</div>
<div className="p-3 rounded-xl text-center">
<output
id="hex"
className="text-blue-400 text-3xl"
>{hex}</output>
<output id="hex" className="text-blue-400 text-3xl">
{hex}
</output>
</div>
</div>
<Footer />

View file

@ -22,7 +22,6 @@
"@/*": ["./src/*"]
}
},
"include": [
"next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}