mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
Adjusted
This commit is contained in:
@@ -31,7 +31,7 @@ export const UserProvider = ({ children }) => {
|
||||
const [attributes, setAttributes] = useState([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState(null);
|
||||
|
||||
|
||||
// ─── Helpers ───────────────────────────────────────────────────────────────
|
||||
const request = useCallback(async (fn) => {
|
||||
setLoading(true);
|
||||
@@ -112,6 +112,29 @@ export const UserProvider = ({ children }) => {
|
||||
[request]
|
||||
);
|
||||
|
||||
// ─── GET /api/admin/users/archived ────────────────────────────────────────────
|
||||
const fetchArchivedUsers = useCallback(
|
||||
({ page = 1, limit = 10, filters = [], sort = [] } = {}) =>
|
||||
request(async () => {
|
||||
const { data } = await api.get(`${BASE}/users/archived`, {
|
||||
params: {
|
||||
page,
|
||||
limit,
|
||||
filters: filters.length ? JSON.stringify(filters) : undefined,
|
||||
sort: sort.length ? JSON.stringify(sort) : undefined,
|
||||
},
|
||||
});
|
||||
|
||||
const final_data = data?.data
|
||||
setUsers(final_data?.data ?? []);
|
||||
setPagination(final_data?.pagination ?? PAGINATION_INIT);
|
||||
setAttributes(final_data?.attributes ?? []);
|
||||
|
||||
return res.data;
|
||||
}),
|
||||
[request]
|
||||
);
|
||||
|
||||
// ─── POST /api/admin/users/:id/restore ────────────────────────────────────
|
||||
const restoreUser = useCallback(
|
||||
(userId) =>
|
||||
@@ -182,6 +205,7 @@ export const UserProvider = ({ children }) => {
|
||||
// actions
|
||||
fetchUserFieldValues,
|
||||
fetchUsers,
|
||||
fetchArchivedUsers,
|
||||
fetchUser,
|
||||
updateUser,
|
||||
deactivateUser,
|
||||
|
||||
Reference in New Issue
Block a user