Skip to content
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

Added detailplan ID to project search result card #496

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions backend/src/components/project/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export function detailplanProjectFragment(input: ProjectSearch) {
return sql.fragment`
SELECT
project_detailplan.id,
project_detailplan.detailplan_id AS "detailplanId",
'detailplanProject' AS "projectType"
FROM app.project_detailplan
WHERE ${
Expand Down Expand Up @@ -196,9 +197,9 @@ export async function projectSearch(input: ProjectSearch) {
), projects AS (
SELECT *
FROM (
SELECT id, "projectType" from investment_projects
SELECT id, "projectType", NULL AS "detailplanId" from investment_projects
UNION ALL
SELECT id, "projectType" from detailplan_projects
SELECT id, "projectType", "detailplanId" from detailplan_projects
) AS filtered_projects
INNER JOIN all_projects ON all_projects.id = filtered_projects.id
), limited AS (
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/views/Project/Projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ function ProjectCard({ result }: { result: DbProject }) {
<Box sx={{ display: 'flex', flexDirection: 'column' }}>
<Typography sx={{ lineHeight: '120%' }} variant="button">
{result.projectName}
{result.detailplanId && (
<>
,{' '}
<span
css={css`
color: #aaa;
`}
>
({result.detailplanId})
</span>
</>
)}
</Typography>
<Typography sx={{ lineHeight: '120%' }} variant="overline">
{dayjs(result.startDate).format(tr('date.format'))} —{' '}
Expand Down
1 change: 1 addition & 0 deletions shared/src/schema/project/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const dbProjectSchema = upsertProjectSchema.extend({
id: z.string(),
geom: z.string().nullable(),
projectType: z.enum(projectTypes),
detailplanId: z.number().nullable(),
});

export type UpsertProject = z.infer<typeof upsertProjectSchema>;
Expand Down