import { useLoadQuerys } from "@/common/composeabe/LoadQuerys";
import { navTo } from "@/components/utils/PageAction";

export function useTaskEntryForm() {
  const { querys } = useLoadQuerys({ 
    villageId: 0,  
    villageVolunteerId: 0,
  });
  
  function goForm(subType: string, subId: number, subKey = 'type', type = 'list', subTitle = '') {
    navTo('/pages/dig/forms/' + type, {
      id: type === 'common' ? 1 : undefined,
      villageId: querys.value.villageId,  
      villageVolunteerId: querys.value.villageVolunteerId,  
      subType,
      subId,
      subKey,
      subTitle,
    })
  }

  return {
    goForm,
  }
}

export function goFormStatic(villageId: number, villageVolunteerId: number, subType: string, subId: number, subKey = 'type', type = 'list', subTitle = '') {
  navTo('/pages/dig/forms/' + type, {
    id: type === 'common' ? 1 : undefined,
    villageId,  
    villageVolunteerId,  
    subType,
    subId,
    subKey,
    subTitle,
  })
}