mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
✨ feat: notification time ago
:%s
This commit is contained in:
3
next-env.d.ts
vendored
3
next-env.d.ts
vendored
@@ -1,3 +1,6 @@
|
|||||||
/// <reference types="next" />
|
/// <reference types="next" />
|
||||||
/// <reference types="next/types/global" />
|
/// <reference types="next/types/global" />
|
||||||
/// <reference types="next/image-types/global" />
|
/// <reference types="next/image-types/global" />
|
||||||
|
|
||||||
|
// NOTE: This file should not be edited
|
||||||
|
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||||
|
@@ -37,6 +37,7 @@
|
|||||||
"lodash.debounce": "^4.0.8",
|
"lodash.debounce": "^4.0.8",
|
||||||
"lodash.random": "^3.2.0",
|
"lodash.random": "^3.2.0",
|
||||||
"lodash.throttle": "^4.1.1",
|
"lodash.throttle": "^4.1.1",
|
||||||
|
"moment": "^2.29.1",
|
||||||
"net": "^1.0.2",
|
"net": "^1.0.2",
|
||||||
"next": "^11.0.0",
|
"next": "^11.0.0",
|
||||||
"next-seo": "^4.26.0",
|
"next-seo": "^4.26.0",
|
||||||
|
@@ -5,7 +5,6 @@ import useSWR from 'swr'
|
|||||||
|
|
||||||
const useNotifications = (options?: QueryNotificationsArgs) => {
|
const useNotifications = (options?: QueryNotificationsArgs) => {
|
||||||
const { data, isValidating, ...rest } = useSWR<NotificationsQuery>([notificationsQuery, options], gglFetcher)
|
const { data, isValidating, ...rest } = useSWR<NotificationsQuery>([notificationsQuery, options], gglFetcher)
|
||||||
console.log("data: ", data)
|
|
||||||
return { notifications: data?.notifications?.items, total: data?.notifications?.totalItems, loading: isValidating, ...rest }
|
return { notifications: data?.notifications?.items, total: data?.notifications?.totalItems, loading: isValidating, ...rest }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@ import Link from 'next/link'
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { IconBill } from 'src/components/icons'
|
import { IconBill } from 'src/components/icons'
|
||||||
import { ACCOUNT_TAB, QUERY_KEY, ROUTE } from 'src/utils/constanst.utils'
|
import { ACCOUNT_TAB, QUERY_KEY, ROUTE } from 'src/utils/constanst.utils'
|
||||||
|
import { formatTimeAgo } from 'src/utils/funtion.utils'
|
||||||
import s from '../NotificationItem/NotificationItem.module.scss'
|
import s from '../NotificationItem/NotificationItem.module.scss'
|
||||||
|
|
||||||
export interface NotificationItemProps extends Omit<Notification, "type" | "data"> {
|
export interface NotificationItemProps extends Omit<Notification, "type" | "data"> {
|
||||||
@@ -30,7 +31,7 @@ const NotificationItem = ({ description, createdAt, order, isNew }: Notification
|
|||||||
{description}
|
{description}
|
||||||
</div>
|
</div>
|
||||||
<div className={s.date}>
|
<div className={s.date}>
|
||||||
{createdAt}
|
{formatTimeAgo(createdAt)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
@@ -1,14 +1,19 @@
|
|||||||
import { Collection } from '@commerce/types/collection';
|
import { Collection } from '@commerce/types/collection';
|
||||||
import { Facet } from "@commerce/types/facet";
|
import { Facet } from "@commerce/types/facet";
|
||||||
import { Product, ProductCard, ProductOptionValues } from "@commerce/types/product";
|
import { Product, ProductCard, ProductOptionValues } from "@commerce/types/product";
|
||||||
import { FacetValue, SearchResultSortParameter } from './../../framework/vendure/schema.d';
|
import { BlogList, FacetValue, SearchResultSortParameter } from './../../framework/vendure/schema.d';
|
||||||
import { CODE_FACET_DISCOUNT, CODE_FACET_FEATURED, CODE_FACET_FEATURED_VARIANT, FACET, PRODUCT_SORT_OPTION_VALUE } from "./constanst.utils";
|
import { CODE_FACET_DISCOUNT, CODE_FACET_FEATURED, CODE_FACET_FEATURED_VARIANT, FACET, PRODUCT_SORT_OPTION_VALUE } from "./constanst.utils";
|
||||||
import { PromiseWithKey, SelectedOptions, SortOrder } from "./types.utils";
|
import { PromiseWithKey, SelectedOptions, SortOrder } from "./types.utils";
|
||||||
|
import moment from 'moment'
|
||||||
|
|
||||||
export function isMobile() {
|
export function isMobile() {
|
||||||
return window.innerWidth < 768
|
return window.innerWidth < 768
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function formatTimeAgo (time: string) {
|
||||||
|
return moment(time).fromNow()
|
||||||
|
}
|
||||||
|
|
||||||
export function getPageFromQuery(pageQuery: string) {
|
export function getPageFromQuery(pageQuery: string) {
|
||||||
let page = 0
|
let page = 0
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user