fix returned pgx data type
This commit is contained in:
parent
42777b4e35
commit
7e152c1532
@ -1,5 +1,3 @@
|
|||||||
import { NullValueRes } from '../types/common';
|
|
||||||
|
|
||||||
export type LocationInfo = {
|
export type LocationInfo = {
|
||||||
id: Number,
|
id: Number,
|
||||||
name: string,
|
name: string,
|
||||||
|
@ -227,7 +227,7 @@ function AddLocation() {
|
|||||||
<a href={'#'} title={x.name}>
|
<a href={'#'} title={x.name}>
|
||||||
<img
|
<img
|
||||||
loading={'lazy'}
|
loading={'lazy'}
|
||||||
src={x.thumbnail.String.toString()}
|
src={x.thumbnail ? x.thumbnail : ""}
|
||||||
alt={x.name}
|
alt={x.name}
|
||||||
style={{ aspectRatio: '1/1' }}
|
style={{ aspectRatio: '1/1' }}
|
||||||
/>
|
/>
|
||||||
|
@ -9,7 +9,7 @@ interface TopLocation {
|
|||||||
row_number: Number,
|
row_number: Number,
|
||||||
id: Number,
|
id: Number,
|
||||||
name: String,
|
name: String,
|
||||||
thumbnail: NullValueRes<"String", String>,
|
thumbnail: string | null,
|
||||||
address: String,
|
address: String,
|
||||||
google_maps_link: string,
|
google_maps_link: string,
|
||||||
regency_name: string,
|
regency_name: string,
|
||||||
@ -145,7 +145,7 @@ function BestLocation() {
|
|||||||
</div>
|
</div>
|
||||||
<div style={{ maxWidth: 200, maxHeight: 200, margin: '0 30px 30px 10px', float: 'left' }}>
|
<div style={{ maxWidth: 200, maxHeight: 200, margin: '0 30px 30px 10px', float: 'left' }}>
|
||||||
<a href={`/location/${x.id}`} >
|
<a href={`/location/${x.id}`} >
|
||||||
<img src={x.thumbnail.String.toString()} loading={'lazy'} style={{ width: '100%', objectFit: 'cover', height: '100%', aspectRatio: '1/1' }} />
|
<img src={x.thumbnail ? x.thumbnail : ""} loading={'lazy'} style={{ width: '100%', objectFit: 'cover', height: '100%', aspectRatio: '1/1' }} />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div className={'text-md font-bold'}>{x.regency_name}</div>
|
<div className={'text-md font-bold'}>{x.regency_name}</div>
|
||||||
|
@ -53,16 +53,8 @@ function Home() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onNavigateToDetail(
|
function onNavigateToDetail(id: Number,) {
|
||||||
id: Number,
|
navigate(`/location/${id}`)
|
||||||
critic_count: Number,
|
|
||||||
critic_score: Number,
|
|
||||||
user_count: Number,
|
|
||||||
user_score: Number,
|
|
||||||
) {
|
|
||||||
|
|
||||||
navigate(`/location/${id}`, { state: { user_score: user_score, user_count: user_count, critic_score: critic_score, critic_count: critic_count } })
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -79,7 +71,7 @@ function Home() {
|
|||||||
<SeparatorWithAnchor pageLink='#' pageName='recently added' secondLink='#' />
|
<SeparatorWithAnchor pageLink='#' pageName='recently added' secondLink='#' />
|
||||||
{recentLocations.map((x) => (
|
{recentLocations.map((x) => (
|
||||||
<div className={"recently-added-section-card"}>
|
<div className={"recently-added-section-card"}>
|
||||||
<a onClick={() => onNavigateToDetail(x.id, x.critic_count, x.critic_score, x.user_count, x.user_score)}>
|
<a onClick={() => onNavigateToDetail(x.id)}>
|
||||||
<div className={'border-secondary recently-img-container'}>
|
<div className={'border-secondary recently-img-container'}>
|
||||||
<img alt={x.name} src={x.thumbnail ? x.thumbnail : ''} loading="lazy" style={{ width: '100%', height: '100%' }} />
|
<img alt={x.name} src={x.thumbnail ? x.thumbnail : ''} loading="lazy" style={{ width: '100%', height: '100%' }} />
|
||||||
</div>
|
</div>
|
||||||
|
@ -61,7 +61,9 @@ function LocationDetail() {
|
|||||||
try {
|
try {
|
||||||
const res = await getLocationService(Number(id))
|
const res = await getLocationService(Number(id))
|
||||||
setLocationDetail(res.data, (val) => {
|
setLocationDetail(res.data, (val) => {
|
||||||
getImage(val.detail.thumbnail.String.toString())
|
if(val.detail.thumbnail) {
|
||||||
|
getImage(val.detail.thumbnail)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let err = error as AxiosError;
|
let err = error as AxiosError;
|
||||||
@ -223,7 +225,7 @@ function LocationDetail() {
|
|||||||
style={{ display: 'grid', position: 'relative', gridTemplateColumns: 'repeat(12,1fr)', cursor: 'zoom-in' }}
|
style={{ display: 'grid', position: 'relative', gridTemplateColumns: 'repeat(12,1fr)', cursor: 'zoom-in' }}
|
||||||
>{Number(locationImages?.total_image) > 0 &&
|
>{Number(locationImages?.total_image) > 0 &&
|
||||||
<div class="image-stack__item image-stack__item--top">
|
<div class="image-stack__item image-stack__item--top">
|
||||||
<img src={locationDetail.detail.thumbnail.String.toString()} alt="" style={{ aspectRatio: '1/1' }} />
|
<img src={locationDetail.detail.thumbnail ? locationDetail.detail.thumbnail : ""} alt="" style={{ aspectRatio: '1/1' }} />
|
||||||
{locationImages?.images.length > 1 &&
|
{locationImages?.images.length > 1 &&
|
||||||
<div className={'text-xs p-2 bg-primary'} style={{ position: 'absolute', bottom: 0, right: 0 }}>
|
<div className={'text-xs p-2 bg-primary'} style={{ position: 'absolute', bottom: 0, right: 0 }}>
|
||||||
Total images ({locationImages?.images.length})
|
Total images ({locationImages?.images.length})
|
||||||
@ -237,7 +239,7 @@ function LocationDetail() {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
<div class="image-stack__item image-stack__item--bottom" style={Number(locationImages?.total_image) > 1 ? {} : { gridColumn: '13/1' }}>
|
<div class="image-stack__item image-stack__item--bottom" style={Number(locationImages?.total_image) > 1 ? {} : { gridColumn: '13/1' }}>
|
||||||
<img src={Number(locationImages?.total_image) > 1 ? locationImages?.images[1].src.toString() : locationDetail.detail.thumbnail.String.toString()} alt="" style={{ aspectRatio: '1/1' }} />
|
<img src={Number(locationImages?.total_image) > 1 ? locationImages?.images[1].src.toString() : locationDetail.detail.thumbnail!} alt="" style={{ aspectRatio: '1/1' }} />
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@ -433,7 +435,7 @@ function LocationDetail() {
|
|||||||
<img
|
<img
|
||||||
loading={'lazy'}
|
loading={'lazy'}
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
src={x.user_avatar.Valid ? x.user_avatar.String.toString() : 'https://cdn.discordapp.com/attachments/743422487882104837/1153985664849805392/421-4212617_person-placeholder-image-transparent-hd-png-download.png'}
|
src={x.user_avatar ? x.user_avatar : 'https://cdn.discordapp.com/attachments/743422487882104837/1153985664849805392/421-4212617_person-placeholder-image-transparent-hd-png-download.png'}
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@ -486,7 +488,7 @@ function LocationDetail() {
|
|||||||
<img
|
<img
|
||||||
loading={'lazy'}
|
loading={'lazy'}
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
src={x.user_avatar.Valid ? x.user_avatar.String.toString() : 'https://cdn.discordapp.com/attachments/743422487882104837/1153985664849805392/421-4212617_person-placeholder-image-transparent-hd-png-download.png'}
|
src={x.user_avatar ? x.user_avatar : 'https://cdn.discordapp.com/attachments/743422487882104837/1153985664849805392/421-4212617_person-placeholder-image-transparent-hd-png-download.png'}
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,7 +9,7 @@ export interface ILocationDetail {
|
|||||||
province_name: String,
|
province_name: String,
|
||||||
region_name: String,
|
region_name: String,
|
||||||
google_maps_link: String,
|
google_maps_link: String,
|
||||||
thumbnail: NullValueRes<"String", String>,
|
thumbnail: string | null,
|
||||||
submitted_by: Number,
|
submitted_by: Number,
|
||||||
critic_score: Number,
|
critic_score: Number,
|
||||||
critic_count: Number,
|
critic_count: Number,
|
||||||
@ -22,7 +22,7 @@ export function emptyLocationDetail(): ILocationDetail {
|
|||||||
id: 0,
|
id: 0,
|
||||||
address: '',
|
address: '',
|
||||||
google_maps_link: '',
|
google_maps_link: '',
|
||||||
thumbnail: { String: '', Valid: false },
|
thumbnail: "",
|
||||||
name: '',
|
name: '',
|
||||||
province_name: '',
|
province_name: '',
|
||||||
regency_name: '',
|
regency_name: '',
|
||||||
@ -41,7 +41,7 @@ export interface LocationReviewsResponse {
|
|||||||
comments: string,
|
comments: string,
|
||||||
user_id: number,
|
user_id: number,
|
||||||
username: string,
|
username: string,
|
||||||
user_avatar: NullValueRes<"String", string>,
|
user_avatar: string | null,
|
||||||
created_at: string,
|
created_at: string,
|
||||||
updated_at: string
|
updated_at: string
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user