From 84903c1e5182124b1bb618b7d8754cb70d0a6647 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Wed, 23 Feb 2022 18:11:37 +0100
Subject: feat: improve Ackee tracking (#11)

* build(deps): add use-ackee hook package

* chore: create a context provider for Ackee

The provider allows users to change the 'detailed' settings.

* chore: add a select menu to choose which info to share with Ackee

* chore: add a tooltip for askee settings

* chore: replace default select styles with custom styles

* chore: register user choice in localstorage

* chore: replace Matomo with Ackee in legal notice
---
 src/components/Form/Select/Select.tsx | 56 +++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 src/components/Form/Select/Select.tsx

(limited to 'src/components/Form/Select/Select.tsx')

diff --git a/src/components/Form/Select/Select.tsx b/src/components/Form/Select/Select.tsx
new file mode 100644
index 0000000..feab991
--- /dev/null
+++ b/src/components/Form/Select/Select.tsx
@@ -0,0 +1,56 @@
+import { ChangeEvent, ReactElement, SetStateAction } from 'react';
+import styles from './Select.module.scss';
+
+type SelectOptions = {
+  id: string;
+  name: string;
+  value: string;
+};
+
+const Select = ({
+  options,
+  id,
+  name,
+  value,
+  setValue,
+  required = false,
+  label,
+}: {
+  options: SelectOptions[];
+  id: string;
+  name: string;
+  value: string;
+  setValue: (value: SetStateAction<string>) => void;
+  required?: boolean;
+  label?: ReactElement;
+}) => {
+  const getOptions = () => {
+    return options.map((option) => (
+      <option key={option.id} value={option.value}>
+        {option.name}
+      </option>
+    ));
+  };
+
+  const handleChange = (event: ChangeEvent<HTMLSelectElement>) => {
+    setValue(event.target.value);
+  };
+
+  return (
+    <>
+      {label}
+      <select
+        name={name}
+        id={id}
+        value={value}
+        onChange={handleChange}
+        required={required}
+        className={styles.wrapper}
+      >
+        {getOptions()}
+      </select>
+    </>
+  );
+};
+
+export default Select;
-- 
cgit v1.2.3

