mirror of
https://github.com/D4M13N-D3V/comissions-app-ui.git
synced 2025-03-14 08:15:08 +00:00
fix: name not being returned
This commit is contained in:
parent
565cb5dffb
commit
b9aed8f3bb
@ -2,13 +2,28 @@ import { getAccessToken, withApiAuthRequired, getSession } from '@auth0/nextjs-a
|
|||||||
|
|
||||||
export default withApiAuthRequired(async function sellerProfile(req, res) {
|
export default withApiAuthRequired(async function sellerProfile(req, res) {
|
||||||
const { accessToken } = await getAccessToken(req, res);
|
const { accessToken } = await getAccessToken(req, res);
|
||||||
const response = await fetch(process.env.NEXT_PUBLIC_API_URL+'/api/SellerProfile', {
|
if(req.method !== 'GET') {
|
||||||
headers: {
|
const response = await fetch(process.env.NEXT_PUBLIC_API_URL+'/api/SellerProfile', {
|
||||||
"Authorization": `Bearer ${accessToken}`
|
headers: {
|
||||||
}
|
"Authorization": `Bearer ${accessToken}`,
|
||||||
});
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
let result = await response.json();
|
method: "PUT",
|
||||||
res.status(200).json(result);
|
body: req.body
|
||||||
|
});
|
||||||
|
|
||||||
|
let result = await response.json();
|
||||||
|
res.status(200).json(result);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
const response = await fetch(process.env.NEXT_PUBLIC_API_URL+'/api/SellerProfile', {
|
||||||
|
headers: {
|
||||||
|
"Authorization": `Bearer ${accessToken}`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let result = await response.json();
|
||||||
|
res.status(200).json(result);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -11,10 +11,59 @@ import Divider from '@mui/material/Divider';
|
|||||||
|
|
||||||
const ArtistSettings = () => {
|
const ArtistSettings = () => {
|
||||||
const {user, isLoading} = useUser();
|
const {user, isLoading} = useUser();
|
||||||
|
|
||||||
|
const [name, setName] = useState("");
|
||||||
|
const [description, setDescription] = useState("");
|
||||||
|
const [social1, setSocial1] = useState("");
|
||||||
|
const [social2, setSocial2] = useState("");
|
||||||
|
const [social3, setSocial3] = useState("");
|
||||||
|
const [social4, setSocial4] = useState("");
|
||||||
|
const [guidelines, setGuidelines] = useState("");
|
||||||
|
const [saved, setSaved] = useState(false);
|
||||||
|
|
||||||
const [profileData, setSellerProfileData] = useState(null);
|
const [profileData, setSellerProfileData] = useState(null);
|
||||||
|
|
||||||
|
const handleDisplayNameChange = (event) => {
|
||||||
|
setName(event.target.value);
|
||||||
|
}
|
||||||
|
const handleBiographyChange = (event) => {
|
||||||
|
setDescription(event.target.value);
|
||||||
|
}
|
||||||
|
const handleSocial1Change = (event) => {
|
||||||
|
setSocial1(event.target.value);
|
||||||
|
}
|
||||||
|
const handleSocial2Change = (event) => {
|
||||||
|
setSocial2(event.target.value);
|
||||||
|
}
|
||||||
|
const handleSocial3Change = (event) => {
|
||||||
|
setSocial3(event.target.value);
|
||||||
|
}
|
||||||
|
const handleSocial4Change = (event) => {
|
||||||
|
setSocial4(event.target.value);
|
||||||
|
}
|
||||||
|
const handleGuidelinesChange = (event) => {
|
||||||
|
setGuidelines(event.target.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
const saveChanges = async () => {
|
||||||
|
var userResponse = await fetch('/api/artist/profile',{
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify({name: name, description: description, socialMeidaLink1: social1, socialMeidaLink2: social2, socialMeidaLink3: social3, socialMeidaLink4: social4, requestGuidelines: guidelines})
|
||||||
|
});
|
||||||
|
var user = await userResponse.json();
|
||||||
|
setSaved(true)
|
||||||
|
}
|
||||||
|
|
||||||
const getData = async () => {
|
const getData = async () => {
|
||||||
const profileResponse = await fetch('/api/artist/profile');
|
const profileResponse = await fetch('/api/artist/profile');
|
||||||
const sellerProfile = await profileResponse.json();
|
const sellerProfile = await profileResponse.json();
|
||||||
|
setDescription(sellerProfile["description"]);
|
||||||
|
setName(sellerProfile["name"]);
|
||||||
|
setSocial1(sellerProfile["socialMeidaLink1"]);
|
||||||
|
setSocial2(sellerProfile["socialMeidaLink2"]);
|
||||||
|
setSocial3(sellerProfile["socialMeidaLink3"]);
|
||||||
|
setSocial4(sellerProfile["socialMeidaLink4"]);
|
||||||
|
setGuidelines(sellerProfile["requestGuidelines"]);
|
||||||
setSellerProfileData(sellerProfile);
|
setSellerProfileData(sellerProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,34 +80,34 @@ const ArtistSettings = () => {
|
|||||||
<Typography variant="h5" gutterBottom>General Settings</Typography>
|
<Typography variant="h5" gutterBottom>General Settings</Typography>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} md={4} >
|
<Grid item xs={12} md={4} >
|
||||||
<Button variant="contained" color="success" fullWidth>Save Changes</Button>
|
<Button variant="contained" onClick={saveChanges} color="success" fullWidth>{saved ? "Saved" : "Save Changes"}</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} md={12} >
|
<Grid item xs={12} md={12} >
|
||||||
<Grid container spacing={2} sx={{paddingTop:"2%"}}>
|
<Grid container spacing={2} sx={{paddingTop:"2%"}}>
|
||||||
<Grid item xs={12} md={12} sx={{paddingTop:"2%"}}>
|
<Grid item xs={12} md={12} sx={{paddingTop:"2%"}}>
|
||||||
<TextField id="outlined-basic" label="Shop Name" size="small" variant="outlined" fullWidth />
|
<TextField id="outlined-basic" label="Shop Name" value={name} onChange={handleDisplayNameChange} size="small" variant="outlined" fullWidth />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} md={12} sx={{paddingTop:"2%"}}>
|
<Grid item xs={12} md={12} sx={{paddingTop:"2%"}}>
|
||||||
<TextField id="outlined-basic" multiline rows={7} size="small" label="Shop Description" variant="outlined" fullWidth />
|
<TextField id="outlined-basic" multiline rows={7} value={description} onChange={handleBiographyChange} size="small" label="Shop Description" variant="outlined" fullWidth />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} md={12} >
|
<Grid item xs={12} md={12} >
|
||||||
<Grid container spacing={2} sx={{paddingTop:"2%"}}>
|
<Grid container spacing={2} sx={{paddingTop:"2%"}}>
|
||||||
<Grid item xs={12} md={6} sx={{paddingTop:"2%"}}>
|
<Grid item xs={12} md={6} sx={{paddingTop:"2%"}}>
|
||||||
<TextField id="outlined-basic" label="Social Media 1" type="url" size="small" variant="outlined" fullWidth />
|
<TextField id="outlined-basic" label="Social Media 1" value={social1} onChange={handleSocial1Change} type="url" size="small" variant="outlined" fullWidth />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} md={6} sx={{paddingTop:"2%"}}>
|
<Grid item xs={12} md={6} sx={{paddingTop:"2%"}}>
|
||||||
<TextField id="outlined-basic" label="Social Media 2" type="url" size="small" variant="outlined" fullWidth />
|
<TextField id="outlined-basic" label="Social Media 2" value={social2} onChange={handleSocial2Change} type="url" size="small" variant="outlined" fullWidth />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} md={6} sx={{paddingTop:"2%"}}>
|
<Grid item xs={12} md={6} sx={{paddingTop:"2%"}}>
|
||||||
<TextField id="outlined-basic" label="Social Media 3" type="url" size="small" variant="outlined" fullWidth />
|
<TextField id="outlined-basic" label="Social Media 3" value={social3} onChange={handleSocial3Change} type="url" size="small" variant="outlined" fullWidth />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} md={6} sx={{paddingTop:"2%"}}>
|
<Grid item xs={12} md={6} sx={{paddingTop:"2%"}}>
|
||||||
<TextField id="outlined-basic" label="Social Media 4" type="url" size="small" variant="outlined" fullWidth />
|
<TextField id="outlined-basic" label="Social Media 4" value={social4} onChange={handleSocial4Change} type="url" size="small" variant="outlined" fullWidth />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} md={12} sx={{paddingTop:"2%"}}>
|
<Grid item xs={12} md={12} sx={{paddingTop:"2%"}}>
|
||||||
<TextField id="outlined-basic" multiline rows={5} size="small" label="Your request guidelines" variant="outlined" fullWidth />
|
<TextField id="outlined-basic" multiline rows={5} size="small" label="Your request guidelines" value={guidelines} onChange={handleGuidelinesChange} variant="outlined" fullWidth />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user