Skip to content
This repository has been archived by the owner on Feb 22, 2025. It is now read-only.

Commit

Permalink
feat(buildteams): ✨ Socials Edit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nudelsuppe42 committed Dec 30, 2023
1 parent eb3cecd commit c0a5e5c
Showing 1 changed file with 41 additions and 23 deletions.
64 changes: 41 additions & 23 deletions src/pages/teams/[team]/manage/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
Select,
Switch,
Text,
TextInput,
Textarea,
TextInput,
Tooltip,
useMantineColorScheme,
useMantineTheme,
Expand Down Expand Up @@ -71,6 +71,35 @@ const Settings = ({ data: tempData }: any) => {
}
});
};
const handleSaveSocials = (e: any) => {
e.preventDefault();
fetch(process.env.NEXT_PUBLIC_API_URL + `/buildteams/${data.id}/socials`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + user.token,
},
body: JSON.stringify({ socials: data.socials }),
})
.then((res) => res.json())
.then((res) => {
if (res.errors) {
showNotification({
title: 'Update failed',
message: res.error,
color: 'red',
});
} else {
showNotification({
title: 'Socials updated',
message: 'All Data has been saved',
color: 'green',
icon: <IconCheck />,
});
// setData({ ...data, ...res });
}
});
};

const handleUpdate = (id: string, d: any) => {
const updatedData = { ...data };
Expand Down Expand Up @@ -305,17 +334,8 @@ const Settings = ({ data: tempData }: any) => {
</Tooltip>
</form>
<Divider mt="md" />
<h3>Socials</h3>
<form onSubmit={handleSave}>
<Alert
variant="light"
color="yellow"
mb="md"
icon={<IconAlertCircle />}
title="Editing Social Links currently does not work"
>
If there are any bugged social links on the build team page right now, message us.
</Alert>
<Group justify={'space-between'}>
<h3>Socials</h3>
<Button
leftSection={<IconPlus />}
mb="md"
Expand All @@ -324,6 +344,8 @@ const Settings = ({ data: tempData }: any) => {
>
Add Social Link
</Button>
</Group>
<form onSubmit={handleSave}>
{data.socials.map((social: any, i: number) => (
<Group
grow
Expand All @@ -348,14 +370,10 @@ const Settings = ({ data: tempData }: any) => {
]}
defaultValue={social.icon}
disabled={!allowSocial}
onChange={(e) => handleUpdateSocial(i, 'icon', e)}
/>
<TextInput
required
label="Social Name"
defaultValue={social.name}
disabled={!allowSocial}
onChange={(e) => handleUpdateSocial(i, 'name', e.target.value)}
onChange={(e) => {
handleUpdateSocial(i, 'icon', e);
handleUpdateSocial(i, 'name', e);
}}
/>
<TextInput
required
Expand All @@ -364,19 +382,19 @@ const Settings = ({ data: tempData }: any) => {
disabled={!allowSocial}
onChange={(e) => handleUpdateSocial(i, 'url', e.target.value)}
/>
<Button
{/* <Button
variant="outline"
style={{ width: '80%' }}
leftSection={<IconTrash />}
disabled={!allowSocial}
onClick={() => handleDeleteSocial(social.id)}
>
Delete
</Button>
</Button> */}
</Group>
))}
<br />
<Button type="submit" disabled={!allowSocial}>
<Button type="submit" disabled={!allowSocial} onClick={handleSaveSocials}>
Save
</Button>
</form>
Expand Down

0 comments on commit c0a5e5c

Please sign in to comment.