Skip to content

Commit

Permalink
🐛 Fix: subscription status update
Browse files Browse the repository at this point in the history
  • Loading branch information
ilp-sys committed May 28, 2024
1 parent 9fcd553 commit 38e5352
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions aeye/app/(nav)/my/ProfileAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export default function ProfileAvatar() {
sx={{
width: 100,
height: 100,
backgroundColor: "#f0f0f0", // Add background color
boxShadow: "0 2px 4px rgba(0,0,0,0.1)", // Add subtle shadow
backgroundColor: "#f0f0f0",
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
}}
/>
<Typography variant="h5" component="h2" style={{ marginTop: "12px" }}>
Expand Down
20 changes: 12 additions & 8 deletions aeye/app/(nav)/my/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { useState } from "react";
import { useState, useEffect } from "react";
import { useRecoilValue } from "recoil";
import { memberState } from "@/app/recoil-states";
import { Alert, Box, Grid, Switch, FormControlLabel } from "@mui/material";
Expand All @@ -21,19 +21,23 @@ function AddPhoneNumberInfo() {
);
}

function SubscribtionSwitch() {
function SubscriptionSwitch() {
const profile = useRecoilValue(memberState);
const [isSubscribed, setIsSubscribed] = useState(
profile?.subscribeDailyReport
const [isSubscribed, setIsSubscribed] = useState<boolean>(
profile?.subscribeDailyReport || false
);

useEffect(() => {
if (profile) {
setIsSubscribed(profile.subscribeDailyReport);
}
}, [profile]);

const handleToggle = () => {
setIsSubscribed(!isSubscribed);
fetchWithInterception("https://api.a-eye.live/member/subscribe", {
method: "PUT",
})
.then((response) => response.json())
.then((jsonData) => console.log(jsonData));
});
};
return (
<FormControlLabel
Expand All @@ -56,7 +60,7 @@ export default function MyPage() {
<Grid item xs={12} sm={8} md={6}>
<AddPhoneNumberInfo />
<ProfileAvatar />
<SubscribtionSwitch />
<SubscriptionSwitch />
<ProfileMenu />
</Grid>
</Grid>
Expand Down

0 comments on commit 38e5352

Please sign in to comment.