Skip to content

Commit

Permalink
Fix: 운영자 제보 시간, 날짜 형변환 에러 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
puretension committed Jun 21, 2024
1 parent 5141140 commit 1ca2f8a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 27 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
echo "Updated version number to $VERSION_NUMBER and build number to $NEW_BUILD_NUMBER"
echo "Updated version number to $VERSION_NUMBER and build number to $NEW_BUILD_NUMBER"
- name: Decode iOS secrets
env:
P12_DISTRIBUTION_CERTIFICATE_BASE64: ${{ secrets.IOS_P12_DISTRIBUTION_CERTIFICATE_BASE64 }}
Expand Down
2 changes: 1 addition & 1 deletion ios/PoppinProject/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>5</string>
<string>7</string>
<key>FirebaseAppDelegateProxyEnabled</key>
<true/>
<key>ITSAppUsesNonExemptEncryption</key>
Expand Down
4 changes: 2 additions & 2 deletions src/apis/mypage/createManagerReportPopUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ const createManagerReportPopUp = async (
formData.append('availableAge', availableAge);
formData.append('parkingAvailable', parkingAvailable);
formData.append('resvRequired', resvRequired);
formData.append('openDate', 'openDate');
formData.append('closeDate', ' closeDate');
formData.append('openDate', openDate);
formData.append('closeDate', closeDate);
formData.append('openTime', openTime);
formData.append('closeTime', closeTime);
formData.append('operationExcept', operationExcept);
Expand Down
59 changes: 40 additions & 19 deletions src/components/OperationHoursBottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {BottomSheetModal} from '@gorhom/bottom-sheet';
import DividerLine from './DividerLine.tsx';
import CompleteButton from './atoms/button/CompleteButton.tsx';
import Text18B from '../styles/texts/body_large/Text18B.ts';
import Text18R from '../styles/texts/body_large/Text18R.ts';
import useBackdrop from '../hooks/common/useBackDrop.tsx';
import {useReducedMotion} from 'react-native-reanimated';
interface Times {
Expand All @@ -17,15 +16,14 @@ interface Times {

interface OperationHoursBottomSheetProps {
setOperationTimes: (times: {start: string; end: string}) => void;
operationTimes: Times; // 추가: 초기값을 받도록 수정
}

const OperationHoursBottomSheet: React.FC<OperationHoursBottomSheetProps> = ({
setOperationTimes,
operationTimes,
}) => {
const [times, setTimes] = useState<Times>({
start: '오픈 시간',
end: '종료 시간',
});
const [times, setTimes] = useState<Times>(operationTimes); // 초기값 설정
const bottomSheetModalRef = useRef<BottomSheetModal>(null);
const [tempTime, setTempTime] = useState(new Date());
const [selectionMode, setSelectionMode] = useState('start');
Expand All @@ -36,15 +34,19 @@ const OperationHoursBottomSheet: React.FC<OperationHoursBottomSheetProps> = ({
bottomSheetModalRef.current?.present();
};

const getInputStyle = (type: string, value: string) => ({
const getInputStyle = (value: string) => ({
color:
value === '오픈 시간' || value === '종료 시간'
? globalColors.font
: globalColors.black,
});

const handleComplete = () => {
setOperationTimes(times); // Set the operation times using the passed prop
const formattedTimes = {
start: formatTimeForData(times.start),
end: formatTimeForData(times.end),
};
setOperationTimes(formattedTimes); // Set the operation times using the passed prop
bottomSheetModalRef.current?.dismiss();
};

Expand Down Expand Up @@ -72,19 +74,40 @@ const OperationHoursBottomSheet: React.FC<OperationHoursBottomSheetProps> = ({
}));
};

const formatTimeForData = (time: string) => {
const match = time.match(/오전|오후|\d{1,2}/g);
if (!match) {
return time;
} // 매치되지 않으면 원래 문자열 반환

const [period, hour, minute] = match;
let hours = parseInt(hour);
const minutes = minute ? parseInt(minute.replace('분', ''), 10) : 0;

if (period === '오후' && hours !== 12) {
hours += 12;
} else if (period === '오전' && hours === 12) {
hours = 0;
}

return `${hours.toString().padStart(2, '0')}:${minutes
.toString()
.padStart(2, '0')}`;
};

return (
<View>
<View style={styles.inputRow}>
<Pressable
style={[styles.input, styles.firstInput]}
onPress={() => showTimePicker('start')}>
<Text style={getInputStyle('start', times.start)}>{times.start}</Text>
<Text style={getInputStyle(times.start)}>{times.start}</Text>
</Pressable>
<Text style={styles.toText}>~</Text>
<Pressable
style={[styles.input, styles.secondInput]}
onPress={() => showTimePicker('end')}>
<Text style={getInputStyle('end', times.end)}>{times.end}</Text>
<Text style={getInputStyle(times.end)}>{times.end}</Text>
<ClockSvg />
</Pressable>
</View>
Expand All @@ -102,16 +125,14 @@ const OperationHoursBottomSheet: React.FC<OperationHoursBottomSheetProps> = ({
</View>

<View style={styles.dateRow}>
<Text style={[Text18R.text, {marginLeft: 10}]}>시작</Text>
<Text style={[Text18B.text, {marginLeft: 10}]}>시작</Text>
<Pressable
style={({pressed}) => [
styles.timeInputContainer,
pressed && {backgroundColor: globalColors.warmGray},
]}
onPress={() => setSelectionMode('start')}>
<Text style={getInputStyle('start', times.start)}>
{times.start}
</Text>
<Text style={getInputStyle(times.start)}>{times.start}</Text>
</Pressable>
</View>
<DividerLine height={1} />
Expand All @@ -123,7 +144,7 @@ const OperationHoursBottomSheet: React.FC<OperationHoursBottomSheetProps> = ({
pressed && {backgroundColor: globalColors.warmGray},
]}
onPress={() => setSelectionMode('end')}>
<Text style={getInputStyle('end', times.end)}>{times.end}</Text>
<Text style={getInputStyle(times.end)}>{times.end}</Text>
</Pressable>
</View>
<DividerLine height={1} />
Expand Down Expand Up @@ -195,14 +216,14 @@ const styles = StyleSheet.create({
marginRight: 10,
},
dateInput: {
flex: 1, // 나머지 공간 채우기
marginLeft: 10, // 아이콘과의 간격
flex: 1,
marginLeft: 10,
color: globalColors.black,
},
centeredView: {
alignItems: 'center', // 수평 중앙 정렬
justifyContent: 'center', // 수직 중앙 정렬
flex: 1, // 부모 컨테이너를 꽉 채우기
alignItems: 'center',
justifyContent: 'center',
flex: 1,
},
});

Expand Down
8 changes: 4 additions & 4 deletions src/pages/myPage/OperatorRegisterScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ const OperatorRegisterScreen = ({navigation}) => {
mapAgeGroupToApiValue(selectedAge),
parkingAvailability === 'parking',
resvRequired === 'required',
'test',
'test',
operationTimes.start,
operationTimes.end,
selectedDates.start ?? '2000-01-01',
selectedDates.end ?? '2024-12-31',
operationTimes.start ?? '00:00',
operationTimes.end ?? '23:59',
operationExcept ?? 'test',
0,
0,
Expand Down

0 comments on commit 1ca2f8a

Please sign in to comment.