-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from alpaca-tc/add_memo
Add memo
- Loading branch information
Showing
25 changed files
with
502 additions
and
112 deletions.
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
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
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
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
45 changes: 45 additions & 0 deletions
45
frontend/pages/DefinitionList/components/SourceMemoInput/SourceMemoInput.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,45 @@ | ||
import React, { FC, useCallback, useEffect, useState } from 'react' | ||
|
||
import { Button, Cluster, FaXmarkIcon, FormControl, Input, Textarea } from '@/components/ui' | ||
import { useSourceMemo } from '@/repositories/sourceMemoRepository' | ||
|
||
type Props = { | ||
sourceName: string | ||
initialMemo: string | ||
onClose: () => void | ||
onUpdate: () => void | ||
} | ||
|
||
export const SourceMemoInput: FC<Props> = ({ sourceName, initialMemo, onClose, onUpdate }) => { | ||
const { trigger } = useSourceMemo(sourceName) | ||
|
||
const [memo, setMemo] = useState<string>(initialMemo) | ||
|
||
const handleUpdate = useCallback(async () => { | ||
await trigger({ memo }) | ||
onUpdate() | ||
}, [trigger, memo, onUpdate]) | ||
|
||
const onInputMemo = useCallback( | ||
(event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => { | ||
setMemo(event.target.value) | ||
}, | ||
[setMemo], | ||
) | ||
|
||
return ( | ||
<Cluster> | ||
<div> | ||
<FormControl title="Memo" helpMessage="Free memo field."> | ||
<Textarea onChange={onInputMemo} value={memo} autoResize /> | ||
</FormControl> | ||
</div> | ||
<Button square={true} variant="primary" onClick={handleUpdate} size="s"> | ||
Update | ||
</Button> | ||
<Button square={true} onClick={onClose} size="s"> | ||
<FaXmarkIcon alt="Cancel" /> | ||
</Button> | ||
</Cluster> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
frontend/pages/DefinitionList/components/SourceMemoInput/index.ts
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 @@ | ||
export { SourceMemoInput } from './SourceMemoInput' |
Oops, something went wrong.