Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] 내 상점 정보 수정 api 연동 #322

Merged
merged 32 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3fda243
Change StoreWithMenu->StoreDetailInfo
skdud0629 Jul 14, 2024
d807e15
Add modify owner shop info api
skdud0629 Jul 14, 2024
5ba0988
Add toStoreDetailInfo and toOperatingTime Mapper
skdud0629 Jul 14, 2024
8157c95
Modify MyStoreInfoList
skdud0629 Jul 14, 2024
8df2a97
Add button click event
skdud0629 Jul 14, 2024
b22463f
Merge remote-tracking branch 'origin/develop' into modify-store-info
skdud0629 Jul 14, 2024
a238540
Modify days_one_letter string array
skdud0629 Jul 15, 2024
bb36f46
Add dayOfWeekToIndex
skdud0629 Jul 15, 2024
67ed84e
Delete operatingTimeList and Add storeInfo state
skdud0629 Jul 15, 2024
b07b2ed
Add modifyInfoViewModel to ModifyInfoNavigator
skdud0629 Jul 15, 2024
c01a6ce
Change storeInfo from nullable to non-nullable.
skdud0629 Jul 15, 2024
8ac42a0
Change parameter structures and storeInfo update functions in ModifyI…
skdud0629 Jul 15, 2024
e7ce6d3
Modify store operating time logic
skdud0629 Jul 15, 2024
713269d
Modify resource id and Change state, viewmodel
skdud0629 Jul 15, 2024
ebc96dd
Delete unnecessary code
skdud0629 Jul 15, 2024
96f60dc
Add store operating hours update logic
skdud0629 Jul 15, 2024
ab6a91c
Modify store info initialization
skdud0629 Jul 15, 2024
db6c605
Add store navigation logic
skdud0629 Jul 15, 2024
9a52d02
Add Navigation and LaunchedEffect
skdud0629 Jul 16, 2024
09e5583
Change usecase name AttachStoreFileUseCase ->GetPresignedUrlUseCase
skdud0629 Jul 16, 2024
f9a3ecf
Delete unnecessary code
skdud0629 Jul 16, 2024
5340219
가게 대표 이미지 변경
skdud0629 Jul 16, 2024
5493b19
Modify to handle ViewModel logic at the top level
skdud0629 Jul 16, 2024
deb6f49
Modify OperatingTimeSettingDialog to use callbacks
skdud0629 Jul 16, 2024
b1a94c7
Modify GetOwnerShopInfoUseCase to use Result
skdud0629 Jul 16, 2024
c16173b
Modify init store info logic
skdud0629 Jul 16, 2024
475031b
Merge branch 'modify-store-info' into feature/business/moify-store-info
skdud0629 Jul 16, 2024
2b2929f
Change forEachIndexed->itemsIndexed
skdud0629 Jul 17, 2024
53ac06d
Add itemsIndexed import
skdud0629 Jul 17, 2024
fb5210d
Merge remote-tracking branch 'origin/develop' into feature/business/m…
skdud0629 Jul 17, 2024
11d68c0
Modify wrong code
skdud0629 Jul 17, 2024
c80eb07
Delete annotation
skdud0629 Jul 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ import androidx.hilt.navigation.compose.hiltViewModel
import com.chargemap.compose.numberpicker.FullHours
import com.chargemap.compose.numberpicker.Hours
import com.chargemap.compose.numberpicker.HoursNumberPicker
import `in`.koreatech.business.feature.insertstore.insertdetailinfo.InsertDetailInfoScreenViewModel
import `in`.koreatech.business.feature.insertstore.insertdetailinfo.dialog.OperatingTimeDialog
import `in`.koreatech.business.ui.theme.ColorPrimary
import `in`.koreatech.business.ui.theme.ColorSecondaryText
import `in`.koreatech.business.ui.theme.ColorTextBackgrond
import `in`.koreatech.koin.core.R
import org.orbitmvi.orbit.compose.collectAsState
import `in`.koreatech.business.feature.insertstore.insertdetailinfo.InsertDetailInfoScreenViewModel
import `in`.koreatech.business.feature.insertstore.insertdetailinfo.dialog.OperatingTimeDialog
import `in`.koreatech.business.ui.theme.ColorPrimary

