Skip to content

fix: 일정 추가시 현재 선택한 날짜에 추가하도록 변경 #83

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

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion packages/react-native/src/apis/mutations/useAddSchedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import useAuthAxios from '../useAuthAxios';
import { StackNavigation } from '@/types/navigation';

interface AddScheduleProps {
day: number;
name: string;
description: string;
}
Expand All @@ -14,9 +15,10 @@ export default function useAddSchedule(id: number) {
const navigation =
useNavigation<StackNavigation<'TripPlanner/AddSchedule'>>();

const addSchedule = async ({ name, description }: AddScheduleProps) => {
const addSchedule = async ({ day, name, description }: AddScheduleProps) => {
const response = await authAxios.post('/api/schedule/location', {
scheduleId: id,
day,
name,
description,
});
Expand Down
3 changes: 2 additions & 1 deletion packages/react-native/src/pages/TripPlanner/AddSchedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import useTripPlanMySpotQuery from '@/apis/queries/tripPlan/useTripPlanMySpotQue

export default function AddSchedule() {
const route = useRoute<StackRouteProps<'TripPlanner/AddSchedule'>>();
const { tripId } = route.params;
const { tripId, day } = route.params;
const { data: spotList } = useTripPlanMySpotQuery({ id: tripId });
const [addType, setAddTYpe] = useState<'new' | 'prev'>();
const [locationName, setLocationName] = useState('');
Expand All @@ -26,6 +26,7 @@ export default function AddSchedule() {
if (!locationName || !locationMemo) return;

mutate({
day,
name: locationName,
description: locationMemo,
});
Expand Down
7 changes: 5 additions & 2 deletions packages/react-native/src/pages/TripPlanner/EditTripPlan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const EditTripPlan = withSuspense(() => {
</View>
<ScrollView className="h-full mt-6">
{data.locations
.filter((location) => location.day === selectedDate + 1)
.filter((location) => location.day === selectedDate)
.sort((a, b) => a.seq - b.seq)
.map((info) => (
<>
Expand All @@ -130,7 +130,10 @@ const EditTripPlan = withSuspense(() => {
{!editMode && (
<FloatingPlusButton
onPress={() =>
navigation.navigate('TripPlanner/AddSchedule', { tripId })
navigation.navigate('TripPlanner/AddSchedule', {
tripId,
day: selectedDate,
})
}
bottom={14}
right={12}
Expand Down
1 change: 1 addition & 0 deletions packages/react-native/src/types/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type StackParamList = {
};
'TripPlanner/AddSchedule': {
tripId: number;
day: number;
};

'MyPage/Profile': undefined;
Expand Down
Loading