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")
|
@app.post("/api/settings/search/suggest")
|
||||||
def suggest_search(body: dict):
|
def suggest_search(body: dict):
|
||||||
# Stub — LLM suggest for paid tier
|
try:
|
||||||
return {"suggestions": []}
|
# 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 arr = { job_titles, locations, exclude_keywords, custom_board_urls, blocklist_companies, blocklist_industries, blocklist_locations }[field]
|
||||||
const trimmed = value.trim()
|
const trimmed = value.trim()
|
||||||
if (!trimmed || arr.value.includes(trimmed)) return
|
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) {
|
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 arr = { job_titles, locations, exclude_keywords, custom_board_urls, blocklist_companies, blocklist_industries, blocklist_locations }[field]
|
||||||
const idx = arr.value.indexOf(value)
|
arr.value = arr.value.filter(v => v !== value)
|
||||||
if (idx !== -1) arr.value.splice(idx, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function acceptSuggestion(type: 'title' | 'location', value: string) {
|
function acceptSuggestion(type: 'title' | 'location', value: string) {
|
||||||
if (type === 'title') {
|
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)
|
titleSuggestions.value = titleSuggestions.value.filter(s => s !== value)
|
||||||
} else {
|
} 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)
|
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 {
|
return {
|
||||||
remote_preference, job_titles, locations, exclude_keywords, job_boards,
|
remote_preference, job_titles, locations, exclude_keywords, job_boards,
|
||||||
custom_board_urls, blocklist_companies, blocklist_industries, blocklist_locations,
|
custom_board_urls, blocklist_companies, blocklist_industries, blocklist_locations,
|
||||||
titleSuggestions, locationSuggestions,
|
titleSuggestions, locationSuggestions,
|
||||||
loading, saving, saveError, loadError,
|
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>
|
<h3>Job Boards</h3>
|
||||||
<div v-for="board in store.job_boards" :key="board.name" class="board-row">
|
<div v-for="board in store.job_boards" :key="board.name" class="board-row">
|
||||||
<label class="checkbox-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 }}
|
{{ board.name }}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue