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

Feat/courtCreate/addNewCourtInfo #24

Merged
merged 10 commits into from
Dec 8, 2021
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: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
"@emotion/styled": "^11.6.0",
"axios": "^0.24.0",
"feather-icons": "^4.28.0",
"framer-motion": "^5.3.3",
"next": "12.0.4",
"react": "17.0.2",
"react-dom": "^17.0.2",
"react-modal-sheet": "^1.4.1",
"uuid": "^8.3.2"
},
"devDependencies": {
Expand Down
24 changes: 21 additions & 3 deletions src/components/KakaoMap/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useRef } from "react";
import React, { useEffect, useRef, CSSProperties } from "react";
import type { ReactNode } from "react";
import { DEFAULT_POSITION } from "@utils/geolocation";
import { useMapContext } from "@contexts/MapProvider";
Expand All @@ -14,17 +14,23 @@ declare global {
interface Props {
level: number;
center: Coord;
draggable?: boolean;
zoomable?: boolean;
onClick: (_: kakao.maps.Map, event: kakao.maps.event.MouseEvent) => void;
onDragEnd: (_: kakao.maps.Map) => void;
onDragEnd?: (_: kakao.maps.Map) => void;
children: ReactNode;
style?: CSSProperties;
}

const KakaoMap = ({
level,
center,
draggable = true,
zoomable = true,
onClick,
onDragEnd,
children,
style,
}: Props): JSX.Element => {
const { map, handleInitMap } = useMapContext();
const mapRef = useRef<HTMLDivElement>(null);
Expand All @@ -41,6 +47,18 @@ const KakaoMap = ({
}
}, [map, level]);

useEffect(() => {
if (map) {
map.setDraggable(draggable);
}
}, [map, draggable]);

useEffect(() => {
if (map) {
map.setZoomable(zoomable);
}
}, [map, zoomable]);

Comment on lines +50 to +61
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ˜΅μ…”λ„ 체이닝을 μ•Œμ•„λ³΄λ©΄ 쒋을 κ±° κ°™μ•„μš”

useEffect(() => {
if (!mapRef.current) {
return;
Expand All @@ -62,7 +80,7 @@ const KakaoMap = ({

return (
<>
<div ref={mapRef} style={{ width: "100%", height: "100%" }}>
<div ref={mapRef} style={{ width: "100%", height: "100%", ...style }}>
ν˜„μž¬ μœ„μΉ˜λ₯Ό λ°›μ•„μ˜€λŠ” μ€‘μž…λ‹ˆλ‹€.
{children}
</div>
Expand Down
21 changes: 21 additions & 0 deletions src/components/base/Input/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { HTMLAttributes } from "react";
import Text from "../Text";

interface Props extends HTMLAttributes<HTMLInputElement> {
label: string;
type: string;
name: string;
block?: boolean;
[x: string]: any;
}

const Input = ({ label, block, ...props }: Props) => (
<div>
<label>
<Text block={block}>{label}</Text>
<input {...props}></input>
</label>
</div>
);

export default Input;
1 change: 1 addition & 0 deletions src/contexts/NavigationProvider/actionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export const pageType = {
MAP: "MAP",
BOOK: "BOOK",
ACTIVITY: "ACTIVITY",
COURT_CREATE: "COURT_CREATE",
} as const;
14 changes: 14 additions & 0 deletions src/contexts/NavigationProvider/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@ export const reducer: Reducer<DataProps, ReducerAction> = (
title: "둜그인",
};
}
case pageType.COURT_CREATE: {
return {
...state,
isTopNavigation: true,
isBottomNavigation: true,
currentPage: type,
isBack: true,
isNotifications: true,
isProfile: true,
isNext: false,
isMenu: false,
title: "μƒˆ 농ꡬμž₯ μΆ”κ°€",
};
}
default: {
return { ...state };
}
Expand Down
9 changes: 5 additions & 4 deletions src/hooks/useForm.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { ChangeEvent, FormEvent, useState } from "react";

export type Error<T> = { [P in keyof T]?: string };

interface UseFormArgs<T> {
initialValues: T;
onSubmit: (values: T) => void;
validate: (values: T) => T;
validate: (values: T) => Error<T>;
}

const useForm = <T>({ initialValues, onSubmit, validate }: UseFormArgs<T>) => {
const [values, setValues] = useState<T>(initialValues);
const [errors, setErrors] = useState<T>(initialValues);
const [errors, setErrors] = useState<Error<T>>({});
const [isLoading, setIsLoading] = useState(false);

const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
Expand All @@ -19,8 +21,7 @@ const useForm = <T>({ initialValues, onSubmit, validate }: UseFormArgs<T>) => {
const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
setIsLoading(true);
e.preventDefault();
console.log("hi");
const newErrors = validate ? validate(values) : initialValues;
const newErrors = validate ? validate(values) : {};
if (Object.keys(newErrors).length === 0) {
await onSubmit(values);
}
Expand Down
Loading