|
1 | 1 | <script context="module" lang="ts"> |
2 | 2 | export type PoliticianProposer = { |
3 | 3 | id: string; |
4 | | - firstname: string; |
5 | | - lastname: string; |
6 | | - avatar: string; |
| 4 | + name: string; |
| 5 | + image: string | null; |
7 | 6 | assembly?: { |
8 | 7 | id: string; |
9 | | - abbreviation: string; |
10 | | - term: number; |
11 | | - startedAt: Date; |
| 8 | + abbreviation: string | null; |
| 9 | + term: number | null; |
| 10 | + startedAt: Date | string | null; |
12 | 11 | }; |
13 | 12 | partyName?: string; |
14 | 13 | }; |
15 | 14 |
|
16 | 15 | export type AssemblyProposer = { |
17 | 16 | id: string; |
18 | | - isCabinet: boolean; |
19 | 17 | abbreviation: string; |
20 | 18 | term: number; |
21 | | - startedAt: Date; |
| 19 | + startedAt: Date | string | null; |
22 | 20 | }; |
23 | 21 |
|
24 | 22 | export type PeopleProposer = { |
|
44 | 42 |
|
45 | 43 | $: isLandscape = orientation === 'landscape'; |
46 | 44 |
|
47 | | - function getBudistYear(date: Date) { |
| 45 | + function getBudistYear(date: string | Date) { |
48 | 46 | return dayjs(date).format('BBBB'); |
49 | 47 | } |
50 | 48 | </script> |
51 | 49 |
|
52 | | -<div class="flex {isLandscape ? 'flex-col gap-x-2 md:flex-row' : 'flex-col'}"> |
| 50 | +<div class="flex items-center {isLandscape ? 'flex-col gap-x-2 md:flex-row' : 'flex-col'}"> |
53 | 51 | {#if proposer === undefined} |
54 | 52 | <p class="text-sm text-gray-60">ไม่พบข้อมูล</p> |
55 | | - {:else if 'firstname' in proposer} |
56 | | - {@const { id, firstname, lastname, avatar, assembly, partyName } = proposer} |
| 53 | + {:else if 'image' in proposer} |
| 54 | + {@const { id, name, image, assembly, partyName } = proposer} |
57 | 55 | <figure class="h-6 w-6 shrink-0 overflow-hidden rounded-full bg-gray-20"> |
58 | | - <img src={avatar} alt="{firstname} {lastname}" class="h-full w-full" loading="lazy" /> |
| 56 | + <img |
| 57 | + src={image || '/images/politicians/_placeholder.webp'} |
| 58 | + alt="" |
| 59 | + class="h-full w-full" |
| 60 | + loading="lazy" |
| 61 | + /> |
59 | 62 | </figure> |
60 | | - <div> |
61 | | - <p class="text-sm"> |
62 | | - <a href="/politicians/{id}" class="text-black"> |
63 | | - {firstname} |
64 | | - {lastname} |
| 63 | + <p class="text-sm"> |
| 64 | + <a href="/politicians/{id}" class="text-black"> |
| 65 | + {name} |
| 66 | + </a> |
| 67 | + {#if assembly} |
| 68 | + <a href="/assemblies/{assembly.id}" class="text-sm text-black underline"> |
| 69 | + {assembly.abbreviation} ชุดที่ {assembly.term} |
| 70 | + {#if assembly.startedAt} |
| 71 | + ({getBudistYear(assembly.startedAt)}) |
| 72 | + {/if} |
65 | 73 | </a> |
66 | | - {#if assembly} |
67 | | - <a href="/assemblies/{assembly.id}" class="text-sm text-black underline"> |
68 | | - {assembly.abbreviation} ชุดที่ {assembly.term} ({getBudistYear(assembly.startedAt)}) |
69 | | - </a> |
70 | | - {/if} |
71 | | - </p> |
72 | | - {#if partyName} |
73 | | - <span class="text-sm text-gray-60">พรรค{partyName}</span> |
74 | 74 | {/if} |
75 | | - </div> |
| 75 | + </p> |
| 76 | + {#if partyName} |
| 77 | + <span class="text-sm text-gray-60">พรรค{partyName}</span> |
| 78 | + {/if} |
76 | 79 | {:else if 'term' in proposer} |
77 | | - {@const { id, abbreviation, term, isCabinet, startedAt } = proposer} |
| 80 | + {@const { id, abbreviation, term, startedAt } = proposer} |
78 | 81 | <div class="flex h-6 w-6 items-center justify-center rounded-full bg-black"> |
79 | 82 | <svelte:component |
80 | | - this={isCabinet ? GeneralIcon : PoliticianIcon} |
| 83 | + this={abbreviation === 'ครม.' ? GeneralIcon : PoliticianIcon} |
81 | 84 | class="stroke-white" |
82 | 85 | size={16} |
83 | 86 | /> |
84 | 87 | </div> |
85 | 88 | <a href="/assemblies/{id}" class="text-sm text-black"> |
86 | 89 | {abbreviation} |
87 | | - <span class="underline">ชุดที่ {term} ({getBudistYear(startedAt)})</span> |
| 90 | + <span class="underline" |
| 91 | + >ชุดที่ {term} |
| 92 | + {#if startedAt} |
| 93 | + ({getBudistYear(startedAt)}) |
| 94 | + {/if} |
| 95 | + </span> |
88 | 96 | </a> |
89 | 97 | {:else} |
90 | 98 | {@const { ledBy, signatoryCount } = proposer} |
|
0 commit comments