diff --git a/web/app/controllers/authenticated/new/doc.js b/web/app/controllers/authenticated/new/doc.js deleted file mode 100644 index 180a7e5b4..000000000 --- a/web/app/controllers/authenticated/new/doc.js +++ /dev/null @@ -1,11 +0,0 @@ -import Controller from "@ember/controller"; -import { inject as service } from "@ember/service"; -import { action } from "@ember/object"; - -export default class AuthenticatedNewDocController extends Controller { - @service router; - - queryParams = ["docType"]; - - -} diff --git a/web/app/controllers/authenticated/new/doc.ts b/web/app/controllers/authenticated/new/doc.ts new file mode 100644 index 000000000..8cecbd5c8 --- /dev/null +++ b/web/app/controllers/authenticated/new/doc.ts @@ -0,0 +1,9 @@ +import Controller from "@ember/controller"; +import AuthenticatedNewDocRoute from "hermes/routes/authenticated/new/doc"; +import { ModelFrom } from "hermes/types/route-models"; + +export default class AuthenticatedNewDocController extends Controller { + queryParams = ["docType"]; + + declare model: ModelFrom; +} diff --git a/web/app/routes/authenticated/new.ts b/web/app/routes/authenticated/new.ts new file mode 100644 index 000000000..986d7d189 --- /dev/null +++ b/web/app/routes/authenticated/new.ts @@ -0,0 +1,3 @@ +import Route from "@ember/routing/route"; + +export default class AuthenticatedNewRoute extends Route {} diff --git a/web/app/routes/authenticated/new/doc.js b/web/app/routes/authenticated/new/doc.js deleted file mode 100644 index bfcefae3d..000000000 --- a/web/app/routes/authenticated/new/doc.js +++ /dev/null @@ -1,21 +0,0 @@ -import Route from "@ember/routing/route"; -import RSVP from "rsvp"; -import { inject as service } from "@ember/service"; - -export default class AuthenticatedNewDocRoute extends Route { - @service("fetch") fetchSvc; - @service flashMessages; - @service router; - - queryParams = { - docType: { - refreshModel: true, - }, - }; - - async model(params) { - return RSVP.hash({ - docType: params?.docType, - }); - } -} diff --git a/web/app/routes/authenticated/new/doc.ts b/web/app/routes/authenticated/new/doc.ts new file mode 100644 index 000000000..0a84dfdbd --- /dev/null +++ b/web/app/routes/authenticated/new/doc.ts @@ -0,0 +1,17 @@ +import Route from "@ember/routing/route"; + +interface AuthenticatedNewDocRouteParams { + docType: string; +} + +export default class AuthenticatedNewDocRoute extends Route { + queryParams = { + docType: { + refreshModel: true, + }, + }; + + model(params: AuthenticatedNewDocRouteParams) { + return params.docType; + } +} diff --git a/web/app/routes/authenticated/new/index.js b/web/app/routes/authenticated/new/index.js deleted file mode 100644 index 0893fb0e6..000000000 --- a/web/app/routes/authenticated/new/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import Route from "@ember/routing/route"; -import { inject as service } from "@ember/service"; - -export default class AuthenticatedNewIndexRoute extends Route { - @service("fetch") fetchSvc; - - async model() { - return await this.fetchSvc - .fetch("/api/v1/document-types") - .then((r) => r.json()); - } -} diff --git a/web/app/routes/authenticated/new/index.ts b/web/app/routes/authenticated/new/index.ts new file mode 100644 index 000000000..46f2f6548 --- /dev/null +++ b/web/app/routes/authenticated/new/index.ts @@ -0,0 +1,14 @@ +import Route from "@ember/routing/route"; +import { inject as service } from "@ember/service"; +import FetchService from "hermes/services/fetch"; +import { HermesDocumentType } from "hermes/types/document-type"; + +export default class AuthenticatedNewIndexRoute extends Route { + @service("fetch") declare fetchSvc: FetchService; + + async model() { + return (await this.fetchSvc + .fetch("/api/v1/document-types") + .then((r) => r?.json())) as HermesDocumentType[]; + } +} diff --git a/web/app/templates/authenticated/new.hbs b/web/app/templates/authenticated/new.hbs index 981f098fc..59395665c 100644 --- a/web/app/templates/authenticated/new.hbs +++ b/web/app/templates/authenticated/new.hbs @@ -1,4 +1,3 @@ -{{! @glint-nocheck: not typesafe yet }}
diff --git a/web/app/templates/authenticated/new/doc.hbs b/web/app/templates/authenticated/new/doc.hbs index 1a49077a6..d7c8beab5 100644 --- a/web/app/templates/authenticated/new/doc.hbs +++ b/web/app/templates/authenticated/new/doc.hbs @@ -1,3 +1,3 @@ -{{page-title (concat "Create Your " @model.docType)}} +{{page-title (concat "Create Your " @model)}} - + diff --git a/web/app/templates/authenticated/new/index.hbs b/web/app/templates/authenticated/new/index.hbs index 4e924cbc2..b1da15804 100644 --- a/web/app/templates/authenticated/new/index.hbs +++ b/web/app/templates/authenticated/new/index.hbs @@ -6,19 +6,19 @@ {{#each @model as |docType|}}
  • -

    +

    {{docType.name}}

  • - {{/each}} - diff --git a/web/tests/acceptance/authenticated/new/index-test.ts b/web/tests/acceptance/authenticated/new-test.ts similarity index 100% rename from web/tests/acceptance/authenticated/new/index-test.ts rename to web/tests/acceptance/authenticated/new-test.ts