Skip to content

Commit

Permalink
fix: 기존 장소 데이터 형식 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hatchling13 committed Mar 28, 2024
1 parent 7c81a93 commit 48acad3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions frontend/src/app/_components/add/course/AddCourseSpotData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export default function AddCourseSpotData({
}) {
const [isOpen, setIsOpen] = useState(false);

const { place, images, review } = spot;
const { place, images, review, createDate } = spot;

const imageUris =
images.type === 'new'
? images.data.map((image) => image.uri)
: images.data.map((image) => image);
const currentDate = new Date(Date.now());
const currentDate = createDate ? createDate : new Date(Date.now());

const currentIndex = index !== undefined ? index : -1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ export default function ExistPlaceItem({
count={rate}
rating
/>
<div className="text-gray-300 font-bold">{created_date}</div>
<div className="text-gray-300 font-bold">
{new Date(created_date).toLocaleDateString('ko-KR')}
</div>
</div>
</div>
</article>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/context/travel/course/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function convertExistingSpot(existing: TExistingSpot): TSpotState {

return {
id: spot_id,
createDate: create_date,
place: {
name: place_name,
address: place_address,
Expand Down
1 change: 1 addition & 0 deletions frontend/src/context/travel/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const manyInputImageSchema = z.discriminatedUnion('type', [

export const spotStateSchema = z.object({
id: z.number().int().optional(),
createDate: z.date().optional(),
place: choosePlaceSchema,
images: manyInputImageSchema,
review: reviewSchema,
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/types/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,7 @@ export const existingSpotSchema = z.object({
rate: z.number(),
description: z.string(),
image_urls: z.array(z.string()),
create_date: z.coerce
.date()
.transform((date) => date.toLocaleDateString('ko-kr')),
create_date: z.coerce.date(),
point: z.object({
x: z.number(),
y: z.number(),
Expand Down

0 comments on commit 48acad3

Please sign in to comment.