@@ -21,6 +21,21 @@ export interface ClientSubsidiaryProjectResult { | |||||
comingPaymentMilestone: string; | comingPaymentMilestone: string; | ||||
} | } | ||||
export interface ClientProjectResult { | |||||
id: number; | |||||
customerId: number; | |||||
customerCode: string; | |||||
customerName: string; | |||||
subsidiaryId: number; | |||||
subsidiaryCode: string; | |||||
subsidiaryName: string; | |||||
projectNo: number; | |||||
} | |||||
export const fetchAllClientProjects = cache(async () => { | |||||
return serverFetchJson<ClientProjectResult[]>(`${BASE_API_URL}/dashboard/searchCustomerSubsidiary`); | |||||
}); | |||||
export const fetchAllClientSubsidiaryProjects = cache(async (customerId: number, tableSorting:string, subsidiaryId?: number) => { | export const fetchAllClientSubsidiaryProjects = cache(async (customerId: number, tableSorting:string, subsidiaryId?: number) => { | ||||
if (subsidiaryId === 0){ | if (subsidiaryId === 0){ | ||||
return serverFetchJson<ClientSubsidiaryProjectResult[]>( | return serverFetchJson<ClientSubsidiaryProjectResult[]>( | ||||
@@ -22,7 +22,7 @@ import { ConstructionOutlined } from "@mui/icons-material"; | |||||
import ReactApexChart from "react-apexcharts"; | import ReactApexChart from "react-apexcharts"; | ||||
import { ApexOptions } from "apexcharts"; | import { ApexOptions } from "apexcharts"; | ||||
import { useSearchParams } from 'next/navigation'; | import { useSearchParams } from 'next/navigation'; | ||||
import { fetchAllClientSubsidiaryProjects} from "@/app/api/clientprojects/actions"; | |||||
import { fetchAllClientSubsidiaryProjects,fetchAllClientProjects} from "@/app/api/clientprojects/actions"; | |||||
// const ReactApexChart = dynamic(() => import('react-apexcharts'), { ssr: false }); | // const ReactApexChart = dynamic(() => import('react-apexcharts'), { ssr: false }); | ||||
type SearchProjectQuery = Partial<Omit<ClientSubsidiaryProjectResult, "id">>; | type SearchProjectQuery = Partial<Omit<ClientSubsidiaryProjectResult, "id">>; | ||||
@@ -94,8 +94,15 @@ const ProgressByClient: React.FC<Props> = () => { | |||||
"#d1fef0", "#04afff", "#ff859e", "#4bdd15", "#ccfb2b"]; | "#d1fef0", "#04afff", "#ff859e", "#4bdd15", "#ccfb2b"]; | ||||
const [clientSubsidiaryProjectResult, setClientSubsidiaryProjectResult]:any[] = useState([]); | const [clientSubsidiaryProjectResult, setClientSubsidiaryProjectResult]:any[] = useState([]); | ||||
const [tableSorting, setTableSorting] = useState('ProjectName'); | const [tableSorting, setTableSorting] = useState('ProjectName'); | ||||
const [customerNameAndCode,setCustomerNameAndCode] = useState(""); | |||||
const fetchData = async () => { | const fetchData = async () => { | ||||
const clientprojects = await fetchAllClientProjects(); | |||||
for (let i = 0; i < clientprojects.length; i++) { | |||||
if (customerId != null && clientprojects[i].customerId == parseInt(customerId)){ | |||||
setCustomerNameAndCode(t("Selected Client") + ": " + clientprojects[i].customerName + " (" + clientprojects[i].customerCode + ")") | |||||
} | |||||
} | |||||
if (customerId && subsidiaryId) { | if (customerId && subsidiaryId) { | ||||
try { | try { | ||||
if (subsidiaryId === '-'){ | if (subsidiaryId === '-'){ | ||||
@@ -112,6 +119,7 @@ const ProgressByClient: React.FC<Props> = () => { | |||||
Number(subsidiaryId)) | Number(subsidiaryId)) | ||||
console.log(clickResult) | console.log(clickResult) | ||||
setClientSubsidiaryProjectResult(clickResult); | setClientSubsidiaryProjectResult(clickResult); | ||||
setFilteredClientSubsidiaryProjectResult(clickResult); | |||||
} | } | ||||
@@ -123,6 +131,7 @@ const ProgressByClient: React.FC<Props> = () => { | |||||
const clickResult = await fetchAllClientSubsidiaryProjects( | const clickResult = await fetchAllClientSubsidiaryProjects( | ||||
Number(customerId),tableSorting) | Number(customerId),tableSorting) | ||||
setClientSubsidiaryProjectResult(clickResult); | setClientSubsidiaryProjectResult(clickResult); | ||||
setFilteredClientSubsidiaryProjectResult(clickResult); | |||||
} catch (error) { | } catch (error) { | ||||
console.error('Error fetching client subsidiary projects:', error); | console.error('Error fetching client subsidiary projects:', error); | ||||
} | } | ||||
@@ -594,6 +603,15 @@ const ProgressByClient: React.FC<Props> = () => { | |||||
<Grid item sm> | <Grid item sm> | ||||
{/* <CustomSearchForm applySearch={applySearch} fields={InputFields}/> */} | {/* <CustomSearchForm applySearch={applySearch} fields={InputFields}/> */} | ||||
{/* <CustomDatagrid rows={rows} columns={columns} columnWidth={200} dataGridHeight={300}/> */} | {/* <CustomDatagrid rows={rows} columns={columns} columnWidth={200} dataGridHeight={300}/> */} | ||||
{customerNameAndCode !== "" && ( | |||||
<div style={{ display: "inline-block", width: "99%" }}> | |||||
<Grid item xs={12} md={12} lg={12}> | |||||
<Card> | |||||
<CardHeader className="text-slate-700" title= {customerNameAndCode} /> | |||||
</Card> | |||||
</Grid> | |||||
</div> | |||||
)} | |||||
<div style={{ display: "inline-block", width: "70%" }}> | <div style={{ display: "inline-block", width: "70%" }}> | ||||
<Grid item xs={12} md={12} lg={12}> | <Grid item xs={12} md={12} lg={12}> | ||||
<Card> | <Card> | ||||
@@ -11,6 +11,7 @@ import VisibilityIcon from '@mui/icons-material/Visibility'; | |||||
import { useRouter, useSearchParams } from "next/navigation"; | import { useRouter, useSearchParams } from "next/navigation"; | ||||
import ProgressByClient from "@/components/ProgressByClient"; | import ProgressByClient from "@/components/ProgressByClient"; | ||||
import Typography from "@mui/material/Typography"; | import Typography from "@mui/material/Typography"; | ||||
import { Card, CardHeader } from "@mui/material"; | |||||
interface Props { | interface Props { | ||||
clientProjects: ClientProjectResult[]; | clientProjects: ClientProjectResult[]; | ||||
@@ -43,6 +44,7 @@ const ProgressByClientSearch: React.FC<Props> = ({ clientProjects }) => { | |||||
const onTaskClick = useCallback(async (clientProjectResult: ClientProjectResult) => { | const onTaskClick = useCallback(async (clientProjectResult: ClientProjectResult) => { | ||||
try { | try { | ||||
// setCustomerNameAndCode(clientProjectResult.) | |||||
router.push( | router.push( | ||||
`/dashboard/ProjectStatusByClient?customerId=${clientProjectResult.customerId}&subsidiaryId=${clientProjectResult.subsidiaryId}` | `/dashboard/ProjectStatusByClient?customerId=${clientProjectResult.customerId}&subsidiaryId=${clientProjectResult.subsidiaryId}` | ||||
); | ); | ||||
@@ -19,7 +19,7 @@ import SearchBox, { Criterion } from "../SearchBox"; | |||||
import ProgressByTeamSearch from "@/components/ProgressByTeamSearch"; | import ProgressByTeamSearch from "@/components/ProgressByTeamSearch"; | ||||
import { Suspense } from "react"; | import { Suspense } from "react"; | ||||
import { useSearchParams } from 'next/navigation'; | import { useSearchParams } from 'next/navigation'; | ||||
import { fetchAllTeamProjects,ClientSubsidiaryProjectResult} from "@/app/api/teamprojects/actions"; | |||||
import { fetchAllTeamProjects, fetchTeamProjects, ClientSubsidiaryProjectResult} from "@/app/api/teamprojects/actions"; | |||||
// const ReactApexChart = dynamic(() => import('react-apexcharts'), { ssr: false }); | // const ReactApexChart = dynamic(() => import('react-apexcharts'), { ssr: false }); | ||||
type SearchProjectQuery = Partial<Omit<ClientSubsidiaryProjectResult, "id">>; | type SearchProjectQuery = Partial<Omit<ClientSubsidiaryProjectResult, "id">>; | ||||
@@ -92,6 +92,7 @@ const ProgressByTeam: React.FC = () => { | |||||
const [currentPage, setCurrentPage] = useState(1); | const [currentPage, setCurrentPage] = useState(1); | ||||
const recordsPerPage = 10; | const recordsPerPage = 10; | ||||
const [tableSorting, setTableSorting] = useState('ProjectName'); | const [tableSorting, setTableSorting] = useState('ProjectName'); | ||||
const [teamNameAndCode,setTeamNameAndCode] = useState(""); | |||||
const projectSearchCriteria: Criterion<SearchProjectParamNames>[] = useMemo( | const projectSearchCriteria: Criterion<SearchProjectParamNames>[] = useMemo( | ||||
() => [ | () => [ | ||||
@@ -102,7 +103,12 @@ const ProgressByTeam: React.FC = () => { | |||||
); | ); | ||||
const fetchData = async () => { | const fetchData = async () => { | ||||
console.log(tableSorting) | |||||
const teamprojects = await fetchTeamProjects(); | |||||
for (let i = 0; i < teamprojects.length; i++) { | |||||
if (teamLeadId != null && teamprojects[i].teamLeadId == parseInt(teamLeadId)){ | |||||
setTeamNameAndCode(t("Selected Team") + ": " + teamprojects[i].teamName + " (" + teamprojects[i].teamCode + ")") | |||||
} | |||||
} | |||||
if (teamLeadId) { | if (teamLeadId) { | ||||
try { | try { | ||||
const clickResult = await fetchAllTeamProjects( | const clickResult = await fetchAllTeamProjects( | ||||
@@ -672,6 +678,15 @@ const ProgressByTeam: React.FC = () => { | |||||
<Grid item sm> | <Grid item sm> | ||||
{/* <CustomSearchForm applySearch={applySearch} fields={InputFields}/> */} | {/* <CustomSearchForm applySearch={applySearch} fields={InputFields}/> */} | ||||
{/* <CustomDatagrid rows={rows} columns={columns} columnWidth={200} dataGridHeight={300}/> */} | {/* <CustomDatagrid rows={rows} columns={columns} columnWidth={200} dataGridHeight={300}/> */} | ||||
{teamNameAndCode !== "" && ( | |||||
<div style={{ display: "inline-block", width: "99%" }}> | |||||
<Grid item xs={12} md={12} lg={12}> | |||||
<Card> | |||||
<CardHeader className="text-slate-700" title= {teamNameAndCode} /> | |||||
</Card> | |||||
</Grid> | |||||
</div> | |||||
)} | |||||
<div style={{ display: "inline-block", width: "70%" }}> | <div style={{ display: "inline-block", width: "70%" }}> | ||||
<Grid item xs={12} md={12} lg={12}> | <Grid item xs={12} md={12} lg={12}> | ||||
<Card> | <Card> | ||||
@@ -229,7 +229,7 @@ const ProjectFinancialCard: React.FC<Props> = ({ | |||||
{Number(CostPerformanceIndex) >= 1 && ( | {Number(CostPerformanceIndex) >= 1 && ( | ||||
<> | <> | ||||
<div | <div | ||||
className="text-lg font-medium ml-5 mb-2" | |||||
className="text-lg font-medium mx-5 mb-2" | |||||
style={dataPositiveStyle} | style={dataPositiveStyle} | ||||
> | > | ||||
{CostPerformanceIndex} | {CostPerformanceIndex} | ||||
@@ -156,5 +156,7 @@ | |||||
"Task Count": "Task Count", | "Task Count": "Task Count", | ||||
"Total": "Total", | "Total": "Total", | ||||
"Status": "Status", | "Status": "Status", | ||||
"Check Project Status": "Check Project Status" | |||||
"Check Project Status": "Check Project Status", | |||||
"Selected Client": "Selected Client", | |||||
"Selected Team": "Selected Team" | |||||
} | } |
@@ -157,5 +157,7 @@ | |||||
"Task Count": "工作數量", | "Task Count": "工作數量", | ||||
"Total": "總計", | "Total": "總計", | ||||
"Status": "狀態", | "Status": "狀態", | ||||
"Check Project Status": "查看項目狀態" | |||||
"Check Project Status": "查看項目狀態", | |||||
"Selected Client": "已選擇客戶", | |||||
"Selected Team": "已選擇團隊" | |||||
} | } |