- API 클라이언트·토큰 갱신·순수 함수를 shared/ (@nalssigak/shared) 로 옮김 - 토큰 저장소·API 주소는 configureApi 로 플랫폼에서 넣는다 (웹 localStorage) - 루트 package.json 에 frontend·mobile·shared workspaces, lock 파일 하나로 - 웹 Docker 빌드 대상을 저장소 루트로 (compose context ., 루트 .dockerignore)
20 lines
985 B
TypeScript
20 lines
985 B
TypeScript
import { RainType, Sky, type WeatherSlot } from '../api/client/types.gen'
|
|
import { kst } from '.'
|
|
|
|
const RAIN_TEXT: Partial<Record<RainType, string>> = { [RainType.RAIN]: '비', [RainType.SLEET]: '진눈깨비', [RainType.SNOW]: '눈', [RainType.SHOWER]: '소나기' }
|
|
const SKY_TEXT: Record<Sky, string> = { [Sky.CLEAR]: '맑음', [Sky.PARTLY]: '구름 많음', [Sky.CLOUDY]: '흐림' }
|
|
|
|
/** 칸 하나의 하늘 상태 한 마디: 비·눈이 오면 그걸, 아니면 하늘 */
|
|
export function skyText(slot: WeatherSlot) {
|
|
return (slot.rain_type != null && RAIN_TEXT[slot.rain_type]) || (slot.sky != null ? SKY_TEXT[slot.sky] : slot.note)
|
|
}
|
|
|
|
/** 주어진 시(0~23)를 넘지 않는 마지막 칸 */
|
|
export function slotAt(slots: WeatherSlot[], hour: number) {
|
|
let pick: WeatherSlot | undefined
|
|
for (const s of slots) if (kst(s.at).h <= hour) pick = s
|
|
return pick ?? slots[0]
|
|
}
|
|
|
|
export const deg = (v: number | null | undefined) => (v == null ? '?°' : `${Math.round(v)}°`)
|