import { ISODate , RegQueryName } from '@hugsmidjan/regulations-editor/types' ; import { RegulationViewTypes , RegulationOriginalDates } from './types-web' ; export const buildRegulationApiPath = ( opts ) : string => { const { viewType , name , date , isCustomDiff } = opts ; const earlierDate = opts . earlierDate === RegulationOriginalDates . gqlHack ? RegulationOriginalDates . api : opts . earlierDate ; let pathParams = viewType ; if ( viewType === 'd' ) { if ( date ) { pathParams = 'd/' + date ; if ( isCustomDiff ) { pathParams += '/diff' + ( earlierDate ? '/' + earlierDate : '' ) ; } } else { pathParams = 'current' ; } } return `/regulation/${ name }/${ pathParams }` ; } ;