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

Notifications System Version 2 #2667

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
742d5be
modify get router
Catherine9898 Jul 3, 2023
3bc8be4
5routers
Catherine9898 Jul 6, 2023
83260a5
all routers
Catherine9898 Jul 7, 2023
b5a0471
modify admin colum
Catherine9898 Jul 19, 2023
ab04f18
add default time col for user page
Catherine9898 Jul 19, 2023
9aa26b7
swap type col and assessment col
Catherine9898 Jul 19, 2023
0fe7176
swap type col and assessment col
Catherine9898 Jul 19, 2023
e2a816d
NA logic
Catherine9898 Jul 19, 2023
c115c12
change to reminder col
Catherine9898 Aug 8, 2023
2411f32
show NA
Catherine9898 Aug 8, 2023
cac0631
fix the prefer page box
Catherine9898 Aug 15, 2023
bffc75c
Fix the empty n_config_id
Catherine9898 Aug 15, 2023
915bbe7
Fix some bugs in staff page
Catherine9898 Aug 17, 2023
40f474d
test
Catherine9898 Sep 5, 2023
2ecd01f
delete some useless comments
Catherine9898 Sep 6, 2023
f4a3bdc
Resolve merge conflict
Catherine9898 Sep 6, 2023
badc7d0
delete unuseful comments
Catherine9898 Sep 6, 2023
b2b8b52
fix argument bugs
Catherine9898 Sep 6, 2023
38cbaed
Merge branch 'master' into sv
RichDom2185 Sep 9, 2023
7b3e76a
Autofix formatting
RichDom2185 Sep 9, 2023
a93b0a3
Fix requests
RichDom2185 Sep 9, 2023
241aff9
Remove unused components
RichDom2185 Sep 9, 2023
95e4ad8
Remove commented code
RichDom2185 Sep 9, 2023
544352c
Merge branch 'master' into sv
RichDom2185 Sep 10, 2023
9ecaf8b
Merge branch 'master' into sv
martin-henz Sep 18, 2023
08ea0be
Merge branch 'master' into sv
martin-henz Sep 19, 2023
fe850a1
Merge branch 'master' into sv
RichDom2185 Oct 18, 2023
88edacb
Merge branch 'master' into sv
RichDom2185 Oct 19, 2023
42bfb58
Merge branch 'master' into sv
RichDom2185 Nov 2, 2023
d09f63c
Merge branch 'master' into sv
RichDom2185 Nov 2, 2023
34d83f0
Merge branch 'master' into sv
RichDom2185 Nov 6, 2023
a9359ec
Merge branch 'master' into sv
RichDom2185 Nov 21, 2023
2814599
Merge branch 'master' into sv
RichDom2185 Dec 8, 2023
988923c
Merge branch 'master' into sv
RichDom2185 Jan 9, 2024
672e9d9
Merge branch 'master' into sv
RichDom2185 Jan 16, 2024
4b31673
Merge branch 'master' of https://github.com/source-academy/frontend i…
RichDom2185 Feb 11, 2024
277fb92
Merge branch 'master' into sv
martin-henz Feb 22, 2024
44c56b4
Merge branch 'master' into sv
RichDom2185 Feb 23, 2024
7b9ebe9
Merge branch 'master' into sv
RichDom2185 Feb 23, 2024
f6dc48a
Merge branch 'master' into sv
RichDom2185 Feb 23, 2024
44fe903
Merge branch 'master' into sv
RichDom2185 Feb 24, 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
57 changes: 37 additions & 20 deletions src/commons/sagas/RequestsSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1014,11 +1014,12 @@ export const putAssessmentConfigs = async (
return resp;
};

// Notification related request
export const putNotificationConfigs = async (
tokens: Tokens,
notificationConfigs: NotificationConfiguration[]
) => {
return await request(`notifications/config`, 'PUT', {
return await request(`courses/${courseIdWithoutPrefix()}/admin/notifications/config`, 'PUT', {
...tokens,
body: notificationConfigs,
noHeaderAccept: true
Expand Down Expand Up @@ -1081,11 +1082,15 @@ export const removeTimeOptions = async (
tokens: Tokens,
timeOptionIds: number[]
): Promise<Response | null> => {
const resp = await request(`notifications/options`, 'DELETE', {
...tokens,
body: timeOptionIds,
noHeaderAccept: true
});
const resp = await request(
`courses/${courseIdWithoutPrefix()}/admin/notifications/options`,
'DELETE',
{
...tokens,
body: timeOptionIds,
noHeaderAccept: true
}
);

return resp;
};
Expand All @@ -1094,7 +1099,7 @@ export const putTimeOptions = async (
tokens: Tokens,
timeOptions: TimeOption[]
): Promise<Response | null> => {
const resp = await request(`notifications/options`, 'PUT', {
const resp = await request(`courses/${courseIdWithoutPrefix()}/notifications/options`, 'PUT', {
...tokens,
body: timeOptions,
noHeaderAccept: true
Expand All @@ -1106,9 +1111,13 @@ export const putTimeOptions = async (
export const getNotificationConfigs = async (
tokens: Tokens
): Promise<NotificationConfiguration[] | null> => {
const resp = await request(`notifications/config/${courseIdWithoutPrefix()}`, 'GET', {
...tokens
});
const resp = await request(
`courses/${courseIdWithoutPrefix()}/admin/notifications/config`,
'GET',
{
...tokens
}
);
if (!resp || !resp.ok) {
return null;
}
Expand All @@ -1120,9 +1129,13 @@ export const getConfigurableNotificationConfigs = async (
tokens: Tokens,
courseRegId: number
): Promise<NotificationConfiguration[] | null> => {
const resp = await request(`notifications/config/user/${courseRegId}`, 'GET', {
...tokens
});
const resp = await request(
`courses/${courseIdWithoutPrefix()}/notifications/config/user/${courseRegId}`,
'GET',
{
...tokens
}
);
if (!resp || !resp.ok) {
return null;
}
Expand Down Expand Up @@ -1155,13 +1168,17 @@ export const putNotificationPreferences = async (
notiPrefs: NotificationPreference[],
courseRegId: number
): Promise<Response | null> => {
const resp = await request(`notifications/preferences`, 'PUT', {
...tokens,
body: notiPrefs.map(pref => {
return { ...pref, courseRegId: courseRegId };
}),
noHeaderAccept: true
});
const resp = await request(
`courses/${courseIdWithoutPrefix()}/notifications/preferences`,
'PUT',
{
...tokens,
body: notiPrefs.map(pref => {
return { ...pref, courseRegId: courseRegId };
}),
noHeaderAccept: true
}
);

return resp;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { NotificationConfiguration, TimeOption } from 'src/commons/application/t
import { useTypedSelector } from 'src/commons/utils/Hooks';

import BooleanCell from './assessmentConfigPanel/BooleanCell';
import SelectCell from './notificationConfigPanel/SelectCell';
import TimeOptionCell from './notificationConfigPanel/TimeOptionCell';

const NotificationConfigPanel = () => {
Expand Down Expand Up @@ -94,16 +93,21 @@ const NotificationConfigPanel = () => {
return params.data!.notificationType.forStaff ? 'Staff' : 'Student';
};

const notificationTypeId: ValueFormatterFunc<NotificationConfiguration> = params => {
const id = params.data!.notificationType?.id || 0;
return String(id);
};

const columnDefs: ColDef[] = [
{
headerName: 'Notification Type',
field: 'notificationType.name',
headerName: 'Assessment Type',
field: 'assessmentConfig.type',
valueFormatter: assessmentTypeFormatter,
rowDrag: true
},
{
headerName: 'Assessment Type',
field: 'assessmentConfig.type',
valueFormatter: assessmentTypeFormatter
headerName: 'Notification Type',
field: 'notificationType.name'
},
{
headerName: 'Recipients',
Expand All @@ -119,16 +123,20 @@ const NotificationConfigPanel = () => {
// headerName: 'Past 30 Days',
// field: 'notificationType.id'
// },

{
headerName: 'Reminder Time Options (hours)',
headerName: 'Default Reminder Time(hours)',
field: 'timeOptions',
cellRenderer: TimeOptionCell,
cellRendererParams: {
setStateHandler: setTimeOptions,
setDelete: addTimeOptionsToDelete,
field: 'timeOptions'
field: 'timeOptions',
typeId: notificationTypeId
}
},

/*
{
headerName: 'Default Reminder (hours)',
field: 'timeOptions',
Expand All @@ -138,6 +146,7 @@ const NotificationConfigPanel = () => {
field: 'timeOptions'
}
},
*/
{
headerName: 'Enabled',
field: 'isEnabled',
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type OwnProps = {
field: KeysOfType<NotificationConfiguration, TimeOption[]>;
setStateHandler: (rowIndex: number, value: TimeOption[]) => void;
setDelete: (timeOption: TimeOption) => void;
typeId: string;
};

const TimeOptionCell: React.FC<TimeOptionCellProps> = props => {
Expand Down Expand Up @@ -45,10 +46,11 @@ const TimeOptionCell: React.FC<TimeOptionCellProps> = props => {
const newTimeOption: TimeOption = {
id: -1,
minutes: parseFloat(value as string) * 60,
isDefault: false
isDefault: true
};

setValues([...values, value]);
console.log(props.rowIndex, value, values);
props.setStateHandler(props.rowIndex, [...timeOptions, newTimeOption]);
} else {
// TODO: Toaster if posisble
Expand All @@ -57,5 +59,4 @@ const TimeOptionCell: React.FC<TimeOptionCellProps> = props => {

return <TagInput values={values} onRemove={onRemove} onAdd={onAdd} />;
};

export default TimeOptionCell;
Loading
Loading