@@ -16,14 +16,14 @@ import { Link } from "react-router";
|
||||
import Fuse from "fuse.js";
|
||||
import type { VendorListPageQuery as VendorListPageQueryType } from "./__generated__/VendorListPageQuery.graphql";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
const ITEMS_PER_PAGE = 2;
|
||||
const ITEMS_PER_PAGE = 4;
|
||||
|
||||
const vendorListPageQuery = graphql`
|
||||
query VendorListPageQuery($count: Int!, $after: CursorKey, $before: CursorKey) {
|
||||
query VendorListPageQuery($first: Int, $after: CursorKey, $last: Int, $before: CursorKey) {
|
||||
node(id: "AZSfP_xAcAC5IAAAAAAltA") {
|
||||
id
|
||||
... on Organization {
|
||||
vendors(first: $count, after: $after, before: $before) {
|
||||
vendors(first: $first, after: $after, last: $last, before: $before) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
@@ -70,7 +70,7 @@ function VendorListContent({
|
||||
onPageChange,
|
||||
}: {
|
||||
queryRef: PreloadedQuery<VendorListPageQueryType>;
|
||||
onPageChange: (params: { before?: string; after?: string }) => void;
|
||||
onPageChange: (params: { first?: number; after?: string; last?: number; before?: string }) => void;
|
||||
}) {
|
||||
const data = usePreloadedQuery(vendorListPageQuery, queryRef);
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
@@ -95,8 +95,8 @@ function VendorListContent({
|
||||
|
||||
startTransition(() => {
|
||||
const params = direction === 'next'
|
||||
? { after: pageInfo.endCursor }
|
||||
: { before: pageInfo.startCursor };
|
||||
? { first: ITEMS_PER_PAGE, after: pageInfo.endCursor }
|
||||
: { last: ITEMS_PER_PAGE, before: pageInfo.startCursor };
|
||||
|
||||
setSearchParams(prev => {
|
||||
if (direction === 'next') {
|
||||
@@ -268,18 +268,20 @@ export default function VendorListPage() {
|
||||
const before = searchParams.get('before');
|
||||
|
||||
loadQuery({
|
||||
count: ITEMS_PER_PAGE,
|
||||
first: before ? undefined : ITEMS_PER_PAGE,
|
||||
after: after || undefined,
|
||||
last: before ? ITEMS_PER_PAGE : undefined,
|
||||
before: before || undefined,
|
||||
});
|
||||
}, [loadQuery, searchParams]);
|
||||
|
||||
const handlePageChange = ({ before, after }: { before?: string; after?: string }) => {
|
||||
const handlePageChange = ({ first, after, last, before }: { first?: number; after?: string; last?: number; before?: string }) => {
|
||||
loadQuery(
|
||||
{
|
||||
count: ITEMS_PER_PAGE,
|
||||
before: before || undefined,
|
||||
after: after || undefined,
|
||||
first,
|
||||
after,
|
||||
last,
|
||||
before,
|
||||
},
|
||||
{ fetchPolicy: 'network-only' }
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<bfb82e1523f2352b45b1cf3135a05b19>>
|
||||
* @generated SignedSource<<3b4f62f431760660274bbff4ae888d0a>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -12,7 +12,8 @@ import { ConcreteRequest } from 'relay-runtime';
|
||||
export type VendorListPageQuery$variables = {
|
||||
after?: any | null | undefined;
|
||||
before?: any | null | undefined;
|
||||
count: number;
|
||||
first?: number | null | undefined;
|
||||
last?: number | null | undefined;
|
||||
};
|
||||
export type VendorListPageQuery$data = {
|
||||
readonly node: {
|
||||
@@ -55,23 +56,28 @@ v1 = {
|
||||
v2 = {
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "count"
|
||||
"name": "first"
|
||||
},
|
||||
v3 = [
|
||||
v3 = {
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "last"
|
||||
},
|
||||
v4 = [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "id",
|
||||
"value": "AZSfP_xAcAC5IAAAAAAltA"
|
||||
}
|
||||
],
|
||||
v4 = {
|
||||
v5 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
v5 = {
|
||||
v6 = {
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
{
|
||||
@@ -90,7 +96,12 @@ v5 = {
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "first",
|
||||
"variableName": "count"
|
||||
"variableName": "first"
|
||||
},
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "last",
|
||||
"variableName": "last"
|
||||
}
|
||||
],
|
||||
"concreteType": "VendorConnection",
|
||||
@@ -114,7 +125,7 @@ v5 = {
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -200,7 +211,8 @@ return {
|
||||
"argumentDefinitions": [
|
||||
(v0/*: any*/),
|
||||
(v1/*: any*/),
|
||||
(v2/*: any*/)
|
||||
(v2/*: any*/),
|
||||
(v3/*: any*/)
|
||||
],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
@@ -208,14 +220,14 @@ return {
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v3/*: any*/),
|
||||
"args": (v4/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/)
|
||||
(v5/*: any*/),
|
||||
(v6/*: any*/)
|
||||
],
|
||||
"storageKey": "node(id:\"AZSfP_xAcAC5IAAAAAAltA\")"
|
||||
}
|
||||
@@ -228,6 +240,7 @@ return {
|
||||
"argumentDefinitions": [
|
||||
(v2/*: any*/),
|
||||
(v0/*: any*/),
|
||||
(v3/*: any*/),
|
||||
(v1/*: any*/)
|
||||
],
|
||||
"kind": "Operation",
|
||||
@@ -235,7 +248,7 @@ return {
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v3/*: any*/),
|
||||
"args": (v4/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
@@ -248,24 +261,24 @@ return {
|
||||
"name": "__typename",
|
||||
"storageKey": null
|
||||
},
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/)
|
||||
(v5/*: any*/),
|
||||
(v6/*: any*/)
|
||||
],
|
||||
"storageKey": "node(id:\"AZSfP_xAcAC5IAAAAAAltA\")"
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "813b95f0cae45fec89ee444ce9be7ebb",
|
||||
"cacheID": "d38a5cbe98c811f237ea5722871aabf6",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "VendorListPageQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query VendorListPageQuery(\n $count: Int!\n $after: CursorKey\n $before: CursorKey\n) {\n node(id: \"AZSfP_xAcAC5IAAAAAAltA\") {\n __typename\n id\n ... on Organization {\n vendors(first: $count, after: $after, before: $before) {\n edges {\n node {\n id\n name\n createdAt\n updatedAt\n }\n cursor\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n }\n}\n"
|
||||
"text": "query VendorListPageQuery(\n $first: Int\n $after: CursorKey\n $last: Int\n $before: CursorKey\n) {\n node(id: \"AZSfP_xAcAC5IAAAAAAltA\") {\n __typename\n id\n ... on Organization {\n vendors(first: $first, after: $after, last: $last, before: $before) {\n edges {\n node {\n id\n name\n createdAt\n updatedAt\n }\n cursor\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "46f94dbcc31c870cab30e1b8a2c64095";
|
||||
(node as any).hash = "e371fe8685ccc70b229f0d5b07d6e271";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"go.gearno.de/crypto/uuid"
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -63,7 +63,7 @@ func CursorKeyFromBytes(b []byte) (CursorKey, error) {
|
||||
return ck, nil
|
||||
}
|
||||
|
||||
func NewCursorKey(id uuid.UUID, t time.Time) CursorKey {
|
||||
func NewCursorKey(id gid.GID, t time.Time) CursorKey {
|
||||
var cursorKey CursorKey
|
||||
copy(cursorKey[:16], id[:])
|
||||
_ = binary.PutVarint(cursorKey[16:], t.UnixMicro())
|
||||
@@ -88,9 +88,8 @@ func (ck CursorKey) Timestamp() time.Time {
|
||||
return time.Unix(seconds, nanoseconds)
|
||||
}
|
||||
|
||||
func (ck CursorKey) ID() uuid.UUID {
|
||||
id, _ := uuid.FromBytes(ck[:])
|
||||
return id
|
||||
func (ck CursorKey) ID() gid.GID {
|
||||
return gid.GID(ck[:16])
|
||||
}
|
||||
|
||||
func (ck CursorKey) MarshalText() ([]byte, error) {
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
"go.gearno.de/crypto/uuid"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
@@ -44,7 +43,7 @@ type (
|
||||
)
|
||||
|
||||
func (c Control) CursorKey() page.CursorKey {
|
||||
return page.NewCursorKey(uuid.UUID(c.ID), c.CreatedAt)
|
||||
return page.NewCursorKey(c.ID, c.CreatedAt)
|
||||
}
|
||||
|
||||
func (c *Control) scan(r pgx.Row) error {
|
||||
@@ -146,13 +145,13 @@ VALUES (
|
||||
`
|
||||
|
||||
args := pgx.NamedArgs{
|
||||
"control_id": c.ID,
|
||||
"control_id": c.ID,
|
||||
"framework_id": c.FrameworkID,
|
||||
"name": c.Name,
|
||||
"description": c.Description,
|
||||
"content_ref": c.ContentRef,
|
||||
"created_at": c.CreatedAt,
|
||||
"updated_at": c.UpdatedAt,
|
||||
"name": c.Name,
|
||||
"description": c.Description,
|
||||
"content_ref": c.ContentRef,
|
||||
"created_at": c.CreatedAt,
|
||||
"updated_at": c.UpdatedAt,
|
||||
}
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
return err
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/crypto/uuid"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
@@ -37,7 +36,7 @@ type (
|
||||
)
|
||||
|
||||
func (cst ControlStateTransition) CursorKey() page.CursorKey {
|
||||
return page.NewCursorKey(uuid.UUID(cst.ID), cst.CreatedAt)
|
||||
return page.NewCursorKey(cst.ID, cst.CreatedAt)
|
||||
}
|
||||
|
||||
func (cst *ControlStateTransition) scan(r pgx.Row) error {
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/crypto/uuid"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
@@ -43,7 +42,7 @@ type (
|
||||
)
|
||||
|
||||
func (e Evidence) CursorKey() page.CursorKey {
|
||||
return page.NewCursorKey(uuid.UUID(e.ID), e.CreatedAt)
|
||||
return page.NewCursorKey(e.ID, e.CreatedAt)
|
||||
}
|
||||
|
||||
func (e *Evidence) scan(r pgx.Row) error {
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/crypto/uuid"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
@@ -37,7 +36,7 @@ type (
|
||||
)
|
||||
|
||||
func (cst EvidenceStateTransition) CursorKey() page.CursorKey {
|
||||
return page.NewCursorKey(uuid.UUID(cst.ID), cst.CreatedAt)
|
||||
return page.NewCursorKey(cst.ID, cst.CreatedAt)
|
||||
}
|
||||
|
||||
func (cst *EvidenceStateTransition) scan(r pgx.Row) error {
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/crypto/uuid"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
@@ -42,7 +41,7 @@ type (
|
||||
)
|
||||
|
||||
func (f Framework) CursorKey() page.CursorKey {
|
||||
return page.NewCursorKey(uuid.UUID(f.ID), f.CreatedAt)
|
||||
return page.NewCursorKey(f.ID, f.CreatedAt)
|
||||
}
|
||||
|
||||
func (f *Framework) scan(r pgx.Row) error {
|
||||
@@ -177,13 +176,13 @@ VALUES (
|
||||
`
|
||||
|
||||
args := pgx.NamedArgs{
|
||||
"framework_id": f.ID,
|
||||
"framework_id": f.ID,
|
||||
"organization_id": f.OrganizationID,
|
||||
"name": f.Name,
|
||||
"description": f.Description,
|
||||
"content_ref": f.ContentRef,
|
||||
"created_at": f.CreatedAt,
|
||||
"updated_at": f.UpdatedAt,
|
||||
"name": f.Name,
|
||||
"description": f.Description,
|
||||
"content_ref": f.ContentRef,
|
||||
"created_at": f.CreatedAt,
|
||||
"updated_at": f.UpdatedAt,
|
||||
}
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
return err
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/crypto/uuid"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
@@ -43,7 +42,7 @@ type (
|
||||
)
|
||||
|
||||
func (p People) CursorKey() page.CursorKey {
|
||||
return page.NewCursorKey(uuid.UUID(p.ID), p.CreatedAt)
|
||||
return page.NewCursorKey(p.ID, p.CreatedAt)
|
||||
}
|
||||
|
||||
func (p *People) scan(r pgx.Row) error {
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
"go.gearno.de/crypto/uuid"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
@@ -44,7 +43,7 @@ type (
|
||||
)
|
||||
|
||||
func (t Task) CursorKey() page.CursorKey {
|
||||
return page.NewCursorKey(uuid.UUID(t.ID), t.CreatedAt)
|
||||
return page.NewCursorKey(t.ID, t.CreatedAt)
|
||||
}
|
||||
|
||||
func (t *Task) scan(r pgx.Row) error {
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/crypto/uuid"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
@@ -37,7 +36,7 @@ type (
|
||||
)
|
||||
|
||||
func (tst TaskStateTransition) CursorKey() page.CursorKey {
|
||||
return page.NewCursorKey(uuid.UUID(tst.ID), tst.CreatedAt)
|
||||
return page.NewCursorKey(tst.ID, tst.CreatedAt)
|
||||
}
|
||||
|
||||
func (tst *TaskStateTransition) scan(r pgx.Row) error {
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/crypto/uuid"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
@@ -40,7 +39,7 @@ type (
|
||||
)
|
||||
|
||||
func (v Vendor) CursorKey() page.CursorKey {
|
||||
return page.NewCursorKey(uuid.UUID(v.ID), v.CreatedAt)
|
||||
return page.NewCursorKey(v.ID, v.CreatedAt)
|
||||
}
|
||||
|
||||
func (v *Vendor) scan(r pgx.Row) error {
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/crypto/uuid"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
@@ -37,7 +36,7 @@ type (
|
||||
)
|
||||
|
||||
func (s Session) CursorKey() page.CursorKey {
|
||||
return page.NewCursorKey(uuid.UUID(s.ID), s.CreatedAt)
|
||||
return page.NewCursorKey(s.ID, s.CreatedAt)
|
||||
}
|
||||
|
||||
func (s *Session) scan(r pgx.Row) error {
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/crypto/uuid"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
@@ -36,7 +35,7 @@ type (
|
||||
)
|
||||
|
||||
func (u User) CursorKey() page.CursorKey {
|
||||
return page.NewCursorKey(uuid.UUID(u.ID), u.CreatedAt)
|
||||
return page.NewCursorKey(u.ID, u.CreatedAt)
|
||||
}
|
||||
|
||||
func (u *User) scan(r pgx.Row) error {
|
||||
|
||||
Reference in New Issue
Block a user