Skip to content

Commit

Permalink
Merge pull request #298 from fiit-tp-tim20/main
Browse files Browse the repository at this point in the history
zarovnanie v tabulkach
  • Loading branch information
lubomirsilny authored May 19, 2024
2 parents 9f4d122 + 387daed commit bc9eb72
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 90 deletions.
11 changes: 3 additions & 8 deletions apps/saip-fe/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ function App() {
reconnectAttempts: 1000,
reconnectInterval: 3900,
});
const { reset: resetCompanyState } = useCompanyStore();
const { reset: resetUpgradeState } = useUpgradesStore();
const { reset: resetMarketingState } = useMarketingStore();

const [enableArc] = useState(true);

Expand Down Expand Up @@ -121,11 +118,6 @@ function App() {
document.documentElement.style.setProperty("--hover", enableArc ? "var(--arc-palette-hover)" : "");
}, [enableArc]);

useEffect(() => {
resetCompanyState();
resetUpgradeState();
resetMarketingState();
}, [comm, turnNum]);
useEffect(() => {
const timer = setTimeout(() => {
if (isLoading) {
Expand Down Expand Up @@ -166,6 +158,9 @@ function App() {
}

if (turnNum === 0 && !isAnonym) {
const { reset: resetCompanyState } = useCompanyStore();
const { reset: resetUpgradeState } = useUpgradesStore();
const { reset: resetMarketingState } = useMarketingStore();
return (
<div className="flex flex-col justify-center items-center h-screen">
<h1 className="text-4xl font-bold pb-4">Hra sa ešte nezačala</h1>
Expand Down
1 change: 1 addition & 0 deletions apps/saip-fe/src/components/bottombar/BottomBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function BottomBar() {
const [tooltipText, setTooltipText] = useState("");
const dataWs = useContext(MyContext);
const {setComm, comm} = useContext(MyContext)
const {turnNum} = useContext(MyContext)
const { isLoading, data, refetch} = useQuery("companyInfo", () => getGeneralInfo());
// @ts-ignore
const [bonusCash, setBonusCash] = useState(0);
Expand Down
48 changes: 24 additions & 24 deletions apps/saip-fe/src/components/reports/ArchiveReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,29 +97,29 @@ function ArchiveReport() {
<table className="table-auto table-white">
<tbody>
<tr>
<th className="px-4 py-2">Kolo</th>
<th className="px-4 py-2">Virálny marketing</th>
<th className="px-4 py-2">OOH</th>
<th className="px-4 py-2">Billboardy</th>
<th className="px-4 py-2">Televízia</th>
<th className="px-4 py-2">Podcasty</th>
<th className="px-4 py-2 text-center">Kolo</th>
<th className="px-4 py-2 text-center">Virálny marketing</th>
<th className="px-4 py-2 text-center">OOH</th>
<th className="px-4 py-2 text-center">Billboardy</th>
<th className="px-4 py-2 text-center">Televízia</th>
<th className="px-4 py-2 text-center">Podcasty</th>
</tr>
{[...Array(turn).keys()].map((turn) => (
<tr key={turn}>
<td className="px-4 py-2">{turn + 1}</td>
<td className="px-4 py-2 whitespace-nowrap">
<td className="px-4 py-2 text-center">{turn + 1}</td>
<td className="px-4 py-2 whitespace-nowrap text-center">
{numberWithSpaces(data.marketing.viral[turn])}
</td>
<td className="px-4 py-2 whitespace-nowrap">
<td className="px-4 py-2 whitespace-nowrap text-center">
{numberWithSpaces(data.marketing.ooh[turn])}
</td>
<td className="px-4 py-2 whitespace-nowrap">
<td className="px-4 py-2 whitespace-nowrap text-center">
{numberWithSpaces(data.marketing.billboard[turn])}
</td>
<td className="px-4 py-2 whitespace-nowrap">
<td className="px-4 py-2 whitespace-nowrap text-center">
{numberWithSpaces(data.marketing.tv[turn])}
</td>
<td className="px-4 py-2 whitespace-nowrap">
<td className="px-4 py-2 whitespace-nowrap text-center">
{numberWithSpaces(data.marketing.podcast[turn])}
</td>
</tr>
Expand All @@ -134,29 +134,29 @@ function ArchiveReport() {
<table className="table-auto table-white">
<tbody>
<tr>
<th className="px-4 py-2">Kolo</th>
<th className="px-4 py-2">Vyrobené množstvo</th>
<th className="px-4 py-2">Predajná cena</th>
<th className="px-4 py-2">Investície do kapitálu</th>
<th className="px-4 py-2">Investície do vylepšení</th>
<th className="px-4 py-2">Dokoné vylepšenia</th>
<th className="px-4 py-2 text-center">Kolo</th>
<th className="px-4 py-2 text-center">Vyrobené množstvo</th>
<th className="px-4 py-2 text-center">Predajná cena</th>
<th className="px-4 py-2 text-center">Investície do kapitálu</th>
<th className="px-4 py-2 text-center">Investície do vylepšení</th>
<th className="px-4 py-2 text-center">Dokoné vylepšenia</th>
</tr>
{[...Array(turn).keys()].map((turn) => (
<tr key={turn}>
<td className="px-4 py-2">{turn + 1}</td>
<td className="px-4 py-2 whitespace-nowrap">
<td className="px-4 py-2 text-center">{turn + 1}</td>
<td className="px-4 py-2 whitespace-nowrap text-center">
{numberWithSpaces(data.production.volume[turn])} ks
</td>
<td className="px-4 py-2 whitespace-nowrap">
<td className="px-4 py-2 whitespace-nowrap text-center">
{numberWithSpaces(data.production.sell_price[turn])}
</td>
<td className="px-4 py-2 whitespace-nowrap">
<td className="px-4 py-2 whitespace-nowrap text-center">
{numberWithSpaces(data.factory.capital[turn])}
</td>
<td className="px-4 py-2 whitespace-nowrap">
<td className="px-4 py-2 whitespace-nowrap text-center">
{numberWithSpaces(data.factory.upgrades[turn])}
</td>
<td className="px-4 py-2 whitespace-nowrap">
<td className="px-4 py-2 whitespace-nowrap text-center">
{numberWithSpaces(data.factory.upgrade_turn[turn])}
</td>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions apps/saip-fe/src/components/reports/CompanyReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ function CompanyReport() {
<i>odpis z kapitálových investícií</i>
<br />
<br />
<h5>Dodatočné náklady na nepredané výrobky</h5>
<h5>Náklady na spravovanie</h5>
= cena za uskladnenie jednotky * počet kusov na sklade
<br />
<br />
Expand Down Expand Up @@ -583,7 +583,7 @@ function CompanyReport() {
</td>
</tr>
<tr>
<td className="px-4 py-2">Dodatočné náklady na nepredané výrobky</td>
<td className="px-4 py-2">Náklady na spravovanie</td>
<td className="px-4 py-2 whitespace-nowrap">
{numberWithSpaces(data?.income_statement.inventory_charge)}
</td>
Expand Down
108 changes: 54 additions & 54 deletions apps/saip-fe/src/components/reports/IndustryReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ function IndustryReport() {
<p>a</p>
) : (
<>
<div className="background-container my-2 flex flex-col rounded-2xl p-6">
{isLoading2 ? (
<div>Loading...</div>
) : (
<IndustryGraph
rank={graphData?.rank}
stock_price={graphData?.stock_price}
num_players={graphData?.num_players}
/>
)}
</div>
<div className="background-container my-2 flex flex-col rounded-2xl p-6">
<div className="flex flex-row items-center justify-between py-2">
<h2>Rebríček všetkých firiem (podľa akcií)</h2>
Expand Down Expand Up @@ -158,28 +169,28 @@ function IndustryReport() {
.map((industry, index) => (
<tr key={industry[0]}>
<td className="px-4 py-2">{index + 1}</td>
<td className="px-4 py-2">{industry[0]}</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">{industry[0]}</td>
<td className="px-4 py-2 text-center">
{industry[1]?.stock_price &&
numberWithSpaces(industry[1]?.stock_price)}{" "}
</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">
{industry[1]?.net_profit &&
numberWithSpaces(industry[1]?.net_profit)}{" "}
</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">
{industry[1]?.sell_price &&
numberWithSpaces(industry[1]?.sell_price)}{" "}
€/ks
</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">
{industry[1]?.market_share &&
numberWithSpaces(industry[1]?.market_share)}{" "}
%
</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">
{industry[1]?.finished_upgrades &&
numberWithSpaces(industry[1]?.finished_upgrades)}{" "}

Expand All @@ -189,10 +200,10 @@ function IndustryReport() {
{/* Add row for average stock price */}
<tr>
<td className="px-4 py-2" />
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">
<b>Priemer</b>
</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">
{/* Calculate and display average stock price */}
{data && (
<b>
Expand All @@ -209,7 +220,7 @@ function IndustryReport() {
</b>
)}
</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">
{/* Calculate and display average net profit */}
{data && (
<b>
Expand All @@ -226,7 +237,7 @@ function IndustryReport() {
</b>
)}
</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">
{/* Calculate and display average sell price */}
{data && (
<b>
Expand Down Expand Up @@ -254,42 +265,42 @@ function IndustryReport() {
<table className="table-auto table-white">
<thead>
<tr>
<th className="px-4 py-2 text-left table-header text-white">Kategória</th>
<th className="px-4 py-2 text-left table-header text-white">Hodnota</th>
<th className="px-4 py-2 text-left table-header text-white">Nárast / pokles</th>
<th className="px-4 py-2 text-center table-header text-white">Kategória</th>
<th className="px-4 py-2 text-center table-header text-white">Hodnota</th>
<th className="px-4 py-2 text-center table-header text-white">Nárast / pokles</th>
</tr>
</thead>
<tbody>
<tr className="hover:bg-stone-100">
<td className="px-4 py-2">Celkové objednávky</td>
<td className="px-4 py-2">{numberWithSpaces(data?.market.demand)}</td>
<td className="px-4 py-2">{numberWithSpaces(data?.market.demand_difference)} %</td>
<td className="px-4 py-2 text-center">Celkové objednávky</td>
<td className="px-4 py-2 text-center">{numberWithSpaces(data?.market.demand)}</td>
<td className="px-4 py-2 text-center">{numberWithSpaces(data?.market.demand_difference)} %</td>
</tr>
<tr className="hover:bg-stone-100">
<td className="px-4 py-2">Celkový predaj</td>
<td className="px-4 py-2">{numberWithSpaces(data?.market.sold_products)}</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">Celkový predaj</td>
<td className="px-4 py-2 text-center">{numberWithSpaces(data?.market.sold_products)}</td>
<td className="px-4 py-2 text-center">
{numberWithSpaces(data?.market.sold_products_difference)} %
</td>
</tr>
<tr className="hover:bg-stone-100">
<td className="px-4 py-2">Celková výroba</td>
<td className="px-4 py-2">{numberWithSpaces(data?.market.manufactured)}</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">Celková výroba</td>
<td className="px-4 py-2 text-center">{numberWithSpaces(data?.market.manufactured)}</td>
<td className="px-4 py-2 text-center">
{numberWithSpaces(data?.market.manufactured_difference)} %
</td>
</tr>
<tr className="hover:bg-stone-100">
<td className="px-4 py-2">Celková kapacita</td>
<td className="px-4 py-2">{numberWithSpaces(data?.market.capacity)}</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">Celková kapacita</td>
<td className="px-4 py-2 text-center">{numberWithSpaces(data?.market.capacity)}</td>
<td className="px-4 py-2 text-center">
{numberWithSpaces(data?.market.capacity_difference)} %
</td>
</tr>
<tr className="hover:bg-stone-100">
<td className="px-4 py-2">Celkové zásoby v odvetví</td>
<td className="px-4 py-2">{numberWithSpaces(data?.market.inventory)}</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">Celkové zásoby v odvetví</td>
<td className="px-4 py-2 text-center">{numberWithSpaces(data?.market.inventory)}</td>
<td className="px-4 py-2 text-center">
{numberWithSpaces(data?.market.inventory_difference)} %
</td>
</tr>
Expand Down Expand Up @@ -325,61 +336,50 @@ function IndustryReport() {
</div>
<table className="table-auto table-white">
<thead>
<th className="px-4 py-2 text-left table-header text-white">Parameter</th>
<th className="px-4 py-2 text-left table-header text-white">Hodnota</th>
<th className="px-4 py-2 text-left table-header text-white">Nárast / pokles</th>
<th className="px-4 py-2 text-center table-header text-white">Parameter</th>
<th className="px-4 py-2 text-center table-header text-white">Hodnota</th>
<th className="px-4 py-2 text-center table-header text-white">Nárast / pokles</th>
</thead>
<tbody>
<tr className="hover:bg-stone-100">
<td className="px-4 py-2">Úroková sadzba</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">Úroková sadzba</td>
<td className="px-4 py-2 text-center">
{numberWithSpaces(data?.economic_parameters.interest_rate)} %
</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">
{numberWithSpaces(data?.economic_parameters.interest_rate_difference)} %
</td>
</tr>
<tr className="hover:bg-stone-100">
<td className="px-4 py-2">Úverový limit</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">Úverový limit</td>
<td className="px-4 py-2 text-center">
{numberWithSpaces(data?.economic_parameters.loan_limit)}
</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">
{numberWithSpaces(data?.economic_parameters.loan_limit_difference)} %
</td>
</tr>
<tr className="hover:bg-stone-100">
<td className="px-4 py-2">Sadzba dane z prijmu</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">Sadzba dane z prijmu</td>
<td className="px-4 py-2 text-center">
{numberWithSpaces(data?.economic_parameters.tax_rate)} %
</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">
{numberWithSpaces(data?.economic_parameters.tax_rate_difference)} %
</td>
</tr>
<tr className="hover:bg-stone-100">
<td className="px-4 py-2">Inflácia</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">Inflácia</td>
<td className="px-4 py-2 text-center">
{numberWithSpaces(data?.economic_parameters.inflation)} %
</td>
<td className="px-4 py-2">
<td className="px-4 py-2 text-center">
{numberWithSpaces(data?.economic_parameters.inflation_difference)} %
</td>
</tr>
</tbody>
</table>
</div>
<div className="background-container my-2 flex flex-col rounded-2xl p-6">
{isLoading2 ? (
<div>Loading...</div>
) : (
<IndustryGraph
rank={graphData?.rank}
stock_price={graphData?.stock_price}
num_players={graphData?.num_players}
/>
)}
</div>
</>
)}
</div>
Expand Down
12 changes: 12 additions & 0 deletions apps/saip-fe/src/screens/Marketing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ function Marketing() {
}
/>
)}
<button
onClick={() => {
setBillboardChecked(true)
setOohChecked(true)
setTvChecked(true)
setPodcastChecked(true)
setViralChecked(true)
}}
className="button-light font-bold py-2 px-4 rounded-lg focus:outline-none focus:shadow-outline ml-auto"
>
Potvrdiť všetky
</button>
</div>
<div className="background-container my-2 flex flex-col rounded-2xl p-6">
<div className="flex flex-row items-center justify-between py-2">
Expand Down
3 changes: 2 additions & 1 deletion apps/saip-fe/src/store/Upgrades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ const useUpgradesStore = create<UpgradeState>()(
reset: () => set(() => ({ upgrades: {}, upgradesCheck: {} })), // Reset upgradesCheck along with upgrades
getSum: () => Object.values(get().upgrades).reduce((a, b) => a + b, 0),
getChecked: () => {
const upgrades_num = Object.values(get().upgrades)
if (upgrades_num.length == 0)return true
const checkedValues = Object.values(get().upgradesCheck);
if (checkedValues.length > 0) {
return checkedValues.every((value) => value);
}
// Check if all upgrades are checked
return false;
},
}),
Expand Down
Loading

0 comments on commit bc9eb72

Please sign in to comment.