diff --git a/frontend/public/css/toggle-button.css b/frontend/public/css/toggle-button.css
index 285cc4f..1b2a976 100644
--- a/frontend/public/css/toggle-button.css
+++ b/frontend/public/css/toggle-button.css
@@ -1,38 +1,59 @@
-.toggle-switch {
+.switch {
position: relative;
- width: 53px; /* 스위치의 전체 너비 */
- height: 25px; /* 스위치의 전체 높이 */
display: inline-block;
- background-color: #646464; /* 스위치의 배경색 */
- border-radius: 15px; /* 둥근 모서리 */
+ width: 52px;
+ height: 18px;
}
-.toggle-switch-checkbox {
- display: none;
+.switch input {
+ opacity: 0;
+ width: 0;
+ height: 0;
}
-.toggle-switch-label {
- display: block;
- overflow: hidden;
+.slider {
+ position: absolute;
cursor: pointer;
- height: 100%; /* 라벨의 높이를 스위치 높이와 동일하게 설정 */
- position: relative; /* 스위치 내부 요소를 정확히 배치하기 위함 */
+ top: 0;
+ left: 6px;
+ right: 0;
+ bottom: 0;
+ background-color: #ccc;
+ -webkit-transition: 0.4s;
+ transition: 0.4s;
}
-.toggle-switch-switch {
- display: block;
- width: 20px; /* 스위치 버튼의 너비 */
- height: 20px; /* 스위치 버튼의 높이 */
- background: #ffffff; /* 스위치 버튼의 배경색 */
+.slider:before {
position: absolute;
- top: 2.5px; /* 위에서부터의 거리 */
- bottom: 4px; /* 아래에서부터의 거리 */
- right: 29px; /* 오른쪽에서부터의 거리 */
- border: 2px solid #999999; /* 테두리 */
- border-radius: 20px; /* 둥근 스위치 버튼 */
- transition: all 0.3s ease-in-out; /* 부드러운 애니메이션 효과 */
+ content: '';
+ height: 13px;
+ width: 13px;
+ left: 3px;
+ bottom: 2.5px;
+ background-color: white;
+ -webkit-transition: 0.4s;
+ transition: 0.4s;
+}
+
+input:checked + .slider {
+ background-color: #535f96;
+}
+
+input:focus + .slider {
+ box-shadow: 0 0 1px #6666a5;
+}
+
+input:checked + .slider:before {
+ -webkit-transform: translateX(26px);
+ -ms-transform: translateX(26px);
+ transform: translateX(26px);
+}
+
+/* Rounded sliders */
+.slider.round {
+ border-radius: 34px;
}
-.toggle-switch-checkbox:checked + .toggle-switch-label .toggle-switch-switch {
- right: 4px; /* 체크될 때 스위치 버튼의 위치 */
+.slider.round:before {
+ border-radius: 50%;
}
diff --git a/frontend/src/app/recruitment/page.tsx b/frontend/src/app/recruitment/page.tsx
index c2d7c38..3511c8a 100644
--- a/frontend/src/app/recruitment/page.tsx
+++ b/frontend/src/app/recruitment/page.tsx
@@ -66,12 +66,12 @@ export default function Recruitment() {
)
if (!res.ok) {
- throw new Error('채용공고 검색에 실패했습니다.')
+ const data = await res.json()
+ throw new Error(data.message)
}
const data = await res.json()
setPostCount(data.data.length)
- console.log(data.data)
return data.data
}
@@ -105,7 +105,7 @@ export default function Recruitment() {
}
return (
-
+
{data.pages.map((group, i) => (
diff --git a/frontend/src/components/recruitment/Filter.tsx b/frontend/src/components/recruitment/Filter.tsx
index 5823de3..ad427b3 100644
--- a/frontend/src/components/recruitment/Filter.tsx
+++ b/frontend/src/components/recruitment/Filter.tsx
@@ -11,7 +11,10 @@ export default function Filter({ postCount }: FilterPropsType) {
게시글 {postCount}개
최신 순
-
+
+ 모집 중인 프로젝트만 보기
+
+
)
}
diff --git a/frontend/src/components/recruitment/MultipleFilter.tsx b/frontend/src/components/recruitment/MultipleFilter.tsx
index 3a5b98e..5f4498d 100644
--- a/frontend/src/components/recruitment/MultipleFilter.tsx
+++ b/frontend/src/components/recruitment/MultipleFilter.tsx
@@ -153,21 +153,23 @@ export default function MultipleFilter() {
- {filter.map((item) => (
-
- {item.name}
-
+ ))}
)
diff --git a/frontend/src/components/recruitment/ToggleButton.tsx b/frontend/src/components/recruitment/ToggleButton.tsx
index 29a73ab..f7ff335 100644
--- a/frontend/src/components/recruitment/ToggleButton.tsx
+++ b/frontend/src/components/recruitment/ToggleButton.tsx
@@ -1,33 +1,37 @@
import { filterState } from '@/utils/atoms'
-import '../../../public/css/toggle-button.css' // 스타일시트 임포트
+import { useEffect, useState } from 'react'
import { useRecoilState } from 'recoil'
-import { useState } from 'react'
+import '../../../public/css/toggle-button.css'
export default function ToggleButton() {
- const [isToggled, setIsToggled] = useState(false)
const [filter, setFilter] = useRecoilState(filterState)
- const handleClick = () => {
- setIsToggled(!isToggled)
- setFilter({
- ...filter,
- isRecruiting: String(!isToggled),
- })
+ const [isChecked, setIsChecked] = useState(
+ filter.find((f) => f.category === 'isRecruiting')?.name === 'true',
+ )
+
+ const handleToggle = () => {
+ const newIsRecruitingValue = String(!isChecked)
+
+ const updatedFilter = filter.map((f) =>
+ f.category === 'isRecruiting' ? { ...f, name: newIsRecruitingValue } : f,
+ )
+
+ setFilter(updatedFilter)
+ setIsChecked(!isChecked)
}
+ useEffect(() => {
+ const recruitingFilter = filter.find((f) => f.category === 'isRecruiting')
+ if (recruitingFilter) {
+ setIsChecked(recruitingFilter.name === 'true')
+ }
+ }, [filter])
+
return (
-
-
-
-
+
)
}
diff --git a/frontend/src/utils/atoms.ts b/frontend/src/utils/atoms.ts
index fb89ea0..60c2228 100644
--- a/frontend/src/utils/atoms.ts
+++ b/frontend/src/utils/atoms.ts
@@ -102,7 +102,12 @@ const usernameState = atom({
const filterState = atom({
key: 'FilterState',
- default: [],
+ default: [
+ {
+ category: 'isRecruiting',
+ name: 'false',
+ },
+ ],
})
export {