您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

87 行
1.8 KiB

  1. import { serverFetchJson } from "@/app/utils/fetchUtil";
  2. import { BASE_API_URL } from "@/config/api";
  3. import { cache } from "react";
  4. import "server-only";
  5. export interface Claim {
  6. id: number;
  7. created: string;
  8. name: string;
  9. cost: number;
  10. type: "Expense" | "Petty Cash";
  11. status: "Not Submitted" | "Waiting for Approval" | "Approved" | "Rejected";
  12. remarks: string;
  13. }
  14. export interface ClaimSearchForm {
  15. id: number;
  16. created: string;
  17. createdTo: string;
  18. name: string;
  19. cost: number;
  20. type: "Expense" | "Petty Cash";
  21. status: "Not Submitted" | "Waiting for Approval" | "Approved" | "Rejected";
  22. remarks: string;
  23. }
  24. export interface ProjectCombo {
  25. id: number;
  26. name: string;
  27. code: string;
  28. }
  29. export interface SupportingDocument {
  30. id: number;
  31. skey: string;
  32. filename: string;
  33. }
  34. export const preloadClaims = () => {
  35. fetchClaims();
  36. };
  37. export const fetchClaims = cache(async () => {
  38. return mockClaims;
  39. // return serverFetchJson<Claim[]>(`${BASE_API_URL}/claim`);
  40. });
  41. export const fetchProjectCombo = cache(async () => {
  42. return serverFetchJson<ProjectCombo[]>(`${BASE_API_URL}/projects`, {
  43. next: { tags: ["projects"] },
  44. });
  45. });
  46. // export const fetchAllCustomers = cache(async () => {
  47. // return serverFetchJson<Customer[]>(`${BASE_API_URL}/customer`);
  48. // });
  49. const mockClaims: Claim[] = [
  50. {
  51. id: 1,
  52. created: "2023/11/22",
  53. name: "Consultancy Project A",
  54. cost: 121.0,
  55. type: "Expense",
  56. status: "Not Submitted",
  57. remarks: "",
  58. },
  59. {
  60. id: 2,
  61. created: "2023/11/30",
  62. name: "Consultancy Project A",
  63. cost: 4300.0,
  64. type: "Expense",
  65. status: "Waiting for Approval",
  66. remarks: "",
  67. },
  68. {
  69. id: 3,
  70. created: "2023/12/12",
  71. name: "Construction Project C",
  72. cost: 3675.0,
  73. type: "Petty Cash",
  74. status: "Rejected",
  75. remarks: "Duplicate Claim Form",
  76. },
  77. ];