Skip to content

Commit 0d270c5

Browse files
authored
Merge pull request #163 from team-ppointer/refactor/native/161
Refactor/native/161
2 parents 2b4b8e8 + a72ed60 commit 0d270c5

9 files changed

Lines changed: 151 additions & 86 deletions

File tree

apps/native/src/apis/controller/student/scrap/putUpdateScrapName.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { useMutation, useQueryClient } from '@tanstack/react-query';
22
import { client } from '@/apis/client';
33
import { paths } from '@/types/api/schema';
4-
import { invalidateScrapSearchQueries, SCRAP_QUERY_KEYS } from './utils';
4+
import {
5+
invalidateFolderScrapsQueries,
6+
invalidateScrapMutationQueries,
7+
SCRAP_QUERY_KEYS,
8+
} from './utils';
59

610
type UpdateScrapNameRequest =
711
paths['/api/student/scrap/{scrapId}/name']['put']['requestBody']['content']['application/json'];
@@ -34,8 +38,9 @@ export const useUpdateScrapName = () => {
3438
queryClient.invalidateQueries({
3539
queryKey: SCRAP_QUERY_KEYS.scrapDetail(scrapId),
3640
});
37-
// 검색 결과 갱신
38-
invalidateScrapSearchQueries(queryClient);
41+
// 폴더 내 스크랩 목록, 최근 스크랩, 검색 결과 갱신
42+
invalidateFolderScrapsQueries(queryClient);
43+
invalidateScrapMutationQueries(queryClient);
3944
},
4045
});
4146
};

apps/native/src/features/student/menu/screens/info/edit/EditPhoneNumberScreen.tsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ const EditPhoneNumberScreen = () => {
4646
}, [isCodeSent, timer]);
4747