@Composable
fun OperatingTimeSettingScreen(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
package `in`.koreatech.business.feature.insertstore.insertmaininfo

import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.net.Uri
import android.util.Log
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import `in`.koreatech.koin.core.upload.toCompressJPEG
import `in`.koreatech.koin.domain.usecase.business.UploadFileUseCase
import `in`.koreatech.koin.domain.usecase.owner.AttachStoreFileUseCase
import `in`.koreatech.koin.domain.usecase.presignedurl.GetMarketPreSignedUrlUseCase
import `in`.koreatech.koin.domain.usecase.presignedurl.UploadPreSignedUrlUseCase
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.orbitmvi.orbit.Container
import org.orbitmvi.orbit.ContainerHost
import org.orbitmvi.orbit.syntax.simple.intent
import org.orbitmvi.orbit.syntax.simple.postSideEffect
import org.orbitmvi.orbit.syntax.simple.reduce
import org.orbitmvi.orbit.viewmodel.container
import java.io.ByteArrayOutputStream
import java.io.InputStream
import javax.inject.Inject

@HiltViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ fun BusinessAuthScreen(
val context = LocalContext.current
val businessAuthState = businessAuthViewModel.collectAsState().value
val accountSetupState = accountSetupViewModel.collectAsState().value


val multiplePhotoPickerLauncher = rememberLauncherForActivityResult(
contract = ActivityResultContracts.PickMultipleVisualMedia(5),
onResult = { uriList ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import `in`.koreatech.koin.data.mapper.strToOwnerRegisterUrl
import `in`.koreatech.koin.domain.model.store.AttachStore
import `in`.koreatech.koin.domain.model.store.StoreUrl
import `in`.koreatech.koin.domain.usecase.business.UploadFileUseCase
import `in`.koreatech.koin.domain.usecase.owner.AttachStoreFileUseCase
import `in`.koreatech.koin.domain.usecase.owner.GetPresignedUrlUseCase
import `in`.koreatech.koin.domain.usecase.owner.OwnerRegisterUseCase
import `in`.koreatech.koin.domain.util.ext.formatBusinessNumber
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.orbitmvi.orbit.ContainerHost
import org.orbitmvi.orbit.syntax.simple.intent
Expand All @@ -24,7 +23,7 @@ import javax.inject.Inject

@HiltViewModel
class BusinessAuthViewModel @Inject constructor(
private val getPresignedUrlUseCase: AttachStoreFileUseCase,
private val getPresignedUrlUseCase: GetPresignedUrlUseCase,
private val uploadFilesUseCase: UploadFileUseCase,
private val ownerRegisterUseCase: OwnerRegisterUseCase
) : ContainerHost<BusinessAuthState, BusinessAuthSideEffect>, ViewModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
Expand All @@ -45,21 +46,24 @@ import `in`.koreatech.business.ui.theme.ColorSecondary
import `in`.koreatech.business.ui.theme.Gray2
import `in`.koreatech.business.ui.theme.Gray6
import `in`.koreatech.business.ui.theme.Gray9
import `in`.koreatech.koin.domain.util.DateFormatUtil.dayOfWeekToIndex
import `in`.koreatech.koin.domain.util.StoreUtil
import org.orbitmvi.orbit.compose.collectAsState
import org.orbitmvi.orbit.compose.collectSideEffect


@Composable
fun ModifyInfoScreen(
modifier: Modifier = Modifier,
onBackClicked: () -> Unit = {},
viewModel: ModifyInfoViewModel = hiltViewModel(),
storeInfoViewModel: MyStoreDetailViewModel = hiltViewModel(),
onSettingOperatingClicked: () -> Unit = {},
) {
val storeInfoViewModel: MyStoreDetailViewModel = hiltViewModel()
val state = viewModel.collectAsState().value
val storeInfoState = storeInfoViewModel.collectAsState().value
val listState = rememberLazyListState()
val context = LocalContext.current

Column {
Box(
modifier = Modifier
Expand All @@ -68,13 +72,13 @@ fun ModifyInfoScreen(
) {
IconButton(onClick = { viewModel.onBackButtonClicked() }) {
Image(
painter = painterResource(id = `in`.koreatech.koin.core.R.drawable.ic_flyer_before_arrow),
contentDescription = stringResource(`in`.koreatech.koin.core.R.string.back),
painter = painterResource(id = R.drawable.ic_flyer_before_arrow),
contentDescription = stringResource(R.string.back),
colorFilter = ColorFilter.tint(Color.White),
)
}
Text(
text = stringResource(id = `in`.koreatech.koin.core.R.string.my_shop),
text = stringResource(id = R.string.my_shop),
modifier = Modifier.align(Alignment.Center),
style = TextStyle(color = Color.White, fontSize = 18.sp),
)
Expand All @@ -94,7 +98,7 @@ fun ModifyInfoScreen(
) {
Image(
modifier = Modifier.height(255.dp),
painter = storeInfoState.storeInfo?.imageUrls?.getOrNull(0)
painter = state.storeInfo?.imageUrls?.getOrNull(0)
.let { painterResource(id = R.drawable.no_image) },
contentDescription = stringResource(R.string.shop_image),
contentScale = ContentScale.Crop,
Expand Down Expand Up @@ -123,15 +127,15 @@ fun ModifyInfoScreen(
item {
InputStoreInfo(
info = stringResource(R.string.shop_name),
data = storeInfoState.storeInfo?.name ?: "",
onValueChange = { storeInfoViewModel.onStoreNameChanged(it) }
data = state.storeInfo?.name ?: "",
onValueChange = { viewModel.onStoreNameChanged(it) }
)
}
item {
InputStoreInfo(
info = stringResource(R.string.telephone_number),
data = storeInfoState.storeInfo?.phone ?: "",
onValueChange = { storeInfoViewModel.onPhoneNumberChanged(it) }
data = state.storeInfo?.phone ?: "",
onValueChange = { viewModel.onPhoneNumberChanged(it) }
)
}
item {
Expand All @@ -157,28 +161,20 @@ fun ModifyInfoScreen(
horizontalArrangement = Arrangement.SpaceBetween,
) {
Column {
state.operatingTimeList.forEach { item ->
val openTimeFormatted = String.format(
"%02d:%02d",
item.operatingTime.openTime.hours,
item.operatingTime.openTime.minutes
)
val closeTimeFormatted = String.format(
"%02d:%02d",
item.operatingTime.closeTime.hours,
item.operatingTime.closeTime.minutes
)
state.storeInfo?.operatingTime?.forEach { item ->
val dayOfWeekIndex = dayOfWeekToIndex(item.dayOfWeek)
val dayOfWeekKorean =
if (dayOfWeekIndex != -1) context.resources.getStringArray(R.array.days_one_letter)[dayOfWeekIndex] else item.dayOfWeek
Text(
text = if (item.closed) stringResource(
id = R.string.insert_store_closed_day,
item.dayOfWeek
dayOfWeekKorean
)
else stringResource(
id = R.string.insert_store_operating_time,
item.dayOfWeek,
openTimeFormatted,
closeTimeFormatted,
),
else "$dayOfWeekKorean " +
StoreUtil.generateOpenCloseTimeString(
item.openTime,
item.closeTime
),
color = ColorMinor,
)
}
Expand All @@ -202,23 +198,23 @@ fun ModifyInfoScreen(
item {
InputStoreInfo(
info = stringResource(R.string.address),
data = storeInfoState.storeInfo?.address ?: "",
onValueChange = { storeInfoViewModel.onAddressChanged(it) }
data = state.storeInfo?.address ?: "",
onValueChange = { viewModel.onAddressChanged(it) }
)
}
item {
InputStoreInfo(
info = stringResource(R.string.delivery_fee),
data = storeInfoState.storeInfo?.deliveryPrice?.toString() ?: "",
onValueChange = { storeInfoViewModel.onDeliveryPriceChanged(it.toInt()) }
data = state.storeInfo?.deliveryPrice?.toString() ?: "",
onValueChange = { viewModel.onDeliveryPriceChanged(it.toInt()) }
)
}

item {
InputStoreInfo(
info = stringResource(R.string.other_info),
data = storeInfoState.storeInfo?.description ?: "",
onValueChange = { storeInfoViewModel.onDescriptionChanged(it) }
data = state.storeInfo?.description ?: "",
onValueChange = { viewModel.onDescriptionChanged(it) }
)
}
item {
Expand All @@ -229,25 +225,31 @@ fun ModifyInfoScreen(
) {
AvailableRadioButton(
text = stringResource(id = R.string.delivery_available),
selected = storeInfoState.storeInfo?.isDeliveryOk ?: false,
onClick = storeInfoViewModel::onDeliveryAvailableChanged
selected = state.storeInfo?.isDeliveryOk ?: false,
onClick = viewModel::onDeliveryAvailableChanged
)
AvailableRadioButton(
text = stringResource(id = R.string.card_payment_available),
selected = storeInfoState.storeInfo?.isCardOk ?: false,
onClick = storeInfoViewModel::onCardAvailableChanged
selected = state.storeInfo?.isCardOk ?: false,
onClick = viewModel::onCardAvailableChanged
)
AvailableRadioButton(
text = stringResource(id = R.string.bank_transfer_available),
selected = storeInfoState.storeInfo?.isBankOk ?: false,
onClick = storeInfoViewModel::onTransferAvailableChanged
selected = state.storeInfo?.isBankOk ?: false,
onClick = viewModel::onTransferAvailableChanged
)
}
}
item {
Box(modifier = Modifier.fillMaxWidth()) {
Button(
onClick = {/*TODO*/ },
onClick = {
viewModel.modifyStoreInfo(
storeInfoState.storeId,
state.storeInfo ?: return@Button
)
viewModel.onBackButtonClicked()
},
modifier = Modifier
.width(130.dp)
.height(40.dp)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
package `in`.koreatech.business.feature.store.modifyinfo

import com.chargemap.compose.numberpicker.FullHours
import `in`.koreatech.koin.domain.model.owner.StoreDetailInfo

data class ModifyInfoState(
val operatingTimeList: List<StoreOperatingTime> = listOf(
StoreOperatingTime(OperatingTime(FullHours(0, 0), FullHours(0, 0)), false, "월", "MONDAY"),
StoreOperatingTime(OperatingTime(FullHours(0, 0), FullHours(0, 0)), false, "화", "TUESDAY"),
StoreOperatingTime(OperatingTime(FullHours(0, 0), FullHours(0, 0)), false, "수", "WEDNESDAY"),
StoreOperatingTime(OperatingTime(FullHours(0, 0), FullHours(0, 0)), false, "목", "THURSDAY"),
StoreOperatingTime(OperatingTime(FullHours(0, 0), FullHours(0, 0)), false, "금", "FRIDAY"),
StoreOperatingTime(OperatingTime(FullHours(0, 0), FullHours(0, 0)), false, "토", "SATURDAY"),
StoreOperatingTime(OperatingTime(FullHours(0, 0), FullHours(0, 0)), false, "일", "SUNDAY"),
val storeInfo: StoreDetailInfo = StoreDetailInfo(
address = "",
categoryIds = listOf(),
isDeliveryOk = false,
deliveryPrice = 0,
description = "",
imageUrls = listOf(),
name = "",
operatingTime = listOf(),
isBankOk = false,
isCardOk = false,
phone = "",
bank = "",
accountNumber = "",
),
val dialogTimeState: OperatingTime = OperatingTime(FullHours(0, 0), FullHours(0, 0)),
val showDialog: Boolean = false,
Expand Down
Loading