Skip to content

Commit

Permalink
fix: update ranking data type export and clean up form field props
Browse files Browse the repository at this point in the history
  • Loading branch information
davidemarcoli committed Nov 16, 2024
1 parent 279544e commit c9e3bd2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/lib/forms/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ type CustomRanks = {
trash: Ranks;
};

type RankingData = {
export type RankingData = {
ranking: {
custom_ranks: CustomRanks;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
8 changes: 4 additions & 4 deletions src/lib/forms/ranking-form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@

<div class="space-y-4">
<h3 class="text-lg font-medium">Options</h3>
<NumberField {form} name="title_similarity" {formData} stepValue={0.01} min={0} max={1} />
<NumberField {form} name="title_similarity" {formData} stepValue={0.01} />
<CheckboxField {form} name="remove_all_trash" {formData} />
<NumberField {form} name="remove_ranks_under" {formData} stepValue={1} />
<CheckboxField {form} name="remove_unknown_languages" {formData} />
Expand All @@ -266,11 +266,11 @@

<div class="space-y-4">
<h3 class="text-lg font-medium">Languages</h3>
<LanguageField {form} {formData} name="languages_required" label="Required Languages" />
<LanguageField {form} {formData} name="languages_required" />

<LanguageField {form} {formData} name="languages_exclude" label="Excluded Languages" />
<LanguageField {form} {formData} name="languages_exclude" />

<LanguageField {form} {formData} name="languages_preferred" label="Preferred Languages" />
<LanguageField {form} {formData} name="languages_preferred" />
<!-- <ArrayField {form} name="languages_required" {formData}>
{#each $formData.languages_required as _, i}
<Form.ElementField {form} name="languages_required[{i}]">
Expand Down
8 changes: 2 additions & 6 deletions src/routes/browse/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,12 @@
function mapSelectedStates(selectedStates: Selected<string>[]) {
return selectedStates
.values()
.map((v) => v.value as keyof typeof states)
.toArray();
.map((v: Selected<String>) => v.value as keyof typeof states);
}
function mapSelectedTypes(selectedTypes: Selected<string>[]) {
return selectedTypes
.values()
.map((v) => v.value as keyof typeof types)
.toArray();
.map((v: Selected<String>) => v.value as keyof typeof types);
}
</script>

Expand Down
5 changes: 3 additions & 2 deletions src/routes/settings/ranking/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
rankingSettingsSchema,
rankingSettingsToGet,
rankingSettingsToPass,
rankingSettingsToSet
rankingSettingsToSet,
type RankingData
} from '$lib/forms/helpers';
import { setSettings, saveSettings, loadSettings } from '$lib/forms/helpers.server';
import { SettingsService } from '$lib/client';
Expand All @@ -17,7 +18,7 @@ export const load: PageServerLoad = async () => {
paths: rankingSettingsToGet.join(',')
}
});
const toPassToSchema = rankingSettingsToPass(data);
const toPassToSchema = rankingSettingsToPass(data as RankingData);

return {
form: await superValidate(toPassToSchema, zod(rankingSettingsSchema))
Expand Down

0 comments on commit c9e3bd2

Please sign in to comment.