Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
48 changes: 28 additions & 20 deletions components/Admin/FormsTable/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,35 @@ import { CloseOutlined, DeleteOutlined, EditOutlined, SaveOutlined } from '@ant-
import { useForms } from '../Context';
import { useEditing } from './Context';

function Actions({ record }) {
function DeleteEntry({ record }) {
const [isVisible, setVisible] = useState(false);
const [loading, setLoading] = useState(false);
const { dispatch: dispatchForms } = useForms();

const confirm = () => {
setLoading(true);
dispatchForms({ type: 'DELETE', slug: record.slug });
setVisible(false);
setLoading(false);
};

return (
<Popconfirm
title="Are you sure?"
okText="Yes"
cancelText="No"
visible={isVisible}
onConfirm={confirm}
okButtonProps={{ loading: loading }}
onCancel={() => setVisible(false)}>
<Button onClick={() => setVisible(true)} type="link" danger>
<DeleteOutlined />
</Button>
</Popconfirm>
);
}

function Actions({ record }) {
const { forms, dispatch: dispatchForms } = useForms();
const { editing, dispatch: dispatchEditing } = useEditing();

Expand All @@ -33,13 +59,6 @@ function Actions({ record }) {
}
};

const confirmDelete = () => {
setLoading(true);
dispatchForms({ type: 'DELETE', slug: record.slug });
setVisible(false);
setLoading(false);
};

return record._id === editing.key ? (
<Space>
<Button onClick={() => save(record._id)} type="link">
Expand All @@ -54,18 +73,7 @@ function Actions({ record }) {
<Button disabled={editing.key !== ''} onClick={() => edit(record)} type="link">
<EditOutlined />
</Button>
<Popconfirm
title="Are you sure?"
okText="Yes"
cancelText="No"
visible={isVisible}
onConfirm={confirmDelete}
okButtonProps={{ loading: loading }}
onCancel={() => setVisible(false)}>
<Button onClick={() => setVisible(true)} type="link" danger>
<DeleteOutlined />
</Button>
</Popconfirm>
<DeleteEntry record={record} />
</Space>
);
}
Expand Down
2 changes: 0 additions & 2 deletions components/Admin/FormsTable/Context/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { useContext, createContext } from 'react';
export const EditingContext = createContext();

export const reducer = async (editing, action) => {
// {key: '',
// form: Form.useForm()}
const { type, key } = action;

switch (type) {
Expand Down
3 changes: 0 additions & 3 deletions components/Admin/LinksTable/NewLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ function NewLink() {
]}>
<Input placeholder="https://cesium.link" />
</Item>
<Item name="description" label="Description">
<Input.TextArea />
</Item>
<Item name="attention" valuePropName="checked">
<Checkbox defaultChecked={false}>Attention</Checkbox>
</Item>
Expand Down
5 changes: 0 additions & 5 deletions components/Admin/LinksTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ const columns = [
dataIndex: 'title',
className: styles.visible
},
{
title: 'Description',
dataIndex: 'description',
className: styles.visible
},
{
title: 'Attention',
dataIndex: 'attention',
Expand Down
21 changes: 0 additions & 21 deletions data/links.yml

This file was deleted.

1 change: 0 additions & 1 deletion models/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import mongoose, { Schema } from 'mongoose';

const Link = new Schema({
title: { type: String, required: true },
description: { type: String, required: false },
url: { type: String, required: true },
emoji: { type: String, required: false },
attention: { type: Boolean, default: false },
Expand Down
1 change: 0 additions & 1 deletion pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Card from '../components/Card';
import dbConnect from '../utils/database';
import Link from '../models/Link';

// import links from "../data/links.yml";
import styles from '../styles/Home.module.css';

export async function getServerSideProps() {
Expand Down