Skip to content

Commit

Permalink
Add settings feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierMod committed Oct 5, 2024
1 parent c6e91b5 commit 0cef3a7
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions client/src/views/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import MainLayout from "../layouts/MainLayout";
import styled from "styled-components";
import { useProvider } from "../context/AppProvider";
import { Button, InputText, Text, TextTypes } from "flatini-fe-library";
import { FaCheck } from "react-icons/fa";

const Wrapper = styled.div`
display: flex;
Expand All @@ -18,6 +19,7 @@ const InputGroup = styled.div`

const Settings = () => {
const { updateRequirements, requirements } = useProvider();
const [settingsSaved, setSettingsSaved] = useState<boolean | null>(null);

const [localRequirements, setLocalRequirements] = useState<{
price: null | string;
Expand Down Expand Up @@ -85,14 +87,35 @@ const Settings = () => {
</InputGroup>
</div>
<Button
onClick={async () =>
onClick={async () => {
await updateRequirements(
localRequirements.price,
localRequirements.locations
)
}
);
setSettingsSaved(true);

setTimeout(() => {
setSettingsSaved(null);
}, 1500);
}}
label="Save settings"
/>
{settingsSaved ? (
<div
style={{
display: "flex",
alignItems: "center",
justifyContent: "center",
gap: "1rem",
marginTop: "1.5rem",
}}
>
<FaCheck />
<Text type={TextTypes.paragraph}>
Your settings have been saved!
</Text>
</div>
) : null}
</form>
</Wrapper>
</MainLayout>
Expand Down

0 comments on commit 0cef3a7

Please sign in to comment.