Skip to content

Commit

Permalink
feature: allows to filter userTaskRuns that were created before a spe…
Browse files Browse the repository at this point in the history
…cified date-time
  • Loading branch information
diablouma committed May 16, 2024
1 parent b198124 commit d19c1b4
Showing 1 changed file with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,23 @@ export const UserTaskDef: FC<Props> = ({ spec }) => {
const [userId, setUserId] = useState('')
const [userGroup, setUserGroup] = useState('')
const [createdAfter, setCreatedAfter] = useState('')
const [createdBefore, setCreatedBefore] = useState('')
const { tenantId } = useWhoAmI()
const [limit, setLimit] = useState<number>(SEARCH_DEFAULT_LIMIT)
const [userIdToSearchFor] = useDebounce(userId, 1000)
const [userGroupToSearchFor] = useDebounce(userGroup, 1000)

const { isPending, data, hasNextPage, fetchNextPage } = useInfiniteQuery({
queryKey: ['userTaskRun', selectedStatus, userIdToSearchFor, userGroupToSearchFor, tenantId, limit, createdAfter],
queryKey: [
'userTaskRun',
selectedStatus,
userIdToSearchFor,
userGroupToSearchFor,
tenantId,
limit,
createdAfter,
createdBefore,
],
initialPageParam: undefined,
getNextPageParam: (lastPage: PaginatedUserTaskRunList) => lastPage.bookmarkAsString,
queryFn: async ({ pageParam }) => {
Expand All @@ -50,6 +60,7 @@ export const UserTaskDef: FC<Props> = ({ spec }) => {
status: selectedStatus,
userTaskDefName: spec.name,
earliestStart: createdAfter ? localDateTimeToUTCIsoString(createdAfter) : undefined,
latestStart: createdBefore ? localDateTimeToUTCIsoString(createdBefore) : undefined,
userId: userIdToSearchFor.trim() != '' ? userIdToSearchFor : undefined,
userGroup: userGroupToSearchFor.trim() != '' ? userGroupToSearchFor : undefined,
})
Expand Down Expand Up @@ -80,32 +91,43 @@ export const UserTaskDef: FC<Props> = ({ spec }) => {
</div>
<div className="mb-5 flex max-w-fit items-start justify-between">
<Field className="flex items-center justify-between">
<Label className="block w-1/2 font-bold">User Id</Label>
<Label className="block w-1/2 font-bold">User Id:</Label>
<Input
type="text"
value={userId}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setUserId(e.target.value)}
className="focus:shadow-outline w-full appearance-none rounded border px-3 py-2 leading-tight shadow focus:outline-none"
className="focus:shadow-outline ml-6 w-full appearance-none rounded border px-3 py-2 leading-tight shadow focus:outline-none"
/>
</Field>

<Field className="ml-6 flex items-center justify-between">
<Label className="block w-1/2 font-bold">User Group</Label>
<Field className="ml-16 flex items-center justify-between">
<Label className="block w-1/2 font-bold">User Group:</Label>
<Input
type="text"
value={userGroup}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setUserGroup(e.target.value)}
className="focus:shadow-outline w-full appearance-none rounded border px-3 py-2 leading-tight shadow focus:outline-none"
className="focus:shadow-outline ml-4 w-full appearance-none rounded border px-3 py-2 leading-tight shadow focus:outline-none"
/>
</Field>

<Field className="ml-6 flex items-center justify-between">
</div>
<div className="mb-5 flex max-w-fit items-start justify-between">
<Field className="flex items-center justify-between">
<Label className="block w-1/2 font-bold">Created after:</Label>
<Input
type="datetime-local"
value={createdAfter}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setCreatedAfter(e.target.value)}
className="focus:shadow-outline w-full appearance-none rounded border px-3 py-2 leading-tight shadow focus:outline-none"
className="focus:shadow-outline ml-3 w-full appearance-none rounded border px-3 py-2 leading-tight shadow focus:outline-none"
/>
</Field>

<Field className="ml-10 flex items-center justify-between">
<Label className="block w-1/2 font-bold">Created before:</Label>
<Input
type="datetime-local"
value={createdBefore}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setCreatedBefore(e.target.value)}
className="focus:shadow-outline ml-4 w-full appearance-none rounded border px-3 py-2 leading-tight shadow focus:outline-none"
/>
</Field>
</div>
Expand Down

0 comments on commit d19c1b4

Please sign in to comment.