update delivery note form
This commit is contained in:
@@ -28,7 +28,7 @@ import {firstValueFrom} from "rxjs";
|
||||
})
|
||||
export class DelivereryNoteForm implements OnInit {
|
||||
deliveryNoteForm: FormGroup = new FormGroup({
|
||||
trackingNumber: new FormControl<string>("TRK-" + Date.now),
|
||||
trackingNumber: new FormControl<string>(null),
|
||||
deliverer: new FormControl<string>(null,[Validators.required]),
|
||||
expeditionDate: new FormControl(null,[Validators.required]),
|
||||
estimatedDate: new FormControl(null),
|
||||
|
||||
@@ -145,8 +145,19 @@ export class DelivereryNoteTable implements OnInit {
|
||||
}
|
||||
|
||||
try {
|
||||
const estimateDate = updateDelivereryNoteComponent.deliveryNoteForm.get('estimatedDate').value;
|
||||
const expeditionDate = updateDelivereryNoteComponent.deliveryNoteForm.get('expeditionDate').value;
|
||||
const realDate = updateDelivereryNoteComponent.deliveryNoteForm.get('realDeliveryDate').value;
|
||||
|
||||
const estimateDateResult = format(estimateDate, 'yyyy-MM-dd');
|
||||
const expeditionDateResult = format(expeditionDate, 'yyyy-MM-dd');
|
||||
const realDateResult = format(realDate, 'yyyy-MM-dd');
|
||||
|
||||
const deliveryNotes = updateDelivereryNoteComponent.deliveryNoteForm.getRawValue();
|
||||
deliveryNotes.estimatedDate = estimateDateResult;
|
||||
deliveryNotes.expeditionDate = expeditionDateResult;
|
||||
deliveryNotes.realDeliveryDate = realDateResult;
|
||||
|
||||
await firstValueFrom(this.deliveryNotesService.updateDeliveryNoteEndpoint(id, deliveryNotes))
|
||||
|
||||
this.notificationService.success(
|
||||
@@ -154,7 +165,6 @@ export class DelivereryNoteTable implements OnInit {
|
||||
'Bon de livraison modifié'
|
||||
)
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
this.notificationService.error(
|
||||
'Erreur',
|
||||
'Erreur lors de la modification'
|
||||
|
||||
@@ -58,6 +58,7 @@ model/patch-supplier-delivery-delay-dto.ts
|
||||
model/patch-user-password-dto.ts
|
||||
model/patch-ware-house-product-quantity-dto.ts
|
||||
model/update-deliverer-dto.ts
|
||||
model/update-delivery-note-dto.ts
|
||||
model/update-product-dto.ts
|
||||
model/update-supplier-dto.ts
|
||||
model/update-user-dto.ts
|
||||
|
||||
@@ -22,6 +22,8 @@ import { CreateDeliveryNoteDto } from '../model/create-delivery-note-dto';
|
||||
import { GetDeliveryNoteDto } from '../model/get-delivery-note-dto';
|
||||
// @ts-ignore
|
||||
import { PatchDeliveryNoteRealDeliveryDateDto } from '../model/patch-delivery-note-real-delivery-date-dto';
|
||||
// @ts-ignore
|
||||
import { UpdateDeliveryNoteDto } from '../model/update-delivery-note-dto';
|
||||
|
||||
// @ts-ignore
|
||||
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
||||
@@ -371,4 +373,72 @@ export class DeliverynotesService extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @endpoint put /API/deliveryNotes/{id}
|
||||
* @param id
|
||||
* @param updateDeliveryNoteDto
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public updateDeliveryNoteEndpoint(id: number, updateDeliveryNoteDto: UpdateDeliveryNoteDto, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<GetDeliveryNoteDto>;
|
||||
public updateDeliveryNoteEndpoint(id: number, updateDeliveryNoteDto: UpdateDeliveryNoteDto, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<GetDeliveryNoteDto>>;
|
||||
public updateDeliveryNoteEndpoint(id: number, updateDeliveryNoteDto: UpdateDeliveryNoteDto, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<GetDeliveryNoteDto>>;
|
||||
public updateDeliveryNoteEndpoint(id: number, updateDeliveryNoteDto: UpdateDeliveryNoteDto, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (id === null || id === undefined) {
|
||||
throw new Error('Required parameter id was null or undefined when calling updateDeliveryNoteEndpoint.');
|
||||
}
|
||||
if (updateDeliveryNoteDto === null || updateDeliveryNoteDto === undefined) {
|
||||
throw new Error('Required parameter updateDeliveryNoteDto was null or undefined when calling updateDeliveryNoteEndpoint.');
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
|
||||
'application/json'
|
||||
]);
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
|
||||
|
||||
const localVarTransferCache: boolean = options?.transferCache ?? true;
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
'application/json'
|
||||
];
|
||||
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||
if (localVarHttpHeaderAcceptSelected) {
|
||||
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
||||
responseType_ = 'json';
|
||||
} else {
|
||||
responseType_ = 'blob';
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/API/deliveryNotes/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<GetDeliveryNoteDto>('put', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
body: updateDeliveryNoteDto,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ export * from './patch-supplier-delivery-delay-dto';
|
||||
export * from './patch-user-password-dto';
|
||||
export * from './patch-ware-house-product-quantity-dto';
|
||||
export * from './update-deliverer-dto';
|
||||
export * from './update-delivery-note-dto';
|
||||
export * from './update-product-dto';
|
||||
export * from './update-supplier-dto';
|
||||
export * from './update-user-dto';
|
||||
|
||||
19
src/app/services/api/model/update-delivery-note-dto.ts
Normal file
19
src/app/services/api/model/update-delivery-note-dto.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* PyroFetes
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface UpdateDeliveryNoteDto {
|
||||
trackingNumber?: string | null;
|
||||
estimateDeliveryDate?: string;
|
||||
expeditionDate?: string;
|
||||
realDeliveryDate?: string | null;
|
||||
delivererId?: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user