Users custome login redirect
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import AdminLayout from "@/Layouts/AdminLayout.vue";
|
||||
import { useForm, Link, router } from "@inertiajs/vue3";
|
||||
import { ref, computed } from "vue";
|
||||
import { SearchIcon, SaveIcon, UserPlusIcon } from "lucide-vue-next";
|
||||
import { SearchIcon, SaveIcon, UserPlusIcon, Link2Icon } from "lucide-vue-next";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
@@ -48,6 +48,13 @@ const forms = Object.fromEntries(
|
||||
])
|
||||
);
|
||||
|
||||
const settingsForms = Object.fromEntries(
|
||||
props.users.map((u) => [
|
||||
u.id,
|
||||
useForm({ login_redirect: u.login_redirect ?? "" }),
|
||||
])
|
||||
);
|
||||
|
||||
function toggle(userId, roleId) {
|
||||
const form = forms[userId];
|
||||
const exists = form.roles.includes(roleId);
|
||||
@@ -140,6 +147,12 @@ function toggleUserActive(userId) {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function submitSettings(userId) {
|
||||
settingsForms[userId].patch(route("admin.users.settings", { user: userId }), {
|
||||
preserveScroll: true,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -254,6 +267,24 @@ function toggleUserActive(userId) {
|
||||
<div class="text-xs text-muted-foreground font-mono">
|
||||
{{ user.email }}
|
||||
</div>
|
||||
<div class="flex items-center gap-1 mt-1.5">
|
||||
<Link2Icon class="h-3 w-3 text-muted-foreground shrink-0" />
|
||||
<Input
|
||||
v-model="settingsForms[user.id].login_redirect"
|
||||
type="text"
|
||||
placeholder="/dashboard"
|
||||
class="h-6 text-xs px-1.5 w-36"
|
||||
/>
|
||||
<Button
|
||||
@click="submitSettings(user.id)"
|
||||
:disabled="settingsForms[user.id].processing"
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
class="h-6 px-2 text-xs"
|
||||
>
|
||||
<SaveIcon class="h-3 w-3" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</TableCell>
|
||||
|
||||
Reference in New Issue
Block a user