File tree Expand file tree Collapse file tree 10 files changed +85
-81
lines changed
Search/components/SearchResults Expand file tree Collapse file tree 10 files changed +85
-81
lines changed Original file line number Diff line number Diff line change 1+ import { StatusMeta } from "@/types/status" ;
2+
13export enum BugStatuses {
24 IN_PROGRESS = 0 ,
35 READY = 1 ,
@@ -14,3 +16,29 @@ export enum RequestStates {
1416 DONE = 2 ,
1517 ERROR = 3 ,
1618}
19+
20+ export const reportStatusMap : Record < number , StatusMeta > = {
21+ 0 : {
22+ title : "В работе" ,
23+ color : "badge-error" ,
24+ border : "border-error" ,
25+ } ,
26+ 1 : {
27+ title : "Решён" ,
28+ color : "badge-success" ,
29+ border : "border-success" ,
30+ } ,
31+ } ;
32+
33+ export const bugStatusMap : Record < number , StatusMeta > = {
34+ 0 : {
35+ title : "Открыт" ,
36+ color : "badge-error" ,
37+ border : "border-error" ,
38+ } ,
39+ 1 : {
40+ title : "Исправлен" ,
41+ color : "badge-success" ,
42+ border : "border-success" ,
43+ } ,
44+ } ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- .section {
2- display : flex;
3- flex-direction : column;
4- gap : 1em ;
5- }
61
72.section-title {
83 font-size : 1.5em ;
Original file line number Diff line number Diff line change 44 loadReportsFx ,
55 $responsibleReports ,
66 $participantReports ,
7- } from "../.. /store/reportsSummary" ;
8- import ReportSummary from "./components/ReportSummary/ReportSummary " ;
7+ } from "@ /store/reportsSummary" ;
8+ import Section from "./components/Section/Section " ;
99import "./Home.css" ;
1010
1111const Main = ( ) => {
@@ -18,25 +18,9 @@ const Main = () => {
1818
1919 return (
2020 < div className = "text-base-content auto-rows-min gap-4" >
21- < section className = "flex flex-column section" >
22- < h2 className = "section-title text-base-content" > Ответственный</ h2 >
23- < div className = "reports-summary-wrapper" >
24- { ! ! responsibleReports . length &&
25- responsibleReports . map ( ( report ) => (
26- < ReportSummary key = { report . id } report = { report } highlight />
27- ) ) }
28- </ div >
29- </ section >
21+ < Section title = "Ответственный" reports = { responsibleReports } />
3022 < div className = "divider section-divider" > </ div >
31- < section className = "flex flex-column section" >
32- < h2 className = "section-title text-base-content" > Участник</ h2 >
33- < div className = "reports-summary-wrapper" >
34- { ! ! participantReports . length &&
35- participantReports . map ( ( report ) => (
36- < ReportSummary key = { report . id } report = { report } />
37- ) ) }
38- </ div >
39- </ section >
23+ < Section title = "Участник" reports = { participantReports } />
4024 </ div >
4125 ) ;
4226} ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import { useNavigate } from "react-router-dom" ;
2-
3- import "./ReportSummary.css" ;
42import { Report } from "@/types/report" ;
53
64type ReportProps = {
Original file line number Diff line number Diff line change 1+ import { Report } from "@/types/report" ;
2+ import ReportSummary from "./ReportSummary" ;
3+
4+ type Props = {
5+ title : string ;
6+ reports : Report [ ] ;
7+ } ;
8+
9+ const Section = ( { title, reports } : Props ) => {
10+ return (
11+ < section className = "flex flex-col gap-3" >
12+ < h2 className = "section-title text-base-content" > { title } </ h2 >
13+ < div className = "reports-summary-wrapper" >
14+ { ! ! reports . length &&
15+ reports . map ( ( report ) => (
16+ < ReportSummary key = { report . id } report = { report } highlight />
17+ ) ) }
18+ </ div >
19+ </ section >
20+ ) ;
21+ } ;
22+
23+ export default Section ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { useUnit } from "effector-react";
22import { $searchResult } from "@/store/search" ;
33import { formatDistanceToNow } from "date-fns" ;
44import { ru } from "date-fns/locale" ;
5- import { getStatusMeta } from "@/constants/status " ;
5+ import getStatusMeta from "@/utils/getStatusMeta " ;
66import { useNavigate } from "react-router-dom" ;
77import { ReportResponse } from "@/api/reports/models" ;
88
Original file line number Diff line number Diff line change 1+ export type StatusMeta = {
2+ title : string ;
3+ color :
4+ | "badge-success"
5+ | "badge-warning"
6+ | "badge-error"
7+ | "badge-info"
8+ | "badge-neutral" ;
9+ border : string ;
10+ } ;
Original file line number Diff line number Diff line change 1+ import { bugStatusMap , reportStatusMap } from "@/const" ;
2+ import { StatusMeta } from "@/types/status" ;
3+
4+ type EntityType = "bug" | "report" ;
5+
6+ const unknownStatus : StatusMeta = {
7+ title : "Неизвестно" ,
8+ color : "badge-neutral" ,
9+ border : "border-neutral" ,
10+ } ;
11+
12+ export default function getStatusMeta (
13+ type : EntityType ,
14+ status : number
15+ ) : StatusMeta {
16+ if ( type === "report" ) return reportStatusMap [ status ] ?? unknownStatus ;
17+ if ( type === "bug" ) return bugStatusMap [ status ] ?? unknownStatus ;
18+ return unknownStatus ;
19+ }
You can’t perform that action at this time.
0 commit comments