diff --git a/app/(main)/insights/utils/downloadCSV.ts b/app/(main)/insights/utils/downloadCSV.ts
new file mode 100644
index 0000000..e2490be
--- /dev/null
+++ b/app/(main)/insights/utils/downloadCSV.ts
@@ -0,0 +1,15 @@
+import { HappinessInsightsChartDTO } from '@/types/InsightsType';
+
+const convertToCSV = (objArray: HappinessInsightsChartDTO[]): string => {
+ if (!Array.isArray(objArray) || objArray.length === 0) {
+ return '';
+ }
+
+ const keys = Object.keys(objArray[0]);
+ const header = keys.join(',');
+ const csvRows = objArray.map((obj) => keys.map((key) => obj[key as keyof HappinessInsightsChartDTO]).join(','));
+
+ return [header, ...csvRows].join('\r\n');
+};
+
+export default convertToCSV;
diff --git a/styles/globals.css b/styles/globals.css
index 5f22fa7..26d1c38 100644
--- a/styles/globals.css
+++ b/styles/globals.css
@@ -3,64 +3,101 @@
@tailwind utilities;
:root {
- --font-outfit: 'Outfit', sans-serif;
+ --font-outfit: 'Outfit', sans-serif;
}
html,
body {
- height: 100%;
- padding: 0;
- margin: 0;
- font-family: var(--font-outfit);
+ height: 100%;
+ padding: 0;
+ margin: 0;
+ font-family: var(--font-outfit);
}
@layer utilities {
- .text-balance {
- text-wrap: balance;
- }
+ .text-balance {
+ text-wrap: balance;
+ }
}
@layer base {
- h1 {
- @apply text-2xl font-extrabold;
- }
+ h1 {
+ @apply text-2xl font-extrabold;
+ }
- h2 {
- @apply text-xl font-medium;
- }
+ h2 {
+ @apply text-xl font-medium;
+ }
- h3 {
- @apply text-sm font-medium;
- }
+ h3 {
+ @apply text-sm font-medium;
+ }
}
@layer base {
- :root {
- --chart-1: 12 76% 61%;
- --chart-2: 173 58% 39%;
- --chart-3: 197 37% 24%;
- --chart-4: 43 74% 66%;
- --chart-5: 27 87% 67%;
- }
-
- .dark {
- --chart-1: 220 70% 50%;
- --chart-2: 160 60% 45%;
- --chart-3: 30 80% 55%;
- --chart-4: 280 65% 60%;
- --chart-5: 340 75% 55%;
- }
+ :root {
+ --chart-1: 12 76% 61%;
+ --chart-2: 173 58% 39%;
+ --chart-3: 197 37% 24%;
+ --chart-4: 43 74% 66%;
+ --chart-5: 27 87% 67%;
+ }
+
+ .dark {
+ --chart-1: 220 70% 50%;
+ --chart-2: 160 60% 45%;
+ --chart-3: 30 80% 55%;
+ --chart-4: 280 65% 60%;
+ --chart-5: 340 75% 55%;
+ }
}
.rotate-360 {
- animation: rotate 0.4s linear;
+ animation: rotate 0.4s linear;
}
@keyframes rotate {
- from {
- transform: rotate(0deg);
- }
- to {
- transform: rotate(360deg);
- }
+ from {
+ transform: rotate(0deg);
+ }
+ to {
+ transform: rotate(360deg);
+ }
}
+
+@media print {
+
+ @page {
+ size: landscape;
+ margin: 1em;
+ }
+
+ body {
+ transform: scale(0.9);
+ transform-origin: top left;
+ }
+
+ /* Hide elements that should not be printed */
+ .no-print {
+ display: none;
+ }
+
+ .print-container {
+ width: 100%;
+ margin: 0;
+ padding: 0;
+ }
+
+ .print-content {
+ page-break-inside: avoid;
+ margin: 0;
+ padding: 10px;
+ font-size: 1em;
+ }
+
+ /* Prevent page breaks within the print content */
+ .print-content, .print-content > div {
+ page-break-inside: avoid;
+ break-inside: avoid;
+ }
+}
\ No newline at end of file