Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/#41' into origin/refactor/b…
Browse files Browse the repository at this point in the history
…us-#43
  • Loading branch information
ftery0 committed Nov 25, 2024
2 parents dc38288 + c908079 commit 0fc419d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 28 deletions.
28 changes: 11 additions & 17 deletions src/components/MyInfo/Contents/BusApply/BusOption/BusOption.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Bus } from "../../../../../types/busApply/busApply.type";
import * as S from "./style";
import { Bus } from '../../../../../types/busApply/busApply.type';
import * as S from './style';

interface Props {
data: Bus;
Expand All @@ -8,32 +8,26 @@ interface Props {
}

const BusOption = ({ data, isSelect, onChangeApplyBus }: Props) => {
const [busNumber, busName] = data.busName.split(" ");
const [busNumber, busName] = data.busName.split(' ');

return (
<S.BusOptionWrap
isSelect={isSelect}
onClick={() => onChangeApplyBus(data.id)}
>
{busNumber === "미탑승" ? (
<S.BusOptionWrap isSelect={isSelect} onClick={() => onChangeApplyBus(data.id)}>
{busNumber === '미탑승' ? (
<>
<S.BusOptionStationText isSelect={isSelect}>{busNumber}</S.BusOptionStationText>
<S.BusOptionStationText isSelect={isSelect}>
{busNumber}
</S.BusOptionStationText>
<S.BusOptionStationText isSelect={isSelect}>
({data.leaveTime.split(" ")[1].substring(0, 5)})
({data.leaveTime.split(' ')[1].substring(0, 5)})
</S.BusOptionStationText>
</>
) : (
<>
<S.BusOptionStationText isSelect={isSelect}>{busNumber}</S.BusOptionStationText>
<S.BusOptionStationText isSelect={isSelect}>
{busNumber}
</S.BusOptionStationText>
<S.BusOptionStationText isSelect={isSelect}>
{busName}
{data.applyCount}/{data.peopleLimit}
</S.BusOptionStationText>
<S.BusOptionStationText isSelect={isSelect}>{busName}</S.BusOptionStationText>
<S.BusOptionStationText isSelect={isSelect}>
({data.leaveTime.split(" ")[1].substring(0, 5)})
({data.leaveTime.split(' ')[1].substring(0, 5)})
</S.BusOptionStationText>
</>
)}
Expand Down
25 changes: 14 additions & 11 deletions src/hooks/busApply/useBusApply.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { B1ndToast } from "@b1nd/b1nd-toastify";
import { useEffect, useState } from "react";
import busApplyRepository from "../../repository/busApply/busApply.repository";
import { Bus } from "../../types/busApply/busApply.type";
import { B1ndToast } from '@b1nd/b1nd-toastify';
import { useEffect, useState } from 'react';
import busApplyRepository from '../../repository/busApply/busApply.repository';
import { Bus } from '../../types/busApply/busApply.type';

const useBusApply = () => {
const [serverBusData, setServerBusData] = useState<Bus[]>([]);
const [selectedBusId, setSelectedBusId] = useState<number>(-1);
const [selectBusId, setSelectBusId] = useState<number>(-1);
const [busDate, setBusDate] = useState("");
const [busDate, setBusDate] = useState('');
const [isChange, setIsChange] = useState(false);

const mappingBusData = async () => {
Expand Down Expand Up @@ -46,10 +46,11 @@ const useBusApply = () => {
const onSubmitBusApply = async () => {
try {
await busApplyRepository.postBusApply({ idx: String(selectBusId) });
B1ndToast.showSuccess("버스 신청 성공");
B1ndToast.showSuccess('버스 신청 성공');
mappingBusData();
setSelectedBusId(selectBusId);
} catch (error) {
B1ndToast.showError("버스 신청 실패");
B1ndToast.showError('버스 신청 실패');
}
};

Expand All @@ -58,22 +59,24 @@ const useBusApply = () => {
await busApplyRepository.patchBusApply({
idx: String(selectBusId),
});
B1ndToast.showSuccess("버스 수정 성공");
B1ndToast.showSuccess('버스 수정 성공');
mappingBusData();
setSelectedBusId(selectBusId);
} catch (error) {
B1ndToast.showInfo("버스 수정 실패");
B1ndToast.showInfo('버스 수정 실패');
}
};
const deleteBusApply = async () => {
try {
await busApplyRepository.deleteBusApply({
idx: String(selectBusId),
});
B1ndToast.showSuccess("버스 신청 취소");
B1ndToast.showSuccess('버스 신청 취소');
mappingBusData();
setSelectBusId(-1);
setSelectedBusId(-1);
} catch (error) {
B1ndToast.showInfo("버스 신청취소 실패");
B1ndToast.showInfo('버스 신청취소 실패');
}
};
const onChangeApplyBus = (busId: number) => setSelectBusId(busId);
Expand Down

0 comments on commit 0fc419d

Please sign in to comment.