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 value = $state(perms);
|
||||||
let prevValue = $state(perms);
|
let prevValue = $state(perms);
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
value = perms;
|
||||||
|
prevValue = perms;
|
||||||
|
});
|
||||||
|
|
||||||
function onChange(change: string[]) {
|
function onChange(change: string[]) {
|
||||||
$permissions.perms.forEach((perm) => {
|
$permissions.perms.forEach((perm) => {
|
||||||
if (prevValue.includes(perm) && !change.includes(perm)) {
|
if (prevValue.includes(perm) && !change.includes(perm)) {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
let rows = $state(0);
|
let rows = $state(0);
|
||||||
|
|
||||||
$effect(() => {
|
$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;
|
data = res.entries;
|
||||||
rows = res.rows;
|
rows = res.rows;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,12 +22,14 @@
|
|||||||
import { permissions } from "@stores/stores.ts";
|
import { permissions } from "@stores/stores.ts";
|
||||||
import { permsRepo } from "@repo/perms.ts";
|
import { permsRepo } from "@repo/perms.ts";
|
||||||
|
|
||||||
const {
|
const { prefix, uuid }: { prefix: string; uuid: string } = $props();
|
||||||
prefix, uuid
|
|
||||||
}: { prefix: string, uuid: string } = $props();
|
|
||||||
|
|
||||||
let value = $state(prefix);
|
let value = $state(prefix);
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
value = prefix;
|
||||||
|
});
|
||||||
|
|
||||||
function onChange(change: string) {
|
function onChange(change: string) {
|
||||||
$permsRepo.setPrefix(uuid, change);
|
$permsRepo.setPrefix(uuid, change);
|
||||||
|
|
||||||
|
|||||||
@@ -36,25 +36,20 @@ export const columns: ColumnDef<Player[]> = [
|
|||||||
accessorKey: "prefix",
|
accessorKey: "prefix",
|
||||||
header: "Prefix",
|
header: "Prefix",
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
return renderComponent(
|
return renderComponent(PrefixDropdown, {
|
||||||
PrefixDropdown, {
|
|
||||||
prefix: row.getValue("prefix"),
|
prefix: row.getValue("prefix"),
|
||||||
uuid: row.getValue("uuid"),
|
uuid: row.getValue("uuid"),
|
||||||
},
|
});
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "perms",
|
accessorKey: "perms",
|
||||||
header: "Permissions",
|
header: "Permissions",
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
return renderComponent(
|
return renderComponent(PermissionsDropdown, {
|
||||||
PermissionsDropdown,
|
|
||||||
{
|
|
||||||
perms: row.getValue("perms"),
|
perms: row.getValue("perms"),
|
||||||
uuid: row.getValue("uuid"),
|
uuid: row.getValue("uuid"),
|
||||||
},
|
});
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
Reference in New Issue
Block a user