Skip to content

Commit

Permalink
Merge pull request #36 from TritonSE/Feature/anthonyp0329/backend-pro…
Browse files Browse the repository at this point in the history
…file-changes

Schema change + function to updateUserDetails
  • Loading branch information
Anthonyp0329 authored May 1, 2023
2 parents 9e8a595 + 7f2089d commit 4b9898e
Show file tree
Hide file tree
Showing 6 changed files with 1,103 additions and 2,169 deletions.
30 changes: 30 additions & 0 deletions SDCTA/src/api/consumer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
interface userDetails {
phone?: string;
address?: string;
city?: string;
state?: string;
zipCode?: string;
country?: string;
}

const updateUserDetails = async (
emailIn: string,
userDetails: userDetails
): Promise<Response> => {
const updateRequestOptions = {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(userDetails),
};

const requestLink = "http://localhost:3001/user/";

const response = await fetch(
requestLink.concat(emailIn),
updateRequestOptions
);

return response;
};

export { updateUserDetails };
20 changes: 19 additions & 1 deletion server/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const dataSchema = new mongoose.model(
new mongoose.Schema({
username: {
required: true,
unique: true,
unique: false,
type: String,
},
email: {
Expand All @@ -18,6 +18,24 @@ const dataSchema = new mongoose.model(
type: mongoose.Types.ObjectId,
ref: "Tier",
},
phone: {
type: String,
},
address: {
type: String,
},
city: {
type: String,
},
state: {
type: String,
},
zipCode: {
type: String,
},
country: {
type: String,
},
})
);

Expand Down
Loading

0 comments on commit 4b9898e

Please sign in to comment.