refactor: improve router type safety and usage

- Add explicit Router type imports across views
- Replace $router type casting with proper typing
- Use $router.back() instead of $router.go(-1) for consistency
- Add proper route and router typings to components
- Clean up router navigation methods
- Fix router push/back method calls

This commit improves type safety and consistency in router usage across
the application's view components.
This commit is contained in:
Matthew Raymer
2025-02-26 06:50:08 +00:00
parent 61da40596c
commit 03178d35e7
56 changed files with 581 additions and 251 deletions

View File

@@ -325,7 +325,7 @@ export default class GiftedDetails extends Vue {
try {
this.prevCredToEdit = (this.$route.query["prevCredToEdit"] as string)
? (JSON.parse(
(this.$route.query["prevCredToEdit"] as string),
this.$route.query["prevCredToEdit"] as string,
) as GenericCredWrapper<GiveVerifiableCredential>)
: undefined;
} catch (error) {
@@ -349,15 +349,16 @@ export default class GiftedDetails extends Vue {
(this.$route.query["description"] as string) ||
this.prevCredToEdit?.claim?.description ||
this.description;
this.destinationPathAfter = (this.$route.query["destinationPathAfter"] as string) || "";
this.destinationPathAfter =
(this.$route.query["destinationPathAfter"] as string) || "";
this.giverDid = ((this.$route.query["giverDid"] as string) ||
(this.prevCredToEdit?.claim?.agent as any)?.identifier ||
(this.prevCredToEdit?.claim?.agent as unknown as { identifier: string })
?.identifier ||
this.giverDid) as string;
this.giverName =
((this.$route.query["giverName"] as string) || "");
this.giverName = (this.$route.query["giverName"] as string) || "";
this.hideBackButton =
(this.$route.query["hideBackButton"] as string) === "true";
this.message = ((this.$route.query["message"] as string) || "");
this.message = (this.$route.query["message"] as string) || "";
// find any offer ID
const fulfills = this.prevCredToEdit?.claim?.fulfills;
@@ -391,38 +392,38 @@ export default class GiftedDetails extends Vue {
const providerProject = providerArray.find(
(rec) => rec["@type"] === "PlanAction",
);
this.providerProjectId = ((this.$route.query["providerProjectId"] as string) ||
this.providerProjectId = ((this.$route.query[
"providerProjectId"
] as string) ||
providerProject?.identifier ||
this.providerProjectId) as string;
this.recipientDid = ((this.$route.query["recipientDid"] as string) ||
this.prevCredToEdit?.claim?.recipient?.identifier) as string;
this.recipientName =
((this.$route.query["recipientName"] as string) || "");
this.recipientName = (this.$route.query["recipientName"] as string) || "";
this.unitCode = ((this.$route.query["unitCode"] as string) ||
this.prevCredToEdit?.claim?.object?.unitCode ||
this.unitCode) as string;
this.imageUrl =
((this.$route.query["imageUrl"] as string) ||
this.imageUrl = ((this.$route.query["imageUrl"] as string) ||
this.prevCredToEdit?.claim?.image ||
localStorage.getItem("imageUrl") ||
this.imageUrl) as string;
// this is an endpoint for sharing project info to highlight something given
// https://developer.mozilla.org/en-US/docs/Web/Manifest/share_target
if ((this.$route.query["shareTitle"] as string)) {
if (this.$route.query["shareTitle"] as string) {
this.description =
((this.$route.query["shareTitle"] as string) || "") +
(this.description ? "\n" + this.description : "");
}
if ((this.$route.query["shareText"] as string)) {
if (this.$route.query["shareText"] as string) {
this.description =
(this.description ? this.description + "\n" : "") +
((this.$route.query["shareText"] as string) || "");
}
if ((this.$route.query["shareUrl"] as string)) {
this.imageUrl = (this.$route.query["shareUrl"] as string);
if (this.$route.query["shareUrl"] as string) {
this.imageUrl = this.$route.query["shareUrl"] as string;
}
const settings = await retrieveSettingsForActiveAccount();