-
Notifications
You must be signed in to change notification settings - Fork 0
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
🗑トラベリンクを削除する機能を追加 #200
Open
eve00
wants to merge
16
commits into
main
Choose a base branch
from
#196_delete_travelink
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
🗑トラベリンクを削除する機能を追加 #200
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b1eac18
アイコンMenuButton追加
eve00 6b83a30
IconMenuButton追加
eve00 2ce9a63
トラベリンク削除モーダルを表示するボタン
eve00 891e613
トラベリンクを削除するモーダルを表示する機能
eve00 a5f9e39
トラベリンクを削除する機能を実装
eve00 28c4567
run formatter
eve00 35695e7
修正
eve00 de89814
run formatter
eve00 b33dfe0
SHUSEI
eve00 4d17b5f
TODOコメント追加
eve00 92ea1e0
Merge branch 'main' into #196_delete_travelink
eve00 186d90c
修正
eve00 bb40ab8
Merge branch '#196_delete_travelink' of https://github.com/traveli-de…
eve00 28a4b38
run formatter
eve00 6dd08b1
typo修正
eve00 9657599
snap
eve00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Box } from '@chakra-ui/react' | ||
|
||
export const IconMenuButton = ({ ...props }) => { | ||
return ( | ||
<Box {...props}> | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
className="h-5 w-5" | ||
viewBox="0 0 20 20" | ||
fill="currentColor" | ||
> | ||
<path d="M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z" /> | ||
</svg> | ||
</Box> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { | ||
Box, | ||
Flex, | ||
Menu, | ||
MenuButton, | ||
MenuItem, | ||
MenuList | ||
} from '@chakra-ui/react' | ||
import { IconMenuButton } from '@/components/Icons' | ||
|
||
type MenuOpenDeleteTravelinkProps = { | ||
onOpen: () => void | ||
} | ||
|
||
export const MenuOpenDeleteTravelink = ({ | ||
onOpen | ||
}: MenuOpenDeleteTravelinkProps) => { | ||
return ( | ||
<Menu> | ||
<MenuButton> | ||
<Flex w={'2.4rem'} h={'2.4rem'} align={'center'} justify={'center'}> | ||
<IconMenuButton w={'1.6rem'} h={'1.6rem'} color={'gray'} /> | ||
</Flex> | ||
</MenuButton> | ||
|
||
<MenuList | ||
padding={'1.35rem 0 0 2.4rem'} | ||
w={'13.9rem'} | ||
h={'5.2rem'} | ||
borderColor={'#CBD5E0'} | ||
borderRadius={'1.5rem'} | ||
boxShadow={0} | ||
> | ||
<MenuItem | ||
display={'flex'} | ||
padding={0} | ||
onClick={() => { | ||
onOpen() | ||
}} | ||
> | ||
<Box | ||
bgImage={'/images/icons/trash.svg'} | ||
w={'1.68rem'} | ||
h={'1.68rem'} | ||
marginRight={'1.6rem'} | ||
/> | ||
<Box fontSize={'sm'} color={'#FF4D4D'}> | ||
削除する | ||
</Box> | ||
</MenuItem> | ||
</MenuList> | ||
</Menu> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { MenuCardLinkEdit } from '@/components/Menus/MenuCardLinkEdit' | ||
export { MenuOpenDeleteTravelink } from '@/components/Menus/MenuOpenDeleteTravelink' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { | ||
Modal, | ||
Button, | ||
ModalOverlay, | ||
ModalContent, | ||
ModalHeader, | ||
ModalFooter, | ||
ModalBody, | ||
Text, | ||
UnorderedList, | ||
ListItem, | ||
Box | ||
} from '@chakra-ui/react' | ||
import { useDeleteTravelink } from '@/hooks/firestore' | ||
|
||
type Props = { | ||
isOpen: boolean | ||
onClose: () => void | ||
id: string | ||
} | ||
|
||
export const ModalDeleteTravelknk = ({ isOpen, onClose, id }: Props) => { | ||
const { onClickDeleteTravelink } = useDeleteTravelink() | ||
return ( | ||
<Modal isOpen={isOpen} onClose={onClose}> | ||
<ModalOverlay /> | ||
<ModalContent | ||
margin={'auto 0'} | ||
width={'90vw'} | ||
maxW={'90vw'} | ||
height={'auto'} | ||
borderRadius={'3rem'} | ||
padding={'1.5rem'} | ||
> | ||
<ModalHeader textAlign={'center'}>トラベリンク削除</ModalHeader> | ||
<ModalBody> | ||
<Text>削除すると以下の情報がすべて失われます</Text> | ||
<Box | ||
bgColor={'#f1f1f1'} | ||
p={'1rem'} | ||
borderRadius={'1rem'} | ||
m={'1rem 0'} | ||
> | ||
<UnorderedList> | ||
<ListItem>とらべりんく削除</ListItem> | ||
</UnorderedList> | ||
</Box> | ||
</ModalBody> | ||
<ModalFooter> | ||
<Button variant={'outline'} size={'md'} mr={3} onClick={onClose}> | ||
キャンセル | ||
</Button> | ||
<Button | ||
colorScheme={'alertRed'} | ||
size={'md'} | ||
w={'5rem'} | ||
h={'3rem'} | ||
onClick={() => { | ||
onClickDeleteTravelink(id) | ||
}} | ||
> | ||
削除 | ||
</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { ModalQrCode } from '@/components/Modals/ModalQrCode' | ||
export { ModalSignIn } from '@/components/Modals/ModalSignIn' | ||
export { ModalDeleteTravelknk } from '@/components/Modals/ModalDeleteTravelink' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { collection, deleteDoc, doc, getFirestore } from 'firebase/firestore' | ||
import { useRouter } from 'next/router' | ||
|
||
export const useDeleteTravelink = () => { | ||
const router = useRouter() | ||
|
||
const onClickDeleteTravelink = async (id: string) => { | ||
const db = getFirestore() | ||
|
||
const travelinkRef = doc(collection(db, 'travelinks'), id) | ||
try { | ||
await deleteDoc(travelinkRef) | ||
} catch (e) { | ||
console.error(e) | ||
} | ||
// TODO: リロード→ぐるぐるにしてDBから再フェッチ | ||
router.reload() | ||
} | ||
return { onClickDeleteTravelink } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Travelknkになってる!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😧