Lee-Park-Bae-Project / KAKIOTALK

πŸ˜†πŸ’¬ μ›Ή 기반 μ±„νŒ… μ–΄ν”Œλ¦¬μΌ€μ΄μ…˜ πŸ˜†πŸ’¬
MIT License
4 stars 2 forks source link

πŸ”¨ [λ¦¬νŒ©ν† λ§] response type 톡일 [WIP] #166

Closed Junow closed 4 years ago

Junow commented 4 years ago

closes #165 closes #50 api response type ν†΅μΌμž‘μ—…μ€‘μž…λ‹ˆλ‹€.

@bbumjun λ‹˜μ΄ server/common/utils.ts 에 μž‘μ„±ν•˜μ…¨λ˜ message κ°μ²΄λŠ” server/common/error.ts 에 ν†΅ν•©λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

μ§€κΈˆ μ•„λž˜μ™€ 같은 μƒνƒœμΈλ° λͺ¨λ‘ 401 μƒνƒœμ½”λ“œλ‘œ λ˜μžˆλŠ”κ²ƒμ€ μƒμ˜ν›„μ— ν†΅μΌν•˜λ„λ‘ ν•˜κ² μŠ΅λ‹ˆλ‹€.

export const CAN_NOT_BE_DONE = _he(_code.NOT_ACCEPTABLE, 'μš”μ²­μ„ μ™„λ£Œν•˜μ§€ λͺ»ν–ˆμŠ΅λ‹ˆλ‹€.')

export const INVALID_GOOGLE_ID = _he(_code.UNAUTHORIZED, '계정이 μœ νš¨ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.')

export const CAN_NOT_ADD_ME = _he(_code.UNAUTHORIZED, '본인은 친ꡬ둜 μΆ”κ°€ν•  수 μ—†μŠ΅λ‹ˆλ‹€.')

export const INVALID_EMAIL = _he(_code.UNAUTHORIZED, 'μœ νš¨ν•˜μ§€ μ•Šμ€ μ΄λ©”μΌμž…λ‹ˆλ‹€.')

export const ALREADY_EXIST_FRIEND = _he(_code.UNAUTHORIZED, '이미 μΆ”κ°€λ˜μ–΄ μžˆλŠ” μΉœκ΅¬μž…λ‹ˆλ‹€.')

export const INVALID_FRIEND_ID = _he(_code.UNAUTHORIZED, '친ꡬ의 계정이 μœ νš¨ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.')

export const ERROR_OCCURED = _he(_code.UNAUTHORIZED, '였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.')

8e019d9 μ»€λ°‹μœΌλ‘œ confirmDelete κΉŒμ§€ alert action 으둜 λ‹€ μž‘μ—…ν–ˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒμ—λŠ” SweetAlert κ±·μ–΄λ‚΄κ³  alert μ»΄ν¬λ„ŒνŠΈ μžμ²΄μ œμž‘ ν•˜κ³ μ‹Άλ„€μš”. λ””μžμΈ 톡일성이 alert λΆ€λΆ„μ—μ„œ μ’€ μ•ˆλ§žμ•„μ„œμš” γ…Ž..

Junow commented 4 years ago

@bbumjun system/profile μ—μ„œ 쓰이고 μžˆλŠ” alert.confirmDelete λŠ” AlertAction 을 dispatch ν•˜λŠ” λ°©μ‹μœΌλ‘œ λ°”κΎΌλ‹€λ©΄ μ–΄λ–»κ²Œ ν•  수 μžˆμ„κΉŒμš”? modules/alert/reducer 에 넣어도 λ κ±°κ°™κΈ΄ν•œλ° if(confirm) 일 λ•Œ reducer μ—μ„œ λ‹€λ₯Έ μ•‘μ…˜μ„ λ””μŠ€νŒ¨μΉ˜ ν•˜λŠ”κ²Œ λ§žλŠ”μ§€ 잘 λͺ¨λ₯΄κ² λ„€μš”

  const onDeleteClick = () => {
    alert.confirmDelete(name).then((confirm) => {
      if (confirm) {
        dispatch(deleteFriend(uuid))
      }
    })
  }
bbumjun commented 4 years ago

