//구단별&전체조회
//조건물 걸어주면 굿이죠잉😉😉
//조건문으로 teamname이 전체이면 전체를 보여주고 아니면 구단별로 보여준답니다
const getTeamAPI = (teamname) => {
return function (dispatch, getState, { history }) {
if (!teamname || teamname === "전체") {
instance
.get("/groups")
.then((res) => {
dispatch(getTeam(res.data));
console.log(res);
})
.catch((err) => {
console(err, "전체 모임 불러오기");
});
return;
}
instance
.get(`/groups?team=${teamname}`)
.then((res) => {
console.log(res.data, "구단 선택");
dispatch(getTeam(res.data));
})
.catch((err) => {
console.log("팀별조회에러", err);
});
// }
};
};
const [team, setTeam] = useState("");를 주어 team에 값을 넣어 줍니다
이놈들은 랜더링을 위해 필수죠잉😏😏
const team_list = useSelector((state) => state.group.team_list); useEffect(() => { dispatch(groupCr.getTeamAPI(team)); }, [team]);
전체를 보여줄것들 setTeam("전체")
<div style={{ marginRight: "10px" }}> <Image onClick={() => { setTeam("전체"); }} style={{ width: "68px", height: "68px" }} roundedCircle src="https://blog.kakaocdn.net/dn/bvJWww/btqF1bBafWG/VwoCNfWLEUCmC2iPTrivj0/img.jpg" </Image> <Text size="11px" center> 전체 </Text> </div>
이것은 name으로 데이터를 불러오기 때문에 e.name이 useState에 넣어지면 좋겠죠🤗🤗
그래서 setTeam(e.name)하면 team값에 e.name가 들어가겠쥬
{clubImageSrc.map((e) => ( <SwiperSlide key={e.id} style={{ width: "68px", marginRight: "15px" }} onClick={() => { setTeam(e.name); console.log(e.name); }}
이것은 제가 어려움이 처했을 때 볼려고 마련해둔 비법입니다.🙄🙄🙄
개인적으로 적은 것이라서 이해가 안될 수 있습니다.