Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/announcements #234

Merged
merged 40 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
599d162
Merge pull request #160 from TogetherCrew/development
cyri113 Jul 27, 2023
bfc2bea
Merge pull request #164 from TogetherCrew/development
cyri113 Aug 2, 2023
2ece4f7
Merge pull request #167 from TogetherCrew/development
cyri113 Aug 5, 2023
9f477e7
Merge pull request #170 from TogetherCrew/development
cyri113 Aug 29, 2023
55fed52
Merge pull request #174 from TogetherCrew/development
cyri113 Sep 5, 2023
8c20e00
Merge pull request #177 from TogetherCrew/development
cyri113 Sep 8, 2023
c6ab738
Merge pull request #192 from TogetherCrew/development
cyri113 Sep 19, 2023
54de3ff
Merge pull request #229 from TogetherCrew/development
cyri113 Dec 22, 2023
ef5c07d
Merge pull request #231 from TogetherCrew/development
cyri113 Dec 22, 2023
8d9e76f
fix issue on fetch data first render
Jan 18, 2024
763b3ab
Merge pull request #233 from TogetherCrew/fix/heatmap-channels
cyri113 Jan 18, 2024
33d3cfa
remove useless code on privateRoute.tsx
Dec 22, 2023
ea3d5c4
remove useless code on index.tsx route and remove old components
Dec 22, 2023
f7d3b07
remove old settings components
Dec 22, 2023
95c80f9
remove settingSlice & authSlice
Dec 22, 2023
9a0efb7
remove old channelList component
Dec 22, 2023
7b99adb
remove useless global component
Dec 22, 2023
92d4f96
create announcements initial route
Dec 25, 2023
fc6fb47
create shared tableContainer component
Dec 26, 2023
138f9f5
public message container done
Dec 27, 2023
2c21184
add TcSwitch component
Dec 27, 2023
f6a7cb3
complete create-announcements
Jan 3, 2024
fd9db25
update announcements-list page
Jan 4, 2024
bdcf53a
make announcements-list page responsive
Jan 4, 2024
33d5fc2
make create announcements page responsive
Jan 4, 2024
3ab8322
add slice for announcements
Jan 4, 2024
fbdb699
add dialog for public message
Jan 8, 2024
eda874e
add private preview dialog and edit announcements
Jan 8, 2024
8dca83d
add confimDialog for create announcements
Jan 9, 2024
a280a1b
implement basic create method
Jan 15, 2024
b6cc0bb
complete create announcements integration
Jan 17, 2024
ed03673
add list integration
Jan 17, 2024
7926de5
update create,list announcements
Jan 18, 2024
8242779
integrate edit announcements
Jan 18, 2024
f353b41
complete announcement feature
Jan 19, 2024
e3f8e16
fix style
Jan 19, 2024
7e26509
fix issue on fetch data and styles
Jan 19, 2024
8e2f91a
fix styles on table and filter issue
Jan 19, 2024
db7a78c
fix issue
Jan 19, 2024
079cc76
updaet button style
Jan 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
389 changes: 307 additions & 82 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"dependencies": {
"@amplitude/analytics-browser": "^1.9.4",
"@date-io/date-fns": "^2.17.0",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@fortawesome/fontawesome-svg-core": "^6.2.0",
Expand All @@ -23,6 +24,7 @@
"@hassanmojab/react-modern-calendar-datepicker": "^3.1.7",
"@mui/lab": "^5.0.0-alpha.121",
"@mui/material": "^5.10.13",
"@mui/x-date-pickers": "^6.18.6",
"@sentry/nextjs": "^7.50.0",
"@types/node": "18.11.9",
"@types/react": "18.0.25",
Expand All @@ -34,6 +36,7 @@
"axios": "^1.2.2",
"clsx": "^1.2.1",
"d3-force": "^3.0.0",
"date-fns": "^2.30.0",
"eslint": "8.27.0",
"eslint-config-next": "13.0.2",
"eslint-config-prettier": "^8.6.0",
Expand Down
16 changes: 16 additions & 0 deletions src/axiosInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,22 @@ axiosInstance.interceptors.response.use(
});
window.location.href = '/';

Sentry.captureException(
new Error(
`API responded with status code ${error.response.status}: ${error.response.data.message}`
)
);
break;
case 500:
toast.error(`${error.response.data.message}`, {
position: 'bottom-left',
autoClose: 5000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: 0,
});
Sentry.captureException(
new Error(
`API responded with status code ${error.response.status}: ${error.response.data.message}`
Expand Down
29 changes: 29 additions & 0 deletions src/components/announcements/TcAnnouncementsAlert.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { render, fireEvent, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import TcAnnouncementsAlert from './TcAnnouncementsAlert';

const mockGrantWritePermissions = jest.fn();

jest.mock('../../store/useStore', () => () => ({
grantWritePermissions: mockGrantWritePermissions,
}));

jest.mock('../../context/TokenContext', () => ({
useToken: () => ({
community: {
platforms: [
{ id: '1', disconnectedAt: null, metadata: { id: '3123141414221' } },
],
},
}),
}));

describe('TcAnnouncementsAlert', () => {
it('renders correctly', () => {
render(<TcAnnouncementsAlert />);
expect(
screen.getByText(/Announcements needs write access at the server-level/i)
).toBeInTheDocument();
});
});
69 changes: 69 additions & 0 deletions src/components/announcements/TcAnnouncementsAlert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React from 'react';
import TcAlert from '../shared/TcAlert';
import TcCollapse from '../shared/TcCollapse';
import TcText from '../shared/TcText';
import TcButton from '../shared/TcButton';
import useAppStore from '../../store/useStore';
import { useToken } from '../../context/TokenContext';

function TcAnnouncementsAlert() {
const { grantWritePermissions } = useAppStore();

const { community } = useToken();

const handleGrantAccess = () => {
const guildId = community?.platforms.find(
(platform) => platform.disconnectedAt === null
)?.metadata.id;

if (guildId)
grantWritePermissions({
platformType: 'discord',
moduleType: 'Announcement',
id: guildId,
});
};
return (
<TcCollapse
in={true}
sx={{
position: 'sticky',
top: 0,
zIndex: 999,
'&:MuiPaper-root': {
display: 'flex',
justifyContent: 'center',
},
}}
>
<TcAlert
variant="filled"
className={'bg-error-500'}
icon={false}
sx={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
paddingY: 0,
}}
>
<div className="md:space-x-3 flex flex-col md:flex-row items-center justify-center p-0">
<TcText
text={
'Announcements needs write access at the server-level (i.e. Send Message, Send Messages in Threads, Create Public Threads, Create Private Threads, etc)'
}
color={'white'}
variant={'subtitle1'}
/>
<TcButton
text="Update Permissions"
onClick={handleGrantAccess}
className="text-white"
/>
</div>
</TcAlert>
</TcCollapse>
);
}

export default TcAnnouncementsAlert;
Loading
Loading