Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDP-703]: Support the edition of the privacy_policy_link #88

Merged
merged 3 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/api/patchOrgInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export const patchOrgInfo = async (
case "name":
formData.append("data", `{"organization_name": "${value}"}`);
break;
case "privacyPolicyLink":
formData.append("data", `{"privacy_policy_link": "${value}"}`);
break;
ceciliaromao marked this conversation as resolved.
Show resolved Hide resolved
case "timezone":
formData.append("data", `{"timezone_utc_offset": "${value}"}`);
break;
Expand Down
51 changes: 45 additions & 6 deletions src/pages/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const Profile = () => {
});
const [organizationDetails, setOrganizationDetails] = useState({
name: "",
privacyPolicyLink: "",
logo: "",
});

Expand Down Expand Up @@ -211,7 +212,7 @@ export const Profile = () => {
id: profile.data.id,
firstName: profile.data.firstName,
lastName: profile.data.lastName,
email: profile.data.lastName,
email: profile.data.email,
role: profile.data.role,
});
dispatch(clearErrorAction());
Expand All @@ -222,13 +223,22 @@ export const Profile = () => {
) => {
event.preventDefault();

if (organizationDetails.name || imageFile || isApprovalRequired) {
if (
organizationDetails.name ||
organizationDetails.privacyPolicyLink ||
imageFile ||
isApprovalRequired
) {
dispatch(
updateOrgInfoAction({
name: emptyValueIfNotChanged(
organizationDetails.name,
organization.data.name,
),
privacyPolicyLink: emptyValueIfNotChanged(
organizationDetails.privacyPolicyLink,
organization.data.privacyPolicyLink,
),
logo: imageFile,
isApprovalRequired,
}),
Expand All @@ -244,6 +254,7 @@ export const Profile = () => {
setImageFile(undefined);
setOrganizationDetails({
name: organization.data.name,
privacyPolicyLink: organization.data.privacyPolicyLink,
logo: organization.data.logo,
});
setIsApprovalRequired(Boolean(organization.data.isApprovalRequired));
Expand Down Expand Up @@ -416,7 +427,7 @@ export const Profile = () => {
: {})}
>
{isEditOrganization ? (
<>
<div className="CardStack__grid">
<Input
id="name"
name="name"
Expand All @@ -425,16 +436,41 @@ export const Profile = () => {
value={organizationDetails.name}
onChange={handleOrgDetailsChange}
/>
</>

<Input
id="privacyPolicyLink"
name="privacyPolicyLink"
label="Privacy Policy Link"
fieldSize="sm"
value={organizationDetails.privacyPolicyLink}
onChange={handleOrgDetailsChange}
/>
</div>
) : (
<>
<div className="CardStack__grid">
<div className="CardStack__infoItem">
<label className="Label Label--sm">Name</label>
<div className="CardStack__infoItem__value">
{organization.data.name}
</div>
</div>
</>

<div className="CardStack__infoItem">
<label className="Label Label--sm">Privacy Policy Link</label>
<div className="CardStack__infoItem__value">
{organization.data.privacyPolicyLink ? (
<Link
href={organization.data.privacyPolicyLink}
target="_blank"
>
{organization.data.privacyPolicyLink}
</Link>
) : (
"-"
)}
</div>
</div>
</div>
)}
<div className="Label Label--sm">
<InfoTooltip
Expand Down Expand Up @@ -471,6 +507,8 @@ export const Profile = () => {
type="submit"
disabled={
organizationDetails.name === organization.data.name &&
organizationDetails.privacyPolicyLink ===
organization.data.privacyPolicyLink &&
!imageFile &&
isApprovalRequired === organization.data.isApprovalRequired
}
Expand Down Expand Up @@ -584,6 +622,7 @@ export const Profile = () => {
setIsEditOrganization(true);
setOrganizationDetails({
name: organization.data.name,
privacyPolicyLink: organization.data.privacyPolicyLink,
logo: organization.data.logo,
});
setIsApprovalRequired(
Expand Down
5 changes: 4 additions & 1 deletion src/store/ducks/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ export const updateOrgInfoAction = createAsyncThunk<
>(
"organization/updateOrgInfoAction",
async (
{ name, timezone, logo, isApprovalRequired },
{ name, privacyPolicyLink, timezone, logo, isApprovalRequired },
{ rejectWithValue, getState, dispatch },
) => {
const { token } = getState().userAccount;

try {
const orgInfo = await patchOrgInfo(token, {
name,
privacyPolicyLink,
timezone,
logo,
isApprovalRequired,
Expand Down Expand Up @@ -127,6 +128,7 @@ export const getStellarAccountAction = createAsyncThunk<
const initialState: OrganizationInitialState = {
data: {
name: "",
privacyPolicyLink: "",
logo: "",
distributionAccountPublicKey: "",
timezoneUtcOffset: "",
Expand Down Expand Up @@ -164,6 +166,7 @@ const organizationSlice = createSlice({
state.data = {
...state.data,
name: action.payload.name,
privacyPolicyLink: action.payload.privacy_policy_link,
distributionAccountPublicKey:
action.payload.distribution_account_public_key,
timezoneUtcOffset: action.payload.timezone_utc_offset,
Expand Down
3 changes: 3 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export type DisbursementDetailsInitialState = {
export type OrganizationInitialState = {
data: {
name: string;
privacyPolicyLink: string;
logo: string;
distributionAccountPublicKey: string;
timezoneUtcOffset: string;
Expand Down Expand Up @@ -447,6 +448,7 @@ export type AccountProfile = {
// =============================================================================
export type OrgUpdateInfo = {
name?: string;
privacyPolicyLink?: string;
timezone?: string;
logo?: File;
isApprovalRequired?: boolean;
Expand Down Expand Up @@ -761,6 +763,7 @@ export type ApiProfileInfo = {

export type ApiOrgInfo = {
name: string;
privacy_policy_link: string;
logo_url: string;
distribution_account_public_key: string;
timezone_utc_offset: string;
Expand Down
Loading