@bbumjun system/profile μ—μ„œ 쓰이고 μžˆλŠ” alert.confirmDelete λŠ” AlertAction 을 dispatch ν•˜λŠ” λ°©μ‹μœΌλ‘œ λ°”κΎΌλ‹€λ©΄ μ–΄λ–»κ²Œ ν•  수 μžˆμ„κΉŒμš”? modules/alert/reducer 에 넣어도 λ κ±°κ°™κΈ΄ν•œλ° if(confirm) 일 λ•Œ reducer μ—μ„œ λ‹€λ₯Έ μ•‘μ…˜μ„ λ””μŠ€νŒ¨μΉ˜ ν•˜λŠ”κ²Œ λ§žλŠ”μ§€ 잘 λͺ¨λ₯΄κ² λ„€μš”

  const onDeleteClick = () => {
    alert.confirmDelete(name).then((confirm) => {
      if (confirm) {
        dispatch(deleteFriend(uuid))
      }
    })
  }

μ—λŸ¬ κ΄€λ ¨ν•œ alertκ°€ μ•„λ‹ˆλΌ λͺ¨λ“  alert에 λŒ€ν•œ λ””μŠ€νŒ¨μΉ˜λ₯Ό λͺ¨μ•„λ‘λŠ” κ±΄κ°€μš”? μœ„κ°™μ€ κ²½μš°λŠ” alert와 delete action을 λΆ„λ¦¬ν•˜λŠ”κ²ƒμ΄ 였히렀 λΆ€μžμ—°μŠ€λŸ¬μš΄κ±° κ°™κΈ°λ„ν•˜λ„€μš”

Junow commented 4 years ago

@bbumjun system/profile μ—μ„œ 쓰이고 μžˆλŠ” alert.confirmDelete λŠ” AlertAction 을 dispatch ν•˜λŠ” λ°©μ‹μœΌλ‘œ λ°”κΎΌλ‹€λ©΄ μ–΄λ–»κ²Œ ν•  수 μžˆμ„κΉŒμš”? modules/alert/reducer 에 넣어도 λ κ±°κ°™κΈ΄ν•œλ° if(confirm) 일 λ•Œ reducer μ—μ„œ λ‹€λ₯Έ μ•‘μ…˜μ„ λ””μŠ€νŒ¨μΉ˜ ν•˜λŠ”κ²Œ λ§žλŠ”μ§€ 잘 λͺ¨λ₯΄κ² λ„€μš”

  const onDeleteClick = () => {
    alert.confirmDelete(name).then((confirm) => {
      if (confirm) {
        dispatch(deleteFriend(uuid))
      }
    })
  }

μ—λŸ¬ κ΄€λ ¨ν•œ alertκ°€ μ•„λ‹ˆλΌ λͺ¨λ“  alert에 λŒ€ν•œ λ””μŠ€νŒ¨μΉ˜λ₯Ό λͺ¨μ•„λ‘λŠ” κ±΄κ°€μš”? μœ„κ°™μ€ κ²½μš°λŠ” alert와 delete action을 λΆ„λ¦¬ν•˜λŠ”κ²ƒμ΄ 였히렀 λΆ€μžμ—°μŠ€λŸ¬μš΄κ±° κ°™κΈ°λ„ν•˜λ„€μš”

μ²˜μŒμ—” λͺ¨λ“  alert κ°€ μ—λŸ¬μΈμ€„ μ•Œμ•˜λŠ”λ° μ •λ¦¬ν•˜λ‹€λ³΄λ‹ˆ μ—λŸ¬κ°€ μ•„λ‹Œ alert 도 μžˆλ”λΌκ΅¬μš” κ·Έλž˜μ„œ alert reducer λ₯Ό λ”°λ‘œ λͺ¨μ•„λ‘κ²Œ λμŠ΅λ‹ˆλ‹€.

λ§μ”€ν•˜μ‹  κ²ƒμ²˜λŸΌ alert 와 delete action이 λΆ„λ¦¬λ˜λŠ” 건 μ•„λ‹ˆκ³  onDeleteClick 이 λ°œμƒν–ˆμ„λ•Œ alert action 을 dispatch ν•˜κ³  처리λ₯Ό alert reducer μ—μ„œ deleteFriend action 을 dispatch ν•˜κ²Œ λ˜λŠ” λͺ¨μ–‘μƒˆκ°€ μ˜³μ€μ§€ κΆκΈˆν•œ κ±°μ˜€μŠ΅λ‹ˆλ‹€.