4848
const handleSendCode = async () => {
49-
console.log('Send verification code to:', phoneNumber);
5049
try {
5150
const response = await postPhoneSend(phoneNumber);
5251
if (response.data?.success) {
@@ -79,8 +78,8 @@ const EditPhoneNumberScreen = () => {
7978
};
8079

8180
const handleVerify = async () => {
82-
if (!verificationCode || verificationCode.length !== 4) {
83-
showToast('error', '인증번호 4자리를 입력해주세요.');
81+
if (!verificationCode || verificationCode.length !== 6) {
82+
showToast('error', '인증번호 6자리를 입력해주세요.');
8483
return;
8584
}
8685

@@ -121,6 +120,13 @@ const EditPhoneNumberScreen = () => {
121120
return `${minutes}:${secs.toString().padStart(2, '0')}`;
122121
};
123122

123+
const handlePhoneNumberChange = (text: string) => {
124+
const phoneRegex = /^[0-9]*$/;
125+
if (phoneRegex.test(text) && text.length <= 11) {
126+
setPhoneNumber(text);
127+
}
128+
};
129+
124130
return (
125131
<KeyboardAvoidingView
126132
className='w-full flex-1'
@@ -147,7 +153,7 @@ const EditPhoneNumberScreen = () => {
147153
<View className='flex-row items-center gap-[10px]'>
148154
<TextInput
149155
value={phoneNumber}
150-
onChangeText={setPhoneNumber}
156+
onChangeText={handlePhoneNumberChange}
151157
placeholder='01012345678'
152158
placeholderTextColor={colors['gray-600']}
153159
keyboardType='phone-pad'
@@ -169,6 +175,7 @@ const EditPhoneNumberScreen = () => {
169175
</View>
170176
)}
171177
</View>
178+
{/* <View className='gap-[10px]'>
172179
<View className='gap-[6px]'>
173180
<Text className='text-14m text-gray-900'>통신사</Text>
174181
<View className='relative'>
@@ -183,7 +190,7 @@ const EditPhoneNumberScreen = () => {
183190
<ChevronDown color={colors['gray-900']} size={20} />
184191
</Pressable>
185192
</View>
186-
</View>
193+
</View> */}
187194
</View>
188195

189196
{isCodeSent && (
@@ -193,9 +200,9 @@ const EditPhoneNumberScreen = () => {
193200
<TextInput
194201
value={verificationCode}
195202
onChangeText={setVerificationCode}
196-
placeholder='인증번호 4자리'
203+
placeholder='인증번호 6자리'
197204
keyboardType='number-pad'
198-
maxLength={4}
205+
maxLength={6}
199206
className='text-16r h-[48px] w-full rounded-[10px] border border-gray-300 bg-white px-4 py-[11px] pr-[60px] text-black'
200207
/>
201208
<View
@@ -215,10 +222,11 @@ const EditPhoneNumberScreen = () => {
215222
</ScrollView>
216223

217224
<SafeAreaView edges={['bottom']} className='mb-[10px]'>
218-
{!isCodeSent ? (
225+
{!isCodeSent || timer == 0 ? (
219226
<Pressable
220227
onPress={handleSendCode}
221-
className='bg-primary-500 items-center rounded-[8px] px-[12px] py-[10px]'>
228+
disabled={phoneNumber.length !== 11}
229+
className={`bg-primary-500 items-center rounded-[8px] px-[12px] py-[10px] ${phoneNumber.length !== 11 ? 'opacity-50' : ''}`}>
222230
<Text className='text-16m text-white'>인증번호 받기</Text>
223231
</Pressable>
224232
) : (
@@ -231,7 +239,7 @@ const EditPhoneNumberScreen = () => {
231239
</SafeAreaView>
232240
</Container>
233241

234-
<Modal visible={carrierModalVisible} transparent animationType='fade'>
242+
{/* <Modal visible={carrierModalVisible} transparent animationType='fade'>
235243
<View className='flex-1 justify-end bg-black/20'>
236244
<Pressable className='flex-1' onPress={() => setCarrierModalVisible(false)} />
237245
<View className='rounded-t-[24px] bg-white px-[24px] pb-[32px] pt-[20px]'>
@@ -249,7 +257,7 @@ const EditPhoneNumberScreen = () => {
249257
))}
250258
</View>
251259
</View>
252-
</Modal>
260+
</Modal> */}
253261
</KeyboardAvoidingView>
254262
);
255263
};

apps/native/src/features/student/scrap/components/Header/ScrapDetailHeader.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ export const ScrapDetailHeader = ({
6565
}
6666
children={(close) => (
6767
<TooltipContainer
68-
height='h-[88px]'
68+
height=''
6969
header={
7070
<View className='h-[32px] w-[216px] rounded-[6px] bg-gray-300 px-[6px] py-1'>
7171
<TextInput
7272
ref={textInputRef}
73-
className='text-16m items-center justify-center text-black'
73+
className='text-16m flex-1 text-black'
74+
style={{ lineHeight: 20, paddingVertical: 0 }}
7475
numberOfLines={1}
7576
value={localName}
7677
placeholder='스크랩 이름'
@@ -118,7 +119,7 @@ export const ScrapDetailHeader = ({
118119
)}></TooltipPopover>
119120
</View>
120121
<Pressable onPress={onMessagePress}>
121-
<MessageCircleMore size={24} color={'#FFF'} />
122+
{/* 미구현 <MessageCircleMore size={24} color={'#FFF'} />` */}
122123
</Pressable>
123124
</View>
124125
);

apps/native/src/features/student/scrap/components/Header/SearchScrapHeader.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,15 @@ const SearchScrapHeader = ({
2525
<TextInput
2626
className='text-18m flex-1 text-black'
2727
placeholder='스크랩 제목을 검색하세요.'
28+
style={{ lineHeight: 27 }}
2829
multiline={false}
2930
textAlignVertical='center'
3031
placeholderTextColor={colors['gray-500']}
31-
allowFontScaling={false}
3232
numberOfLines={1}
3333
value={query}
3434
returnKeyType='search'
3535
onSubmitEditing={onSubmitEditing}
3636
onChangeText={setQuery}
37-
onEndEditing={() => {}}
3837
/>
3938
{query.length > 0 && (
4039
<Pressable

apps/native/src/features/student/scrap/components/Modal/CreateFolderModal.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const CreateFolderModal = () => {
1414
useScrapModal();
1515
const [folderName, setFolderName] = useState('');
1616
const [selectedImage, setSelectedImage] = useState<ImagePicker.ImagePickerAsset | null>(null);
17+
const [isCreating, setIsCreating] = useState(false);
1718
const { mutateAsync: createFolder } = useCreateFolder();
1819
const { mutateAsync: uploadFile } = useUploadFile();
1920

@@ -41,11 +42,17 @@ export const CreateFolderModal = () => {
4142
};
4243

4344
const handleCreate = async () => {
45+
if (isCreating) {
46+
return;
47+
}
48+
4449
if (!folderName.trim()) {
4550
showToast('error', '폴더 이름을 입력해주세요.');
4651
return;
4752
}
4853

54+
setIsCreating(true);
55+
4956
try {
5057
let thumbnailImageId: number | undefined;
5158

@@ -63,12 +70,14 @@ export const CreateFolderModal = () => {
6370
thumbnailImageId,
6471
});
6572

73+
closeCreateFolderModal();
6674
showToast('success', '폴더가 추가되었습니다.');
6775
refetchFolders?.();
6876
refetchScraps?.();
69-
closeCreateFolderModal();
7077
} catch (error) {
7178
showToast('error', '폴더 추가에 실패했습니다.');
79+
} finally {
80+
setIsCreating(false);
7281
}
7382
};
7483

@@ -100,10 +109,11 @@ export const CreateFolderModal = () => {
100109
</View>
101110
)}
102111
</Pressable>
103-
<View className='w-full rounded-[8px] border border-gray-400 bg-white px-3 py-2'>
112+
<View className='h-[40px] w-full rounded-[8px] border border-gray-400 bg-white px-3 py-2'>
104113
<TextInput
105114
className='text-16sb text-black'
106115
placeholder='제목없음'
116+
style={{ lineHeight: 20, paddingVertical: 0 }}
107117
placeholderTextColor={colors['gray-500']}
108118
value={folderName}
109119
onChangeText={setFolderName}

apps/native/src/features/student/scrap/components/Tooltip/ScrapItemTooltip.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,13 @@ export const ScrapItemTooltip = ({ props, onClose, onMovePress }: ScrapItemToolt
164164

165165
return (
166166
<TooltipContainer
167-
height='h-[176px]'
167+
height=''
168168
header={
169-
<View className='h-[32px] w-[216px] rounded-[6px] bg-gray-300 px-[6px] py-1'>
169+
<View className='h-[32px] w-full rounded-[6px] bg-gray-300 px-[6px] py-1'>
170170
<TextInput
171-
className='text-16m items-center justify-center text-black'
171+
className='text-16m flex-1 text-black'
172172
numberOfLines={1}
173+
style={{ lineHeight: 20, paddingVertical: 0 }}
173174
value={text}
174175
onChangeText={setText}
175176
onEndEditing={async () => {

apps/native/src/features/student/scrap/components/Tooltip/TooltipMenuItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const TooltipMenuItem = ({
3838
}: TooltipMenuItemProps) => {
3939
return (
4040
<Pressable
41-
className={`flex-1 flex-row items-center gap-2 pl-4 pr-[26px] ${
41+
className={`flex-1 flex-row items-center gap-2 py-2.5 pl-4 pr-[26px] ${
4242
!isLastItem ? 'border-b-[0.5px] border-gray-500' : ''
4343
}`}
4444
onPress={onPress}>

apps/native/src/features/student/scrap/hooks/useHandwritingManager.ts

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,49 +40,54 @@ export function useHandwritingManager({
4040
// 저장하기 함수
4141
const handleSave = useCallback(
4242
(isAutoSave = false) => {
43-
if (!canvasRef.current) return;
43+
if (!canvasRef.current) return Promise.resolve(false);
4444

4545
const strokes = canvasRef.current.getStrokes();
4646
const texts = canvasRef.current.getTexts();
4747

4848
try {
4949
const base64Data = encodeHandwritingData(strokes || [], texts || []);
5050

51-
// 변경사항이 없으면 저장하지 않음
51+
// 변경사항 없으면 저장 안 함
5252
if (base64Data === lastSavedDataRef.current) {
5353
if (!isAutoSave) {
5454
Alert.alert('알림', '변경사항이 없습니다.');
5555
}
56-
return;
56+
return Promise.resolve(true);
5757
}
5858

59-
updateHandwriting(
60-
{
61-
scrapId,
62-
request: { data: base64Data },
63-
},
64-
{
65-
onSuccess: () => {
66-
lastSavedDataRef.current = base64Data;
67-
onSaveSuccess?.();
68-
if (!isAutoSave) {
69-
Alert.alert('성공', '필기가 저장되었습니다.');
70-
}
59+
return new Promise<boolean>((resolve) => {
60+
updateHandwriting(
61+
{
62+
scrapId,
63+
request: { data: base64Data },
7164
},
72-
onError: (error) => {
73-
console.error('필기 저장 실패:', error);
74-
onSaveError?.();
75-
if (!isAutoSave) {
76-
Alert.alert('오류', '필기 저장에 실패했습니다.');
77-
}
78-
},
79-
}
80-
);
65+
{
66+
onSuccess: () => {
67+
lastSavedDataRef.current = base64Data;
68+
onSaveSuccess?.();
69+
if (!isAutoSave) {
70+
Alert.alert('성공', '필기가 저장되었습니다.');
71+
}
72+
resolve(true);
73+
},
74+
onError: (error) => {
75+
console.error('필기 저장 실패:', error);
76+
onSaveError?.();
77+
if (!isAutoSave) {
78+
Alert.alert('오류', '필기 저장에 실패했습니다.');
79+
}
80+
resolve(false);
81+
},
82+
}
83+
);
84+
});
8185
} catch (error) {
8286
console.error('필기 데이터 변환 실패:', error);
8387
if (!isAutoSave) {
8488
Alert.alert('오류', '필기 데이터 변환에 실패했습니다.');
8589
}
90+
return Promise.resolve(false);
8691
}
8792
},
8893
[scrapId, canvasRef, updateHandwriting, onSaveSuccess, onSaveError]

0 commit comments

Comments
 (0)