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

Split name into first and last name #1563

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/components/Input.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const Input = ({
name,
lastName,
type,
title,
placeholder,
Expand All @@ -21,6 +22,7 @@ const Input = ({
className="truncate disabled:border-0 border-b-2 border-black pl-3 w-full focus:outline-none placeholder:text-hackathon-gray-200 bg-transparent"
type={type}
name={name}
lastName={lastName}
placeholder={placeholder}
value={value}
maxLength={maxLength}
Expand Down
11 changes: 11 additions & 0 deletions src/components/form/Admin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@ import { STATUSES } from "@/data/admin/Admins";

const Admin = () => {
const { data: session } = useSession();

function extractFirstName(str) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. arrow function
  2. put this as a util and have 1 function return both the first and last name and use that everywhere

return str.trim().split(" ")[0];
}

function extractLastName(str) {
return str.trim().split(" ")[1];
}

const [admin, setAdmin] = useState({
...ATTRIBUTES,
name: session.user.name,
firstName: extractFirstName(session.user.name),
lastName: extractLastName(session.user.name),
email: session.user.email,
roles: session.user.roles,
form: "admins",
Expand Down
12 changes: 11 additions & 1 deletion src/components/form/Committee.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,22 @@ import { STATUSES } from "@/data/admin/Committees";

const Committee = () => {
const { data: session } = useSession();
function extractFirstName(str) {
return str.trim().split(" ")[0];
}

function extractLastName(str) {
return str.trim().split(" ")[1];
}

const [committee, setCommittee] = useState({
...ATTRIBUTES,
name: session.user.name,
firstName: extractFirstName(session.user.name),
lastName: extractLastName(session.user.name),
email: session.user.email,
roles: session.user.roles,
form: "committees",
form: "admins",
});

const handleSubmit = (setLoading, setState) => {
Expand Down
11 changes: 11 additions & 0 deletions src/components/form/Interest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@ import { STATUSES } from "@/data/admin/Interests";

const Interest = () => {
const { data: session } = useSession();

function extractFirstName(str) {
return str.trim().split(" ")[0];
}

function extractLastName(str) {
return str.trim().split(" ")[1];
}

const [interest, setInterest] = useState({
...ATTRIBUTES,
name: session.user.name,
firstName: extractFirstName(session.user.name),
lastName: extractLastName(session.user.name),
email: session.user.email,
roles: session.user.roles,
form: "interests",
Expand Down
11 changes: 10 additions & 1 deletion src/components/form/Judge.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,21 @@ import { STATUSES } from "@/data/admin/Judges.js";

const Judge = () => {
const { data: session } = useSession();
function extractFirstName(str) {
return str.trim().split(" ")[0];
}

function extractLastName(str) {
return str.trim().split(" ")[1];
}

const [judge, setJudge] = useState({
...ATTRIBUTES,
name: session.user.name,
firstName: extractFirstName(session.user.name),
lastName: extractLastName(session.user.name),
email: session.user.email,
roles: session.user.roles,
photo: session.user.photo ?? null,
form: "judges",
});

Expand Down
12 changes: 11 additions & 1 deletion src/components/form/Lead.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@ import { STATUSES } from "@/data/admin/Leads";

const Lead = () => {
const { data: session } = useSession();
function extractFirstName(str) {
return str.trim().split(" ")[0];
}

function extractLastName(str) {
return str.trim().split(" ")[1];
}

const [lead, setLead] = useState({
...ATTRIBUTES,
name: session.user.name,
roles: session.user.roles,
firstName: extractFirstName(session.user.name),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call the variables just first and last

lastName: extractLastName(session.user.name),
email: session.user.email,
roles: session.user.roles,
form: "leads",
});

Expand Down
10 changes: 10 additions & 0 deletions src/components/form/Mentor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ import { STATUSES } from "@/data/admin/Mentors.js";
const Mentor = () => {
const { data: session } = useSession();

function extractFirstName(str) {
return str.trim().split(" ")[0];
}

function extractLastName(str) {
return str.trim().split(" ")[1];
}

const [mentor, setMentor] = useState({
...ATTRIBUTES,
name: session.user.name,
firstName: extractFirstName(session.user.name),
lastName: extractLastName(session.user.name),
email: session.user.email,
roles: session.user.roles,
form: "mentors",
Expand Down
11 changes: 10 additions & 1 deletion src/components/form/Panelist.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,21 @@ import { STATUSES } from "@/data/admin/Panelists";

const Panel = () => {
const { data: session } = useSession();
function extractFirstName(str) {
return str.trim().split(" ")[0];
}

function extractLastName(str) {
return str.trim().split(" ")[1];
}

const [panel, setPanel] = useState({
...ATTRIBUTES,
name: session.user.name,
firstName: extractFirstName(session.user.name),
lastName: extractLastName(session.user.name),
email: session.user.email,
roles: session.user.roles,
photo: session.user.photo ?? null,
form: "panels",
});

Expand Down
10 changes: 10 additions & 0 deletions src/components/form/Participant.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@ import { STATUSES } from "@/data/admin/Participants.js";

const Participant = () => {
const { data: session } = useSession();
function extractFirstName(str) {
return str.trim().split(" ")[0];
}

function extractLastName(str) {
return str.trim().split(" ")[1];
}

const [participant, setParticipant] = useState({
...ATTRIBUTES,
name: session.user.name,
firstName: extractFirstName(session.user.name),
lastName: extractLastName(session.user.name),
email: session.user.email,
roles: session.user.roles,
form: "participants",
Expand Down
10 changes: 10 additions & 0 deletions src/components/form/Sponsor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@ import { STATUSES } from "@/data/admin/Sponsors";

const Sponsor = () => {
const { data: session } = useSession();
function extractFirstName(str) {
return str.trim().split(" ")[0];
}

function extractLastName(str) {
return str.trim().split(" ")[1];
}

const [sponsor, setSponsor] = useState({
...ATTRIBUTES,
name: session.user.name,
firstName: extractFirstName(session.user.name),
lastName: extractLastName(session.user.name),
email: session.user.email,
roles: session.user.roles,
form: "sponsors",
Expand Down
10 changes: 10 additions & 0 deletions src/components/form/Volunteer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ import { STATUSES } from "@/data/admin/Volunteers.js";
const Volunteer = () => {
const { data: session } = useSession();

function extractFirstName(str) {
return str.trim().split(" ")[0];
}

function extractLastName(str) {
return str.trim().split(" ")[1];
}

const [volunteer, setVolunteer] = useState({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for each form, when we submit, we need to remove the first and last separate and merge it back into just name so the DB remains the same

...ATTRIBUTES,
name: session.user.name,
firstName: extractFirstName(session.user.name),
lastName: extractLastName(session.user.name),
email: session.user.email,
roles: session.user.roles,
form: "volunteers",
Expand Down
1 change: 1 addition & 0 deletions src/components/form/form/Questions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const Questions = ({
{field.input === "input" && (
<Input
name={field.name}
lastName={field.lastName}
type={field.type}
title={field.title}
placeholder={field.placeholder}
Expand Down
9 changes: 9 additions & 0 deletions src/data/admin/Admins.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ export const COLUMNS = [
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "lastName",
header: "Last Name",
width: "w-3/12",
enableColumnFilter: true,
filterFn: "includesString",
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "email",
header: "Email",
Expand Down
9 changes: 9 additions & 0 deletions src/data/admin/Committees.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ export const COLUMNS = [
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "lastName",
header: "Last Name",
width: "w-3/12",
enableColumnFilter: true,
filterFn: "includesString",
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "email",
header: "Email",
Expand Down
9 changes: 9 additions & 0 deletions src/data/admin/Interests.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ export const COLUMNS = [
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "lastName",
header: "Last Name",
width: "w-3/12",
enableColumnFilter: true,
filterFn: "includesString",
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "email",
header: "Email",
Expand Down
9 changes: 9 additions & 0 deletions src/data/admin/Judges.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ export const COLUMNS = [
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "lastName",
header: "Last Name",
width: "w-3/12",
enableColumnFilter: true,
filterFn: "includesString",
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "email",
header: "Email",
Expand Down
9 changes: 9 additions & 0 deletions src/data/admin/Leads.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ export const COLUMNS = [
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "lastName",
header: "Last Name",
width: "w-3/12",
enableColumnFilter: true,
filterFn: "includesString",
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "email",
header: "Email",
Expand Down
9 changes: 9 additions & 0 deletions src/data/admin/Mentors.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ export const COLUMNS = [
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "lastName",
header: "Last Name",
width: "w-3/12",
enableColumnFilter: true,
filterFn: "includesString",
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "email",
header: "Email",
Expand Down
9 changes: 9 additions & 0 deletions src/data/admin/Panelists.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ export const COLUMNS = [
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "lastName",
header: "Last Name",
width: "w-3/12",
enableColumnFilter: true,
filterFn: "includesString",
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "email",
header: "Email",
Expand Down
9 changes: 9 additions & 0 deletions src/data/admin/Participants.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ export const COLUMNS = [
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "lastName",
header: "Last Name",
width: "w-3/12",
enableColumnFilter: true,
filterFn: "includesString",
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "email",
header: "Email",
Expand Down
9 changes: 9 additions & 0 deletions src/data/admin/Sponsors.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ export const COLUMNS = [
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "lastName",
header: "Last Name",
width: "w-3/12",
enableColumnFilter: true,
filterFn: "includesString",
searchable: true,
cell: ({ getValue }) => <div>{getValue()}</div>,
},
{
accessorKey: "email",
header: "Email",
Expand Down
Loading
Loading