-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat/new role and edit role #226
Merged
Merged
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
69569d8
wip: add NewRole and EditRole pages
yawn-c111 c4529dc
remove: yarn.lock
yawn-c111 2641e82
Merge branch 'main' into feature/new-role-and-edit-role
yawn-c111 249acc5
wip: SHD
yawn-c111 7b91d69
update: input and textarea
yawn-c111 320f590
update: ipfs upload
yawn-c111 248cefd
update: fetch treeIds and parse createHat event log
yawn-c111 a3347e6
chore: update ipfs uploading in top test page
yawn-c111 a3d8a14
update: add some HatsDetails types
yawn-c111 de3d368
add: create roles page and role attributes dialogs
yawn-c111 0d19baf
Merge branch 'main' into feature/new-role-and-edit-role
yawn-c111 1fdfe00
fix: edit dialog bug
yawn-c111 3f85ed7
add: edit role page
yawn-c111 5ef6639
delete: unnecessary comments
yawn-c111 fdbc5b7
refactor: delete unnecessary import
yawn-c111 35b3995
update: check if role updated
yawn-c111 dd333a0
delete: remove unnecessary console logs from EditRole component
yawn-c111 ebb3fb8
refactor: role attributes list
yawn-c111 a233714
fix: adjust margin for InputImage component
yawn-c111 c898bdf
add page header
yu23ki14 aa75a35
refactor: add input dir for components related input
yawn-c111 6c9aeef
feat: disable save button when form state unchanged
yawn-c111 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Box } from "@chakra-ui/react"; | ||
|
||
export const ContentContainer = ({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) => { | ||
return ( | ||
<Box | ||
display="flex" | ||
flexDirection="column" | ||
justifyContent="center" | ||
alignItems="center" | ||
> | ||
{children} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Box, BoxProps } from "@chakra-ui/react"; | ||
import { CommonTextArea } from "./common/CommonTextarea"; | ||
|
||
export const InputDescription = ({ | ||
description, | ||
setDescription, | ||
...boxProps | ||
}: { | ||
description: string; | ||
setDescription: (description: string) => void; | ||
} & BoxProps) => { | ||
return ( | ||
<Box minH="100px" w="100%" {...boxProps}> | ||
<CommonTextArea | ||
minHeight="125px" | ||
placeholder="Description" | ||
value={description} | ||
onChange={(e) => setDescription(e.target.value)} | ||
/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { Box, Input, Text } from "@chakra-ui/react"; | ||
import { CommonIcon } from "./common/CommonIcon"; | ||
import { HiOutlinePlus } from "react-icons/hi2"; | ||
|
||
const EmptyImage = () => { | ||
return ( | ||
<Box | ||
borderRadius="3xl" | ||
border="1px solid" | ||
borderColor="#1e1e1e" | ||
bg="#e9ecef" | ||
p={5} | ||
w={200} | ||
h={200} | ||
> | ||
<Box | ||
display="flex" | ||
flexDirection="column" | ||
justifyContent="center" | ||
alignItems="center" | ||
w="33%" | ||
mx="auto" | ||
mt={9} | ||
mb={1} | ||
> | ||
<HiOutlinePlus size="full" /> | ||
</Box> | ||
<Text textAlign="center">画像を選択</Text> | ||
</Box> | ||
); | ||
}; | ||
|
||
export const InputImage = ({ | ||
imageFile, | ||
setImageFile, | ||
previousImageUrl, | ||
}: { | ||
imageFile: File | null; | ||
setImageFile: (file: File | null) => void; | ||
previousImageUrl?: string; | ||
}) => { | ||
const imageUrl = imageFile | ||
? URL.createObjectURL(imageFile) | ||
: previousImageUrl | ||
? previousImageUrl | ||
: undefined; | ||
|
||
return ( | ||
<Box as="label" cursor="pointer" m="40px auto 40px"> | ||
<Input | ||
type="file" | ||
accept="image/*" | ||
display="none" | ||
onChange={(e) => { | ||
const file = e.target.files?.[0]; | ||
if (file && file.type.startsWith("image/")) { | ||
setImageFile(file); | ||
} else { | ||
alert("画像ファイルを選択してください"); | ||
} | ||
}} | ||
/> | ||
<CommonIcon | ||
imageUrl={imageUrl} | ||
fallbackIconComponent={<EmptyImage />} | ||
size={200} | ||
borderRadius="3xl" | ||
/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Box, BoxProps } from "@chakra-ui/react"; | ||
import { CommonInput } from "./common/CommonInput"; | ||
|
||
interface InputLinkProps extends BoxProps { | ||
link: string; | ||
setLink: (link: string) => void; | ||
} | ||
|
||
export const InputLink = ({ link, setLink, ...boxProps }: InputLinkProps) => { | ||
return ( | ||
<Box w="100%" {...boxProps}> | ||
<CommonInput | ||
minHeight="45px" | ||
placeholder="Link" | ||
value={link} | ||
onChange={(e) => setLink(e.target.value)} | ||
/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Box, BoxProps } from "@chakra-ui/react"; | ||
import { CommonInput } from "./common/CommonInput"; | ||
|
||
export const InputName = ({ | ||
name, | ||
setName, | ||
...boxProps | ||
}: { | ||
name: string; | ||
setName: (name: string) => void; | ||
} & BoxProps) => { | ||
return ( | ||
<Box w="100%" {...boxProps}> | ||
<CommonInput | ||
minHeight="45px" | ||
placeholder="Name" | ||
value={name} | ||
onChange={(e) => setName(e.target.value)} | ||
w="100%" | ||
/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { FC } from "react"; | ||
import { Box, Text } from "@chakra-ui/react"; | ||
import { HatsDetailsAttributes } from "types/hats"; | ||
import { EditRoleAttributeDialog } from "~/components/roleAttributeDialog/EditRoleAttributeDialog"; | ||
|
||
export const RoleAttributesList: FC<{ | ||
items: HatsDetailsAttributes; | ||
setItems: (value: HatsDetailsAttributes) => void; | ||
}> = ({ items, setItems }) => { | ||
return ( | ||
<Box w="100%" mt={2}> | ||
{items.map((_, index) => ( | ||
<Box | ||
key={index} | ||
minHeight="45px" | ||
mt={2} | ||
width="100%" | ||
border="1px solid" | ||
borderColor="gray.800" | ||
borderRadius="xl" | ||
backgroundColor="white" | ||
py="auto" | ||
display="flex" | ||
alignItems="stretch" | ||
justifyContent="space-between" | ||
gap={4} | ||
fontWeight="normal" | ||
> | ||
<Text ml={4} display="flex" alignItems="center"> | ||
{items[index]?.label} | ||
</Text> | ||
<Box ml="auto" display="flex" alignItems="center"> | ||
<EditRoleAttributeDialog | ||
type="responsibility" | ||
attributes={items} | ||
setAttributes={setItems} | ||
attributeIndex={index} | ||
/> | ||
</Box> | ||
</Box> | ||
))} | ||
</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
47 changes: 47 additions & 0 deletions
47
pkgs/frontend/app/components/roleAttributeDialog/AddRoleAttributeDialog.tsx
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,47 @@ | ||
import { Button } from "@chakra-ui/react"; | ||
import { DialogTrigger } from "../ui/dialog"; | ||
import { BaseRoleAttributeDialog } from "./BaseRoleAttributeDialog"; | ||
import { HatsDetailsAttributes } from "types/hats"; | ||
|
||
const PlusButton = () => { | ||
return ( | ||
<DialogTrigger asChild> | ||
<Button | ||
aria-label="add" | ||
width="full" | ||
bg="blue.500" | ||
mt={4} | ||
color="gray.50" | ||
> | ||
+ | ||
</Button> | ||
</DialogTrigger> | ||
); | ||
}; | ||
|
||
interface AddRoleAttributeDialogProps { | ||
type: "responsibility" | "authority"; | ||
attributes: HatsDetailsAttributes; | ||
setAttributes: (attributes: HatsDetailsAttributes) => void; | ||
} | ||
|
||
export const AddRoleAttributeDialog = ({ | ||
type, | ||
attributes, | ||
setAttributes, | ||
}: AddRoleAttributeDialogProps) => { | ||
const onClick = (name: string, description: string, link: string) => { | ||
setAttributes([...attributes, { label: name, description, link }]); | ||
}; | ||
|
||
return ( | ||
<> | ||
<BaseRoleAttributeDialog | ||
type={type} | ||
mode="add" | ||
TriggerButton={<PlusButton />} | ||
onClick={onClick} | ||
/> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
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.
InputDescription, InputImage, InputLink, InputNameを /components/input/~~~.tsx にディレクトリ一つ掘っていただけると!