feat(manager/users/share): Enhance device sharing functionality and update related APIs and UI components

This commit is contained in:
Tran Anh Tuan
2026-01-23 11:29:35 +07:00
parent 8b95a620c2
commit 6691122c8f
11 changed files with 782 additions and 380 deletions

View File

@@ -1,4 +1,8 @@
import { API_THINGS_SEARCH } from '@/constants/api';
import {
API_SHARE_THING,
API_THING_POLICY,
API_THINGS_SEARCH,
} from '@/constants/api';
import { request } from '@umijs/max';
export async function apiSearchThings(
@@ -28,3 +32,43 @@ export async function apiSearchThings(
});
}
}
export async function apiGetThingPolicyByUser(
params: Partial<MasterModel.SearchPaginationBody>,
userId: string,
) {
return request<MasterModel.ThingPolicyResponse>(
`${API_THING_POLICY}/${userId}`,
{
params: params,
},
);
}
export async function apiDeleteUserThingPolicy(
thing_id: string,
user_id: string,
) {
return request(`${API_SHARE_THING}/${thing_id}/share`, {
method: 'DELETE',
data: {
policies: ['read', 'write', 'delete'],
user_ids: [user_id],
},
getResponse: true,
});
}
export async function apiShareThingToUser(
thing_id: string,
user_id: string,
policies: string[],
) {
return request(`${API_SHARE_THING}/${thing_id}/share`, {
method: 'POST',
data: {
policies: policies,
user_ids: [user_id],
},
getResponse: true,
});
}