Skip to content

Commit

Permalink
1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
Dindb-dong committed Jan 16, 2025
1 parent 0c248e8 commit 6241e11
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 58 deletions.
8 changes: 4 additions & 4 deletions src/components/Auth/BasicForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ export default function BasicForm({ navigation, route }: FormProps) {
const accessToken = await response.data.access;
const refreshToken = await response.data.refresh;
console.log({ accessToken }, '||', { refreshToken });
} else if (response?.status === 500) {
} else if (response?.status === 400) {
console.log(response);
Alert.alert('이미 가입된 이메일입니다.');
} else {
console.error('Error Status:', response?.status);
console.error('Error Status:', response);
Alert.alert('가입에 실패했습니다.');
}
} catch (err) {
Expand All @@ -210,11 +210,11 @@ export default function BasicForm({ navigation, route }: FormProps) {
const refreshToken = await response.data.refresh;
console.log({ accessToken }, '||', { refreshToken });
handleNext();
} else if (response?.status === 500) {
} else if (response?.status === 400) {
console.log(response);
Alert.alert('이미 가입된 이메일입니다.');
} else {
console.error('Error Status:', response?.status);
console.error('Error Status:', response);
Alert.alert('가입에 실패했습니다.');
}
} catch (err) {
Expand Down
22 changes: 17 additions & 5 deletions src/components/Auth/Reformer/ReformFormCareer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { useEffect, useRef, useState } from 'react';
import { BLACK, GRAY, PURPLE } from '../../../styles/GlobalColor';
import CareerModal from './CareerModal';
import Request from '../../../common/requests';
import { useNavigation } from '@react-navigation/native';
import { CommonActions, useNavigation } from '@react-navigation/native';
import { StackNavigationProp } from '@react-navigation/stack';
import { SignInParams } from '../SignIn';
import { getAccessToken, getMarketUUID, setMarketUUID } from '../../../common/storage';
Expand Down Expand Up @@ -572,7 +572,7 @@ export default function ReformCareer({ fix, form, setForm }: ReformProps) {
const linkChanged = JSON.stringify(memorizedForm.current?.link) !== JSON.stringify(updatedForm.link);
const regionChanged = JSON.stringify(memorizedForm.current?.region) !== JSON.stringify(updatedForm.region);
// 변경된 항목만 포함하는 params 객체 생성
const params: Partial<{ reformer_link: string; reformer_area: string }> = {};
const params: Partial<{ reformer_link: string; reformer_area: string; }> = {};
if (linkChanged) params.reformer_link = updatedForm.link;
if (regionChanged) params.reformer_area = updatedForm.region;
if (linkChanged || regionChanged) {
Expand Down Expand Up @@ -740,7 +740,19 @@ export default function ReformCareer({ fix, form, setForm }: ReformProps) {
"프로필 수정이 완료되었습니다.",
"",
[
{ text: "확인", onPress: () => { navigation.goBack(); } }
{
text: "확인",
onPress: () => {
navigation.dispatch(
CommonActions.reset({
index: 0, // 새로운 스택의 첫 번째 화면
routes: [
{ name: 'Main', params: { screen: 'UPCY' } }
]
})
);
}
}
]
);
}
Expand Down Expand Up @@ -954,8 +966,8 @@ export default function ReformCareer({ fix, form, setForm }: ReformProps) {
// 기존 form.field에 새로운 데이터 추가
setForm(prevForm => ({
...prevForm,
introduce: data.introduce || prevForm.introduce,
nickname: data.nickname || prevForm.nickname,
introduce: data.user_info.introduce || prevForm.introduce,
nickname: data.user_info.nickname || prevForm.nickname,
link: data.reformer_link || prevForm.link,
region: data.reformer_area || prevForm.region,
field: [...prevForm.field, ...newFields], // 기존 field에 newFields 추가
Expand Down
22 changes: 16 additions & 6 deletions src/components/Auth/Reformer/ReformerMyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,18 @@ export const ReformerMyPageScreen = ({
market_uuid: '',
};
const defaultReformerResponseData: ReformerResponseType = {
reformer_nickname: '', // 닉네임
user_info: {
email: '[email protected]',
phone: '010-1234-5678',
full_name: '',
nickname: '',
agreement_terms: true,
address: '',
profile_image_url: '',
introduce: '',
is_active: true,
role: 'reformer',
},
reformer_link: '', // 자기소개
reformer_area: '', // 활동지역
education: [], // 학력
Expand All @@ -157,7 +168,7 @@ export const ReformerMyPageScreen = ({
useState<ReformerResponseType>(defaultReformerResponseData);
const [marketData, setMarketData] = useState<MarketType>({
reformer_link: '', // 링크
market_introduce: '정보 없음', // TODO: 이거 introduce로 수정하기
introduce: '정보 없음', // TODO: 이거 introduce로 수정하기
reformer_nickname: '정보 없음', // 닉네임
market_thumbnail: '', // 왜 안 나오지...? 원래없나
market_uuid: '',
Expand Down Expand Up @@ -222,8 +233,7 @@ export const ReformerMyPageScreen = ({
setMarketResponseData(marketResult);
const marketUUID = await getMarketUUID();
fetchMarketData({
market_introduce: marketResult.market_introduce,
market_thumbnail: marketResult.market_thumbnail || '', // 기본값 유지
//market_thumbnail: marketResult.market_thumbnail || '', // 기본값 유지
market_uuid: marketUUID || marketResult.market_uuid,
});
console.log('마켓 정보 가져오기 성공', response2.data);
Expand All @@ -238,9 +248,9 @@ export const ReformerMyPageScreen = ({
const reformerResult: ReformerResponseType = response3.data;
setReformerResponseData(reformerResult);
fetchMarketData({
reformer_nickname: reformerResult.reformer_nickname,
reformer_nickname: reformerResult.user_info.nickname,
//TODO: 의종님이 api 수정하시면 여기서 자기소개 받도록 수정하기
//introduce: reformerResult.introduce,
introduce: reformerResult.user_info.introduce,
reformer_link: reformerResult.reformer_link,
reformer_area: reformerResult.reformer_area,
education: reformerResult.education,
Expand Down
4 changes: 2 additions & 2 deletions src/components/Home/Market/InfoPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type InfoPageDataType = {

export type MarketType = {
reformer_link?: string, // 링크
market_introduce: string, // 자기소개
introduce: string, // 자기소개
// TODO: introduce로 수정하기
reformer_nickname?: string, // 닉네임
market_thumbnail: string, // ???
Expand Down Expand Up @@ -87,7 +87,7 @@ const InfoPage = ({ marketData }: { marketData: MarketType }) => {
const newData = [
{
label: '소개글',
data: marketData.market_introduce,
data: marketData.introduce,
},
{ label: '오픈채팅 링크', data: marketData.reformer_link },
{ label: '주요 활동지역', data: marketData.reformer_area },
Expand Down
4 changes: 2 additions & 2 deletions src/components/Home/Market/MarketTabView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const MarketTabView = ({

const defaultMarketResponseData: MarketType = {
reformer_link: '',
market_introduce: '정보 없음',
introduce: '정보 없음',
reformer_nickname: '정보 없음',
market_thumbnail: '',
market_uuid: '',
Expand Down Expand Up @@ -241,7 +241,7 @@ const MarketTabView = ({
const reformerDataResult: ReformerDataResponseType = response.data;
const tempMarketResult: MarketType = {
reformer_link: reformerDataResult.reformer_link ?? '',
market_introduce: '정보 없음',
introduce: '정보 없음',
reformer_nickname: reformerName,
market_thumbnail: '',
market_uuid: '',
Expand Down
4 changes: 3 additions & 1 deletion src/components/Home/Market/Service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ const EntireServiceMarket = ({
try {
// API 호출: 전체 서비스
const response = await request.get(`/api/market/services`, {}, {});
if (response && response.status === 200) {
if (response.status === 404) {
Alert.alert('아직 등록된 서비스가 없습니다.')
} else if (response && response.status === 200) {
const serviceListResults: ServiceResponseType[] = response.data.results;
console.log(serviceListResults[0].service_option);
setServiceCardRawData(serviceListResults);
Expand Down
5 changes: 4 additions & 1 deletion src/components/Home/Market/ServicePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ const ServicePage: React.FC<ServicePageProps> = ({
if (response && response.status === 200) {
const marketResult = response.data;
setItems(marketResult);
} else {
} else if (response.status === 404) {
setError('아직 등록된 서비스가 없습니다.')
}
else {
setError('서비스를 불러오는 데 실패했습니다.');
console.log(response);
Alert.alert('ServicePage.tsx에서 오류가 발생했습니다.');
Expand Down
86 changes: 49 additions & 37 deletions src/types/UserTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,41 +45,41 @@ export type RegionType =
| '중구'
| '중랑구'
| '';
type BaseType = {
file?: Files; // 공통 속성
};
type Educ = BaseType & {
school?: string; // 학교명
major?: string | undefined; // 전공
academic_status?: string | undefined; // 상태
};
export type EducType = Educ[];
type Career = BaseType & {
company_name?: string; // 회사명
department?: string | undefined; // 근무부서 및 직책
period?: string | undefined; // 근무기간
};
export type CareerType = Career[];
type Awards = BaseType & {
competition?: string; // 공모전명
prize?: string | undefined; // 수상내역
};
export type AwardsType = Awards[];
type Certifi = BaseType & {
name?: string; // 자격증명
issuing_authority?: string | undefined; // 발급기관
};
export type CertifiType = Certifi[];
type Free = BaseType & {
project_name?: string; // 프로젝트명
description?: string | undefined; // 상세설명
};
export type FreeType = Free[];
type BaseType = {
file?: Files; // 공통 속성
};

type Educ = BaseType & {
school?: string; // 학교명
major?: string | undefined; // 전공
academic_status?: string | undefined; // 상태
};
export type EducType = Educ[];

type Career = BaseType & {
company_name?: string; // 회사명
department?: string | undefined; // 근무부서 및 직책
period?: string | undefined; // 근무기간
};
export type CareerType = Career[];

type Awards = BaseType & {
competition?: string; // 공모전명
prize?: string | undefined; // 수상내역
};
export type AwardsType = Awards[];

type Certifi = BaseType & {
name?: string; // 자격증명
issuing_authority?: string | undefined; // 발급기관
};
export type CertifiType = Certifi[];

type Free = BaseType & {
project_name?: string; // 프로젝트명
description?: string | undefined; // 상세설명
};
export type FreeType = Free[];

export type Field = {
name: string;
Expand All @@ -95,9 +95,21 @@ export type Field = {
export type FieldType = Field[];
// 종류별 타입 정의

export type UserInfoType = {
email: string;
phone: string | null;
full_name: string;
nickname: string;
agreement_terms: boolean;
address: string | null;
profile_image_url: string;
introduce: string;
is_active: boolean;
role: string;
}

export type ReformerResponseType = {
introduce?: string;
reformer_nickname: string;
user_info: UserInfoType;
reformer_link: string;
reformer_area: string;
education: EducType;
Expand Down

0 comments on commit 6241e11

Please sign in to comment.