@vonaffenfels/contentful-teasermanager 1.0.37 → 1.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonaffenfels/contentful-teasermanager",
3
- "version": "1.0.37",
3
+ "version": "1.0.39",
4
4
  "scripts": {
5
5
  "prepublish": "yarn run build",
6
6
  "dev": "yarn run start",
@@ -98,7 +98,7 @@
98
98
  "@vonaffenfels/slate-editor": "^1.0.35",
99
99
  "webpack": "5.88.2"
100
100
  },
101
- "gitHead": "d615f4feaf8cd8d3f04c0f102887cac6f5e0659f",
101
+ "gitHead": "b0d5a3885e533ce76b5dcbd962125ceee42c073a",
102
102
  "publishConfig": {
103
103
  "access": "public"
104
104
  }
@@ -123,11 +123,26 @@ export const NewestArticles = ({
123
123
  <EntityList>
124
124
  {loading && <Spinner/>}
125
125
  {!loading && data.items.map((entry) => {
126
+ const isCurrentlySelectedInOtherSlot = !! Object.keys(slotState || {}).find(slot => slotState[slot] === entry.sys.id && slot !== slotId);
127
+ const isCurrentlySelectedInSlot = !!Object.keys(slotState || {}).find(slot => slotState[slot] === entry.sys.id && slot === slotId);
128
+
129
+ let status = "draft";
130
+ if (entry.sys.publishedAt) {
131
+ status = "published";
132
+ }
133
+
134
+ let description = "";
135
+ if (isCurrentlySelectedInSlot) {
136
+ description = "Aktuell ausgewählt";
137
+ } else if (isCurrentlySelectedInOtherSlot) {
138
+ description = "Aktuell in anderem Teaser ausgewählt"
139
+ }
140
+
126
141
  return <div
127
142
  key={entry.sys.id}
128
143
  className={classNames({
129
- "border-2 border-red-300": Object.keys(slotState || {}).find(slot => slotState[slot] === entry.sys.id && slot !== slotId),
130
- "border-2 border-green-300": Object.keys(slotState || {}).find(slot => slotState[slot] === entry.sys.id && slot === slotId),
144
+ "border-2 border-red-300": isCurrentlySelectedInSlot,
145
+ "border-2 border-green-300": isCurrentlySelectedInOtherSlot,
131
146
  })}
132
147
  >
133
148
  <EntityList.Item
@@ -136,8 +151,8 @@ export const NewestArticles = ({
136
151
  title={entry.fields.title?.de}
137
152
  onClick={() => onEntryClick(entry)}
138
153
  thumbnailUrl={getArticleThumbnailUrl(entry)}
139
- description={""}
140
- status={entry.sys.publishedAt ? "published" : "draft"}
154
+ description={description}
155
+ status={status}
141
156
  />
142
157
  </div>
143
158
  })}
@@ -8,13 +8,13 @@ const Dialog = ({sdk, portals, getArticleThumbnailUrl}) => {
8
8
  sdk.close(entry);
9
9
  }
10
10
 
11
- const loadSlotStateForPage = async (date) => {
11
+ const loadSlotStateForPage = async () => {
12
12
  try {
13
13
  const apiRoot = sdk.parameters.instance.apiRoot;
14
14
  const portal = sdk.parameters.invocation.portal;
15
15
  const pageId = sdk.parameters.invocation.entryId;
16
16
  const date = sdk.parameters.invocation.date;
17
- const teasermanagerUrl = `${apiRoot}/api/findStateForPage?project=${portal}&page=${pageId}&date=${date}`;
17
+ const teasermanagerUrl = `${apiRoot}/api/findStateForPage?project=${portal}&page=${pageId}&date=${date.toISOString()}`;
18
18
  const response = await fetch(teasermanagerUrl).then(res => res.json());
19
19
 
20
20
  if (response?.message) {
@@ -29,7 +29,7 @@ const Dialog = ({sdk, portals, getArticleThumbnailUrl}) => {
29
29
 
30
30
  useEffect(() => {
31
31
  loadSlotStateForPage().then(setSlotState);
32
- }, []);
32
+ }, [sdk.parameters.invocation]);
33
33
 
34
34
  return <div style={{backgroundColor: "#FFFFFF", minHeight: "100vh"}}>
35
35
  <NewestArticles sdk={sdk} onEntryClick={selectEntry} slotState={slotState} getArticleThumbnailUrl={getArticleThumbnailUrl} portals={portals}/>
@@ -91,7 +91,7 @@ const Entry = ({sdk}) => {
91
91
  const loadSlotStateForPage = async (date) => {
92
92
  try {
93
93
  const apiRoot = sdk.parameters.instance.apiRoot;
94
- const teasermanagerUrl = `${apiRoot}/api/findStateForPage?project=${portal}&page=${sdk.entry.getSys().id}&date=${date}`;
94
+ const teasermanagerUrl = `${apiRoot}/api/findStateForPage?project=${portal}&page=${sdk.entry.getSys().id}&date=${date.toISOString()}`;
95
95
  const response = await fetch(teasermanagerUrl).then(res => res.json());
96
96
 
97
97
  if (response?.message) {