mirror of
https://github.com/bubblecup-12/VogelSocialMedia.git
synced 2025-07-06 15:18:48 +00:00
Before changing to grid
This commit is contained in:
parent
b156360c3a
commit
1c67a3dacc
2 changed files with 24 additions and 20 deletions
|
@ -1,6 +1,6 @@
|
||||||
import "./postCreation.css";
|
import "./postCreation.css";
|
||||||
import "./loginAndSignUpPage.css";
|
import "./loginAndSignUpPage.css";
|
||||||
import { useState, ChangeEvent } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import Chip from '@mui/material/Chip';
|
import Chip from '@mui/material/Chip';
|
||||||
import Autocomplete from '@mui/material/Autocomplete';
|
import Autocomplete from '@mui/material/Autocomplete';
|
||||||
|
@ -29,25 +29,13 @@ import CloseIcon from '@mui/icons-material/Close';
|
||||||
|
|
||||||
function PostCreation(){
|
function PostCreation(){
|
||||||
const {user} = useAuth();
|
const {user} = useAuth();
|
||||||
const startTags = [
|
|
||||||
{ title: 'Bird' },
|
|
||||||
{ title: 'Birds'},
|
|
||||||
{ title: 'Feather'},
|
|
||||||
{ title: 'Bird Feather'},
|
|
||||||
{ title: 'Feathers'},
|
|
||||||
{ title: 'Featherfeed'}
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
interface ImageItem {
|
interface ImageItem {
|
||||||
src: string;
|
src: string;
|
||||||
title: string;
|
title: string;
|
||||||
}
|
}
|
||||||
|
const [options, setOptions] = useState<string[]>([]);
|
||||||
const initialOptions = startTags.map((option) => option.title);
|
const [tags, setTags] = useState<string[]>([]);
|
||||||
|
|
||||||
const [options, setOptions] = useState(initialOptions);
|
|
||||||
const [tags, setTags] = useState<string[]>([initialOptions[1]]);
|
|
||||||
const [description, setDescription] = useState<string>("");
|
const [description, setDescription] = useState<string>("");
|
||||||
const [selectedImage, setSelectedImage] = useState<string>();
|
const [selectedImage, setSelectedImage] = useState<string>();
|
||||||
|
|
||||||
|
@ -56,6 +44,19 @@ function PostCreation(){
|
||||||
|
|
||||||
const [fileList,setFileList] = useState<FileList|null>(null);
|
const [fileList,setFileList] = useState<FileList|null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let cancelled = false;
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
const res = await api.get<string[]>("/posts/tags"); // GET /api/posts/tags
|
||||||
|
if (!cancelled) setOptions(res.data);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
return () => { cancelled = true; };
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||||
setDescription(event.target.value);
|
setDescription(event.target.value);
|
||||||
};
|
};
|
||||||
|
@ -114,7 +115,6 @@ function PostCreation(){
|
||||||
} catch (error:any) {
|
} catch (error:any) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
const onCancel= () => {
|
const onCancel= () => {
|
||||||
navigate("/profile")
|
navigate("/profile")
|
||||||
|
@ -128,6 +128,7 @@ function PostCreation(){
|
||||||
<div className="create-part">
|
<div className="create-part">
|
||||||
<form onSubmit={onSubmit}>
|
<form onSubmit={onSubmit}>
|
||||||
<h1>Create Post</h1>
|
<h1>Create Post</h1>
|
||||||
|
<div className="create-layout">
|
||||||
<div className="create-account">
|
<div className="create-account">
|
||||||
<Avatar >OP</Avatar>
|
<Avatar >OP</Avatar>
|
||||||
<span className="create-username">{user?.username}</span>
|
<span className="create-username">{user?.username}</span>
|
||||||
|
@ -230,16 +231,15 @@ function PostCreation(){
|
||||||
multiple
|
multiple
|
||||||
id="tags-filled"
|
id="tags-filled"
|
||||||
options={options}
|
options={options}
|
||||||
defaultValue={[startTags[1].title]}
|
|
||||||
freeSolo
|
freeSolo
|
||||||
value={tags}
|
value={tags}
|
||||||
onChange={handleTags}
|
onChange={handleTags}
|
||||||
sx={{ width: "90vw" }}
|
sx={{ width: "90vw" }}
|
||||||
renderValue={(value: readonly string[], getItemProps) =>
|
renderValue={(value: readonly string[], getItemProps) =>
|
||||||
value.map((option: string, index: number) => {
|
value.map((tags: string, index: number) => {
|
||||||
const { key, ...itemProps } = getItemProps({ index });
|
const { key, ...itemProps } = getItemProps({ index });
|
||||||
return (
|
return (
|
||||||
<Chip variant="outlined" label={option} key={key} {...itemProps} />
|
<Chip variant="outlined" label={tags} key={key} {...itemProps} />
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -258,6 +258,7 @@ function PostCreation(){
|
||||||
<ButtonPrimary style="primary" label="Post" type="submit" ></ButtonPrimary>
|
<ButtonPrimary style="primary" label="Post" type="submit" ></ButtonPrimary>
|
||||||
<ButtonPrimary style="secondary" label="Cancel" type="button" onClick={onCancel} ></ButtonPrimary>
|
<ButtonPrimary style="secondary" label="Cancel" type="button" onClick={onCancel} ></ButtonPrimary>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -21,7 +21,10 @@
|
||||||
border-left: 4px solid var(--Rotkehlchen-gray-hover);
|
border-left: 4px solid var(--Rotkehlchen-gray-hover);
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
}
|
}
|
||||||
|
.create-layout{
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: auto auto auto;
|
||||||
|
}
|
||||||
.create-account{
|
.create-account{
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue