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

Feature/detail fixes #43

Merged
merged 8 commits into from
Oct 31, 2024
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
2 changes: 1 addition & 1 deletion fe/src/app/event-maps/[id]/load-mappin/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function Form({ uuid }: FormProps) {

try {
const response = await fetch(
"http://110.165.17.236:8081/api/v1/nonmembers/pings",
`${process.env.NEXT_PUBLIC_API_BASE_URL}/nonmembers/pings`,
{
method: "POST",
headers: {
Expand Down
29 changes: 13 additions & 16 deletions fe/src/app/eventcreate-page/components/EventNameInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function EventNameInput({
className,
selectedLocation,
onChange,
value,
}: EventNameInputProps) {
const [eventName, setEventName] = useState("");
const [isFocused, setIsFocused] = useState(false);
const [hasUserEdited, setHasUserEdited] = useState(false);
const [isLoading, setIsLoading] = useState(true);
Expand All @@ -27,41 +27,38 @@ function EventNameInput({
const newEventName = selectedLocation
? `${currentDate} ${selectedLocation} 모임`
: `${currentDate} 모임`;
setEventName(newEventName);
onChange(newEventName);
}
setIsLoading(false); // 로딩 완료 상태로 변경
setIsLoading(false);
}, [selectedLocation, currentDate, onChange, hasUserEdited]);

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const newValue = e.target.value;
setEventName(newValue);
setHasUserEdited(true);
onChange(newValue);
};

const handleClear = () => {
setEventName("");
setHasUserEdited(true);
onChange("");
};

const borderClass = isFocused ? "border-[#2C2C2C]" : "border-transparent";
const textColorClass =
eventName === `${currentDate} 모임` ||
eventName === `${currentDate} ${selectedLocation} 모임`
value === `${currentDate} 모임` ||
value === `${currentDate} ${selectedLocation} 모임`
? "text-mediumGray"
: "text-text-default";
: "text-[#8e8e8e]";

const charCount = eventName.length;
const charCount = value.length;
const showWarning = charCount < 1 || charCount > 20;
const isDefaultValue =
eventName === `${currentDate} 모임` ||
eventName === `${currentDate} ${selectedLocation} 모임`;
value === `${currentDate} 모임` ||
value === `${currentDate} ${selectedLocation} 모임`;

return (
<div className={`relative flex flex-col ${className}`}>
<div className="text-text-default text-xl font-semibold leading-loose mb-[12px]">
<div className="text-black text-xl font-semibold leading-loose mb-[12px]">
이벤트 이름
</div>

Expand All @@ -72,14 +69,14 @@ function EventNameInput({
>
<input
type="text"
value={eventName}
value={value}
onChange={handleInputChange}
className={`bg-transparent border-none grow shrink basis-0 ${textColorClass} text-base font-medium font-['Pretendard'] leading-normal outline-none flex-1`}
onFocus={() => setIsFocused(true)}
onBlur={() => setIsFocused(false)}
/>

{eventName && !isDefaultValue && (
{value && !isDefaultValue && (
<div
role="button"
tabIndex={0}
Expand All @@ -92,8 +89,8 @@ function EventNameInput({
<Image
src="/images/Cancel.svg"
alt="삭제 아이콘"
layout="fill"
objectFit="cover"
width={24}
height={24}
/>
</div>
)}
Expand Down
38 changes: 25 additions & 13 deletions fe/src/app/eventcreate-page/components/LocationInput.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
"use client";

import React, { useState } from "react";
import { LocationInputProps, Place } from "@/app/eventcreate-page/types/types"; // 최상단으로 이동
import Image from "next/image";
import SearchResults from "./SearchResults";

interface LocationInputProps {
className?: string;
onSelect: (place: {
name: string;
address: string;
px?: number;
py?: number;
}) => void;
}

function LocationInput({ className, onSelect }: LocationInputProps) {
const [location, setLocation] = useState<string>("");
const [results, setResults] = useState<Place[]>([]);
const [results, setResults] = useState<
{ name: string; address: string; px?: number; py?: number }[]
>([]);
const [isFetching, setIsFetching] = useState(false);

const fetchPlacesBySearch = async (query: string) => {
Expand Down Expand Up @@ -45,7 +56,12 @@ function LocationInput({ className, onSelect }: LocationInputProps) {
}
};

const handleSelectPlace = (place: Place) => {
const handleSelectPlace = (place: {
name: string;
address: string;
px?: number;
py?: number;
}) => {
setLocation(place.name);
setResults([]);
onSelect(place);
Expand Down Expand Up @@ -73,7 +89,7 @@ function LocationInput({ className, onSelect }: LocationInputProps) {

const data = await response.json();
if (data.data && data.data.length > 0) {
const selectedPlace: Place = { ...data.data[0], px, py };
const selectedPlace = { ...data.data[0], px, py };
setResults(data.data);
setLocation(selectedPlace.name);
handleSelectPlace(selectedPlace);
Expand All @@ -93,15 +109,9 @@ function LocationInput({ className, onSelect }: LocationInputProps) {
);
};

const handleKeyDown = (e: React.KeyboardEvent) => {
if (e.key === "Enter" || e.key === " ") {
handleCurrentLocation();
}
};

return (
<div className={`relative flex flex-col ${className}`}>
<div className="text-text-default text-xl font-semibold leading-loose mb-[12px]">
<div className="text-black text-xl font-semibold leading-loose mb-[12px]">
어떤 공간을 찾고 계신가요?
</div>
<div className="relative w-[328px] h-14 p-4 bg-background-light rounded-lg flex justify-between items-center">
Expand All @@ -117,15 +127,17 @@ function LocationInput({ className, onSelect }: LocationInputProps) {
value={location}
onChange={handleSearch}
placeholder="장소를 입력해주세요"
className="bg-transparent border-none grow text-base placeholder-mediumGray outline-none"
className="bg-transparent border-none grow text-base text-[#8e8e8e] placeholder-[#8e8e8e] outline-none font-['Pretendard']"
/>
</div>
<div
role="button"
tabIndex={0}
className="w-[38px] h-[38px] bg-darkGray rounded flex items-center justify-center cursor-pointer"
onClick={handleCurrentLocation}
onKeyDown={handleKeyDown}
onKeyDown={(e) => {
if (e.key === "Enter") handleCurrentLocation();
}}
>
<Image
src="/images/Location.svg"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function SearchResultItem({
height={24}
className="text-gray-600"
/>
<div className="text-base font-pretendard">
<div className="text-base font-medium font-['Pretendard'] leading-normal">
{highlightText(place.name, searchTerm)}
</div>
</button>
Expand Down
5 changes: 3 additions & 2 deletions fe/src/app/eventcreate-page/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ function EventCreatePage() {
const [uuid, setUuid] = useState<string | null>(null);
const router = useRouter();

// Adjust coordinates by dividing by 10^7 to match standard map coordinates
const adjustedPx = px ? px / 1e7 : null;
const adjustedPy = py ? py / 1e7 : null;

useEffect(() => {
setIsFormComplete(
selectedLocation.trim() !== "" &&
eventName.trim() !== "" &&
eventName.length >= 1 &&
eventName.length <= 20 &&
adjustedPx !== null &&
adjustedPy !== null
);
Expand Down Expand Up @@ -109,7 +110,7 @@ function EventCreatePage() {
label={isSubmitting ? "처리 중..." : "다음"}
type="start"
onClick={createEvent}
className="w-[328px] h-[60px] py-[17px] rounded-lg"
className="w-[328px] h-[60px] py-[17px] rounded-lg text-base font-medium font-['Pretendard']"
disabled={!isFormComplete || isSubmitting}
/>
</div>
Expand Down
Loading