Skip to content

Commit

Permalink
add frontend to show inactive status
Browse files Browse the repository at this point in the history
  • Loading branch information
c1495616js committed Oct 28, 2024
1 parent 4186498 commit bde29fd
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
16 changes: 15 additions & 1 deletion apps/api/src/applicant/endofjourney.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,15 @@ export class EndOfJourneyService {
.addSelect('job.ha_pcn_id', 'ha_pcn_id')
.leftJoin('audit.status', 'status')
.leftJoin('audit.job', 'job')
.leftJoin(
'ien_applicants_active_flag',
'active_flag',
'audit.applicant_id = active_flag.applicant_id',
)
.having('MAX(audit.effective_date) = :oneYearBeforeYesterday', { oneYearBeforeYesterday }) // Use HAVING for aggregate filtering
.where('status.status = :status', { status: STATUS.JOB_OFFER_ACCEPTED }) // Filter by status
.andWhere('audit.effective_date IS NOT NULL') // Filter out null effective_date
.andWhere('active_flag.applicant_id IS NULL') // Exclude applicants in ien_applicants_active_flag
.groupBy('audit.applicant_id') // Group by applicant_id
.addGroupBy('status.id')
.addGroupBy('job.id');
Expand Down Expand Up @@ -161,7 +167,7 @@ export class EndOfJourneyService {
throw new Error(`Status not found: ${STATUS.END_OF_JOURNEY_COMPLETE}`);
}
for (const applicant of list) {
// First, attempt the update
// First, attempt the update table "ien_applicants_active_flag"
const result = await manager
.createQueryBuilder()
.update('ien_applicants_active_flag')
Expand All @@ -187,6 +193,14 @@ export class EndOfJourneyService {
})
.execute();
}

// update the status and updated_date of the applicant
await manager
.createQueryBuilder()
.update('ien_applicants')
.set({ status: endOfJourneyCompleteStatus, updated_date: new Date() })
.where('id = :id', { id: applicant.applicant_id })
.execute();
}
};
}
6 changes: 5 additions & 1 deletion apps/api/src/applicant/ienapplicant.util.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ export class IENApplicantUtilService {
'applicant.active_flags',
'active_flag',
`active_flag.applicant_id = applicant.id AND active_flag.ha_id = '${ha_pcn_id}'`,
)
.leftJoinAndSelect(
'active_flag.status',
'active_flag_status',
'active_flag_status.id = active_flag.status_id',
);

if (!showHiddenApplicants) {
Expand All @@ -67,7 +72,6 @@ export class IENApplicantUtilService {
}),
);
}

if (recruiter) {
builder.innerJoinAndSelect(
'applicant.recruiters',
Expand Down
9 changes: 8 additions & 1 deletion apps/web/src/components/display/ApplicantTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface ApplicantTableProps {
applicants: ApplicantRO[];
loading?: boolean;
onSortChange: (field: string) => void;
showHiddenApplicants?: boolean;
}

// determine milestone text for status
Expand All @@ -35,7 +36,7 @@ const milestoneText = (applicant: ApplicantRO) => {
};

export const ApplicantTable = (props: ApplicantTableProps) => {
const { applicants, loading, onSortChange } = props;
const { applicants, loading, onSortChange, showHiddenApplicants } = props;
const searchParams = useSearchParams();

const { authUser } = useAuthContext();
Expand Down Expand Up @@ -87,6 +88,7 @@ export const ApplicantTable = (props: ApplicantTableProps) => {
<SortButton label='Recruiter' sortKey='recruiter' onChange={onSortChange} />
</th>
</AclMask>
{!!showHiddenApplicants && <th className='px-6'>Inactive Status</th>}
<th className='w-32' scope='col'></th>
</tr>
</thead>
Expand All @@ -108,6 +110,11 @@ export const ApplicantTable = (props: ApplicantTableProps) => {
{app.recruiters?.find(r => r?.organization === authUser?.organization)?.name}
</td>
</AclMask>
{!!showHiddenApplicants && (
<td className='px-4 whitespace-normal break-words' scope='col'>
{app.active_flags?.map(flag => flag.status).join(', ')}
</td>
)}
<td className='px-6 text-right'>
<Link
href={{
Expand Down
7 changes: 6 additions & 1 deletion apps/web/src/pages/applicants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,12 @@ const Applicants = () => {
pageOptions={{ pageIndex, pageSize: limit, total }}
onChange={handlePageOptions}
/>
<ApplicantTable applicants={applicants} onSortChange={handleSort} loading={loading} />
<ApplicantTable
applicants={applicants}
onSortChange={handleSort}
loading={loading}
showHiddenApplicants={showHiddenApplicants}
/>
<Pagination
id='applicant-page-bottom'
pageOptions={{ pageIndex, pageSize: limit, total }}
Expand Down

0 comments on commit bde29fd

Please sign in to comment.