Skip to content

Commit

Permalink
updated details info fro adverts
Browse files Browse the repository at this point in the history
  • Loading branch information
Yariki committed Mar 17, 2024
1 parent df25f02 commit ef9cabb
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 21 deletions.
32 changes: 28 additions & 4 deletions dimria-fe/src/Components/AdvertDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Dialog, ExpandableText,
FlexBox,
FlexBoxAlignItems,
Label,
Label, Link, MediaGallery, MediaGalleryItem,
Title,
TitleLevel,
} from "@ui5/webcomponents-react";
Expand Down Expand Up @@ -35,13 +35,13 @@ const AdvertDetailsModal = forwardRef<typeof Dialog, AdvertDetailsModalProps>((p
}

dispatch(fetchAdvertDetailsStart(advertId));
},[advertId]);
},[advertId, dispatch]);

return (
<Dialog
ref={ref}
footer={<FlexBox alignItems={FlexBoxAlignItems.Center}><Button onClick={onClose}>Close</Button></FlexBox>}
header={<FlexBox alignItems={FlexBoxAlignItems.Center}><Title level={TitleLevel.H4}>{advertDetailsDto?.advert_id}</Title></FlexBox>}
header={<FlexBox alignItems={FlexBoxAlignItems.Center}><Link href={advertDetailsDto?.url} target="_blank">{advertDetailsDto?.advert_id}</Link></FlexBox>}
>

{ isDetailsLoading && <BusyIndicator active delay={0} /> }
Expand All @@ -55,10 +55,34 @@ const AdvertDetailsModal = forwardRef<typeof Dialog, AdvertDetailsModalProps>((p
<Label>Rooms Count:</Label><Title level={TitleLevel.H6}> {advertDetailsDto?.rooms_count}</Title>
</FlexBox>
<FlexBox alignItems={FlexBoxAlignItems.Center}>
<ExpandableText maxCharacters={50}>
<Label>Floor:</Label><Title level={TitleLevel.H6}> {advertDetailsDto?.floor}</Title>
</FlexBox>
<FlexBox alignItems={FlexBoxAlignItems.Center}>
<Label>Building name:</Label><Title level={TitleLevel.H6}> {advertDetailsDto?.building_name}</Title>
</FlexBox>
<FlexBox alignItems={FlexBoxAlignItems.Center}>
<ExpandableText maxCharacters={50} >
{advertDetailsDto?.description}
</ExpandableText>
</FlexBox>

<FlexBox alignItems={FlexBoxAlignItems.Center}>
<MediaGallery layout="Auto">
{
advertDetailsDto?.photos.map((photo, index) => {
return (
photo.map((item) => (
<MediaGalleryItem key={index}>
<img src={item} alt="photo" />
</MediaGalleryItem>
))
);
})
}
</MediaGallery>
</FlexBox>


</>
)}
</Dialog>
Expand Down
2 changes: 1 addition & 1 deletion dimria-fe/src/Components/AdvertsPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from "@ui5/webcomponents-react";
import {AdvertList} from "../AdvertList";
import {AdvertDto} from "../../models/AdvertDto";
import React, {useEffect, useState, useRef} from "react";
import {useState, useRef} from "react";
import {AdvertPrices} from "../AdvertPrices";
import AdvertDetailsModal from "../AdvertDetails";
import { createUseStyles } from 'react-jss';
Expand Down
6 changes: 6 additions & 0 deletions dimria-fe/src/models/AdvertDetailsDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ export interface AdvertDetailsDto{
currency: string;
floor: string;
rooms_count: number;
main_photo: string;
lat?: number;
lon?: number;
building_name: string;
url: string;
photos: string[][];
}
2 changes: 1 addition & 1 deletion dimria/handle_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def build_ptoho_url(file):
file = split[0] + "xl." + split[1]
return f'https://cdn.riastatic.com/photos/{file}'

def parse_photos(photos):
def parse_photos(photos) -> []:
result = []
for photoId in photos:
photo = photos[photoId]
Expand Down
4 changes: 3 additions & 1 deletion dimria/models/AdvertDetailsResponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

class AdvertDetailsResponse:

def __init__(self, advert_id, city_name, description, price, currency,floor, rooms_count, main_photo, lat, lon, building_name, url, photos = []) -> None:
photos = []

def __init__(self, advert_id, city_name, description, price, currency,floor, rooms_count, main_photo, lat, lon, building_name, url, photos) -> None:
self.advert_id = advert_id
self.city_name = city_name
self.description = description
Expand Down
28 changes: 14 additions & 14 deletions function_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get_advert_details(req: func.HttpRequest) -> func.HttpResponse:
if(resultRequest is None):
return func.HttpResponse("No advert details found", status_code=404)

print(type(resultRequest))
print(resultRequest)

cityName = resultRequest['city_name']
state_id = resultRequest['state_id']
Expand All @@ -126,19 +126,19 @@ def get_advert_details(req: func.HttpRequest) -> func.HttpResponse:
url = build_main_advert_url(resultRequest['beautiful_url'])

resultResponse: AdvertDetailsResponse = AdvertDetailsResponse(
advert_id=advert_id,
city_name=cityName,
price=price,
rooms_count=rooms_count,
currency=currency_type_uk,
description=description,
floor=floor,
main_photo=main_photo,
lat = lat,
lon = lon,
building_name = building_name,
url = url,
photos=photos
advert_id,
cityName,
price,
rooms_count,
currency_type_uk,
description,
floor,
main_photo,
lat,
lon,
building_name,
url,
photos
)

data = json.dumps(resultResponse, cls=AdvertDetailsResponseEncoder)
Expand Down

0 comments on commit ef9cabb

Please sign in to comment.