Add custom option in the estimate templates

This commit is contained in:
Satish Gandham 2024-05-27 19:08:24 +05:30
parent eb9b60df04
commit 600ad8698f
3 changed files with 44 additions and 13 deletions

View File

@ -56,6 +56,7 @@ export type TEstimatePointsObject = {
export type TTemplateValues = { export type TTemplateValues = {
title: string; title: string;
values: TEstimatePointsObject[]; values: TEstimatePointsObject[];
hide?: boolean;
}; };
export type TEstimateSystem = { export type TEstimateSystem = {

View File

@ -37,20 +37,34 @@ export const EstimateCreateStageOne: FC<TEstimateCreateStageOne> = (props) => {
/> />
</div> </div>
<div className="space-y-3"> <div className="space-y-3">
<div className="text-sm font-medium text-custom-text-200 mb-3">Choose a template</div> <div className="text-sm font-medium text-custom-text-200">Start from scratch</div>
<button
className="border border-custom-border-200 rounded-md p-2 text-left flex-1 w-full block"
onClick={() => handleEstimatePoints("custom")}
>
<p className="block text-sm">Custom</p>
<p className="text-xs text-gray-400">
Add your own <span className="lowercase">{currentEstimateSystem.name}</span> from scratch
</p>
</button>
<div className="text-sm font-medium text-custom-text-200">Choose a template</div>
<div className="grid grid-cols-1 lg:grid-cols-2 gap-3"> <div className="grid grid-cols-1 lg:grid-cols-2 gap-3">
{Object.keys(currentEstimateSystem.templates).map((name) => ( {Object.keys(currentEstimateSystem.templates).map((name) =>
<button currentEstimateSystem.templates[name]?.hide ? null : (
key={name} <button
className="border border-custom-border-200 rounded-md p-2 text-left" key={name}
onClick={() => handleEstimatePoints(name)} className="border border-custom-border-200 rounded-md p-2 text-left"
> onClick={() => handleEstimatePoints(name)}
<p className="block text-sm">{currentEstimateSystem.templates[name]?.title}</p> >
<p className="text-xs text-gray-400"> <p className="block text-sm">{currentEstimateSystem.templates[name]?.title}</p>
{currentEstimateSystem.templates[name]?.values?.map((template) => template?.value)?.join(", ")} <p className="text-xs text-gray-400">
</p> {currentEstimateSystem.templates[name]?.values?.map((template) => template?.value)?.join(", ")}
</button> </p>
))} </button>
)
)}
</div> </div>
</div> </div>
</div> </div>

View File

@ -57,6 +57,14 @@ export const ESTIMATE_SYSTEMS: TEstimateSystems = {
{ id: undefined, key: 6, value: "36" }, { id: undefined, key: 6, value: "36" },
], ],
}, },
custom: {
title: "Custom",
values: [
{ id: undefined, key: 1, value: "1" },
{ id: undefined, key: 2, value: "2" },
],
hide: true,
},
}, },
is_available: true, is_available: true,
}, },
@ -83,6 +91,14 @@ export const ESTIMATE_SYSTEMS: TEstimateSystems = {
{ id: undefined, key: 4, value: "Very Hard" }, { id: undefined, key: 4, value: "Very Hard" },
], ],
}, },
custom: {
title: "Custom",
values: [
{ id: undefined, key: 1, value: "1" },
{ id: undefined, key: 2, value: "2" },
],
hide: true,
},
}, },
is_available: true, is_available: true,
}, },