@@ -3,14 +3,17 @@ import { computed, nextTick, onBeforeMount, provide, ref, watch } from 'vue';
33import { useI18n } from ' vue-i18n' ;
44import { useRoute , useRouter } from ' vue-router' ;
55
6+ import AuthorizationStatusPill from ' @/components/authorization/AuthorizationStatusPill.vue' ;
67import Tooltip from ' @/components/common/Tooltip.vue' ;
78import EnquiryListProponent from ' @/components/projectCommon/enquiry/EnquiryListProponent.vue' ;
89import SubmissionDraftListProponent from ' @/components/projectCommon/submission/SubmissionDraftListProponent.vue' ;
910import { Button , Paginator } from ' @/lib/primevue' ;
10- import { enquiryService , housingProjectService } from ' @/services' ;
11+ import { enquiryService , housingProjectService , permitService } from ' @/services' ;
1112import { useContactStore } from ' @/store' ;
1213import { NavigationPermission } from ' @/store/authzStore' ;
1314import { RouteName } from ' @/utils/enums/application' ;
15+ import { PermitAuthorizationStatus } from ' @/utils/enums/permit' ;
16+ import { ApplicationStatus } from ' @/utils/enums/projectCommon' ;
1417import { formatDate } from ' @/utils/formatters' ;
1518import {
1619 draftableProjectServiceKey ,
@@ -20,7 +23,7 @@ import {
2023} from ' @/utils/keys' ;
2124
2225import type { Ref } from ' vue' ;
23- import type { Enquiry , HousingProject } from ' @/types' ;
26+ import type { Enquiry , HousingProject , Permit } from ' @/types' ;
2427
2528// Constants
2629const PAGE_ROWS = 5 ;
@@ -31,7 +34,7 @@ const route = useRoute();
3134const router = useRouter ();
3235
3336// State
34- const displayedProjects = computed (() => projects . value . slice ( first . value , first . value + PAGE_ROWS ) );
37+ const authorizations : Ref < Array < Permit >> = ref ([] );
3538const drafts: Ref <Array <any >> = ref ([]);
3639const enquiries: Ref <Array <Enquiry >> = ref ([]);
3740const first: Ref <number > = ref (0 );
@@ -70,6 +73,35 @@ async function createIntake() {
7073 });
7174}
7275
76+ const displayedProjectsInOrder = computed (() => {
77+ // Filter projects to only include completed projects and sort them by last updated
78+ const completed = projects .value
79+ .filter ((p ) => p .applicationStatus === ApplicationStatus .COMPLETED )
80+ .sort (sortByLastUpdated );
81+
82+ // Filter projects to only include active projects and sort them by last updated
83+ const active = projects .value
84+ .filter ((p ) => [ApplicationStatus .IN_PROGRESS , ApplicationStatus .NEW ].includes (p .applicationStatus ))
85+ .sort ((a , b ) => {
86+ if (a .submittedAt && b .submittedAt ) {
87+ return a .submittedAt > b .submittedAt ? - 1 : 1 ;
88+ } else {
89+ if (! a .submittedAt ) return 1 ;
90+ if (! b .submittedAt ) return - 1 ;
91+ return 0 ;
92+ }
93+ });
94+
95+ // Combine active and completed projects, then slice based on pagination
96+ return [... active , ... completed ].slice (first .value , first .value + PAGE_ROWS );
97+ });
98+
99+ const hasPendingAuth = computed (() => (activityId : string ) => {
100+ return authorizations .value .some (
101+ (auth ) => auth .activityId === activityId && auth .authStatus === PermitAuthorizationStatus .PENDING
102+ );
103+ });
104+
73105function onHousingProjectDraftDelete(draftId : string ) {
74106 drafts .value = drafts .value .filter ((x ) => x .draftId !== draftId );
75107}
@@ -98,8 +130,9 @@ watch(
98130);
99131
100132onBeforeMount (async () => {
101- [enquiries .value , projects .value , drafts .value ] = (
133+ [authorizations . value , enquiries .value , projects .value , drafts .value ] = (
102134 await Promise .all ([
135+ permitService .listPermits (),
103136 enquiryService .getEnquiries (),
104137 housingProjectService .searchProjects ({ includeDeleted: false }),
105138 housingProjectService .getDrafts ()
@@ -202,27 +235,53 @@ onBeforeMount(async () => {
202235 <p class =" font-bold" >{{ t('e.housing.housingView.projectsEmpty') }}</p >
203236 </div >
204237 <div
205- v-for =" (project, index) in displayedProjects "
238+ v-for =" (project, index) in displayedProjectsInOrder "
206239 v-else
207240 :key =" project.activityId"
208241 :index =" index"
209242 class =" rounded-sm shadow-md hover:shadow-lg px-6 py-4 custom-card hover-hand"
210- :class =" { 'mb-2': index != displayedProjects.length - 1 }"
243+ :class =" {
244+ 'mb-2': index != displayedProjectsInOrder.length - 1,
245+ 'custom-card-completed': project.applicationStatus === ApplicationStatus.COMPLETED
246+ }"
211247 >
248+ <router-link
249+ v-if =" hasPendingAuth(project.activityId)"
250+ class =" no-underline"
251+ :to =" {
252+ name: RouteName.EXT_HOUSING_PROJECT,
253+ params: { projectId: project.housingProjectId }
254+ }"
255+ >
256+ <h5 class =" font-bold mb-4" >{{ project.projectName }}</h5 >
257+ </router-link >
212258 <div class =" grid grid-cols-12 gap-4" >
213259 <div class =" col-span-3 flex items-center" >
214260 <router-link
261+ v-if =" !hasPendingAuth(project.activityId)"
215262 class =" no-underline"
216263 :to =" {
217264 name: RouteName.EXT_HOUSING_PROJECT,
218265 params: { projectId: project.housingProjectId }
219266 }"
220267 >
221- <h4 class =" font-bold mb-0" >{{ project.projectName }}</h4 >
268+ <h5 class =" font-bold mb-0" >{{ project.projectName }}</h5 >
222269 </router-link >
270+ <AuthorizationStatusPill
271+ v-if =" hasPendingAuth (project .activityId )"
272+ class="my-1"
273+ :auth-status =" PermitAuthorizationStatus .PENDING "
274+ :display-text =" t (' e.housing.housingView.pendingAuths' )"
275+ />
223276 </div >
224277 <div class =" col-span-3 flex items-center" >
225- <p >{{ t('e.housing.housingView.projectState') }}: {{ project.applicationStatus }}</p >
278+ <p
279+ :class =" {
280+ 'font-bold': [ApplicationStatus.IN_PROGRESS, ApplicationStatus.NEW].includes(project.applicationStatus)
281+ }"
282+ >
283+ {{ project.applicationStatus }}
284+ </p >
226285 </div >
227286 <div class =" col-span-3 flex items-center" >
228287 <p >{{ t('e.housing.housingView.confirmationId') }}: {{ project.activityId }}</p >
@@ -306,7 +365,17 @@ onBeforeMount(async () => {
306365
307366<style scoped lang="scss">
308367.custom-card {
309- background-color : #f7f9fc ;
368+ background-color : var (--p-white );
369+ border : 1px solid var (--p-greyscale-200 );
370+
371+ & :hover {
372+ a {
373+ text-decoration : underline !important ;
374+ }
375+ }
376+ }
377+ .custom-card-completed {
378+ background-color : var (--p-greyscale-50 );
310379
311380 & :hover {
312381 a {
0 commit comments