|
146 | 146 | </template>
|
147 | 147 |
|
148 | 148 | <script lang="ts">
|
| 149 | +import axios from 'axios' |
149 | 150 | import { byError, emailQueries, orcidQueries } from 'src/error-filtering'
|
150 | 151 | import { computed, defineComponent } from 'vue'
|
151 | 152 | import InfoDialog from 'components/InfoDialog.vue'
|
@@ -193,8 +194,29 @@ export default defineComponent({
|
193 | 194 | setup (props) {
|
194 | 195 | const { errors } = useValidation()
|
195 | 196 | const orcidErrors = computed(() => {
|
196 |
| - return orcidQueries(props.index) |
| 197 | + const orcidErrors = orcidQueries(props.index) |
197 | 198 | .filter(byError(errors.value))
|
| 199 | + if (orcidErrors.length === 0) { |
| 200 | + // If a valid orcid is found, look for data in the orcid API (maybe only if we do not have data already) |
| 201 | + const orcid = '0000-0001-8555-849X' // This should come from props.orcid |
| 202 | + const orcidEndpoint = 'https://pub.sandbox.orcid.org/v3.0/expanded-search/?q=orcid:' + orcid + '&rows=1' |
| 203 | + axios.get(orcidEndpoint, |
| 204 | + { |
| 205 | + data: {}, |
| 206 | + headers: { |
| 207 | + 'accept': 'application/vnd.orcid+json' |
| 208 | + } |
| 209 | + }).then(resp => { |
| 210 | + console.log('These values should be injected in the right places') |
| 211 | + console.log('email : ' + resp.data['expanded-result'][0]['email'][0]) |
| 212 | + console.log('last-name : ' + resp.data['expanded-result'][0]['family-names']) |
| 213 | + console.log('first-name: ' + resp.data['expanded-result'][0]['given-names']) |
| 214 | + console.log('Institution: ' + resp.data['expanded-result'][0]['institution-name']) |
| 215 | + console.log('Orcid : ' + resp.data['expanded-result'][0]['orcid-id']) |
| 216 | + |
| 217 | + }) |
| 218 | + } |
| 219 | + return orcidErrors |
198 | 220 | .map(query => query.replace.message)
|
199 | 221 | })
|
200 | 222 | const emailErrors = computed(() => {
|
|
0 commit comments