Skip to content

Commit

Permalink
Merge pull request #245 from TogetherCrew/fix/announcements-issues-29/1
Browse files Browse the repository at this point in the history
Fix/announcements issues 29/1
  • Loading branch information
mehdi-torabiv authored Jan 29, 2024
2 parents 31cc858 + cc729b0 commit 41d993c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const formatDateToLocalTimezone = (scheduledDate: string) => {
return 'Invalid Date';
}

const formattedDate = moment(scheduledDate).format('MMMM D [at] hA');
const formattedDate = moment(scheduledDate).format('MMMM D [at] hh:mm A');

const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,7 @@ function TcPrivateMessageContainer({
if (message && privateMessage) {
prepareAndSendData();
}
}, [
message,
selectedRoles,
selectedUsers,
messageType,
privateMessage,
handlePrivateAnnouncements,
]);
}, [message, selectedRoles, selectedUsers, messageType, privateMessage]);

useEffect(() => {
if (isEdit && privateAnnouncementsData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import React, { useEffect, useState } from 'react';
import { useToken } from '../../../../context/TokenContext';
import useAppStore from '../../../../store/useStore';
import { FetchedData, IUser } from '../../../../utils/interfaces';
import { debounce } from '../../../../helpers/helper';
import { debounce, truncateCenter } from '../../../../helpers/helper';
import TcAutocomplete from '../../../shared/TcAutocomplete';
import { Chip, CircularProgress } from '@mui/material';
import TcAvatar from '../../../shared/TcAvatar';
import TcText from '../../../shared/TcText';
import { conf } from '../../../../configs';

interface ITcUsersAutoCompleteProps {
isEdit?: boolean;
Expand Down Expand Up @@ -182,26 +185,54 @@ function TcUsersAutoComplete({
disableCloseOnSelect
renderOption={(props, option) => (
<li {...props} key={option.discordId}>
{option.ngu}
<div className="flex items-center space-x-2">
<TcAvatar
sx={{ height: '28px', width: '28px' }}
src={
option.discordId && option?.avatar
? `${conf.DISCORD_CDN}avatars/${option.discordId}/${option?.avatar}.png`
: ''
}
alt="User Avatar"
/>
<TcText text={option.ngu} />
<TcText
text={`${
option.username ? '@' + truncateCenter(option.username, 10) : ''
}`}
className="text-gray-500"
/>
</div>
</li>
)}
renderTags={(value, getTagProps) =>
value.map((option, index) => (
<Chip
variant="outlined"
label={
<div style={{ display: 'flex', alignItems: 'center' }}>
<span
style={{
height: '8px',
width: '8px',
backgroundColor: '#96A5A6',
borderRadius: '50%',
display: 'inline-block',
marginRight: '5px',
}}
<div className="flex items-center space-x-1">
<div>
<span
style={{
height: '8px',
width: '8px',
backgroundColor: '#96A5A6',
borderRadius: '50%',
display: 'inline-block',
marginRight: '5px',
}}
/>
<TcText text={option.ngu} variant="caption" />
</div>
<TcText
text={`${
option.username
? '@' + truncateCenter(option.username, 10)
: ''
}`}
variant="caption"
className="text-gray-500"
/>
{option.ngu}
</div>
}
size="small"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/announcements/edit-announcements/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function Index() {

if (data) {
showMessage('Announcement updated successfully', 'success');
location.replace('/announcements');
router.push('/announcements');
}
} catch (error) {
showMessage('Failed to create announcement', 'error');
Expand Down

0 comments on commit 41d993c

Please sign in to comment.