diff --git a/manifest.webapp b/manifest.webapp index e9fb10c949..8ea8a338fc 100755 --- a/manifest.webapp +++ b/manifest.webapp @@ -249,7 +249,7 @@ "contacts": { "description": "Used to link accounts to contacts", "type": "io.cozy.contacts", - "verbs": ["GET"] + "verbs": ["GET", "PUT", "POST"] } } } diff --git a/package.json b/package.json index 1d95e24395..81f354691d 100644 --- a/package.json +++ b/package.json @@ -160,7 +160,7 @@ "cozy-authentication": "2.1.0", "cozy-bar": "7.13.3", "cozy-ci": "0.4.1", - "cozy-client": "13.15.1", + "cozy-client": "13.16.0", "cozy-client-js": "0.16.4", "cozy-device-helper": "1.9.2", "cozy-doctypes": "1.69.0", @@ -170,10 +170,10 @@ "cozy-konnector-libs": "4.30.3-beta.1", "cozy-logger": "1.6.0", "cozy-notifications": "0.5.0", - "cozy-pouch-link": "13.15.1", + "cozy-pouch-link": "13.16.0", "cozy-realtime": "3.9.0", "cozy-scripts": "4.1.0", - "cozy-stack-client": "13.8.3", + "cozy-stack-client": "13.16.0", "cozy-ui": "35.33.1", "d3": "5.11.0", "date-fns": "1.30.1", diff --git a/src/components/ModalStack.jsx b/src/components/ModalStack.jsx index 65ca8e6fd5..550c415385 100644 --- a/src/components/ModalStack.jsx +++ b/src/components/ModalStack.jsx @@ -7,8 +7,7 @@ import React, { useState } from 'react' import Modal from 'cozy-ui/transpiled/react/Modal' import { ViewStackContext } from 'cozy-ui/transpiled/react' - -const sleep = duration => new Promise(resolve => setTimeout(resolve, duration)) +import sleep from 'utils/sleep' // Same as in cozy-ui const useStack = (initialState, options = {}) => { diff --git a/src/doctypes.js b/src/doctypes.js index 55a402d214..8fa6ce824c 100644 --- a/src/doctypes.js +++ b/src/doctypes.js @@ -234,3 +234,8 @@ export const recurrenceConn = { as: 'recurrence', fetchPolicy: older30s } + +export const myselfConn = { + query: () => Q('io.cozy.contacts').where({ me: true }), + as: 'myself' +} diff --git a/src/ducks/client/checks.js b/src/ducks/client/checks.js index df44719fa6..675c18cd6b 100644 --- a/src/ducks/client/checks.js +++ b/src/ducks/client/checks.js @@ -1,8 +1,7 @@ import matches from 'lodash/matches' import { triggerStates } from 'cozy-client/dist/models/trigger' import { triggersConn } from 'doctypes' - -const sleep = delay => new Promise(resolve => setTimeout(resolve, delay)) +import sleep from 'utils/sleep' const policies = { 'never-executed': triggerState => diff --git a/src/ducks/client/checks.spec.js b/src/ducks/client/checks.spec.js index cdb6f401b6..6b1e9d5a77 100644 --- a/src/ducks/client/checks.spec.js +++ b/src/ducks/client/checks.spec.js @@ -1,8 +1,7 @@ import StartupChecksPlugin from './checks' import CozyClient from 'cozy-client' import merge from 'lodash/merge' - -const sleep = delay => new Promise(resolve => setTimeout(resolve, delay)) +import sleep from 'utils/sleep' describe('startup checks', () => { beforeEach(() => { diff --git a/src/ducks/personal-info/Form.jsx b/src/ducks/personal-info/Form.jsx new file mode 100644 index 0000000000..2c761272cc --- /dev/null +++ b/src/ducks/personal-info/Form.jsx @@ -0,0 +1,123 @@ +import React from 'react' +import { translate } from 'cozy-ui/transpiled/react/I18n' +import { withClient } from 'cozy-client' +import Button from 'cozy-ui/transpiled/react/Button' +import Field from 'cozy-ui/transpiled/react/Field' +import Stack from 'cozy-ui/transpiled/react/Stack' +import compose from 'lodash/flowRight' + +import countries from './countries.json' +import PersonalInfoInfos from 'ducks/personal-info/Infos' + +const defaultNationality = { label: 'French', value: 'FR' } + +const nationalities = countries.map(country => { + return { + label: country.nationality, + value: country.alpha_2_code + } +}) + +/** + * Displays a form to fill personal info into the myself contact. + */ +class PersonalInfoForm extends React.Component { + constructor(props, context) { + super(props, context) + this.handleChangeField = this.handleChangeField.bind(this) + this.handleSave = this.handleSave.bind(this) + + const myself = this.props.myself + + this.state = { + saving: false, + formData: { + birthcity: myself.birthcity, + nationality: + nationalities.find( + x => myself.nationality && x.value === myself.nationality + ) || defaultNationality + } + } + } + + render() { + const { t } = this.props + const { saving, formData } = this.state + + return ( + +
+ + this.handleChangeField('birthcity', ev.target.value) + } + type="text" + name="birthcity" + label={t('PersonalInfo.birthcity')} + placeholder={t('PersonalInfo.birthcity-placeholder')} + /> + this.handleChangeField('nationality', option)} + value={formData.nationality} + type="select" + name="nationality" + options={nationalities} + label={t('PersonalInfo.nationality')} + /> +
+ +