Skip to content

Commit

Permalink
feat: 지점 설정 시, 지점명 업데이트
Browse files Browse the repository at this point in the history
  • Loading branch information
jiohjung98 committed May 31, 2024
1 parent 9f47176 commit 6888c18
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/components/home/CurrentOffice.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import SearchModal from './SearchModal';
import SelectOfficeMap from './SelectOfficeMap';
import { Branch } from '@/api/types/branch';
import { useBranchStore } from '@/store/branch.store';

const CurrentOffice = () => {
const [showSearchModal, setShowSearchModal] = useState(false);
const [showSelectOfficeMap, setShowSelectOfficeMap] = useState(false);
const selectedBranch = useBranchStore((state) => state.selectedBranch);
const setSelectedBranch = useBranchStore((state) => state.setSelectedBranch);

const handleBranchSelect = (branch: Branch) => {
setSelectedBranch(branch);
setShowSearchModal(false);
setShowSelectOfficeMap(true);
};

const handleSearchClick = () => {
setShowSearchModal(true);
};

const handleCloseSelectOfficeMap = () => {
setShowSelectOfficeMap(false);
};

useEffect(() => {
console.log('Selected Branch Updated:', selectedBranch);
}, [selectedBranch]);

return (
<>
<div className="flex items-center gap-[10px] mt-6 relative">
Expand All @@ -32,7 +42,9 @@ const CurrentOffice = () => {
</div>
</div>
{showSearchModal && <SearchModal onClose={() => setShowSearchModal(false)} onBranchSelect={handleBranchSelect} />}
{selectedBranch && <SelectOfficeMap branch={selectedBranch} onClose={() => setSelectedBranch(null)} />}
{showSelectOfficeMap && selectedBranch && (
<SelectOfficeMap branch={selectedBranch} onClose={handleCloseSelectOfficeMap} />
)}
</>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/home/SearchModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const SearchModal: React.FC<SearchModalProps> = ({ onClose, onBranchSelect }) =>

const handleItemClick = (branch: Branch) => {
setSelectedBranch(branch);
onBranchSelect(branch);
onBranchSelect(branch);
};

return (
Expand Down

0 comments on commit 6888c18

Please sign in to comment.