-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI - hosts,strata,examiner applications table updates #455
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { ApiApplicationBaseResp } from '~/interfaces/strr-api' | ||
|
||
export const useStrrBasePermitList = <A extends ApiApplicationBaseResp>( | ||
setType?: ApplicationType, setStatus?: ApplicationStatus | ||
) => { | ||
const { getAccountApplications } = useStrrApi() | ||
|
||
const limit = ref(50) | ||
const page = ref(1) | ||
const status = ref<ApplicationStatus | undefined>(setStatus) | ||
const type = ref<ApplicationType | undefined>(setType) | ||
|
||
const getApplicationList = async () => { | ||
return await getAccountApplications<A>(limit.value, page.value, type.value, status.value) | ||
.catch((e) => { | ||
logFetchError(e, 'Unable to load account applications') | ||
return undefined | ||
}) | ||
} | ||
|
||
return { | ||
limit, | ||
page, | ||
status, | ||
type, | ||
getApplicationList | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,12 @@ import { RoutesE } from '~/enums/routes' | |
import type { HostApplicationResp } from '~/interfaces/host-i' | ||
import type { ApiBasePlatformApplication, PlatformApplicationResp } from '~/interfaces/platform-i' | ||
import type { StrataApplicationResp } from '~/interfaces/strata-i' | ||
import { useExaminerStore } from '~/store/examiner' | ||
import { displayFullUnitAddress } from '~/utils/format-helper' | ||
|
||
const localePath = useLocalePath() | ||
const { t } = useI18n() | ||
const { loading } = storeToRefs(useConnectDetailsHeaderStore()) | ||
// TODO: ApplicationStatus.FULL_REVIEW is temporary until we have reqs defined | ||
const { limit, page, getApplicationList } = useStrrBasePermitList(undefined, ApplicationStatus.FULL_REVIEW) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably will need to pass a few statuses here, eventually. |
||
|
||
useHead({ | ||
title: t('page.dashboardList.title') | ||
|
@@ -23,30 +24,20 @@ const PROPERTY_MANAGER_TYPE = 'Property Manager' | |
const STRATA_HOTEL_TYPE = 'Strata Hotel' | ||
const PLATFORM_TYPE = 'Platform' | ||
|
||
const applications = ref() | ||
const mappedApplications = ref() | ||
const { data: applicationListResp, status } = await useAsyncData( | ||
'application-list-resp', | ||
getApplicationList, | ||
{ | ||
watch: [limit, page], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not really an issue but we could use transform here to clean things up a bit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll keep it as is for now since its likely to change a bit with further reqs. Host / strata need the extra mapping for the local sorting (temporary till its available via the api) |
||
default: () => ({ applications: [], total: 0 }) | ||
} | ||
) | ||
|
||
const columns = [ | ||
{ key: 'applicationNumber', label: 'Application Number', sortable: false }, | ||
{ key: 'registrationNumber', label: 'Registration Number', sortable: false }, | ||
{ key: 'registrationType', label: 'Type', sortable: false }, | ||
{ key: 'propertyAddress', label: 'Address', sortable: false }, | ||
{ key: 'applicantName', label: 'Applicant Name', sortable: false }, | ||
{ key: 'status', label: 'Status', sortable: false }, | ||
{ key: 'submissionDate', label: 'Submission Date', sortable: false }, | ||
{ key: 'actions', label: t('label.actions') } | ||
] | ||
|
||
async function handleItemSelect (row: any) { | ||
await navigateTo(localePath(`${RoutesE.EXAMINE}/${row.applicationNumber}`)) | ||
} | ||
|
||
onMounted(async () => { | ||
loading.value = true | ||
|
||
applications.value = await useExaminerStore().getAllApplications() | ||
|
||
mappedApplications.value = applications.value.map( | ||
const mapApplicationsList = () => { | ||
if (!applicationListResp.value?.applications) { | ||
return [] | ||
} | ||
return (applicationListResp.value.applications).map( | ||
(application: HostApplicationResp | PlatformApplicationResp | StrataApplicationResp) => { | ||
const { | ||
header: { | ||
|
@@ -94,24 +85,87 @@ onMounted(async () => { | |
isPaid: status !== 'DRAFT' && status !== 'PAYMENT_DUE', | ||
submissionDate: dateToString(applicationDateTime, 'MMMM d, yyyy') | ||
} | ||
} | ||
) | ||
}) | ||
} | ||
const applications = computed(() => mapApplicationsList()) | ||
|
||
loading.value = false | ||
}) | ||
const columns = [ | ||
{ key: 'applicationNumber', label: 'Application Number', sortable: false }, | ||
{ key: 'registrationNumber', label: 'Registration Number', sortable: false }, | ||
{ key: 'registrationType', label: 'Type', sortable: false }, | ||
{ key: 'propertyAddress', label: 'Address', sortable: false }, | ||
{ key: 'applicantName', label: 'Applicant Name', sortable: false }, | ||
{ key: 'status', label: 'Status', sortable: false }, | ||
{ key: 'submissionDate', label: 'Submission Date', sortable: false }, | ||
{ key: 'actions', label: t('label.actions') } | ||
] | ||
|
||
const selectedColumns = ref([...columns]) | ||
|
||
async function handleItemSelect (row: any) { | ||
await navigateTo(localePath(`${RoutesE.EXAMINE}/${row.applicationNumber}`)) | ||
} | ||
|
||
</script> | ||
<template> | ||
<div v-if="loading" class="w-full justify-center p-14"> | ||
Loading... | ||
</div> | ||
<div v-else class="space-y-8 py-8 sm:space-y-10 sm:py-10"> | ||
<div class="bg-white"> | ||
<UTable :columns="columns" :rows="mappedApplications"> | ||
<template #actions-data="{ row }"> | ||
<UButton :label="$t('btn.view')" @click="handleItemSelect(row)" /> | ||
</template> | ||
</UTable> | ||
<div class="h-full space-y-8 py-8 sm:space-y-10 sm:py-10"> | ||
<div class="flex justify-end gap-3"> | ||
<UPagination | ||
v-if="applicationListResp.total > limit" | ||
v-model="page" | ||
:page-count="limit" | ||
size="lg" | ||
:total="applicationListResp?.total || 0" | ||
:ui="{ | ||
base: 'h-[42px]', | ||
default: { | ||
activeButton: { class: 'rounded' } | ||
} | ||
}" | ||
/> | ||
<USelectMenu | ||
v-slot="{ open }" | ||
v-model="selectedColumns" | ||
:options="columns" | ||
multiple | ||
:ui="{ trigger: 'flex items-center w-full' }" | ||
> | ||
<UButton | ||
color="white" | ||
class="h-[42px] flex-1 justify-between text-gray-700" | ||
:aria-label="$t('btn.colsToShow.aria', { count: selectedColumns.length })" | ||
> | ||
<span>{{ $t('btn.colsToShow.label') }}</span> | ||
|
||
<UIcon | ||
name="i-mdi-caret-down" | ||
class="size-5 text-gray-700 transition-transform" | ||
:class="[open && 'rotate-180']" | ||
/> | ||
</UButton> | ||
</USelectMenu> | ||
</div> | ||
<UTable | ||
ref="tableRef" | ||
:columns="selectedColumns" | ||
:rows="applications" | ||
:loading="status === 'pending'" | ||
:ui="{ | ||
wrapper: 'relative overflow-x-auto h-[512px]', | ||
thead: 'sticky top-0 bg-white z-10', | ||
th: { padding: 'px-2 py-4' }, | ||
td: { | ||
base: 'whitespace-normal max-w-96 align-top', | ||
padding: 'p-2', | ||
color: 'text-bcGovColor-midGray', | ||
font: '', | ||
size: 'text-sm', | ||
} | ||
}" | ||
> | ||
<template #actions-data="{ row }"> | ||
<UButton :label="$t('btn.view')" @click="handleItemSelect(row)" /> | ||
</template> | ||
</UTable> | ||
</div> | ||
</template> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice