Investigating

This commit is contained in:
Terry Sutton committed 2024-05-07 16:03:59 -02:30
1 parent 56a1babebf
commit 27b18190e2
3 files changed
+42 -17

No files matched your search

@@ -36,7 +36,7 @@ const NotificationRow: ItemRenderer<Notification, NotificationRowProps> = ({
const ref = useRef<HTMLDivElement>(null)
const { ref: viewRef, inView } = useInView()
const { status, priority } = notification
console.log('the', { notification })
const data = notification.data as NotificationData
const project = data.project_ref !== undefined ? getProject(data.project_ref) : undefined
const organization =
@@ -133,6 +133,7 @@ const NotificationRow: ItemRenderer<Notification, NotificationRowProps> = ({
{data.actions.map((action, idx) => {
const key = `${notification.id}-action-${idx}`
if (action.url !== undefined) {
console.log({ action }, project)
const url = action.url.includes('[ref]')
? action.url.replace('[ref]', project?.ref ?? '_')
: action.url.includes('[slug]')
@@ -41,6 +41,7 @@ const NotificationsPopoverV2 = () => {
const rowHeights = useRef<{ [key: number]: number }>({})
const { data: projects } = useProjectsQuery()
console.log({ projects })
const { data: organizations } = useOrganizationsQuery()
const {
data,
@@ -70,7 +71,7 @@ const NotificationsPopoverV2 = () => {
useNotificationsArchiveAllMutation({
onSuccess: () => toast.success('Successfully archived all notifications'),
})
console.log({ projects })
const notifications = useMemo(() => data?.pages.flatMap((page) => page) ?? [], [data?.pages])
const hasNewNotifications = summary?.unread_count ?? 0 > 0
const hasWarning = summary?.has_warning
@@ -81,7 +82,7 @@ const NotificationsPopoverV2 = () => {
updateNotifications({ ids: markedRead.current, status: 'seen' })
}
}
console.log({ notifications })
return (
<Popover_Shadcn_
modal={false}
@@ -37,23 +37,46 @@ export type NotificationData = {
export async function getNotifications(options: NotificationVariables, signal?: AbortSignal) {
const { status, filters, page = 0, limit = NOTIFICATIONS_PAGE_LIMIT } = options
const { data, error } = await get('/platform/notifications', {
params: {
// @ts-ignore
query: {
offset: page * limit,
limit,
...(status !== undefined ? { status } : { status: ['new', 'seen'] }),
...(filters.priority.length > 0 ? { priority: filters.priority } : {}),
...(filters.organizations.length > 0 ? { org_slug: filters.organizations } : {}),
...(filters.projects.length > 0 ? { project_ref: filters.projects } : {}),
// const { data, error } = await get('/platform/notifications', {
// params: {
// // @ts-ignore
// query: {
// offset: page * limit,
// limit,
// ...(status !== undefined ? { status } : { status: ['new', 'seen'] }),
// ...(filters.priority.length > 0 ? { priority: filters.priority } : {}),
// ...(filters.organizations.length > 0 ? { org_slug: filters.organizations } : {}),
// ...(filters.projects.length > 0 ? { project_ref: filters.projects } : {}),
// },
// },
// headers: { Version: '2' },
// signal,
// })
// if (error) throw error
const data = [
{
status: 'seen',
priority: 'Warning',
data: {
title: 'Security Recommendation',
actions: [{ url: '/project/[ref]/database/security-advisor', label: 'Security Advisor' }],
message:
'The way you have configured your database is open to the public, please check the notifications in the Security Advisor page.',
project_ref: 'yxrbshyrkjhbbglmsqyj',
},
},
headers: { Version: '2' },
signal,
})
if (error) throw error
// {
// title: 'Security Recommendation',
// actions: [{ url: '/project/[ref]/database/security-advisor', label: 'Security Advisor' }],
// message:
// 'The way you have configured your database is open to the public, please check the notifications in the Security Advisor page.',
// project_ref: 'pnlhfnllpxpapxrdkihw',
// },
// Add more notifications as needed
]
return data
}