diff --git a/app/src/main/java/ru/ulstu/is/airticketrentservice/api/model/FlightRemote.kt b/app/src/main/java/ru/ulstu/is/airticketrentservice/api/model/FlightRemote.kt index 32e9709..3613d4c 100644 --- a/app/src/main/java/ru/ulstu/is/airticketrentservice/api/model/FlightRemote.kt +++ b/app/src/main/java/ru/ulstu/is/airticketrentservice/api/model/FlightRemote.kt @@ -12,7 +12,6 @@ data class FlightRemote( var direction_to: String = "", var departure_date: String = "", var arrival_date: String = "", - var tickets_count: Int = 0, val one_ticket_cost: Double = 0.0 ) @@ -22,7 +21,6 @@ fun FlightRemote.toFlight(): Flight = Flight( direction_to, departure_date, arrival_date, - tickets_count, one_ticket_cost ) @@ -32,6 +30,5 @@ fun Flight.toFlightRemote(): FlightRemote = FlightRemote( direction_to, departure_date, arrival_date, - tickets_count, one_ticket_cost ) \ No newline at end of file diff --git a/app/src/main/java/ru/ulstu/is/airticketrentservice/database/AppDatabase.kt b/app/src/main/java/ru/ulstu/is/airticketrentservice/database/AppDatabase.kt index 3ca4f4d..2f704ae 100644 --- a/app/src/main/java/ru/ulstu/is/airticketrentservice/database/AppDatabase.kt +++ b/app/src/main/java/ru/ulstu/is/airticketrentservice/database/AppDatabase.kt @@ -24,7 +24,7 @@ abstract class AppDatabase : RoomDatabase() { abstract fun remoteKeysDao(): RemoteKeysDao companion object { - private const val DB_NAME: String = "ticketservicedatabase5" + private const val DB_NAME: String = "ticketservicedatabase6" @Volatile private var INSTANCE: AppDatabase? = null @@ -51,12 +51,12 @@ abstract class AppDatabase : RoomDatabase() { rentDao.insert(rent5) rentDao.insert(rent6) val flightDao = database.flightDao() - val flight1 = Flight(1, "Ульяновск", "Москва","17-12-2023 16:00", "17-12-2023 19:00",50, 2539.4) - val flight2 = Flight(2, "Ульяновск", "Париж","18-12-2023 12:25", "19-12-2023 17:15",200, 8362.2) - val flight3 = Flight(3, "Ульяновск", "Сочи","24-12-2023 17:28", "24-12-2023 19:23", 100, 1934.5) - val flight4 = Flight(4, "Ульяновск", "Нижний Новгород","24-12-2023 08:10", "24-12-2023 10:00", 100, 1934.5) - val flight5 = Flight(5, "Ульяновск", "Самара","27-12-2023 13:00", "27-12-2023 14:00", 100, 1934.5) - val flight6 = Flight(6, "Ульяновск", "Крым","24-11-2023 17:25", "24-11-2023 19:50", 100, 1934.5) + val flight1 = Flight(1, "Ульяновск", "Москва","17-12-2023 16:00", "17-12-2023 19:00",2539.4) + val flight2 = Flight(2, "Ульяновск", "Париж","18-12-2023 12:25", "19-12-2023 17:15", 8362.2) + val flight3 = Flight(3, "Ульяновск", "Сочи","24-12-2023 17:28", "24-12-2023 19:23", 1934.5) + val flight4 = Flight(4, "Ульяновск", "Нижний Новгород","24-12-2023 08:10", "24-12-2023 10:00", 1934.5) + val flight5 = Flight(5, "Ульяновск", "Самара","27-12-2023 13:00", "27-12-2023 14:00", 1934.5) + val flight6 = Flight(6, "Ульяновск", "Крым","24-11-2023 17:25", "24-11-2023 19:50", 1934.5) flightDao.insert(flight1) flightDao.insert(flight2) flightDao.insert(flight3) diff --git a/app/src/main/java/ru/ulstu/is/airticketrentservice/database/models/Flight.kt b/app/src/main/java/ru/ulstu/is/airticketrentservice/database/models/Flight.kt index 2c3a57a..d5b53b1 100644 --- a/app/src/main/java/ru/ulstu/is/airticketrentservice/database/models/Flight.kt +++ b/app/src/main/java/ru/ulstu/is/airticketrentservice/database/models/Flight.kt @@ -11,7 +11,6 @@ data class Flight( var direction_to: String, var departure_date: String, var arrival_date: String, - var tickets_count: Int, val one_ticket_cost: Double ) { override fun equals(other: Any?): Boolean { diff --git a/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/FlightEdit.kt b/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/FlightEdit.kt index c955557..78c72a1 100644 --- a/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/FlightEdit.kt +++ b/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/FlightEdit.kt @@ -204,23 +204,6 @@ private fun FlightEdit( Text(text = flightUiState.flightDetails.arrival_date, fontSize = 15.sp, color = Color.DarkGray) - TextField( - modifier = Modifier - .fillMaxWidth() - .padding(10.dp), - value = flightUiState.flightDetails.tickets_count.toString(), - onValueChange = { onUpdate(flightUiState.flightDetails.copy(tickets_count = it.toInt())) }, - colors = TextFieldDefaults.textFieldColors( - containerColor = Color.LightGray.copy(.2f), - unfocusedIndicatorColor = Color.Transparent, - focusedIndicatorColor = Color.Transparent - ), - shape = RoundedCornerShape(15.dp), - label = { Text("Количество билетов") }, - singleLine = true, - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number) - ) - TextField( modifier = Modifier .fillMaxWidth() diff --git a/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/FlightInfo.kt b/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/FlightInfo.kt index ddcd85c..e6d3ffa 100644 --- a/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/FlightInfo.kt +++ b/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/FlightInfo.kt @@ -123,23 +123,6 @@ private fun FlightInfo( readOnly = true ) - TextField( - modifier = Modifier - .fillMaxWidth() - .padding(10.dp), - value = flightUiState.flightDetails.tickets_count.toString(), - onValueChange = { }, - colors = TextFieldDefaults.textFieldColors( - containerColor = Color.LightGray.copy(.2f), - unfocusedIndicatorColor = Color.Transparent, - focusedIndicatorColor = Color.Transparent - ), - shape = RoundedCornerShape(15.dp), - label = { Text("Количество билетов") }, - singleLine = true, - readOnly = true - ) - TextField( modifier = Modifier .fillMaxWidth() diff --git a/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/RentStatusEdit.kt b/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/RentStatusEdit.kt new file mode 100644 index 0000000..9e7eb5f --- /dev/null +++ b/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/RentStatusEdit.kt @@ -0,0 +1,200 @@ +package ru.ulstu.`is`.airticketrentservice.screen + +import android.annotation.SuppressLint +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.DropdownMenuItem +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.ExposedDropdownMenuBox +import androidx.compose.material3.ExposedDropdownMenuDefaults +import androidx.compose.material3.Text +import androidx.compose.material3.TextField +import androidx.compose.material3.TextFieldDefaults +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.colorResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import androidx.lifecycle.viewmodel.compose.viewModel +import androidx.navigation.NavController +import kotlinx.coroutines.launch +import ru.ulstu.`is`.airticketrentservice.R +import ru.ulstu.`is`.airticketrentservice.viewModel.AppViewModelProvider +import ru.ulstu.`is`.airticketrentservice.viewModel.RentDetails +import ru.ulstu.`is`.airticketrentservice.viewModel.RentEditViewModel +import ru.ulstu.`is`.airticketrentservice.viewModel.RentUiState +import ru.ulstu.`is`.airticketrentservice.viewModel.TicketEditViewModel +import ru.ulstu.`is`.airticketrentservice.viewModel.TicketUiState +import ru.ulstu.`is`.airticketrentservice.viewModel.UserEditViewModel +import ru.ulstu.`is`.airticketrentservice.viewModel.UserUiState + +@SuppressLint("UnrememberedMutableState") +@Composable +fun RentStatusEdit( + navController: NavController, + viewModel: RentEditViewModel = viewModel(factory = AppViewModelProvider.Factory), + userViewModel: UserEditViewModel = viewModel(factory = AppViewModelProvider.Factory), + ticketViewModel: TicketEditViewModel = viewModel(factory = AppViewModelProvider.Factory) +) { + val coroutineScope = rememberCoroutineScope() + userViewModel.setCurrentUser(viewModel.rentUiState.rentDetails.userId) + ticketViewModel.setCurrentTicket(viewModel.rentUiState.rentDetails.ticketId) + RentStatusEdit( + rentUiState = viewModel.rentUiState, + userUiState = userViewModel.userUiState, + ticketUiState = ticketViewModel.ticketUiState, + onClick = { + coroutineScope.launch { + viewModel.saveRent() + navController.popBackStack() + } + }, + onUpdate = viewModel::updateUiState + ) +} + + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +private fun RentStatusEdit( + rentUiState: RentUiState, + userUiState: UserUiState, + ticketUiState: TicketUiState, + onClick: () -> Unit, + onUpdate: (RentDetails) -> Unit +) { + Column( + Modifier + .fillMaxWidth() + .padding(all = 10.dp) + ) { + TextField( + value = rentUiState.rentDetails.ticketId.toString(), + onValueChange = { onUpdate(rentUiState.rentDetails.copy(ticketId = it.toInt())) }, + modifier = Modifier.fillMaxWidth().padding(all = 5.dp), + colors = TextFieldDefaults.colors( + focusedContainerColor = Color.LightGray.copy(.2f), + unfocusedContainerColor = Color.LightGray.copy(.2f), + disabledContainerColor = Color.LightGray.copy(.2f), + focusedIndicatorColor = Color.Transparent, + unfocusedIndicatorColor = Color.Transparent, + ), + shape = RoundedCornerShape(15.dp), + label = { + Text("Номер билета") + } + ) + TextField( + value = "${userUiState.userDetails.surname} ${userUiState.userDetails.name} ${userUiState.userDetails.patronymic}", + onValueChange = {}, + readOnly = true, + modifier = Modifier.fillMaxWidth().padding(all = 5.dp), + colors = TextFieldDefaults.colors( + focusedContainerColor = Color.LightGray.copy(.2f), + unfocusedContainerColor = Color.LightGray.copy(.2f), + disabledContainerColor = Color.LightGray.copy(.2f), + focusedIndicatorColor = Color.Transparent, + unfocusedIndicatorColor = Color.Transparent, + ), + shape = RoundedCornerShape(15.dp), + label = { + Text("Пользователь") + } + ) + var expanded by remember { mutableStateOf(false) } + + Box( + modifier = Modifier.fillMaxWidth().padding(all = 5.dp).clip(RoundedCornerShape(15.dp)) + ) { + ExposedDropdownMenuBox( + modifier = Modifier.fillMaxWidth(), + expanded = expanded, + onExpandedChange = { expanded = !expanded }, + ) + { + TextField( + value = rentUiState.rentDetails.status, + onValueChange = {}, + readOnly = true, + trailingIcon = { + ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded) + }, + modifier = Modifier.menuAnchor().fillMaxWidth(), + colors = TextFieldDefaults.colors( + focusedContainerColor = Color.LightGray.copy(.2f), + unfocusedContainerColor = Color.LightGray.copy(.2f), + disabledContainerColor = Color.LightGray.copy(.2f), + focusedIndicatorColor = Color.Transparent, + unfocusedIndicatorColor = Color.Transparent, + ), + shape = RoundedCornerShape(15.dp), + label = { + Text(stringResource(id = R.string.rent_status)) + } + ) + ExposedDropdownMenu( + expanded = expanded, + onDismissRequest = { expanded = false }, + modifier = Modifier + .background(Color.LightGray.copy(.2f)) + .exposedDropdownSize() + .fillMaxWidth() + ) { + DropdownMenuItem( + modifier = Modifier.fillMaxWidth().clip(RoundedCornerShape(15.dp)), + text = { Text("Подтверждено") }, + onClick = { + onUpdate(rentUiState.rentDetails.copy(status = "Подтверждено")) + expanded = false + } + ) + DropdownMenuItem( + modifier = Modifier.fillMaxWidth().clip(RoundedCornerShape(15.dp)), + text = { Text("Ожидает подтверждения") }, + onClick = { + onUpdate(rentUiState.rentDetails.copy(status = "Ожидает подтверждения")) + expanded = false + } + ) + DropdownMenuItem( + modifier = Modifier.fillMaxWidth().clip(RoundedCornerShape(15.dp)), + text = { Text("Отклонено") }, + onClick = { + onUpdate(rentUiState.rentDetails.copy(status = "Отклонено")) + expanded = false + } + ) + } + } + } + Button( + enabled = rentUiState.isEntryValid, + modifier = Modifier + .fillMaxWidth() + .padding(all = 10.dp), + onClick = onClick, + elevation = ButtonDefaults.buttonElevation( + defaultElevation = 10.dp, + pressedElevation = 6.dp + ), + shape = RoundedCornerShape(15.dp), + colors = ButtonDefaults.buttonColors(containerColor = colorResource(R.color.lightBlue)), + content = { + Text(text = stringResource(R.string.rent_save_button)) + } + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/TicketEdit.kt b/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/TicketEdit.kt index ff17825..8f46598 100644 --- a/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/TicketEdit.kt +++ b/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/TicketEdit.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.DropdownMenu @@ -34,6 +35,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel import androidx.navigation.NavController @@ -202,7 +204,8 @@ private fun TicketEdit( ), shape = RoundedCornerShape(15.dp), label = { Text("Количество пассажиров") }, - singleLine = true + singleLine = true, + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number) ) LaunchedEffect(totalCost) { ticketCost.doubleValue = totalCost diff --git a/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/TicketView.kt b/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/TicketView.kt index 393b014..34b9857 100644 --- a/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/TicketView.kt +++ b/app/src/main/java/ru/ulstu/is/airticketrentservice/screen/TicketView.kt @@ -23,6 +23,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableDoubleStateOf +import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope @@ -43,6 +44,7 @@ import ru.ulstu.`is`.airticketrentservice.database.models.Flight import ru.ulstu.`is`.airticketrentservice.navigation.BottomBarScreen import ru.ulstu.`is`.airticketrentservice.viewModel.AppViewModelProvider import ru.ulstu.`is`.airticketrentservice.viewModel.CurrentUserViewModel +import ru.ulstu.`is`.airticketrentservice.viewModel.FlightDetails import ru.ulstu.`is`.airticketrentservice.viewModel.FlightDropDownUiState import ru.ulstu.`is`.airticketrentservice.viewModel.FlightDropDownViewModel import ru.ulstu.`is`.airticketrentservice.viewModel.FlightEditViewModel @@ -52,6 +54,7 @@ import ru.ulstu.`is`.airticketrentservice.viewModel.RentEditViewModel import ru.ulstu.`is`.airticketrentservice.viewModel.TicketDetails import ru.ulstu.`is`.airticketrentservice.viewModel.TicketUiState import ru.ulstu.`is`.airticketrentservice.viewModel.TicketViewViewModel +import ru.ulstu.`is`.airticketrentservice.viewModel.toDetails import ru.ulstu.`is`.airticketrentservice.viewModel.toTicket @Composable @@ -65,19 +68,15 @@ fun TicketView( val coroutineScope = rememberCoroutineScope() flightViewModel.setCurrentDropDownFlight(viewModel.flightId) val currentUser by remember { mutableStateOf(currentUserViewModel.user) } - TicketEdit( + TicketView( ticketUiState = viewModel.ticketUiState, flightUiState = flightViewModel.flightDropDownUiState, onClick = { coroutineScope.launch { - Log.d("TicketView", "Текущий пользователь: $currentUser") - Log.d("TicketView", "Стоимость билета: ${viewModel.ticketUiState.ticketDetails.ticket_cost}") - Log.d("TicketView", "Текущий рейс для билета: ${viewModel.flightId}") viewModel.saveNewTicket(viewModel.flightId) viewModel.savedTicket.collect { id -> - Log.d("TicketView", "Текущий билет: $id") currentUser?.let { id?.toInt() - ?.let { it1 -> rentEditViewModel.saveNewRent(it.id, it1) } }} + ?.let { it1 -> rentEditViewModel.saveNewRent(it.id, it1) } } } } navController.navigate(BottomBarScreen.Profile.route) }, @@ -163,7 +162,7 @@ private fun FlightView( @SuppressLint("UnrememberedMutableState") @OptIn(ExperimentalMaterial3Api::class) @Composable -private fun TicketEdit( +private fun TicketView( ticketUiState: TicketUiState, flightUiState: FlightDropDownUiState, onClick: () -> Unit, @@ -190,8 +189,6 @@ private fun TicketEdit( } val ticketCost = remember { mutableDoubleStateOf(totalCost) } - Log.d("TicketView", "Текущий рейс: ${flightUiState.flight}") - TextField( modifier = Modifier .fillMaxWidth() diff --git a/app/src/main/java/ru/ulstu/is/airticketrentservice/viewModel/FlightDropDownViewModel.kt b/app/src/main/java/ru/ulstu/is/airticketrentservice/viewModel/FlightDropDownViewModel.kt index 03c00fe..3ef06b1 100644 --- a/app/src/main/java/ru/ulstu/is/airticketrentservice/viewModel/FlightDropDownViewModel.kt +++ b/app/src/main/java/ru/ulstu/is/airticketrentservice/viewModel/FlightDropDownViewModel.kt @@ -49,6 +49,5 @@ fun Flight.toUiState() = FlightDropDownUiState(flight = Flight( direction_to = direction_to, departure_date = departure_date, arrival_date = arrival_date, - tickets_count = tickets_count, one_ticket_cost = one_ticket_cost )) \ No newline at end of file diff --git a/app/src/main/java/ru/ulstu/is/airticketrentservice/viewModel/FlightEditViewModel.kt b/app/src/main/java/ru/ulstu/is/airticketrentservice/viewModel/FlightEditViewModel.kt index db8097c..a314e0b 100644 --- a/app/src/main/java/ru/ulstu/is/airticketrentservice/viewModel/FlightEditViewModel.kt +++ b/app/src/main/java/ru/ulstu/is/airticketrentservice/viewModel/FlightEditViewModel.kt @@ -59,7 +59,6 @@ class FlightEditViewModel( && direction_to.isNotBlank() && departure_date.isNotBlank() && arrival_date.isNotBlank() - && tickets_count > 0 && one_ticket_cost > 0 } } @@ -76,7 +75,6 @@ data class FlightDetails( val direction_to: String = "", val departure_date: String = "", val arrival_date: String = "", - val tickets_count: Int = 0, val one_ticket_cost: Double = 0.0 ) @@ -86,7 +84,6 @@ fun FlightDetails.toFlight(id: Int = 0): Flight = Flight( direction_to = direction_to, departure_date = departure_date, arrival_date = arrival_date, - tickets_count = tickets_count, one_ticket_cost = one_ticket_cost ) @@ -95,7 +92,6 @@ fun Flight.toDetails(): FlightDetails = FlightDetails( direction_to = direction_to, departure_date = departure_date, arrival_date = arrival_date, - tickets_count = tickets_count, one_ticket_cost = one_ticket_cost ) diff --git a/server/data.json b/server/data.json index 99b4372..3a502b7 100644 --- a/server/data.json +++ b/server/data.json @@ -11,126 +11,6 @@ "passengers_count": 2, "ticket_cost": 4870, "flightId": 5 - }, - { - "passengers_count": 5, - "ticket_cost": 54000, - "flightId": 10, - "id": 3 - }, - { - "passengers_count": 1, - "ticket_cost": 2680, - "flightId": 6, - "id": 4 - }, - { - "passengers_count": 3, - "ticket_cost": 26160, - "flightId": 8, - "id": 5 - }, - { - "passengers_count": 5, - "ticket_cost": 54000, - "flightId": 10, - "id": 6 - }, - { - "passengers_count": 4, - "ticket_cost": 71200, - "flightId": 9, - "id": 7 - }, - { - "passengers_count": 6, - "ticket_cost": 106800, - "flightId": 9, - "id": 9 - }, - { - "passengers_count": 6, - "ticket_cost": 106800, - "flightId": 9, - "id": 10 - }, - { - "passengers_count": 6, - "ticket_cost": 106800, - "flightId": 9, - "id": 11 - }, - { - "passengers_count": 11, - "ticket_cost": 29480, - "flightId": 6, - "id": 12 - }, - { - "passengers_count": 3, - "ticket_cost": 8040, - "flightId": 6, - "id": 13 - }, - { - "passengers_count": 8, - "ticket_cost": 142400, - "flightId": 9, - "id": 14 - }, - { - "passengers_count": 1, - "ticket_cost": 2680, - "flightId": 6, - "id": 15 - }, - { - "passengers_count": 1, - "ticket_cost": 2680, - "flightId": 6, - "id": 16 - }, - { - "passengers_count": 1, - "ticket_cost": 2680, - "flightId": 6, - "id": 17 - }, - { - "passengers_count": 1, - "ticket_cost": 17800, - "flightId": 9, - "id": 18 - }, - { - "passengers_count": 5, - "ticket_cost": 5000, - "flightId": 2, - "id": 19 - }, - { - "passengers_count": 6, - "ticket_cost": 6000, - "flightId": 2, - "id": 20 - }, - { - "passengers_count": 3, - "ticket_cost": 3000, - "flightId": 2, - "id": 21 - }, - { - "passengers_count": 10, - "ticket_cost": 10000, - "flightId": 2, - "id": 22 - }, - { - "passengers_count": 6, - "ticket_cost": 6000, - "flightId": 2, - "id": 23 } ], "flights": [ @@ -140,7 +20,6 @@ "direction_to": "b", "departure_date": "1-1-2024", "arrival_date": "1-1-2024", - "tickets_count": 100, "one_ticket_cost": 1000 }, { @@ -148,7 +27,6 @@ "direction_to": "Сочи", "departure_date": "17-12-2023", "arrival_date": "17-12-2023", - "tickets_count": 320, "one_ticket_cost": 2435, "id": 5 }, @@ -158,7 +36,6 @@ "direction_to": "Москва", "departure_date": "26-12-2023", "arrival_date": "26-12-2023", - "tickets_count": 50, "one_ticket_cost": 2680 }, { @@ -167,7 +44,6 @@ "direction_to": "Кострома", "departure_date": "5-1-2024", "arrival_date": "5-1-2024", - "tickets_count": 200, "one_ticket_cost": 6870 }, { @@ -175,7 +51,6 @@ "direction_to": "Нижний Новгород", "departure_date": "28-1-2024", "arrival_date": "28-1-2024", - "tickets_count": 68, "one_ticket_cost": 8720, "id": 8 }, @@ -184,7 +59,6 @@ "direction_to": "Мурманск", "departure_date": "27-1-2024", "arrival_date": "28-1-2024", - "tickets_count": 100, "one_ticket_cost": 17800, "id": 9 }, @@ -193,7 +67,6 @@ "direction_to": "Астана", "departure_date": "14-1-2024", "arrival_date": "15-1-2024", - "tickets_count": 200, "one_ticket_cost": 10800, "id": 10 } @@ -219,36 +92,6 @@ "role": "User", "id": 3 }, - { - "surname": "ыщылы", - "name": "шчшчгч", - "patronymic": "шчшчшч", - "date_of_birth": "10-12-2015", - "email": "aaa@mail.ru", - "password": "aaa", - "role": "User", - "id": 4 - }, - { - "surname": "фффф", - "name": "ффф", - "patronymic": "ффф", - "date_of_birth": "7-5-2005", - "email": "userff@mail.ru", - "password": "password", - "role": "User", - "id": 6 - }, - { - "surname": "ккк", - "name": "ккк", - "patronymic": "ккк", - "date_of_birth": "23-12-2011", - "email": "kkk@mail.ru", - "password": "kkk", - "role": "User", - "id": 7 - }, { "id": 8, "surname": "Артамонова", @@ -261,23 +104,17 @@ } ], "rents": [ - { + { "id": 1, "status": "Ожидает подтверждения", "userId": 2, "ticketId": 1 }, - { + { "id": 2, "status": "Ожидает подтверждения", "userId": 2, "ticketId": 2 }, - { - "id": 3, - "status": "Ожидает подтверждения", - "userId": 2, - "ticketId": 3 - } ] } \ No newline at end of file diff --git a/server/data.json.bak b/server/data.json.bak index ddeb29a..4fd0dd8 100644 --- a/server/data.json.bak +++ b/server/data.json.bak @@ -131,6 +131,42 @@ "ticket_cost": 6000, "flightId": 2, "id": 23 + }, + { + "passengers_count": 9, + "ticket_cost": 160200, + "flightId": 9, + "id": 24 + }, + { + "passengers_count": 8, + "ticket_cost": 142400, + "flightId": 9, + "id": 25 + }, + { + "passengers_count": 3, + "ticket_cost": 53400, + "flightId": 9, + "id": 26 + }, + { + "passengers_count": 6, + "ticket_cost": 106800, + "flightId": 9, + "id": 27 + }, + { + "passengers_count": 5, + "ticket_cost": 89000, + "flightId": 9, + "id": 28 + }, + { + "passengers_count": 3, + "ticket_cost": 20610, + "flightId": 7, + "id": 29 } ], "flights": [ @@ -140,7 +176,6 @@ "direction_to": "b", "departure_date": "1-1-2024", "arrival_date": "1-1-2024", - "tickets_count": 100, "one_ticket_cost": 1000 }, { @@ -148,7 +183,6 @@ "direction_to": "Сочи", "departure_date": "17-12-2023", "arrival_date": "17-12-2023", - "tickets_count": 320, "one_ticket_cost": 2435, "id": 5 }, @@ -158,7 +192,6 @@ "direction_to": "Москва", "departure_date": "26-12-2023", "arrival_date": "26-12-2023", - "tickets_count": 50, "one_ticket_cost": 2680 }, { @@ -167,7 +200,6 @@ "direction_to": "Кострома", "departure_date": "5-1-2024", "arrival_date": "5-1-2024", - "tickets_count": 200, "one_ticket_cost": 6870 }, { @@ -175,7 +207,6 @@ "direction_to": "Нижний Новгород", "departure_date": "28-1-2024", "arrival_date": "28-1-2024", - "tickets_count": 68, "one_ticket_cost": 8720, "id": 8 }, @@ -184,7 +215,6 @@ "direction_to": "Мурманск", "departure_date": "27-1-2024", "arrival_date": "28-1-2024", - "tickets_count": 100, "one_ticket_cost": 17800, "id": 9 }, @@ -193,7 +223,6 @@ "direction_to": "Астана", "departure_date": "14-1-2024", "arrival_date": "15-1-2024", - "tickets_count": 200, "one_ticket_cost": 10800, "id": 10 } @@ -260,5 +289,54 @@ "role": "Admin" } ], - "rents": [] + "rents": [ + { + "id": 1, + "status": "Ожидает подтверждения", + "userId": 2, + "ticketId": 1 + }, + { + "id": 2, + "status": "Ожидает подтверждения", + "userId": 2, + "ticketId": 2 + }, + { + "status": "Ожидает подтверждения", + "userId": 2, + "ticketId": 24, + "id": 3 + }, + { + "status": "Ожидает подтверждения", + "userId": 2, + "ticketId": 25, + "id": 4 + }, + { + "status": "Ожидает подтверждения", + "userId": 2, + "ticketId": 26, + "id": 5 + }, + { + "status": "Ожидает подтверждения", + "userId": 2, + "ticketId": 27, + "id": 6 + }, + { + "status": "Ожидает подтверждения", + "userId": 2, + "ticketId": 28, + "id": 7 + }, + { + "status": "Ожидает подтверждения", + "userId": 8, + "ticketId": 29, + "id": 8 + } + ] } \ No newline at end of file