Skip to content

Commit

Permalink
fix: tender rows update
Browse files Browse the repository at this point in the history
  • Loading branch information
mp3000mp committed Sep 9, 2024
1 parent 4dcf902 commit 6d88ba0
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 15 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,30 @@ Clone this repository
git clone https://github.com/mp3000mp/auto-entreprise.git
```

Install scripts and database
Install frontend
```shell
composer install
npm install
npm run build
```

Install backend and database
```shell
composer install
php bin/console doctrine:database:create
php bin/console doctrine:migration:migrate
php bin/console doctrine:fixtures:load
```

Launch frontend
```shell
npm run dev
```

Launch backend
```shell
symfony server:start
```

OR
- change ansible/inventory/hosts
- change ansible/vars.yml
Expand Down
1 change: 1 addition & 0 deletions backend/resources/fixtures/user.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
parameters:
# Test2000!
password: $2y$04$.n4U7lMIgVBecQNnA5LsOeFJw396J5E5W1y2W1uKctAua2gGdkIfi

App\Entity\User:
Expand Down
4 changes: 2 additions & 2 deletions deployment/ansible/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
roles:
# - files
# - docker
- deploy_back
# - deploy_front
# - deploy_back
- deploy_front
# - apache
# - backup
# - launch
5 changes: 3 additions & 2 deletions frontend/src/stores/tender/dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ export function convertTenderOut(tender: Tender | NewTender): TenderDtoOut | New
}
}
export function convertTenderRowOut(
tenderRow: TenderRow | NewTenderRow
tenderRow: TenderRow | NewTenderRow,
tender: Tender,
): TenderRowDtoOut | NewTenderRowDtoOut {
return {
...tenderRow,
tender: '/api/tenders/' + tenderRow.tender.id
tender: '/api/tenders/' + tender.id
}
}
8 changes: 4 additions & 4 deletions frontend/src/stores/tender/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ export const useTenderStore = defineStore('tender', {
notifyError('Error while deleting tender: ', err)
}
},
async addTenderRow(tenderRow: NewTenderRow) {
async addTenderRow(tenderRow: NewTenderRow, tender: Tender) {
try {
const rawTenderRow = await ApiClient.query<TenderRow>(
HttpMethodEnum.POST,
rowUrlPrefix,
convertTenderRowOut(tenderRow)
convertTenderRowOut(tenderRow, tender)
)
if (null === this.currentTender) {
return
Expand All @@ -153,12 +153,12 @@ export const useTenderStore = defineStore('tender', {
notifyError('Error while adding tender row: ', err)
}
},
async editTenderRow(tenderRow: TenderRow) {
async editTenderRow(tenderRow: TenderRow, tender: Tender) {
try {
const rawTenderRow = await ApiClient.query<TenderRow>(
HttpMethodEnum.PUT,
rowUrlPrefix + '/' + tenderRow.id,
convertTenderRowOut(tenderRow)
convertTenderRowOut(tenderRow, tender)
)
if (null === this.currentTender) {
return
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/views/tenders/TenderView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const confirmMessage = computed(() => ({
}))
const tender = computed(() => tenderStore.currentTender)
const tenderSoldDays = computed(() => tender.value.tenderRows.reduce((acc, tenderRow) => acc + tenderRow.soldDays, 0))
const isDeletable = computed(() => null === tender.value || tender.value.tenderRows.length === 0)
function showForm() {
isFormShowing.value = true
Expand Down Expand Up @@ -149,7 +150,7 @@ onMounted(async () => {
Statut: {{ tender.status.label }}
<mp3000-icon icon="circle-info" title="Historique" @click="showStatusLogsPopin" /><br />
TJM: {{ tender.averageDailyRate }}<br />
Jours vendus: {{ tender.soldDays }}<br />
Jours vendus: {{ tenderSoldDays }}<br />
Date d'envoi: {{ tender.sentAt?.format('YYYY-MM-DD') ?? '-' }}<br />
Date de commande: {{ tender.acceptedAt?.format('YYYY-MM-DD') ?? '-' }}<br />
Date de refus: {{ tender.refusedAt?.format('YYYY-MM-DD') ?? '-' }}<br />
Expand Down Expand Up @@ -235,8 +236,8 @@ onMounted(async () => {
/>
<tr class="total" v-if="tenderRowFilterSearch.length < 3">
<td colspan="2" class="text-end">Total:</td>
<td>{{ tender.soldDays }}</td>
<td>{{ tender.soldDays * tender.averageDailyRate }}€</td>
<td>{{ tenderSoldDays }}</td>
<td>{{ tenderSoldDays * tender.averageDailyRate }}€</td>
</tr>
</template>
</template>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/tenders/tenderRows/tenderRowForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ async function submit() {
}
isSubmitting.value = true
await ('id' in currentTenderRow.value
? tenderStore.editTenderRow(currentTenderRow.value)
: tenderStore.addTenderRow(currentTenderRow.value))
? tenderStore.editTenderRow(currentTenderRow.value, props.tender)
: tenderStore.addTenderRow(currentTenderRow.value, props.tender))
emit('stop-showing')
isSubmitting.value = false
}
Expand Down

0 comments on commit 6d88ba0

Please sign in to comment.