The state of the submissions to filter by (e.g., "approved"
, "pending"
).
Optional
params: SubmissionParamsOptional additional parameters to filter or paginate the submissions:
projectId
: The ID of the project to which the submissions belong.schemaId
: The ID of the schema used for filtering submissions.state
: The state(s) of the submissions to filter by. Can be a single state or an array of states.ownerId
: The ID of the owner to filter submissions by.limit
: The maximum number of submissions to fetch in a single query. Useful for pagination.page
: The page number to fetch when paginating through submissions. Typically used alongside limit
.The returning object contains:
submissions
: The filtered list of submissions, which includes only submissions that match
the specified state
.approveAll
: Function to approve all submissions in the current list.refresh
: Function to refresh the list of submissions by re-fetching them from the
backend. Pass quiet
to suppress loading indicators.rejectAll
: Function to reject all submissions in the current list.fetchMore
: Function to fetch additional submissions beyond the current list.
Pass refresh
to indicate whether to refresh the existing list.fetched
: Boolean indicating whether the list of submissions has been fetched from the
backend.hasMore
: Boolean indicating whether there are more submissions available to fetch.currentPage
: The current page of submissions that has been fetched.state
property
passed as an argument. Only submissions matching the provided state are included in the result.params
) are forwarded to the
useSubmissions
hook, allowing further filtering, pagination, or customization of the
submission query.useSubmissions
: The hook delegates data fetching and state
management to the useSubmissions
hook, enhancing it with the added state filtering
functionality.useSubmissions
hook, allowing
you to fetch additional submissions if necessary, and handle the results accordingly.useSubmissions
hook are passed through,
and they should be handled as needed.Optional
refresh: booleanimport { useSubmissionsByState } from 'react-playmakers';
const ApprovedSubmissionsList = () => {
const { submissions, fetchMore, refresh, fetched } = useSubmissionsByState("approved", {
limit: 10 });
if (!fetched) {
return <div>Loading submissions...</div>;
}
return (
<div>
{submissions.map(submission => (
<div key={submission.id}>{submission.name}</div>
))}
<button onClick={() => fetchMore()}>Load More</button>
<button onClick={() => refresh(false)}>Refresh</button>
</div>
);
};
Generated using TypeDoc
Custom React hook fetch and manage submissions filtered by their state.
This hook is a wrapper around the useSubmissions hook, allowing you to fetch submissions and filter them by a specific state.