Refactor player components: streamline state management and improve code readability in PermissionsDropdown, Players, and PrefixDropdown
Some checks failed
SteamWarCI Build failed
Some checks failed
SteamWarCI Build failed
This commit is contained in:
@@ -28,6 +28,11 @@
|
||||
let value = $state(perms);
|
||||
let prevValue = $state(perms);
|
||||
|
||||
$effect(() => {
|
||||
value = perms;
|
||||
prevValue = perms;
|
||||
});
|
||||
|
||||
function onChange(change: string[]) {
|
||||
$permissions.perms.forEach((perm) => {
|
||||
if (prevValue.includes(perm) && !change.includes(perm)) {
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
let rows = $state(0);
|
||||
|
||||
$effect(() => {
|
||||
$dataRepo.queryPlayers(search || undefined, undefined, undefined, pagination.pageSize, pagination.pageIndex, true, true).then((res) => {
|
||||
$dataRepo.queryPlayers(search || undefined, undefined, undefined, pagination.pageSize, pagination.pageIndex, true, false).then((res) => {
|
||||
data = res.entries;
|
||||
rows = res.rows;
|
||||
});
|
||||
|
||||
@@ -22,12 +22,14 @@
|
||||
import { permissions } from "@stores/stores.ts";
|
||||
import { permsRepo } from "@repo/perms.ts";
|
||||
|
||||
const {
|
||||
prefix, uuid
|
||||
}: { prefix: string, uuid: string } = $props();
|
||||
const { prefix, uuid }: { prefix: string; uuid: string } = $props();
|
||||
|
||||
let value = $state(prefix);
|
||||
|
||||
$effect(() => {
|
||||
value = prefix;
|
||||
});
|
||||
|
||||
function onChange(change: string) {
|
||||
$permsRepo.setPrefix(uuid, change);
|
||||
|
||||
|
||||
@@ -36,25 +36,20 @@ export const columns: ColumnDef<Player[]> = [
|
||||
accessorKey: "prefix",
|
||||
header: "Prefix",
|
||||
cell: ({ row }) => {
|
||||
return renderComponent(
|
||||
PrefixDropdown, {
|
||||
return renderComponent(PrefixDropdown, {
|
||||
prefix: row.getValue("prefix"),
|
||||
uuid: row.getValue("uuid"),
|
||||
},
|
||||
);
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "perms",
|
||||
header: "Permissions",
|
||||
cell: ({ row }) => {
|
||||
return renderComponent(
|
||||
PermissionsDropdown,
|
||||
{
|
||||
return renderComponent(PermissionsDropdown, {
|
||||
perms: row.getValue("perms"),
|
||||
uuid: row.getValue("uuid"),
|
||||
},
|
||||
);
|
||||
});
|
||||
},
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user