Skip to content

Commit

Permalink
Update - Possibilité de renseigner un nom commercial
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmugnier committed Nov 24, 2020
1 parent 2b41a16 commit e217bc4
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 36 deletions.
18 changes: 15 additions & 3 deletions src/routes/account/EditProducer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
import { UPDATE_PRODUCER } from "./mutations.js";
import { GET_PRODUCER_DETAILS } from "./queries.js";
import { form, bindClass } from '../../../vendors/svelte-forms/src/index';
import CitySearch from "./../../components/search/CitySearch.svelte";
import CitySearch from "./../../components/search/CitySearch.svelte";
import ErrorContainer from "./../../components/ErrorContainer.svelte";
import Toggle from "./../../components/controls/Toggle.svelte";
import ProfileForm from "./ProfileForm.svelte";
export let errorsHandler, userId;
let producer = {
name: null,
firstName: null,
lastName: null,
email: null,
Expand All @@ -25,6 +26,7 @@
};
const producerForm = form(() => ({
name: { value: producer.name, validators: ['required'], enabled: true },
firstName: { value: producer.firstName, validators: ['required'], enabled: true },
lastName: { value: producer.lastName, validators: ['required'], enabled: true },
email: { value: producer.email, validators: ['required', 'email'], enabled: true },
Expand All @@ -41,8 +43,18 @@
getQuery={GET_PRODUCER_DETAILS}
{errorsHandler}
{userId}>
<h3 class="font-semibold uppercase mb-0 mt-5">{producer.name || "Votre société"}</h3>
<span class="bg-primary h-1 w-20 mt-2 mb-6 block"></span>
<h3 class="font-semibold uppercase mb-0 mt-5">Votre entreprise</h3>
<span class="bg-primary h-1 w-20 mt-2 mb-6 block"></span>
<div class="form-control">
<div class="w-full md:w-2/2">
<label for="grid-line2">Nom commercial *</label>
<input
bind:value={producer.name}
id="grid-line"
type="text"
placeholder="Nom commercial de votre entreprise" />
</div>
</div>
<input hidden required name="city" bind:value={producer.address.city} />
<input
hidden
Expand Down
14 changes: 13 additions & 1 deletion src/routes/account/EditStore.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
export let errorsHandler, userId;
let store = {
name: null,
firstName: null,
lastName: null,
email: null,
Expand All @@ -29,6 +30,7 @@
};
const storeForm = form(() => ({
name: { value: producer.name, validators: ['required'], enabled: true },
firstName: { value: store.firstName, validators: ['required'], enabled: true },
lastName: { value: store.lastName, validators: ['required'], enabled: true },
email: { value: store.email, validators: ['required', 'email'], enabled: true },
Expand All @@ -46,8 +48,18 @@
getQuery={GET_STORE_DETAILS}
{errorsHandler}
{userId}>
<h3 class="font-semibold uppercase mb-0 mt-5">{store.name || "Votre société"}</h3>
<h3 class="font-semibold uppercase mb-0 mt-5">Votre magasin</h3>
<span class="bg-primary h-1 w-20 mt-2 mb-6 block"></span>
<div class="form-control">
<div class="w-full md:w-2/2">
<label for="grid-line2">Nom commercial *</label>
<input
bind:value={store.name}
id="grid-line"
type="text"
placeholder="Nom commercial de votre magasin" />
</div>
</div>
<input hidden required name="city" bind:value={store.address.city} />
<input
hidden
Expand Down
17 changes: 9 additions & 8 deletions src/routes/account/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ export const UPDATE_STORE = gql`
mutation UpdateStore($input: UpdateStoreInput) {
updateStore(input: $input) {
id
lastName
firstName
name
openForNewBusiness
description
email
phone
picture
address {
line1
line2
Expand All @@ -26,14 +34,6 @@ export const UPDATE_STORE = gql`
latitude
longitude
}
lastName
firstName
name
openForNewBusiness
description
email
phone
picture
openingHours {
day
from
Expand All @@ -54,6 +54,7 @@ export const UPDATE_PRODUCER = gql`
description
email
phone
picture
address {
line1
line2
Expand Down
1 change: 1 addition & 0 deletions src/routes/register/RegisterOwner.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
picture: authInstance.user.profile.picture || null,
sponsoringCode: sponsorshipCode || null,
legals: {
name: null,
vatIdentifier: null,
siret: null,
kind: null,
Expand Down
59 changes: 35 additions & 24 deletions src/routes/register/owner/FormCompany.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
const companyForm = form(() => ({
name: { value: company.name, validators: ['required'], enabled: true },
vat: { value: vat, validators: ['required'], enabled: !company.notSubjectToVat },
legalName: { value: company.legals.name, validators: ['required'], enabled: true },
kind: { value: company.legals.kind, validators: ['required'], enabled: true },
email: { value: company.legals.email, validators: ['required', 'email'], enabled: true },
line1: { value: company.legals.address.line1, validators: ['required'], enabled: true },
Expand Down Expand Up @@ -77,18 +78,6 @@
<div class="-my-3 -mx-5 px-5 py-3 mb-4 bg-gray-100 border-b border-gray-400 lg:rounded-t font-semibold flex justify-between items-center">
<p>Infos générales</p>
</div>
<div class="w-full mb-2 md:mb-0 form-control">
<label for="name">
Nom {isStore ? 'du magasin' : "de l'entreprise"} *
</label>
<input
id="name"
type="text"
placeholder="ex : GAEC Fromages du Cantal"
use:bindClass={{ form: companyForm, name: "name" }}
bind:value={company.name} />
<ErrorContainer field={$companyForm.fields.name} />
</div>
<div class="w-full form-control">
<label for="grid-kind">Forme juridique *</label>
<div class="w-full text-xs justify-center button-group" use:bindClass={{ form: companyForm, name: "kind" }}>
Expand All @@ -112,7 +101,39 @@
</button>
</div>
</div>
<ErrorContainer field={$companyForm.fields.kind} />
<ErrorContainer field={$companyForm.fields.kind} />
<div class="w-full form-control">
<label for="company_legalName">Raison sociale *</label>
<input
id="company_legalName"
type="text"
placeholder="ex : G.A.E.C des balmettes"
use:bindClass={{ form: companyForm, name: "legalName" }}
bind:value={company.legals.name} />
<ErrorContainer field={$companyForm.fields.legalName} />
</div>
<div class="w-full mb-2 md:mb-0 form-control">
<label for="name">
Nom commercial {isStore ? 'du magasin' : "de l'entreprise"} *
</label>
<input
id="name"
type="text"
placeholder="ex : La ferme des balmettes"
use:bindClass={{ form: companyForm, name: "name" }}
bind:value={company.name} />
<ErrorContainer field={$companyForm.fields.name} />
</div>
{#if !isStore}
<div class="mt-2 mb-2">
<label class="cursor-pointer">
<InputCheckbox
checked={company.notSubjectToVat}
onClick={() => (company.notSubjectToVat = !company.notSubjectToVat)} />
Mon entreprise n'est pas assujettie à la TVA
</label>
</div>
{/if}
{#if !company.notSubjectToVat}
<div class="w-full form-control">
<label for="vat">N° de TVA *</label>
Expand All @@ -139,7 +160,7 @@
</div>
<ErrorContainer field={$companyForm.fields.vat} />
</div>
{/if}
{/if}
<div class="w-full form-control">
<label for="company_email">Email de contact *</label>
<input
Expand Down Expand Up @@ -192,16 +213,6 @@
<label for="country">Pays *</label>
<CountrySelect bind:selectedValue={company.legals.address.country} formName={companyForm} name="country" {errorsHandler} />
</div>
{#if !isStore}
<div class="mt-2">
<label class="cursor-pointer">
<InputCheckbox
checked={company.notSubjectToVat}
onClick={() => (company.notSubjectToVat = !company.notSubjectToVat)} />
Mon entreprise n'est pas assujettie à la TVA
</label>
</div>
{/if}
</div>
</div>
</fieldset>
Expand Down

0 comments on commit e217bc4

Please sign in to comment.