|
| 1 | +import{g as E,u as I,S as u,e as T,a as g,t as h,b as B,c as F,r as C,j as e,d as n}from"./index-HSlvYZEY.js";import{B as w}from"./blueButton-CEU8-eJw.js";import{b as S,a as A,C as M,u as N}from"./useGetInfiniteData-CpjWvf4I.js";import{a as q,A as D}from"./AddTaskModal-nnvXEMH9.js";import{r as R}from"./commuApi-TAvZ0IbL.js";import{b as H,H as P}from"./skeleton-B5_-emf1.js";import{F as z}from"./friendNewsRender-Nw540kIV.js";import{u as V}from"./useDebounce-DGMoi5Um.js";import"./useBaseQuery-Dcs-aCZV.js";function K(t,x=10){const{token:a}=E(),c=I();return S({queryFn:async({pageParam:o=1})=>{var r;if(!a){u.fire({icon:"info",text:"로그인이 필요합니다",showConfirmButton:!1,timer:2e3}).then(()=>{c("/")});return}try{const{data:s}=await T.get(`${t}?page=${o}&size=${x}`);return s}catch(s){if(s.response){const d=((r=s.response.data)==null?void 0:r.error)||`API 오류: ${s.response.status}`;console.error("API 실패 메시지:",d),u.fire({icon:"error",text:d,showConfirmButton:!1,timer:2e3})}else if(s instanceof Error){const d=s.message||"Network/API Error";console.error("네트워크 오류:",d),u.fire({icon:"error",title:"네트워크 오류",text:d,showConfirmButton:!1,timer:2e3})}else console.error("예상치 못한 오류:",s),u.fire({icon:"error",title:"오류",text:"예상치 못한 오류가 발생했습니다.",showConfirmButton:!1,timer:2e3});return[]}},queryKey:[t,x],initialPageParam:1,getNextPageParam:o=>{var r;if(!(!o||o.last))return(((r=o.pageable)==null?void 0:r.pageNumber)??0)+2}})}const Q=n.div` |
| 2 | + padding: 34.5px 109px 67.5px 37px; |
| 3 | + background: ${({background:t})=>t}; |
| 4 | + box-shadow: 0px 3px 10px rgba(0, 0, 0, 0.25); |
| 5 | + border-radius: 20px; |
| 6 | + width: calc(100% - 146px); |
| 7 | + display: flex; |
| 8 | + flex-direction: column; |
| 9 | + height: 100%; |
| 10 | +`,G=n.div` |
| 11 | + background-color: white; |
| 12 | + border-radius: 20px; |
| 13 | + padding: 20px; |
| 14 | + padding-left: 30px; |
| 15 | + padding-right: 30px; |
| 16 | + box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.1); |
| 17 | + margin-bottom: 1px; |
| 18 | + margin-top: 1px; |
| 19 | + display: flex; |
| 20 | + justify-content: space-between; |
| 21 | + align-items: center; |
| 22 | +`,L=n.div` |
| 23 | + display: flex; |
| 24 | + gap: 100px; |
| 25 | + font-size: 18px; |
| 26 | + font-family: Pretendard, sans-serif; |
| 27 | + font-weight: 500; |
| 28 | + color: black; |
| 29 | +`,k=n.div` |
| 30 | + min-width: 100px; |
| 31 | + text-align: center; |
| 32 | +`,J=n.div` |
| 33 | + width: 100vw; |
| 34 | + height: 50px; |
| 35 | + margin-top: 50px; |
| 36 | + display: flex; |
| 37 | + justify-content: center; |
| 38 | + align-items: flex-end; |
| 39 | +`,O=()=>{var j;const{selectedTheme:t}=g(),a=h[t][1],{data:c,isPending:f,isFetching:o,hasNextPage:r,fetchNextPage:s}=K("/api/activity",5),{ref:d,inView:m}=A({threshold:0}),{openModal:y}=B(),b=F(),l=q({mutationFn:({requestId:p,isAccepted:i})=>R({requestId:p,isAccepted:i}),onSuccess:()=>{b.invalidateQueries({queryKey:["/api/activity/friend"]}),u.fire({icon:"success",text:"친구 요청을 수락했습니다",timer:2e3,showConfirmButton:!1})},onError:p=>{u.fire({icon:"error",text:"친구 수락에 실패했습니다.",timer:2e3,showConfirmButton:!1}),console.error(p)}});return C.useEffect(()=>{m&&r&&!o&&s()},[m,r,o,s]),f?e.jsx(H,{count:5}):e.jsxs(e.Fragment,{children:[e.jsxs(Q,{background:a,children:[(j=c==null?void 0:c.pages)==null?void 0:j.flatMap(p=>p.content.map(i=>e.jsxs(G,{children:[e.jsxs(L,{children:[e.jsx(k,{children:i.date}),e.jsx(k,{children:i.time}),e.jsx(k,{children:i.content})]}),i.type==="과제 추가"||i.type==="과제 공유"?i.isRegistered?e.jsx(w,{status:"등록됨",children:"등록됨"}):e.jsx(w,{onClick:()=>y(e.jsx(D,{assId:i.assId,onTaskAdded:()=>console.log("과제가 추가되었습니다.")})),children:"내 일정에 등록"}):i.type==="친구 요청"?i.check==="CHECK"?e.jsx(w,{status:"등록됨",children:"수락됨"}):e.jsx(w,{onClick:()=>l.mutate({requestId:i.friendRequestId,isAccepted:!0}),children:"수락"}):null," "]},i.createdAt))),o&&e.jsx(H,{count:5})]}),e.jsx(J,{ref:d,children:o&&e.jsx(M,{color:"black"})})]})},U=n.div` |
| 40 | + padding: 34.5px 109px 67.5px 37px; |
| 41 | + background: ${({background:t})=>t}; |
| 42 | + box-shadow: 0px 3px 10px rgba(0, 0, 0, 0.25); |
| 43 | + border-radius: 20px; |
| 44 | + width: calc(100% - 146px); |
| 45 | + display: flex; |
| 46 | + flex-direction: column; |
| 47 | + height: 100%; |
| 48 | +`,W=()=>{const{selectedTheme:t}=g(),a=h[t][1];return e.jsxs(U,{background:a,children:[e.jsx(z,{})," "]})},$=n.div` |
| 49 | + padding: 34.5px 109px 67.5px 37px; |
| 50 | + background: ${({background:t})=>t}; |
| 51 | + box-shadow: 0px 3px 10px rgba(0, 0, 0, 0.25); |
| 52 | + border-radius: 20px; |
| 53 | + width: calc(100% - 146px); |
| 54 | + display: flex; |
| 55 | + flex-direction: column; |
| 56 | + height: 100%; |
| 57 | +`,X=n.div` |
| 58 | + background-color: white; |
| 59 | + border-radius: 20px; |
| 60 | + padding: 20px; |
| 61 | + padding-left: 30px; |
| 62 | + padding-right: 30px; |
| 63 | + box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.1); |
| 64 | + margin-bottom: 1px; |
| 65 | + margin-top: 1px; |
| 66 | + display: flex; |
| 67 | + justify-content: space-between; |
| 68 | + align-items: center; |
| 69 | +`,Y=n.div` |
| 70 | + display: flex; |
| 71 | + gap: 100px; |
| 72 | + font-size: 18px; |
| 73 | + font-family: Pretendard, sans-serif; |
| 74 | + font-weight: 500; |
| 75 | + color: black; |
| 76 | +`,v=n.div` |
| 77 | + min-width: 100px; |
| 78 | + text-align: center; |
| 79 | +`,Z=n.div` |
| 80 | + width: 100vw; |
| 81 | + height: 50px; |
| 82 | + margin-top: 50px; |
| 83 | + display: flex; |
| 84 | + justify-content: center; |
| 85 | + align-items: flex-end; |
| 86 | +`,_=n.div` |
| 87 | + text-align: center; |
| 88 | + font-size: 18px; |
| 89 | + font-family: Pretendard, sans-serif; |
| 90 | + font-weight: 500; |
| 91 | + color: gray; |
| 92 | + margin-top: 20px; |
| 93 | +`,ee=()=>{const{selectedTheme:t}=g(),a=h[t][1],{data:c,isPending:f,isFetching:o,hasNextPage:r,fetchNextPage:s}=N("/api/activity/assignment/notify",5),{ref:d,inView:m}=A({threshold:0}),y=V(m,300);C.useEffect(()=>{y&&r&&!o&&s()},[y,r,o,s]);const b=C.useMemo(()=>{var l;return((l=c==null?void 0:c.pages)==null?void 0:l.flatMap(j=>j.content.filter(p=>p.type==="과제 시간 알림")))||[]},[c]);return f?e.jsx($,{background:a,children:e.jsx(P,{count:3})}):e.jsxs(e.Fragment,{children:[e.jsxs($,{background:a,children:[b.length===0?e.jsx(_,{children:"과제 알림 항목이 없습니다."}):b.map(l=>e.jsx(X,{children:e.jsxs(Y,{children:[e.jsx(v,{children:l.date}),e.jsx(v,{children:l.time}),e.jsx(v,{children:l.content})]})},l.createdAt)),o&&e.jsx(P,{count:3})]}),e.jsx(Z,{ref:d,children:o&&e.jsx(M,{color:"black"})})]})},te=n.div` |
| 94 | + padding: 34.5px 109px 67.5px 37px; |
| 95 | + background: ${({background:t})=>t}; |
| 96 | + box-shadow: 0px 3px 10px rgba(0, 0, 0, 0.25); |
| 97 | + border-radius: 20px; |
| 98 | + width: calc(100% - 146px); |
| 99 | + display: flex; |
| 100 | + flex-direction: column; |
| 101 | + height: 100%; |
| 102 | + align-items: center; |
| 103 | + justify-content: flex-start; |
| 104 | + position: relative; |
| 105 | +`,ne=n.div` |
| 106 | + align-self: center; |
| 107 | + text-align: center; |
| 108 | + font-size: 18px; |
| 109 | + font-family: Pretendard, sans-serif; |
| 110 | + font-weight: 500; |
| 111 | + color: gray; |
| 112 | + margin-top: 20px; |
| 113 | +`,oe=()=>{const{selectedTheme:t}=g(),a=h[t][1];return e.jsx(te,{background:a,children:e.jsx(ne,{children:"기타 항목이 없습니다."})})},re=n.div` |
| 114 | + width: 100%; |
| 115 | + height: 100%; |
| 116 | + display: flex; |
| 117 | + flex-direction: column; |
| 118 | + justify-content: flex-start; |
| 119 | + align-items: flex-start; |
| 120 | + gap: 30px; |
| 121 | + margin-top: 70px; |
| 122 | + margin-left: 79px; |
| 123 | +`,se=n.div` |
| 124 | + font-size: 28px; |
| 125 | + font-family: Pretendard, sans-serif; |
| 126 | + font-weight: 700; |
| 127 | + color: black; |
| 128 | +`,ie=n.div` |
| 129 | + display: flex; |
| 130 | + gap: 10px; |
| 131 | +`,ae=n.button` |
| 132 | + height: 38px; |
| 133 | + width: 135px; |
| 134 | + padding: 8px 8px; |
| 135 | + background-color: ${t=>t.active?t.background:"#E8E8E8"}; |
| 136 | + border-radius: 50px; |
| 137 | + border: none; |
| 138 | + color: ${t=>t.active?"white":"#666666"}; |
| 139 | + font-size: 16px; |
| 140 | + font-family: Pretendard, sans-serif; |
| 141 | + font-weight: 500; |
| 142 | + cursor: pointer; |
| 143 | + &:hover { |
| 144 | + background-color: ${({background:t})=>t}; |
| 145 | + color: white; |
| 146 | + } |
| 147 | +`,me=()=>{const[t,x]=C.useState("전체"),{selectedTheme:a}=g(),f=h[a][0],o=()=>{switch(t){case"친구소식":return e.jsx(W,{});case"과제알림":return e.jsx(ee,{});case"기타":return e.jsx(oe,{});default:return e.jsx(O,{})}};return e.jsxs(re,{children:[e.jsx(se,{children:"히스토리"}),e.jsx(ie,{children:["전체","친구소식","과제알림","기타"].map(r=>e.jsx(ae,{background:f,active:t===r,onClick:()=>x(r),children:r},r))}),o()]})};export{me as default}; |
0 commit comments