Skip to content

Commit

Permalink
improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
pachonjcl committed Jun 13, 2024
1 parent d59ec36 commit b023e57
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const AuditLogTab: FC<IProps> = ({ label, ...rest }) => {
/>
</When>
<When condition={buttonToogle === AuditLogButtonStates.PROJECT && !record?.project}>
<SiteAuditLogProjectStatus record={record} auditLogData={auditLogData} refresh={refetch} />
<SiteAuditLogProjectStatus record={record} auditLogData={auditLogData} />
</When>
<When condition={buttonToogle !== AuditLogButtonStates.PROJECT}>
<SiteAuditLogEntityStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const SiteAuditLogEntityStatusSide = ({
<Text variant="text-16-bold">{`${entityType} Status`}</Text>
<StepProgressbar
color="secondary"
value={(getValueForStatus && getValueForStatus(record?.status)) ?? 0}
value={getValueForStatus?.(record?.status) ?? 0}
labels={progressBarLabels}
classNameLabels="min-w-[99px] "
className={classNames("w-[98%] pl-[1%]", entityType === "Polygon" && "pl-[6%]")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,26 @@ import { FC } from "react";
import Text from "@/components/elements/Text/Text";
import { AuditStatusResponse, ProjectLiteRead } from "@/generated/apiSchemas";

import CommentarySection from "../../PolygonReviewTab/components/CommentarySection/CommentarySection";
import AuditLogTable from "./AuditLogTable";

export interface SiteAuditLogProjectStatusProps {
record?: ProjectLiteRead | null;
refresh?: () => void;
auditLogData?: { data: AuditStatusResponse[] };
}

export const gridData = [
{
id: "1",
date: "28/11/2023 09.39",
user: "Jessica Chaimers",
site: null,
status: "Need More Information",
comentary: null
},
{
id: "2",
date: "28/11/2023 09.39",
user: "Teresa Muthoni",
site: null,
status: "Need More Information",
comentary:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
},
{
id: "3",
date: "28/11/2023 09.39",
user: "Jessica Chaimers",
site: null,
status: "Awaiting Approval",
comentary: null
},
{
id: "4",
date: "28/11/2023 09.39",
user: "Jessica Chaimers",
site: null,
status: "Awaiting Approval",
comentary: null
},
{
id: "5",
date: "28/11/2023 09.39",
user: "Jessica Chaimers",
site: null,
status: "Awaiting Approval",
comentary: null
}
];

const SiteAuditLogProjectStatus: FC<SiteAuditLogProjectStatusProps> = ({ record, auditLogData, refresh }) => {
return (
<div className="flex flex-col gap-6">
<div>
<Text variant="text-24-bold" className="mb-1">
Project Status and Comments
</Text>
<Text variant="text-14-light" className="mb-4">
Update the project status, view updates, or add comments
</Text>
<CommentarySection record={record} entity={"Project"} refresh={refresh} viewCommentsList={false} />
</div>
<Text variant="text-16-bold">History and Discussion for {record && record?.name}</Text>
{auditLogData && <AuditLogTable auditLogData={auditLogData} />}
const SiteAuditLogProjectStatus: FC<SiteAuditLogProjectStatusProps> = ({ record, auditLogData }) => (
<div className="flex flex-col gap-6">
<div>
<Text variant="text-24-bold" className="mb-1">
Project Status and Comments
</Text>
<Text variant="text-14-light" className="mb-4">
Update the project status, view updates, or add comments
</Text>
</div>
);
};
<Text variant="text-16-bold">History and Discussion for {record && record?.name}</Text>
{auditLogData && <AuditLogTable auditLogData={auditLogData} />}
</div>
);

export default SiteAuditLogProjectStatus;
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ const StatusDisplay = ({
);

const onFinallyRequest = () => {
refresh && refresh();
reloadEntity && reloadEntity();
refresh?.();
reloadEntity();
closeModal();
};

Expand Down
6 changes: 3 additions & 3 deletions src/components/elements/CommentaryBox/CommentaryBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ const CommentaryBox = (props: CommentaryBoxProps) => {
<div className="flex items-center gap-2 rounded-3xl border border-grey-750 p-3">
<div className="flex min-h-[32px] min-w-[32px] items-center justify-center self-start rounded-full bg-primary-500">
<Text variant="text-14-semibold" className="uppercase text-white">
{(name && name[0]) ?? ""}
{(lastName && lastName[0]) ?? ""}
{name?.[0] ?? ""}
{lastName?.[0] ?? ""}
</Text>
</div>
<TextArea
Expand Down Expand Up @@ -185,7 +185,7 @@ const CommentaryBox = (props: CommentaryBoxProps) => {
<div className="display-grid">
{warning && charCount > 255 && <div className="text-right text-xs text-red">{warning}</div>}
<div className={`text-nowrap text-right text-xs ${charCount > 255 ? "text-red" : "text-grey-500"}`}>
{charCount}/255 characters
{charCount}/255 {t("characters")}
</div>
</div>
</div>
Expand Down

0 comments on commit b023e57

Please sign in to comment.