feat : copy buzzy audit logs
This commit is contained in:
@@ -19,23 +19,17 @@ const ALL = "all";
|
||||
|
||||
export function AuditLogFilters({
|
||||
actors,
|
||||
targetTypes,
|
||||
initialActorId,
|
||||
initialTargetType,
|
||||
}: {
|
||||
actors: Array<{ id: string; label: string }>;
|
||||
targetTypes: Array<{ value: string; label: string }>;
|
||||
initialActorId?: string;
|
||||
initialTargetType?: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [actorId, setActorId] = useState(initialActorId ?? ALL);
|
||||
const [targetType, setTargetType] = useState(initialTargetType ?? ALL);
|
||||
|
||||
function applyFilters() {
|
||||
const query = new URLSearchParams();
|
||||
if (actorId !== ALL) query.set("actor", actorId);
|
||||
if (targetType !== ALL) query.set("type", targetType);
|
||||
const suffix = query.toString();
|
||||
router.push(suffix ? `/admin/activity?${suffix}` : "/admin/activity");
|
||||
}
|
||||
@@ -60,24 +54,6 @@ export function AuditLogFilters({
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel htmlFor="audit-target-type">ประเภทเป้าหมาย</FieldLabel>
|
||||
<Select value={targetType} onValueChange={(value) => value && setTargetType(value)}>
|
||||
<SelectTrigger id="audit-target-type" className="w-full md:w-56">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem value={ALL}>ทั้งหมด</SelectItem>
|
||||
{targetTypes.map((type) => (
|
||||
<SelectItem key={type.value} value={type.value}>
|
||||
{type.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
<div className="flex gap-2">
|
||||
<Button type="button" onClick={applyFilters}>
|
||||
<FilterIcon data-icon="inline-start" />
|
||||
@@ -88,7 +64,6 @@ export function AuditLogFilters({
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
setActorId(ALL);
|
||||
setTargetType(ALL);
|
||||
router.push("/admin/activity");
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user