Skip to content

Commit

Permalink
fix: more type issues
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Trost <[email protected]>
  • Loading branch information
galexrt committed Sep 2, 2024
1 parent 7a188b8 commit 99e82d3
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 76 deletions.
7 changes: 3 additions & 4 deletions app/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DiscordConfig, FeatureGates, LoginConfig, Website } from '~/shims';
import type { DiscordConfig, FeatureGates, GameConfig, LoginConfig, WebsiteConfig } from '~/typings';

export default defineAppConfig({
version: '',
Expand All @@ -10,12 +10,11 @@ export default defineAppConfig({
discord: {
botInviteURL: '',
} as DiscordConfig,
website: {} as Website,
website: {} as WebsiteConfig,
featureGates: {} as FeatureGates,
game: {
unemployedJobName: 'unemployed',
},
statsPage: false,
} as GameConfig,

// File upload related config
fileUpload: {
Expand Down
12 changes: 6 additions & 6 deletions app/components/SingleHint.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script lang="ts" setup generic="T extends RoutesNamesList, P extends string, E extends boolean = false">
import type { NuxtRoute, RoutesNamesList } from '@typed-router';
defineProps<{
const props = defineProps<{
hintId: string;
keyboard?: boolean;
showKey?: boolean;
to?: NuxtRoute<T, P, E>;
external?: E;
linkTarget?: '_blank' | null;
linkTarget?: '_blank';
}>();
</script>

Expand All @@ -30,10 +30,10 @@ defineProps<{
<div class="mx-auto mb-2 flex items-center gap-1 text-base">
<span class="grow">{{ $t(`components.hints.${hintId}.content`) }} </span>

<div v-if="keyboard || to" class="flex-initial">
<UKbd v-if="keyboard" :value="$t(`components.hints.${hintId}.keyboard`)" />
<div v-if="showKey || to" class="flex-initial">
<UKbd v-if="showKey" :value="$t(`components.hints.${hintId}.keyboard`)" />

<UButton v-else-if="to" variant="soft" :to="to" :external="external" :target="linkTarget ?? null">
<UButton v-else-if="to" variant="soft" :to="to" :external="props.external" :target="linkTarget">
{{ $t('components.hints.click_me') }}
</UButton>
</div>
Expand Down
11 changes: 7 additions & 4 deletions app/components/auth/PasswordStrengthMeter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ watch(result, () => {
percent.value = (result.value.score * 100) / 3;
feedback.value = result.value.feedback.warning;
if (props.input.trimEnd() === '') {
color.value = 'base';
return;
}
switch (result.value.score) {
case 0:
case 1:
Expand All @@ -35,16 +40,14 @@ watch(result, () => {
color.value = 'base';
break;
}
if (props.input === '') {
color.value = 'base';
}
});
</script>

<template>
<div>
<!-- @vue-expect-error seems that the `color` prop is not using the `ProgressColor` type -->
<UProgress :color="color" :value="percent" />

<p v-if="showFeedback && feedback !== null" class="my-1 text-sm">
{{ feedback }}
</p>
Expand Down
2 changes: 1 addition & 1 deletion app/components/citizens/info/CitizenDocuments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CitizenInfoPopover from '~/components/partials/citizens/CitizenInfoPopove
import DataErrorBlock from '~/components/partials/data/DataErrorBlock.vue';
import DocumentInfoPopover from '~/components/partials/documents/DocumentInfoPopover.vue';
import GenericTime from '~/components/partials/elements/GenericTime.vue';
import type { OpenClose } from '~/shims';
import type { OpenClose } from '~/typings';
import { DocRelation } from '~~/gen/ts/resources/documents/documents';
import { ListUserDocumentsResponse } from '~~/gen/ts/services/docstore/docstore';
Expand Down
12 changes: 6 additions & 6 deletions app/components/documents/DocumentEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ const state = reactive<Schema>({
category: undefined,
});
const access = ref<
Map<
const access = ref(
new Map<
string,
{
id: string;
Expand All @@ -82,18 +82,18 @@ const access = ref<
};
required?: boolean;
}
>
>(new Map());
>(),
);
const docAccess = ref<DocumentAccess>();
const docCreator = ref<UserShort | undefined>();
const openRelationManager = ref<boolean>(false);
const relationManagerData = ref<Map<string, DocumentRelation>>(new Map());
const relationManagerData = ref(new Map<string, DocumentRelation>());
const currentRelations = ref<Readonly<DocumentRelation>[]>([]);
watch(currentRelations, () => currentRelations.value.forEach((e) => relationManagerData.value.set(e.id!, e)));
const openReferenceManager = ref<boolean>(false);
const referenceManagerData = ref<Map<string, DocumentReference>>(new Map());
const referenceManagerData = ref(new Map<string, DocumentReference>());
const currentReferences = ref<Readonly<DocumentReference>[]>([]);
watch(currentReferences, () => currentReferences.value.forEach((e) => referenceManagerData.value.set(e.id!, e)));
Expand Down
2 changes: 1 addition & 1 deletion app/components/documents/DocumentList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import DocumentListEntry from '~/components/documents/DocumentListEntry.vue';
import DataErrorBlock from '~/components/partials/data/DataErrorBlock.vue';
import DataNoDataBlock from '~/components/partials/data/DataNoDataBlock.vue';
import Pagination from '~/components/partials/Pagination.vue';
import type { OpenClose } from '~/shims';
import type { OpenClose } from '~/typings';
import { useCompletorStore } from '~/store/completor';
import { useSettingsStore } from '~/store/settings';
import * as googleProtobufTimestamp from '~~/gen/ts/google/protobuf/timestamp';
Expand Down
16 changes: 8 additions & 8 deletions app/components/documents/templates/TemplateEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ const schemaEditor = ref<SchemaEditorValue>({
max: 0,
},
});
const access = ref<
Map<
const access = ref(
new Map<
string,
{
id: string;
Expand All @@ -92,8 +92,8 @@ const access = ref<
minimumGrade?: number;
};
}
>
>(new Map());
>(),
);
const accessTypes = [{ id: 1, name: t('common.job', 2) }];
Expand Down Expand Up @@ -162,8 +162,8 @@ function updateDocumentAccessEntryAccess(event: { id: string; access: AccessLeve
access.value.set(event.id, accessEntry);
}
const contentAccess = ref<
Map<
const contentAccess = ref(
new Map<
string,
{
id: string;
Expand All @@ -176,8 +176,8 @@ const contentAccess = ref<
};
required?: boolean;
}
>
>(new Map());
>(),
);
const contentAccessTypes = [
{ id: 0, name: t('common.citizen', 2) },
Expand Down
16 changes: 8 additions & 8 deletions app/components/documents/templates/TemplateView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ const contentAccessTypes = [
{ id: 1, name: t('common.job', 2) },
];
const templateAccess = ref<
Map<
const templateAccess = ref(
new Map<
string,
{
id: string;
Expand All @@ -85,11 +85,11 @@ const templateAccess = ref<
minimumGrade?: number;
};
}
>
>(new Map());
>(),
);
const contentAccess = ref<
Map<
const contentAccess = ref(
new Map<
string,
{
id: string;
Expand All @@ -102,8 +102,8 @@ const contentAccess = ref<
};
required?: boolean;
}
>
>(new Map());
>(),
);
watch(template, () => {
if (!template.value) {
Expand Down
6 changes: 3 additions & 3 deletions app/components/partials/PageFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import FiveNetLogo from '~/components/partials/logos/FiveNetLogo.vue';
const { t } = useI18n();
const { links } = useAppConfig();
const { website } = useAppConfig();
const footerLinks = [
{
label: t('common.privacy_policy'),
to: links?.privacyPolicy,
to: website.links?.privacyPolicy,
},
{
label: t('common.imprint'),
to: links?.imprint,
to: website.links?.imprint,
},
].filter((l) => l.to !== undefined);
Expand Down
8 changes: 4 additions & 4 deletions app/components/qualifications/QualificationEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ const state = reactive<Schema>({
},
});
const access = ref<
Map<
const access = ref(
new Map<
string,
{
id: string;
Expand All @@ -105,8 +105,8 @@ const access = ref<
minimumGrade?: number;
};
}
>
>(new Map());
>(),
);
const qualiAccess = ref<QualificationAccess>();
const qualiRequirements = ref<QualificationRequirement[]>([]);
Expand Down
4 changes: 2 additions & 2 deletions app/components/rector/attrs/AttrView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ const changed = ref(false);
const permList = ref<Permission[]>([]);
const permCategories = ref<Set<string>>(new Set());
const permStates = ref<Map<string, boolean | undefined>>(new Map());
const permStates = ref(new Map<string, boolean | undefined>());
const attrList = ref<RoleAttribute[]>([]);
const attrStates = ref<Map<string, AttributeValues | undefined>>(new Map());
const attrStates = ref(new Map<string, AttributeValues | undefined>());
async function getRole(id: string): Promise<Role> {
try {
Expand Down
2 changes: 1 addition & 1 deletion app/components/rector/attrs/AttrViewAttr.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const completorStore = useCompletorStore();
const { jobs } = storeToRefs(completorStore);
const { listJobs } = completorStore;
const jobGrades = ref<Map<string, JobGrade>>(new Map());
const jobGrades = ref(new Map<string, JobGrade>());
const states = ref<typeof props.states>(props.states);
const id = ref<string>(props.attribute.attrId);
Expand Down
4 changes: 2 additions & 2 deletions app/components/rector/roles/RoleView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ const changed = ref(false);
const permList = ref<Permission[]>([]);
const permCategories = ref<Set<string>>(new Set());
const permStates = ref<Map<string, boolean | undefined>>(new Map());
const permStates = ref(new Map<string, boolean | undefined>());
const attrList = ref<RoleAttribute[]>([]);
const attrStates = ref<Map<string, AttributeValues | undefined>>(new Map());
const attrStates = ref(new Map<string, AttributeValues | undefined>());
async function getRole(id: string): Promise<Role> {
try {
Expand Down
2 changes: 1 addition & 1 deletion app/components/rector/roles/RoleViewAttr.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const completorStore = useCompletorStore();
const { jobs } = storeToRefs(completorStore);
const { listJobs } = completorStore;
const jobGrades = ref<Map<string, JobGrade>>(new Map());
const jobGrades = ref(new Map<string, JobGrade>());
const states = ref<typeof props.states>(props.states);
const id = ref<string>(props.attribute.attrId);
Expand Down
9 changes: 8 additions & 1 deletion app/error.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@ const isDev = import.meta.dev;
</div>

<div class="inline-flex w-full gap-2">
<UButton block class="flex-1" size="lg" :disabled="buttonDisabled" @click="handleError()">
<UButton
color="primary"
block
class="flex-1"
size="lg"
:disabled="buttonDisabled"
@click="handleError()"
>
{{ $t('common.home') }}
</UButton>

Expand Down
28 changes: 4 additions & 24 deletions app/shims.d.ts → app/typings.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
import type { Perms } from '~~/gen/ts/perms';

declare module '#app' {
interface PageMeta {
title?: string;
requiresAuth?: boolean;
redirectIfAuthed?: boolean;
permission?: Perms | Perms[];
authTokenOnly?: boolean;
showCookieOptions?: boolean;
}
}

import 'vue-router';
declare module 'vue-router' {
interface RouteMeta {
title?: string;
Expand Down Expand Up @@ -38,9 +27,9 @@ export type DiscordConfig = {
botInviteURL?: string;
};

export type Website = {
export type WebsiteConfig = {
links: Links;
statsPage: boolean;
statsPage: boolean = false;
};

export type Links = {
Expand All @@ -50,19 +39,10 @@ export type Links = {

export type FeatureGates = {};

export type Game = {
export type GameConfig = {
unemployedJobName: string;
};

export type AppConfig = {
version: string;
login: LoginConfig;
discord: DiscordConfig;
website: Website;
featureGates: FeatureGates;
game: Game;
};

export type OpenClose = { id: number; label: string; closed?: boolean };

// It is always important to ensure you import/export something when augmenting a type
Expand Down

0 comments on commit 99e82d3

Please sign in to comment.