ν•œκ°€μ§€ λ– μ˜€λ₯΄λŠ”건 콜백으둜 dispatch(deleteFriend) λ₯Ό λ„˜κ²¨μ£Όκ³  alert μ—μ„œ if(confirm) μΌλ•Œ μ½œλ°±μ„ μ‹€ν–‰μ‹œν‚¬ μˆ˜λ„ μžˆκ² λ„€μš”. view λ‹¨μ—μ„œ μ—λŸ¬ 핸듀링을 μ •μ˜ν•΄μ£ΌλŠ”κ²Œ λ‚˜μœΌλ‹ˆκΉŒμš”

bbumjun commented 4 years ago

@bbumjun system/profile μ—μ„œ 쓰이고 μžˆλŠ” alert.confirmDelete λŠ” AlertAction 을 dispatch ν•˜λŠ” λ°©μ‹μœΌλ‘œ λ°”κΎΌλ‹€λ©΄ μ–΄λ–»κ²Œ ν•  수 μžˆμ„κΉŒμš”? modules/alert/reducer 에 넣어도 λ κ±°κ°™κΈ΄ν•œλ° if(confirm) 일 λ•Œ reducer μ—μ„œ λ‹€λ₯Έ μ•‘μ…˜μ„ λ””μŠ€νŒ¨μΉ˜ ν•˜λŠ”κ²Œ λ§žλŠ”μ§€ 잘 λͺ¨λ₯΄κ² λ„€μš”

  const onDeleteClick = () => {
    alert.confirmDelete(name).then((confirm) => {
      if (confirm) {
        dispatch(deleteFriend(uuid))
      }
    })
  }

μ—λŸ¬ κ΄€λ ¨ν•œ alertκ°€ μ•„λ‹ˆλΌ λͺ¨λ“  alert에 λŒ€ν•œ λ””μŠ€νŒ¨μΉ˜λ₯Ό λͺ¨μ•„λ‘λŠ” κ±΄κ°€μš”? μœ„κ°™μ€ κ²½μš°λŠ” alert와 delete action을 λΆ„λ¦¬ν•˜λŠ”κ²ƒμ΄ 였히렀 λΆ€μžμ—°μŠ€λŸ¬μš΄κ±° κ°™κΈ°λ„ν•˜λ„€μš”

μ²˜μŒμ—” λͺ¨λ“  alert κ°€ μ—λŸ¬μΈμ€„ μ•Œμ•˜λŠ”λ° μ •λ¦¬ν•˜λ‹€λ³΄λ‹ˆ μ—λŸ¬κ°€ μ•„λ‹Œ alert 도 μžˆλ”λΌκ΅¬μš” κ·Έλž˜μ„œ alert reducer λ₯Ό λ”°λ‘œ λͺ¨μ•„λ‘κ²Œ λμŠ΅λ‹ˆλ‹€.

λ§μ”€ν•˜μ‹  κ²ƒμ²˜λŸΌ alert 와 delete action이 λΆ„λ¦¬λ˜λŠ” 건 μ•„λ‹ˆκ³  onDeleteClick 이 λ°œμƒν–ˆμ„λ•Œ alert action 을 dispatch ν•˜κ³  처리λ₯Ό alert reducer μ—μ„œ deleteFriend action 을 dispatch ν•˜κ²Œ λ˜λŠ” λͺ¨μ–‘μƒˆκ°€ μ˜³μ€μ§€ κΆκΈˆν•œ κ±°μ˜€μŠ΅λ‹ˆλ‹€.

ν•œκ°€μ§€ λ– μ˜€λ₯΄λŠ”건 콜백으둜 dispatch(deleteFriend) λ₯Ό λ„˜κ²¨μ£Όκ³  alert μ—μ„œ if(confirm) μΌλ•Œ μ½œλ°±μ„ μ‹€ν–‰μ‹œν‚¬ μˆ˜λ„ μžˆκ² λ„€μš”. view λ‹¨μ—μ„œ μ—λŸ¬ 핸듀링을 μ •μ˜ν•΄μ£ΌλŠ”κ²Œ λ‚˜μœΌλ‹ˆκΉŒμš”

λ§μ”€ν•˜μ‹  λ°©λ²•λŒ€λ‘œ 콜백으둜 λ„˜κ²¨μ£Όλ©΄ 문제될건 없을것 κ°™λ„€μš” πŸ‘