Skip to content

Commit

Permalink
US15 with the AC done
Browse files Browse the repository at this point in the history
  • Loading branch information
guzmanalejandro committed Dec 13, 2023
1 parent eb1b7e5 commit 26d7a11
Show file tree
Hide file tree
Showing 3 changed files with 243 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REACT_APP_API_URL = 'http://127.0.0.1:8000'
REACT_APP_API_URL = 'https://kasula-develop-5q5vehm3ja-ew.a.run.app'

# LA VARIABLE ESTÀ PENSADA PERQUÈ NO PORTI BARRA AL FINAL

Expand Down
116 changes: 116 additions & 0 deletions src/components/PrivacySettings.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import React, { useState, useEffect } from "react";
import { Tooltip, OverlayTrigger, Container, Row, Col, Dropdown, Form, Button } from "react-bootstrap";
import { InfoCircleFill } from "react-bootstrap-icons";

const PrivacySettings = ({
onClose,
handleSaveProfile,
handleVisibilityChange,
imPrivate,
usernameValidationMessage,
emailValidationMessage,
userNameAux,
userMailAux,
userBioAux,
usernameValid,
emailValid,
usernameValidated,
emailValidated,
onUsernameChange,
onEmailChange,
setUserBioAux
}) => {

const renderTooltip = (message) => (
<Tooltip id="button-tooltip">{message}</Tooltip>
);

useEffect(() => {
console.error(usernameValid==true)
}, [usernameValid]);

return (
<Container className="form-container p-4">
<Row>
<Col sm={12}>
<Form>
{/* Sección de edición de perfil */}
<Form.Group className="mb-3">
<Form.Label>Username</Form.Label>
<Form.Control
type="text"
value={userNameAux}
onChange={(e) => onUsernameChange(e)}
isInvalid={usernameValidated && !usernameValid}
/>
<Form.Control.Feedback type="invalid">
{usernameValidationMessage}
</Form.Control.Feedback>
</Form.Group>
<Form.Group className="mb-3">
<Form.Label>Email</Form.Label>
<Form.Control
type="email"
value={userMailAux}
onChange={(e) => onEmailChange(e)}
isInvalid={emailValidated && !emailValid}
/>
<Form.Control.Feedback type="invalid">
{emailValidationMessage}
</Form.Control.Feedback>
</Form.Group>
<Form.Group className="mb-3">
<Form.Label>Biography</Form.Label>
<Form.Control
as="textarea"
rows={3}
value={userBioAux}
onChange={(e) => setUserBioAux(e.target.value)}
/>
</Form.Group>
{/* Botón para guardar cambios */}
<Button variant="primary" onClick={handleSaveProfile} disabled={!usernameValid || !emailValid} >
Save Changes
</Button>
</Form>

<hr/>
<Row className="privacy-section align-items-center mt-4">
<Col sm={3}>
<h5>Profile Visibility:</h5>
</Col>
<Col sm={2}>
<Dropdown>
<Dropdown.Toggle
id="dropdown-visibility-button"
variant={!imPrivate ? "outline-primary" : "outline-secondary"}>
{imPrivate ? "Private" : "Public"}
</Dropdown.Toggle>

<Dropdown.Menu>
<Dropdown.Item onClick={() => handleVisibilityChange(false)}>
<OverlayTrigger
placement="right"
overlay={renderTooltip("Public profiles can be viewed by anyone.")}>
<span>Public <InfoCircleFill className="ms-1" /></span>
</OverlayTrigger>
</Dropdown.Item>

<Dropdown.Item onClick={() => handleVisibilityChange(true)}>
<OverlayTrigger
placement="right"
overlay={renderTooltip("Private profiles can only be viewed by approved followers.")}>
<span>Private <InfoCircleFill className="ms-1" /></span>
</OverlayTrigger>
</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</Col>
</Row>
</Col>
</Row>
</Container>
);
};

export default PrivacySettings;
Loading

0 comments on commit 26d7a11

Please sign in to comment.