front end for managing households

This commit is contained in:
DESKTOP-T0O5CDB\DESK-555BD 2025-11-11 16:11:39 -07:00
parent a137fbaa52
commit e30f1def1e
3 changed files with 18 additions and 10 deletions

View File

@ -183,7 +183,7 @@ namespace CarCareTracker.Controllers
Collaborators = result,
CanModifyCollaborators = userCanModify
};
return PartialView("_Collaborators", result);
return PartialView("_Collaborators", viewModel);
}
[TypeFilter(typeof(CollaboratorFilter))]
[HttpPost]

View File

@ -21,21 +21,27 @@
<table class="table table-hover">
<thead>
<tr class="d-flex">
<th scope="col" class="col-8">@translator.Translate(userLanguage, "Username")</th>
<th scope="col" class="col-4">@translator.Translate(userLanguage, "Delete")</th>
<th scope="col" class="@(Model.CanModifyCollaborators ? "col-8" : "col-12")">@translator.Translate(userLanguage, "Username")</th>
@if (Model.CanModifyCollaborators)
{
<th scope="col" class="col-4">@translator.Translate(userLanguage, "Delete")</th>
}
</tr>
</thead>
<tbody>
@foreach (UserCollaborator user in Model.Collaborators)
{
<tr class="d-flex">
<td class="col-8">@user.UserName</td>
<td class="col-4">
@if(User.Identity.Name != user.UserName && Model.CanModifyCollaborators)
{
<button onclick="deleteCollaborator(@user.UserVehicle.UserId, @user.UserVehicle.VehicleId)" class="btn btn-outline-danger btn-sm"><i class="bi bi-trash"></i></button>
}
</td>
<td class="@(Model.CanModifyCollaborators ? "col-8" : "col-12")">@user.UserName</td>
@if (Model.CanModifyCollaborators)
{
<td class="col-4">
@if (User.Identity.Name != user.UserName && Model.CanModifyCollaborators)
{
<button onclick="deleteCollaborator(@user.UserVehicle.UserId, @user.UserVehicle.VehicleId)" class="btn btn-outline-danger btn-sm"><i class="bi bi-trash"></i></button>
}
</td>
}
</tr>
}
</tbody>

View File

@ -588,6 +588,7 @@ function hideHouseholdModal() {
function removeUserFromHousehold(userId) {
$.post('/Home/RemoveUserFromHousehold', { userId: userId }, function (data) {
if (data) {
successToast('User Removed');
showHouseholdModal();
} else {
errorToast(genericErrorMessage())
@ -614,6 +615,7 @@ function addUserToHousehold() {
$.post('/Home/AddUserToHousehold', { username: result.value.userName }, function (data) {
if (data.success) {
showHouseholdModal();
successToast('User Added');
} else {
errorToast(data.message);
}