better haters managment

This commit is contained in:
Stepan Usatiuk
2023-12-29 13:27:19 +01:00
parent 02c48d2f22
commit b79c1dd1ad
2 changed files with 20 additions and 6 deletions

View File

@@ -9,7 +9,17 @@
.tools { .tools {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
max-width: 10rem; max-width: 20rem;
> * {
margin-top: 0.2rem;
}
.delResults {
margin-top: 1rem;
display: flex;
flex-direction: column;
}
} }
.found { .found {

View File

@@ -109,7 +109,10 @@ export function Haters() {
author: p.authorUsername, author: p.authorUsername,
}); });
}); });
const uuidToUsername: Record<string, string> = {};
data.persons.forEach((p) => (uuidToUsername[p.uuid] = p.username));
console.log(uuidToUsername);
console.log(foundU); console.log(foundU);
const foundUArr = Array.from(foundU); const foundUArr = Array.from(foundU);
@@ -137,13 +140,14 @@ export function Haters() {
if (isError(e)) { if (isError(e)) {
setDeleted((old) => [ setDeleted((old) => [
...old, ...old,
`error deleting user with uuid ${u}: ` + `error deleting user ${uuidToUsername[u]}: ` +
e.errors.join(" "), e.errors.join(" "),
]); ]);
} else { } else {
setDeleted((old) => [ setDeleted((old) => [
...old, ...old,
"deleted user with id: " + u, "deleted user: " +
uuidToUsername[u],
]); ]);
} }
deluser(rest); deluser(rest);
@@ -151,7 +155,7 @@ export function Haters() {
.catch(() => { .catch(() => {
setDeleted((old) => [ setDeleted((old) => [
...old, ...old,
`error deleting user with uuid ${u}`, `error deleting user ${uuidToUsername[u]}`,
]); ]);
}); });
}; };
@@ -159,9 +163,9 @@ export function Haters() {
deluser(foundUArr); deluser(foundUArr);
}} }}
> >
delete all users delete all found users
</button> </button>
<div> <div className={"delResults"}>
{deleted.map((d) => ( {deleted.map((d) => (
<span>{d}</span> <span>{d}</span>
))} ))}