-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f87cf10
commit 9ffe8c3
Showing
5 changed files
with
141 additions
and
1 deletion.
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,62 @@ | ||
import { Box, Button, Modal, Text, Image } from '@mantine/core'; | ||
import { useState } from 'react'; | ||
import useSWR from 'swr'; | ||
import { LookBook } from '../api/ai'; | ||
|
||
interface LookBookSelectModalButtonProps { | ||
onAddLookBook: (lookBook: LookBook) => void; | ||
} | ||
|
||
const LookBookSelectModalButton = ({ | ||
onAddLookBook, | ||
}: LookBookSelectModalButtonProps) => { | ||
const { data } = useSWR<{ total: number; list: LookBook[] }>('/ai'); | ||
const [show, setShow] = useState(false); | ||
|
||
return ( | ||
<> | ||
<Button type="button" onClick={() => setShow(true)}> | ||
Select LookBooks | ||
</Button> | ||
<Modal | ||
opened={show} | ||
onClose={() => setShow(false)} | ||
title={<Text size="lg">Select LookBook</Text>} | ||
> | ||
<Box | ||
w="100%" | ||
display="flex" | ||
style={{ flexDirection: 'column', gap: 4 }} | ||
> | ||
{data?.list.map((lookBook) => ( | ||
<Box | ||
key={lookBook.id} | ||
h={400} | ||
bd="1px solid black" | ||
style={{ position: 'relative' }} | ||
> | ||
<Image | ||
src={lookBook.imageUrl} | ||
alt={lookBook.prompt} | ||
h={200} | ||
fit="contain" | ||
/> | ||
<Text>{lookBook.prompt}</Text> | ||
<Button | ||
onClick={() => { | ||
onAddLookBook(lookBook); | ||
setShow(false); | ||
}} | ||
style={{ position: 'absolute', right: 0, bottom: 0 }} | ||
> | ||
Add | ||
</Button> | ||
</Box> | ||
))} | ||
</Box> | ||
</Modal> | ||
</> | ||
); | ||
}; | ||
|
||
export default LookBookSelectModalButton; |
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,66 @@ | ||
import { Box, Button, Image, Input, Text, Textarea } from '@mantine/core'; | ||
import { useState } from 'react'; | ||
import { LookBook } from '../api/ai'; | ||
import LookBookSelectModalButton from './LookBookSelectModalButton'; | ||
import { createPost } from '../api/post'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
const PostCreatePage = () => { | ||
const [imageUrls, setImageUrls] = useState<string[]>([]); | ||
const navigate = useNavigate(); | ||
|
||
const upload = async (e: React.FormEvent<HTMLFormElement>) => { | ||
e.preventDefault(); | ||
const res = await createPost({ | ||
title: e.currentTarget.titleText.value, | ||
body: e.currentTarget.content.value, | ||
imageUrls, | ||
}); | ||
navigate(`/posts/${res.id}`); | ||
}; | ||
|
||
return ( | ||
<Box | ||
display="flex" | ||
style={{ flexDirection: 'column', gap: 4 }} | ||
p={4} | ||
component="form" | ||
onSubmit={upload} | ||
> | ||
<Box display="flex" style={{ alignItems: 'center', gap: 4 }} ta="right"> | ||
<Text style={{ width: 80 }}>Title</Text> | ||
<Input name="titleText" required /> | ||
</Box> | ||
<Box display="flex" style={{ gap: 4 }}> | ||
<Text style={{ width: 80 }} ta="right"> | ||
Content | ||
</Text> | ||
<Textarea name="content" required /> | ||
</Box> | ||
<Box display="flex" style={{ gap: 4 }}> | ||
<Text style={{ width: 80 }} ta="right"> | ||
Selected LookBooks | ||
</Text> | ||
<Box | ||
miw={200} | ||
mih={200} | ||
bd="1px solid black" | ||
display="flex" | ||
style={{ gap: 4 }} | ||
> | ||
{imageUrls.map((url) => ( | ||
<Image key={url} src={url} alt="LookBook" h={300} fit="contain" /> | ||
))} | ||
</Box> | ||
</Box> | ||
<LookBookSelectModalButton | ||
onAddLookBook={(lookBook: LookBook) => | ||
setImageUrls([...imageUrls, lookBook.imageUrl]) | ||
} | ||
/> | ||
<Button type="submit">Create Post</Button> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default PostCreatePage; |
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,5 @@ | ||
const PostDetailPage = () => { | ||
return null; | ||
}; | ||
|
||
export default PostDetailPage; |
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