Compare commits
10 Commits
a4cdb4b1cc
...
975a528b49
Author | SHA1 | Date | |
---|---|---|---|
![]() |
975a528b49 | ||
![]() |
749fef7e28 | ||
![]() |
cf34833d42 | ||
![]() |
7bb45316af | ||
![]() |
02771185af | ||
![]() |
cf70e2af21 | ||
![]() |
1a77c3a5e8 | ||
![]() |
af446aed59 | ||
![]() |
c7f1f544ec | ||
![]() |
99ee2f9fc3 |
10
.prettierrc
Normal file
10
.prettierrc
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"endOfLine": "lf",
|
||||||
|
"printWidth": 120,
|
||||||
|
"quoteProps": "consistent",
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": true,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"trailingComma": "es5",
|
||||||
|
"plugins": []
|
||||||
|
}
|
@@ -6,6 +6,9 @@ import ListItemIcon from '@mui/material/ListItemIcon';
|
|||||||
import { Box } from '@mui/system';
|
import { Box } from '@mui/system';
|
||||||
import { Trash as TrashIcon } from '@phosphor-icons/react/dist/ssr/Trash';
|
import { Trash as TrashIcon } from '@phosphor-icons/react/dist/ssr/Trash';
|
||||||
|
|
||||||
|
import { logger } from '@/lib/default-logger';
|
||||||
|
import { toast } from '@/components/core/toaster';
|
||||||
|
|
||||||
interface PropsHelloworld {
|
interface PropsHelloworld {
|
||||||
message: string;
|
message: string;
|
||||||
}
|
}
|
||||||
@@ -33,11 +36,21 @@ function InnerComponent(): React.JSX.Element {
|
|||||||
// RULES: sample of main component
|
// RULES: sample of main component
|
||||||
function MainComponent(): React.JSX.Element {
|
function MainComponent(): React.JSX.Element {
|
||||||
const [state, setState] = React.useState<string>('');
|
const [state, setState] = React.useState<string>('');
|
||||||
|
const [loading, setLoading] = React.useState(true);
|
||||||
|
const [showError, setShowError] = React.useState<boolean>(false);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
try {
|
||||||
setState(funcHelloworld('hello'));
|
setState(funcHelloworld('hello'));
|
||||||
|
} catch (error) {
|
||||||
|
setShowError(true);
|
||||||
|
}
|
||||||
|
setLoading(false);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
if (loading) return <>Loading</>;
|
||||||
|
if (showError) return <>Error</>;
|
||||||
|
|
||||||
// you should obey react/jsx-no-useless-fragment
|
// you should obey react/jsx-no-useless-fragment
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
|
@@ -189,7 +189,15 @@ function NotificationsButton(): React.JSX.Element {
|
|||||||
<Tooltip title="Notifications">
|
<Tooltip title="Notifications">
|
||||||
<Badge
|
<Badge
|
||||||
color="error"
|
color="error"
|
||||||
sx={{ '& .MuiBadge-dot': { borderRadius: '50%', height: '10px', right: '6px', top: '6px', width: '10px' } }}
|
sx={{
|
||||||
|
'& .MuiBadge-dot': {
|
||||||
|
borderRadius: '50%',
|
||||||
|
right: '6px',
|
||||||
|
top: '6px',
|
||||||
|
height: '10px',
|
||||||
|
width: '10px',
|
||||||
|
},
|
||||||
|
}}
|
||||||
variant="dot"
|
variant="dot"
|
||||||
>
|
>
|
||||||
<IconButton
|
<IconButton
|
||||||
|
@@ -1,38 +1,42 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import Avatar from '@mui/material/Avatar';
|
import { getNotificationsByUserId } from '@/db/Notifications/GetNotificationByUserId';
|
||||||
|
import type { Notification } from '@/db/Notifications/type';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import IconButton from '@mui/material/IconButton';
|
import IconButton from '@mui/material/IconButton';
|
||||||
import Link from '@mui/material/Link';
|
|
||||||
import List from '@mui/material/List';
|
import List from '@mui/material/List';
|
||||||
import ListItem from '@mui/material/ListItem';
|
|
||||||
import Popover from '@mui/material/Popover';
|
import Popover from '@mui/material/Popover';
|
||||||
import Stack from '@mui/material/Stack';
|
import Stack from '@mui/material/Stack';
|
||||||
import Tooltip from '@mui/material/Tooltip';
|
import Tooltip from '@mui/material/Tooltip';
|
||||||
import Typography from '@mui/material/Typography';
|
import Typography from '@mui/material/Typography';
|
||||||
import { ChatText as ChatTextIcon } from '@phosphor-icons/react/dist/ssr/ChatText';
|
|
||||||
import { EnvelopeSimple as EnvelopeSimpleIcon } from '@phosphor-icons/react/dist/ssr/EnvelopeSimple';
|
import { EnvelopeSimple as EnvelopeSimpleIcon } from '@phosphor-icons/react/dist/ssr/EnvelopeSimple';
|
||||||
import { User as UserIcon } from '@phosphor-icons/react/dist/ssr/User';
|
|
||||||
import { X as XIcon } from '@phosphor-icons/react/dist/ssr/X';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { dayjs } from '@/lib/dayjs';
|
import { User } from '@/types/user';
|
||||||
|
import { useHelloworld } from '@/hooks/use-helloworld';
|
||||||
|
import { useUser } from '@/hooks/use-user';
|
||||||
|
|
||||||
|
import { NotificationItem } from './notification-item';
|
||||||
// import type { Notification } from './type.d.tsx.del';
|
// import type { Notification } from './type.d.tsx.del';
|
||||||
import { SampleNotifications } from './sample-notifications';
|
import { SampleNotifications } from './sample-notifications';
|
||||||
import { useHelloworld } from '@/hooks/use-helloworld';
|
import getImageUrlFromFile from '@/lib/get-image-url-from-file.ts';
|
||||||
import { getAllNotifications } from '@/db/Notifications/GetAll';
|
import { getUnreadNotificationsByUserId } from '@/db/Notifications/GetUnreadNotificationsByUserId';
|
||||||
import { ListResult, RecordModel } from 'pocketbase';
|
import { logger } from '@/lib/default-logger';
|
||||||
import { defaultNotification } from '@/db/Notifications/constants';
|
import { toast } from '@/components/core/toaster';
|
||||||
import { getNotificationsByUserId } from '@/db/Notifications/GetNotificationByUserId';
|
|
||||||
import { Notification } from '@/db/Notifications/type';
|
import { NoteBlank as NoteBlankIcon } from '@phosphor-icons/react/dist/ssr/NoteBlank';
|
||||||
|
import { Sun as SunIcon } from '@phosphor-icons/react/dist/ssr/Sun';
|
||||||
|
import { MarkAllAsReadButton } from './mark-all-as-read-button';
|
||||||
|
import { Button } from '@mui/material';
|
||||||
|
|
||||||
export interface NotificationsPopoverProps {
|
export interface NotificationsPopoverProps {
|
||||||
anchorEl: null | Element;
|
anchorEl: null | Element;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
onMarkAllAsRead?: () => void;
|
onMarkAllAsRead?: () => void;
|
||||||
onRemoveOne?: (id: string) => void;
|
onRemoveOne?: (id: string, reload: () => Promise<void>) => void;
|
||||||
open?: boolean;
|
open?: boolean;
|
||||||
|
setListLength: React.Dispatch<React.SetStateAction<number>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function NotificationsPopover({
|
export function NotificationsPopover({
|
||||||
@@ -41,37 +45,101 @@ export function NotificationsPopover({
|
|||||||
onMarkAllAsRead,
|
onMarkAllAsRead,
|
||||||
onRemoveOne,
|
onRemoveOne,
|
||||||
open = false,
|
open = false,
|
||||||
|
setListLength,
|
||||||
}: NotificationsPopoverProps): React.JSX.Element {
|
}: NotificationsPopoverProps): React.JSX.Element {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [notiList, setNotiList] = React.useState<Notification[]>([]);
|
const [notiList, setNotiList] = React.useState<Notification[]>([]);
|
||||||
|
const { user } = useUser();
|
||||||
|
|
||||||
const [loading, setLoading] = React.useState(false);
|
const [loading, setLoading] = React.useState(true);
|
||||||
const [error, setError] = React.useState<string | null>(null);
|
const [showError, setShowError] = React.useState<boolean>(false);
|
||||||
|
|
||||||
const { data, handleClose, handleOpen, open: testOpen } = useHelloworld<string>();
|
async function loadUnreadNotifications(): Promise<void> {
|
||||||
React.useEffect(() => {
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
async function LoadAllNotifications() {
|
try {
|
||||||
const notiList: Notification[] = await getNotificationsByUserId('1');
|
if (user?.id) {
|
||||||
setNotiList(notiList);
|
const tempNotiList: Notification[] = await getUnreadNotificationsByUserId(user.id);
|
||||||
|
setNotiList(tempNotiList);
|
||||||
|
setListLength(tempNotiList.length);
|
||||||
|
}
|
||||||
|
} catch (loadNotiError) {
|
||||||
|
logger.error(loadNotiError);
|
||||||
|
toast.error('error during loading noti list');
|
||||||
}
|
}
|
||||||
setLoading(false);
|
|
||||||
void LoadAllNotifications();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
if (loading) return <>Loading</>;
|
setLoading(false);
|
||||||
if (error) return <>Error</>;
|
}
|
||||||
if (notiList.length == 0)
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (user?.id) {
|
||||||
|
void loadUnreadNotifications();
|
||||||
|
}
|
||||||
|
}, [user]);
|
||||||
|
|
||||||
|
// if (loading) return <>Loading</>;
|
||||||
|
// if (showError) return <>Error</>;
|
||||||
|
|
||||||
|
if (notiList.length === 0)
|
||||||
return (
|
return (
|
||||||
<Popover
|
<Popover
|
||||||
anchorEl={anchorEl}
|
anchorEl={anchorEl}
|
||||||
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
|
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
open={open}
|
open={open}
|
||||||
slotProps={{ paper: { sx: { width: '380px' } } }}
|
slotProps={{ paper: { sx: { width: 'unset' } } }}
|
||||||
transformOrigin={{ horizontal: 'right', vertical: 'top' }}
|
transformOrigin={{ horizontal: 'right', vertical: 'top' }}
|
||||||
>
|
>
|
||||||
list is empty
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
sx={{ alignItems: 'center', justifyContent: 'space-between', px: 3, py: 2 }}
|
||||||
|
>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
sx={{ alignItems: 'left' }}
|
||||||
|
>
|
||||||
|
<Typography variant="h6">
|
||||||
|
{t('Notifications')} ({notiList.length})
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
{loading ? (
|
||||||
|
<Typography
|
||||||
|
color="gray"
|
||||||
|
variant="subtitle2"
|
||||||
|
>
|
||||||
|
({t('loading')})
|
||||||
|
</Typography>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
{/* MarkAllAsReadButton(onMarkAllAsRead, notiList.length <= 0) */}
|
||||||
|
<MarkAllAsReadButton
|
||||||
|
onMarkAllAsRead={onMarkAllAsRead}
|
||||||
|
disabled={notiList.length <= 0}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Stack
|
||||||
|
direction="column"
|
||||||
|
spacing={2}
|
||||||
|
sx={{ alignItems: 'center', padding: '50px' }}
|
||||||
|
>
|
||||||
|
<SunIcon
|
||||||
|
size={48}
|
||||||
|
color="lightgray"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Typography
|
||||||
|
color="lightgray"
|
||||||
|
variant={'subtitle2'}
|
||||||
|
>
|
||||||
|
{t('list-is-empty')}
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
<Button variant="outlined">{t('refresh')}</Button>
|
||||||
|
</Stack>
|
||||||
</Popover>
|
</Popover>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -80,6 +148,7 @@ export function NotificationsPopover({
|
|||||||
anchorEl={anchorEl}
|
anchorEl={anchorEl}
|
||||||
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
|
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
|
// todo: should not use 'true', fallback to 'open'
|
||||||
open={open}
|
open={open}
|
||||||
slotProps={{ paper: { sx: { width: '380px' } } }}
|
slotProps={{ paper: { sx: { width: '380px' } } }}
|
||||||
transformOrigin={{ horizontal: 'right', vertical: 'top' }}
|
transformOrigin={{ horizontal: 'right', vertical: 'top' }}
|
||||||
@@ -89,16 +158,32 @@ export function NotificationsPopover({
|
|||||||
spacing={2}
|
spacing={2}
|
||||||
sx={{ alignItems: 'center', justifyContent: 'space-between', px: 3, py: 2 }}
|
sx={{ alignItems: 'center', justifyContent: 'space-between', px: 3, py: 2 }}
|
||||||
>
|
>
|
||||||
<Typography variant="h6">{t('Notifications')}</Typography>
|
<Stack
|
||||||
<Tooltip title={t('Mark all as read')}>
|
direction="row"
|
||||||
<IconButton
|
spacing={2}
|
||||||
edge="end"
|
sx={{ alignItems: 'left' }}
|
||||||
onClick={onMarkAllAsRead}
|
|
||||||
>
|
>
|
||||||
<EnvelopeSimpleIcon />
|
<Typography variant="h6">
|
||||||
</IconButton>
|
{t('Notifications')} ({notiList.length})
|
||||||
</Tooltip>
|
</Typography>
|
||||||
|
|
||||||
|
{loading ? (
|
||||||
|
<Typography
|
||||||
|
color="gray"
|
||||||
|
variant="subtitle2"
|
||||||
|
>
|
||||||
|
({t('loading')})
|
||||||
|
</Typography>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
<MarkAllAsReadButton
|
||||||
|
onMarkAllAsRead={onMarkAllAsRead}
|
||||||
|
disabled={notiList.length <= 0}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
{notiList.length === 0 ? (
|
{notiList.length === 0 ? (
|
||||||
<Box sx={{ p: 2 }}>
|
<Box sx={{ p: 2 }}>
|
||||||
<Typography variant="subtitle2">{t('There are no notifications')}</Typography>
|
<Typography variant="subtitle2">{t('There are no notifications')}</Typography>
|
||||||
@@ -108,11 +193,11 @@ export function NotificationsPopover({
|
|||||||
<List disablePadding>
|
<List disablePadding>
|
||||||
{notiList.map((notification, index) => (
|
{notiList.map((notification, index) => (
|
||||||
<NotificationItem
|
<NotificationItem
|
||||||
divider={index < SampleNotifications.length - 1}
|
divider={index < notiList.length - 1}
|
||||||
key={notification.id}
|
key={notification.id}
|
||||||
notification={notification}
|
notification={notification}
|
||||||
onRemove={() => {
|
onRemove={() => {
|
||||||
onRemoveOne?.(notification.id);
|
onRemoveOne?.(notification.id, () => loadUnreadNotifications());
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
@@ -123,135 +208,25 @@ export function NotificationsPopover({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NotificationItemProps {
|
// TODO: remove me
|
||||||
divider?: boolean;
|
// function MarkAllAsReadButton({
|
||||||
notification: Notification;
|
// onMarkAllAsRead,
|
||||||
onRemove?: () => void;
|
// disabled,
|
||||||
}
|
// }: {
|
||||||
|
// onMarkAllAsRead: (() => void) | undefined;
|
||||||
|
// disabled: boolean;
|
||||||
|
// }): React.JSX.Element {
|
||||||
|
// const { t } = useTranslation();
|
||||||
|
|
||||||
function NotificationItem({ divider, notification, onRemove }: NotificationItemProps): React.JSX.Element {
|
// return (
|
||||||
return (
|
// <Tooltip title={t('mark-all-as-read')}>
|
||||||
<ListItem
|
// <IconButton
|
||||||
divider={divider}
|
// edge="end"
|
||||||
sx={{ alignItems: 'flex-start', justifyContent: 'space-between' }}
|
// onClick={onMarkAllAsRead}
|
||||||
>
|
// disabled={disabled}
|
||||||
<NotificationContent notification={notification} />
|
// >
|
||||||
<Tooltip title="Remove">
|
// <EnvelopeSimpleIcon color={disabled ? 'lightgray' : 'black'} />
|
||||||
<IconButton
|
// </IconButton>
|
||||||
edge="end"
|
// </Tooltip>
|
||||||
onClick={onRemove}
|
// );
|
||||||
size="small"
|
// }
|
||||||
>
|
|
||||||
<XIcon />
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
</ListItem>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface NotificationContentProps {
|
|
||||||
notification: Notification;
|
|
||||||
}
|
|
||||||
|
|
||||||
function NotificationContent({ notification }: NotificationContentProps): React.JSX.Element {
|
|
||||||
if (notification.type === 'new_feature') {
|
|
||||||
return (
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
spacing={2}
|
|
||||||
sx={{ alignItems: 'flex-start' }}
|
|
||||||
>
|
|
||||||
<Avatar>
|
|
||||||
<ChatTextIcon fontSize="var(--Icon-fontSize)" />
|
|
||||||
</Avatar>
|
|
||||||
<div>
|
|
||||||
<Typography variant="subtitle2">New feature!</Typography>
|
|
||||||
<Typography variant="body2">{notification.description}</Typography>
|
|
||||||
<Typography
|
|
||||||
color="text.secondary"
|
|
||||||
variant="caption"
|
|
||||||
>
|
|
||||||
{dayjs(notification.createdAt).format('MMM D, hh:mm A')}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notification.type === 'new_company') {
|
|
||||||
return (
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
spacing={2}
|
|
||||||
sx={{ alignItems: 'flex-start' }}
|
|
||||||
>
|
|
||||||
<Avatar src={notification.author.avatar}>
|
|
||||||
<UserIcon />
|
|
||||||
</Avatar>
|
|
||||||
<div>
|
|
||||||
<Typography variant="body2">
|
|
||||||
<Typography
|
|
||||||
component="span"
|
|
||||||
variant="subtitle2"
|
|
||||||
>
|
|
||||||
{notification.author.name}
|
|
||||||
</Typography>{' '}
|
|
||||||
created{' '}
|
|
||||||
<Link
|
|
||||||
underline="always"
|
|
||||||
variant="body2"
|
|
||||||
>
|
|
||||||
{notification.company.name}
|
|
||||||
</Link>{' '}
|
|
||||||
company
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
color="text.secondary"
|
|
||||||
variant="caption"
|
|
||||||
>
|
|
||||||
{dayjs(notification.createdAt).format('MMM D, hh:mm A')}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notification.type === 'new_job') {
|
|
||||||
return (
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
spacing={2}
|
|
||||||
sx={{ alignItems: 'flex-start' }}
|
|
||||||
>
|
|
||||||
<Avatar src={notification.author.avatar}>
|
|
||||||
<UserIcon />
|
|
||||||
</Avatar>
|
|
||||||
<div>
|
|
||||||
<Typography variant="body2">
|
|
||||||
<Typography
|
|
||||||
component="span"
|
|
||||||
variant="subtitle2"
|
|
||||||
>
|
|
||||||
{notification.author.name}
|
|
||||||
</Typography>{' '}
|
|
||||||
added a new job{' '}
|
|
||||||
<Link
|
|
||||||
underline="always"
|
|
||||||
variant="body2"
|
|
||||||
>
|
|
||||||
{notification.job.title}
|
|
||||||
</Link>
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
color="text.secondary"
|
|
||||||
variant="caption"
|
|
||||||
>
|
|
||||||
{dayjs(notification.createdAt).format('MMM D, hh:mm A')}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return <div />;
|
|
||||||
}
|
|
||||||
|
@@ -0,0 +1,29 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
import IconButton from '@mui/material/IconButton';
|
||||||
|
import Tooltip from '@mui/material/Tooltip';
|
||||||
|
import { EnvelopeSimple as EnvelopeSimpleIcon } from '@phosphor-icons/react/dist/ssr/EnvelopeSimple';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
export function MarkAllAsReadButton({
|
||||||
|
onMarkAllAsRead,
|
||||||
|
disabled,
|
||||||
|
}: {
|
||||||
|
onMarkAllAsRead: (() => void) | undefined;
|
||||||
|
disabled: boolean;
|
||||||
|
}): React.JSX.Element {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip title={t('mark-all-as-read')}>
|
||||||
|
<IconButton
|
||||||
|
edge="end"
|
||||||
|
onClick={onMarkAllAsRead}
|
||||||
|
disabled={disabled}
|
||||||
|
>
|
||||||
|
<EnvelopeSimpleIcon color={disabled ? 'lightgray' : 'black'} />
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
}
|
@@ -0,0 +1,139 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
import type { Notification } from '@/db/Notifications/type';
|
||||||
|
import Avatar from '@mui/material/Avatar';
|
||||||
|
import Link from '@mui/material/Link';
|
||||||
|
import Stack from '@mui/material/Stack';
|
||||||
|
import Typography from '@mui/material/Typography';
|
||||||
|
import { ChatText as ChatTextIcon } from '@phosphor-icons/react/dist/ssr/ChatText';
|
||||||
|
import { User as UserIcon } from '@phosphor-icons/react/dist/ssr/User';
|
||||||
|
|
||||||
|
import { dayjs } from '@/lib/dayjs';
|
||||||
|
import getImageUrlFromFile from '@/lib/get-image-url-from-file.ts';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { toast } from '@/components/core/toaster';
|
||||||
|
|
||||||
|
interface NotificationContentProps {
|
||||||
|
notification: Notification;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function NotificationContent({ notification }: NotificationContentProps): React.JSX.Element {
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
if (notification.type === 'new_feature') {
|
||||||
|
return (
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
sx={{ alignItems: 'flex-start' }}
|
||||||
|
>
|
||||||
|
<Avatar>
|
||||||
|
<ChatTextIcon fontSize="var(--Icon-fontSize)" />
|
||||||
|
</Avatar>
|
||||||
|
<div>
|
||||||
|
<Typography variant="subtitle2">New feature!</Typography>
|
||||||
|
<Typography variant="body2">{notification.description}</Typography>
|
||||||
|
<Typography
|
||||||
|
color="text.secondary"
|
||||||
|
variant="caption"
|
||||||
|
>
|
||||||
|
{dayjs(notification.createdAt).format('MMM D, hh:mm A')}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (notification.type === 'new_company') {
|
||||||
|
return (
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
sx={{ alignItems: 'flex-start' }}
|
||||||
|
>
|
||||||
|
<Avatar src={notification?.author?.avatar || ''}>
|
||||||
|
<UserIcon size={24} />
|
||||||
|
</Avatar>
|
||||||
|
<div>
|
||||||
|
<Typography variant="body2">
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
variant="subtitle2"
|
||||||
|
>
|
||||||
|
{notification?.author?.name}
|
||||||
|
</Typography>{' '}
|
||||||
|
created{' '}
|
||||||
|
<Link
|
||||||
|
underline="always"
|
||||||
|
variant="body2"
|
||||||
|
>
|
||||||
|
{notification?.company?.name}
|
||||||
|
</Link>{' '}
|
||||||
|
company
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
color="text.secondary"
|
||||||
|
variant="caption"
|
||||||
|
>
|
||||||
|
{dayjs(notification.created).format('MMM D, hh:mm A')}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (notification.type === 'new_job') {
|
||||||
|
const handleClick = (): void => {
|
||||||
|
try {
|
||||||
|
if (notification.link) {
|
||||||
|
router.push(notification.link);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
toast.error((error as { message: string }).message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
sx={{
|
||||||
|
alignItems: 'flex-start',
|
||||||
|
cursor: notification.link ? 'pointer' : '',
|
||||||
|
}}
|
||||||
|
//
|
||||||
|
onClick={handleClick}
|
||||||
|
>
|
||||||
|
<Avatar src={notification?.author?.avatar}>
|
||||||
|
<UserIcon />
|
||||||
|
</Avatar>
|
||||||
|
<div>
|
||||||
|
<Typography variant="body2">
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
variant="subtitle2"
|
||||||
|
>
|
||||||
|
{notification?.author?.name}
|
||||||
|
</Typography>{' '}
|
||||||
|
added a new job{' '}
|
||||||
|
<Link
|
||||||
|
underline="always"
|
||||||
|
variant="body2"
|
||||||
|
>
|
||||||
|
{notification?.job?.title}
|
||||||
|
</Link>
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
color="text.secondary"
|
||||||
|
variant="caption"
|
||||||
|
>
|
||||||
|
{dayjs(notification.created).format('MMM D, hh:mm A')}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return <div />;
|
||||||
|
}
|
@@ -0,0 +1,36 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
import type { Notification } from '@/db/Notifications/type';
|
||||||
|
import IconButton from '@mui/material/IconButton';
|
||||||
|
import ListItem from '@mui/material/ListItem';
|
||||||
|
import Tooltip from '@mui/material/Tooltip';
|
||||||
|
import { X as XIcon } from '@phosphor-icons/react/dist/ssr/X';
|
||||||
|
|
||||||
|
import { NotificationContent } from './notification-content';
|
||||||
|
|
||||||
|
interface NotificationItemProps {
|
||||||
|
divider?: boolean;
|
||||||
|
notification: Notification;
|
||||||
|
onRemove?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function NotificationItem({ divider, notification, onRemove }: NotificationItemProps): React.JSX.Element {
|
||||||
|
return (
|
||||||
|
<ListItem
|
||||||
|
divider={divider}
|
||||||
|
sx={{ alignItems: 'flex-start', justifyContent: 'space-between' }}
|
||||||
|
>
|
||||||
|
<NotificationContent notification={notification} />
|
||||||
|
<Tooltip title="Remove">
|
||||||
|
<IconButton
|
||||||
|
edge="end"
|
||||||
|
onClick={onRemove}
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<XIcon />
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
</ListItem>
|
||||||
|
);
|
||||||
|
}
|
@@ -1,6 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
import { Notification } from '@/db/Notifications/type';
|
||||||
import { dayjs } from '@/lib/dayjs';
|
import { dayjs } from '@/lib/dayjs';
|
||||||
import type { Notification } from './type.d.tsx.del';
|
// import type { Notification } from './type.d.tsx';
|
||||||
|
|
||||||
export const SampleNotifications = [
|
export const SampleNotifications = [
|
||||||
{
|
{
|
||||||
@@ -8,7 +9,7 @@ export const SampleNotifications = [
|
|||||||
createdAt: dayjs().subtract(7, 'minute').subtract(5, 'hour').subtract(1, 'day').toDate(),
|
createdAt: dayjs().subtract(7, 'minute').subtract(5, 'hour').subtract(1, 'day').toDate(),
|
||||||
read: false,
|
read: false,
|
||||||
type: 'new_job',
|
type: 'new_job',
|
||||||
author: { name: 'Jie Yan', avatar: '/assets/avatar-8.png' },
|
author: { id: '0001', collectionId: '0001', name: 'Jie Yan', avatar: '/assets/avatar-8.png' },
|
||||||
job: { title: 'Remote React / React Native Developer' },
|
job: { title: 'Remote React / React Native Developer' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -16,7 +17,7 @@ export const SampleNotifications = [
|
|||||||
createdAt: dayjs().subtract(18, 'minute').subtract(3, 'hour').subtract(5, 'day').toDate(),
|
createdAt: dayjs().subtract(18, 'minute').subtract(3, 'hour').subtract(5, 'day').toDate(),
|
||||||
read: true,
|
read: true,
|
||||||
type: 'new_job',
|
type: 'new_job',
|
||||||
author: { name: 'Fran Perez', avatar: '/assets/avatar-5.png' },
|
author: { id: '0001', collectionId: '0001', name: 'Fran Perez', avatar: '/assets/avatar-5.png' },
|
||||||
job: { title: 'Senior Golang Backend Engineer' },
|
job: { title: 'Senior Golang Backend Engineer' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -24,6 +25,7 @@ export const SampleNotifications = [
|
|||||||
createdAt: dayjs().subtract(4, 'minute').subtract(5, 'hour').subtract(7, 'day').toDate(),
|
createdAt: dayjs().subtract(4, 'minute').subtract(5, 'hour').subtract(7, 'day').toDate(),
|
||||||
read: true,
|
read: true,
|
||||||
type: 'new_feature',
|
type: 'new_feature',
|
||||||
|
author: { id: '0001', collectionId: '0001', name: 'Fran Perez', avatar: '/assets/avatar-5.png' },
|
||||||
description: 'Logistics management is now available',
|
description: 'Logistics management is now available',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -31,7 +33,7 @@ export const SampleNotifications = [
|
|||||||
createdAt: dayjs().subtract(7, 'minute').subtract(8, 'hour').subtract(7, 'day').toDate(),
|
createdAt: dayjs().subtract(7, 'minute').subtract(8, 'hour').subtract(7, 'day').toDate(),
|
||||||
read: true,
|
read: true,
|
||||||
type: 'new_company',
|
type: 'new_company',
|
||||||
author: { name: 'Jie Yan', avatar: '/assets/avatar-8.png' },
|
author: { id: '0001', collectionId: '002', name: 'Jie Yan', avatar: '/assets/avatar-8.png' },
|
||||||
company: { name: 'Stripe' },
|
company: { name: 'Stripe' },
|
||||||
},
|
},
|
||||||
] satisfies Notification[];
|
] satisfies Notification[];
|
||||||
|
@@ -9,18 +9,60 @@ import { Bell as BellIcon } from '@phosphor-icons/react/dist/ssr/Bell';
|
|||||||
import { usePopover } from '@/hooks/use-popover';
|
import { usePopover } from '@/hooks/use-popover';
|
||||||
|
|
||||||
import { NotificationsPopover } from '../../notifications-popover';
|
import { NotificationsPopover } from '../../notifications-popover';
|
||||||
|
import { logger } from '@/lib/default-logger';
|
||||||
// import { NotificationsButton } from './notifications-button';
|
// import { NotificationsButton } from './notifications-button';
|
||||||
|
import { toast } from '@/components/core/toaster';
|
||||||
|
import { MarkOneAsRead } from '@/db/Notifications/mark-one-as-read';
|
||||||
|
import { getUnreadNotificationsByUserId } from '@/db/Notifications/GetUnreadNotificationsByUserId';
|
||||||
|
import { Notification } from '@/db/Notifications/type';
|
||||||
|
import { useUser } from '@/hooks/use-user';
|
||||||
|
|
||||||
export function NotificationsButton(): React.JSX.Element {
|
export function NotificationsButton(): React.JSX.Element {
|
||||||
const popover = usePopover<HTMLButtonElement>();
|
const popover = usePopover<HTMLButtonElement>();
|
||||||
|
const { user } = useUser();
|
||||||
|
|
||||||
|
const [loading, setLoading] = React.useState(true);
|
||||||
|
const [showError, setShowError] = React.useState<boolean>(false);
|
||||||
|
const [listLength, setListLength] = React.useState<number>(0);
|
||||||
|
|
||||||
|
const [notiList, setNotiList] = React.useState<Notification[]>([]);
|
||||||
|
|
||||||
|
function handleMarkAllAsRead(): void {
|
||||||
|
// try {
|
||||||
|
// await MarkOneAsRead(id);
|
||||||
|
// toast.success('Notification marked as read');
|
||||||
|
// } catch (error) {
|
||||||
|
// logger.debug(error);
|
||||||
|
// toast.error('Something went wrong');
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleRemoveOne(id: string, cb: () => void): void {
|
||||||
|
MarkOneAsRead(id)
|
||||||
|
.then(() => {
|
||||||
|
toast.success('Notification marked as read');
|
||||||
|
cb();
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
logger.debug(error);
|
||||||
|
toast.error('Something went wrong');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Tooltip title="Notifications">
|
<Tooltip title="Notifications">
|
||||||
<Badge
|
<Badge
|
||||||
color="error"
|
color="error"
|
||||||
sx={{ '& .MuiBadge-dot': { borderRadius: '50%', height: '10px', right: '6px', top: '6px', width: '10px' } }}
|
sx={{
|
||||||
variant="dot"
|
'& .MuiBadge-badge': {
|
||||||
|
height: '20px',
|
||||||
|
width: '20px',
|
||||||
|
right: '6px',
|
||||||
|
top: '6px',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
badgeContent={listLength}
|
||||||
>
|
>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={popover.handleOpen}
|
onClick={popover.handleOpen}
|
||||||
@@ -30,10 +72,14 @@ export function NotificationsButton(): React.JSX.Element {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
</Badge>
|
</Badge>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
{/* */}
|
||||||
<NotificationsPopover
|
<NotificationsPopover
|
||||||
anchorEl={popover.anchorRef.current}
|
anchorEl={popover.anchorRef.current}
|
||||||
onClose={popover.handleClose}
|
onClose={popover.handleClose}
|
||||||
open={popover.open}
|
open={popover.open}
|
||||||
|
onMarkAllAsRead={handleMarkAllAsRead}
|
||||||
|
onRemoveOne={handleRemoveOne}
|
||||||
|
setListLength={setListLength}
|
||||||
/>
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
|
@@ -1,14 +1,18 @@
|
|||||||
//
|
//
|
||||||
// RULES:
|
// RULES:
|
||||||
// api method for get notifications by user id
|
// api method for get notifications by user id
|
||||||
import { pb } from '@/lib/pb';
|
|
||||||
import { COL_NOTIFICATIONS } from '@/constants';
|
import { COL_NOTIFICATIONS } from '@/constants';
|
||||||
|
|
||||||
|
import { pb } from '@/lib/pb';
|
||||||
|
|
||||||
import type { Notification } from './type.d';
|
import type { Notification } from './type.d';
|
||||||
|
|
||||||
export async function getNotificationsByUserId(userId: string): Promise<Notification[]> {
|
export async function getNotificationsByUserId(userId: string): Promise<Notification[]> {
|
||||||
const records = await pb.collection(COL_NOTIFICATIONS).getFullList({
|
const records = await pb.collection(COL_NOTIFICATIONS).getFullList({
|
||||||
filter: `author.id = "000000000000001"`,
|
expand: 'author, to_user_id',
|
||||||
|
filter: `to_user_id.id = "${userId}"`,
|
||||||
sort: '-created',
|
sort: '-created',
|
||||||
});
|
});
|
||||||
|
|
||||||
return records as unknown as Notification[];
|
return records as unknown as Notification[];
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// RULES:
|
||||||
|
// api method for get notifications by user id
|
||||||
|
import { COL_NOTIFICATIONS } from '@/constants';
|
||||||
|
|
||||||
|
import { pb } from '@/lib/pb';
|
||||||
|
|
||||||
|
import type { Notification } from './type.d';
|
||||||
|
|
||||||
|
export async function getUnreadNotificationsByUserId(userId: string): Promise<Notification[]> {
|
||||||
|
const records = await pb.collection(COL_NOTIFICATIONS).getFullList({
|
||||||
|
expand: 'author, to_user_id',
|
||||||
|
filter: `to_user_id.id = "${userId}" && read = false`,
|
||||||
|
sort: '-created',
|
||||||
|
cache: 'no-cache',
|
||||||
|
requestKey: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
return records as unknown as Notification[];
|
||||||
|
}
|
11
002_source/cms/src/db/Notifications/mark-one-as-read.tsx
Normal file
11
002_source/cms/src/db/Notifications/mark-one-as-read.tsx
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
// api method for update notification record
|
||||||
|
// RULES:
|
||||||
|
// TBA
|
||||||
|
import { pb } from '@/lib/pb';
|
||||||
|
import { COL_NOTIFICATIONS } from '@/constants';
|
||||||
|
import type { RecordModel } from 'pocketbase';
|
||||||
|
import type { NotificationFormProps } from '@/components/dashboard/notification/type.d';
|
||||||
|
|
||||||
|
export async function MarkOneAsRead(id: string): Promise<RecordModel> {
|
||||||
|
return pb.collection(COL_NOTIFICATIONS).update(id, { read: true });
|
||||||
|
}
|
16
002_source/cms/src/db/Notifications/type.d.ts
vendored
16
002_source/cms/src/db/Notifications/type.d.ts
vendored
@@ -1,17 +1,21 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import type { User } from '@/types/user';
|
||||||
|
|
||||||
export type SortDir = 'asc' | 'desc';
|
export type SortDir = 'asc' | 'desc';
|
||||||
|
|
||||||
export interface Notification {
|
export interface Notification {
|
||||||
id: string;
|
id: string;
|
||||||
|
created: string;
|
||||||
|
createdAt: Date;
|
||||||
read: boolean;
|
read: boolean;
|
||||||
type: string;
|
type: string;
|
||||||
author: Record<string, unknown>;
|
author?: User;
|
||||||
job: Record<string, unknown>;
|
job?: { title: string };
|
||||||
description: string;
|
description?: string;
|
||||||
NOTI_ID: string;
|
company?: { name: string };
|
||||||
created: string;
|
to_user_id?: User;
|
||||||
updated: string;
|
link: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateFormProps {
|
export interface CreateFormProps {
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
{
|
{
|
||||||
"printWidth": 120,
|
"endOfLine": "lf",
|
||||||
"quoteProps": "consistent",
|
|
||||||
"semi": true,
|
"semi": true,
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"trailingComma": "all",
|
"trailingComma": "es5",
|
||||||
"plugins": ["prettier-plugin-organize-imports", "prettier-plugin-unused-imports-configurable"]
|
"printWidth": 120,
|
||||||
|
"quoteProps": "consistent",
|
||||||
|
"plugins": []
|
||||||
}
|
}
|
||||||
|
17
002_source/ionic_mobile/default.code-workspace
Normal file
17
002_source/ionic_mobile/default.code-workspace
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": ".",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./../../001_documentation",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "../../000_AI_WORKSPACE",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"git.ignoreLimitWarning": true,
|
||||||
|
"remote.autoForwardPortsFallback": 0,
|
||||||
|
},
|
||||||
|
}
|
62
002_source/ionic_mobile/package-lock.json
generated
62
002_source/ionic_mobile/package-lock.json
generated
@@ -21,11 +21,14 @@
|
|||||||
"@ionic/react-router": "^8.0.0",
|
"@ionic/react-router": "^8.0.0",
|
||||||
"@ionic/storage": "^4.0.0",
|
"@ionic/storage": "^4.0.0",
|
||||||
"@lifeomic/attempt": "^3.1.0",
|
"@lifeomic/attempt": "^3.1.0",
|
||||||
|
"@tanstack/react-query": "^5.74.4",
|
||||||
|
"@tanstack/react-query-devtools": "^5.74.6",
|
||||||
"@types/react-router": "^5.1.20",
|
"@types/react-router": "^5.1.20",
|
||||||
"@types/react-router-dom": "^5.3.3",
|
"@types/react-router-dom": "^5.3.3",
|
||||||
"axios": "^1.8.1",
|
"axios": "^1.8.1",
|
||||||
"i18next": "^24.2.2",
|
"i18next": "^24.2.2",
|
||||||
"ionicons": "^7.0.0",
|
"ionicons": "^7.0.0",
|
||||||
|
"pocketbase": "^0.26.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-i18next": "^15.4.1",
|
"react-i18next": "^15.4.1",
|
||||||
@@ -2836,6 +2839,59 @@
|
|||||||
"npm": ">=7.10.0"
|
"npm": ">=7.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@tanstack/query-core": {
|
||||||
|
"version": "5.74.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.74.7.tgz",
|
||||||
|
"integrity": "sha512-X3StkN/Y6KGHndTjJf8H8th7AX4bKfbRpiVhVqevf0QWlxl6DhyJ0TYG3R0LARa/+xqDwzU9mA4pbJxzPCI29A==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/tannerlinsley"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@tanstack/query-devtools": {
|
||||||
|
"version": "5.74.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@tanstack/query-devtools/-/query-devtools-5.74.7.tgz",
|
||||||
|
"integrity": "sha512-nSNlfuGdnHf4yB0S+BoNYOE1o3oAH093weAYZolIHfS2stulyA/gWfSk/9H4ZFk5mAAHb5vNqAeJOmbdcGPEQw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/tannerlinsley"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@tanstack/react-query": {
|
||||||
|
"version": "5.74.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.74.7.tgz",
|
||||||
|
"integrity": "sha512-u4o/RIWnnrq26orGZu2NDPwmVof1vtAiiV6KYUXd49GuK+8HX+gyxoAYqIaZogvCE1cqOuZAhQKcrKGYGkrLxg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@tanstack/query-core": "5.74.7"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/tannerlinsley"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^18 || ^19"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@tanstack/react-query-devtools": {
|
||||||
|
"version": "5.74.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@tanstack/react-query-devtools/-/react-query-devtools-5.74.7.tgz",
|
||||||
|
"integrity": "sha512-j60esTQF+ES0x52kQUYOX0Z8AJUcqCGANj6GaOf8J3YQz2bZPB1imLSw4SFeM3Ozv8uO/X/Dmh3IT1z+y57ZLQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@tanstack/query-devtools": "5.74.7"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/tannerlinsley"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@tanstack/react-query": "^5.74.7",
|
||||||
|
"react": "^18 || ^19"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@testing-library/dom": {
|
"node_modules/@testing-library/dom": {
|
||||||
"version": "10.4.0",
|
"version": "10.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.0.tgz",
|
||||||
@@ -12281,6 +12337,12 @@
|
|||||||
"node": ">=10.4.0"
|
"node": ">=10.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/pocketbase": {
|
||||||
|
"version": "0.26.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/pocketbase/-/pocketbase-0.26.0.tgz",
|
||||||
|
"integrity": "sha512-WBBeOgz4Jnrd7a1KEzSBUJqpTortKKCcp16j5KoF+4tNIyQHsmynj+qRSvS56/RVacVMbAqO8Qkfj3N84fpzEw==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/possible-typed-array-names": {
|
"node_modules/possible-typed-array-names": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz",
|
||||||
|
@@ -49,7 +49,10 @@
|
|||||||
"react-router-dom": "^5.3.4",
|
"react-router-dom": "^5.3.4",
|
||||||
"react-use": "^17.6.0",
|
"react-use": "^17.6.0",
|
||||||
"react-use-audio-player": "^2.3.0-alpha.1",
|
"react-use-audio-player": "^2.3.0-alpha.1",
|
||||||
"remark-gfm": "^4.0.0"
|
"remark-gfm": "^4.0.0",
|
||||||
|
"@tanstack/react-query": "^5.74.4",
|
||||||
|
"@tanstack/react-query-devtools": "^5.74.6",
|
||||||
|
"pocketbase": "^0.26.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@capacitor/assets": "^3.0.5",
|
"@capacitor/assets": "^3.0.5",
|
||||||
|
1
002_source/pocketbase/pb_hooks/seed/.gitignore
vendored
Normal file
1
002_source/pocketbase/pb_hooks/seed/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
_archive
|
@@ -2,9 +2,9 @@ const config = require("/pb_hooks/seed/config.js");
|
|||||||
const utils = require("/pb_hooks/seed/utils.js");
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
const { CR_cat_id_news, CR_cat_id_technology, user_id_admin } = config;
|
||||||
const { getId, getAsset } = utils;
|
const { getId, getAsset } = utils;
|
||||||
const ADMIN_USER_ID = getId("999");
|
const ADMIN_USER_ID = user_id_admin;
|
||||||
|
|
||||||
let row_array = [[ADMIN_USER_ID, "admin@123.com", "admin@123.com", "admin@123.com", true, true, "test_admin_1"]];
|
let row_array = [[ADMIN_USER_ID, "admin@123.com", "admin@123.com", "admin@123.com", true, true, "test_admin_1"]];
|
||||||
|
|
||||||
|
@@ -5,7 +5,7 @@ const config = require("/pb_hooks/seed/config.js");
|
|||||||
const utils = require("/pb_hooks/seed/utils.js");
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
//
|
//
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
const { CR_cat_id_news, CR_cat_id_technology, user_id_admin, user_id_test_teacher_1 } = config;
|
||||||
const { getId, getAsset, dirtyTruncateTable } = utils;
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
|
|
||||||
// const ASSETS_DIR = "/pb_hooks/assets";
|
// const ASSETS_DIR = "/pb_hooks/assets";
|
||||||
@@ -15,29 +15,34 @@ module.exports = ($app) => {
|
|||||||
// const getId = (id) => id.padStart(15, 0);
|
// const getId = (id) => id.padStart(15, 0);
|
||||||
|
|
||||||
// generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs`
|
// generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs`
|
||||||
const SAMPLE_CUSTOMER_ARRAY = [
|
const SAMPLE_NOTI_ARRAY = [
|
||||||
[getId("1"), "EV-004", false, "new_job", { id: getId("1"), name: "Jie Yan", avatar: "/assets/avatar-8.png" }, { title: "Remote React / React Native Developer" }, ""],
|
[getId("1"), "EV-004", "2025-05-01", false, "new_job", user_id_admin, { title: "Remote React / React Native Developer" }, "", {}, user_id_admin, "https://www.google.com"],
|
||||||
[getId("2"), "EV-003", true, "new_job", { id: getId("2"), name: "Fran Perez", avatar: "/assets/avatar-5.png" }, { title: "Senior Golang Backend Engineer" }, ""],
|
[getId("2"), "EV-003", "2025-05-01", false, "new_job", user_id_admin, { title: "Senior Golang Backend Engineer" }, "", {}, user_id_admin, "https://www.google.com"],
|
||||||
[getId("3"), "EV-002", true, "new_feature", "", "", "Logistics management is now available"],
|
[getId("3"), "EV-002", "2025-05-01", false, "new_feature", user_id_admin, {}, "Logistics management is now available", {}, user_id_admin, "https://www.google.com"],
|
||||||
[getId("4"), "EV-001", true, "new_company", { id: getId("3"), name: "Jie Yan", avatar: "/assets/avatar-8.png" }, { name: "Stripe" }, ""],
|
[getId("4"), "EV-001", "2025-05-01", false, "new_company", user_id_admin, {}, "", { name: "Stripe" }, user_id_admin, "https://www.google.com"],
|
||||||
|
[getId("5"), "EV-005", "2025-05-01", false, "new_company", user_id_admin, {}, "", { name: "Stripe (without link test)" }, user_id_admin, null],
|
||||||
];
|
];
|
||||||
|
|
||||||
let row_array = SAMPLE_CUSTOMER_ARRAY;
|
let row_array = SAMPLE_NOTI_ARRAY;
|
||||||
dirtyTruncateTable("Notifications");
|
dirtyTruncateTable("Notifications");
|
||||||
|
|
||||||
let lt_collection = $app.findCollectionByNameOrId("Notifications");
|
let lt_collection = $app.findCollectionByNameOrId("Notifications");
|
||||||
|
|
||||||
for (let i = 0; i < row_array.length; i++) {
|
for (let i = 0; i < row_array.length; i++) {
|
||||||
let customer = row_array[i];
|
let noti = row_array[i];
|
||||||
|
|
||||||
let record = new Record(lt_collection);
|
let record = new Record(lt_collection);
|
||||||
record.set("id", customer[0]);
|
record.set("id", noti[0]);
|
||||||
record.set("NOTI_ID", customer[1]);
|
record.set("NOTI_ID", noti[1]);
|
||||||
record.set("read", customer[2]);
|
record.set("created_at", noti[2]);
|
||||||
record.set("type", customer[3]);
|
record.set("read", noti[3]);
|
||||||
record.set("author", customer[4]);
|
record.set("type", noti[4]);
|
||||||
record.set("job", customer[5]);
|
record.set("author", noti[5]);
|
||||||
record.set("description", customer[6]);
|
record.set("job", noti[6]);
|
||||||
|
record.set("description", noti[7]);
|
||||||
|
record.set("company", noti[8]);
|
||||||
|
record.set("to_user_id", noti[9]);
|
||||||
|
record.set("link", noti[10]);
|
||||||
|
|
||||||
$app.save(record);
|
$app.save(record);
|
||||||
}
|
}
|
||||||
|
@@ -24,4 +24,7 @@ module.exports = {
|
|||||||
CR_cat_id_news: "1".padStart(15, 0),
|
CR_cat_id_news: "1".padStart(15, 0),
|
||||||
CR_cat_id_sports: "2".padStart(15, 0),
|
CR_cat_id_sports: "2".padStart(15, 0),
|
||||||
CR_cat_id_technology: "3".padStart(15, 0),
|
CR_cat_id_technology: "3".padStart(15, 0),
|
||||||
|
//
|
||||||
|
user_id_admin: "999".padStart(15, 0),
|
||||||
|
user_id_test_teacher_1: "11".padStart(15, 0),
|
||||||
};
|
};
|
||||||
|
@@ -1057,16 +1057,6 @@
|
|||||||
"system": false,
|
"system": false,
|
||||||
"type": "text"
|
"type": "text"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"hidden": false,
|
|
||||||
"id": "json3182418120",
|
|
||||||
"maxSize": 0,
|
|
||||||
"name": "author",
|
|
||||||
"presentable": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"type": "json"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
"id": "json4225294584",
|
"id": "json4225294584",
|
||||||
@@ -1124,6 +1114,66 @@
|
|||||||
"presentable": false,
|
"presentable": false,
|
||||||
"system": false,
|
"system": false,
|
||||||
"type": "autodate"
|
"type": "autodate"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cascadeDelete": false,
|
||||||
|
"collectionId": "pbc_1305841361",
|
||||||
|
"hidden": false,
|
||||||
|
"id": "relation704048736",
|
||||||
|
"maxSelect": 1,
|
||||||
|
"minSelect": 0,
|
||||||
|
"name": "to_user_id",
|
||||||
|
"presentable": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "relation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cascadeDelete": false,
|
||||||
|
"collectionId": "pbc_1305841361",
|
||||||
|
"hidden": false,
|
||||||
|
"id": "relation556806202",
|
||||||
|
"maxSelect": 1,
|
||||||
|
"minSelect": 0,
|
||||||
|
"name": "from_user_id",
|
||||||
|
"presentable": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "relation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cascadeDelete": false,
|
||||||
|
"collectionId": "pbc_1305841361",
|
||||||
|
"hidden": false,
|
||||||
|
"id": "relation3182418120",
|
||||||
|
"maxSelect": 1,
|
||||||
|
"minSelect": 0,
|
||||||
|
"name": "author",
|
||||||
|
"presentable": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "relation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"convertURLs": false,
|
||||||
|
"hidden": false,
|
||||||
|
"id": "editor4274335913",
|
||||||
|
"maxSize": 0,
|
||||||
|
"name": "content",
|
||||||
|
"presentable": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "editor"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hidden": false,
|
||||||
|
"id": "json1337919823",
|
||||||
|
"maxSize": 0,
|
||||||
|
"name": "company",
|
||||||
|
"presentable": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "json"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"indexes": [],
|
"indexes": [],
|
||||||
|
Reference in New Issue
Block a user