import { Component } from '../../../../lib/vues6/vues6.js' const template = ` ` export default class ProfilePhotoUploaderComponent extends Component { static get selector() { return 'coreid-profile-photo-uploader' } static get template() { return template } static get params() { return [] } ready = false show() { this.ready = true this.$nextTick(() => { $(this.$refs.modal).modal() }) } close() { $(this.$refs.modal).modal('hide') } async do_upload() { if ( this.$refs.input.files.length < 1 ) return const data = new FormData() data.append('photo', this.$refs.input.files[0]) try { await axios.post(`/api/v1/profile/me/photo`, data, { // TODO support passed-in user_id headers: { 'Content-Type': 'multipart/form-data', } }) this.$emit('upload') } catch (e) { console.error(e) } } }