Skip to content

Commit

Permalink
Merge pull request #103 from BacPacNet/post_access_dropdown
Browse files Browse the repository at this point in the history
added post access dropdown
  • Loading branch information
bacpactech authored Nov 7, 2024
2 parents 60ca87f + 02bf2ad commit 2b3511c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/components/organisms/UserPostContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useCreateUserPost } from '@/services/community-timeline'
import { replaceImage } from '@/services/uploadImage'
import { useUniStore } from '@/store/store'
import { Skeleton } from '@/components/ui/Skeleton'
import SelectDropdown from '@/components/atoms/SelectDropdown/SelectDropdown'

type props = {
communityID?: string
Expand All @@ -25,6 +26,7 @@ function UserPostContainer({ communityID, communityGroupID, type }: props) {
const textareaRef = useRef<HTMLTextAreaElement>(null)
const valueRef = useRef<string>('')
const [images, setImages] = useState<File[]>([])
const [postAccessType, setPostAccessType] = useState('Public')
const { mutate: CreateGroupPost, isPending } = useCreateGroupPost()
const { mutate: CreateTimelinePost } = useCreateUserPost()
const { userProfileData } = useUniStore()
Expand Down Expand Up @@ -84,6 +86,7 @@ function UserPostContainer({ communityID, communityGroupID, type }: props) {
const data: PostInputData = {
content: inputValue,
imageUrl: imagedata,
...(type == PostInputType.Timeline ? { PostType: postAccessType } : { communityPostsType: postAccessType }),
}

//if type is community , add communityId field to data
Expand All @@ -100,6 +103,7 @@ function UserPostContainer({ communityID, communityGroupID, type }: props) {
} else {
const data: PostInputData = {
content: inputValue,
...(type == PostInputType.Timeline ? { PostType: postAccessType } : { communityPostsType: postAccessType }),
}
if (type === PostInputType.Community) {
const communityData: CommunityPostData = {
Expand Down Expand Up @@ -171,6 +175,17 @@ function UserPostContainer({ communityID, communityGroupID, type }: props) {
<label htmlFor="postPool">
<VscSettings size={24} className="text-neutral-400" />
</label>
<div className="w-28 max-sm:w-20">
<SelectDropdown
options={['Public', 'Private']}
value={postAccessType}
onChange={(e) => setPostAccessType(e)}
placeholder=""
icon={'single'}
// search={true}
err={false}
/>
</div>
</div>
<div>
<button onClick={handleSubmit} className="bg-primary-500 text-white rounded-lg px-3 py-2 w-[69px]">
Expand Down
2 changes: 2 additions & 0 deletions src/types/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ export interface PostInputData {
imageUrl: string
publicId: string
}>
PostType?: string
communityPostsType?: string
}

export interface UserPostData extends PostInputData {}
Expand Down

0 comments on commit 2b3511c

Please sign in to comment.