fix(settings): search prefs review fixes
- add try/except to suggest endpoint - use immutable spread/filter in addTag, removeTag, acceptSuggestion - add toggleBoard store action, remove direct v-model on board.enabled
This commit is contained in:
parent
c358d8c470
commit
91874a176c
3 changed files with 17 additions and 9 deletions
|
|
@ -1137,5 +1137,8 @@ def save_search_prefs(payload: SearchPrefsPayload):
|
|||
|
||||
@app.post("/api/settings/search/suggest")
|
||||
def suggest_search(body: dict):
|
||||
try:
|
||||
# Stub — LLM suggest for paid tier
|
||||
return {"suggestions": []}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
|
|
|||
|
|
@ -91,30 +91,35 @@ export const useSearchStore = defineStore('settings/search', () => {
|
|||
const arr = { job_titles, locations, exclude_keywords, custom_board_urls, blocklist_companies, blocklist_industries, blocklist_locations }[field]
|
||||
const trimmed = value.trim()
|
||||
if (!trimmed || arr.value.includes(trimmed)) return
|
||||
arr.value.push(trimmed)
|
||||
arr.value = [...arr.value, trimmed]
|
||||
}
|
||||
|
||||
function removeTag(field: 'job_titles' | 'locations' | 'exclude_keywords' | 'custom_board_urls' | 'blocklist_companies' | 'blocklist_industries' | 'blocklist_locations', value: string) {
|
||||
const arr = { job_titles, locations, exclude_keywords, custom_board_urls, blocklist_companies, blocklist_industries, blocklist_locations }[field]
|
||||
const idx = arr.value.indexOf(value)
|
||||
if (idx !== -1) arr.value.splice(idx, 1)
|
||||
arr.value = arr.value.filter(v => v !== value)
|
||||
}
|
||||
|
||||
function acceptSuggestion(type: 'title' | 'location', value: string) {
|
||||
if (type === 'title') {
|
||||
if (!job_titles.value.includes(value)) job_titles.value.push(value)
|
||||
if (!job_titles.value.includes(value)) job_titles.value = [...job_titles.value, value]
|
||||
titleSuggestions.value = titleSuggestions.value.filter(s => s !== value)
|
||||
} else {
|
||||
if (!locations.value.includes(value)) locations.value.push(value)
|
||||
if (!locations.value.includes(value)) locations.value = [...locations.value, value]
|
||||
locationSuggestions.value = locationSuggestions.value.filter(s => s !== value)
|
||||
}
|
||||
}
|
||||
|
||||
function toggleBoard(name: string) {
|
||||
job_boards.value = job_boards.value.map(b =>
|
||||
b.name === name ? { ...b, enabled: !b.enabled } : b
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
remote_preference, job_titles, locations, exclude_keywords, job_boards,
|
||||
custom_board_urls, blocklist_companies, blocklist_industries, blocklist_locations,
|
||||
titleSuggestions, locationSuggestions,
|
||||
loading, saving, saveError, loadError,
|
||||
load, save, suggestTitles, suggestLocations, addTag, removeTag, acceptSuggestion,
|
||||
load, save, suggestTitles, suggestLocations, addTag, removeTag, acceptSuggestion, toggleBoard,
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@
|
|||
<h3>Job Boards</h3>
|
||||
<div v-for="board in store.job_boards" :key="board.name" class="board-row">
|
||||
<label class="checkbox-row">
|
||||
<input type="checkbox" v-model="board.enabled" />
|
||||
<input type="checkbox" :checked="board.enabled" @change="store.toggleBoard(board.name)" />
|
||||
{{ board.name }}
|
||||
</label>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue