Skip to content

Commit

Permalink
bugfix (#559)
Browse files Browse the repository at this point in the history
* hot fix, postView title margin bottom

* hot fix, autofill find post author field on update post

* hot fix, autofill find post author field on update post

* edit testCase

* edit postCreation files
  • Loading branch information
0shar0 authored Sep 7, 2021
1 parent 89f0e19 commit c789f2b
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 23 deletions.
3 changes: 2 additions & 1 deletion src/old/modules/posts/styles/PostView.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const useStyles = makeStyles(
position: 'relative',
minHeight: '550px',
padding: '70px 225px 150px',
wordBreak:'break-word',
wordBreak: 'break-word',
},
wrapper: {
display: 'flex',
Expand Down Expand Up @@ -34,6 +34,7 @@ export const useStyles = makeStyles(
flexDirection: 'column',
'& h1': {
marginTop: theme.spacing(14),
marginBottom: theme.spacing(10),
},
},
createdAt: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ describe('PostAuthorSeclection', () => {
const { getAllByTestId } = render(
<PostAuthorSelection
authors={authors}
isDisplayTable
onAuthorTableClick={onAuthorTableClick}
handleOnChange={() => {}}
/>,
Expand All @@ -97,6 +98,7 @@ describe('PostAuthorSeclection', () => {
render(
<PostAuthorSelection
authors={authors}
isDisplayTable
searchValue="Ivan"
onAuthorTableClick={onAuthorTableClick}
handleOnChange={handleOnChangeMock}
Expand All @@ -113,6 +115,7 @@ describe('PostAuthorSeclection', () => {
const { getByPlaceholderText } = render(
<PostAuthorSelection
authors={authors}
isDisplayTable
searchValue="Ivan"
onAuthorTableClick={onAuthorTableClick}
handleOnChange={handleOnChangeMock}
Expand All @@ -131,6 +134,7 @@ describe('PostAuthorSeclection', () => {
const { getByPlaceholderText } = render(
<PostAuthorSelection
authors={authors}
isDisplayTable
searchValue="Ivan"
onAuthorTableClick={onAuthorTableClick}
handleOnChange={handleOnChangeMock}
Expand All @@ -149,6 +153,7 @@ describe('PostAuthorSeclection', () => {
const { getByRole, rerender } = render(
<PostAuthorSelection
authors={[]}
isDisplayTable
searchValue=""
onAuthorTableClick={onAuthorTableClick}
handleOnChange={handleOnChangeMock}
Expand All @@ -161,6 +166,7 @@ describe('PostAuthorSeclection', () => {
rerender(
<PostAuthorSelection
authors={newAuthors}
isDisplayTable
searchValue="I"
onAuthorTableClick={onAuthorTableClick}
handleOnChange={handleOnChangeMock}
Expand Down
43 changes: 23 additions & 20 deletions src/views/postCreation/PostAuthorSelection/PostAuthorSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ interface IPostAuthorSelectionProps {
onAuthorTableClick: (value: number, item: ExpertResponseType) => void;
authors?: ExpertResponseType[];
searchValue?: string;
authorsLength?: number|null;
authorsLength?: number | null;
isDisplayTable?: boolean;
}

export const PostAuthorSelection: React.FC<IPostAuthorSelectionProps> = ({
handleOnChange,
onAuthorTableClick,
searchValue,
authors,
authorsLength
authorsLength,
isDisplayTable,
}) => {
const { t } = useTranslation();
const classes = useStyle();
Expand Down Expand Up @@ -64,24 +66,25 @@ export const PostAuthorSelection: React.FC<IPostAuthorSelectionProps> = ({
/>
</FormControl>

{authors?.length !== 0 ? (
<Table>
<TableHead>
<TableRow>
<TableCell>#</TableCell>
<TableCell>First Name</TableCell>
<TableCell>Second Name</TableCell>
</TableRow>
</TableHead>
<TableBody>{table}</TableBody>
</Table>
) : (
authorsLength === 0 && searchValue?.length !== 0 && (
<div style={{ color: 'red' }}>
{t(langTokens.common.noFoundAuthors)}
</div>
)
)}
{authors?.length !== 0
? isDisplayTable && (
<Table>
<TableHead>
<TableRow>
<TableCell>#</TableCell>
<TableCell>First Name</TableCell>
<TableCell>Second Name</TableCell>
</TableRow>
</TableHead>
<TableBody>{table}</TableBody>
</Table>
)
: authorsLength === 0 &&
searchValue?.length !== 0 && (
<div style={{ color: 'red' }}>
{t(langTokens.common.noFoundAuthors)}
</div>
)}

<div style={{ marginBottom: '24px' }} />
</>
Expand Down
1 change: 1 addition & 0 deletions src/views/postCreation/TextPostCreation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ export const TextPostCreation: React.FC<IPostCreationProps> = ({

const postAuthorSelection = isAdmin && (
<PostAuthorSelection
isDisplayTable
onAuthorTableClick={onAuthorTableClick}
handleOnChange={handleOnChange}
authors={authors}
Expand Down
1 change: 1 addition & 0 deletions src/views/postCreation/VideoCreation/VideoPostCreation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ export const VideoPostCreation: React.FC<IVideoPostCreationProps> = ({

const postAuthorSelection = isAdmin && (
<PostAuthorSelection
isDisplayTable
onAuthorTableClick={onAuthorTableClick}
handleOnChange={handleOnChange}
authors={authors}
Expand Down
5 changes: 4 additions & 1 deletion src/views/postUpdation/TextPostUpdation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ export const TextPostUpdation: React.FC<ITextPostUpdationProps> = ({
const [authors, setAuthors] = useState<ExpertResponseType[]>([]);
const [authorId, setAuthorId] = useState<number | null>(null);
const [author, setAuthor] = useState<ExpertResponseType>();
const [searchValue, setSearchValue] = useState('');
const [searchValue, setSearchValue] = useState(`${post.author.firstName} ${post.author.lastName}`);
const [authorLength, setAuthorLength] = useState<number | null>(null);
const [typing, setTyping] = useState({ content: false, preview: false });
const [previewing, setPreviewing] = useState(false);
const [isDisplayTable, setIsDisplayTable] = useState(false);

const { t } = useTranslation();

Expand Down Expand Up @@ -113,6 +114,7 @@ export const TextPostUpdation: React.FC<ITextPostUpdationProps> = ({
);

const handleOnChange = (value: string) => {
setIsDisplayTable(true);
setSearchValue(value);
};

Expand Down Expand Up @@ -219,6 +221,7 @@ export const TextPostUpdation: React.FC<ITextPostUpdationProps> = ({

const postAuthorSelection = isAdmin && (
<PostAuthorSelection
isDisplayTable={isDisplayTable}
onAuthorTableClick={onAuthorTableClick}
handleOnChange={handleOnChange}
authors={authors}
Expand Down
5 changes: 4 additions & 1 deletion src/views/postUpdation/VideoUpdation/VideoPostUpdation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ export const VideoPostUpdation: React.FC<ITextPostUpdationProps> = ({
const [authors, setAuthors] = useState<ExpertResponseType[]>([]);
const [authorId, setAuthorId] = useState<number | null>(null);
const [author, setAuthor] = useState<ExpertResponseType>();
const [searchValue, setSearchValue] = useState('');
const [searchValue, setSearchValue] = useState(`${post.author.firstName} ${post.author.lastName}`);
const [authorLength, setAuthorLength] = useState<number | null>(null);
const [typing, setTyping] = useState({ content: false, preview: false });
const [previewing, setPreviewing] = useState(false);
const [isDisplayTable, setIsDisplayTable] = useState(false);

const { t } = useTranslation();

Expand Down Expand Up @@ -105,6 +106,7 @@ export const VideoPostUpdation: React.FC<ITextPostUpdationProps> = ({
);

const handleOnChange = (value: string) => {
setIsDisplayTable(true);
setSearchValue(value);
};

Expand Down Expand Up @@ -197,6 +199,7 @@ export const VideoPostUpdation: React.FC<ITextPostUpdationProps> = ({

const postAuthorSelection = isAdmin && (
<PostAuthorSelection
isDisplayTable={isDisplayTable}
onAuthorTableClick={onAuthorTableClick}
handleOnChange={handleOnChange}
authors={authors}
Expand Down

0 comments on commit c789f2b

Please sign in to comment.