Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | 5x 9x 9x 27x 1x 18x 18x 1x | import { isMobile } from "@/utils";
import { languages } from "@/utils/constants";
import ReactCountryFlag from "react-country-flag";
import usePreferencesDialog from "@/hooks/usePreferencesDialog";
import { Dialog, DialogTitle, DialogContent, DialogActions } from "@mui/material";
import CloseIcon from "@mui/icons-material/Close";
import CheckIcon from "@mui/icons-material/Check";
export const PreferencesDialog = ({ onClose, openDialog }: { onClose: () => void; openDialog: boolean }) => {
const {
accentColors,
t,
accentColor,
selectedColor,
setSelectedColor,
selectedLanguage,
setSelectedLanguage,
selectedFontStyle,
setSelectedFontStyle,
handleUpdatePreferences,
} = usePreferencesDialog(onClose);
return (
<Dialog fullScreen={isMobile()} onClose={onClose} open={openDialog}>
<DialogTitle>
<div className="flex justify-between items-center">
<span className="text-2xl font-semibold">{t("preferences")}</span>
<CloseIcon onClick={onClose} sx={{ color: "#5A5A5A", cursor: "pointer" }} />
</div>
</DialogTitle>
<DialogContent>
<section>
<div className="font-bold text-xl">{t("language")}</div>
<div className="flex flex-col md:flex-row gap-4 mt-2">
{languages.map((l) => (
<div
key={l.name}
onClick={() => setSelectedLanguage(l.iso_639_1)}
className="flex items-center gap-1 border rounded-md shadow-md p-4 cursor-pointer w-full"
>
{selectedLanguage === l.iso_639_1 && (
<div className="flex justify-center items-center rounded-full h-[20px] w-[20px] border-2 bg-[#172554]">
<CheckIcon sx={{ color: "#fff", fontSize: 12 }} />
</div>
)}
<ReactCountryFlag countryCode={l.flag} />
<span>{t(l.english_name.toLowerCase())}</span>
</div>
))}
</div>
</section>
<section className="my-8">
<div className="font-bold text-xl">{t("font_style")}</div>
<div className="flex gap-2 mt-2">
{["normal", "italic"].map((_) => (
<div
key={_}
className="flex gap-1 items-center border rounded-md shadow-md p-4 cursor-pointer w-full"
onClick={() => setSelectedFontStyle(_)}
>
{_ === selectedFontStyle && (
<div className="flex justify-center items-center rounded-full h-[20px] w-[20px] border-2 bg-[#172554]">
<CheckIcon sx={{ color: "#fff", fontSize: 12 }} />
</div>
)}
{t(_)}
</div>
))}
</div>
</section>
<section className="mt-8">
<div className="font-bold text-xl">{t("personalize")}</div>
<div className="mt-1">{t("choose_accent_notice")}</div>
<div className="text-lg mt-5">{t("select_your_color")}</div>
<div className="grid grid-cols-6 mt-2 gap-6">
{accentColors.map((color, index) => (
<div
key={color}
data-testid={`accent-color-${index}`}
style={{
background: color,
}}
className="w-11 h-11 flex items-center justify-center rounded-full cursor-pointer"
onClick={() => setSelectedColor(color)}
>
{color === selectedColor && <CheckIcon sx={{ color: "#fff" }} fontSize="large" />}
</div>
))}
</div>
</section>
</DialogContent>
<DialogActions>
<button
onClick={handleUpdatePreferences}
style={{ background: accentColor }}
className="rounded-md w-full px-4 py-2 shadow-md text-white"
>
{t("apply")}
</button>
</DialogActions>
</Dialog>
);
};
|