FPSMS-frontend
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

62 строки
1.3 KiB

  1. "use server";
  2. // import { serverFetchJson } from "@/app/utils/fetchUtil";
  3. // import { BASE_API_URL } from "@/config/api";
  4. import { serverFetchJson } from "../../utils/fetchUtil";
  5. import { BASE_API_URL } from "../../../config/api";
  6. import { Task, TaskGroup } from "../tasks";
  7. export interface CreateProjectInputs {
  8. // Project details
  9. projectCode: string;
  10. projectName: string;
  11. projectCategory: string;
  12. projectDescription: string;
  13. // Client details
  14. clientCode: string;
  15. clientName: string;
  16. clientContactName: string;
  17. clientPhone: string;
  18. clientEmail: string;
  19. clientSubsidiary: string;
  20. // Tasks
  21. tasks: {
  22. [taskId: Task["id"]]: {
  23. manhourAllocation: ManhourAllocation;
  24. };
  25. };
  26. // Staff
  27. allocatedStaffIds: number[];
  28. // Milestones
  29. milestones: {
  30. [taskGroupId: TaskGroup["id"]]: {
  31. startDate: string;
  32. endDate: string;
  33. payments: PaymentInputs[];
  34. };
  35. };
  36. }
  37. export interface ManhourAllocation {
  38. [gradeId: number]: number;
  39. }
  40. export interface PaymentInputs {
  41. id: number;
  42. description: string;
  43. date: string;
  44. amount: number;
  45. }
  46. export const saveProject = async (data: CreateProjectInputs) => {
  47. return serverFetchJson(`${BASE_API_URL}/projects/new`, {
  48. method: "POST",
  49. body: JSON.stringify(data),
  50. headers: { "Content-Type": "application/json" },
  51. });
  52. };