Skip to content

Commit

Permalink
Merge pull request #125 from moevm/123-more-client-orders-filters
Browse files Browse the repository at this point in the history
123 more client orders filters
  • Loading branch information
1that authored Dec 23, 2024
2 parents 686b411 + 32e9d68 commit 158748a
Show file tree
Hide file tree
Showing 6 changed files with 535 additions and 9 deletions.
31 changes: 31 additions & 0 deletions frontend/src/api/models/orderFilter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
interface OrderFilter {
user_id: string;
address_city: string;
address_street: string;
address_building: string;
address_entrance: string;
address_floor: string;
address_door_number: string;
price_min: number;
price_max: number;
pollution_min: number;
pollution_max: number;
area_min: number;
area_max: number;
number_of_rooms_min: number;
number_of_rooms_max: number;
number_of_bathrooms_min: number;
number_of_bathrooms_max: number;
required_workers_min: number;
required_workers_max: number;

worker_name: string;
worker_surname: string;
worker_patronymic: string;
statuses?: string[];
services?: string[];
date_time_begin: string;
date_time_end: string;
}

export default OrderFilter;
16 changes: 16 additions & 0 deletions frontend/src/api/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
import Order from './models/order'
import Service from './models/service'
import { FilterOrder } from './models/filterOrder'
import OrderFilter from './models/orderFilter' // для клиента
import { FilterWorkers } from './models/filterWorkers'

const baseURL = 'http://localhost:8080/api'
Expand Down Expand Up @@ -224,6 +225,21 @@ export async function getAllOrders(id: string | null): Promise<Order[]> {
})
}

export async function getFiltredOrders(filter: OrderFilter): Promise<Order[]> {
return axios.get(baseURL + getAllOrdersPath, {
params: filter,
paramsSerializer: {
indexes: null
}
})
.then((response) => {
return Promise.resolve(response.data)
})
.catch((error) => {
return Promise.reject(error);
})
}

export async function updateOrder(newOrder: Order): Promise<Order> {
return axios.put<Order>(baseURL + updateOrdersPath(newOrder.id!), newOrder)
.then((response) => {
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/components/admin/AdminOrdersPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,21 @@ function filtrationOrder(): void {
})
}
function formatToRFC3339(dateString: Date | null) {
if (dateString === null) return ''
let date = new Date(dateString);
date.setDate(date.getDate() + 1);
date = new Date(date.getTime() - 1);
return date.toISOString();
}
function submitSearch(): void {
filterOrder({
...filterData.value,
statuses: statuses.value,
services: selectedServiceIds.value,
date_time_begin: startDate.value?.toISOString(),
date_time_end: endDate.value?.toISOString()
date_time_end: formatToRFC3339(endDate.value)
})
.then((response) => {
orders.value = response
Expand Down Expand Up @@ -168,7 +176,7 @@ onMounted(() => {
</template>
</HeaderList>
<Dialog
title="Филтрация заказов"
title="Фильтрация заказов"
:visible="isDialogVisible"
dialogMaxWidth="40%"
@update:visible="closeDialog"
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/admin/AdminWorkersSettingsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ async function fetchWorkersList() {
}));
if (maxOrdersWorker.value === null) {
console.log("maxOrdersWorker null finde max orders")
maxOrdersWorker.value = Math.max(...workers.value.map(worker => worker.orders_count));
}
} catch (error) {
Expand Down
Loading

0 comments on commit 158748a

Please sign in to comment.