mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 01:38:19 +08:00
core&ui: add problems gql to fix autocomplete (#389)
This commit is contained in:
1 parent
4b3c57549a
commit
a52c488e23
5 files changed
+17
-5
No files matched your search
+8
-2
@@ -1,5 +1,6 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import api, { gql } from 'vj/utils/api';
|
||||
import request from 'vj/utils/request';
|
||||
import type { ProblemDoc } from 'hydrooj/src/interface';
|
||||
import AutoComplete, { AutoCompleteHandle, AutoCompleteProps } from './AutoComplete';
|
||||
@@ -9,8 +10,13 @@ const ProblemSelectAutoComplete = forwardRef<AutoCompleteHandle<ProblemDoc>, Aut
|
||||
ref={ref as any}
|
||||
cacheKey={`problem-${UiContext.domainId}`}
|
||||
queryItems={(query) => request.get(`/d/${UiContext.domainId}/problem/list`, { prefix: query })}
|
||||
// FIXME fetch items
|
||||
fetchItems={(ids) => ids.map((id) => ({ docId: id, pid: id, title: id }) as any)}
|
||||
fetchItems={(ids) => api(gql`
|
||||
problems(ids: ${ids.map((i) => +i)}) {
|
||||
docId
|
||||
pid
|
||||
title
|
||||
}
|
||||
`, ['data', 'problems'])}
|
||||
itemText={(pdoc) => `${`${pdoc.docId} ${pdoc.title}`}`}
|
||||
itemKey={(pdoc) => `${pdoc.docId || pdoc}`}
|
||||
renderItem={(pdoc) => (
|
||||
|
||||
Reference in new issue
Block a user