All files / src/pages/main-page/components MainPageContentDefinitions.tsx

72.72% Statements 8/11
50% Branches 2/4
50% Functions 3/6
70% Lines 7/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68    49x 49x 49x 49x                         49x     285x         212x                                                                                  
import { FlowsheetRead, UserInfo } from "@/api/apiStore.gen";
 
export enum MainPageContentTypes {
  project = "project",
  template = "template",
  binned = "binned",
}
 
export type MainPageContentConfig = {
  type: MainPageContentTypes;
  mainTitle: string;
  subTitle: string;
  emptyString: string;
  sortStorageKey: string;
  sortStorageValue: string;
  filter?: () => FlowsheetRead;
};
 
export const MainPageContents = {
  home: {
    type: MainPageContentTypes.project,
    mainTitle: (name: string) => `Kia Ora, ${name}!`,
    subTitle: "My Projects",
    emptyString: "No Current Projects",
    sortStorageKey: "flowsheet-sort-order",
    sortStorageValue: "Recently Edited",
    filter: (flowsheet: FlowsheetRead) => !flowsheet.is_binned,
  },
  templates: {
    type: MainPageContentTypes.template,
    mainTitle: "Templates",
    subTitle: "All Templates",
    emptyString: "No Current Templates",
    sortStorageKey: "flowsheet-sort-order-templates",
    sortStorageValue: "Recently Created",
    filter: undefined,
  },
  sharedWithMe: {
    type: MainPageContentTypes.project,
    mainTitle: "Shared With Me",
    subTitle: "All Shared",
    emptyString: "No Shared Projects",
    sortStorageKey: "flowsheet-sort-order",
    sortStorageValue: "Recently Edited",
    filter: (data: UserInfo, flowsheet: FlowsheetRead) =>
      flowsheet?.owner.id !== data?.id,
  },
  starred: {
    type: MainPageContentTypes.project,
    mainTitle: "Starred",
    subTitle: "All Starred",
    emptyString: "No Starred Projects",
    sortStorageKey: "flowsheet-sort-order",
    sortStorageValue: "Recently Edited",
    filter: (flowsheet: FlowsheetRead) =>
      flowsheet.is_starred && !flowsheet.is_binned,
  },
  binned: {
    type: MainPageContentTypes.binned,
    mainTitle: "Binned",
    subTitle: "All Binned",
    emptyString: "No Binned Projects",
    sortStorageKey: "flowsheet-sort-order-bin",
    sortStorageValue: "Recently Binned",
    filter: (flowsheet: FlowsheetRead) => flowsheet.is_binned,
  },
};